OLD | NEW |
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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "components/url_formatter/elide_url.h" | 32 #include "components/url_formatter/elide_url.h" |
33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/navigation_handle.h" | 34 #include "content/public/browser/navigation_handle.h" |
35 #include "content/public/browser/render_frame_host.h" | 35 #include "content/public/browser/render_frame_host.h" |
36 #include "content/public/browser/render_process_host.h" | 36 #include "content/public/browser/render_process_host.h" |
37 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
38 #include "content/public/common/media_stream_request.h" | 38 #include "content/public/common/media_stream_request.h" |
39 #include "content/public/common/origin_util.h" | 39 #include "content/public/common/origin_util.h" |
40 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
42 #include "ui/gfx/vector_icons_public.h" | |
43 | 42 |
44 #if defined(OS_ANDROID) | 43 #if defined(OS_ANDROID) |
45 #include <vector> | 44 #include <vector> |
46 | 45 |
47 #include "chrome/browser/android/preferences/pref_service_bridge.h" | 46 #include "chrome/browser/android/preferences/pref_service_bridge.h" |
48 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" | 47 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
49 #include "chrome/grit/theme_resources.h" | 48 #include "chrome/grit/theme_resources.h" |
50 #include "content/public/browser/android/content_view_core.h" | 49 #include "content/public/browser/android/content_view_core.h" |
51 #include "ui/android/window_android.h" | 50 #include "ui/android/window_android.h" |
52 #endif // defined(OS_ANDROID) | 51 #else // !defined(OS_ANDROID) |
| 52 #include "ui/vector_icons/vector_icons.h" |
| 53 #endif |
53 | 54 |
54 using content::BrowserThread; | 55 using content::BrowserThread; |
55 | 56 |
56 namespace { | 57 namespace { |
57 | 58 |
58 // Returns true if the given ContentSettingsType is being requested in | 59 // Returns true if the given ContentSettingsType is being requested in |
59 // |request|. | 60 // |request|. |
60 bool ContentTypeIsRequested(content::PermissionType type, | 61 bool ContentTypeIsRequested(content::PermissionType type, |
61 const content::MediaStreamRequest& request) { | 62 const content::MediaStreamRequest& request) { |
62 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) | 63 if (request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PermissionRequest::IconId MediaStreamDevicesController::GetIconId() const { | 279 PermissionRequest::IconId MediaStreamDevicesController::GetIconId() const { |
279 #if defined(OS_ANDROID) | 280 #if defined(OS_ANDROID) |
280 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA | 281 return IsAskingForVideo() ? IDR_INFOBAR_MEDIA_STREAM_CAMERA |
281 : IDR_INFOBAR_MEDIA_STREAM_MIC; | 282 : IDR_INFOBAR_MEDIA_STREAM_MIC; |
282 #else | 283 #else |
283 return IsAskingForVideo() ? gfx::VectorIconId::VIDEOCAM | 284 return IsAskingForVideo() ? ui::kVideocamIcon : ui::kMicrophoneIcon; |
284 : gfx::VectorIconId::MICROPHONE; | |
285 #endif | 285 #endif |
286 } | 286 } |
287 | 287 |
288 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { | 288 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { |
289 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | 289 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; |
290 if (!IsAskingForAudio()) | 290 if (!IsAskingForAudio()) |
291 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | 291 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; |
292 else if (!IsAskingForVideo()) | 292 else if (!IsAskingForVideo()) |
293 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | 293 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; |
294 return l10n_util::GetStringUTF16(message_id); | 294 return l10n_util::GetStringUTF16(message_id); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 if (android_permission_blocked) | 622 if (android_permission_blocked) |
623 return false; | 623 return false; |
624 | 624 |
625 // Don't approve device requests if the tab was hidden. | 625 // Don't approve device requests if the tab was hidden. |
626 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 626 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
627 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 627 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
628 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 628 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
629 #endif | 629 #endif |
630 return true; | 630 return true; |
631 } | 631 } |
OLD | NEW |