OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL
_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL
_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL
_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL
_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/media/router/media_router_dialog_controller.h" | 9 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
11 #include "content/public/browser/web_contents_user_data.h" | 11 #include "content/public/browser/web_contents_user_data.h" |
12 | 12 |
13 namespace media_router { | 13 namespace media_router { |
14 | 14 |
15 // A desktop implementation of MediaRouterDialogController. | 15 // A desktop implementation of MediaRouterDialogController. |
16 // This class is not thread safe and must be called on the UI thread. | 16 // This class is not thread safe and must be called on the UI thread. |
17 class MediaRouterDialogControllerImpl | 17 class MediaRouterDialogControllerImpl : |
18 : public content::WebContentsUserData<MediaRouterDialogControllerImpl>, | 18 public content::WebContentsUserData<MediaRouterDialogControllerImpl>, |
19 public MediaRouterDialogController { | 19 public MediaRouterDialogController { |
20 public: | 20 public: |
21 ~MediaRouterDialogControllerImpl() override; | 21 ~MediaRouterDialogControllerImpl() override; |
22 | 22 |
23 static MediaRouterDialogControllerImpl* GetOrCreateForWebContents( | 23 static MediaRouterDialogControllerImpl* GetOrCreateForWebContents( |
24 content::WebContents* web_contents); | 24 content::WebContents* web_contents); |
25 | 25 |
26 // SuperClass: | |
27 bool ShowMediaRouterDialogForPresentation( | |
28 scoped_ptr<CreatePresentationSessionRequest> request) override; | |
29 | |
30 // Shows the media router dialog modal to the initiator WebContents. | |
31 // Creates the dialog if it did not exist prior to this call. | |
32 // If the dialog already exists, brings the dialog to the front. | |
33 // Returns WebContents for the media router dialog. | |
34 content::WebContents* ShowMediaRouterDialog(); | |
35 | |
36 // Returns the media router dialog WebContents. | 26 // Returns the media router dialog WebContents. |
37 // Returns nullptr if there is no dialog. | 27 // Returns nullptr if there is no dialog. |
38 content::WebContents* GetMediaRouterDialog() const; | 28 content::WebContents* GetMediaRouterDialog() const; |
39 | 29 |
40 // Closes the media router dialog. This will destroy the dialog WebContents. | |
41 // It is an error to call this function if there is currently no dialog. | |
42 void CloseMediaRouterDialog(); | |
43 | 30 |
44 private: | 31 private: |
45 class DialogWebContentsObserver; | 32 class DialogWebContentsObserver; |
46 class InitiatorWebContentsObserver; | |
47 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>; | 33 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>; |
48 | 34 |
49 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an | 35 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an |
50 // instance. | 36 // instance. |
51 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents); | 37 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents); |
52 | 38 |
53 // Creates a new media router dialog modal to |initiator_|. | 39 // MediaRouterDialogController: |
54 void CreateMediaRouterDialog(); | 40 void CreateMediaRouterDialog() override; |
55 | 41 void CloseMediaRouterDialog() override; |
56 // Resets this dialog controller to an empty state. | 42 bool IsShowingMediaRouterDialog() const override; |
57 void Reset(); | 43 void Reset() override; |
58 | 44 |
59 // Invoked when the dialog WebContents has navigated. | 45 // Invoked when the dialog WebContents has navigated. |
60 void OnDialogNavigated(const content::LoadCommittedDetails& details); | 46 void OnDialogNavigated(const content::LoadCommittedDetails& details); |
61 | 47 |
62 void PopulateDialog(content::WebContents* media_router_dialog); | 48 void PopulateDialog(content::WebContents* media_router_dialog); |
63 | 49 |
64 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | |
65 scoped_ptr<DialogWebContentsObserver> dialog_observer_; | 50 scoped_ptr<DialogWebContentsObserver> dialog_observer_; |
66 | 51 |
67 content::WebContents* const initiator_; | |
68 | |
69 // True if the controller is waiting for a new media router dialog to be | 52 // True if the controller is waiting for a new media router dialog to be |
70 // created. | 53 // created. |
71 bool media_router_dialog_pending_; | 54 bool media_router_dialog_pending_; |
72 | 55 |
73 // Data for dialogs created under a Presentation API context. | |
74 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and | |
75 // passed to the MediaRouterUI when it is initialized. | |
76 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | |
77 | |
78 base::ThreadChecker thread_checker_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerImpl); | 56 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerImpl); |
81 }; | 57 }; |
82 | 58 |
83 } // namespace media_router | 59 } // namespace media_router |
84 | 60 |
85 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_I
MPL_H_ | 61 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_I
MPL_H_ |
OLD | NEW |