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/ui/webui/options/content_settings_handler.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/ui/webui/options/content_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
21 #include "chrome/browser/content_settings/web_site_settings_uma_util.h" 22 #include "chrome/browser/content_settings/web_site_settings_uma_util.h"
22 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 23 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
23 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 24 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
24 #include "chrome/browser/extensions/extension_special_storage_policy.h" 25 #include "chrome/browser/extensions/extension_special_storage_policy.h"
25 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 26 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/browser_list.h" 28 #include "chrome/browser/ui/browser_list.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 30 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 signin_partition->GetHostZoomMap(); 587 signin_partition->GetHostZoomMap();
587 signin_host_zoom_map_subscription_ = 588 signin_host_zoom_map_subscription_ =
588 signin_host_zoom_map->AddZoomLevelChangedCallback( 589 signin_host_zoom_map->AddZoomLevelChangedCallback(
589 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, 590 base::Bind(&ContentSettingsHandler::OnZoomLevelChanged,
590 base::Unretained(this))); 591 base::Unretained(this)));
591 } 592 }
592 593
593 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); 594 flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context));
594 595
595 Profile* profile = Profile::FromWebUI(web_ui()); 596 Profile* profile = Profile::FromWebUI(web_ui());
596 observer_.Add(profile->GetHostContentSettingsMap()); 597 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile));
597 if (profile->HasOffTheRecordProfile()) { 598 if (profile->HasOffTheRecordProfile()) {
598 auto map = profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); 599 auto map = HostContentSettingsMapFactory::GetForProfile(
600 profile->GetOffTheRecordProfile());
599 if (!observer_.IsObserving(map)) 601 if (!observer_.IsObserving(map))
600 observer_.Add(map); 602 observer_.Add(map);
601 } 603 }
602 } 604 }
603 605
604 void ContentSettingsHandler::InitializePage() { 606 void ContentSettingsHandler::InitializePage() {
605 media_settings_.reset(new MediaSettingsInfo()); 607 media_settings_.reset(new MediaSettingsInfo());
606 RefreshFlashMediaSettings(); 608 RefreshFlashMediaSettings();
607 609
608 UpdateHandlersEnabledRadios(); 610 UpdateHandlersEnabledRadios();
(...skipping 22 matching lines...) Expand all
631 } 633 }
632 } 634 }
633 635
634 void ContentSettingsHandler::Observe( 636 void ContentSettingsHandler::Observe(
635 int type, 637 int type,
636 const content::NotificationSource& source, 638 const content::NotificationSource& source,
637 const content::NotificationDetails& details) { 639 const content::NotificationDetails& details) {
638 switch (type) { 640 switch (type) {
639 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 641 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
640 Profile* profile = content::Source<Profile>(source).ptr(); 642 Profile* profile = content::Source<Profile>(source).ptr();
643 HostContentSettingsMap* settings_map =
644 HostContentSettingsMapFactory::GetForProfile(profile);
641 if (profile->IsOffTheRecord() && 645 if (profile->IsOffTheRecord() &&
642 observer_.IsObserving(profile->GetHostContentSettingsMap())) { 646 observer_.IsObserving(settings_map)) {
643 web_ui()->CallJavascriptFunction( 647 web_ui()->CallJavascriptFunction(
644 "ContentSettingsExceptionsArea.OTRProfileDestroyed"); 648 "ContentSettingsExceptionsArea.OTRProfileDestroyed");
645 observer_.Remove(profile->GetHostContentSettingsMap()); 649 observer_.Remove(settings_map);
646 } 650 }
647 break; 651 break;
648 } 652 }
649 653
650 case chrome::NOTIFICATION_PROFILE_CREATED: { 654 case chrome::NOTIFICATION_PROFILE_CREATED: {
651 Profile* profile = content::Source<Profile>(source).ptr(); 655 Profile* profile = content::Source<Profile>(source).ptr();
652 if (profile->IsOffTheRecord()) { 656 if (profile->IsOffTheRecord()) {
653 UpdateAllOTRExceptionsViewsFromModel(); 657 UpdateAllOTRExceptionsViewsFromModel();
654 observer_.Add(profile->GetHostContentSettingsMap()); 658 observer_.Add(HostContentSettingsMapFactory::GetForProfile(profile));
655 } 659 }
656 break; 660 break;
657 } 661 }
658 662
659 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: { 663 case chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED: {
660 UpdateHandlersEnabledRadios(); 664 UpdateHandlersEnabledRadios();
661 break; 665 break;
662 } 666 }
663 } 667 }
664 } 668 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 784 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
781 UpdateMIDISysExExceptionsView(); 785 UpdateMIDISysExExceptionsView();
782 } else { 786 } else {
783 UpdateExceptionsViewFromHostContentSettingsMap(type); 787 UpdateExceptionsViewFromHostContentSettingsMap(type);
784 } 788 }
785 } 789 }
786 790
787 // TODO(estade): merge with GetExceptionsFromHostContentSettingsMap. 791 // TODO(estade): merge with GetExceptionsFromHostContentSettingsMap.
788 void ContentSettingsHandler::UpdateGeolocationExceptionsView() { 792 void ContentSettingsHandler::UpdateGeolocationExceptionsView() {
789 Profile* profile = Profile::FromWebUI(web_ui()); 793 Profile* profile = Profile::FromWebUI(web_ui());
790 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); 794 HostContentSettingsMap* map =
795 HostContentSettingsMapFactory::GetForProfile(profile);
791 796
792 ContentSettingsForOneType all_settings; 797 ContentSettingsForOneType all_settings;
793 map->GetSettingsForOneType( 798 map->GetSettingsForOneType(
794 CONTENT_SETTINGS_TYPE_GEOLOCATION, 799 CONTENT_SETTINGS_TYPE_GEOLOCATION,
795 std::string(), 800 std::string(),
796 &all_settings); 801 &all_settings);
797 802
798 // Group geolocation settings by primary_pattern. 803 // Group geolocation settings by primary_pattern.
799 AllPatternsSettings all_patterns_settings; 804 AllPatternsSettings all_patterns_settings;
800 for (ContentSettingsForOneType::iterator i = all_settings.begin(); 805 for (ContentSettingsForOneType::iterator i = all_settings.begin();
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group); 1310 ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group);
1306 Profile* profile = Profile::FromWebUI(web_ui()); 1311 Profile* profile = Profile::FromWebUI(web_ui());
1307 1312
1308 #if defined(OS_CHROMEOS) 1313 #if defined(OS_CHROMEOS)
1309 // ChromeOS special case : in Guest mode settings are opened in Incognito 1314 // ChromeOS special case : in Guest mode settings are opened in Incognito
1310 // mode, so we need original profile to actually modify settings. 1315 // mode, so we need original profile to actually modify settings.
1311 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) 1316 if (user_manager::UserManager::Get()->IsLoggedInAsGuest())
1312 profile = profile->GetOriginalProfile(); 1317 profile = profile->GetOriginalProfile();
1313 #endif 1318 #endif
1314 1319
1315 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); 1320 HostContentSettingsMap* map =
1321 HostContentSettingsMapFactory::GetForProfile(profile);
1316 1322
1317 // MEDIASTREAM is deprecated and the two separate settings MEDIASTREAM_CAMERA 1323 // MEDIASTREAM is deprecated and the two separate settings MEDIASTREAM_CAMERA
1318 // and MEDIASTREAM_MIC should be used instead. However, we still only have 1324 // and MEDIASTREAM_MIC should be used instead. However, we still only have
1319 // one pair of radio buttons that sets both settings. 1325 // one pair of radio buttons that sets both settings.
1320 // TODO(msramek): Clean this up once we have the new UI for media. 1326 // TODO(msramek): Clean this up once we have the new UI for media.
1321 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 1327 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
1322 map->SetDefaultContentSetting( 1328 map->SetDefaultContentSetting(
1323 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, default_setting); 1329 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, default_setting);
1324 map->SetDefaultContentSetting( 1330 map->SetDefaultContentSetting(
1325 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, default_setting); 1331 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, default_setting);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { 1466 for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
1461 if (type == kContentSettingsTypeGroupNames[i].type) 1467 if (type == kContentSettingsTypeGroupNames[i].type)
1462 return kContentSettingsTypeGroupNames[i].name; 1468 return kContentSettingsTypeGroupNames[i].name;
1463 } 1469 }
1464 1470
1465 NOTREACHED(); 1471 NOTREACHED();
1466 return std::string(); 1472 return std::string();
1467 } 1473 }
1468 1474
1469 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { 1475 HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() {
1470 return Profile::FromWebUI(web_ui())->GetHostContentSettingsMap(); 1476 return HostContentSettingsMapFactory::GetForProfile(
1477 Profile::FromWebUI(web_ui()));
1471 } 1478 }
1472 1479
1473 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { 1480 ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() {
1474 return ProtocolHandlerRegistryFactory::GetForBrowserContext( 1481 return ProtocolHandlerRegistryFactory::GetForBrowserContext(
1475 GetBrowserContext(web_ui())); 1482 GetBrowserContext(web_ui()));
1476 } 1483 }
1477 1484
1478 HostContentSettingsMap* 1485 HostContentSettingsMap*
1479 ContentSettingsHandler::GetOTRContentSettingsMap() { 1486 ContentSettingsHandler::GetOTRContentSettingsMap() {
1480 Profile* profile = Profile::FromWebUI(web_ui()); 1487 Profile* profile = Profile::FromWebUI(web_ui());
1481 if (profile->HasOffTheRecordProfile()) 1488 if (profile->HasOffTheRecordProfile())
1482 return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap(); 1489 return HostContentSettingsMapFactory::GetForProfile(
1490 profile->GetOffTheRecordProfile());
1483 return NULL; 1491 return NULL;
1484 } 1492 }
1485 1493
1486 void ContentSettingsHandler::RefreshFlashMediaSettings() { 1494 void ContentSettingsHandler::RefreshFlashMediaSettings() {
1487 MediaSettingsInfo::ForFlash& settings = media_settings_->forFlash(); 1495 MediaSettingsInfo::ForFlash& settings = media_settings_->forFlash();
1488 settings.initialized = false; 1496 settings.initialized = false;
1489 1497
1490 settings.last_refresh_request_id = 1498 settings.last_refresh_request_id =
1491 flash_settings_manager_->GetPermissionSettings( 1499 flash_settings_manager_->GetPermissionSettings(
1492 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC); 1500 PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1610
1603 // Exceptions apply only when the feature is enabled. 1611 // Exceptions apply only when the feature is enabled.
1604 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); 1612 PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui()));
1605 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); 1613 bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM);
1606 web_ui()->CallJavascriptFunction( 1614 web_ui()->CallJavascriptFunction(
1607 "ContentSettings.enableProtectedContentExceptions", 1615 "ContentSettings.enableProtectedContentExceptions",
1608 base::FundamentalValue(enable_exceptions)); 1616 base::FundamentalValue(enable_exceptions));
1609 } 1617 }
1610 1618
1611 } // namespace options 1619 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/website_settings/website_settings_unittest.cc ('k') | chrome/browser/ui/webui/plugins_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698