| 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 content_settings->IsContentBlocked(content_type())) { |
| 119 set_plugin_names(content_settings->GetBlockedPluginNames()); |
| 120 } |
| 121 |
| 111 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { | 122 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { |
| 112 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 123 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
| 113 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 124 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
| 114 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 125 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
| 115 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 126 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_TITLE}, |
| 116 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, | 127 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, |
| 117 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 128 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
| 118 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 129 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
| 119 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 130 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 120 IDS_BLOCKED_PPAPI_BROKER_TITLE}, | 131 IDS_BLOCKED_PPAPI_BROKER_TITLE}, |
| 121 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, | 132 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, |
| 122 }; | 133 }; |
| 123 // Fields as for kBlockedTitleIDs, above. | 134 // Fields as for kBlockedTitleIDs, above. |
| 124 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { | 135 static const ContentSettingsTypeIdEntry kAccessedTitleIDs[] = { |
| 125 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, | 136 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_ACCESSED_COOKIES_TITLE}, |
| 126 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, | 137 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_ALLOWED_PPAPI_BROKER_TITLE}, |
| 127 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, | 138 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_ALLOWED_DOWNLOAD_TITLE}, |
| 128 }; | 139 }; |
| 129 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; | 140 const ContentSettingsTypeIdEntry *title_ids = kBlockedTitleIDs; |
| 130 size_t num_title_ids = arraysize(kBlockedTitleIDs); | 141 size_t num_title_ids = arraysize(kBlockedTitleIDs); |
| 131 if (web_contents() && | 142 if (content_settings && content_settings->IsContentAllowed(content_type()) && |
| 132 TabSpecificContentSettings::FromWebContents( | 143 !content_settings->IsContentBlocked(content_type())) { |
| 133 web_contents())->IsContentAllowed(content_type()) && | |
| 134 !TabSpecificContentSettings::FromWebContents( | |
| 135 web_contents())->IsContentBlocked(content_type())) { | |
| 136 title_ids = kAccessedTitleIDs; | 144 title_ids = kAccessedTitleIDs; |
| 137 num_title_ids = arraysize(kAccessedTitleIDs); | 145 num_title_ids = arraysize(kAccessedTitleIDs); |
| 138 } | 146 } |
| 139 int title_id = | 147 int title_id = |
| 140 GetIdForContentType(title_ids, num_title_ids, content_type()); | 148 GetIdForContentType(title_ids, num_title_ids, content_type()); |
| 141 if (title_id) | 149 if (title_id) |
| 142 set_title(l10n_util::GetStringUTF8(title_id)); | 150 set_title(l10n_util::GetStringUTF8(title_id)); |
| 143 } | 151 } |
| 144 | 152 |
| 145 void ContentSettingTitleAndLinkModel::SetManageLink() { | 153 void ContentSettingTitleAndLinkModel::SetManageLink() { |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1302 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
| 1295 DCHECK_EQ(web_contents_, | 1303 DCHECK_EQ(web_contents_, |
| 1296 content::Source<WebContents>(source).ptr()); | 1304 content::Source<WebContents>(source).ptr()); |
| 1297 web_contents_ = NULL; | 1305 web_contents_ = NULL; |
| 1298 } else { | 1306 } else { |
| 1299 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1307 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 1300 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1308 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 1301 profile_ = NULL; | 1309 profile_ = NULL; |
| 1302 } | 1310 } |
| 1303 } | 1311 } |
| OLD | NEW |