Index: chrome/browser/android/media_in_product_help_manager.h |
diff --git a/chrome/browser/android/media_in_product_help_manager.h b/chrome/browser/android/media_in_product_help_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f434a1e5ac0bc6d10b4427bf7d930fe6a1619be8 |
--- /dev/null |
+++ b/chrome/browser/android/media_in_product_help_manager.h |
@@ -0,0 +1,66 @@ |
+// Copyright 2017 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 CHROME_BROWSER_ANDROID_MEDIA_IN_PRODUCT_HELP_MANAGER_H_ |
+#define CHROME_BROWSER_ANDROID_MEDIA_IN_PRODUCT_HELP_MANAGER_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "services/service_manager/public/cpp/binder_registry.h" |
+#include "third_party/WebKit/public/platform/media_in_product_help.mojom.h" |
+ |
+class MediaInProductHelpManagerClient { |
+ public: |
+ ~MediaInProductHelpManagerClient() {} |
+ |
+ // Updates the position of the InProductHelp widget. |rect_in_frame| provides |
+ // the position of the widget in the space of the renderer's main frame. |
+ virtual void ShowMediaDownloadInProductHelp( |
+ const gfx::Rect& rect_in_frame) = 0; |
+ |
+ // Request to dismiss the InProductHelp widget. This request must be |
+ // acknowledged using MediaInProductHelpManager::WidgetDismissed once the |
+ // widget is removed. |
+ virtual void DismissMediaDownloadInProductHelp() = 0; |
+}; |
+ |
+class MediaInProductHelpManager : public content::WebContentsObserver { |
+ public: |
+ MediaInProductHelpManager(content::WebContents* web_contents, |
+ MediaInProductHelpManagerClient* client); |
+ ~MediaInProductHelpManager() override; |
+ |
+ // Notifies when the InProductHelp widget requested from the client is |
+ // removed. |
+ void WidgetDismissed(); |
+ |
+ // content::WebContentsObserver implementation. |
+ void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
+ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
+ |
+ private: |
+ class MediaInProductHelp; |
+ |
+ // Used by MediaInProductHelpService to plumb notifications from the renderer. |
+ void ShowInProductHelpWidget(const gfx::Rect& rect_in_main_frame); |
+ |
+ // Called when the connection to the renderer is closed. |
+ void OnConnectionError(); |
+ |
+ // Creates the mojo service exposed to the renderer. |
+ void CreateInProductHelpService( |
+ content::RenderFrameHost* render_frame_host, |
+ const service_manager::BindSourceInfo& source_info, |
+ blink::mojom::MediaInProductHelpRequest request); |
+ |
+ std::unique_ptr<MediaInProductHelp> media_in_product_help_; |
+ |
+ // The |client_| outlives this class. |
+ MediaInProductHelpManagerClient* client_; |
+ base::WeakPtrFactory<MediaInProductHelpManager> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaInProductHelpManager); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_MEDIA_IN_PRODUCT_HELP_MANAGER_H_ |