Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 CHROME_BROWSER_ANDROID_MEDIA_IPH_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_ANDROID_MEDIA_IPH_MANAGER_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "chrome/common/media_iph.mojom.h" | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "services/service_manager/public/cpp/binder_registry.h" | |
| 12 | |
| 13 class MediaIPHManagerClient { | |
| 14 public: | |
| 15 ~MediaIPHManagerClient() {} | |
| 16 | |
| 17 // Request to show the IPH for media download. Returns true iff the IPH can | |
| 18 // be shown. | |
| 19 virtual bool ShowMediaDownloadIPH() = 0; | |
| 20 | |
| 21 // Updates the position of the IPH widget. |rect_in_frame| provides the | |
| 22 // position of the widget in the space of the renderer's main frame. | |
| 23 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.
| |
| 24 const gfx::Rect& rect_in_frame) = 0; | |
| 25 | |
| 26 // Request to dismiss the IPH widget. This request must be acknowledged using | |
| 27 // MediaIPHManager::WidgetDismissed once the widget is removed. | |
| 28 virtual void DismissMediaDownloadIPH() = 0; | |
| 29 }; | |
| 30 | |
| 31 class MediaIPHManager : public content::WebContentsObserver { | |
| 32 public: | |
| 33 MediaIPHManager(content::WebContents* web_contents, | |
| 34 MediaIPHManagerClient* client); | |
| 35 ~MediaIPHManager() override; | |
| 36 | |
| 37 // Notifies when the IPH widget requested from the client is removed. | |
| 38 void WidgetDismissed(); | |
| 39 | |
| 40 // content::WebContentsObserver implementation. | |
| 41 // TODO(khushalsagar): Listen to navigations/process crash to dismiss the | |
| 42 // widget in the browser. | |
| 43 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | |
| 44 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | |
| 45 | |
| 46 private: | |
| 47 class MediaIPHService; | |
| 48 | |
| 49 // Methods used by MediaIPHService to plumb notifications from the renderer. | |
| 50 void ShowIPHWidget(content::RenderFrameHost* render_frame_host, | |
| 51 const gfx::Rect& rect_in_main_frame, | |
| 52 bool new_request); | |
| 53 void HideIPHWidget(content::RenderFrameHost* render_frame_host); | |
| 54 | |
| 55 // Creates the mojo service exposed to the renderer. | |
| 56 void CreateIPHService(content::RenderFrameHost* render_frame_host, | |
| 57 const service_manager::BindSourceInfo& source_info, | |
| 58 chrome::mojom::MediaIPHServiceRequest request); | |
| 59 void DismissUI(); | |
| 60 | |
| 61 content::RenderFrameHost* active_render_frame_host_ = nullptr; | |
| 62 MediaIPHManagerClient* client_; | |
| 63 base::WeakPtrFactory<MediaIPHManager> weak_factory_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(MediaIPHManager); | |
| 66 }; | |
| 67 | |
| 68 #endif // CHROME_BROWSER_ANDROID_MEDIA_IPH_MANAGER_H_ | |
| OLD | NEW |