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

Side by Side Diff: chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc

Issue 2619603002: Remove android_java_ui as it is not used (Closed)
Patch Set: Created 3 years, 11 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
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 #include "chrome/browser/media/webrtc/permission_bubble_media_access_handler.h" 5 #include "chrome/browser/media/webrtc/permission_bubble_media_access_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "chrome/browser/media/webrtc/media_permission.h" 10 #include "chrome/browser/media/webrtc/media_permission.h"
11 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" 11 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
12 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" 12 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/features.h" 14 #include "chrome/common/features.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "components/content_settings/core/browser/host_content_settings_map.h" 16 #include "components/content_settings/core/browser/host_content_settings_map.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 21
22 #if BUILDFLAG(ANDROID_JAVA_UI) 22 #if defined(OS_ANDROID)
23 #include <vector> 23 #include <vector>
24 24
25 #include "base/bind.h" 25 #include "base/bind.h"
26 #include "base/bind_helpers.h" 26 #include "base/bind_helpers.h"
27 #include "chrome/browser/android/chrome_feature_list.h" 27 #include "chrome/browser/android/chrome_feature_list.h"
28 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h" 28 #include "chrome/browser/media/webrtc/media_stream_infobar_delegate_android.h"
29 #include "chrome/browser/media/webrtc/screen_capture_infobar_delegate_android.h" 29 #include "chrome/browser/media/webrtc/screen_capture_infobar_delegate_android.h"
30 #include "chrome/browser/permissions/permission_dialog_delegate.h" 30 #include "chrome/browser/permissions/permission_dialog_delegate.h"
31 #include "chrome/browser/permissions/permission_uma_util.h" 31 #include "chrome/browser/permissions/permission_uma_util.h"
32 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 32 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
33 #include "chrome/browser/permissions/permission_util.h" 33 #include "chrome/browser/permissions/permission_util.h"
34 #else 34 #else
35 #include "chrome/browser/permissions/permission_request_manager.h" 35 #include "chrome/browser/permissions/permission_request_manager.h"
36 #endif // BUILDFLAG(ANDROID_JAVA_UI) 36 #endif // defined(OS_ANDROID)
37 37
38 #if BUILDFLAG(ANDROID_JAVA_UI) 38 #if defined(OS_ANDROID)
39 namespace { 39 namespace {
40 // Callback for the permission update infobar when the site and Chrome 40 // Callback for the permission update infobar when the site and Chrome
41 // permissions are mismatched on Android. 41 // permissions are mismatched on Android.
42 void OnPermissionConflictResolved( 42 void OnPermissionConflictResolved(
43 std::unique_ptr<MediaStreamDevicesController> controller, 43 std::unique_ptr<MediaStreamDevicesController> controller,
44 bool allowed) { 44 bool allowed) {
45 if (allowed) 45 if (allowed)
46 controller->PermissionGranted(); 46 controller->PermissionGranted();
47 else 47 else
48 controller->ForcePermissionDeniedTemporarily(); 48 controller->ForcePermissionDeniedTemporarily();
49 } 49 }
50 } // namespace 50 } // namespace
51 51
52 #endif // BUILDFLAG(ANDROID_JAVA_UI) 52 #endif // defined(OS_ANDROID)
53 53
54 using content::BrowserThread; 54 using content::BrowserThread;
55 55
56 struct PermissionBubbleMediaAccessHandler::PendingAccessRequest { 56 struct PermissionBubbleMediaAccessHandler::PendingAccessRequest {
57 PendingAccessRequest(const content::MediaStreamRequest& request, 57 PendingAccessRequest(const content::MediaStreamRequest& request,
58 const content::MediaResponseCallback& callback) 58 const content::MediaResponseCallback& callback)
59 : request(request), callback(callback) {} 59 : request(request), callback(callback) {}
60 ~PendingAccessRequest() {} 60 ~PendingAccessRequest() {}
61 61
62 // TODO(gbillock): make the MediaStreamDevicesController owned by 62 // TODO(gbillock): make the MediaStreamDevicesController owned by
(...skipping 11 matching lines...) Expand all
74 notifications_registrar_.Add(this, 74 notifications_registrar_.Add(this,
75 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 75 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
76 content::NotificationService::AllSources()); 76 content::NotificationService::AllSources());
77 } 77 }
78 78
79 PermissionBubbleMediaAccessHandler::~PermissionBubbleMediaAccessHandler() {} 79 PermissionBubbleMediaAccessHandler::~PermissionBubbleMediaAccessHandler() {}
80 80
81 bool PermissionBubbleMediaAccessHandler::SupportsStreamType( 81 bool PermissionBubbleMediaAccessHandler::SupportsStreamType(
82 const content::MediaStreamType type, 82 const content::MediaStreamType type,
83 const extensions::Extension* extension) { 83 const extensions::Extension* extension) {
84 #if BUILDFLAG(ANDROID_JAVA_UI) 84 #if defined(OS_ANDROID)
85 return type == content::MEDIA_DEVICE_VIDEO_CAPTURE || 85 return type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
86 type == content::MEDIA_DEVICE_AUDIO_CAPTURE || 86 type == content::MEDIA_DEVICE_AUDIO_CAPTURE ||
87 type == content::MEDIA_DESKTOP_VIDEO_CAPTURE; 87 type == content::MEDIA_DESKTOP_VIDEO_CAPTURE;
88 #else 88 #else
89 return type == content::MEDIA_DEVICE_VIDEO_CAPTURE || 89 return type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
90 type == content::MEDIA_DEVICE_AUDIO_CAPTURE; 90 type == content::MEDIA_DEVICE_AUDIO_CAPTURE;
91 #endif 91 #endif
92 } 92 }
93 93
94 bool PermissionBubbleMediaAccessHandler::CheckMediaAccessPermission( 94 bool PermissionBubbleMediaAccessHandler::CheckMediaAccessPermission(
(...skipping 15 matching lines...) Expand all
110 return permission.GetPermissionStatus(&unused) == CONTENT_SETTING_ALLOW; 110 return permission.GetPermissionStatus(&unused) == CONTENT_SETTING_ALLOW;
111 } 111 }
112 112
113 void PermissionBubbleMediaAccessHandler::HandleRequest( 113 void PermissionBubbleMediaAccessHandler::HandleRequest(
114 content::WebContents* web_contents, 114 content::WebContents* web_contents,
115 const content::MediaStreamRequest& request, 115 const content::MediaStreamRequest& request,
116 const content::MediaResponseCallback& callback, 116 const content::MediaResponseCallback& callback,
117 const extensions::Extension* extension) { 117 const extensions::Extension* extension) {
118 DCHECK_CURRENTLY_ON(BrowserThread::UI); 118 DCHECK_CURRENTLY_ON(BrowserThread::UI);
119 119
120 #if BUILDFLAG(ANDROID_JAVA_UI) 120 #if defined(OS_ANDROID)
121 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE && 121 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE &&
122 !base::FeatureList::IsEnabled( 122 !base::FeatureList::IsEnabled(
123 chrome::android::kUserMediaScreenCapturing)) { 123 chrome::android::kUserMediaScreenCapturing)) {
124 // If screen capturing isn't enabled on Android, we'll use "invalid state" 124 // If screen capturing isn't enabled on Android, we'll use "invalid state"
125 // as result, same as on desktop. 125 // as result, same as on desktop.
126 callback.Run(content::MediaStreamDevices(), 126 callback.Run(content::MediaStreamDevices(),
127 content::MEDIA_DEVICE_INVALID_STATE, nullptr); 127 content::MEDIA_DEVICE_INVALID_STATE, nullptr);
128 return; 128 return;
129 } 129 }
130 #endif // BUILDFLAG(ANDROID_JAVA_UI) 130 #endif // defined(OS_ANDROID)
131 131
132 RequestsQueue& queue = pending_requests_[web_contents]; 132 RequestsQueue& queue = pending_requests_[web_contents];
133 queue.push_back(PendingAccessRequest(request, callback)); 133 queue.push_back(PendingAccessRequest(request, callback));
134 134
135 // If this is the only request then show the infobar. 135 // If this is the only request then show the infobar.
136 if (queue.size() == 1) 136 if (queue.size() == 1)
137 ProcessQueuedAccessRequest(web_contents); 137 ProcessQueuedAccessRequest(web_contents);
138 } 138 }
139 139
140 void PermissionBubbleMediaAccessHandler::ProcessQueuedAccessRequest( 140 void PermissionBubbleMediaAccessHandler::ProcessQueuedAccessRequest(
141 content::WebContents* web_contents) { 141 content::WebContents* web_contents) {
142 DCHECK_CURRENTLY_ON(BrowserThread::UI); 142 DCHECK_CURRENTLY_ON(BrowserThread::UI);
143 143
144 std::map<content::WebContents*, RequestsQueue>::iterator it = 144 std::map<content::WebContents*, RequestsQueue>::iterator it =
145 pending_requests_.find(web_contents); 145 pending_requests_.find(web_contents);
146 146
147 if (it == pending_requests_.end() || it->second.empty()) { 147 if (it == pending_requests_.end() || it->second.empty()) {
148 // Don't do anything if the tab was closed. 148 // Don't do anything if the tab was closed.
149 return; 149 return;
150 } 150 }
151 151
152 DCHECK(!it->second.empty()); 152 DCHECK(!it->second.empty());
153 153
154 const content::MediaStreamRequest request = it->second.front().request; 154 const content::MediaStreamRequest request = it->second.front().request;
155 #if BUILDFLAG(ANDROID_JAVA_UI) 155 #if defined(OS_ANDROID)
156 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) { 156 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
157 ScreenCaptureInfoBarDelegateAndroid::Create( 157 ScreenCaptureInfoBarDelegateAndroid::Create(
158 web_contents, request, 158 web_contents, request,
159 base::Bind(&PermissionBubbleMediaAccessHandler::OnAccessRequestResponse, 159 base::Bind(&PermissionBubbleMediaAccessHandler::OnAccessRequestResponse,
160 base::Unretained(this), web_contents)); 160 base::Unretained(this), web_contents));
161 return; 161 return;
162 } 162 }
163 #endif 163 #endif
164 164
165 std::unique_ptr<MediaStreamDevicesController> controller( 165 std::unique_ptr<MediaStreamDevicesController> controller(
166 new MediaStreamDevicesController( 166 new MediaStreamDevicesController(
167 web_contents, request, 167 web_contents, request,
168 base::Bind( 168 base::Bind(
169 &PermissionBubbleMediaAccessHandler::OnAccessRequestResponse, 169 &PermissionBubbleMediaAccessHandler::OnAccessRequestResponse,
170 base::Unretained(this), web_contents))); 170 base::Unretained(this), web_contents)));
171 if (!controller->IsAskingForAudio() && !controller->IsAskingForVideo()) { 171 if (!controller->IsAskingForAudio() && !controller->IsAskingForVideo()) {
172 #if BUILDFLAG(ANDROID_JAVA_UI) 172 #if defined(OS_ANDROID)
173 // If either audio or video was previously allowed and Chrome no longer has 173 // If either audio or video was previously allowed and Chrome no longer has
174 // the necessary permissions, show a infobar to attempt to address this 174 // the necessary permissions, show a infobar to attempt to address this
175 // mismatch. 175 // mismatch.
176 std::vector<ContentSettingsType> content_settings_types; 176 std::vector<ContentSettingsType> content_settings_types;
177 if (controller->IsAllowedForAudio()) 177 if (controller->IsAllowedForAudio())
178 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 178 content_settings_types.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
179 179
180 if (controller->IsAllowedForVideo()) { 180 if (controller->IsAllowedForVideo()) {
181 content_settings_types.push_back( 181 content_settings_types.push_back(
182 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 182 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
183 } 183 }
184 if (!content_settings_types.empty() && 184 if (!content_settings_types.empty() &&
185 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar( 185 PermissionUpdateInfoBarDelegate::ShouldShowPermissionInfobar(
186 web_contents, content_settings_types)) { 186 web_contents, content_settings_types)) {
187 PermissionUpdateInfoBarDelegate::Create( 187 PermissionUpdateInfoBarDelegate::Create(
188 web_contents, content_settings_types, 188 web_contents, content_settings_types,
189 base::Bind(&OnPermissionConflictResolved, base::Passed(&controller))); 189 base::Bind(&OnPermissionConflictResolved, base::Passed(&controller)));
190 } 190 }
191 #endif 191 #endif
192 return; 192 return;
193 } 193 }
194 194
195 #if BUILDFLAG(ANDROID_JAVA_UI) 195 #if defined(OS_ANDROID)
196 PermissionUmaUtil::RecordPermissionPromptShown( 196 PermissionUmaUtil::RecordPermissionPromptShown(
197 controller->GetPermissionRequestType(), 197 controller->GetPermissionRequestType(),
198 PermissionUtil::GetGestureType(request.user_gesture)); 198 PermissionUtil::GetGestureType(request.user_gesture));
199 if (PermissionDialogDelegate::ShouldShowDialog(request.user_gesture)) { 199 if (PermissionDialogDelegate::ShouldShowDialog(request.user_gesture)) {
200 PermissionDialogDelegate::CreateMediaStreamDialog( 200 PermissionDialogDelegate::CreateMediaStreamDialog(
201 web_contents, request.user_gesture, std::move(controller)); 201 web_contents, request.user_gesture, std::move(controller));
202 } else { 202 } else {
203 MediaStreamInfoBarDelegateAndroid::Create( 203 MediaStreamInfoBarDelegateAndroid::Create(
204 web_contents, request.user_gesture, std::move(controller)); 204 web_contents, request.user_gesture, std::move(controller));
205 } 205 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 void PermissionBubbleMediaAccessHandler::Observe( 277 void PermissionBubbleMediaAccessHandler::Observe(
278 int type, 278 int type,
279 const content::NotificationSource& source, 279 const content::NotificationSource& source,
280 const content::NotificationDetails& details) { 280 const content::NotificationDetails& details) {
281 DCHECK_CURRENTLY_ON(BrowserThread::UI); 281 DCHECK_CURRENTLY_ON(BrowserThread::UI);
282 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, type); 282 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, type);
283 283
284 pending_requests_.erase(content::Source<content::WebContents>(source).ptr()); 284 pending_requests_.erase(content::Source<content::WebContents>(source).ptr());
285 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698