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

Side by Side Diff: content/browser/renderer_host/media/media_stream_ui_controller.h

Issue 11339014: Move content\browser\renderer_host\media to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // MediaStreamUIController is used to decide which of the available capture 5 // MediaStreamUIController is used to decide which of the available capture
6 // device to use as well as getting user permission to use the capture device. 6 // device to use as well as getting user permission to use the capture device.
7 // There will be one instance of MediaStreamDeviceSettings handling all 7 // There will be one instance of MediaStreamDeviceSettings handling all
8 // requests. 8 // requests.
9 9
10 // Expected call flow: 10 // Expected call flow:
11 // 1. MakeUIRequest() is called to create a new request to the UI for capture 11 // 1. MakeUIRequest() is called to create a new request to the UI for capture
12 // device access. 12 // device access.
13 // 2. AddAvailableDevicesToRequest() is called with a list of currently 13 // 2. AddAvailableDevicesToRequest() is called with a list of currently
14 // available devices. 14 // available devices.
15 // 3. Pick device and get user confirmation. 15 // 3. Pick device and get user confirmation.
16 // 4. Confirm by calling SettingsRequester::DevicesAccepted(). 16 // 4. Confirm by calling SettingsRequester::DevicesAccepted().
17 // Repeat step 1 - 4 for new device requests. 17 // Repeat step 1 - 4 for new device requests.
18 18
19 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_ 19 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
20 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_ 20 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
21 21
22 #include <map> 22 #include <map>
23 #include <string> 23 #include <string>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/memory/weak_ptr.h" 26 #include "base/memory/weak_ptr.h"
27 #include "content/browser/renderer_host/media/media_stream_provider.h" 27 #include "content/browser/renderer_host/media/media_stream_provider.h"
28 #include "content/public/browser/web_contents_delegate.h" 28 #include "content/public/browser/web_contents_delegate.h"
29 29
30 30 namespace content {
31 namespace media_stream { 31 class MediaStreamRequestForUI;
32 class SettingsRequester; 32 class SettingsRequester;
33 }
34
35 namespace content {
36
37 class MediaStreamRequestForUI;
38 33
39 // MediaStreamUIController is responsible for getting user permission to use 34 // MediaStreamUIController is responsible for getting user permission to use
40 // a media capture device as well as selecting what device to use. 35 // a media capture device as well as selecting what device to use.
41 class CONTENT_EXPORT MediaStreamUIController { 36 class CONTENT_EXPORT MediaStreamUIController {
42 public: 37 public:
43 explicit MediaStreamUIController(media_stream::SettingsRequester* requester); 38 explicit MediaStreamUIController(SettingsRequester* requester);
44 virtual ~MediaStreamUIController(); 39 virtual ~MediaStreamUIController();
45 40
46 // Called when a new request for the capture device access is made. 41 // Called when a new request for the capture device access is made.
47 // Users are responsbile for cancel the pending request if they don't wait 42 // Users are responsbile for cancel the pending request if they don't wait
48 // for the result from the UI. 43 // for the result from the UI.
49 void MakeUIRequest(const std::string& label, 44 void MakeUIRequest(const std::string& label,
50 int render_process_id, 45 int render_process_id,
51 int render_view_id, 46 int render_view_id,
52 const media_stream::StreamOptions& stream_components, 47 const StreamOptions& stream_components,
53 const GURL& security_origin); 48 const GURL& security_origin);
54 49
55 // Called to cancel a pending UI request of capture device access when the 50 // Called to cancel a pending UI request of capture device access when the
56 // user has no action for the media stream InfoBar. 51 // user has no action for the media stream InfoBar.
57 void CancelUIRequest(const std::string& label); 52 void CancelUIRequest(const std::string& label);
58 53
59 // Called to pass in an array of available devices for a request represented 54 // Called to pass in an array of available devices for a request represented
60 // by |label|. There could be multiple calls for a request. 55 // by |label|. There could be multiple calls for a request.
61 // TODO(xians): use the monitor to get a up-to-date device list and remove 56 // TODO(xians): use the monitor to get a up-to-date device list and remove
62 // this API. 57 // this API.
63 void AddAvailableDevicesToRequest( 58 void AddAvailableDevicesToRequest(
64 const std::string& label, 59 const std::string& label,
65 MediaStreamDeviceType stream_type, 60 MediaStreamDeviceType stream_type,
66 const media_stream::StreamDeviceInfoArray& devices); 61 const StreamDeviceInfoArray& devices);
67 62
68 // Called by the InfoBar when the user grants/denies access to some devices 63 // Called by the InfoBar when the user grants/denies access to some devices
69 // to the webpage. This is placed here, so the request can be cleared from the 64 // to the webpage. This is placed here, so the request can be cleared from the
70 // list of pending requests, instead of letting the InfoBar itself respond to 65 // list of pending requests, instead of letting the InfoBar itself respond to
71 // the requester. An empty list of devices means that access has been denied. 66 // the requester. An empty list of devices means that access has been denied.
72 // This method must be called on the IO thread. 67 // This method must be called on the IO thread.
73 void PostResponse(const std::string& label, 68 void PostResponse(const std::string& label,
74 const content::MediaStreamDevices& devices); 69 const MediaStreamDevices& devices);
75 70
76 // Called to signal the UI indicator that the devices are opened. 71 // Called to signal the UI indicator that the devices are opened.
77 void NotifyUIIndicatorDevicesOpened( 72 void NotifyUIIndicatorDevicesOpened(
78 int render_process_id, 73 int render_process_id,
79 int render_view_id, 74 int render_view_id,
80 const content::MediaStreamDevices& devices); 75 const MediaStreamDevices& devices);
81 76
82 // Called to signal the UI indicator that the devices are closed. 77 // Called to signal the UI indicator that the devices are closed.
83 void NotifyUIIndicatorDevicesClosed( 78 void NotifyUIIndicatorDevicesClosed(
84 int render_process_id, 79 int render_process_id,
85 int render_view_id, 80 int render_view_id,
86 const content::MediaStreamDevices& devices); 81 const MediaStreamDevices& devices);
87 82
88 // Used for testing only. This function is called to use faked UI, which is 83 // Used for testing only. This function is called to use faked UI, which is
89 // needed for server based tests. The first non-opened device(s) will be 84 // needed for server based tests. The first non-opened device(s) will be
90 // picked. 85 // picked.
91 void UseFakeUI(); 86 void UseFakeUI();
92 87
93 private: 88 private:
94 typedef std::map<std::string, MediaStreamRequestForUI*> UIRequests; 89 typedef std::map<std::string, MediaStreamRequestForUI*> UIRequests;
95 90
96 // Returns true if the UI is already processing a request for this render 91 // Returns true if the UI is already processing a request for this render
97 // view. 92 // view.
98 bool IsUIBusy(int render_process_id, int render_view_id); 93 bool IsUIBusy(int render_process_id, int render_view_id);
99 94
100 // Process the next pending request and bring it up to the UI on the given 95 // Process the next pending request and bring it up to the UI on the given
101 // page for user approval. 96 // page for user approval.
102 void ProcessNextRequestForView(int render_process_id, int render_view_id); 97 void ProcessNextRequestForView(int render_process_id, int render_view_id);
103 98
104 // Posts a request to be approved/denied by UI. 99 // Posts a request to be approved/denied by UI.
105 void PostRequestToUI(const std::string& label); 100 void PostRequestToUI(const std::string& label);
106 101
107 // Posts a request to fake UI which is used for testing purpose. 102 // Posts a request to fake UI which is used for testing purpose.
108 void PostRequestToFakeUI(const std::string& label); 103 void PostRequestToFakeUI(const std::string& label);
109 104
110 media_stream::SettingsRequester* requester_; 105 SettingsRequester* requester_;
111 UIRequests requests_; 106 UIRequests requests_;
112 107
113 // See comment above for method UseFakeUI. Used for automated testing. 108 // See comment above for method UseFakeUI. Used for automated testing.
114 bool use_fake_ui_; 109 bool use_fake_ui_;
115 110
116 base::WeakPtrFactory<MediaStreamUIController> weak_ptr_factory_; 111 base::WeakPtrFactory<MediaStreamUIController> weak_ptr_factory_;
117 112
118 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIController); 113 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIController);
119 }; 114 };
120 115
121 } // namespace content 116 } // namespace content
122 117
123 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_ 118 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698