Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: chrome/browser/media/router/media_router_dialog_controller.h

Issue 1436703002: Revert of [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "chrome/browser/media/router/create_presentation_connection_request.h" 13 #include "chrome/browser/media/router/create_presentation_session_request.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 15
16 namespace content { 16 namespace content {
17 class WebContents; 17 class WebContents;
18 } // namespace content 18 } // namespace content
19 19
20 namespace media_router { 20 namespace media_router {
21 21
22 // An abstract base class for Media Router dialog controllers. Tied to a 22 // An abstract base class for Media Router dialog controllers. Tied to a
23 // WebContents known as the |initiator|, and is lazily created when a Media 23 // WebContents known as the |initiator|, and is lazily created when a Media
24 // Router dialog needs to be shown. The MediaRouterDialogController allows 24 // Router dialog needs to be shown. The MediaRouterDialogController allows
25 // showing and closing a Media Router dialog modal to the initiator WebContents. 25 // showing and closing a Media Router dialog modal to the initiator WebContents.
26 // This class is not thread safe and must be called on the UI thread. 26 // This class is not thread safe and must be called on the UI thread.
27 class MediaRouterDialogController { 27 class MediaRouterDialogController {
28 public: 28 public:
29 virtual ~MediaRouterDialogController(); 29 virtual ~MediaRouterDialogController();
30 30
31 // Gets a reference to the MediaRouterDialogController associated with 31 // Gets a reference to the MediaRouterDialogController associated with
32 // |web_contents|, creating one if it does not exist. The returned pointer is 32 // |web_contents|, creating one if it does not exist. The returned pointer is
33 // guaranteed to be non-null. 33 // guaranteed to be non-null.
34 static MediaRouterDialogController* GetOrCreateForWebContents( 34 static MediaRouterDialogController* GetOrCreateForWebContents(
35 content::WebContents* web_contents); 35 content::WebContents* web_contents);
36 36
37 // Shows the media router dialog modal to |initiator_| and the parameters 37 // Shows the media router dialog modal to |initiator_| and the parameters
38 // specified in |request|. 38 // specified in |request|.
39 // Creates the dialog if it did not exist prior to this call, returns true. 39 // Creates the dialog if it did not exist prior to this call, returns true.
40 // If the dialog already exists, brings it to the front but doesn't change the 40 // If the dialog already exists, brings it to the front but doesn't change the
41 // dialog with |request|, returns false and |request| is deleted. 41 // dialog with |request|, returns false and |request| is deleted.
42 bool ShowMediaRouterDialogForPresentation( 42 bool ShowMediaRouterDialogForPresentation(
43 scoped_ptr<CreatePresentationConnectionRequest> request); 43 scoped_ptr<CreatePresentationSessionRequest> request);
44 44
45 // Shows the media router dialog modal to |initiator_|. 45 // Shows the media router dialog modal to |initiator_|.
46 // Creates the dialog if it did not exist prior to this call, returns true. 46 // Creates the dialog if it did not exist prior to this call, returns true.
47 // If the dialog already exists, brings it to the front, returns false. 47 // If the dialog already exists, brings it to the front, returns false.
48 virtual bool ShowMediaRouterDialog(); 48 virtual bool ShowMediaRouterDialog();
49 49
50 // Hides the media router dialog. 50 // Hides the media router dialog.
51 // It is a no-op to call this function if there is currently no dialog. 51 // It is a no-op to call this function if there is currently no dialog.
52 void HideMediaRouterDialog(); 52 void HideMediaRouterDialog();
53 53
54 // Indicates if the media router dialog already exists. 54 // Indicates if the media router dialog already exists.
55 virtual bool IsShowingMediaRouterDialog() const = 0; 55 virtual bool IsShowingMediaRouterDialog() const = 0;
56 56
57 protected: 57 protected:
58 // Use MediaRouterDialogController::GetOrCreateForWebContents() to create an 58 // Use MediaRouterDialogController::GetOrCreateForWebContents() to create an
59 // instance. 59 // instance.
60 explicit MediaRouterDialogController(content::WebContents* initiator); 60 explicit MediaRouterDialogController(content::WebContents* initiator);
61 61
62 // Activates the WebContents that initiated the dialog, e.g. focuses the tab. 62 // Activates the WebContents that initiated the dialog, e.g. focuses the tab.
63 void ActivateInitiatorWebContents(); 63 void ActivateInitiatorWebContents();
64 64
65 // Passes the ownership of the CreatePresentationConnectionRequest to the 65 // Passes the ownership of the CreatePresentationSessionRequest to the caller.
66 // caller. 66 scoped_ptr<CreatePresentationSessionRequest> TakePresentationRequest();
67 scoped_ptr<CreatePresentationConnectionRequest> TakeCreateConnectionRequest();
68 67
69 // Returns the CreatePresentationConnectionRequest to the caller but keeps the 68 // Returns the CreatePresentationSessionRequest to the caller but keeps the
70 // ownership with the MediaRouterDialogController. 69 // ownership with the MediaRouterDialogController.
71 const CreatePresentationConnectionRequest* create_connection_request() const { 70 const CreatePresentationSessionRequest* presentation_request() const {
72 return create_connection_request_.get(); 71 return presentation_request_.get();
73 } 72 }
74 73
75 // Returns the WebContents that initiated showing the dialog. 74 // Returns the WebContents that initiated showing the dialog.
76 content::WebContents* initiator() const { return initiator_; } 75 content::WebContents* initiator() const { return initiator_; }
77 76
78 // Resets the state of the controller. Must be called from the overrides. 77 // Resets the state of the controller. Must be called from the overrides.
79 virtual void Reset(); 78 virtual void Reset();
80 // Creates a new media router dialog modal to |initiator_|. 79 // Creates a new media router dialog modal to |initiator_|.
81 virtual void CreateMediaRouterDialog() = 0; 80 virtual void CreateMediaRouterDialog() = 0;
82 // Closes the media router dialog if it exists. 81 // Closes the media router dialog if it exists.
83 virtual void CloseMediaRouterDialog() = 0; 82 virtual void CloseMediaRouterDialog() = 0;
84 83
85 base::ThreadChecker thread_checker_; 84 base::ThreadChecker thread_checker_;
86 85
87 private: 86 private:
88 class InitiatorWebContentsObserver; 87 class InitiatorWebContentsObserver;
89 88
90 // An observer for the |initiator_| that closes the dialog when |initiator_| 89 // An observer for the |initiator_| that closes the dialog when |initiator_|
91 // is destroyed or navigated. 90 // is destroyed or navigated.
92 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; 91 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_;
93 content::WebContents* const initiator_; 92 content::WebContents* const initiator_;
94 93
95 // Data for dialogs created at the request of the Presentation API. 94 // Data for dialogs created at the request of the Presentation API.
96 // Passed from the caller via ShowMediaRouterDialogForPresentation to the 95 // Passed from the caller via ShowMediaRouterDialogForPresentation to the
97 // dialog when it is initialized. 96 // dialog when it is initialized.
98 scoped_ptr<CreatePresentationConnectionRequest> create_connection_request_; 97 scoped_ptr<CreatePresentationSessionRequest> presentation_request_;
99 98
100 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); 99 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController);
101 }; 100 };
102 101
103 } // namespace media_router 102 } // namespace media_router
104 103
105 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ 104 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router.gypi ('k') | chrome/browser/media/router/media_router_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698