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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/contextual_search/overlay_js_render_frame_observer.h"
6
7 #include "base/bind.h"
8 #include "components/contextual_search/contextual_search_wrapper.h"
9 #include "components/contextual_search/overlay_page_notifier_service_impl.h"
10 #include "content/public/common/service_registry.h"
11 #include "content/public/renderer/render_frame.h"
12 #include "v8/include/v8.h"
13
14 namespace contextual_search {
15
16 OverlayJsRenderFrameObserver::OverlayJsRenderFrameObserver(
17 content::RenderFrame* render_frame)
18 : RenderFrameObserver(render_frame),
19 is_contextual_search_overlay_(false),
20 weak_factory_(this) {}
21
22 OverlayJsRenderFrameObserver::~OverlayJsRenderFrameObserver() {}
23
24 void OverlayJsRenderFrameObserver::DidStartProvisionalLoad() {
25 RegisterMojoService();
26 }
27
28 void OverlayJsRenderFrameObserver::RegisterMojoService() {
29 render_frame()->GetServiceRegistry()->AddService(base::Bind(
30 &OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService,
31 weak_factory_.GetWeakPtr()));
32 }
33
34 void OverlayJsRenderFrameObserver::CreateOverlayPageNotifierService(
35 mojo::InterfaceRequest<OverlayPageNotifierService> request) {
36 // This is strongly bound to and owned by the pipe.
37 new OverlayPageNotifierServiceImpl(this, request.Pass());
38 }
39
40 void OverlayJsRenderFrameObserver::SetIsContextualSearchOverlay() {
41 is_contextual_search_overlay_ = true;
42 }
43
44 void OverlayJsRenderFrameObserver::DidCreateNewDocument() {
45 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.
46 << render_frame();
47 if (is_contextual_search_overlay_) {
48 DVLOG(0) << "ctxs installing CS... ";
49 contextual_search::ContextualSearchWrapper::Install(render_frame());
50 DVLOG(0) << "ctxs installing CS... DONE!";
51 }
52 }
53
54 void OverlayJsRenderFrameObserver::DidFinishLoad() {
55 // If no message about the distilled page was received at this point, there
56 // will not be one; remove the OverlayPageNotifierService from the registry.
57 render_frame()
58 ->GetServiceRegistry()
59 ->RemoveService<OverlayPageNotifierService>();
60 }
61
62 } // namespace contextual_search
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698