Chromium Code Reviews| 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_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_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/create_presentation_session_request.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 // An instance of this class is tied to a WebContents known as the initiator, | 15 // A desktop implementation of MediaRouterDialogController. |
| 16 // and is lazily created when a Media Router dialog needs to be shown. | |
| 17 // The MediaRouterDialogController allows creating, querying, and removing a | |
| 18 // Media Router dialog modal to the initiator WebContents. | |
| 19 // 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. |
| 20 class MediaRouterDialogController | 17 class MediaRouterDialogControllerImpl |
| 21 : public content::WebContentsUserData<MediaRouterDialogController> { | 18 : public content::WebContentsUserData<MediaRouterDialogControllerImpl>, |
| 19 public MediaRouterDialogController { | |
| 22 public: | 20 public: |
| 23 ~MediaRouterDialogController() override; | 21 ~MediaRouterDialogControllerImpl() override; |
| 24 | 22 |
| 25 // Gets a reference to the MediaRouterDialogController associated with | 23 static MediaRouterDialogControllerImpl* GetOrCreateForWebContents( |
| 26 // |web_contents|, creating one if it does not exist. The returned pointer is | |
| 27 // guaranteed to be non-null. | |
| 28 static MediaRouterDialogController* GetOrCreateForWebContents( | |
| 29 content::WebContents* web_contents); | 24 content::WebContents* web_contents); |
| 30 | 25 |
| 26 // SuperClass: | |
|
apacible
2015/07/22 04:00:08
Oops, some miscommunication for this line --
Thi
whywhat
2015/07/22 22:55:01
Yup, now it makes much more sense and I changed it
| |
| 27 bool ShowMediaRouterDialogForPresentation( | |
| 28 scoped_ptr<CreatePresentationSessionRequest> request) override; | |
| 29 | |
| 31 // Shows the media router dialog modal to the initiator WebContents. | 30 // Shows the media router dialog modal to the initiator WebContents. |
| 32 // Creates the dialog if it did not exist prior to this call. | 31 // Creates the dialog if it did not exist prior to this call. |
| 33 // If the dialog already exists, brings the dialog to the front. | 32 // If the dialog already exists, brings the dialog to the front. |
| 34 // Returns WebContents for the media router dialog. | 33 // Returns WebContents for the media router dialog. |
| 35 content::WebContents* ShowMediaRouterDialog(); | 34 content::WebContents* ShowMediaRouterDialog(); |
| 36 | 35 |
| 37 // Creates a Media Router modal dialog using the initiator and parameters | |
| 38 // specified in |request|. If the dialog already exists, brings the dialog | |
| 39 // to the front, but does not change the dialog with |request|. | |
| 40 // Returns WebContents for the media router dialog if a dialog was created. | |
| 41 // Otherwise returns nullptr and |request| is deleted. | |
| 42 content::WebContents* ShowMediaRouterDialogForPresentation( | |
| 43 scoped_ptr<CreatePresentationSessionRequest> request); | |
| 44 | |
| 45 // Returns the media router dialog WebContents. | 36 // Returns the media router dialog WebContents. |
| 46 // Returns nullptr if there is no dialog. | 37 // Returns nullptr if there is no dialog. |
| 47 content::WebContents* GetMediaRouterDialog() const; | 38 content::WebContents* GetMediaRouterDialog() const; |
| 48 | 39 |
| 49 // Closes the media router dialog. This will destroy the dialog WebContents. | 40 // Closes the media router dialog. This will destroy the dialog WebContents. |
| 50 // It is an error to call this function if there is currently no dialog. | 41 // It is an error to call this function if there is currently no dialog. |
| 51 void CloseMediaRouterDialog(); | 42 void CloseMediaRouterDialog(); |
| 52 | 43 |
| 53 private: | 44 private: |
| 54 class DialogWebContentsObserver; | 45 class DialogWebContentsObserver; |
| 55 class InitiatorWebContentsObserver; | 46 class InitiatorWebContentsObserver; |
| 56 friend class content::WebContentsUserData<MediaRouterDialogController>; | 47 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>; |
| 57 | 48 |
| 58 // Use MediaRouterDialogController::CreateForWebContents() to create an | 49 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an |
| 59 // instance. | 50 // instance. |
| 60 explicit MediaRouterDialogController(content::WebContents* web_contents); | 51 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents); |
| 61 | 52 |
| 62 // Creates a new media router dialog modal to |initiator_|. | 53 // Creates a new media router dialog modal to |initiator_|. |
| 63 void CreateMediaRouterDialog(); | 54 void CreateMediaRouterDialog(); |
| 64 | 55 |
| 65 // Resets this dialog controller to an empty state. | 56 // Resets this dialog controller to an empty state. |
| 66 void Reset(); | 57 void Reset(); |
| 67 | 58 |
| 68 // Invoked when the dialog WebContents has navigated. | 59 // Invoked when the dialog WebContents has navigated. |
| 69 void OnDialogNavigated(const content::LoadCommittedDetails& details); | 60 void OnDialogNavigated(const content::LoadCommittedDetails& details); |
| 70 | 61 |
| 71 void PopulateDialog(content::WebContents* media_router_dialog); | 62 void PopulateDialog(content::WebContents* media_router_dialog); |
| 72 | 63 |
| 73 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | 64 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; |
| 74 scoped_ptr<DialogWebContentsObserver> dialog_observer_; | 65 scoped_ptr<DialogWebContentsObserver> dialog_observer_; |
| 75 | 66 |
| 76 content::WebContents* const initiator_; | 67 content::WebContents* const initiator_; |
| 77 | 68 |
| 78 // True if the controller is waiting for a new media router dialog to be | 69 // True if the controller is waiting for a new media router dialog to be |
| 79 // created. | 70 // created. |
| 80 bool media_router_dialog_pending_; | 71 bool media_router_dialog_pending_; |
| 81 | 72 |
| 82 // Data for dialogs created under a Presentation API context. | 73 // Data for dialogs created under a Presentation API context. |
| 83 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and | 74 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and |
| 84 // passed to the MediaRouterUI when it is initialized. | 75 // passed to the MediaRouterUI when it is initialized. |
| 85 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | 76 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; |
| 86 | 77 |
| 87 base::ThreadChecker thread_checker_; | 78 base::ThreadChecker thread_checker_; |
| 88 | 79 |
| 89 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); | 80 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerImpl); |
| 90 }; | 81 }; |
| 91 | 82 |
| 92 } // namespace media_router | 83 } // namespace media_router |
| 93 | 84 |
| 94 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H _ | 85 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_I MPL_H_ |
| OLD | NEW |