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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 1417023007: Replace HostContentSettingsMap::AddExceptionForURL with SetNarrowestWebsiteSetting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 Profile* profile, 249 Profile* profile,
250 ContentSettingsType content_type); 250 ContentSettingsType content_type);
251 ~ContentSettingSingleRadioGroup() override; 251 ~ContentSettingSingleRadioGroup() override;
252 252
253 protected: 253 protected:
254 bool settings_changed() const; 254 bool settings_changed() const;
255 int selected_item() const { return selected_item_; } 255 int selected_item() const { return selected_item_; }
256 256
257 private: 257 private:
258 void SetRadioGroup(); 258 void SetRadioGroup();
259 void AddException(ContentSetting setting); 259 void SetNarrowestContentSetting(ContentSetting setting);
260 void OnRadioClicked(int radio_index) override; 260 void OnRadioClicked(int radio_index) override;
261 261
262 ContentSetting block_setting_; 262 ContentSetting block_setting_;
263 int selected_item_; 263 int selected_item_;
264 }; 264 };
265 265
266 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup( 266 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup(
267 Delegate* delegate, 267 Delegate* delegate,
268 WebContents* web_contents, 268 WebContents* web_contents,
269 Profile* profile, 269 Profile* profile,
270 ContentSettingsType content_type) 270 ContentSettingsType content_type)
271 : ContentSettingTitleLinkAndCustomModel(delegate, web_contents, profile, 271 : ContentSettingTitleLinkAndCustomModel(delegate, web_contents, profile,
272 content_type), 272 content_type),
273 block_setting_(CONTENT_SETTING_BLOCK), 273 block_setting_(CONTENT_SETTING_BLOCK),
274 selected_item_(0) { 274 selected_item_(0) {
275 SetRadioGroup(); 275 SetRadioGroup();
276 } 276 }
277 277
278 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() { 278 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() {
279 if (settings_changed()) { 279 if (settings_changed()) {
280 ContentSetting setting = 280 ContentSetting setting =
281 selected_item_ == kAllowButtonIndex ? 281 selected_item_ == kAllowButtonIndex ?
282 CONTENT_SETTING_ALLOW : 282 CONTENT_SETTING_ALLOW :
283 block_setting_; 283 block_setting_;
284 AddException(setting); 284 SetNarrowestContentSetting(setting);
285 } 285 }
286 } 286 }
287 287
288 bool ContentSettingSingleRadioGroup::settings_changed() const { 288 bool ContentSettingSingleRadioGroup::settings_changed() const {
289 return selected_item_ != bubble_content().radio_group.default_item; 289 return selected_item_ != bubble_content().radio_group.default_item;
290 } 290 }
291 291
292 // Initialize the radio group by setting the appropriate labels for the 292 // Initialize the radio group by setting the appropriate labels for the
293 // content type and setting the default value based on the content setting. 293 // content type and setting the default value based on the content setting.
294 void ContentSettingSingleRadioGroup::SetRadioGroup() { 294 void ContentSettingSingleRadioGroup::SetRadioGroup() {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 setting != CONTENT_SETTING_ASK); 407 setting != CONTENT_SETTING_ASK);
408 if (setting_source != SETTING_SOURCE_USER) { 408 if (setting_source != SETTING_SOURCE_USER) {
409 set_radio_group_enabled(false); 409 set_radio_group_enabled(false);
410 } else { 410 } else {
411 set_radio_group_enabled(true); 411 set_radio_group_enabled(true);
412 } 412 }
413 selected_item_ = radio_group.default_item; 413 selected_item_ = radio_group.default_item;
414 set_radio_group(radio_group); 414 set_radio_group(radio_group);
415 } 415 }
416 416
417 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) { 417 void ContentSettingSingleRadioGroup::SetNarrowestContentSetting(
418 ContentSetting setting) {
418 if (profile()) { 419 if (profile()) {
419 HostContentSettingsMapFactory::GetForProfile(profile())->AddExceptionForURL( 420 HostContentSettingsMapFactory::GetForProfile(profile())
420 bubble_content().radio_group.url, 421 ->SetNarrowestContentSetting(bubble_content().radio_group.url,
421 bubble_content().radio_group.url, 422 bubble_content().radio_group.url,
422 content_type(), 423 content_type(), setting);
423 setting);
424 } 424 }
425 } 425 }
426 426
427 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) { 427 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) {
428 selected_item_ = radio_index; 428 selected_item_ = radio_index;
429 } 429 }
430 430
431 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { 431 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
432 public: 432 public:
433 ContentSettingCookiesBubbleModel(Delegate* delegate, 433 ContentSettingCookiesBubbleModel(Delegate* delegate,
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1379 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1380 DCHECK_EQ(web_contents_, 1380 DCHECK_EQ(web_contents_,
1381 content::Source<WebContents>(source).ptr()); 1381 content::Source<WebContents>(source).ptr());
1382 web_contents_ = NULL; 1382 web_contents_ = NULL;
1383 } else { 1383 } else {
1384 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1384 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1385 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1385 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1386 profile_ = NULL; 1386 profile_ = NULL;
1387 } 1387 }
1388 } 1388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698