Chromium Code Reviews| 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/renderer/overlay_js_render_frame_observer .h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "components/contextual_search/renderer/contextual_search_wrapper.h" | |
| 9 #include "components/contextual_search/renderer/overlay_page_notifier_service_im pl.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 if (is_contextual_search_overlay_) | |
| 46 wrapper_ = | |
| 47 contextual_search::ContextualSearchWrapper::Install(render_frame()); | |
|
jochen (gone - plz use gerrit)
2015/12/02 12:59:15
this should happen in DidClearWindowObject()
Donn Denman
2015/12/03 01:21:09
Done.
| |
| 48 } | |
| 49 | |
| 50 void OverlayJsRenderFrameObserver::DidFinishLoad() { | |
| 51 // If no message about the Contextual Search overlay was received at this | |
| 52 // point, there will not be one; remove the OverlayPageNotifierService | |
| 53 // from the registry. | |
| 54 render_frame() | |
| 55 ->GetServiceRegistry() | |
| 56 ->RemoveService<OverlayPageNotifierService>(); | |
| 57 } | |
| 58 | |
| 59 void OverlayJsRenderFrameObserver::FrameWillClose() { | |
|
Donn Denman
2015/12/02 03:32:48
This doesn't get called when I expect it to (when
Donn Denman
2015/12/03 01:21:09
There seems to be a problem with our RenderFrameOb
| |
| 60 if (wrapper_ && wrapper_.get()) | |
| 61 wrapper_.reset(); | |
| 62 } | |
| 63 | |
| 64 } // namespace contextual_search | |
| OLD | NEW |