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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.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/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" 13 #include "chrome/browser/content_settings/chrome_content_settings_utils.h"
14 #include "chrome/browser/content_settings/cookie_settings_factory.h" 14 #include "chrome/browser/content_settings/cookie_settings_factory.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
15 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
16 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
17 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
18 #include "chrome/browser/infobars/infobar_service.h" 19 #include "chrome/browser/infobars/infobar_service.h"
19 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 20 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
20 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 21 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 23 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
23 #include "chrome/browser/ui/browser_navigator.h" 24 #include "chrome/browser/ui/browser_navigator.h"
24 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 25 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 SettingSource setting_source = SETTING_SOURCE_NONE; 371 SettingSource setting_source = SETTING_SOURCE_NONE;
371 bool setting_is_wildcard = false; 372 bool setting_is_wildcard = false;
372 373
373 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) { 374 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) {
374 content_settings::CookieSettings* cookie_settings = 375 content_settings::CookieSettings* cookie_settings =
375 CookieSettingsFactory::GetForProfile(profile()).get(); 376 CookieSettingsFactory::GetForProfile(profile()).get();
376 setting = cookie_settings->GetCookieSetting( 377 setting = cookie_settings->GetCookieSetting(
377 url, url, true, &setting_source); 378 url, url, true, &setting_source);
378 } else { 379 } else {
379 SettingInfo info; 380 SettingInfo info;
380 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); 381 HostContentSettingsMap* map =
382 HostContentSettingsMapFactory::GetForProfile(profile());
381 scoped_ptr<base::Value> value = 383 scoped_ptr<base::Value> value =
382 map->GetWebsiteSetting(url, url, content_type(), std::string(), &info); 384 map->GetWebsiteSetting(url, url, content_type(), std::string(), &info);
383 setting = content_settings::ValueToContentSetting(value.get()); 385 setting = content_settings::ValueToContentSetting(value.get());
384 setting_source = info.source; 386 setting_source = info.source;
385 setting_is_wildcard = 387 setting_is_wildcard =
386 info.primary_pattern == ContentSettingsPattern::Wildcard() && 388 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
387 info.secondary_pattern == ContentSettingsPattern::Wildcard(); 389 info.secondary_pattern == ContentSettingsPattern::Wildcard();
388 } 390 }
389 391
390 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS && 392 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS &&
(...skipping 17 matching lines...) Expand all
408 set_radio_group_enabled(false); 410 set_radio_group_enabled(false);
409 } else { 411 } else {
410 set_radio_group_enabled(true); 412 set_radio_group_enabled(true);
411 } 413 }
412 selected_item_ = radio_group.default_item; 414 selected_item_ = radio_group.default_item;
413 set_radio_group(radio_group); 415 set_radio_group(radio_group);
414 } 416 }
415 417
416 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) { 418 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) {
417 if (profile()) { 419 if (profile()) {
418 profile()->GetHostContentSettingsMap()->AddExceptionForURL( 420 HostContentSettingsMapFactory::GetForProfile(profile())->AddExceptionForURL(
419 bubble_content().radio_group.url, 421 bubble_content().radio_group.url,
420 bubble_content().radio_group.url, 422 bubble_content().radio_group.url,
421 content_type(), 423 content_type(),
422 setting); 424 setting);
423 } 425 }
424 } 426 }
425 427
426 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) { 428 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) {
427 selected_item_ = radio_index; 429 selected_item_ = radio_index;
428 } 430 }
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 radio_group.radio_items.push_back(radio_block_label); 797 radio_group.radio_items.push_back(radio_block_label);
796 798
797 set_radio_group(radio_group); 799 set_radio_group(radio_group);
798 set_radio_group_enabled(true); 800 set_radio_group_enabled(true);
799 } 801 }
800 802
801 void ContentSettingMediaStreamBubbleModel::UpdateSettings( 803 void ContentSettingMediaStreamBubbleModel::UpdateSettings(
802 ContentSetting setting) { 804 ContentSetting setting) {
803 if (profile()) { 805 if (profile()) {
804 HostContentSettingsMap* content_settings = 806 HostContentSettingsMap* content_settings =
805 profile()->GetHostContentSettingsMap(); 807 HostContentSettingsMapFactory::GetForProfile(profile());
806 TabSpecificContentSettings* tab_content_settings = 808 TabSpecificContentSettings* tab_content_settings =
807 TabSpecificContentSettings::FromWebContents(web_contents()); 809 TabSpecificContentSettings::FromWebContents(web_contents());
808 // The same patterns must be used as in other places (e.g. the infobar) in 810 // The same patterns must be used as in other places (e.g. the infobar) in
809 // order to override the existing rule. Otherwise a new rule is created. 811 // order to override the existing rule. Otherwise a new rule is created.
810 // TODO(markusheintz): Extract to a helper so that there is only a single 812 // TODO(markusheintz): Extract to a helper so that there is only a single
811 // place to touch. 813 // place to touch.
812 ContentSettingsPattern primary_pattern = 814 ContentSettingsPattern primary_pattern =
813 ContentSettingsPattern::FromURLNoWildcard( 815 ContentSettingsPattern::FromURLNoWildcard(
814 tab_content_settings->media_stream_access_origin()); 816 tab_content_settings->media_stream_access_origin());
815 ContentSettingsPattern secondary_pattern = 817 ContentSettingsPattern secondary_pattern =
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 if (!web_contents()) 1011 if (!web_contents())
1010 return; 1012 return;
1011 // Reset this embedder's entry to default for each of the requesting 1013 // Reset this embedder's entry to default for each of the requesting
1012 // origins currently on the page. 1014 // origins currently on the page.
1013 const GURL& embedder_url = web_contents()->GetURL(); 1015 const GURL& embedder_url = web_contents()->GetURL();
1014 TabSpecificContentSettings* content_settings = 1016 TabSpecificContentSettings* content_settings =
1015 TabSpecificContentSettings::FromWebContents(web_contents()); 1017 TabSpecificContentSettings::FromWebContents(web_contents());
1016 const ContentSettingsUsagesState::StateMap& state_map = 1018 const ContentSettingsUsagesState::StateMap& state_map =
1017 content_settings->geolocation_usages_state().state_map(); 1019 content_settings->geolocation_usages_state().state_map();
1018 HostContentSettingsMap* settings_map = 1020 HostContentSettingsMap* settings_map =
1019 profile()->GetHostContentSettingsMap(); 1021 HostContentSettingsMapFactory::GetForProfile(profile());
1020 1022
1021 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1023 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1022 settings_map->SetContentSetting( 1024 settings_map->SetContentSetting(
1023 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), 1025 ContentSettingsPattern::FromURLNoWildcard(map_entry.first),
1024 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 1026 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
1025 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(), 1027 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(),
1026 CONTENT_SETTING_DEFAULT); 1028 CONTENT_SETTING_DEFAULT);
1027 } 1029 }
1028 } 1030 }
1029 1031
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 if (!web_contents()) 1265 if (!web_contents())
1264 return; 1266 return;
1265 // Reset this embedder's entry to default for each of the requesting 1267 // Reset this embedder's entry to default for each of the requesting
1266 // origins currently on the page. 1268 // origins currently on the page.
1267 const GURL& embedder_url = web_contents()->GetURL(); 1269 const GURL& embedder_url = web_contents()->GetURL();
1268 TabSpecificContentSettings* content_settings = 1270 TabSpecificContentSettings* content_settings =
1269 TabSpecificContentSettings::FromWebContents(web_contents()); 1271 TabSpecificContentSettings::FromWebContents(web_contents());
1270 const ContentSettingsUsagesState::StateMap& state_map = 1272 const ContentSettingsUsagesState::StateMap& state_map =
1271 content_settings->midi_usages_state().state_map(); 1273 content_settings->midi_usages_state().state_map();
1272 HostContentSettingsMap* settings_map = 1274 HostContentSettingsMap* settings_map =
1273 profile()->GetHostContentSettingsMap(); 1275 HostContentSettingsMapFactory::GetForProfile(profile());
1274 1276
1275 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1277 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1276 settings_map->SetContentSetting( 1278 settings_map->SetContentSetting(
1277 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), 1279 ContentSettingsPattern::FromURLNoWildcard(map_entry.first),
1278 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 1280 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
1279 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), 1281 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(),
1280 CONTENT_SETTING_DEFAULT); 1282 CONTENT_SETTING_DEFAULT);
1281 } 1283 }
1282 } 1284 }
1283 1285
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1380 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1379 DCHECK_EQ(web_contents_, 1381 DCHECK_EQ(web_contents_,
1380 content::Source<WebContents>(source).ptr()); 1382 content::Source<WebContents>(source).ptr());
1381 web_contents_ = NULL; 1383 web_contents_ = NULL;
1382 } else { 1384 } else {
1383 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1385 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1384 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1386 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1385 profile_ = NULL; 1387 profile_ = NULL;
1386 } 1388 }
1387 } 1389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698