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" | |
| 9 #include "chrome/browser/media/router/create_presentation_session_request.h" | 10 #include "chrome/browser/media/router/create_presentation_session_request.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | |
| 10 | 12 |
| 11 namespace content { | 13 namespace content { |
| 12 class WebContents; | 14 class WebContents; |
| 13 } // namespace content | 15 } // namespace content |
| 14 | 16 |
| 15 namespace media_router { | 17 namespace media_router { |
| 16 | 18 |
| 17 // An implementation of this interface is tied to a WebContents known as the | 19 // An implementation of this interface is tied to a WebContents known as the |
|
imcheng
2015/07/23 00:41:14
nit: It is no longer an interface but an abstract
| |
| 18 // initiator, and is lazily created when a Media Router dialog needs to be | 20 // initiator, and is lazily created when a Media Router dialog needs to be |
| 19 // shown. The MediaRouterDialogController allows creating, querying, and | 21 // shown. The MediaRouterDialogController allows creating, querying, and |
| 20 // removing a Media Router dialog modal to the initiator WebContents. | 22 // removing a Media Router dialog modal to the initiator WebContents. |
| 21 // This class is not thread safe and must be called on the UI thread. | 23 // This class is not thread safe and must be called on the UI thread. |
| 22 class MediaRouterDialogController { | 24 class MediaRouterDialogController { |
| 23 public: | 25 public: |
| 24 virtual ~MediaRouterDialogController() = default; | 26 virtual ~MediaRouterDialogController(); |
| 25 | 27 |
| 26 // Gets a reference to the MediaRouterDialogController associated with | 28 // Gets a reference to the MediaRouterDialogController associated with |
| 27 // |web_contents|, creating one if it does not exist. The returned pointer is | 29 // |web_contents|, creating one if it does not exist. The returned pointer is |
| 28 // guaranteed to be non-null. | 30 // guaranteed to be non-null. |
| 29 static MediaRouterDialogController* GetOrCreateForWebContents( | 31 static MediaRouterDialogController* GetOrCreateForWebContents( |
| 30 content::WebContents* web_contents); | 32 content::WebContents* web_contents); |
| 31 | 33 |
| 32 // Creates a Media Router modal dialog using the initiator and parameters | 34 // Creates a Media Router modal dialog using the initiator and parameters |
| 33 // specified in |request|. If the dialog already exists, brings the dialog | 35 // specified in |request|. If the dialog already exists, brings the dialog |
| 34 // to the front, but does not change the dialog with |request|. | 36 // to the front, but does not change the dialog with |request|. |
| 35 // Returns WebContents for the media router dialog if a dialog was created. | 37 // Returns WebContents for the media router dialog if a dialog was created. |
| 36 // Otherwise returns false and |request| is deleted. | 38 // Otherwise returns false and |request| is deleted. |
| 37 virtual bool ShowMediaRouterDialogForPresentation( | 39 virtual bool ShowMediaRouterDialogForPresentation( |
| 38 scoped_ptr<CreatePresentationSessionRequest> request) = 0; | 40 scoped_ptr<CreatePresentationSessionRequest> request) = 0; |
| 41 | |
| 42 // Closes the media router dialog. | |
| 43 // It is an error to call this function if there is currently no dialog. | |
| 44 virtual void CloseMediaRouterDialog() = 0; | |
| 45 | |
| 46 protected: | |
|
imcheng
2015/07/23 00:41:14
nit:indent
whywhat
2015/07/23 21:20:09
Done.
| |
| 47 // Use MediaRouterDialogController::GetOrCreateForWebContents() to create an | |
| 48 // instance. | |
| 49 explicit MediaRouterDialogController(content::WebContents* initiator); | |
| 50 | |
| 51 void ActivateInitiatorWebContents(); | |
| 52 void CreateMediaRouterDialog(); | |
| 53 scoped_ptr<CreatePresentationSessionRequest> PassPresentationRequest(); | |
| 54 void SetPresentationRequest( | |
| 55 scoped_ptr<CreatePresentationSessionRequest> request); | |
| 56 | |
| 57 content::WebContents* initiator() { return initiator_; } | |
| 58 | |
| 59 virtual void Reset() = 0; | |
|
imcheng
2015/07/23 00:41:14
this needs documentation.
whywhat
2015/07/23 21:20:09
Done.
| |
| 60 | |
| 61 private: | |
|
imcheng
2015/07/23 00:41:14
nit: indent
whywhat
2015/07/23 21:20:09
Done.
| |
| 62 class InitiatorWebContentsObserver; | |
| 63 | |
| 64 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | |
| 65 content::WebContents* const initiator_; | |
| 66 | |
| 67 // Data for dialogs created under a Presentation API context. | |
| 68 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and | |
| 69 // passed to the dialog when it is initialized. | |
| 70 scoped_ptr<CreatePresentationSessionRequest> presentation_request_; | |
| 39 }; | 71 }; |
|
imcheng
2015/07/23 00:41:14
DISALLOW_COPY_AND_ASSIGN ?
whywhat
2015/07/23 21:20:09
Done.
| |
| 40 | 72 |
| 41 } // namespace media_router | 73 } // namespace media_router |
| 42 | 74 |
| 43 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ | 75 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
| OLD | NEW |