diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 389acb5a07834..5d875cbc06367 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4397,7 +4397,6 @@ static_library("browser") {
"//chrome/browser/ui/webui/side_panel/companion:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/customize_chrome:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/reading_list:mojo_bindings",
- "//chrome/browser/ui/webui/side_panel/search_companion:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/user_notes:mojo_bindings",
"//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/tab_strip:mojo_bindings",
diff --git a/chrome/browser/chrome_browser_interface_binders.cc b/chrome/browser/chrome_browser_interface_binders.cc
index 5bc068b40e3e2..3b931dd8c44f7 100644
--- a/chrome/browser/chrome_browser_interface_binders.cc
+++ b/chrome/browser/chrome_browser_interface_binders.cc
@@ -174,7 +174,6 @@
#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list.mojom.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/user_notes/user_notes.mojom.h"
#include "chrome/browser/ui/webui/side_panel/user_notes/user_notes_side_panel_ui.h"
#include "chrome/browser/ui/webui/tab_search/tab_search.mojom.h"
@@ -1058,18 +1057,11 @@ void PopulateChromeWebUIFrameBinders(
RegisterWebUIControllerInterfaceBinder<
shopping_list::mojom::ShoppingListHandlerFactory, BookmarksSidePanelUI>(
map);
-
if (base::FeatureList::IsEnabled(features::kPowerBookmarksSidePanel)) {
RegisterWebUIControllerInterfaceBinder<
image_service::mojom::ImageServiceHandler, BookmarksSidePanelUI>(map);
}
- if (base::FeatureList::IsEnabled(features::kSidePanelSearchCompanion)) {
- RegisterWebUIControllerInterfaceBinder<
- side_panel::mojom::SearchCompanionPageHandlerFactory,
- SearchCompanionSidePanelUI>(map);
- }
-
if (customize_chrome::IsSidePanelEnabled()) {
RegisterWebUIControllerInterfaceBinder<
side_panel::mojom::CustomizeChromePageHandlerFactory,
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn
index d6acf006aaf1e..535f573822f01 100644
--- a/chrome/browser/resources/BUILD.gn
+++ b/chrome/browser/resources/BUILD.gn
@@ -50,7 +50,6 @@ group("resources") {
"side_panel/history_clusters:resources",
"side_panel/read_anything:resources",
"side_panel/reading_list:resources",
- "side_panel/search_companion:resources",
"side_panel/shared:resources",
"side_panel/user_notes:resources",
"signin:resources",
diff --git a/chrome/browser/resources/side_panel/search_companion/BUILD.gn b/chrome/browser/resources/side_panel/search_companion/BUILD.gn
deleted file mode 100644
index 0a3d908a09b46..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/BUILD.gn
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2023 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//ui/webui/resources/tools/build_webui.gni")
-
-assert(!is_android)
-
-build_webui("build") {
- grd_prefix = "side_panel_search_companion"
-
- static_files = [ "search_companion.html" ]
-
- web_component_files = [ "app.ts" ]
-
- non_web_component_files = [ "search_companion_api_proxy.ts" ]
-
- mojo_files_deps = [ "//chrome/browser/ui/webui/side_panel/search_companion:mojo_bindings_ts__generator" ]
- mojo_files = [ "$root_gen_dir/chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom-webui.ts" ]
-
- ts_deps = [
- "//third_party/polymer/v3_0:library",
- "//ui/webui/resources/js:build_ts",
- "//ui/webui/resources/mojo:build_ts",
- ]
-}
diff --git a/chrome/browser/resources/side_panel/search_companion/OWNERS b/chrome/browser/resources/side_panel/search_companion/OWNERS
deleted file mode 100644
index f23f87f662745..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-stanfield@google.com
-
-file://components/lens/OWNERS
diff --git a/chrome/browser/resources/side_panel/search_companion/app.html b/chrome/browser/resources/side_panel/search_companion/app.html
deleted file mode 100644
index ca45915c25f24..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/app.html
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
Current page:
[[currentUrl_]]
-
Suggest response:
[[currentSuggestResponse_]]
-
Content annotations:
[[currentContentAnnotations_]]
-
Viewport images:
[[currentViewportImages_]]
-
diff --git a/chrome/browser/resources/side_panel/search_companion/app.ts b/chrome/browser/resources/side_panel/search_companion/app.ts
deleted file mode 100644
index 1a2eafff1c520..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/app.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import '../strings.m.js';
-
-import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
-
-import {getTemplate} from './app.html.js';
-import {SearchCompanionApiProxy, SearchCompanionApiProxyImpl} from './search_companion_api_proxy.js';
-
-export interface SearchCompanionAppElement {
- $: {};
-}
-
-export class SearchCompanionAppElement extends PolymerElement {
- static get is() {
- return 'search-companion-app';
- }
-
- static get template() {
- return getTemplate();
- }
-
- static get properties() {
- return {};
- }
-
- private searchCompanionApi_: SearchCompanionApiProxy =
- SearchCompanionApiProxyImpl.getInstance();
- private currentUrl_: string = 'No new page updates';
- private currentSuggestResponse_: string;
- private currentContentAnnotations_: string;
- private currentViewportImages_: string;
-
- override connectedCallback() {
- super.connectedCallback();
-
- // Setup data listeners
- this.searchCompanionApi_.callbackRouter.onURLChanged.addListener(
- (newUrl: string) => {
- this.currentUrl_ = newUrl;
- });
- this.searchCompanionApi_.callbackRouter.onNewZeroSuggestPrefixData
- .addListener((suggestResponse: string) => {
- this.currentSuggestResponse_ = suggestResponse;
- });
- this.searchCompanionApi_.callbackRouter
- .onNewOptimizationGuidePageAnnotations.addListener(
- (contentAnnotations: string) => {
- this.currentContentAnnotations_ = contentAnnotations;
- });
- this.searchCompanionApi_.callbackRouter.onNewViewportImages.addListener(
- (imagesString: string) => {
- this.currentViewportImages_ = imagesString;
- });
-
- this.searchCompanionApi_.showUi();
- }
-}
-declare global {
- interface HTMLElementTagNameMap {
- 'search-companion-app': SearchCompanionAppElement;
- }
-}
-customElements.define(SearchCompanionAppElement.is, SearchCompanionAppElement);
\ No newline at end of file
diff --git a/chrome/browser/resources/side_panel/search_companion/search_companion.html b/chrome/browser/resources/side_panel/search_companion/search_companion.html
deleted file mode 100644
index e3973c982dadb..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/search_companion.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/chrome/browser/resources/side_panel/search_companion/search_companion_api_proxy.ts b/chrome/browser/resources/side_panel/search_companion/search_companion_api_proxy.ts
deleted file mode 100644
index 9e9696a3253d9..0000000000000
--- a/chrome/browser/resources/side_panel/search_companion/search_companion_api_proxy.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import {SearchCompanionPageCallbackRouter, SearchCompanionPageHandlerFactory, SearchCompanionPageHandlerRemote} from './search_companion.mojom-webui.js';
-
-let instance: SearchCompanionApiProxy|null = null;
-
-export interface SearchCompanionApiProxy {
- callbackRouter: SearchCompanionPageCallbackRouter;
- showUi(): void;
-}
-
-export class SearchCompanionApiProxyImpl implements SearchCompanionApiProxy {
- handler: SearchCompanionPageHandlerRemote;
- callbackRouter: SearchCompanionPageCallbackRouter;
-
- constructor() {
- this.handler = new SearchCompanionPageHandlerRemote();
- this.callbackRouter = new SearchCompanionPageCallbackRouter();
-
- const factory = SearchCompanionPageHandlerFactory.getRemote();
- factory.createSearchCompanionPageHandler(
- this.handler.$.bindNewPipeAndPassReceiver(),
- this.callbackRouter.$.bindNewPipeAndPassRemote());
- }
-
- showUi() {
- this.handler.showUI();
- }
-
- static getInstance() {
- return instance || (instance = new SearchCompanionApiProxyImpl());
- }
-
- static setInstance(obj: SearchCompanionApiProxy) {
- instance = obj;
- }
-}
\ No newline at end of file
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index e601f8575e09a..659d3568f49e7 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -1706,10 +1706,6 @@ static_library("ui") {
"webui/side_panel/reading_list/reading_list_page_handler.h",
"webui/side_panel/reading_list/reading_list_ui.cc",
"webui/side_panel/reading_list/reading_list_ui.h",
- "webui/side_panel/search_companion/search_companion_page_handler.cc",
- "webui/side_panel/search_companion/search_companion_page_handler.h",
- "webui/side_panel/search_companion/search_companion_side_panel_ui.cc",
- "webui/side_panel/search_companion/search_companion_side_panel_ui.h",
"webui/side_panel/user_notes/user_notes_page_handler.cc",
"webui/side_panel/user_notes/user_notes_page_handler.h",
"webui/side_panel/user_notes/user_notes_side_panel_ui.cc",
@@ -1824,7 +1820,6 @@ static_library("ui") {
"//chrome/browser/ui/webui/side_panel/companion:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/customize_chrome:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/reading_list:mojo_bindings",
- "//chrome/browser/ui/webui/side_panel/search_companion:mojo_bindings",
"//chrome/browser/ui/webui/side_panel/user_notes:mojo_bindings",
"//chrome/browser/ui/webui/tab_search:mojo_bindings",
"//chrome/browser/ui/webui/tab_strip:mojo_bindings",
diff --git a/chrome/browser/ui/browser_element_identifiers.cc b/chrome/browser/ui/browser_element_identifiers.cc
index b87ee60bf2008..b0e0848a3cab0 100644
--- a/chrome/browser/ui/browser_element_identifiers.cc
+++ b/chrome/browser/ui/browser_element_identifiers.cc
@@ -32,7 +32,6 @@ DEFINE_ELEMENT_IDENTIFIER_VALUE(kPasswordsOmniboxKeyIconElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kPriceTrackingChipElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kPriceTrackingBookmarkViewElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kReadLaterSidePanelWebViewElementId);
-DEFINE_ELEMENT_IDENTIFIER_VALUE(kSearchCompanionSidePanelWebViewElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kSidePanelButtonElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kSidePanelElementId);
DEFINE_ELEMENT_IDENTIFIER_VALUE(kSidePanelCloseButtonElementId);
diff --git a/chrome/browser/ui/browser_element_identifiers.h b/chrome/browser/ui/browser_element_identifiers.h
index 2a47d39ce5680..9b05fac839745 100644
--- a/chrome/browser/ui/browser_element_identifiers.h
+++ b/chrome/browser/ui/browser_element_identifiers.h
@@ -48,7 +48,6 @@ DECLARE_ELEMENT_IDENTIFIER_VALUE(kSidePanelComboboxElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kSidePanelOpenInNewTabButtonElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kSidePanelReadingListUnreadElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kSavePasswordComboboxElementId);
-DECLARE_ELEMENT_IDENTIFIER_VALUE(kSearchCompanionSidePanelWebViewElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kSideSearchButtonElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kSideSearchWebViewElementId);
DECLARE_ELEMENT_IDENTIFIER_VALUE(kTabAlertIndicatorButtonElementId);
diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc
index 64e2a65797829..503e3d2ada863 100644
--- a/chrome/browser/ui/ui_features.cc
+++ b/chrome/browser/ui/ui_features.cc
@@ -120,9 +120,6 @@ BASE_FEATURE(kSidePanelJourneysQueryless,
"SidePanelJourneysQueryless",
base::FEATURE_DISABLED_BY_DEFAULT);
-BASE_FEATURE(kSidePanelSearchCompanion,
- "SidePanelSearchCompanion",
- base::FEATURE_DISABLED_BY_DEFAULT);
#if !defined(ANDROID)
// This differs from the search companion by providing a separate WebUI that
// contains untrusted content in an iframe.
diff --git a/chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.cc b/chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.cc
index a9ba0a9a65d49..089a3b4245f5e 100644
--- a/chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.cc
+++ b/chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/ui/views/side_panel/side_panel_registry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_web_ui_view.h"
#include "chrome/browser/ui/webui/side_panel/companion/companion_side_panel_untrusted_ui.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h"
#include "chrome/common/webui_url_constants.h"
SearchCompanionSidePanelCoordinator::SearchCompanionSidePanelCoordinator(
@@ -39,34 +38,22 @@ void SearchCompanionSidePanelCoordinator::
std::unique_ptr
SearchCompanionSidePanelCoordinator::CreateCompanionWebView() {
- if (base::FeatureList::IsEnabled(features::kSidePanelCompanion)) {
- auto wrapper =
- std::make_unique>(
- GURL(chrome::kChromeUIUntrustedCompanionSidePanelURL),
- GetBrowserView()->GetProfile(),
- /*webui_resizes_host=*/false,
- /*esc_closes_ui=*/false);
- auto* raw_wrapper = wrapper.get();
- auto companion_web_view =
- std::make_unique>(
- base::RepeatingClosure(), base::RepeatingClosure(),
- std::move(wrapper));
- // Need to set browser after SidePanelWebUIViewT is constructed since it
- // creates the WebUIController. The WebUI needs a Browser pointer in order
- // to observe changes to the tab strip model.
- raw_wrapper->GetWebUIController()->GetWeakPtr()->set_browser(browser_);
- return companion_web_view;
- }
-
- auto search_companion_web_view =
- std::make_unique>(
+ auto wrapper =
+ std::make_unique>(
+ GURL(chrome::kChromeUIUntrustedCompanionSidePanelURL),
+ GetBrowserView()->GetProfile(),
+ /*webui_resizes_host=*/false,
+ /*esc_closes_ui=*/false);
+ auto* raw_wrapper = wrapper.get();
+ auto companion_web_view =
+ std::make_unique>(
base::RepeatingClosure(), base::RepeatingClosure(),
- std::make_unique>(
- GURL(chrome::kChromeUISearchCompanionSidePanelURL),
- GetBrowserView()->GetProfile(),
- /*webui_resizes_host=*/false,
- /*esc_closes_ui=*/false));
- return search_companion_web_view;
+ std::move(wrapper));
+ // Need to set browser after SidePanelWebUIViewT is constructed since it
+ // creates the WebUIController. The WebUI needs a Browser pointer in order
+ // to observe changes to the tab strip model.
+ raw_wrapper->GetWebUIController()->GetWeakPtr()->set_browser(browser_);
+ return companion_web_view;
}
bool SearchCompanionSidePanelCoordinator::Show() {
diff --git a/chrome/browser/ui/views/side_panel/side_panel_util.cc b/chrome/browser/ui/views/side_panel/side_panel_util.cc
index 5f2f8661427f4..fdae3203e888e 100644
--- a/chrome/browser/ui/views/side_panel/side_panel_util.cc
+++ b/chrome/browser/ui/views/side_panel/side_panel_util.cc
@@ -92,8 +92,7 @@ void SidePanelUtil::PopulateGlobalEntries(Browser* browser,
}
// Create Search Companion coordinator.
- if (base::FeatureList::IsEnabled(features::kSidePanelSearchCompanion) ||
- base::FeatureList::IsEnabled(features::kSidePanelCompanion)) {
+ if (base::FeatureList::IsEnabled(features::kSidePanelCompanion)) {
SearchCompanionSidePanelCoordinator::GetOrCreateForBrowser(browser)
->CreateAndRegisterEntriesForExistingWebContents(
browser->tab_strip_model());
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index d2f109f62f3f5..4389690b0fff2 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -164,7 +164,6 @@
#include "chrome/browser/ui/webui/side_panel/history_clusters/history_clusters_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/read_anything/read_anything_ui.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h"
#include "chrome/browser/ui/webui/side_panel/user_notes/user_notes_side_panel_ui.h"
#include "chrome/browser/ui/webui/signin/sync_confirmation_ui.h"
#include "chrome/browser/ui/webui/support_tool/support_tool_ui.h"
@@ -927,9 +926,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI;
if (url.host_piece() == chrome::kChromeUIBookmarksSidePanelHost)
return &NewWebUI;
- if (url.host_piece() == chrome::kChromeUISearchCompanionSidePanelHost) {
- return &NewWebUI;
- }
if (url.host_piece() == chrome::kChromeUICustomizeChromeSidePanelHost &&
customize_chrome::IsSidePanelEnabled()) {
return &NewWebUI;
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/BUILD.gn b/chrome/browser/ui/webui/side_panel/search_companion/BUILD.gn
deleted file mode 100644
index 42e59c0c95d08..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/BUILD.gn
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2023 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//mojo/public/tools/bindings/mojom.gni")
-
-# Feature dependent on side panel only available on desktop.
-assert(!is_android)
-
-mojom("mojo_bindings") {
- sources = [ "search_companion.mojom" ]
- webui_module_path = "/"
- use_typescript_sources = true
- public_deps = [
- "//mojo/public/mojom/base",
- "//ui/base/mojom",
- "//ui/gfx/geometry/mojom",
- "//url/mojom:url_mojom_gurl",
- ]
-}
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/OWNERS b/chrome/browser/ui/webui/side_panel/search_companion/OWNERS
deleted file mode 100644
index b6d1ce7a4d9c6..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-file://components/lens/OWNERS
-
-per-file *.mojom=set noparent
-per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom b/chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom
deleted file mode 100644
index 052ea61cdb6d7..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-module side_panel.mojom;
-
-// Factory method for creating a new WebUI page handler.
-interface SearchCompanionPageHandlerFactory {
- // The WebUI calls this method when the page is first initialized.
- CreateSearchCompanionPageHandler(
- pending_receiver handler,
- pending_remote page);
-};
-
-// Browser-side handler for requests from WebUI page. (TypeScript -> C++)
-interface SearchCompanionPageHandler {
- // Notify the backend that the UI is ready to be shown.
- ShowUI();
-};
-
-// WebUI page handler for request from Browser side. (C++ -> TypeScript)
-interface SearchCompanionPage {
- // Pass the current main content URL to frontend
- OnURLChanged(string new_url);
-
- // Pass the Zero Suggest Prefix data to frontend
- // TODO(b/268286065): Use actual struct instead of string
- OnNewZeroSuggestPrefixData(string suggest_response);
-
- // Pass the optimization guide page annotations to the frontend
- // TODO(b/268286065): Use actual struct instead of string
- OnNewOptimizationGuidePageAnnotations(string content_annotations);
-
- // Pass the current viewport images to the frontend
- // TODO(b/268286065): Pass actual Image struct instead of assembling a string
- OnNewViewportImages(string images_string);
-};
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.cc b/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.cc
deleted file mode 100644
index b2ce6101dc4ea..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.cc
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.h"
-
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/autocomplete/zero_suggest_cache_service_factory.h"
-#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
-#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h"
-#include "components/optimization_guide/core/optimization_guide_features.h"
-#include "components/optimization_guide/proto/page_entities_metadata.pb.h"
-#include "ui/base/resource/resource_bundle.h"
-
-#include "chrome/common/chrome_isolated_world_ids.h"
-#include "components/grit/components_resources.h"
-
-using optimization_guide::proto::PageEntitiesMetadata;
-
-constexpr base::TimeDelta kTimerInterval = base::Seconds(5);
-
-namespace {
-std::string ContentAnnotationsToString(
- const PageEntitiesMetadata& entities_metadata) {
- std::string content_annotation_string = "";
- for (const auto& category : entities_metadata.categories()) {
- if (category.category_id().empty()) {
- continue;
- }
- if (category.score() < 0 || category.score() > 100) {
- continue;
- }
- content_annotation_string +=
- "Page Category: " + category.category_id() + "\n";
- }
- for (auto& entity : entities_metadata.entities()) {
- if (entity.entity_id().empty()) {
- continue;
- }
- if (entity.score() < 0 || entity.score() > 100) {
- continue;
- }
- content_annotation_string += "Page Entity: " + entity.entity_id() + "\n";
- }
- return content_annotation_string;
-}
-} // namespace
-
-SearchCompanionPageHandler::SearchCompanionPageHandler(
- mojo::PendingReceiver
- receiver,
- mojo::PendingRemote page,
- SearchCompanionSidePanelUI* search_companion_ui)
- : receiver_(this, std::move(receiver)),
- page_(std::move(page)),
- search_companion_ui_(search_companion_ui),
- browser_(chrome::FindLastActive()),
- weak_ptr_factory_(this) {
- Profile* profile = Profile::FromWebUI(search_companion_ui->GetWebUi());
- zero_suggest_cache_service_observation_.Observe(
- ZeroSuggestCacheServiceFactory::GetForProfile(profile));
-
- if (optimization_guide::features::RemotePageMetadataEnabled()) {
- opt_guide_ = OptimizationGuideKeyedServiceFactory::GetForProfile(profile);
-
- if (opt_guide_) {
- opt_guide_->RegisterOptimizationTypes(
- {optimization_guide::proto::OptimizationType::PAGE_ENTITIES});
- }
- }
-}
-
-SearchCompanionPageHandler::~SearchCompanionPageHandler() = default;
-
-void SearchCompanionPageHandler::OnZeroSuggestResponseUpdated(
- const std::string& page_url,
- const ZeroSuggestCacheService::CacheEntry& response) {
- NotifyUrlChanged(page_url);
- // response.substr() to crop initial characters: ")]}' "
- NotifyNewZeroSuggestPrefixData(response.response_json.substr(5));
-
- // Use zero suggest returning as the trigger to request entities from
- // optimization guide.
- // TODO(b/268285939): In the future use web navigation in the main frame to
- // trigger.
- if (opt_guide_) {
- opt_guide_->CanApplyOptimization(
- GURL(page_url),
- optimization_guide::proto::OptimizationType::PAGE_ENTITIES,
- base::BindOnce(
- &SearchCompanionPageHandler::HandleOptGuidePageEntitiesResponse,
- weak_ptr_factory_.GetWeakPtr()));
- }
-
- // Use zero suggest returning as the trigger to start a recurring timer to
- // fetch images from the main frame.
- // TODO(b/268285663): Rather than using a timer explore listening to page
- // scroll events.
- ExecuteFetchImagesJavascript(); // Fetching images one time right away
- fetch_images_timer_.Start(
- FROM_HERE, kTimerInterval, this,
- &SearchCompanionPageHandler::ExecuteFetchImagesJavascript);
-}
-
-void SearchCompanionPageHandler::HandleOptGuidePageEntitiesResponse(
- optimization_guide::OptimizationGuideDecision decision,
- const optimization_guide::OptimizationMetadata& metadata) {
- if (decision != optimization_guide::OptimizationGuideDecision::kTrue) {
- return;
- }
- absl::optional page_entities_metadata =
- metadata.ParsedMetadata();
- if (page_entities_metadata) {
- NotifyNewOptimizationGuidePageAnnotations(
- ContentAnnotationsToString(*page_entities_metadata));
- }
-}
-
-void SearchCompanionPageHandler::ExecuteFetchImagesJavascript() {
- if (!browser_) {
- return;
- }
-
- content::RenderFrameHost* main_frame_render_host =
- browser_->tab_strip_model()
- ->GetActiveWebContents()
- ->GetPrimaryMainFrame();
-
- std::string script =
- ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
- IDR_SEARCH_COMPANION_FETCH_IMAGES_JS);
-
- main_frame_render_host->ExecuteJavaScriptInIsolatedWorld(
- base::UTF8ToUTF16(script),
- base::BindOnce(&SearchCompanionPageHandler::OnFetchImagesJavascriptResult,
- weak_ptr_factory_.GetWeakPtr()),
- ISOLATED_WORLD_ID_CHROME_INTERNAL);
-}
-
-void SearchCompanionPageHandler::OnFetchImagesJavascriptResult(
- base::Value result) {
- data_decoder::DataDecoder::ParseJsonIsolated(
- result.GetString(),
- base::BindOnce(
- &SearchCompanionPageHandler::OnImageFetchJsonSanitizationCompleted,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void SearchCompanionPageHandler::OnImageFetchJsonSanitizationCompleted(
- data_decoder::DataDecoder::ValueOrError result) {
- if (!result.has_value() || !result.value().is_dict()) {
- return;
- }
- std::string new_image_content =
- *(result.value().GetDict().FindString("images"));
- NotifyNewViewportImages(new_image_content);
-}
-
-void SearchCompanionPageHandler::ShowUI() {
- if (auto embedder = search_companion_ui_->embedder()) {
- embedder->ShowUI();
- }
-}
-
-void SearchCompanionPageHandler::NotifyUrlChanged(std::string new_url) {
- page_->OnURLChanged(new_url);
-}
-
-void SearchCompanionPageHandler::NotifyNewZeroSuggestPrefixData(
- std::string suggest_response) {
- page_->OnNewZeroSuggestPrefixData(suggest_response);
-}
-
-void SearchCompanionPageHandler::NotifyNewOptimizationGuidePageAnnotations(
- std::string content_annotations) {
- page_->OnNewOptimizationGuidePageAnnotations(content_annotations);
-}
-
-void SearchCompanionPageHandler::NotifyNewViewportImages(
- std::string images_string) {
- page_->OnNewViewportImages(images_string);
-}
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.h b/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.h
deleted file mode 100644
index c039f97eb0556..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_PAGE_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_PAGE_HANDLER_H_
-
-#include "base/memory/raw_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/scoped_observation.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom.h"
-#include "components/omnibox/browser/zero_suggest_cache_service.h"
-#include "components/optimization_guide/core/optimization_guide_decision.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "mojo/public/cpp/bindings/remote.h"
-
-#include "services/data_decoder/public/cpp/data_decoder.h"
-
-class SearchCompanionSidePanelUI;
-
-namespace optimization_guide {
-class NewOptimizationGuideDecider;
-} // namespace optimization_guide
-
-///////////////////////////////////////////////////////////////////////////////
-// SearchCompanionPageHandler
-//
-// A handler of the Search Companion side panel WebUI (based on Polymer).
-// (chrome/browser/resources/side_panel/search_companion/app.ts).
-// This class is created and owned by SearchCompanionUI and has the same
-// lifetime as the Side Panel view.
-//
-class SearchCompanionPageHandler
- : public side_panel::mojom::SearchCompanionPageHandler,
- public ZeroSuggestCacheService::Observer {
- public:
- explicit SearchCompanionPageHandler(
- mojo::PendingReceiver
- receiver,
- mojo::PendingRemote page,
- SearchCompanionSidePanelUI* search_companion_ui);
- SearchCompanionPageHandler(const SearchCompanionPageHandler&) = delete;
- SearchCompanionPageHandler& operator=(const SearchCompanionPageHandler&) =
- delete;
- ~SearchCompanionPageHandler() override;
-
- // side_panel::mojom::SearchCompanionPageHandler:
- void ShowUI() override;
-
- void NotifyUrlChanged(std::string new_url);
- void NotifyNewZeroSuggestPrefixData(std::string suggest_response);
- void NotifyNewOptimizationGuidePageAnnotations(
- std::string content_annotations);
- void NotifyNewViewportImages(std::string images_string);
-
- // ZeroSuggestCacheService::Observer:
- void OnZeroSuggestResponseUpdated(
- const std::string& page_url,
- const ZeroSuggestCacheService::CacheEntry& response) override;
-
- private:
- // Handle the output of page entity data once the appropriate server
- // call is made on page load.
- void HandleOptGuidePageEntitiesResponse(
- optimization_guide::OptimizationGuideDecision decision,
- const optimization_guide::OptimizationMetadata& metadata);
-
- // Tracks the observed ZeroSuggestCacheService, for cleanup.
- base::ScopedObservation
- zero_suggest_cache_service_observation_{this};
-
- // Execute a script on the current primary frame's web content to pull the
- // image url of images on screen which fill certain filtering criteria.
- void ExecuteFetchImagesJavascript();
- // Handle the output of the fetch images javascript to ensure it is valid.
- void OnFetchImagesJavascriptResult(base::Value result);
- // Handle the output of the fetch images javascript after validity is ensured.
- void OnImageFetchJsonSanitizationCompleted(
- data_decoder::DataDecoder::ValueOrError result);
-
- base::RepeatingTimer fetch_images_timer_;
-
- // A handle to optimization guide for information about URLs that have
- // recently been navigated to.
- raw_ptr opt_guide_ = nullptr;
-
- mojo::Receiver receiver_;
- mojo::Remote page_;
- raw_ptr search_companion_ui_ = nullptr;
- raw_ptr browser_;
-
- base::WeakPtrFactory weak_ptr_factory_;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_PAGE_HANDLER_H_
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.cc b/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.cc
deleted file mode 100644
index 015820022f766..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h"
-
-#include
-#include
-
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/ui/ui_features.h"
-#include "chrome/browser/ui/webui/favicon_source.h"
-#include "chrome/browser/ui/webui/plural_string_handler.h"
-#include "chrome/browser/ui/webui/sanitized_image_source.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion_page_handler.h"
-#include "chrome/browser/ui/webui/webui_util.h"
-#include "chrome/common/webui_url_constants.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/grit/side_panel_search_companion_resources.h"
-#include "chrome/grit/side_panel_search_companion_resources_map.h"
-#include "components/favicon_base/favicon_url_parser.h"
-#include "components/strings/grit/components_strings.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "ui/accessibility/accessibility_features.h"
-#include "ui/base/webui/web_ui_util.h"
-#include "ui/views/style/platform_style.h"
-
-SearchCompanionSidePanelUI::SearchCompanionSidePanelUI(content::WebUI* web_ui)
- : ui::MojoBubbleWebUIController(web_ui, true), web_ui_(web_ui) {
- content::WebUIDataSource* source = content::WebUIDataSource::Create(
- chrome::kChromeUISearchCompanionSidePanelHost);
-
- Profile* const profile = Profile::FromWebUI(web_ui);
-
- content::URLDataSource::Add(
- profile, std::make_unique(
- profile, chrome::FaviconUrlFormat::kFavicon2));
- webui::SetupWebUIDataSource(
- source,
- base::make_span(kSidePanelSearchCompanionResources,
- kSidePanelSearchCompanionResourcesSize),
- IDR_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_HTML);
-
- content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
- source);
- content::URLDataSource::Add(profile,
- std::make_unique(profile));
-}
-
-SearchCompanionSidePanelUI::~SearchCompanionSidePanelUI() = default;
-
-WEB_UI_CONTROLLER_TYPE_IMPL(SearchCompanionSidePanelUI)
-
-content::WebUI* SearchCompanionSidePanelUI::GetWebUi() {
- return web_ui_;
-}
-
-void SearchCompanionSidePanelUI::BindInterface(
- mojo::PendingReceiver
- receiver) {
- search_companion_page_factory_receiver_.reset();
- search_companion_page_factory_receiver_.Bind(std::move(receiver));
-}
-
-void SearchCompanionSidePanelUI::CreateSearchCompanionPageHandler(
- mojo::PendingReceiver
- receiver,
- mojo::PendingRemote page) {
- search_companion_page_handler_ = std::make_unique(
- std::move(receiver), std::move(page), this);
-}
diff --git a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h b/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h
deleted file mode 100644
index e4eabe49fcebd..0000000000000
--- a/chrome/browser/ui/webui/side_panel/search_companion/search_companion_side_panel_ui.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_SIDE_PANEL_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_SIDE_PANEL_UI_H_
-
-#include
-
-#include "base/memory/raw_ptr.h"
-#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom.h"
-#include "chrome/browser/ui/webui/webui_load_timer.h"
-#include "mojo/public/cpp/bindings/pending_receiver.h"
-#include "mojo/public/cpp/bindings/pending_remote.h"
-#include "mojo/public/cpp/bindings/receiver.h"
-#include "ui/webui/mojo_bubble_web_ui_controller.h"
-
-class SearchCompanionPageHandler;
-
-///////////////////////////////////////////////////////////////////////////////
-// SearchCompanionSidePanelUI
-//
-// A UI class to create the necessary handlers and bind the side panel view to
-// the mojo-driven UI that is contained within it.
-//
-class SearchCompanionSidePanelUI
- : public ui::MojoBubbleWebUIController,
- public side_panel::mojom::SearchCompanionPageHandlerFactory {
- public:
- explicit SearchCompanionSidePanelUI(content::WebUI* web_ui);
- SearchCompanionSidePanelUI(const SearchCompanionSidePanelUI&) = delete;
- SearchCompanionSidePanelUI& operator=(const SearchCompanionSidePanelUI&) =
- delete;
- ~SearchCompanionSidePanelUI() override;
-
- // Instantiates the implementor of the mojom::PageHandlerFactory mojo
- // interface passing the pending receiver that will be internally bound.
- void BindInterface(
- mojo::PendingReceiver<
- side_panel::mojom::SearchCompanionPageHandlerFactory> receiver);
-
- content::WebUI* GetWebUi();
-
- private:
- // side_panel::mojom::SearchCompanionPageHandlerFactory:
- void CreateSearchCompanionPageHandler(
- mojo::PendingReceiver
- receiver,
- mojo::PendingRemote page)
- override;
-
- std::unique_ptr search_companion_page_handler_;
- mojo::Receiver
- search_companion_page_factory_receiver_{this};
- raw_ptr web_ui_;
-
- WEB_UI_CONTROLLER_TYPE_DECL();
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_SIDE_PANEL_SEARCH_COMPANION_SEARCH_COMPANION_SIDE_PANEL_UI_H_
diff --git a/chrome/chrome_paks.gni b/chrome/chrome_paks.gni
index 0ce003e97f5ab..081be7d38ce6c 100644
--- a/chrome/chrome_paks.gni
+++ b/chrome/chrome_paks.gni
@@ -179,7 +179,6 @@ template("chrome_extra_paks") {
"$root_gen_dir/chrome/side_panel_history_clusters_resources.pak",
"$root_gen_dir/chrome/side_panel_read_anything_resources.pak",
"$root_gen_dir/chrome/side_panel_reading_list_resources.pak",
- "$root_gen_dir/chrome/side_panel_search_companion_resources.pak",
"$root_gen_dir/chrome/side_panel_shared_resources.pak",
"$root_gen_dir/chrome/side_panel_user_notes_resources.pak",
"$root_gen_dir/chrome/signin_resources.pak",
@@ -221,7 +220,6 @@ template("chrome_extra_paks") {
"//chrome/browser/resources/side_panel/history_clusters:resources",
"//chrome/browser/resources/side_panel/read_anything:resources",
"//chrome/browser/resources/side_panel/reading_list:resources",
- "//chrome/browser/resources/side_panel/search_companion:resources",
"//chrome/browser/resources/side_panel/shared:resources",
"//chrome/browser/resources/side_panel/user_notes:resources",
"//chrome/browser/resources/signin:resources",
diff --git a/chrome/common/webui_url_constants.cc b/chrome/common/webui_url_constants.cc
index ab96426fbdb3b..6edcb5bcc95de 100644
--- a/chrome/common/webui_url_constants.cc
+++ b/chrome/common/webui_url_constants.cc
@@ -272,10 +272,6 @@ const char kChromeUIReadAnythingSidePanelURL[] =
"chrome://read-anything-side-panel.top-chrome/";
const char kChromeUIReadLaterHost[] = "read-later.top-chrome";
const char kChromeUIReadLaterURL[] = "chrome://read-later.top-chrome/";
-const char kChromeUISearchCompanionSidePanelHost[] =
- "search-companion-side-panel.top-chrome";
-const char kChromeUISearchCompanionSidePanelURL[] =
- "chrome://search-companion-side-panel.top-chrome/";
const char kChromeUIUntrustedFeedURL[] = "chrome-untrusted://feed/";
const char kChromeUIUserNotesSidePanelHost[] =
"user-notes-side-panel.top-chrome";
diff --git a/chrome/common/webui_url_constants.h b/chrome/common/webui_url_constants.h
index 44e8934f1d1e8..c47c2da8c5e3d 100644
--- a/chrome/common/webui_url_constants.h
+++ b/chrome/common/webui_url_constants.h
@@ -254,8 +254,6 @@ extern const char kChromeUIReadAnythingSidePanelHost[];
extern const char kChromeUIReadAnythingSidePanelURL[];
extern const char kChromeUIReadLaterHost[];
extern const char kChromeUIReadLaterURL[];
-extern const char kChromeUISearchCompanionSidePanelHost[];
-extern const char kChromeUISearchCompanionSidePanelURL[];
extern const char kChromeUIUntrustedCompanionSidePanelHost[];
extern const char kChromeUIUntrustedCompanionSidePanelURL[];
extern const char kChromeUIUntrustedFeedURL[];
diff --git a/tools/gritsettings/resource_ids.spec b/tools/gritsettings/resource_ids.spec
index 69d4640085161..e8747641bbce5 100644
--- a/tools/gritsettings/resource_ids.spec
+++ b/tools/gritsettings/resource_ids.spec
@@ -326,10 +326,6 @@
"META": {"sizes": {"includes": [20],}},
"includes": [1935],
},
- "<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/side_panel/search_companion/resources.grd": {
- "META": {"sizes": {"includes": [5],}},
- "includes": [1936],
- },
"<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/settings/chromeos/os_settings_resources.grd": {
"META": {"sizes": {"includes": [1000],}},
"includes": [1940],