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 #ifndef COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVER_H
_ |
| 6 #define COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVER_H
_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/contextual_search/common/overlay_page_notifier_service.mojo
m.h" |
| 11 #include "content/public/renderer/render_frame.h" |
| 12 #include "content/public/renderer/render_frame_observer.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 #include "v8/include/v8.h" |
| 15 |
| 16 namespace contextual_search { |
| 17 |
| 18 class ContextualSearchWrapper; |
| 19 |
| 20 // OverlayJsRenderFrame observer waits for a page to be loaded and then |
| 21 // tries to connect to a mojo service hosted in the browser process. The |
| 22 // service will tell this render process if the current page is presented |
| 23 // in an overlay panel. |
| 24 class OverlayJsRenderFrameObserver : public content::RenderFrameObserver { |
| 25 public: |
| 26 explicit OverlayJsRenderFrameObserver(content::RenderFrame* render_frame); |
| 27 ~OverlayJsRenderFrameObserver() override; |
| 28 |
| 29 // RenderFrameObserver implementation. |
| 30 void DidStartProvisionalLoad() override; |
| 31 void DidCreateNewDocument() override; |
| 32 void DidFinishLoad() override; |
| 33 void FrameWillClose() override; |
| 34 |
| 35 // Flag the current page as a contextual search overlay. |
| 36 void SetIsContextualSearchOverlay(); |
| 37 |
| 38 private: |
| 39 // Add the mojo service to a RenderFrame's service registry. |
| 40 void RegisterMojoService(); |
| 41 void CreateOverlayPageNotifierService( |
| 42 mojo::InterfaceRequest<OverlayPageNotifierService> request); |
| 43 |
| 44 // Track if the current page is presented in the contextual search overlay. |
| 45 bool is_contextual_search_overlay_; |
| 46 |
| 47 // Wrapper for the API in the panel, disposed when the frame goes away. |
| 48 scoped_ptr<ContextualSearchWrapper> wrapper_; |
| 49 |
| 50 base::WeakPtrFactory<OverlayJsRenderFrameObserver> weak_factory_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(OverlayJsRenderFrameObserver); |
| 53 }; |
| 54 |
| 55 } // namespace contextual_search |
| 56 |
| 57 #endif // COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVE
R_H_ |
OLD | NEW |