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/api/infobars/infobar_service.h" | 8 #include "chrome/browser/api/infobars/infobar_service.h" |
9 #include "chrome/browser/content_settings/content_settings_utils.h" | 9 #include "chrome/browser/content_settings/content_settings_utils.h" |
10 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 11 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
12 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 12 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
13 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 13 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
14 #include "chrome/browser/favicon/favicon_tab_helper.h" | 14 #include "chrome/browser/favicon/favicon_tab_helper.h" |
15 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | |
16 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 17 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
19 #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" |
20 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 19 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
21 #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" |
22 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/content_settings.h" | 22 #include "chrome/common/content_settings.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
26 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/render_process_host.h" | |
28 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
30 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
31 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
32 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
33 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
34 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
35 | 33 |
36 using content::UserMetricsAction; | 34 using content::UserMetricsAction; |
37 using content::WebContents; | 35 using content::WebContents; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 if (!web_contents()) | 389 if (!web_contents()) |
392 return; | 390 return; |
393 content::NotificationService::current()->Notify( | 391 content::NotificationService::current()->Notify( |
394 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, | 392 chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
395 content::Source<TabSpecificContentSettings>( | 393 content::Source<TabSpecificContentSettings>( |
396 TabSpecificContentSettings::FromWebContents(web_contents())), | 394 TabSpecificContentSettings::FromWebContents(web_contents())), |
397 content::NotificationService::NoDetails()); | 395 content::NotificationService::NoDetails()); |
398 delegate()->ShowCollectedCookiesDialog(web_contents()); | 396 delegate()->ShowCollectedCookiesDialog(web_contents()); |
399 } | 397 } |
400 | 398 |
401 #if defined(ENABLE_PLUGINS) | |
402 | |
403 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { | 399 class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { |
404 public: | 400 public: |
405 ContentSettingPluginBubbleModel(Delegate* delegate, | 401 ContentSettingPluginBubbleModel(Delegate* delegate, |
406 WebContents* web_contents, | 402 WebContents* web_contents, |
407 Profile* profile, | 403 Profile* profile, |
408 ContentSettingsType content_type); | 404 ContentSettingsType content_type); |
409 | 405 |
410 virtual ~ContentSettingPluginBubbleModel() {} | 406 virtual ~ContentSettingPluginBubbleModel() {} |
411 | 407 |
412 private: | 408 private: |
(...skipping 11 matching lines...) Expand all Loading... |
424 set_custom_link_enabled(web_contents && | 420 set_custom_link_enabled(web_contents && |
425 TabSpecificContentSettings::FromWebContents( | 421 TabSpecificContentSettings::FromWebContents( |
426 web_contents)->load_plugins_link_enabled()); | 422 web_contents)->load_plugins_link_enabled()); |
427 } | 423 } |
428 | 424 |
429 void ContentSettingPluginBubbleModel::OnCustomLinkClicked() { | 425 void ContentSettingPluginBubbleModel::OnCustomLinkClicked() { |
430 content::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble")); | 426 content::RecordAction(UserMetricsAction("ClickToPlay_LoadAll_Bubble")); |
431 DCHECK(web_contents()); | 427 DCHECK(web_contents()); |
432 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); | 428 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
433 // TODO(bauerb): We should send the identifiers of blocked plug-ins here. | 429 // TODO(bauerb): We should send the identifiers of blocked plug-ins here. |
434 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | |
435 host->GetProcess()->GetID()); | |
436 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID(), | 430 host->Send(new ChromeViewMsg_LoadBlockedPlugins(host->GetRoutingID(), |
437 std::string())); | 431 std::string())); |
438 set_custom_link_enabled(false); | 432 set_custom_link_enabled(false); |
439 TabSpecificContentSettings::FromWebContents(web_contents())-> | 433 TabSpecificContentSettings::FromWebContents(web_contents())-> |
440 set_load_plugins_link_enabled(false); | 434 set_load_plugins_link_enabled(false); |
441 } | 435 } |
442 | 436 |
443 #endif // ENABLE_PLUGINS | |
444 | |
445 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { | 437 class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { |
446 public: | 438 public: |
447 ContentSettingPopupBubbleModel(Delegate* delegate, | 439 ContentSettingPopupBubbleModel(Delegate* delegate, |
448 WebContents* web_contents, | 440 WebContents* web_contents, |
449 Profile* profile, | 441 Profile* profile, |
450 ContentSettingsType content_type); | 442 ContentSettingsType content_type); |
451 virtual ~ContentSettingPopupBubbleModel() {} | 443 virtual ~ContentSettingPopupBubbleModel() {} |
452 | 444 |
453 private: | 445 private: |
454 void SetPopups(); | 446 void SetPopups(); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 content_type); | 883 content_type); |
892 } | 884 } |
893 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 885 if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
894 return new ContentSettingDomainListBubbleModel(delegate, web_contents, | 886 return new ContentSettingDomainListBubbleModel(delegate, web_contents, |
895 profile, content_type); | 887 profile, content_type); |
896 } | 888 } |
897 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { | 889 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) { |
898 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, | 890 return new ContentSettingMediaStreamBubbleModel(delegate, web_contents, |
899 profile); | 891 profile); |
900 } | 892 } |
901 #if defined(ENABLE_PLUGINS) | |
902 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { | 893 if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { |
903 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, | 894 return new ContentSettingPluginBubbleModel(delegate, web_contents, profile, |
904 content_type); | 895 content_type); |
905 } | 896 } |
906 #endif | |
907 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { | 897 if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { |
908 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, | 898 return new ContentSettingMixedScriptBubbleModel(delegate, web_contents, |
909 profile, content_type); | 899 profile, content_type); |
910 } | 900 } |
911 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { | 901 if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { |
912 ProtocolHandlerRegistry* registry = | 902 ProtocolHandlerRegistry* registry = |
913 ProtocolHandlerRegistryFactory::GetForProfile(profile); | 903 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
914 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, | 904 return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, |
915 registry, content_type); | 905 registry, content_type); |
916 } | 906 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 952 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
963 DCHECK_EQ(web_contents_, | 953 DCHECK_EQ(web_contents_, |
964 content::Source<WebContents>(source).ptr()); | 954 content::Source<WebContents>(source).ptr()); |
965 web_contents_ = NULL; | 955 web_contents_ = NULL; |
966 } else { | 956 } else { |
967 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 957 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
968 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 958 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
969 profile_ = NULL; | 959 profile_ = NULL; |
970 } | 960 } |
971 } | 961 } |
OLD | NEW |