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

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

Issue 16342002: Replace MediaStreamUIController with MediaStreamUIProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
(Empty)
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
3 // found in the LICENSE file.
4
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.
7 // There will be one instance of MediaStreamDeviceSettings handling all
8 // requests.
9
10 // Expected call flow:
11 // 1. MakeUIRequest() is called to create a new request to the UI for capture
12 // device access.
13 // 2. Pick device and get user confirmation.
14 // 3. Confirm by calling SettingsRequester::DevicesAccepted().
15 // Repeat step 1 - 3 for new device requests.
16
17 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
18 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
19
20 #include <map>
21 #include <string>
22
23 #include "base/basictypes.h"
24 #include "content/browser/renderer_host/media/media_stream_provider.h"
25 #include "content/public/browser/web_contents_delegate.h"
26
27 namespace content {
28
29 class MediaStreamRequestForUI;
30 class SettingsRequester;
31
32 // MediaStreamUIController is responsible for getting user permission to use
33 // a media capture device as well as selecting what device to use.
34 class CONTENT_EXPORT MediaStreamUIController {
35 public:
36 explicit MediaStreamUIController(SettingsRequester* requester);
37 virtual ~MediaStreamUIController();
38
39 // Called when a new request for the capture device access is made.
40 // Users are responsible for canceling the pending request if they don't wait
41 // for the result from the UI.
42 void MakeUIRequest(const std::string& label,
43 int render_process_id,
44 int render_view_id,
45 const StreamOptions& stream_components,
46 const GURL& security_origin,
47 MediaStreamRequestType request_type,
48 const std::string& requested_device_id);
49
50 // Called to cancel a pending UI request of capture device access when the
51 // user has no action for the media stream InfoBar.
52 void CancelUIRequest(const std::string& label);
53
54 // Called to signal the UI indicator that the devices are opened.
55 void NotifyUIIndicatorDevicesOpened(const std::string& label);
56
57 // Called to signal the UI indicator that the devices are closed.
58 void NotifyUIIndicatorDevicesClosed(const std::string& label);
59
60 // Used for testing only. This function is called to use faked UI, which is
61 // needed for server based tests. The first non-opened device(s) will be
62 // picked.
63 void UseFakeUI(scoped_ptr<MediaStreamUI> fake_ui);
64
65 private:
66 typedef std::map<std::string, MediaStreamRequestForUI*> UIRequests;
67 typedef std::map<std::string, MediaStreamUI*> IndicatorsMap;
68
69 // Returns true if the UI is already processing a request for this render
70 // view.
71 bool IsUIBusy(int render_process_id, int render_view_id);
72
73 // Process the next pending request and bring it up to the UI on the given
74 // page for user approval.
75 void ProcessNextRequestForView(int render_process_id, int render_view_id);
76
77 // Posts a request to be approved/denied by UI.
78 void PostRequestToUI(const std::string& label);
79
80 // Posts a request to fake UI which is used for testing purpose.
81 void PostRequestToFakeUI(const std::string& label);
82
83 // Callback handler for WebContents::RequestMediaAccessPermission().
84 void ProcessAccessRequestResponse(const std::string& label,
85 const MediaStreamDevices& devices,
86 scoped_ptr<MediaStreamUI> stream_ui);
87
88 // Callback for UI called when user requests a stream to be stopped.
89 void OnStopStreamFromUI(const std::string& label);
90
91 SettingsRequester* requester_;
92 UIRequests requests_;
93
94 // See comment above for method UseFakeUI. Used for automated testing.
95 bool use_fake_ui_;
96 scoped_ptr<MediaStreamUI> fake_ui_;
97
98 // Container MediaStreamUI objects for currently active streams.
99 IndicatorsMap stream_indicators_;
100
101 DISALLOW_COPY_AND_ASSIGN(MediaStreamUIController);
102 };
103
104 } // namespace content
105
106 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698