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_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_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | |
mark a. foltz
2015/07/14 21:36:32
Not used
| |
9 #include "chrome/browser/media/router/create_session_request.h" | 10 #include "chrome/browser/media/router/create_session_request.h" |
11 #include "chrome/browser/media/router/media_router.h" | |
10 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
11 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
12 | 14 |
13 namespace media_router { | 15 namespace media_router { |
14 | 16 |
15 // An instance of this class is tied to a WebContents known as the initiator, | 17 // An instance of this class is tied to a WebContents known as the initiator, |
16 // and is lazily created when a Media Router dialog needs to be shown. | 18 // and is lazily created when a Media Router dialog needs to be shown. |
17 // The MediaRouterDialogController allows creating, querying, and removing a | 19 // The MediaRouterDialogController allows creating, querying, and removing a |
18 // Media Router dialog modal to the initiator WebContents. | 20 // Media Router dialog modal to the initiator WebContents. |
19 // This class is not thread safe and must be called on the UI thread. | 21 // This class is not thread safe and must be called on the UI thread. |
(...skipping 23 matching lines...) Expand all Loading... | |
43 scoped_ptr<CreateSessionRequest> request); | 45 scoped_ptr<CreateSessionRequest> request); |
44 | 46 |
45 // Returns the media router dialog WebContents. | 47 // Returns the media router dialog WebContents. |
46 // Returns nullptr if there is no dialog. | 48 // Returns nullptr if there is no dialog. |
47 content::WebContents* GetMediaRouterDialog() const; | 49 content::WebContents* GetMediaRouterDialog() const; |
48 | 50 |
49 // Closes the media router dialog. This will destroy the dialog WebContents. | 51 // 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. | 52 // It is an error to call this function if there is currently no dialog. |
51 void CloseMediaRouterDialog(); | 53 void CloseMediaRouterDialog(); |
52 | 54 |
55 // Called by the dialog when it is about to make a presentation route request | |
haibinlu
2015/07/14 01:44:55
create route
imcheng
2015/07/14 16:45:37
This is specific to presentation route requests.
| |
56 // to ensure the response can be received and handled properly even when | |
57 // the dialog is destroyed while the request is in progress. | |
58 // Returns a MediaRouteResponseCallback that can be used to be used as the | |
59 // callback argument in |MediaRouter::CreateRoute()|. | |
60 // |route_response_callback|: Callback to the dialog to invoke when the | |
61 // presentation route response comes back, if the dialog still exists. | |
62 // |presentation_request|: The Presentation API request to respond to when | |
63 // route reponse comes back, or nullptr if the request did not originate from | |
64 // Presentation API. | |
mark a. foltz
2015/07/14 21:36:32
The comment above suggests that this is only for P
| |
65 MediaRouteResponseCallback AddPresentationRouteRequest( | |
66 const MediaRouteResponseCallback& route_response_callback, | |
67 scoped_ptr<CreateSessionRequest> presentation_request); | |
mark a. foltz
2015/07/14 21:36:32
CreateSessionRequest -> CreatePresentationSessionR
imcheng
2015/07/16 01:06:52
Done.
| |
68 | |
53 private: | 69 private: |
70 class BrowserInitiatedCallbacks; | |
54 class DialogWebContentsObserver; | 71 class DialogWebContentsObserver; |
55 class InitiatorWebContentsObserver; | 72 class InitiatorWebContentsObserver; |
73 class MediaRouterDialogCallbacks; | |
74 class PresentationInitiatedCallbacks; | |
56 friend class content::WebContentsUserData<MediaRouterDialogController>; | 75 friend class content::WebContentsUserData<MediaRouterDialogController>; |
57 | 76 |
58 // Use MediaRouterDialogController::CreateForWebContents() to create an | 77 // Use MediaRouterDialogController::CreateForWebContents() to create an |
59 // instance. | 78 // instance. |
60 explicit MediaRouterDialogController(content::WebContents* web_contents); | 79 explicit MediaRouterDialogController(content::WebContents* web_contents); |
61 | 80 |
62 // Creates a new media router dialog modal to |initiator_|. | 81 // Creates a new media router dialog modal to |initiator_|. |
63 void CreateMediaRouterDialog(); | 82 void CreateMediaRouterDialog(); |
64 | 83 |
65 // Resets this dialog controller to an empty state. | 84 // Resets this dialog controller to an empty state. |
66 void Reset(); | 85 void Reset(); |
67 | 86 |
68 // Invoked when the dialog WebContents has navigated. | 87 // Invoked when the dialog WebContents has navigated. |
69 void OnDialogNavigated(const content::LoadCommittedDetails& details); | 88 void OnDialogNavigated(const content::LoadCommittedDetails& details); |
70 | 89 |
71 void PopulateDialog(content::WebContents* media_router_dialog); | 90 void PopulateDialog(content::WebContents* media_router_dialog); |
72 | 91 |
92 // Destroys |callbacks| by removing it from |pending_dialog_callbacks_|. | |
93 // Called by MediaRouterDialogCallbacks after it receives route response and | |
94 // is done processing it. | |
95 // |callbacks|: The MediaRouterDialogCallbacks to destroy. | |
96 void DestroyDialogCallbacks(MediaRouterDialogCallbacks* callbacks); | |
mark a. foltz
2015/07/14 21:36:32
This might be better named RemoveDialogCallbacks()
| |
97 | |
73 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; | 98 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; |
74 scoped_ptr<DialogWebContentsObserver> dialog_observer_; | 99 scoped_ptr<DialogWebContentsObserver> dialog_observer_; |
75 | 100 |
76 content::WebContents* const initiator_; | 101 content::WebContents* const initiator_; |
77 | 102 |
78 // True if the controller is waiting for a new media router dialog to be | 103 // True if the controller is waiting for a new media router dialog to be |
79 // created. | 104 // created. |
80 bool media_router_dialog_pending_; | 105 bool media_router_dialog_pending_; |
81 | 106 |
82 // Data for dialogs created under a Presentation API context. | 107 // Data for dialogs created under a Presentation API context. |
83 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and | 108 // Passed from the caller of ShowMediaRouterDialogForPresentation(), and |
84 // passed to the MediaRouterUI when it is initialized. | 109 // passed to the MediaRouterUI when it is initialized. |
85 scoped_ptr<CreateSessionRequest> presentation_request_; | 110 scoped_ptr<CreateSessionRequest> presentation_request_; |
86 | 111 |
112 // MediaRouterDialogCallbacks corresponding to presentation route requests | |
haibinlu
2015/07/14 01:44:55
create route requests
imcheng
2015/07/14 16:45:37
ditto
| |
113 // made from dialogs created from this instance. Note that they may outlive | |
114 // their corresponding dialogs. | |
115 ScopedVector<MediaRouterDialogCallbacks> pending_dialog_callbacks_; | |
116 | |
87 base::ThreadChecker thread_checker_; | 117 base::ThreadChecker thread_checker_; |
88 | 118 |
89 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); | 119 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); |
90 }; | 120 }; |
91 | 121 |
92 } // namespace media_router | 122 } // namespace media_router |
93 | 123 |
94 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H _ | 124 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H _ |
OLD | NEW |