Commit 97752289 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

Create contextual search renderer side if build flag set

This change adds a condition so that the renderer part of the contextual
search code is only created when the corresponding build flag is defined.
It also updates the browser-side ContextualSearchJsApiService interface
binder registration depend on the same build flag rather than the more
generic OS_ANDROID condition.

Bug: 1047680
Change-Id: Ia0c88558736b028b96b0092acb6dde4a7a526b87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055992Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743223}
parent b44f32f9
......@@ -62,6 +62,7 @@ include_rules = [
"+components/content_capture/browser",
"+components/content_settings/core/browser",
"+components/content_settings/core/test",
"+components/contextual_search/buildflags.h",
"+components/contextual_search/content/browser",
"+components/contextual_search/content/common",
"+components/contextual_search/core/browser",
......
......@@ -33,6 +33,7 @@
#include "chrome/browser/ui/webui/omnibox/omnibox_ui.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals.mojom.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
#include "components/contextual_search/buildflags.h"
#include "components/dom_distiller/content/browser/distillability_driver.h"
#include "components/dom_distiller/content/browser/distiller_javascript_service_impl.h"
#include "components/dom_distiller/content/common/mojom/distillability_service.mojom.h"
......@@ -166,7 +167,7 @@ void BindUnhandledTapWebContentsObserver(
}
#endif // BUILDFLAG(ENABLE_UNHANDLED_TAP)
#if defined(OS_ANDROID)
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
void BindContextualSearchObserver(
content::RenderFrameHost* const host,
mojo::PendingReceiver<
......@@ -184,7 +185,7 @@ void BindContextualSearchObserver(
contextual_search_observer->api_handler(), std::move(receiver));
}
}
#endif
#endif // BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
// Forward image Annotator requests to the profile's AccessibilityLabelsService.
void BindImageAnnotator(
......@@ -365,6 +366,7 @@ void PopulateChromeFrameBinders(
map->Add<blink::mojom::ShareService>(base::BindRepeating(
&ForwardToJavaWebContents<blink::mojom::ShareService>));
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
map->Add<contextual_search::mojom::ContextualSearchJsApiService>(
base::BindRepeating(&BindContextualSearchObserver));
......@@ -372,6 +374,7 @@ void PopulateChromeFrameBinders(
map->Add<blink::mojom::UnhandledTapNotifier>(
base::BindRepeating(&BindUnhandledTapWebContentsObserver));
#endif // BUILDFLAG(ENABLE_UNHANDLED_TAP)
#endif // BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
#if defined(ENABLE_SPATIAL_NAVIGATION_HOST)
map->Add<blink::mojom::SpatialNavigationHost>(base::BindRepeating(
......
......@@ -7,6 +7,7 @@ include_rules = [
"+components/content_capture/common",
"+components/content_capture/renderer",
"+components/content_settings/core/common",
"+components/contextual_search/buildflags.h",
"+components/contextual_search/content/renderer",
"+components/crash/core/common/crash_key.h",
"+components/crx_file",
......
......@@ -71,6 +71,7 @@
#include "components/content_capture/common/content_capture_features.h"
#include "components/content_capture/renderer/content_capture_sender.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/contextual_search/buildflags.h"
#include "components/contextual_search/content/renderer/overlay_js_render_frame_observer.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "components/dom_distiller/content/renderer/distillability_agent.h"
......@@ -544,8 +545,10 @@ void ChromeContentRendererClient::RenderFrameCreated(
new dom_distiller::DistillabilityAgent(render_frame, DCHECK_IS_ON());
}
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
// Set up a mojo service to test if this page is a contextual search page.
new contextual_search::OverlayJsRenderFrameObserver(render_frame, registry);
#endif
blink::AssociatedInterfaceRegistry* associated_interfaces =
render_frame_observer->associated_interfaces();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment