| 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: | 26 // MediaRouterDialogController: |
| 27 bool ShowMediaRouterDialogForPresentation( | 27 bool IsShowingMediaRouterDialog() override; |
| 28 scoped_ptr<CreatePresentationSessionRequest> request) override; | 28 // This will destroy the dialog WebContents. |
| 29 | 29 void CloseMediaRouterDialog() override; |
| 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 | 30 |
| 36 // Returns the media router dialog WebContents. | 31 // Returns the media router dialog WebContents. |
| 37 // Returns nullptr if there is no dialog. | 32 // Returns nullptr if there is no dialog. |
| 38 content::WebContents* GetMediaRouterDialog() const; | 33 content::WebContents* GetMediaRouterDialog() const; |
| 39 | 34 |
| 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 | 35 |
| 44 private: | 36 private: |
| 45 class DialogWebContentsObserver; | 37 class DialogWebContentsObserver; |
| 46 class InitiatorWebContentsObserver; | |
| 47 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>; | 38 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>; |
| 48 | 39 |
| 49 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an | 40 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an |
| 50 // instance. | 41 // instance. |
| 51 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents); | 42 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents); |
| 52 | 43 |
| 53 // Creates a new media router dialog modal to |initiator_|. | 44 // MediaRouterDialogController: |
| 54 void CreateMediaRouterDialog(); | 45 void Reset() override; |
| 55 | 46 void CreateMediaRouterDialog() override; |
| 56 // Resets this dialog controller to an empty state. | |
| 57 void Reset(); | |
| 58 | 47 |
| 59 // Invoked when the dialog WebContents has navigated. | 48 // Invoked when the dialog WebContents has navigated. |
| 60 void OnDialogNavigated(const content::LoadCommittedDetails& details); | 49 void OnDialogNavigated(const content::LoadCommittedDetails& details); |
| 61 | 50 |
| 62 void PopulateDialog(content::WebContents* media_router_dialog); | 51 void PopulateDialog(content::WebContents* media_router_dialog); |
| 63 | 52 |
| 64 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | |
| 65 scoped_ptr<DialogWebContentsObserver> dialog_observer_; | 53 scoped_ptr<DialogWebContentsObserver> dialog_observer_; |
| 66 | 54 |
| 67 content::WebContents* const initiator_; | |
| 68 | |
| 69 // True if the controller is waiting for a new media router dialog to be | 55 // True if the controller is waiting for a new media router dialog to be |
| 70 // created. | 56 // created. |
| 71 bool media_router_dialog_pending_; | 57 bool media_router_dialog_pending_; |
| 72 | 58 |
| 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); | 59 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerImpl); |
| 81 }; | 60 }; |
| 82 | 61 |
| 83 } // namespace media_router | 62 } // namespace media_router |
| 84 | 63 |
| 85 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_I
MPL_H_ | 64 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_I
MPL_H_ |
| OLD | NEW |