| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 auto& 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 Loading... |
| 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 Loading... |
| 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 auto& 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 Loading... |
| 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 auto& 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 Loading... |
| 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 auto& media_menu : bubble_content().media_menus) { |
| 644 it != bubble_content().media_menus.end(); ++it) { | 649 if (media_menu.second.selected_device.id != |
| 645 if (it->second.selected_device.id != it->second.default_device.id) { | 650 media_menu.second.default_device.id) { |
| 646 UpdateDefaultDeviceForType(it->first, it->second.selected_device.id); | 651 UpdateDefaultDeviceForType(media_menu.first, |
| 652 media_menu.second.selected_device.id); |
| 647 } | 653 } |
| 648 } | 654 } |
| 649 | 655 |
| 650 // Update the media settings if the radio button selection was changed. | 656 // Update the media settings if the radio button selection was changed. |
| 651 if (selected_item_ != bubble_content().radio_group.default_item) { | 657 if (selected_item_ != bubble_content().radio_group.default_item) { |
| 652 UpdateSettings(radio_item_setting_[selected_item_]); | 658 UpdateSettings(radio_item_setting_[selected_item_]); |
| 653 } | 659 } |
| 654 } | 660 } |
| 655 | 661 |
| 656 void ContentSettingMediaStreamBubbleModel::SetTitle() { | 662 void ContentSettingMediaStreamBubbleModel::SetTitle() { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 // Reset this embedder's entry to default for each of the requesting | 951 // Reset this embedder's entry to default for each of the requesting |
| 946 // origins currently on the page. | 952 // origins currently on the page. |
| 947 const GURL& embedder_url = web_contents()->GetURL(); | 953 const GURL& embedder_url = web_contents()->GetURL(); |
| 948 TabSpecificContentSettings* content_settings = | 954 TabSpecificContentSettings* content_settings = |
| 949 TabSpecificContentSettings::FromWebContents(web_contents()); | 955 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 950 const ContentSettingsUsagesState::StateMap& state_map = | 956 const ContentSettingsUsagesState::StateMap& state_map = |
| 951 content_settings->geolocation_usages_state().state_map(); | 957 content_settings->geolocation_usages_state().state_map(); |
| 952 HostContentSettingsMap* settings_map = | 958 HostContentSettingsMap* settings_map = |
| 953 profile()->GetHostContentSettingsMap(); | 959 profile()->GetHostContentSettingsMap(); |
| 954 | 960 |
| 955 for (ContentSettingsUsagesState::StateMap::const_iterator it = | 961 for (const auto& map_entry : state_map) { |
| 956 state_map.begin(); it != state_map.end(); ++it) { | |
| 957 settings_map->SetContentSetting( | 962 settings_map->SetContentSetting( |
| 958 ContentSettingsPattern::FromURLNoWildcard(it->first), | 963 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), |
| 959 ContentSettingsPattern::FromURLNoWildcard(embedder_url), | 964 ContentSettingsPattern::FromURLNoWildcard(embedder_url), |
| 960 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 965 CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string(), |
| 961 std::string(), | |
| 962 CONTENT_SETTING_DEFAULT); | 966 CONTENT_SETTING_DEFAULT); |
| 963 } | 967 } |
| 964 } | 968 } |
| 965 | 969 |
| 966 class ContentSettingMixedScriptBubbleModel | 970 class ContentSettingMixedScriptBubbleModel |
| 967 : public ContentSettingTitleLinkAndCustomModel { | 971 : public ContentSettingTitleLinkAndCustomModel { |
| 968 public: | 972 public: |
| 969 ContentSettingMixedScriptBubbleModel(Delegate* delegate, | 973 ContentSettingMixedScriptBubbleModel(Delegate* delegate, |
| 970 WebContents* web_contents, | 974 WebContents* web_contents, |
| 971 Profile* profile, | 975 Profile* profile); |
| 972 ContentSettingsType content_type); | |
| 973 | 976 |
| 974 ~ContentSettingMixedScriptBubbleModel() override {} | 977 ~ContentSettingMixedScriptBubbleModel() override {} |
| 975 | 978 |
| 976 private: | 979 private: |
| 977 void OnCustomLinkClicked() override; | 980 void OnCustomLinkClicked() override; |
| 978 }; | 981 }; |
| 979 | 982 |
| 980 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel( | 983 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel( |
| 981 Delegate* delegate, | 984 Delegate* delegate, |
| 982 WebContents* web_contents, | 985 WebContents* web_contents, |
| 983 Profile* profile, | 986 Profile* profile) |
| 984 ContentSettingsType content_type) | 987 : ContentSettingTitleLinkAndCustomModel(delegate, |
| 985 : ContentSettingTitleLinkAndCustomModel( | 988 web_contents, |
| 986 delegate, web_contents, profile, content_type) { | 989 profile, |
| 987 DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_MIXEDSCRIPT); | 990 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { |
| 988 content_settings::RecordMixedScriptAction( | 991 content_settings::RecordMixedScriptAction( |
| 989 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE); | 992 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE); |
| 990 set_custom_link_enabled(true); | 993 set_custom_link_enabled(true); |
| 991 } | 994 } |
| 992 | 995 |
| 993 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() { | 996 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() { |
| 994 content_settings::RecordMixedScriptAction( | 997 content_settings::RecordMixedScriptAction( |
| 995 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW); | 998 content_settings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW); |
| 996 DCHECK(web_contents()); | 999 DCHECK(web_contents()); |
| 997 web_contents()->SendToAllFrames( | 1000 web_contents()->SendToAllFrames( |
| 998 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true)); | 1001 new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true)); |
| 999 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame( | 1002 web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame( |
| 1000 web_contents()->GetMainFrame()->GetRoutingID())); | 1003 web_contents()->GetMainFrame()->GetRoutingID())); |
| 1001 } | 1004 } |
| 1002 | 1005 |
| 1003 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( | 1006 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( |
| 1004 Delegate* delegate, | 1007 Delegate* delegate, |
| 1005 WebContents* web_contents, | 1008 WebContents* web_contents, |
| 1006 Profile* profile, | 1009 Profile* profile, |
| 1007 ProtocolHandlerRegistry* registry, | 1010 ProtocolHandlerRegistry* registry) |
| 1008 ContentSettingsType content_type) | 1011 : ContentSettingTitleAndLinkModel(delegate, |
| 1009 : ContentSettingTitleAndLinkModel( | 1012 web_contents, |
| 1010 delegate, web_contents, profile, content_type), | 1013 profile, |
| 1014 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS), |
| 1011 selected_item_(0), | 1015 selected_item_(0), |
| 1012 registry_(registry), | 1016 registry_(registry), |
| 1013 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), | 1017 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 1014 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { | 1018 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { |
| 1015 DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type); | |
| 1016 | |
| 1017 TabSpecificContentSettings* content_settings = | 1019 TabSpecificContentSettings* content_settings = |
| 1018 TabSpecificContentSettings::FromWebContents(web_contents); | 1020 TabSpecificContentSettings::FromWebContents(web_contents); |
| 1019 pending_handler_ = content_settings->pending_protocol_handler(); | 1021 pending_handler_ = content_settings->pending_protocol_handler(); |
| 1020 previous_handler_ = content_settings->previous_protocol_handler(); | 1022 previous_handler_ = content_settings->previous_protocol_handler(); |
| 1021 | 1023 |
| 1022 base::string16 protocol; | 1024 base::string16 protocol; |
| 1023 if (pending_handler_.protocol() == "mailto") { | 1025 if (pending_handler_.protocol() == "mailto") { |
| 1024 protocol = l10n_util::GetStringUTF16( | 1026 protocol = l10n_util::GetStringUTF16( |
| 1025 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); | 1027 IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); |
| 1026 } else if (pending_handler_.protocol() == "webcal") { | 1028 } else if (pending_handler_.protocol() == "webcal") { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 } else { | 1131 } else { |
| 1130 registry_->OnAcceptRegisterProtocolHandler(previous_handler_); | 1132 registry_->OnAcceptRegisterProtocolHandler(previous_handler_); |
| 1131 } | 1133 } |
| 1132 } | 1134 } |
| 1133 | 1135 |
| 1134 class ContentSettingMidiSysExBubbleModel | 1136 class ContentSettingMidiSysExBubbleModel |
| 1135 : public ContentSettingTitleAndLinkModel { | 1137 : public ContentSettingTitleAndLinkModel { |
| 1136 public: | 1138 public: |
| 1137 ContentSettingMidiSysExBubbleModel(Delegate* delegate, | 1139 ContentSettingMidiSysExBubbleModel(Delegate* delegate, |
| 1138 WebContents* web_contents, | 1140 WebContents* web_contents, |
| 1139 Profile* profile, | 1141 Profile* profile); |
| 1140 ContentSettingsType content_type); | |
| 1141 ~ContentSettingMidiSysExBubbleModel() override {} | 1142 ~ContentSettingMidiSysExBubbleModel() override {} |
| 1142 | 1143 |
| 1143 private: | 1144 private: |
| 1144 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id); | 1145 void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id); |
| 1145 void SetDomainsAndCustomLink(); | 1146 void SetDomainsAndCustomLink(); |
| 1146 void OnCustomLinkClicked() override; | 1147 void OnCustomLinkClicked() override; |
| 1147 }; | 1148 }; |
| 1148 | 1149 |
| 1149 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel( | 1150 ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel( |
| 1150 Delegate* delegate, | 1151 Delegate* delegate, |
| 1151 WebContents* web_contents, | 1152 WebContents* web_contents, |
| 1152 Profile* profile, | 1153 Profile* profile) |
| 1153 ContentSettingsType content_type) | 1154 : ContentSettingTitleAndLinkModel(delegate, |
| 1154 : ContentSettingTitleAndLinkModel( | 1155 web_contents, |
| 1155 delegate, web_contents, profile, content_type) { | 1156 profile, |
| 1156 DCHECK_EQ(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, content_type); | 1157 CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 1157 SetDomainsAndCustomLink(); | 1158 SetDomainsAndCustomLink(); |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList( | 1161 void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList( |
| 1161 const std::set<std::string>& hosts, int title_id) { | 1162 const std::set<std::string>& hosts, int title_id) { |
| 1162 if (!hosts.empty()) { | 1163 if (!hosts.empty()) { |
| 1163 DomainList domain_list; | 1164 DomainList domain_list; |
| 1164 domain_list.title = l10n_util::GetStringUTF8(title_id); | 1165 domain_list.title = l10n_util::GetStringUTF8(title_id); |
| 1165 domain_list.hosts = hosts; | 1166 domain_list.hosts = hosts; |
| 1166 add_domain_list(domain_list); | 1167 add_domain_list(domain_list); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 // Reset this embedder's entry to default for each of the requesting | 1201 // Reset this embedder's entry to default for each of the requesting |
| 1201 // origins currently on the page. | 1202 // origins currently on the page. |
| 1202 const GURL& embedder_url = web_contents()->GetURL(); | 1203 const GURL& embedder_url = web_contents()->GetURL(); |
| 1203 TabSpecificContentSettings* content_settings = | 1204 TabSpecificContentSettings* content_settings = |
| 1204 TabSpecificContentSettings::FromWebContents(web_contents()); | 1205 TabSpecificContentSettings::FromWebContents(web_contents()); |
| 1205 const ContentSettingsUsagesState::StateMap& state_map = | 1206 const ContentSettingsUsagesState::StateMap& state_map = |
| 1206 content_settings->midi_usages_state().state_map(); | 1207 content_settings->midi_usages_state().state_map(); |
| 1207 HostContentSettingsMap* settings_map = | 1208 HostContentSettingsMap* settings_map = |
| 1208 profile()->GetHostContentSettingsMap(); | 1209 profile()->GetHostContentSettingsMap(); |
| 1209 | 1210 |
| 1210 for (ContentSettingsUsagesState::StateMap::const_iterator it = | 1211 for (const auto& map_entry : state_map) { |
| 1211 state_map.begin(); it != state_map.end(); ++it) { | |
| 1212 settings_map->SetContentSetting( | 1212 settings_map->SetContentSetting( |
| 1213 ContentSettingsPattern::FromURLNoWildcard(it->first), | 1213 ContentSettingsPattern::FromURLNoWildcard(map_entry.first), |
| 1214 ContentSettingsPattern::FromURLNoWildcard(embedder_url), | 1214 ContentSettingsPattern::FromURLNoWildcard(embedder_url), |
| 1215 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, | 1215 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), |
| 1216 std::string(), | |
| 1217 CONTENT_SETTING_DEFAULT); | 1216 CONTENT_SETTING_DEFAULT); |
| 1218 } | 1217 } |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 // static | 1220 // static |
| 1222 ContentSettingBubbleModel* | 1221 ContentSettingBubbleModel* |
| 1223 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 1222 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 1224 Delegate* delegate, | 1223 Delegate* delegate, |
| 1225 WebContents* web_contents, | 1224 WebContents* web_contents, |
| 1226 Profile* profile, | 1225 Profile* profile, |
| 1227 ContentSettingsType content_type) { | 1226 ContentSettingsType content_type) { |
| 1228 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { | 1227 if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { |
| 1229 return new ContentSettingCookiesBubbleModel(delegate, web_contents, profile, | 1228 return new ContentSettingCookiesBubbleModel(delegate, web_contents, |
| 1230 content_type); | 1229 profile); |
| 1231 } | 1230 } |
| 1232 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { | 1231 if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { |
| 1233 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile, | 1232 return new ContentSettingPopupBubbleModel(delegate, web_contents, profile); |
| 1234 content_type); | |
| 1235 } | 1233 } |
| 1236 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 1234 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 1237 return new ContentSettingDomainListBubbleModel(delegate, web_contents, | 1235 return new ContentSettingDomainListBubbleModel(delegate, web_contents, |
| 1238 profile, content_type); | 1236 profile, content_type); |
| 1239 } | 1237 } |
| 1240 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | 1238 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
| 1241 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, | 1239 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, |
| 1242 profile); | 1240 profile); |
| 1243 } | 1241 } |
| 1244 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 1242 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 1245 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, | 1243 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile); |
| 1246 content_type); | |
| 1247 } | 1244 } |
| 1248 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { | 1245 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { |
| 1249 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, | 1246 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, |
| 1250 profile, content_type); | 1247 profile); |
| 1251 } | 1248 } |
| 1252 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 1249 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
| 1253 ProtocolHandlerRegistry* registry = | 1250 ProtocolHandlerRegistry* registry = |
| 1254 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); | 1251 ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); |
| 1255 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, | 1252 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, |
| 1256 registry, content_type); | 1253 registry); |
| 1257 } | 1254 } |
| 1258 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 1255 if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 1259 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, | 1256 return new ContentSettingMidiSysExBubbleModel(delegate, web_contents, |
| 1260 profile, content_type); | 1257 profile); |
| 1261 } | 1258 } |
| 1262 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, | 1259 return new ContentSettingSingleRadioGroup(delegate, web_contents, profile, |
| 1263 content_type); | 1260 content_type); |
| 1264 } | 1261 } |
| 1265 | 1262 |
| 1266 ContentSettingBubbleModel::ContentSettingBubbleModel( | 1263 ContentSettingBubbleModel::ContentSettingBubbleModel( |
| 1267 WebContents* web_contents, | 1264 WebContents* web_contents, |
| 1268 Profile* profile, | 1265 Profile* profile, |
| 1269 ContentSettingsType content_type) | 1266 ContentSettingsType content_type) |
| 1270 : web_contents_(web_contents), | 1267 : web_contents_(web_contents), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1306 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1303 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1307 DCHECK_EQ(web_contents_, | 1304 DCHECK_EQ(web_contents_, |
| 1308 content::Source<WebContents>(source).ptr()); | 1305 content::Source<WebContents>(source).ptr()); |
| 1309 web_contents_ = NULL; | 1306 web_contents_ = NULL; |
| 1310 } else { | 1307 } else { |
| 1311 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1308 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1312 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1309 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1313 profile_ = NULL; | 1310 profile_ = NULL; |
| 1314 } | 1311 } |
| 1315 } | 1312 } |
| OLD | NEW |