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

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

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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/media_stream_devices_controller.h" 5 #include "chrome/browser/media/media_stream_devices_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/scoped_user_pref_update.h" 8 #include "base/prefs/scoped_user_pref_update.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
13 #include "chrome/browser/media/media_permission.h" 14 #include "chrome/browser/media/media_permission.h"
14 #include "chrome/browser/media/media_stream_capture_indicator.h" 15 #include "chrome/browser/media/media_stream_capture_indicator.h"
15 #include "chrome/browser/media/media_stream_device_permissions.h" 16 #include "chrome/browser/media/media_stream_device_permissions.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/grit/generated_resources.h" 21 #include "chrome/grit/generated_resources.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 break; 281 break;
281 } 282 }
282 case content::MEDIA_ENUMERATE_DEVICES: { 283 case content::MEDIA_ENUMERATE_DEVICES: {
283 // Do nothing. 284 // Do nothing.
284 NOTREACHED(); 285 NOTREACHED();
285 break; 286 break;
286 } 287 }
287 } // switch 288 } // switch
288 289
289 if (audio_allowed) { 290 if (audio_allowed) {
290 profile_->GetHostContentSettingsMap()->UpdateLastUsageByPattern( 291 HostContentSettingsMapFactory::GetForProfile(profile_)
291 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin), 292 ->UpdateLastUsageByPattern(
292 ContentSettingsPattern::Wildcard(), 293 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin),
293 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 294 ContentSettingsPattern::Wildcard(),
295 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
294 } 296 }
295 if (video_allowed) { 297 if (video_allowed) {
296 profile_->GetHostContentSettingsMap()->UpdateLastUsageByPattern( 298 HostContentSettingsMapFactory::GetForProfile(profile_)
297 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin), 299 ->UpdateLastUsageByPattern(
298 ContentSettingsPattern::Wildcard(), 300 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin),
299 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 301 ContentSettingsPattern::Wildcard(),
302 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
300 } 303 }
301 304
302 return devices; 305 return devices;
303 } 306 }
304 307
305 void MediaStreamDevicesController::RunCallback( 308 void MediaStreamDevicesController::RunCallback(
306 ContentSetting audio_setting, 309 ContentSetting audio_setting,
307 ContentSetting video_setting, 310 ContentSetting video_setting,
308 content::MediaStreamRequestResult denial_reason) { 311 content::MediaStreamRequestResult denial_reason) {
309 StorePermission(audio_setting, video_setting); 312 StorePermission(audio_setting, video_setting);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 ContentSetting new_video_setting) const { 344 ContentSetting new_video_setting) const {
342 DCHECK_CURRENTLY_ON(BrowserThread::UI); 345 DCHECK_CURRENTLY_ON(BrowserThread::UI);
343 ContentSettingsPattern primary_pattern = 346 ContentSettingsPattern primary_pattern =
344 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin); 347 ContentSettingsPattern::FromURLNoWildcard(request_.security_origin);
345 348
346 bool is_pepper_request = request_.request_type == content::MEDIA_OPEN_DEVICE; 349 bool is_pepper_request = request_.request_type == content::MEDIA_OPEN_DEVICE;
347 350
348 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) { 351 if (IsAskingForAudio() && new_audio_setting != CONTENT_SETTING_ASK) {
349 if (ShouldPersistContentSetting(new_audio_setting, request_.security_origin, 352 if (ShouldPersistContentSetting(new_audio_setting, request_.security_origin,
350 is_pepper_request)) { 353 is_pepper_request)) {
351 profile_->GetHostContentSettingsMap()->SetContentSetting( 354 HostContentSettingsMapFactory::GetForProfile(profile_)->SetContentSetting(
352 primary_pattern, ContentSettingsPattern::Wildcard(), 355 primary_pattern, ContentSettingsPattern::Wildcard(),
353 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), 356 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(),
354 new_audio_setting); 357 new_audio_setting);
355 } 358 }
356 } 359 }
357 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) { 360 if (IsAskingForVideo() && new_video_setting != CONTENT_SETTING_ASK) {
358 if (ShouldPersistContentSetting(new_video_setting, request_.security_origin, 361 if (ShouldPersistContentSetting(new_video_setting, request_.security_origin,
359 is_pepper_request)) { 362 is_pepper_request)) {
360 profile_->GetHostContentSettingsMap()->SetContentSetting( 363 HostContentSettingsMapFactory::GetForProfile(profile_)->SetContentSetting(
361 primary_pattern, ContentSettingsPattern::Wildcard(), 364 primary_pattern, ContentSettingsPattern::Wildcard(),
362 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), 365 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(),
363 new_video_setting); 366 new_video_setting);
364 } 367 }
365 } 368 }
366 } 369 }
367 370
368 void MediaStreamDevicesController::UpdateTabSpecificContentSettings( 371 void MediaStreamDevicesController::UpdateTabSpecificContentSettings(
369 ContentSetting audio_setting, 372 ContentSetting audio_setting,
370 ContentSetting video_setting) const { 373 ContentSetting video_setting) const {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (android_permission_blocked) 484 if (android_permission_blocked)
482 return false; 485 return false;
483 486
484 // Don't approve device requests if the tab was hidden. 487 // Don't approve device requests if the tab was hidden.
485 // TODO(qinmin): Add a test for this. http://crbug.com/396869. 488 // TODO(qinmin): Add a test for this. http://crbug.com/396869.
486 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video? 489 // TODO(raymes): Shouldn't this apply to all permissions not just audio/video?
487 return web_contents_->GetRenderWidgetHostView()->IsShowing(); 490 return web_contents_->GetRenderWidgetHostView()->IsShowing();
488 #endif 491 #endif
489 return true; 492 return true;
490 } 493 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698