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

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

Issue 1025503002: Use same base class for popup and plugin blocking UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use actual types in for loops instead of auto Created 5 years, 9 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/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 18 matching lines...) Expand all
29 #include "components/content_settings/core/browser/content_settings_utils.h" 29 #include "components/content_settings/core/browser/content_settings_utils.h"
30 #include "components/content_settings/core/common/content_settings.h" 30 #include "components/content_settings/core/common/content_settings.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "content/public/browser/render_frame_host.h" 32 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_view_host.h" 34 #include "content/public/browser/render_view_host.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
38 #include "grit/components_strings.h" 38 #include "grit/components_strings.h"
39 #include "grit/theme_resources.h"
39 #include "net/base/net_util.h" 40 #include "net/base/net_util.h"
40 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/resource/resource_bundle.h" 42 #include "ui/base/resource/resource_bundle.h"
42 #include "ui/resources/grit/ui_resources.h" 43 #include "ui/resources/grit/ui_resources.h"
43 44
44 using base::UserMetricsAction; 45 using base::UserMetricsAction;
45 using content::WebContents; 46 using content::WebContents;
46 using content_settings::SettingInfo; 47 using content_settings::SettingInfo;
47 using content_settings::SettingSource; 48 using content_settings::SettingSource;
48 using content_settings::SETTING_SOURCE_USER; 49 using content_settings::SETTING_SOURCE_USER;
(...skipping 23 matching lines...) Expand all
72 if (entries[i].type == type) 73 if (entries[i].type == type)
73 return entries[i].id; 74 return entries[i].id;
74 } 75 }
75 return 0; 76 return 0;
76 } 77 }
77 78
78 const content::MediaStreamDevice& GetMediaDeviceById( 79 const content::MediaStreamDevice& GetMediaDeviceById(
79 const std::string& device_id, 80 const std::string& device_id,
80 const content::MediaStreamDevices& devices) { 81 const content::MediaStreamDevices& devices) {
81 DCHECK(!devices.empty()); 82 DCHECK(!devices.empty());
82 for (content::MediaStreamDevices::const_iterator it = devices.begin(); 83 for (const content::MediaStreamDevice& device : devices) {
83 it != devices.end(); ++it) { 84 if (device.id == device_id)
84 if (it->id == device_id) 85 return device;
85 return *(it);
86 } 86 }
87 87
88 // A device with the |device_id| was not found. It is likely that the device 88 // A device with the |device_id| was not found. It is likely that the device
89 // has been unplugged from the OS. Return the first device as the default 89 // has been unplugged from the OS. Return the first device as the default
90 // device. 90 // device.
91 return *devices.begin(); 91 return *devices.begin();
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
(...skipping 11 matching lines...) Expand all
107 SetLearnMoreLink(); 107 SetLearnMoreLink();
108 } 108 }
109 109
110 void ContentSettingTitleAndLinkModel::SetTitle() { 110 void ContentSettingTitleAndLinkModel::SetTitle() {
111 TabSpecificContentSettings* content_settings = NULL; 111 TabSpecificContentSettings* content_settings = NULL;
112 if (web_contents()) { 112 if (web_contents()) {
113 content_settings = 113 content_settings =
114 TabSpecificContentSettings::FromWebContents(web_contents()); 114 TabSpecificContentSettings::FromWebContents(web_contents());
115 } 115 }
116 116
117 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS && content_settings &&
118 content_settings->IsContentBlocked(content_type())) {
119 set_plugin_names(content_settings->GetBlockedPluginNames());
120 }
121
122 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { 117 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = {
123 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, 118 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE},
124 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, 119 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE},
125 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, 120 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE},
126 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, 121 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE},
127 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, 122 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE},
128 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 123 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
129 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, 124 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT},
130 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 125 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
131 IDS_BLOCKED_PPAPI_BROKER_TITLE}, 126 IDS_BLOCKED_PPAPI_BROKER_TITLE},
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 413 }
419 414
420 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) { 415 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) {
421 selected_item_ = radio_index; 416 selected_item_ = radio_index;
422 } 417 }
423 418
424 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { 419 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
425 public: 420 public:
426 ContentSettingCookiesBubbleModel(Delegate* delegate, 421 ContentSettingCookiesBubbleModel(Delegate* delegate,
427 WebContents* web_contents, 422 WebContents* web_contents,
428 Profile* profile, 423 Profile* profile);
429 ContentSettingsType content_type);
430 424
431 ~ContentSettingCookiesBubbleModel() override; 425 ~ContentSettingCookiesBubbleModel() override;
432 426
433 private: 427 private:
434 void OnCustomLinkClicked() override; 428 void OnCustomLinkClicked() override;
435 }; 429 };
436 430
437 ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel( 431 ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel(
438 Delegate* delegate, 432 Delegate* delegate,
439 WebContents* web_contents, 433 WebContents* web_contents,
440 Profile* profile, 434 Profile* profile)
441 ContentSettingsType content_type) 435 : ContentSettingSingleRadioGroup(delegate,
442 : ContentSettingSingleRadioGroup( 436 web_contents,
443 delegate, web_contents, profile, content_type) { 437 profile,
444 DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type); 438 CONTENT_SETTINGS_TYPE_COOKIES) {
445 set_custom_link_enabled(true); 439 set_custom_link_enabled(true);
446 } 440 }
447 441
448 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() { 442 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() {
449 // On some plattforms e.g. MacOS X it is possible to close a tab while the 443 // On some plattforms e.g. MacOS X it is possible to close a tab while the
450 // cookies settings bubble is open. This resets the web contents to NULL. 444 // cookies settings bubble is open. This resets the web contents to NULL.
451 if (settings_changed() && web_contents()) { 445 if (settings_changed() && web_contents()) {
452 CollectedCookiesInfoBarDelegate::Create( 446 CollectedCookiesInfoBarDelegate::Create(
453 InfoBarService::FromWebContents(web_contents())); 447 InfoBarService::FromWebContents(web_contents()));
454 } 448 }
455 } 449 }
456 450
457 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() { 451 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() {
458 if (!web_contents()) 452 if (!web_contents())
459 return; 453 return;
460 content::NotificationService::current()->Notify( 454 content::NotificationService::current()->Notify(
461 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 455 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
462 content::Source<TabSpecificContentSettings>( 456 content::Source<TabSpecificContentSettings>(
463 TabSpecificContentSettings::FromWebContents(web_contents())), 457 TabSpecificContentSettings::FromWebContents(web_contents())),
464 content::NotificationService::NoDetails()); 458 content::NotificationService::NoDetails());
465 delegate()->ShowCollectedCookiesDialog(web_contents()); 459 delegate()->ShowCollectedCookiesDialog(web_contents());
466 } 460 }
467 461
468 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { 462 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup {
469 public: 463 public:
470 ContentSettingPluginBubbleModel(Delegate* delegate, 464 ContentSettingPluginBubbleModel(Delegate* delegate,
471 WebContents* web_contents, 465 WebContents* web_contents,
472 Profile* profile, 466 Profile* profile);
473 ContentSettingsType content_type);
474 467
475 ~ContentSettingPluginBubbleModel() override; 468 ~ContentSettingPluginBubbleModel() override;
476 469
477 private: 470 private:
478 void OnCustomLinkClicked() override; 471 void OnCustomLinkClicked() override;
479 }; 472 };
480 473
481 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel( 474 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel(
482 Delegate* delegate, 475 Delegate* delegate,
483 WebContents* web_contents, 476 WebContents* web_contents,
484 Profile* profile, 477 Profile* profile)
485 ContentSettingsType content_type) 478 : ContentSettingSingleRadioGroup(delegate,
486 : ContentSettingSingleRadioGroup( 479 web_contents,
487 delegate, web_contents, profile, content_type) { 480 profile,
488 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); 481 CONTENT_SETTINGS_TYPE_PLUGINS) {
489 // Disable the "Run all plugins this time" link if the setting is managed and 482 // Disable the "Run all plugins this time" link if the setting is managed and
490 // can't be controlled by the user or if the user already clicked on the link 483 // can't be controlled by the user or if the user already clicked on the link
491 // and ran all plugins. 484 // and ran all plugins.
492 set_custom_link_enabled(!setting_is_managed() && 485 set_custom_link_enabled(!setting_is_managed() &&
493 web_contents && 486 web_contents &&
494 TabSpecificContentSettings::FromWebContents( 487 TabSpecificContentSettings::FromWebContents(
495 web_contents)->load_plugins_link_enabled()); 488 web_contents)->load_plugins_link_enabled());
489 // Build blocked plugin list.
490 if (web_contents) {
491 TabSpecificContentSettings* content_settings =
492 TabSpecificContentSettings::FromWebContents(web_contents);
493
494 const std::vector<base::string16>& blocked_plugins =
495 content_settings->blocked_plugin_names();
496 for (const base::string16& blocked_plugin : blocked_plugins) {
497 ListItem plugin_item(
498 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
499 IDR_BLOCKED_PLUGINS),
500 base::UTF16ToUTF8(blocked_plugin), false, 0);
501 add_list_item(plugin_item);
502 }
503 }
496 } 504 }
497 505
498 ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() { 506 ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() {
499 if (settings_changed()) { 507 if (settings_changed()) {
500 // If the user elected to allow all plugins then run plugins at this time. 508 // If the user elected to allow all plugins then run plugins at this time.
501 if (selected_item() == kAllowButtonIndex) 509 if (selected_item() == kAllowButtonIndex)
502 OnCustomLinkClicked(); 510 OnCustomLinkClicked();
503 } 511 }
504 } 512 }
505 513
(...skipping 10 matching lines...) Expand all
516 #endif 524 #endif
517 set_custom_link_enabled(false); 525 set_custom_link_enabled(false);
518 TabSpecificContentSettings::FromWebContents(web_contents())-> 526 TabSpecificContentSettings::FromWebContents(web_contents())->
519 set_load_plugins_link_enabled(false); 527 set_load_plugins_link_enabled(false);
520 } 528 }
521 529
522 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { 530 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
523 public: 531 public:
524 ContentSettingPopupBubbleModel(Delegate* delegate, 532 ContentSettingPopupBubbleModel(Delegate* delegate,
525 WebContents* web_contents, 533 WebContents* web_contents,
526 Profile* profile, 534 Profile* profile);
527 ContentSettingsType content_type);
528 ~ContentSettingPopupBubbleModel() override {} 535 ~ContentSettingPopupBubbleModel() override {}
529 536
530 private: 537 private:
531 void SetPopups(); 538 void OnListItemClicked(int index) override;
532 void OnPopupClicked(int index) override; 539
540 int32 item_id_from_item_index(int index) const {
541 return bubble_content().list_items[index].item_id;
542 }
533 }; 543 };
534 544
535 ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel( 545 ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel(
536 Delegate* delegate, 546 Delegate* delegate,
537 WebContents* web_contents, 547 WebContents* web_contents,
538 Profile* profile, 548 Profile* profile)
539 ContentSettingsType content_type) 549 : ContentSettingSingleRadioGroup(delegate,
540 : ContentSettingSingleRadioGroup( 550 web_contents,
541 delegate, web_contents, profile, content_type) { 551 profile,
542 SetPopups(); 552 CONTENT_SETTINGS_TYPE_POPUPS) {
543 } 553 if (web_contents) {
544 554 // Build blocked popup list.
545 555 std::map<int32, GURL> blocked_popups =
546 void ContentSettingPopupBubbleModel::SetPopups() { 556 PopupBlockerTabHelper::FromWebContents(web_contents)
547 std::map<int32, GURL> blocked_popups = 557 ->GetBlockedPopupRequests();
548 PopupBlockerTabHelper::FromWebContents(web_contents()) 558 for (const std::pair<int32, GURL>& blocked_popup : blocked_popups) {
549 ->GetBlockedPopupRequests(); 559 std::string title(blocked_popup.second.spec());
550 for (std::map<int32, GURL>::const_iterator iter = blocked_popups.begin(); 560 // The popup may not have a valid URL.
551 iter != blocked_popups.end(); 561 if (title.empty())
552 ++iter) { 562 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE);
553 std::string title(iter->second.spec()); 563 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
554 // The popup may not have a valid URL. 564 IDR_DEFAULT_FAVICON),
555 if (title.empty()) 565 title, true, blocked_popup.first);
556 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); 566 add_list_item(popup_item);
557 PopupItem popup_item( 567 }
558 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
559 IDR_DEFAULT_FAVICON),
560 title,
561 iter->first);
562 add_popup(popup_item);
563 } 568 }
564 } 569 }
565 570
566 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { 571 void ContentSettingPopupBubbleModel::OnListItemClicked(int index) {
567 if (web_contents()) { 572 if (web_contents()) {
568 PopupBlockerTabHelper::FromWebContents(web_contents())-> 573 PopupBlockerTabHelper::FromWebContents(web_contents())
569 ShowBlockedPopup(bubble_content().popup_items[index].popup_id); 574 ->ShowBlockedPopup(item_id_from_item_index(index));
570 } 575 }
571 } 576 }
572 577
573 // The model of the content settings bubble for media settings. 578 // The model of the content settings bubble for media settings.
574 class ContentSettingMediaStreamBubbleModel 579 class ContentSettingMediaStreamBubbleModel
575 : public ContentSettingTitleAndLinkModel { 580 : public ContentSettingTitleAndLinkModel {
576 public: 581 public:
577 ContentSettingMediaStreamBubbleModel(Delegate* delegate, 582 ContentSettingMediaStreamBubbleModel(Delegate* delegate,
578 WebContents* web_contents, 583 WebContents* web_contents,
579 Profile* profile); 584 Profile* profile);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 SetMediaMenus(); 638 SetMediaMenus();
634 SetCustomLink(); 639 SetCustomLink();
635 } 640 }
636 641
637 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { 642 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() {
638 // On some platforms (e.g. MacOS X) it is possible to close a tab while the 643 // On some platforms (e.g. MacOS X) it is possible to close a tab while the
639 // media stream bubble is open. This resets the web contents to NULL. 644 // media stream bubble is open. This resets the web contents to NULL.
640 if (!web_contents()) 645 if (!web_contents())
641 return; 646 return;
642 647
643 for (MediaMenuMap::const_iterator it = bubble_content().media_menus.begin(); 648 for (const std::pair<content::MediaStreamType, MediaMenu>& media_menu :
644 it != bubble_content().media_menus.end(); ++it) { 649 bubble_content().media_menus) {
645 if (it->second.selected_device.id != it->second.default_device.id) { 650 if (media_menu.second.selected_device.id !=
646 UpdateDefaultDeviceForType(it->first, it->second.selected_device.id); 651 media_menu.second.default_device.id) {
652 UpdateDefaultDeviceForType(media_menu.first,
653 media_menu.second.selected_device.id);
647 } 654 }
648 } 655 }
649 656
650 // Update the media settings if the radio button selection was changed. 657 // Update the media settings if the radio button selection was changed.
651 if (selected_item_ != bubble_content().radio_group.default_item) { 658 if (selected_item_ != bubble_content().radio_group.default_item) {
652 UpdateSettings(radio_item_setting_[selected_item_]); 659 UpdateSettings(radio_item_setting_[selected_item_]);
653 } 660 }
654 } 661 }
655 662
656 void ContentSettingMediaStreamBubbleModel::SetTitle() { 663 void ContentSettingMediaStreamBubbleModel::SetTitle() {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 // Reset this embedder's entry to default for each of the requesting 952 // Reset this embedder's entry to default for each of the requesting
946 // origins currently on the page. 953 // origins currently on the page.
947 const GURL& embedder_url = web_contents()->GetURL(); 954 const GURL& embedder_url = web_contents()->GetURL();
948 TabSpecificContentSettings* content_settings = 955 TabSpecificContentSettings* content_settings =
949 TabSpecificContentSettings::FromWebContents(web_contents()); 956 TabSpecificContentSettings::FromWebContents(web_contents());
950 const ContentSettingsUsagesState::StateMap& state_map = 957 const ContentSettingsUsagesState::StateMap& state_map =
951 content_settings->geolocation_usages_state().state_map(); 958 content_settings->geolocation_usages_state().state_map();
952 HostContentSettingsMap* settings_map = 959 HostContentSettingsMap* settings_map =
953 profile()->GetHostContentSettingsMap(); 960 profile()->GetHostContentSettingsMap();
954 961
955 for (ContentSettingsUsagesState::StateMap::const_iterator it = 962 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
956 state_map.begin(); it != state_map.end(); ++it) {
957 settings_map->SetContentSetting( 963 settings_map->SetContentSetting(
958 ContentSettingsPattern::FromURLNoWildcard(it->first), 964 ContentSettingsPattern::FromURLNoWildcard(map_entry.first),
959 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 965 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
960 CONTENT_SETTINGS_TYPE_GEOLOCATION, 966 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(),
961 std::string(),
962 CONTENT_SETTING_DEFAULT); 967 CONTENT_SETTING_DEFAULT);
963 } 968 }
964 } 969 }
965 970
966 class ContentSettingMixedScriptBubbleModel 971 class ContentSettingMixedScriptBubbleModel
967 : public ContentSettingTitleLinkAndCustomModel { 972 : public ContentSettingTitleLinkAndCustomModel {
968 public: 973 public:
969 ContentSettingMixedScriptBubbleModel(Delegate* delegate, 974 ContentSettingMixedScriptBubbleModel(Delegate* delegate,
970 WebContents* web_contents, 975 WebContents* web_contents,
971 Profile* profile, 976 Profile* profile);
972 ContentSettingsType content_type);
973 977
974 ~ContentSettingMixedScriptBubbleModel() override {} 978 ~ContentSettingMixedScriptBubbleModel() override {}
975 979
976 private: 980 private:
977 void OnCustomLinkClicked() override; 981 void OnCustomLinkClicked() override;
978 }; 982 };
979 983
980 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel( 984 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel(
981 Delegate* delegate, 985 Delegate* delegate,
982 WebContents* web_contents, 986 WebContents* web_contents,
983 Profile* profile, 987 Profile* profile)
984 ContentSettingsType content_type) 988 : ContentSettingTitleLinkAndCustomModel(delegate,
985 : ContentSettingTitleLinkAndCustomModel( 989 web_contents,
986 delegate, web_contents, profile, content_type) { 990 profile,
987 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); 991 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
988 content_settings::RecordMixedScriptAction( 992 content_settings::RecordMixedScriptAction(
989 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE); 993 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE);
990 set_custom_link_enabled(true); 994 set_custom_link_enabled(true);
991 } 995 }
992 996
993 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() { 997 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() {
994 content_settings::RecordMixedScriptAction( 998 content_settings::RecordMixedScriptAction(
995 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW); 999 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW);
996 DCHECK(web_contents()); 1000 DCHECK(web_contents());
997 web_contents()->SendToAllFrames( 1001 web_contents()->SendToAllFrames(
998 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true)); 1002 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true));
999 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame( 1003 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
1000 web_contents()->GetMainFrame()->GetRoutingID())); 1004 web_contents()->GetMainFrame()->GetRoutingID()));
1001 } 1005 }
1002 1006
1003 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( 1007 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
1004 Delegate* delegate, 1008 Delegate* delegate,
1005 WebContents* web_contents, 1009 WebContents* web_contents,
1006 Profile* profile, 1010 Profile* profile,
1007 ProtocolHandlerRegistry* registry, 1011 ProtocolHandlerRegistry* registry)
1008 ContentSettingsType content_type) 1012 : ContentSettingTitleAndLinkModel(delegate,
1009 : ContentSettingTitleAndLinkModel( 1013 web_contents,
1010 delegate, web_contents, profile, content_type), 1014 profile,
1015 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS),
1011 selected_item_(0), 1016 selected_item_(0),
1012 registry_(registry), 1017 registry_(registry),
1013 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), 1018 pending_handler_(ProtocolHandler::EmptyProtocolHandler()),
1014 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { 1019 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) {
1015 DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type);
1016
1017 TabSpecificContentSettings* content_settings = 1020 TabSpecificContentSettings* content_settings =
1018 TabSpecificContentSettings::FromWebContents(web_contents); 1021 TabSpecificContentSettings::FromWebContents(web_contents);
1019 pending_handler_ = content_settings->pending_protocol_handler(); 1022 pending_handler_ = content_settings->pending_protocol_handler();
1020 previous_handler_ = content_settings->previous_protocol_handler(); 1023 previous_handler_ = content_settings->previous_protocol_handler();
1021 1024
1022 base::string16 protocol; 1025 base::string16 protocol;
1023 if (pending_handler_.protocol() == "mailto") { 1026 if (pending_handler_.protocol() == "mailto") {
1024 protocol = l10n_util::GetStringUTF16( 1027 protocol = l10n_util::GetStringUTF16(
1025 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); 1028 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME);
1026 } else if (pending_handler_.protocol() == "webcal") { 1029 } else if (pending_handler_.protocol() == "webcal") {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 } else { 1132 } else {
1130 registry_->OnAcceptRegisterProtocolHandler(previous_handler_); 1133 registry_->OnAcceptRegisterProtocolHandler(previous_handler_);
1131 } 1134 }
1132 } 1135 }
1133 1136
1134 class ContentSettingMidiSysExBubbleModel 1137 class ContentSettingMidiSysExBubbleModel
1135 : public ContentSettingTitleAndLinkModel { 1138 : public ContentSettingTitleAndLinkModel {
1136 public: 1139 public:
1137 ContentSettingMidiSysExBubbleModel(Delegate* delegate, 1140 ContentSettingMidiSysExBubbleModel(Delegate* delegate,
1138 WebContents* web_contents, 1141 WebContents* web_contents,
1139 Profile* profile, 1142 Profile* profile);
1140 ContentSettingsType content_type);
1141 ~ContentSettingMidiSysExBubbleModel() override {} 1143 ~ContentSettingMidiSysExBubbleModel() override {}
1142 1144
1143 private: 1145 private:
1144 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id); 1146 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id);
1145 void SetDomainsAndCustomLink(); 1147 void SetDomainsAndCustomLink();
1146 void OnCustomLinkClicked() override; 1148 void OnCustomLinkClicked() override;
1147 }; 1149 };
1148 1150
1149 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel( 1151 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel(
1150 Delegate* delegate, 1152 Delegate* delegate,
1151 WebContents* web_contents, 1153 WebContents* web_contents,
1152 Profile* profile, 1154 Profile* profile)
1153 ContentSettingsType content_type) 1155 : ContentSettingTitleAndLinkModel(delegate,
1154 : ContentSettingTitleAndLinkModel( 1156 web_contents,
1155 delegate, web_contents, profile, content_type) { 1157 profile,
1156 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, content_type); 1158 CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1157 SetDomainsAndCustomLink(); 1159 SetDomainsAndCustomLink();
1158 } 1160 }
1159 1161
1160 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList( 1162 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList(
1161 const std::set<std::string>& hosts, int title_id) { 1163 const std::set<std::string>& hosts, int title_id) {
1162 if (!hosts.empty()) { 1164 if (!hosts.empty()) {
1163 DomainList domain_list; 1165 DomainList domain_list;
1164 domain_list.title = l10n_util::GetStringUTF8(title_id); 1166 domain_list.title = l10n_util::GetStringUTF8(title_id);
1165 domain_list.hosts = hosts; 1167 domain_list.hosts = hosts;
1166 add_domain_list(domain_list); 1168 add_domain_list(domain_list);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 // Reset this embedder's entry to default for each of the requesting 1202 // Reset this embedder's entry to default for each of the requesting
1201 // origins currently on the page. 1203 // origins currently on the page.
1202 const GURL& embedder_url = web_contents()->GetURL(); 1204 const GURL& embedder_url = web_contents()->GetURL();
1203 TabSpecificContentSettings* content_settings = 1205 TabSpecificContentSettings* content_settings =
1204 TabSpecificContentSettings::FromWebContents(web_contents()); 1206 TabSpecificContentSettings::FromWebContents(web_contents());
1205 const ContentSettingsUsagesState::StateMap& state_map = 1207 const ContentSettingsUsagesState::StateMap& state_map =
1206 content_settings->midi_usages_state().state_map(); 1208 content_settings->midi_usages_state().state_map();
1207 HostContentSettingsMap* settings_map = 1209 HostContentSettingsMap* settings_map =
1208 profile()->GetHostContentSettingsMap(); 1210 profile()->GetHostContentSettingsMap();
1209 1211
1210 for (ContentSettingsUsagesState::StateMap::const_iterator it = 1212 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1211 state_map.begin(); it != state_map.end(); ++it) {
1212 settings_map->SetContentSetting( 1213 settings_map->SetContentSetting(
1213 ContentSettingsPattern::FromURLNoWildcard(it->first), 1214 ContentSettingsPattern::FromURLNoWildcard(map_entry.first),
1214 ContentSettingsPattern::FromURLNoWildcard(embedder_url), 1215 ContentSettingsPattern::FromURLNoWildcard(embedder_url),
1215 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 1216 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(),
1216 std::string(),
1217 CONTENT_SETTING_DEFAULT); 1217 CONTENT_SETTING_DEFAULT);
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 // static 1221 // static
1222 ContentSettingBubbleModel* 1222 ContentSettingBubbleModel*
1223 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1223 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1224 Delegate* delegate, 1224 Delegate* delegate,
1225 WebContents* web_contents, 1225 WebContents* web_contents,
1226 Profile* profile, 1226 Profile* profile,
1227 ContentSettingsType content_type) { 1227 ContentSettingsType content_type) {
1228 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 1228 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
1229 return new ContentSettingCookiesBubbleModel(delegate, web_contents, profile, 1229 return new ContentSettingCookiesBubbleModel(delegate, web_contents,
1230 content_type); 1230 profile);
1231 } 1231 }
1232 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { 1232 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) {
1233 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile, 1233 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile);
1234 content_type);
1235 } 1234 }
1236 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 1235 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
1237 return new ContentSettingDomainListBubbleModel(delegate, web_contents, 1236 return new ContentSettingDomainListBubbleModel(delegate, web_contents,
1238 profile, content_type); 1237 profile, content_type);
1239 } 1238 }
1240 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 1239 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
1241 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, 1240 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents,
1242 profile); 1241 profile);
1243 } 1242 }
1244 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { 1243 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) {
1245 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, 1244 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile);
1246 content_type);
1247 } 1245 }
1248 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { 1246 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
1249 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, 1247 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents,
1250 profile, content_type); 1248 profile);
1251 } 1249 }
1252 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { 1250 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
1253 ProtocolHandlerRegistry* registry = 1251 ProtocolHandlerRegistry* registry =
1254 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); 1252 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
1255 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, 1253 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile,
1256 registry, content_type); 1254 registry);
1257 } 1255 }
1258 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 1256 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1259 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, 1257 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents,
1260 profile, content_type); 1258 profile);
1261 } 1259 }
1262 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, 1260 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile,
1263 content_type); 1261 content_type);
1264 } 1262 }
1265 1263
1266 ContentSettingBubbleModel::ContentSettingBubbleModel( 1264 ContentSettingBubbleModel::ContentSettingBubbleModel(
1267 WebContents* web_contents, 1265 WebContents* web_contents,
1268 Profile* profile, 1266 Profile* profile,
1269 ContentSettingsType content_type) 1267 ContentSettingsType content_type)
1270 : web_contents_(web_contents), 1268 : web_contents_(web_contents),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1304 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1307 DCHECK_EQ(web_contents_, 1305 DCHECK_EQ(web_contents_,
1308 content::Source<WebContents>(source).ptr()); 1306 content::Source<WebContents>(source).ptr());
1309 web_contents_ = NULL; 1307 web_contents_ = NULL;
1310 } else { 1308 } else {
1311 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1309 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1312 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1310 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1313 profile_ = NULL; 1311 profile_ = NULL;
1314 } 1312 }
1315 } 1313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698