Index: chrome/browser/media/router/media_router_dialog_controller.h |
diff --git a/chrome/browser/media/router/media_router_dialog_controller.h b/chrome/browser/media/router/media_router_dialog_controller.h |
index a627b44d91d7c8baa5f41ebc178a359ce57d3acc..8bd183d51243edff260891c0c0be4ca4e640d76b 100644 |
--- a/chrome/browser/media/router/media_router_dialog_controller.h |
+++ b/chrome/browser/media/router/media_router_dialog_controller.h |
@@ -6,7 +6,10 @@ |
#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
#include "base/macros.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/thread_checker.h" |
#include "chrome/browser/media/router/create_presentation_session_request.h" |
+#include "content/public/browser/web_contents_observer.h" |
namespace content { |
class WebContents; |
@@ -14,14 +17,14 @@ class WebContents; |
namespace media_router { |
-// An implementation of this interface is tied to a WebContents known as the |
-// initiator, and is lazily created when a Media Router dialog needs to be |
-// shown. The MediaRouterDialogController allows creating, querying, and |
-// removing a Media Router dialog modal to the initiator WebContents. |
+// An abstract base class for Media Router dialog controllers. Tied to a |
+// WebContents known as the |initiator|, and is lazily created when a Media |
+// Router dialog needs to be shown. The MediaRouterDialogController allows |
+// showing and closing a Media Router dialog modal to the initiator WebContents. |
// This class is not thread safe and must be called on the UI thread. |
class MediaRouterDialogController { |
public: |
- virtual ~MediaRouterDialogController() = default; |
+ virtual ~MediaRouterDialogController(); |
// Gets a reference to the MediaRouterDialogController associated with |
// |web_contents|, creating one if it does not exist. The returned pointer is |
@@ -34,8 +37,55 @@ class MediaRouterDialogController { |
// to the front, but does not change the dialog with |request|. |
// Returns WebContents for the media router dialog if a dialog was created. |
// Otherwise returns false and |request| is deleted. |
- virtual bool ShowMediaRouterDialogForPresentation( |
- scoped_ptr<CreatePresentationSessionRequest> request) = 0; |
+ bool ShowMediaRouterDialogForPresentation( |
+ scoped_ptr<CreatePresentationSessionRequest> request); |
+ |
+ // 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.
|
+ // It is an error to call this function if there is currently no dialog. |
+ virtual void CloseMediaRouterDialog(); |
+ |
+ // Indicates if the media router dialog already exists. |
+ virtual bool IsShowingMediaRouterDialog() = 0; |
mark a. foltz
2015/07/24 20:10:35
const?
whywhat
2015/07/28 18:52:53
Done.
|
+ |
+ // Creates a new media router dialog modal to |initiator_|. |
+ 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.
|
+ |
+ // 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.
|
+ // Creates the dialog if it did not exist prior to this call. |
+ // If the dialog already exists, brings the dialog to the front. |
+ virtual void ShowMediaRouterDialog(); |
+ |
+ protected: |
+ // 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
|
+ // instance. |
+ explicit MediaRouterDialogController(content::WebContents* initiator); |
+ |
+ void ActivateInitiatorWebContents(); |
+ void ObserveInitiatorWebContents(); |
+ |
+ scoped_ptr<CreatePresentationSessionRequest> PassPresentationRequest(); |
+ void TakePresentationRequest( |
+ scoped_ptr<CreatePresentationSessionRequest> request); |
+ |
+ 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
|
+ |
+ // Resets the state of the controller. Must be called from the overrides. |
+ 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
|
+ |
+ base::ThreadChecker thread_checker_; |
+ |
+ private: |
+ class InitiatorWebContentsObserver; |
+ |
+ 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.
|
+ content::WebContents* const initiator_; |
+ |
+ // 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.
|
+ // 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.
|
+ // passed to the dialog when it is initialized. |
+ scoped_ptr<CreatePresentationSessionRequest> presentation_request_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); |
}; |
} // namespace media_router |