| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/content_settings_utils.h" | 8 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 9 #include "chrome/browser/content_settings/cookie_settings.h" | 9 #include "chrome/browser/content_settings/cookie_settings.h" |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 12 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 12 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 13 #include "chrome/browser/infobars/infobar_tab_helper.h" | 14 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" | 18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.
h" |
| 18 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 19 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" | 20 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 content::RenderViewHost* host = | 600 content::RenderViewHost* host = |
| 600 tab_contents()->web_contents()->GetRenderViewHost(); | 601 tab_contents()->web_contents()->GetRenderViewHost(); |
| 601 host->Send(new ChromeViewMsg_SetAllowRunningInsecureContent( | 602 host->Send(new ChromeViewMsg_SetAllowRunningInsecureContent( |
| 602 host->GetRoutingID(), true)); | 603 host->GetRoutingID(), true)); |
| 603 } | 604 } |
| 604 | 605 |
| 605 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( | 606 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel( |
| 606 Delegate* delegate, | 607 Delegate* delegate, |
| 607 TabContents* tab_contents, | 608 TabContents* tab_contents, |
| 608 Profile* profile, | 609 Profile* profile, |
| 610 ProtocolHandlerRegistry* registry, |
| 609 ContentSettingsType content_type) | 611 ContentSettingsType content_type) |
| 610 : ContentSettingTitleAndLinkModel( | 612 : ContentSettingTitleAndLinkModel( |
| 611 delegate, tab_contents, profile, content_type), | 613 delegate, tab_contents, profile, content_type), |
| 612 selected_item_(0), | 614 selected_item_(0), |
| 615 registry_(registry), |
| 613 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), | 616 pending_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 614 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { | 617 previous_handler_(ProtocolHandler::EmptyProtocolHandler()) { |
| 618 |
| 615 DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type); | 619 DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type); |
| 616 | 620 |
| 617 TabSpecificContentSettings* content_settings = | 621 TabSpecificContentSettings* content_settings = |
| 618 tab_contents->content_settings(); | 622 tab_contents->content_settings(); |
| 619 pending_handler_ = content_settings->pending_protocol_handler(); | 623 pending_handler_ = content_settings->pending_protocol_handler(); |
| 620 previous_handler_ = content_settings->previous_protocol_handler(); | 624 previous_handler_ = content_settings->previous_protocol_handler(); |
| 621 | 625 |
| 622 string16 protocol; | 626 string16 protocol; |
| 623 if (pending_handler_.protocol() == "mailto") { | 627 if (pending_handler_.protocol() == "mailto") { |
| 624 protocol = l10n_util::GetStringUTF16( | 628 protocol = l10n_util::GetStringUTF16( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 UnregisterProtocolHandler(); | 687 UnregisterProtocolHandler(); |
| 684 else if (radio_index == RPH_IGNORE) | 688 else if (radio_index == RPH_IGNORE) |
| 685 IgnoreProtocolHandler(); | 689 IgnoreProtocolHandler(); |
| 686 else | 690 else |
| 687 NOTREACHED(); | 691 NOTREACHED(); |
| 688 } | 692 } |
| 689 | 693 |
| 690 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() { | 694 void ContentSettingRPHBubbleModel::RegisterProtocolHandler() { |
| 691 // A no-op if the handler hasn't been ignored, but needed in case the user | 695 // A no-op if the handler hasn't been ignored, but needed in case the user |
| 692 // selects sequences like register/ignore/register. | 696 // selects sequences like register/ignore/register. |
| 693 profile()->GetProtocolHandlerRegistry()->RemoveIgnoredHandler( | 697 registry_->RemoveIgnoredHandler(pending_handler_); |
| 694 pending_handler_); | |
| 695 | 698 |
| 696 profile()->GetProtocolHandlerRegistry()->OnAcceptRegisterProtocolHandler( | 699 registry_->OnAcceptRegisterProtocolHandler(pending_handler_); |
| 697 pending_handler_); | |
| 698 tab_contents()->content_settings()->set_pending_protocol_handler_setting( | 700 tab_contents()->content_settings()->set_pending_protocol_handler_setting( |
| 699 CONTENT_SETTING_ALLOW); | 701 CONTENT_SETTING_ALLOW); |
| 700 } | 702 } |
| 701 | 703 |
| 702 void ContentSettingRPHBubbleModel::UnregisterProtocolHandler() { | 704 void ContentSettingRPHBubbleModel::UnregisterProtocolHandler() { |
| 703 profile()->GetProtocolHandlerRegistry()->OnDenyRegisterProtocolHandler( | 705 registry_->OnDenyRegisterProtocolHandler(pending_handler_); |
| 704 pending_handler_); | |
| 705 tab_contents()->content_settings()->set_pending_protocol_handler_setting( | 706 tab_contents()->content_settings()->set_pending_protocol_handler_setting( |
| 706 CONTENT_SETTING_BLOCK); | 707 CONTENT_SETTING_BLOCK); |
| 707 ClearOrSetPreviousHandler(); | 708 ClearOrSetPreviousHandler(); |
| 708 } | 709 } |
| 709 | 710 |
| 710 void ContentSettingRPHBubbleModel::IgnoreProtocolHandler() { | 711 void ContentSettingRPHBubbleModel::IgnoreProtocolHandler() { |
| 711 profile()->GetProtocolHandlerRegistry()->OnIgnoreRegisterProtocolHandler( | 712 registry_->OnIgnoreRegisterProtocolHandler(pending_handler_); |
| 712 pending_handler_); | |
| 713 tab_contents()->content_settings()->set_pending_protocol_handler_setting( | 713 tab_contents()->content_settings()->set_pending_protocol_handler_setting( |
| 714 CONTENT_SETTING_DEFAULT); | 714 CONTENT_SETTING_DEFAULT); |
| 715 ClearOrSetPreviousHandler(); | 715 ClearOrSetPreviousHandler(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 void ContentSettingRPHBubbleModel::ClearOrSetPreviousHandler() { | 718 void ContentSettingRPHBubbleModel::ClearOrSetPreviousHandler() { |
| 719 if (previous_handler_.IsEmpty()) { | 719 if (previous_handler_.IsEmpty()) { |
| 720 profile()->GetProtocolHandlerRegistry()->ClearDefault( | 720 registry_->ClearDefault(pending_handler_.protocol()); |
| 721 pending_handler_.protocol()); | |
| 722 } else { | 721 } else { |
| 723 profile()->GetProtocolHandlerRegistry()->OnAcceptRegisterProtocolHandler( | 722 registry_->OnAcceptRegisterProtocolHandler(previous_handler_); |
| 724 previous_handler_); | |
| 725 } | 723 } |
| 726 } | 724 } |
| 727 | 725 |
| 728 // static | 726 // static |
| 729 ContentSettingBubbleModel* | 727 ContentSettingBubbleModel* |
| 730 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 728 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 731 Delegate* delegate, | 729 Delegate* delegate, |
| 732 TabContents* tab_contents, | 730 TabContents* tab_contents, |
| 733 Profile* profile, | 731 Profile* profile, |
| 734 ContentSettingsType content_type) { | 732 ContentSettingsType content_type) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 746 } | 744 } |
| 747 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 745 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 748 return new ContentSettingPluginBubbleModel(delegate, tab_contents, profile, | 746 return new ContentSettingPluginBubbleModel(delegate, tab_contents, profile, |
| 749 content_type); | 747 content_type); |
| 750 } | 748 } |
| 751 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { | 749 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { |
| 752 return new ContentSettingMixedScriptBubbleModel(delegate, tab_contents, | 750 return new ContentSettingMixedScriptBubbleModel(delegate, tab_contents, |
| 753 profile, content_type); | 751 profile, content_type); |
| 754 } | 752 } |
| 755 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 753 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
| 754 ProtocolHandlerRegistry* registry = |
| 755 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
| 756 return new ContentSettingRPHBubbleModel(delegate, tab_contents, profile, | 756 return new ContentSettingRPHBubbleModel(delegate, tab_contents, profile, |
| 757 content_type); | 757 registry, content_type); |
| 758 } | 758 } |
| 759 return new ContentSettingSingleRadioGroup(delegate, tab_contents, profile, | 759 return new ContentSettingSingleRadioGroup(delegate, tab_contents, profile, |
| 760 content_type); | 760 content_type); |
| 761 } | 761 } |
| 762 | 762 |
| 763 ContentSettingBubbleModel::ContentSettingBubbleModel( | 763 ContentSettingBubbleModel::ContentSettingBubbleModel( |
| 764 TabContents* tab_contents, | 764 TabContents* tab_contents, |
| 765 Profile* profile, | 765 Profile* profile, |
| 766 ContentSettingsType content_type) | 766 ContentSettingsType content_type) |
| 767 : tab_contents_(tab_contents), | 767 : tab_contents_(tab_contents), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 const content::NotificationDetails& details) { | 803 const content::NotificationDetails& details) { |
| 804 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) { | 804 if (type == chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED) { |
| 805 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr()); | 805 DCHECK_EQ(tab_contents_, content::Source<TabContents>(source).ptr()); |
| 806 tab_contents_ = NULL; | 806 tab_contents_ = NULL; |
| 807 } else { | 807 } else { |
| 808 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 808 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 809 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 809 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 810 profile_ = NULL; | 810 profile_ = NULL; |
| 811 } | 811 } |
| 812 } | 812 } |
| OLD | NEW |