| 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/media_stream_devices_controller.h" | 5 #include "chrome/browser/media/media_stream_devices_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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 "components/content_settings/core/browser/host_content_settings_map.h" | 29 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 30 #include "components/content_settings/core/common/content_settings_pattern.h" | 30 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 31 #include "components/pref_registry/pref_registry_syncable.h" | 31 #include "components/pref_registry/pref_registry_syncable.h" |
| 32 #include "components/prefs/scoped_user_pref_update.h" | 32 #include "components/prefs/scoped_user_pref_update.h" |
| 33 #include "components/url_formatter/elide_url.h" |
| 33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/permission_type.h" | 35 #include "content/public/browser/permission_type.h" |
| 35 #include "content/public/browser/render_frame_host.h" | 36 #include "content/public/browser/render_frame_host.h" |
| 36 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 38 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/common/media_stream_request.h" | 39 #include "content/public/common/media_stream_request.h" |
| 39 #include "content/public/common/origin_util.h" | 40 #include "content/public/common/origin_util.h" |
| 40 #include "extensions/common/constants.h" | 41 #include "extensions/common/constants.h" |
| 41 #include "grit/theme_resources.h" | 42 #include "grit/theme_resources.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 226 } |
| 226 | 227 |
| 227 bool MediaStreamDevicesController::IsAskingForAudio() const { | 228 bool MediaStreamDevicesController::IsAskingForAudio() const { |
| 228 return old_audio_setting_ == CONTENT_SETTING_ASK; | 229 return old_audio_setting_ == CONTENT_SETTING_ASK; |
| 229 } | 230 } |
| 230 | 231 |
| 231 bool MediaStreamDevicesController::IsAskingForVideo() const { | 232 bool MediaStreamDevicesController::IsAskingForVideo() const { |
| 232 return old_video_setting_ == CONTENT_SETTING_ASK; | 233 return old_video_setting_ == CONTENT_SETTING_ASK; |
| 233 } | 234 } |
| 234 | 235 |
| 235 const std::string& MediaStreamDevicesController::GetSecurityOriginSpec() const { | |
| 236 return request_.security_origin.spec(); | |
| 237 } | |
| 238 | |
| 239 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { | 236 void MediaStreamDevicesController::ForcePermissionDeniedTemporarily() { |
| 240 base::AutoReset<bool> persist_permissions( | 237 base::AutoReset<bool> persist_permissions( |
| 241 &persist_permission_changes_, false); | 238 &persist_permission_changes_, false); |
| 242 // TODO(tsergeant): Determine whether it is appropriate to record permission | 239 // TODO(tsergeant): Determine whether it is appropriate to record permission |
| 243 // action metrics here, as this is a different sort of user action. | 240 // action metrics here, as this is a different sort of user action. |
| 244 RunCallback(CONTENT_SETTING_BLOCK, | 241 RunCallback(CONTENT_SETTING_BLOCK, |
| 245 CONTENT_SETTING_BLOCK, | 242 CONTENT_SETTING_BLOCK, |
| 246 content::MEDIA_DEVICE_PERMISSION_DENIED); | 243 content::MEDIA_DEVICE_PERMISSION_DENIED); |
| 247 } | 244 } |
| 248 | 245 |
| 249 int MediaStreamDevicesController::GetIconId() const { | 246 int MediaStreamDevicesController::GetIconId() const { |
| 250 if (IsAskingForVideo()) | 247 if (IsAskingForVideo()) |
| 251 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; | 248 return IDR_INFOBAR_MEDIA_STREAM_CAMERA; |
| 252 | 249 |
| 253 return IDR_INFOBAR_MEDIA_STREAM_MIC; | 250 return IDR_INFOBAR_MEDIA_STREAM_MIC; |
| 254 } | 251 } |
| 255 | 252 |
| 256 base::string16 MediaStreamDevicesController::GetMessageText() const { | 253 base::string16 MediaStreamDevicesController::GetMessageText() const { |
| 257 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; | 254 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO; |
| 258 if (!IsAskingForAudio()) | 255 if (!IsAskingForAudio()) |
| 259 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 256 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
| 260 else if (!IsAskingForVideo()) | 257 else if (!IsAskingForVideo()) |
| 261 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; | 258 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY; |
| 262 return l10n_util::GetStringFUTF16( | 259 return l10n_util::GetStringFUTF16( |
| 263 message_id, base::UTF8ToUTF16(GetSecurityOriginSpec())); | 260 message_id, |
| 261 url_formatter::FormatUrlForSecurityDisplay( |
| 262 GetOrigin(), url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); |
| 264 } | 263 } |
| 265 | 264 |
| 266 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { | 265 base::string16 MediaStreamDevicesController::GetMessageTextFragment() const { |
| 267 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; | 266 int message_id = IDS_MEDIA_CAPTURE_AUDIO_AND_VIDEO_PERMISSION_FRAGMENT; |
| 268 if (!IsAskingForAudio()) | 267 if (!IsAskingForAudio()) |
| 269 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; | 268 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY_PERMISSION_FRAGMENT; |
| 270 else if (!IsAskingForVideo()) | 269 else if (!IsAskingForVideo()) |
| 271 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; | 270 message_id = IDS_MEDIA_CAPTURE_AUDIO_ONLY_PERMISSION_FRAGMENT; |
| 272 return l10n_util::GetStringUTF16(message_id); | 271 return l10n_util::GetStringUTF16(message_id); |
| 273 } | 272 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 if (android_permission_blocked) | 610 if (android_permission_blocked) |
| 612 return false; | 611 return false; |
| 613 | 612 |
| 614 // Don't approve device requests if the tab was hidden. | 613 // Don't approve device requests if the tab was hidden. |
| 615 // TODO(qinmin): Add a test for this. http://crbug.com/396869. | 614 // TODO(qinmin): Add a test for this. http://crbug.com/396869. |
| 616 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? | 615 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? |
| 617 return web_contents_->GetRenderWidgetHostView()->IsShowing(); | 616 return web_contents_->GetRenderWidgetHostView()->IsShowing(); |
| 618 #endif | 617 #endif |
| 619 return true; | 618 return true; |
| 620 } | 619 } |
| OLD | NEW |