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

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

Issue 106713004: Remove kEnableResourceContentSettings and all the code that uses it since it's been behind a flag f… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 7 years 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 | Annotate | Revision Log
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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 ContentSettingTitleAndLinkModel::ContentSettingTitleAndLinkModel( 86 ContentSettingTitleAndLinkModel::ContentSettingTitleAndLinkModel(
87 Delegate* delegate, 87 Delegate* delegate,
88 WebContents* web_contents, 88 WebContents* web_contents,
89 Profile* profile, 89 Profile* profile,
90 ContentSettingsType content_type) 90 ContentSettingsType content_type)
91 : ContentSettingBubbleModel(web_contents, profile, content_type), 91 : ContentSettingBubbleModel(web_contents, profile, content_type),
92 delegate_(delegate) { 92 delegate_(delegate) {
93 // Notifications do not have a bubble. 93 // Notifications do not have a bubble.
94 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 94 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
95 SetBlockedResources();
96 SetTitle(); 95 SetTitle();
97 SetManageLink(); 96 SetManageLink();
98 } 97 }
99 98
100 void ContentSettingTitleAndLinkModel::SetBlockedResources() {
101 TabSpecificContentSettings* settings =
102 TabSpecificContentSettings::FromWebContents(web_contents());
103 const std::set<std::string>& resources = settings->BlockedResourcesForType(
104 content_type());
105 for (std::set<std::string>::const_iterator it = resources.begin();
106 it != resources.end(); ++it) {
107 AddBlockedResource(*it);
108 }
109 }
110
111 void ContentSettingTitleAndLinkModel::SetTitle() { 99 void ContentSettingTitleAndLinkModel::SetTitle() {
112 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { 100 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = {
113 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, 101 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE},
114 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, 102 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE},
115 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, 103 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE},
116 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, 104 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE},
117 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, 105 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE},
118 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 106 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
119 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, 107 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT},
120 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 108 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
121 IDS_BLOCKED_PPAPI_BROKER_TITLE}, 109 IDS_BLOCKED_PPAPI_BROKER_TITLE},
122 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, 110 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE},
123 }; 111 };
124 // Fields as for kBlockedTitleIDs, above. 112 // Fields as for kBlockedTitleIDs, above.
125 static const ContentSettingsTypeIdEntry
126 kResourceSpecificBlockedTitleIDs[] = {
127 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE},
128 };
129 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { 113 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = {
130 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, 114 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE},
131 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, 115 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE},
132 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, 116 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE},
133 }; 117 };
134 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; 118 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs;
135 size_t num_title_ids = arraysize(kBlockedTitleIDs); 119 size_t num_title_ids = arraysize(kBlockedTitleIDs);
136 if (web_contents() && 120 if (web_contents() &&
137 TabSpecificContentSettings::FromWebContents( 121 TabSpecificContentSettings::FromWebContents(
138 web_contents())->IsContentAllowed(content_type()) && 122 web_contents())->IsContentAllowed(content_type()) &&
139 !TabSpecificContentSettings::FromWebContents( 123 !TabSpecificContentSettings::FromWebContents(
140 web_contents())->IsContentBlocked(content_type())) { 124 web_contents())->IsContentBlocked(content_type())) {
141 title_ids = kAccessedTitleIDs; 125 title_ids = kAccessedTitleIDs;
142 num_title_ids = arraysize(kAccessedTitleIDs); 126 num_title_ids = arraysize(kAccessedTitleIDs);
143 } else if (!bubble_content().resource_identifiers.empty()) {
144 title_ids = kResourceSpecificBlockedTitleIDs;
145 num_title_ids = arraysize(kResourceSpecificBlockedTitleIDs);
146 } 127 }
147 int title_id = 128 int title_id =
148 GetIdForContentType(title_ids, num_title_ids, content_type()); 129 GetIdForContentType(title_ids, num_title_ids, content_type());
149 if (title_id) 130 if (title_id)
150 set_title(l10n_util::GetStringUTF8(title_id)); 131 set_title(l10n_util::GetStringUTF8(title_id));
151 } 132 }
152 133
153 void ContentSettingTitleAndLinkModel::SetManageLink() { 134 void ContentSettingTitleAndLinkModel::SetManageLink() {
154 static const ContentSettingsTypeIdEntry kLinkIDs[] = { 135 static const ContentSettingsTypeIdEntry kLinkIDs[] = {
155 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, 136 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK},
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 Profile* profile, 199 Profile* profile,
219 ContentSettingsType content_type); 200 ContentSettingsType content_type);
220 virtual ~ContentSettingSingleRadioGroup(); 201 virtual ~ContentSettingSingleRadioGroup();
221 202
222 protected: 203 protected:
223 bool settings_changed() const; 204 bool settings_changed() const;
224 int selected_item() const { return selected_item_; } 205 int selected_item() const { return selected_item_; }
225 206
226 private: 207 private:
227 void SetRadioGroup(); 208 void SetRadioGroup();
228 void AddException(ContentSetting setting, 209 void AddException(ContentSetting setting);
229 const std::string& resource_identifier);
230 virtual void OnRadioClicked(int radio_index) OVERRIDE; 210 virtual void OnRadioClicked(int radio_index) OVERRIDE;
231 211
232 ContentSetting block_setting_; 212 ContentSetting block_setting_;
233 int selected_item_; 213 int selected_item_;
234 }; 214 };
235 215
236 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup( 216 ContentSettingSingleRadioGroup::ContentSettingSingleRadioGroup(
237 Delegate* delegate, 217 Delegate* delegate,
238 WebContents* web_contents, 218 WebContents* web_contents,
239 Profile* profile, 219 Profile* profile,
240 ContentSettingsType content_type) 220 ContentSettingsType content_type)
241 : ContentSettingTitleLinkAndCustomModel(delegate, web_contents, profile, 221 : ContentSettingTitleLinkAndCustomModel(delegate, web_contents, profile,
242 content_type), 222 content_type),
243 block_setting_(CONTENT_SETTING_BLOCK), 223 block_setting_(CONTENT_SETTING_BLOCK),
244 selected_item_(0) { 224 selected_item_(0) {
245 SetRadioGroup(); 225 SetRadioGroup();
246 } 226 }
247 227
248 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() { 228 ContentSettingSingleRadioGroup::~ContentSettingSingleRadioGroup() {
249 if (settings_changed()) { 229 if (settings_changed()) {
250 ContentSetting setting = 230 ContentSetting setting =
251 selected_item_ == kAllowButtonIndex ? 231 selected_item_ == kAllowButtonIndex ?
252 CONTENT_SETTING_ALLOW : 232 CONTENT_SETTING_ALLOW :
253 block_setting_; 233 block_setting_;
254 const std::set<std::string>& resources = 234 AddException(setting);
255 bubble_content().resource_identifiers;
256 if (resources.empty()) {
257 AddException(setting, std::string());
258 } else {
259 for (std::set<std::string>::const_iterator it = resources.begin();
260 it != resources.end(); ++it) {
261 AddException(setting, *it);
262 }
263 }
264 } 235 }
265 } 236 }
266 237
267 bool ContentSettingSingleRadioGroup::settings_changed() const { 238 bool ContentSettingSingleRadioGroup::settings_changed() const {
268 return selected_item_ != bubble_content().radio_group.default_item; 239 return selected_item_ != bubble_content().radio_group.default_item;
269 } 240 }
270 241
271 // Initialize the radio group by setting the appropriate labels for the 242 // Initialize the radio group by setting the appropriate labels for the
272 // content type and setting the default value based on the content setting. 243 // content type and setting the default value based on the content setting.
273 void ContentSettingSingleRadioGroup::SetRadioGroup() { 244 void ContentSettingSingleRadioGroup::SetRadioGroup() {
274 GURL url = web_contents()->GetURL(); 245 GURL url = web_contents()->GetURL();
275 string16 display_host; 246 string16 display_host;
276 net::AppendFormattedHost( 247 net::AppendFormattedHost(
277 url, 248 url,
278 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), 249 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages),
279 &display_host); 250 &display_host);
280 251
281 if (display_host.empty()) 252 if (display_host.empty())
282 display_host = ASCIIToUTF16(url.spec()); 253 display_host = ASCIIToUTF16(url.spec());
283 254
284 const std::set<std::string>& resources =
285 bubble_content().resource_identifiers;
286
287 TabSpecificContentSettings* content_settings = 255 TabSpecificContentSettings* content_settings =
288 TabSpecificContentSettings::FromWebContents(web_contents()); 256 TabSpecificContentSettings::FromWebContents(web_contents());
289 bool allowed = 257 bool allowed =
290 !content_settings->IsContentBlocked(content_type()); 258 !content_settings->IsContentBlocked(content_type());
291 DCHECK(!allowed || 259 DCHECK(!allowed ||
292 content_settings->IsContentAllowed(content_type())); 260 content_settings->IsContentAllowed(content_type()));
293 261
294 RadioGroup radio_group; 262 RadioGroup radio_group;
295 radio_group.url = url; 263 radio_group.url = url;
296 264
297 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = { 265 static const ContentSettingsTypeIdEntry kBlockedAllowIDs[] = {
298 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, 266 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK},
299 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK}, 267 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_UNBLOCK},
300 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK}, 268 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_UNBLOCK},
301 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL}, 269 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK_ALL},
302 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK}, 270 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_UNBLOCK},
303 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK}, 271 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_UNBLOCK},
304 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK}, 272 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_UNBLOCK},
305 }; 273 };
306 // Fields as for kBlockedAllowIDs, above. 274 // Fields as for kBlockedAllowIDs, above.
307 static const ContentSettingsTypeIdEntry kResourceSpecificBlockedAllowIDs[] = {
308 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_UNBLOCK},
309 };
310 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = { 275 static const ContentSettingsTypeIdEntry kAllowedAllowIDs[] = {
311 // TODO(bauerb): The string shouldn't be "unblock" (they weren't blocked). 276 // TODO(bauerb): The string shouldn't be "unblock" (they weren't blocked).
312 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK}, 277 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_UNBLOCK},
313 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION}, 278 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_NO_ACTION},
314 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION}, 279 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_NO_ACTION},
315 }; 280 };
316 281
317 std::string radio_allow_label; 282 std::string radio_allow_label;
318 if (allowed) { 283 if (allowed) {
319 int resource_id = GetIdForContentType(kAllowedAllowIDs, 284 int resource_id = GetIdForContentType(kAllowedAllowIDs,
320 arraysize(kAllowedAllowIDs), 285 arraysize(kAllowedAllowIDs),
321 content_type()); 286 content_type());
322 radio_allow_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ? 287 radio_allow_label = (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) ?
323 l10n_util::GetStringFUTF8(resource_id, display_host) : 288 l10n_util::GetStringFUTF8(resource_id, display_host) :
324 l10n_util::GetStringUTF8(resource_id); 289 l10n_util::GetStringUTF8(resource_id);
325 } else if (resources.empty()) { 290 } else {
326 radio_allow_label = l10n_util::GetStringFUTF8( 291 radio_allow_label = l10n_util::GetStringFUTF8(
327 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs), 292 GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs),
328 content_type()), 293 content_type()),
329 display_host); 294 display_host);
330 } else {
331 radio_allow_label = l10n_util::GetStringFUTF8(
332 GetIdForContentType(kResourceSpecificBlockedAllowIDs,
333 arraysize(kResourceSpecificBlockedAllowIDs),
334 content_type()),
335 display_host);
336 } 295 }
337 296
338 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = { 297 static const ContentSettingsTypeIdEntry kBlockedBlockIDs[] = {
339 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION}, 298 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_NO_ACTION},
340 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION}, 299 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_NO_ACTION},
341 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION}, 300 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_NO_ACTION},
342 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION}, 301 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_NO_ACTION},
343 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION}, 302 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_NO_ACTION},
344 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION}, 303 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_NO_ACTION},
345 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION}, 304 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_NO_ACTION},
(...skipping 14 matching lines...) Expand all
360 l10n_util::GetStringUTF8(resource_id) : 319 l10n_util::GetStringUTF8(resource_id) :
361 l10n_util::GetStringFUTF8(resource_id, display_host); 320 l10n_util::GetStringFUTF8(resource_id, display_host);
362 } else { 321 } else {
363 radio_block_label = l10n_util::GetStringUTF8( 322 radio_block_label = l10n_util::GetStringUTF8(
364 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs), 323 GetIdForContentType(kBlockedBlockIDs, arraysize(kBlockedBlockIDs),
365 content_type())); 324 content_type()));
366 } 325 }
367 326
368 radio_group.radio_items.push_back(radio_allow_label); 327 radio_group.radio_items.push_back(radio_allow_label);
369 radio_group.radio_items.push_back(radio_block_label); 328 radio_group.radio_items.push_back(radio_block_label);
370 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap(); 329 ContentSetting setting;
371 CookieSettings* cookie_settings = 330 SettingSource setting_source = SETTING_SOURCE_NONE;
372 CookieSettings::Factory::GetForProfile(profile()).get(); 331 bool setting_is_wildcard = false;
373 ContentSetting most_restrictive_setting;
374 SettingSource most_restrictive_setting_source = SETTING_SOURCE_NONE;
375 bool most_restrictive_setting_is_wildcard = false;
376 332
377 if (resources.empty()) { 333 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) {
378 if (content_type() == CONTENT_SETTINGS_TYPE_COOKIES) { 334 CookieSettings* cookie_settings =
379 most_restrictive_setting = cookie_settings->GetCookieSetting( 335 CookieSettings::Factory::GetForProfile(profile()).get();
380 url, url, true, &most_restrictive_setting_source); 336 setting = cookie_settings->GetCookieSetting(
381 } else { 337 url, url, true, &setting_source);
382 SettingInfo info;
383 scoped_ptr<Value> value(map->GetWebsiteSetting(
384 url, url, content_type(), std::string(), &info));
385 most_restrictive_setting =
386 content_settings::ValueToContentSetting(value.get());
387 most_restrictive_setting_source = info.source;
388 most_restrictive_setting_is_wildcard =
389 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
390 info.secondary_pattern == ContentSettingsPattern::Wildcard();
391 }
392 } else { 338 } else {
393 most_restrictive_setting = CONTENT_SETTING_ALLOW; 339 SettingInfo info;
394 for (std::set<std::string>::const_iterator it = resources.begin(); 340 HostContentSettingsMap* map = profile()->GetHostContentSettingsMap();
395 it != resources.end(); ++it) { 341 scoped_ptr<Value> value(map->GetWebsiteSetting(
396 SettingInfo info; 342 url, url, content_type(), std::string(), &info));
397 scoped_ptr<Value> val(map->GetWebsiteSetting( 343 setting = content_settings::ValueToContentSetting(value.get());
398 url, url, content_type(), *it, &info)); 344 setting_source = info.source;
399 ContentSetting setting = 345 setting_is_wildcard =
400 content_settings::ValueToContentSetting(val.get()); 346 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
401 if (setting == CONTENT_SETTING_BLOCK) { 347 info.secondary_pattern == ContentSettingsPattern::Wildcard();
402 most_restrictive_setting = CONTENT_SETTING_BLOCK;
403 most_restrictive_setting_source = info.source;
404 most_restrictive_setting_is_wildcard =
405 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
406 info.secondary_pattern == ContentSettingsPattern::Wildcard();
407 break;
408 }
409 if (setting == CONTENT_SETTING_ASK) {
410 most_restrictive_setting = CONTENT_SETTING_ASK;
411 most_restrictive_setting_source = info.source;
412 most_restrictive_setting_is_wildcard =
413 info.primary_pattern == ContentSettingsPattern::Wildcard() &&
414 info.secondary_pattern == ContentSettingsPattern::Wildcard();
415 }
416 }
417 } 348 }
418 349
419 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS && 350 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS &&
420 most_restrictive_setting == CONTENT_SETTING_ALLOW && 351 setting == CONTENT_SETTING_ALLOW &&
421 most_restrictive_setting_is_wildcard) { 352 setting_is_wildcard) {
422 // In the corner case of unrecognized plugins (which are now blocked by 353 // In the corner case of unrecognized plugins (which are now blocked by
423 // default) we indicate the blocked state in the UI and allow the user to 354 // default) we indicate the blocked state in the UI and allow the user to
424 // whitelist. 355 // whitelist.
425 radio_group.default_item = 1; 356 radio_group.default_item = 1;
426 } else if (most_restrictive_setting == CONTENT_SETTING_ALLOW) { 357 } else if (setting == CONTENT_SETTING_ALLOW) {
427 radio_group.default_item = kAllowButtonIndex; 358 radio_group.default_item = kAllowButtonIndex;
428 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|. 359 // |block_setting_| is already set to |CONTENT_SETTING_BLOCK|.
429 } else { 360 } else {
430 radio_group.default_item = 1; 361 radio_group.default_item = 1;
431 block_setting_ = most_restrictive_setting; 362 block_setting_ = setting;
432 } 363 }
433 if (most_restrictive_setting_source != SETTING_SOURCE_USER) { 364 if (setting_source != SETTING_SOURCE_USER) {
434 set_radio_group_enabled(false); 365 set_radio_group_enabled(false);
435 } else { 366 } else {
436 set_radio_group_enabled(true); 367 set_radio_group_enabled(true);
437 } 368 }
438 selected_item_ = radio_group.default_item; 369 selected_item_ = radio_group.default_item;
439 set_radio_group(radio_group); 370 set_radio_group(radio_group);
440 } 371 }
441 372
442 void ContentSettingSingleRadioGroup::AddException( 373 void ContentSettingSingleRadioGroup::AddException(ContentSetting setting) {
443 ContentSetting setting,
444 const std::string& resource_identifier) {
445 if (profile()) { 374 if (profile()) {
446 profile()->GetHostContentSettingsMap()->AddExceptionForURL( 375 profile()->GetHostContentSettingsMap()->AddExceptionForURL(
447 bubble_content().radio_group.url, 376 bubble_content().radio_group.url,
448 bubble_content().radio_group.url, 377 bubble_content().radio_group.url,
449 content_type(), 378 content_type(),
450 resource_identifier,
451 setting); 379 setting);
452 } 380 }
453 } 381 }
454 382
455 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) { 383 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) {
456 selected_item_ = radio_index; 384 selected_item_ = radio_index;
457 } 385 }
458 386
459 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { 387 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
460 public: 388 public:
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 1286
1359 ContentSettingBubbleModel::MediaMenu::~MediaMenu() {} 1287 ContentSettingBubbleModel::MediaMenu::~MediaMenu() {}
1360 1288
1361 ContentSettingBubbleModel::BubbleContent::BubbleContent() 1289 ContentSettingBubbleModel::BubbleContent::BubbleContent()
1362 : radio_group_enabled(false), 1290 : radio_group_enabled(false),
1363 custom_link_enabled(false) { 1291 custom_link_enabled(false) {
1364 } 1292 }
1365 1293
1366 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {} 1294 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {}
1367 1295
1368
1369 void ContentSettingBubbleModel::AddBlockedResource(
1370 const std::string& resource_identifier) {
1371 bubble_content_.resource_identifiers.insert(resource_identifier);
1372 }
1373
1374 void ContentSettingBubbleModel::Observe( 1296 void ContentSettingBubbleModel::Observe(
1375 int type, 1297 int type,
1376 const content::NotificationSource& source, 1298 const content::NotificationSource& source,
1377 const content::NotificationDetails& details) { 1299 const content::NotificationDetails& details) {
1378 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1300 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1379 DCHECK_EQ(web_contents_, 1301 DCHECK_EQ(web_contents_,
1380 content::Source<WebContents>(source).ptr()); 1302 content::Source<WebContents>(source).ptr());
1381 web_contents_ = NULL; 1303 web_contents_ = NULL;
1382 } else { 1304 } else {
1383 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1305 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1384 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1306 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1385 profile_ = NULL; 1307 profile_ = NULL;
1386 } 1308 }
1387 } 1309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698