Chromium Code Reviews| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 : ContentSettingBubbleModel(web_contents, profile, content_type), | 101 : ContentSettingBubbleModel(web_contents, profile, content_type), |
| 102 delegate_(delegate) { | 102 delegate_(delegate) { |
| 103 // Notifications do not have a bubble. | 103 // Notifications do not have a bubble. |
| 104 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 104 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 105 SetTitle(); | 105 SetTitle(); |
| 106 SetManageLink(); | 106 SetManageLink(); |
| 107 SetLearnMoreLink(); | 107 SetLearnMoreLink(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ContentSettingTitleAndLinkModel::SetTitle() { | 110 void ContentSettingTitleAndLinkModel::SetTitle() { |
| 111 TabSpecificContentSettings* content_settings = NULL; | |
| 112 if (web_contents()) { | |
| 113 content_settings = | |
| 114 TabSpecificContentSettings::FromWebContents(web_contents()); | |
| 115 } | |
| 116 | |
| 117 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS && content_settings) { | |
| 118 if (content_settings->IsContentBlocked(content_type())) { | |
| 119 const base::string16 plugin_names = | |
| 120 content_settings->GetBlockedPluginNames(); | |
| 121 if (!plugin_names.empty()) { | |
|
Bernhard Bauer
2014/12/08 09:21:44
If |plugin_names| is indeed empty, you will call s
Will Harris
2014/12/08 21:11:46
Done.
| |
| 122 set_plugin_names(plugin_names); | |
| 123 } | |
| 124 } | |
| 125 } | |
| 126 | |
| 111 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { | 127 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { |
| 112 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 128 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
| 113 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 129 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
| 114 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 130 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
| 115 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 131 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, |
| 116 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, | 132 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, |
| 117 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 133 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
| 118 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 134 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
| 119 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 135 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 120 IDS_BLOCKED_PPAPI_BROKER_TITLE}, | 136 IDS_BLOCKED_PPAPI_BROKER_TITLE}, |
| 121 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, | 137 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, |
| 122 }; | 138 }; |
| 123 // Fields as for kBlockedTitleIDs, above. | 139 // Fields as for kBlockedTitleIDs, above. |
| 124 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { | 140 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { |
| 125 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, | 141 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, |
| 126 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, | 142 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, |
| 127 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, | 143 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, |
| 128 }; | 144 }; |
| 129 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; | 145 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; |
| 130 size_t num_title_ids = arraysize(kBlockedTitleIDs); | 146 size_t num_title_ids = arraysize(kBlockedTitleIDs); |
| 131 if (web_contents() && | 147 if (content_settings && content_settings->IsContentAllowed(content_type()) && |
| 132 TabSpecificContentSettings::FromWebContents( | 148 !content_settings->IsContentBlocked(content_type())) { |
| 133 web_contents())->IsContentAllowed(content_type()) && | |
| 134 !TabSpecificContentSettings::FromWebContents( | |
| 135 web_contents())->IsContentBlocked(content_type())) { | |
| 136 title_ids = kAccessedTitleIDs; | 149 title_ids = kAccessedTitleIDs; |
| 137 num_title_ids = arraysize(kAccessedTitleIDs); | 150 num_title_ids = arraysize(kAccessedTitleIDs); |
| 138 } | 151 } |
| 139 int title_id = | 152 int title_id = |
| 140 GetIdForContentType(title_ids, num_title_ids, content_type()); | 153 GetIdForContentType(title_ids, num_title_ids, content_type()); |
| 141 if (title_id) | 154 if (title_id) |
| 142 set_title(l10n_util::GetStringUTF8(title_id)); | 155 set_title(l10n_util::GetStringUTF8(title_id)); |
| 143 } | 156 } |
| 144 | 157 |
| 145 void ContentSettingTitleAndLinkModel::SetManageLink() { | 158 void ContentSettingTitleAndLinkModel::SetManageLink() { |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1294 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1307 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1295 DCHECK_EQ(web_contents_, | 1308 DCHECK_EQ(web_contents_, |
| 1296 content::Source<WebContents>(source).ptr()); | 1309 content::Source<WebContents>(source).ptr()); |
| 1297 web_contents_ = NULL; | 1310 web_contents_ = NULL; |
| 1298 } else { | 1311 } else { |
| 1299 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1312 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1300 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1313 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1301 profile_ = NULL; | 1314 profile_ = NULL; |
| 1302 } | 1315 } |
| 1303 } | 1316 } |
| OLD | NEW |