OLD | NEW |
---|---|
(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 | |
OLD | NEW |