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

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

Issue 2385063005: Make PermissionRequest::GetIconId return different types (Closed)
Patch Set: android Created 4 years, 2 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 (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 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" 5 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" 17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
18 #include "chrome/browser/media/webrtc/media_permission.h" 18 #include "chrome/browser/media/webrtc/media_permission.h"
19 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" 19 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
20 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" 20 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h"
21 #include "chrome/browser/permissions/permission_uma_util.h" 21 #include "chrome/browser/permissions/permission_uma_util.h"
22 #include "chrome/browser/permissions/permission_util.h" 22 #include "chrome/browser/permissions/permission_util.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/features.h" 26 #include "chrome/common/features.h"
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
29 #include "chrome/grit/theme_resources.h"
30 #include "components/content_settings/core/browser/host_content_settings_map.h" 29 #include "components/content_settings/core/browser/host_content_settings_map.h"
31 #include "components/content_settings/core/common/content_settings_pattern.h" 30 #include "components/content_settings/core/common/content_settings_pattern.h"
32 #include "components/pref_registry/pref_registry_syncable.h" 31 #include "components/pref_registry/pref_registry_syncable.h"
33 #include "components/prefs/scoped_user_pref_update.h" 32 #include "components/prefs/scoped_user_pref_update.h"
34 #include "components/url_formatter/elide_url.h" 33 #include "components/url_formatter/elide_url.h"
35 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/render_frame_host.h" 35 #include "content/public/browser/render_frame_host.h"
37 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
38 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
39 #include "content/public/common/media_stream_request.h" 38 #include "content/public/common/media_stream_request.h"
40 #include "content/public/common/origin_util.h" 39 #include "content/public/common/origin_util.h"
41 #include "extensions/common/constants.h" 40 #include "extensions/common/constants.h"
42 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/gfx/vector_icons_public.h"
43 43
44 #if BUILDFLAG(ANDROID_JAVA_UI) 44 #if BUILDFLAG(ANDROID_JAVA_UI)
45 #include <vector> 45 #include <vector>
46 46
47 #include "chrome/browser/android/preferences/pref_service_bridge.h" 47 #include "chrome/browser/android/preferences/pref_service_bridge.h"
48 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h" 48 #include "chrome/browser/permissions/permission_update_infobar_delegate_android. h"
49 #include "chrome/grit/theme_resources.h"
49 #include "content/public/browser/android/content_view_core.h" 50 #include "content/public/browser/android/content_view_core.h"
50 #include "ui/android/window_android.h" 51 #include "ui/android/window_android.h"
51 #endif // BUILDFLAG(ANDROID_JAVA_UI) 52 #endif // BUILDFLAG(ANDROID_JAVA_UI)
52 53
53 using content::BrowserThread; 54 using content::BrowserThread;
54 55
55 namespace { 56 namespace {
56 57
57 // Returns true if the given ContentSettingsType is being requested in 58 // Returns true if the given ContentSettingsType is being requested in
58 // |request|. 59 // |request|.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { 269 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() {
269 set_persist(false); 270 set_persist(false);
270 // TODO(tsergeant): Determine whether it is appropriate to record permission 271 // TODO(tsergeant): Determine whether it is appropriate to record permission
271 // action metrics here, as this is a different sort of user action. 272 // action metrics here, as this is a different sort of user action.
272 RunCallback(CONTENT_SETTING_BLOCK, 273 RunCallback(CONTENT_SETTING_BLOCK,
273 CONTENT_SETTING_BLOCK, 274 CONTENT_SETTING_BLOCK,
274 content::MEDIA_DEVICE_PERMISSION_DENIED); 275 content::MEDIA_DEVICE_PERMISSION_DENIED);
275 set_persist(true); 276 set_persist(true);
276 } 277 }
277 278
278 int MediaStreamDevicesController::GetIconId() const { 279 PermissionRequest::IconId MediaStreamDevicesController::GetIconId() const {
279 if (IsAskingForVideo()) 280 #if defined(OS_ANDROID)
280 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; 281 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA
281 282 : IDR_INFOBAR_MEDIA_STREAM_MIC;
282 return IDR_INFOBAR_MEDIA_STREAM_MIC; 283 #else
284 return IsAskingForVideo() ? gfx::VectorIconId::VIDEOCAM
285 : gfx::VectorIconId::MICROPHONE;
286 #endif
283 } 287 }
284 288
285 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { 289 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const {
286 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; 290 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT;
287 if (!IsAskingForAudio()) 291 if (!IsAskingForAudio())
288 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; 292 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT;
289 else if (!IsAskingForVideo()) 293 else if (!IsAskingForVideo())
290 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; 294 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT;
291 return l10n_util::GetStringUTF16(message_id); 295 return l10n_util::GetStringUTF16(message_id);
292 } 296 }
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 if (android_permission_blocked) 628 if (android_permission_blocked)
625 return false; 629 return false;
626 630
627 // Don't approve device requests if the tab was hidden. 631 // Don't approve device requests if the tab was hidden.
628 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 632 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
629 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? 633 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video?
630 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 634 return web_contents_->GetRenderWidgetHostView()->IsShowing();
631 #endif 635 #endif
632 return true; 636 return true;
633 } 637 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698