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

Unified Diff: components/contextual_search/renderer/overlay_js_render_frame_observer.h

Issue 1385663002: [Contextual Search] Add Mojo-enabled API component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reset the Wrapper when the Frame goes away. Created 5 years 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/renderer/overlay_js_render_frame_observer.h
diff --git a/components/contextual_search/renderer/overlay_js_render_frame_observer.h b/components/contextual_search/renderer/overlay_js_render_frame_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..68531d870b8bc94b392cd67f2183aceee6f79967
--- /dev/null
+++ b/components/contextual_search/renderer/overlay_js_render_frame_observer.h
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVER_H_
+#define COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVER_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "components/contextual_search/common/overlay_page_notifier_service.mojom.h"
+#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/render_frame_observer.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "v8/include/v8.h"
+
+namespace contextual_search {
+
+class ContextualSearchWrapper;
+
+// OverlayJsRenderFrame observer waits for a page to be loaded and then
+// tries to connect to a mojo service hosted in the browser process. The
+// service will tell this render process if the current page is presented
+// in an overlay panel.
+class OverlayJsRenderFrameObserver : public content::RenderFrameObserver {
+ public:
+ explicit OverlayJsRenderFrameObserver(content::RenderFrame* render_frame);
+ ~OverlayJsRenderFrameObserver() override;
+
+ // RenderFrameObserver implementation.
+ void DidStartProvisionalLoad() override;
+ void DidCreateNewDocument() override;
+ void DidFinishLoad() override;
+ void FrameWillClose() override;
+
+ // Flag the current page as a contextual search overlay.
+ void SetIsContextualSearchOverlay();
+
+ private:
+ // Add the mojo service to a RenderFrame's service registry.
+ void RegisterMojoService();
+ void CreateOverlayPageNotifierService(
+ mojo::InterfaceRequest<OverlayPageNotifierService> request);
+
+ // Track if the current page is presented in the contextual search overlay.
+ bool is_contextual_search_overlay_;
+
+ // Wrapper for the API in the panel, disposed when the frame goes away.
+ scoped_ptr<ContextualSearchWrapper> wrapper_;
+
+ base::WeakPtrFactory<OverlayJsRenderFrameObserver> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(OverlayJsRenderFrameObserver);
+};
+
+} // namespace contextual_search
+
+#endif // COMPONENTS_CONTEXTUAL_SEARCH_RENDERER_OVERLAY_JS_RENDER_FRAME_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698