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

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

Issue 1865803002: [Policy Experimental] Add policies to allow Cookies and Pop-ups exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync; compile fix in PolicyProvider::GetUserExceptionsUsageSettingForType(). Created 4 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs), 319 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs),
320 content_type())); 320 content_type()));
321 } 321 }
322 322
323 radio_group.radio_items.push_back(radio_allow_label); 323 radio_group.radio_items.push_back(radio_allow_label);
324 radio_group.radio_items.push_back(radio_block_label); 324 radio_group.radio_items.push_back(radio_block_label);
325 ContentSetting setting; 325 ContentSetting setting;
326 SettingSource setting_source = SETTING_SOURCE_NONE; 326 SettingSource setting_source = SETTING_SOURCE_NONE;
327 bool setting_is_wildcard = false; 327 bool setting_is_wildcard = false;
328 328
329 HostContentSettingsMap* map =
330 HostContentSettingsMapFactory::GetForProfile(profile());
329 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) { 331 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) {
330 content_settings::CookieSettings* cookie_settings = 332 content_settings::CookieSettings* cookie_settings =
331 CookieSettingsFactory::GetForProfile(profile()).get(); 333 CookieSettingsFactory::GetForProfile(profile()).get();
332 setting = cookie_settings->GetCookieSetting( 334 setting = cookie_settings->GetCookieSetting(
333 url, url, true, &setting_source); 335 url, url, true, &setting_source);
334 } else { 336 } else {
335 SettingInfo info; 337 SettingInfo info;
336 HostContentSettingsMap* map =
337 HostContentSettingsMapFactory::GetForProfile(profile());
338 std::unique_ptr<base::Value> value = 338 std::unique_ptr<base::Value> value =
339 map->GetWebsiteSetting(url, url, content_type(), std::string(), &info); 339 map->GetWebsiteSetting(url, url, content_type(), std::string(), &info);
340 setting = content_settings::ValueToContentSetting(value.get()); 340 setting = content_settings::ValueToContentSetting(value.get());
341 setting_source = info.source; 341 setting_source = info.source;
342 setting_is_wildcard = 342 setting_is_wildcard =
343 info.primary_pattern == ContentSettingsPattern::Wildcard() && 343 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
344 info.secondary_pattern == ContentSettingsPattern::Wildcard(); 344 info.secondary_pattern == ContentSettingsPattern::Wildcard();
345 } 345 }
346 346
347 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS && 347 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS &&
348 setting == CONTENT_SETTING_ALLOW && 348 setting == CONTENT_SETTING_ALLOW &&
349 setting_is_wildcard) { 349 setting_is_wildcard) {
350 // In the corner case of unrecognized plugins (which are now blocked by 350 // In the corner case of unrecognized plugins (which are now blocked by
351 // default) we indicate the blocked state in the UI and allow the user to 351 // default) we indicate the blocked state in the UI and allow the user to
352 // whitelist. 352 // whitelist.
353 radio_group.default_item = 1; 353 radio_group.default_item = 1;
354 } else if (setting == CONTENT_SETTING_ALLOW) { 354 } else if (setting == CONTENT_SETTING_ALLOW) {
355 radio_group.default_item = kAllowButtonIndex; 355 radio_group.default_item = kAllowButtonIndex;
356 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. 356 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|.
357 } else { 357 } else {
358 radio_group.default_item = 1; 358 radio_group.default_item = 1;
359 block_setting_ = setting; 359 block_setting_ = setting;
360 } 360 }
361 361
362 set_setting_is_managed(setting_source != SETTING_SOURCE_USER && 362 set_setting_is_managed(setting_source != SETTING_SOURCE_USER &&
363 setting != CONTENT_SETTING_ASK); 363 setting != CONTENT_SETTING_ASK);
364 if (setting_source != SETTING_SOURCE_USER) { 364
365 set_radio_group_enabled(false); 365 // Radio buttons are enabled iff user can edit exceptions in settings.
366 } else { 366 bool user_exception_allowed =
367 set_radio_group_enabled(true); 367 map->AreUserExceptionsAllowedForType(content_type());
368 } 368 set_radio_group_enabled(user_exception_allowed);
369
369 selected_item_ = radio_group.default_item; 370 selected_item_ = radio_group.default_item;
370 set_radio_group(radio_group); 371 set_radio_group(radio_group);
371 } 372 }
372 373
373 void ContentSettingSingleRadioGroup::SetNarrowestContentSetting( 374 void ContentSettingSingleRadioGroup::SetNarrowestContentSetting(
374 ContentSetting setting) { 375 ContentSetting setting) {
375 if (profile()) { 376 if (profile()) {
376 HostContentSettingsMapFactory::GetForProfile(profile()) 377 HostContentSettingsMapFactory::GetForProfile(profile())
377 ->SetNarrowestContentSetting(bubble_content().radio_group.url, 378 ->SetNarrowestContentSetting(bubble_content().radio_group.url,
378 bubble_content().radio_group.url, 379 bubble_content().radio_group.url,
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1314 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1314 // In general, bubble models might not inherit from the simple bubble model. 1315 // In general, bubble models might not inherit from the simple bubble model.
1315 return nullptr; 1316 return nullptr;
1316 } 1317 }
1317 1318
1318 ContentSettingMediaStreamBubbleModel* 1319 ContentSettingMediaStreamBubbleModel*
1319 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1320 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1320 // In general, bubble models might not inherit from the media bubble model. 1321 // In general, bubble models might not inherit from the media bubble model.
1321 return nullptr; 1322 return nullptr;
1322 } 1323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698