Index: chrome/browser/android/media_iph_manager.h |
diff --git a/chrome/browser/android/media_iph_manager.h b/chrome/browser/android/media_iph_manager.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..889f3c9b1f420a21f3f95d434c86f56f2e89401f |
--- /dev/null |
+++ b/chrome/browser/android/media_iph_manager.h |
@@ -0,0 +1,68 @@ |
+// 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_IPH_MANAGER_H_ |
+#define CHROME_BROWSER_ANDROID_MEDIA_IPH_MANAGER_H_ |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "chrome/common/media_iph.mojom.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "services/service_manager/public/cpp/binder_registry.h" |
+ |
+class MediaIPHManagerClient { |
+ public: |
+ ~MediaIPHManagerClient() {} |
+ |
+ // Request to show the IPH for media download. Returns true iff the IPH can |
+ // be shown. |
+ virtual bool ShowMediaDownloadIPH() = 0; |
+ |
+ // Updates the position of the IPH widget. |rect_in_frame| provides the |
+ // position of the widget in the space of the renderer's main frame. |
+ virtual void UpdateMediaDownloadIPHPosition( |
chrishtr
2017/06/23 00:39:44
You can remove this method and pass the rect to Sh
Khushal
2017/06/28 05:32:38
Done.
|
+ const gfx::Rect& rect_in_frame) = 0; |
+ |
+ // Request to dismiss the IPH widget. This request must be acknowledged using |
+ // MediaIPHManager::WidgetDismissed once the widget is removed. |
+ virtual void DismissMediaDownloadIPH() = 0; |
+}; |
+ |
+class MediaIPHManager : public content::WebContentsObserver { |
+ public: |
+ MediaIPHManager(content::WebContents* web_contents, |
+ MediaIPHManagerClient* client); |
+ ~MediaIPHManager() override; |
+ |
+ // Notifies when the IPH widget requested from the client is removed. |
+ void WidgetDismissed(); |
+ |
+ // content::WebContentsObserver implementation. |
+ // TODO(khushalsagar): Listen to navigations/process crash to dismiss the |
+ // widget in the browser. |
+ void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; |
+ void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
+ |
+ private: |
+ class MediaIPHService; |
+ |
+ // Methods used by MediaIPHService to plumb notifications from the renderer. |
+ void ShowIPHWidget(content::RenderFrameHost* render_frame_host, |
+ const gfx::Rect& rect_in_main_frame, |
+ bool new_request); |
+ void HideIPHWidget(content::RenderFrameHost* render_frame_host); |
+ |
+ // Creates the mojo service exposed to the renderer. |
+ void CreateIPHService(content::RenderFrameHost* render_frame_host, |
+ const service_manager::BindSourceInfo& source_info, |
+ chrome::mojom::MediaIPHServiceRequest request); |
+ void DismissUI(); |
+ |
+ content::RenderFrameHost* active_render_frame_host_ = nullptr; |
+ MediaIPHManagerClient* client_; |
+ base::WeakPtrFactory<MediaIPHManager> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaIPHManager); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_MEDIA_IPH_MANAGER_H_ |