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_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/threading/thread_checker.h" | |
| 9 #include "chrome/browser/media/router/create_presentation_session_request.h" | 11 #include "chrome/browser/media/router/create_presentation_session_request.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | |
| 10 | 13 |
| 11 namespace content { | 14 namespace content { |
| 12 class WebContents; | 15 class WebContents; |
| 13 } // namespace content | 16 } // namespace content |
| 14 | 17 |
| 15 namespace media_router { | 18 namespace media_router { |
| 16 | 19 |
| 17 // An implementation of this interface is tied to a WebContents known as the | 20 // An abstract base class for Media Router dialog controllers. Tied to a |
| 18 // initiator, and is lazily created when a Media Router dialog needs to be | 21 // WebContents known as the |initiator|, and is lazily created when a Media |
| 19 // shown. The MediaRouterDialogController allows creating, querying, and | 22 // Router dialog needs to be shown. The MediaRouterDialogController allows |
| 20 // removing a Media Router dialog modal to the initiator WebContents. | 23 // showing and closing a Media Router dialog modal to the initiator WebContents. |
| 21 // This class is not thread safe and must be called on the UI thread. | 24 // This class is not thread safe and must be called on the UI thread. |
| 22 class MediaRouterDialogController { | 25 class MediaRouterDialogController { |
| 23 public: | 26 public: |
| 24 virtual ~MediaRouterDialogController() = default; | 27 virtual ~MediaRouterDialogController(); |
| 25 | 28 |
| 26 // Gets a reference to the MediaRouterDialogController associated with | 29 // Gets a reference to the MediaRouterDialogController associated with |
| 27 // |web_contents|, creating one if it does not exist. The returned pointer is | 30 // |web_contents|, creating one if it does not exist. The returned pointer is |
| 28 // guaranteed to be non-null. | 31 // guaranteed to be non-null. |
| 29 static MediaRouterDialogController* GetOrCreateForWebContents( | 32 static MediaRouterDialogController* GetOrCreateForWebContents( |
|
mark a. foltz
2015/07/24 20:10:34
Does this need to be public or is it an implementa
| |
| 30 content::WebContents* web_contents); | 33 content::WebContents* web_contents); |
| 31 | 34 |
| 32 // Creates a Media Router modal dialog using the initiator and parameters | 35 // Creates a Media Router modal dialog using the initiator and parameters |
| 33 // specified in |request|. If the dialog already exists, brings the dialog | 36 // specified in |request|. If the dialog already exists, brings the dialog |
| 34 // to the front, but does not change the dialog with |request|. | 37 // to the front, but does not change the dialog with |request|. |
| 35 // Returns WebContents for the media router dialog if a dialog was created. | 38 // Returns WebContents for the media router dialog if a dialog was created. |
| 36 // Otherwise returns false and |request| is deleted. | 39 // Otherwise returns false and |request| is deleted. |
| 37 virtual bool ShowMediaRouterDialogForPresentation( | 40 bool ShowMediaRouterDialogForPresentation( |
| 38 scoped_ptr<CreatePresentationSessionRequest> request) = 0; | 41 scoped_ptr<CreatePresentationSessionRequest> request); |
| 42 | |
| 43 // Closes the media router dialog. Must be called from the overrides. | |
|
imcheng
2015/07/24 22:09:28
sounds like this should be moved to protected? Or
whywhat
2015/07/28 18:52:53
Done.
| |
| 44 // It is an error to call this function if there is currently no dialog. | |
| 45 virtual void CloseMediaRouterDialog(); | |
| 46 | |
| 47 // Indicates if the media router dialog already exists. | |
| 48 virtual bool IsShowingMediaRouterDialog() = 0; | |
|
mark a. foltz
2015/07/24 20:10:35
const?
whywhat
2015/07/28 18:52:53
Done.
| |
| 49 | |
| 50 // Creates a new media router dialog modal to |initiator_|. | |
| 51 virtual void CreateMediaRouterDialog() = 0; | |
|
mark a. foltz
2015/07/24 20:10:35
Would a client ever want to create a dialog withou
whywhat
2015/07/28 18:52:53
Done.
| |
| 52 | |
| 53 // Shows the media router dialog modal to the initiator WebContents. | |
|
mark a. foltz
2015/07/24 20:10:34
(1) for consistency, "modal to |initiator_|."
(2)
whywhat
2015/07/28 18:52:53
Done.
| |
| 54 // Creates the dialog if it did not exist prior to this call. | |
| 55 // If the dialog already exists, brings the dialog to the front. | |
| 56 virtual void ShowMediaRouterDialog(); | |
| 57 | |
| 58 protected: | |
| 59 // Use MediaRouterDialogController::GetOrCreateForWebContents() to create an | |
|
mark a. foltz
2015/07/24 20:10:35
Or should the public API be ShowMediaRouterDialog{
whywhat
2015/07/28 18:52:53
I believe there's some advantage to be able to cac
| |
| 60 // instance. | |
| 61 explicit MediaRouterDialogController(content::WebContents* initiator); | |
| 62 | |
| 63 void ActivateInitiatorWebContents(); | |
| 64 void ObserveInitiatorWebContents(); | |
| 65 | |
| 66 scoped_ptr<CreatePresentationSessionRequest> PassPresentationRequest(); | |
| 67 void TakePresentationRequest( | |
| 68 scoped_ptr<CreatePresentationSessionRequest> request); | |
| 69 | |
| 70 content::WebContents* initiator() { return initiator_; } | |
|
mark a. foltz
2015/07/24 20:10:34
Should this method be const?
whywhat
2015/07/28 18:52:53
If I can use const content::WebContents* everywher
| |
| 71 | |
| 72 // Resets the state of the controller. Must be called from the overrides. | |
| 73 virtual void Reset(); | |
|
imcheng
2015/07/24 22:09:28
similar comment to CloseMediaRouterDialog() above
whywhat
2015/07/28 18:52:53
I don't think it's justified in the case of Reset
| |
| 74 | |
| 75 base::ThreadChecker thread_checker_; | |
| 76 | |
| 77 private: | |
| 78 class InitiatorWebContentsObserver; | |
| 79 | |
| 80 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | |
|
mark a. foltz
2015/07/24 20:10:34
It would be helpful to include a comment here sinc
whywhat
2015/07/28 18:52:53
Done.
| |
| 81 content::WebContents* const initiator_; | |
| 82 | |
| 83 // Data for dialogs created under a Presentation API context. | |
|
mark a. foltz
2015/07/24 20:10:35
created at the request of the Presentation API.
whywhat
2015/07/28 18:52:53
Done.
| |
| 84 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and | |
|
mark a. foltz
2015/07/24 20:10:34
Passed from the caller via SMRDFP to the dialog wh
whywhat
2015/07/28 18:52:53
Done.
| |
| 85 // passed to the dialog when it is initialized. | |
| 86 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); | |
| 39 }; | 89 }; |
| 40 | 90 |
| 41 } // namespace media_router | 91 } // namespace media_router |
| 42 | 92 |
| 43 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ | 93 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
| OLD | NEW |