Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: components/contextual_search/overlay_js_render_frame_observer.cc

Issue 1385663002: [Contextual Search] Add Mojo-enabled API component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworked to use a new Contextual Search component and Mojo communication, removed CS Manager stuff. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/contextual_search/overlay_js_render_frame_observer.cc
diff --git a/components/contextual_search/overlay_js_render_frame_observer.cc b/components/contextual_search/overlay_js_render_frame_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..520691eb21927bf2e35930148ace14f78b0eb65d
--- /dev/null
+++ b/components/contextual_search/overlay_js_render_frame_observer.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/contextual_search/overlay_js_render_frame_observer.h"
+
+#include "base/bind.h"
+#include "components/contextual_search/contextual_search_wrapper.h"
+#include "components/contextual_search/overlay_page_notifier_service_impl.h"
+#include "content/public/common/service_registry.h"
+#include "content/public/renderer/render_frame.h"
+#include "v8/include/v8.h"
+
+namespace contextual_search {
+
+OverlayJsRenderFrameObserver::OverlayJsRenderFrameObserver(
+ content::RenderFrame* render_frame)
+ : RenderFrameObserver(render_frame),
+ is_contextual_search_overlay_(false),
+ weak_factory_(this) {}
+
+OverlayJsRenderFrameObserver::~OverlayJsRenderFrameObserver() {}
+
+void OverlayJsRenderFrameObserver::DidStartProvisionalLoad() {
+ RegisterMojoService();
+}
+
+void OverlayJsRenderFrameObserver::RegisterMojoService() {
+ render_frame()->GetServiceRegistry()->AddService(base::Bind(
+ &OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService,
+ weak_factory_.GetWeakPtr()));
+}
+
+void OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService(
+ mojo::InterfaceRequest<OverlayPageNotifierService> request) {
+ // This is strongly bound to and owned by the pipe.
+ new OverlayPageNotifierServiceImpl(this, request.Pass());
+}
+
+void OverlayJsRenderFrameObserver::SetIsContextualSearchOverlay() {
+ is_contextual_search_overlay_ = true;
+}
+
+void OverlayJsRenderFrameObserver::DidCreateNewDocument() {
+ DVLOG(0) << "ctxs OverlayJsRenderFrameObserver::DidCreateNewDocument for "
jochen (gone - plz use gerrit) 2015/11/17 14:58:12 0 is too noisy, please use at least 1. or consider
Donn Denman 2015/11/19 01:11:29 Done - removed.
+ << render_frame();
+ if (is_contextual_search_overlay_) {
+ DVLOG(0) << "ctxs installing CS... ";
+ contextual_search::ContextualSearchWrapper::Install(render_frame());
+ DVLOG(0) << "ctxs installing CS... DONE!";
+ }
+}
+
+void OverlayJsRenderFrameObserver::DidFinishLoad() {
+ // If no message about the distilled page was received at this point, there
+ // will not be one; remove the OverlayPageNotifierService from the registry.
+ render_frame()
+ ->GetServiceRegistry()
+ ->RemoveService<OverlayPageNotifierService>();
+}
+
+} // namespace contextual_search

Powered by Google App Engine
This is Rietveld 408576698