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

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: msw comments 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 SetLearnMoreLink(); 108 SetLearnMoreLink();
108 } 109 }
109 110
110 void ContentSettingTitleAndLinkModel::SetTitle() { 111 void ContentSettingTitleAndLinkModel::SetTitle() {
111 TabSpecificContentSettings* content_settings = NULL; 112 TabSpecificContentSettings* content_settings = NULL;
112 if (web_contents()) { 113 if (web_contents()) {
113 content_settings = 114 content_settings =
114 TabSpecificContentSettings::FromWebContents(web_contents()); 115 TabSpecificContentSettings::FromWebContents(web_contents());
115 } 116 }
116 117
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[] = { 118 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = {
123 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, 119 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE},
124 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, 120 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE},
125 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, 121 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE},
126 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, 122 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE},
127 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, 123 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE},
128 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 124 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
129 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, 125 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT},
130 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 126 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
131 IDS_BLOCKED_PPAPI_BROKER_TITLE}, 127 IDS_BLOCKED_PPAPI_BROKER_TITLE},
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 414 }
419 415
420 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) { 416 void ContentSettingSingleRadioGroup::OnRadioClicked(int radio_index) {
421 selected_item_ = radio_index; 417 selected_item_ = radio_index;
422 } 418 }
423 419
424 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { 420 class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
425 public: 421 public:
426 ContentSettingCookiesBubbleModel(Delegate* delegate, 422 ContentSettingCookiesBubbleModel(Delegate* delegate,
427 WebContents* web_contents, 423 WebContents* web_contents,
428 Profile* profile, 424 Profile* profile);
429 ContentSettingsType content_type);
430 425
431 ~ContentSettingCookiesBubbleModel() override; 426 ~ContentSettingCookiesBubbleModel() override;
432 427
433 private: 428 private:
434 void OnCustomLinkClicked() override; 429 void OnCustomLinkClicked() override;
435 }; 430 };
436 431
437 ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel( 432 ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel(
438 Delegate* delegate, 433 Delegate* delegate,
439 WebContents* web_contents, 434 WebContents* web_contents,
440 Profile* profile, 435 Profile* profile)
441 ContentSettingsType content_type) 436 : ContentSettingSingleRadioGroup(delegate,
msw 2015/03/21 00:25:19 nit: un-wrap "delegate, web_contents, profile," he
meacer 2015/03/23 18:19:40 Did you mean the formatting? This is the |git cl f
442 : ContentSettingSingleRadioGroup( 437 web_contents,
443 delegate, web_contents, profile, content_type) { 438 profile,
444 DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type); 439 CONTENT_SETTINGS_TYPE_COOKIES) {
445 set_custom_link_enabled(true); 440 set_custom_link_enabled(true);
446 } 441 }
447 442
448 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() { 443 ContentSettingCookiesBubbleModel::~ContentSettingCookiesBubbleModel() {
449 // On some plattforms e.g. MacOS X it is possible to close a tab while the 444 // 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. 445 // cookies settings bubble is open. This resets the web contents to NULL.
451 if (settings_changed() && web_contents()) { 446 if (settings_changed() && web_contents()) {
452 CollectedCookiesInfoBarDelegate::Create( 447 CollectedCookiesInfoBarDelegate::Create(
453 InfoBarService::FromWebContents(web_contents())); 448 InfoBarService::FromWebContents(web_contents()));
454 } 449 }
455 } 450 }
456 451
457 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() { 452 void ContentSettingCookiesBubbleModel::OnCustomLinkClicked() {
458 if (!web_contents()) 453 if (!web_contents())
459 return; 454 return;
460 content::NotificationService::current()->Notify( 455 content::NotificationService::current()->Notify(
461 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 456 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
462 content::Source<TabSpecificContentSettings>( 457 content::Source<TabSpecificContentSettings>(
463 TabSpecificContentSettings::FromWebContents(web_contents())), 458 TabSpecificContentSettings::FromWebContents(web_contents())),
464 content::NotificationService::NoDetails()); 459 content::NotificationService::NoDetails());
465 delegate()->ShowCollectedCookiesDialog(web_contents()); 460 delegate()->ShowCollectedCookiesDialog(web_contents());
466 } 461 }
467 462
468 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { 463 class PluginBubbleModel : public ContentSettingSingleRadioGroup {
469 public: 464 public:
470 ContentSettingPluginBubbleModel(Delegate* delegate, 465 PluginBubbleModel(Delegate* delegate,
471 WebContents* web_contents, 466 WebContents* web_contents,
472 Profile* profile, 467 Profile* profile);
473 ContentSettingsType content_type);
474 468
475 ~ContentSettingPluginBubbleModel() override; 469 ~PluginBubbleModel() override;
476 470
477 private: 471 private:
478 void OnCustomLinkClicked() override; 472 void OnCustomLinkClicked() override;
473
474 void SetListItems();
479 }; 475 };
480 476
481 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel( 477 PluginBubbleModel::PluginBubbleModel(Delegate* delegate,
482 Delegate* delegate, 478 WebContents* web_contents,
483 WebContents* web_contents, 479 Profile* profile)
484 Profile* profile, 480 : ContentSettingSingleRadioGroup(delegate,
485 ContentSettingsType content_type) 481 web_contents,
486 : ContentSettingSingleRadioGroup( 482 profile,
487 delegate, web_contents, profile, content_type) { 483 CONTENT_SETTINGS_TYPE_PLUGINS) {
488 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS);
489 // Disable the "Run all plugins this time" link if the setting is managed and 484 // 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 485 // can't be controlled by the user or if the user already clicked on the link
491 // and ran all plugins. 486 // and ran all plugins.
492 set_custom_link_enabled(!setting_is_managed() && 487 set_custom_link_enabled(!setting_is_managed() &&
493 web_contents && 488 web_contents &&
494 TabSpecificContentSettings::FromWebContents( 489 TabSpecificContentSettings::FromWebContents(
495 web_contents)->load_plugins_link_enabled()); 490 web_contents)->load_plugins_link_enabled());
491 SetListItems();
msw 2015/03/21 00:25:19 nit: inline this?
meacer 2015/03/23 18:19:40 Done.
496 } 492 }
497 493
498 ContentSettingPluginBubbleModel::~ContentSettingPluginBubbleModel() { 494 PluginBubbleModel::~PluginBubbleModel() {
499 if (settings_changed()) { 495 if (settings_changed()) {
500 // If the user elected to allow all plugins then run plugins at this time. 496 // If the user elected to allow all plugins then run plugins at this time.
501 if (selected_item() == kAllowButtonIndex) 497 if (selected_item() == kAllowButtonIndex)
502 OnCustomLinkClicked(); 498 OnCustomLinkClicked();
503 } 499 }
504 } 500 }
505 501
506 void ContentSettingPluginBubbleModel::OnCustomLinkClicked() { 502 void PluginBubbleModel::SetListItems() {
503 if (!web_contents())
504 return;
505 TabSpecificContentSettings* content_settings =
506 TabSpecificContentSettings::FromWebContents(web_contents());
507
508 const std::vector<base::string16>& blocked_plugins =
509 content_settings->blocked_plugin_names();
510 for (auto iter = blocked_plugins.begin(); iter != blocked_plugins.end();
511 ++iter) {
512 // TODO(meacer): Link to chrome://plugins#plugin_id from here.
513 ListItem plugin_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
514 IDR_BLOCKED_PLUGINS),
515 base::UTF16ToUTF8(*iter), false, 0);
516 add_list_item(plugin_item);
517 }
518 }
519
520 void PluginBubbleModel::OnCustomLinkClicked() {
507 content::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble")); 521 content::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble"));
508 // Web contents can be NULL if the tab was closed while the plugins 522 // Web contents can be NULL if the tab was closed while the plugins
509 // settings bubble is visible. 523 // settings bubble is visible.
510 if (!web_contents()) 524 if (!web_contents())
511 return; 525 return;
512 #if defined(ENABLE_PLUGINS) 526 #if defined(ENABLE_PLUGINS)
513 // TODO(bauerb): We should send the identifiers of blocked plugins here. 527 // TODO(bauerb): We should send the identifiers of blocked plugins here.
514 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( 528 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
515 web_contents(), true, std::string()); 529 web_contents(), true, std::string());
516 #endif 530 #endif
517 set_custom_link_enabled(false); 531 set_custom_link_enabled(false);
518 TabSpecificContentSettings::FromWebContents(web_contents())-> 532 TabSpecificContentSettings::FromWebContents(web_contents())->
519 set_load_plugins_link_enabled(false); 533 set_load_plugins_link_enabled(false);
520 } 534 }
521 535
522 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { 536 class PopupBubbleModel : public ContentSettingSingleRadioGroup {
523 public: 537 public:
524 ContentSettingPopupBubbleModel(Delegate* delegate, 538 PopupBubbleModel(Delegate* delegate,
525 WebContents* web_contents, 539 WebContents* web_contents,
526 Profile* profile, 540 Profile* profile);
527 ContentSettingsType content_type); 541 ~PopupBubbleModel() override {}
528 ~ContentSettingPopupBubbleModel() override {}
529 542
530 private: 543 private:
531 void SetPopups(); 544 void OnListItemClicked(int index) override;
532 void OnPopupClicked(int index) override; 545
546 void SetListItems();
547
548 int32 item_id_from_item_index(int index) const {
549 return bubble_content().list_items[index].item_id;
550 }
533 }; 551 };
534 552
535 ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel( 553 PopupBubbleModel::PopupBubbleModel(Delegate* delegate,
536 Delegate* delegate, 554 WebContents* web_contents,
537 WebContents* web_contents, 555 Profile* profile)
538 Profile* profile, 556 : ContentSettingSingleRadioGroup(delegate,
539 ContentSettingsType content_type) 557 web_contents,
540 : ContentSettingSingleRadioGroup( 558 profile,
541 delegate, web_contents, profile, content_type) { 559 CONTENT_SETTINGS_TYPE_POPUPS) {
542 SetPopups(); 560 SetListItems();
543 } 561 }
544 562
545 563 void PopupBubbleModel::SetListItems() {
msw 2015/03/21 00:25:19 ditto nit: inline this?
meacer 2015/03/23 18:19:40 Done.
546 void ContentSettingPopupBubbleModel::SetPopups() {
547 std::map<int32, GURL> blocked_popups = 564 std::map<int32, GURL> blocked_popups =
548 PopupBlockerTabHelper::FromWebContents(web_contents()) 565 PopupBlockerTabHelper::FromWebContents(web_contents())
549 ->GetBlockedPopupRequests(); 566 ->GetBlockedPopupRequests();
550 for (std::map<int32, GURL>::const_iterator iter = blocked_popups.begin(); 567 for (auto iter = blocked_popups.begin(); iter != blocked_popups.end();
551 iter != blocked_popups.end();
552 ++iter) { 568 ++iter) {
553 std::string title(iter->second.spec()); 569 std::string title(iter->second.spec());
554 // The popup may not have a valid URL. 570 // The popup may not have a valid URL.
555 if (title.empty()) 571 if (title.empty())
556 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); 572 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE);
557 PopupItem popup_item( 573 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
558 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 574 IDR_DEFAULT_FAVICON),
559 IDR_DEFAULT_FAVICON), 575 title, true, iter->first);
560 title, 576 add_list_item(popup_item);
561 iter->first);
562 add_popup(popup_item);
563 } 577 }
564 } 578 }
565 579
566 void ContentSettingPopupBubbleModel::OnPopupClicked(int index) { 580 void PopupBubbleModel::OnListItemClicked(int index) {
567 if (web_contents()) { 581 if (web_contents()) {
568 PopupBlockerTabHelper::FromWebContents(web_contents())-> 582 PopupBlockerTabHelper::FromWebContents(web_contents())
569 ShowBlockedPopup(bubble_content().popup_items[index].popup_id); 583 ->ShowBlockedPopup(item_id_from_item_index(index));
570 } 584 }
571 } 585 }
572 586
573 // The model of the content settings bubble for media settings. 587 // The model of the content settings bubble for media settings.
574 class ContentSettingMediaStreamBubbleModel 588 class ContentSettingMediaStreamBubbleModel
575 : public ContentSettingTitleAndLinkModel { 589 : public ContentSettingTitleAndLinkModel {
576 public: 590 public:
577 ContentSettingMediaStreamBubbleModel(Delegate* delegate, 591 ContentSettingMediaStreamBubbleModel(Delegate* delegate,
578 WebContents* web_contents, 592 WebContents* web_contents,
579 Profile* profile); 593 Profile* profile);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 std::string(), 975 std::string(),
962 CONTENT_SETTING_DEFAULT); 976 CONTENT_SETTING_DEFAULT);
963 } 977 }
964 } 978 }
965 979
966 class ContentSettingMixedScriptBubbleModel 980 class ContentSettingMixedScriptBubbleModel
967 : public ContentSettingTitleLinkAndCustomModel { 981 : public ContentSettingTitleLinkAndCustomModel {
968 public: 982 public:
969 ContentSettingMixedScriptBubbleModel(Delegate* delegate, 983 ContentSettingMixedScriptBubbleModel(Delegate* delegate,
970 WebContents* web_contents, 984 WebContents* web_contents,
971 Profile* profile, 985 Profile* profile);
972 ContentSettingsType content_type);
973 986
974 ~ContentSettingMixedScriptBubbleModel() override {} 987 ~ContentSettingMixedScriptBubbleModel() override {}
975 988
976 private: 989 private:
977 void OnCustomLinkClicked() override; 990 void OnCustomLinkClicked() override;
978 }; 991 };
979 992
980 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel( 993 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel(
981 Delegate* delegate, 994 Delegate* delegate,
982 WebContents* web_contents, 995 WebContents* web_contents,
983 Profile* profile, 996 Profile* profile)
984 ContentSettingsType content_type) 997 : ContentSettingTitleLinkAndCustomModel(delegate,
985 : ContentSettingTitleLinkAndCustomModel( 998 web_contents,
986 delegate, web_contents, profile, content_type) { 999 profile,
987 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); 1000 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
988 content_settings::RecordMixedScriptAction( 1001 content_settings::RecordMixedScriptAction(
989 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE); 1002 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE);
990 set_custom_link_enabled(true); 1003 set_custom_link_enabled(true);
991 } 1004 }
992 1005
993 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() { 1006 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() {
994 content_settings::RecordMixedScriptAction( 1007 content_settings::RecordMixedScriptAction(
995 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW); 1008 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW);
996 DCHECK(web_contents()); 1009 DCHECK(web_contents());
997 web_contents()->SendToAllFrames( 1010 web_contents()->SendToAllFrames(
998 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true)); 1011 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true));
999 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame( 1012 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
1000 web_contents()->GetMainFrame()->GetRoutingID())); 1013 web_contents()->GetMainFrame()->GetRoutingID()));
1001 } 1014 }
1002 1015
1003 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( 1016 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
1004 Delegate* delegate, 1017 Delegate* delegate,
1005 WebContents* web_contents, 1018 WebContents* web_contents,
1006 Profile* profile, 1019 Profile* profile,
1007 ProtocolHandlerRegistry* registry, 1020 ProtocolHandlerRegistry* registry)
1008 ContentSettingsType content_type) 1021 : ContentSettingTitleAndLinkModel(delegate,
1009 : ContentSettingTitleAndLinkModel( 1022 web_contents,
1010 delegate, web_contents, profile, content_type), 1023 profile,
1024 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS),
1011 selected_item_(0), 1025 selected_item_(0),
1012 registry_(registry), 1026 registry_(registry),
1013 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), 1027 pending_handler_(ProtocolHandler::EmptyProtocolHandler()),
1014 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { 1028 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) {
1015 DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type);
1016
1017 TabSpecificContentSettings* content_settings = 1029 TabSpecificContentSettings* content_settings =
1018 TabSpecificContentSettings::FromWebContents(web_contents); 1030 TabSpecificContentSettings::FromWebContents(web_contents);
1019 pending_handler_ = content_settings->pending_protocol_handler(); 1031 pending_handler_ = content_settings->pending_protocol_handler();
1020 previous_handler_ = content_settings->previous_protocol_handler(); 1032 previous_handler_ = content_settings->previous_protocol_handler();
1021 1033
1022 base::string16 protocol; 1034 base::string16 protocol;
1023 if (pending_handler_.protocol() == "mailto") { 1035 if (pending_handler_.protocol() == "mailto") {
1024 protocol = l10n_util::GetStringUTF16( 1036 protocol = l10n_util::GetStringUTF16(
1025 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); 1037 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME);
1026 } else if (pending_handler_.protocol() == "webcal") { 1038 } else if (pending_handler_.protocol() == "webcal") {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 } else { 1141 } else {
1130 registry_->OnAcceptRegisterProtocolHandler(previous_handler_); 1142 registry_->OnAcceptRegisterProtocolHandler(previous_handler_);
1131 } 1143 }
1132 } 1144 }
1133 1145
1134 class ContentSettingMidiSysExBubbleModel 1146 class ContentSettingMidiSysExBubbleModel
1135 : public ContentSettingTitleAndLinkModel { 1147 : public ContentSettingTitleAndLinkModel {
1136 public: 1148 public:
1137 ContentSettingMidiSysExBubbleModel(Delegate* delegate, 1149 ContentSettingMidiSysExBubbleModel(Delegate* delegate,
1138 WebContents* web_contents, 1150 WebContents* web_contents,
1139 Profile* profile, 1151 Profile* profile);
1140 ContentSettingsType content_type);
1141 ~ContentSettingMidiSysExBubbleModel() override {} 1152 ~ContentSettingMidiSysExBubbleModel() override {}
1142 1153
1143 private: 1154 private:
1144 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id); 1155 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id);
1145 void SetDomainsAndCustomLink(); 1156 void SetDomainsAndCustomLink();
1146 void OnCustomLinkClicked() override; 1157 void OnCustomLinkClicked() override;
1147 }; 1158 };
1148 1159
1149 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel( 1160 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel(
1150 Delegate* delegate, 1161 Delegate* delegate,
1151 WebContents* web_contents, 1162 WebContents* web_contents,
1152 Profile* profile, 1163 Profile* profile)
1153 ContentSettingsType content_type) 1164 : ContentSettingTitleAndLinkModel(delegate,
1154 : ContentSettingTitleAndLinkModel( 1165 web_contents,
1155 delegate, web_contents, profile, content_type) { 1166 profile,
1156 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, content_type); 1167 CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1157 SetDomainsAndCustomLink(); 1168 SetDomainsAndCustomLink();
1158 } 1169 }
1159 1170
1160 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList( 1171 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList(
1161 const std::set<std::string>& hosts, int title_id) { 1172 const std::set<std::string>& hosts, int title_id) {
1162 if (!hosts.empty()) { 1173 if (!hosts.empty()) {
1163 DomainList domain_list; 1174 DomainList domain_list;
1164 domain_list.title = l10n_util::GetStringUTF8(title_id); 1175 domain_list.title = l10n_util::GetStringUTF8(title_id);
1165 domain_list.hosts = hosts; 1176 domain_list.hosts = hosts;
1166 add_domain_list(domain_list); 1177 add_domain_list(domain_list);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } 1230 }
1220 1231
1221 // static 1232 // static
1222 ContentSettingBubbleModel* 1233 ContentSettingBubbleModel*
1223 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1234 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1224 Delegate* delegate, 1235 Delegate* delegate,
1225 WebContents* web_contents, 1236 WebContents* web_contents,
1226 Profile* profile, 1237 Profile* profile,
1227 ContentSettingsType content_type) { 1238 ContentSettingsType content_type) {
1228 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { 1239 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) {
1229 return new ContentSettingCookiesBubbleModel(delegate, web_contents, profile, 1240 return new ContentSettingCookiesBubbleModel(delegate, web_contents,
1230 content_type); 1241 profile);
1231 } 1242 }
1232 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { 1243 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) {
1233 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile, 1244 return new PopupBubbleModel(delegate, web_contents, profile);
1234 content_type);
1235 } 1245 }
1236 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 1246 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
1237 return new ContentSettingDomainListBubbleModel(delegate, web_contents, 1247 return new ContentSettingDomainListBubbleModel(delegate, web_contents,
1238 profile, content_type); 1248 profile, content_type);
1239 } 1249 }
1240 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { 1250 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
1241 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, 1251 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents,
1242 profile); 1252 profile);
1243 } 1253 }
1244 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { 1254 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) {
1245 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, 1255 return new PluginBubbleModel(delegate, web_contents, profile);
1246 content_type);
1247 } 1256 }
1248 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { 1257 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) {
1249 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, 1258 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents,
1250 profile, content_type); 1259 profile);
1251 } 1260 }
1252 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { 1261 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
1253 ProtocolHandlerRegistry* registry = 1262 ProtocolHandlerRegistry* registry =
1254 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); 1263 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
1255 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, 1264 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile,
1256 registry, content_type); 1265 registry);
1257 } 1266 }
1258 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { 1267 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
1259 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, 1268 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents,
1260 profile, content_type); 1269 profile);
1261 } 1270 }
1262 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, 1271 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile,
1263 content_type); 1272 content_type);
1264 } 1273 }
1265 1274
1266 ContentSettingBubbleModel::ContentSettingBubbleModel( 1275 ContentSettingBubbleModel::ContentSettingBubbleModel(
1267 WebContents* web_contents, 1276 WebContents* web_contents,
1268 Profile* profile, 1277 Profile* profile,
1269 ContentSettingsType content_type) 1278 ContentSettingsType content_type)
1270 : web_contents_(web_contents), 1279 : web_contents_(web_contents),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { 1315 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
1307 DCHECK_EQ(web_contents_, 1316 DCHECK_EQ(web_contents_,
1308 content::Source<WebContents>(source).ptr()); 1317 content::Source<WebContents>(source).ptr());
1309 web_contents_ = NULL; 1318 web_contents_ = NULL;
1310 } else { 1319 } else {
1311 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); 1320 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
1312 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); 1321 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
1313 profile_ = NULL; 1322 profile_ = NULL;
1314 } 1323 }
1315 } 1324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698