| 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_image_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 105 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
| 106 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 106 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, |
| 107 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, | 107 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TOOLTIP}, |
| 108 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 108 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
| 109 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, | 109 IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT}, |
| 110 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_TITLE}, | 110 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_BLOCKED_PPAPI_BROKER_TITLE}, |
| 111 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, | 111 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOAD_TITLE}, |
| 112 }; | 112 }; |
| 113 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { | 113 static const ContentSettingsTypeIdEntry kBlockedExplanatoryTextIDs[] = { |
| 114 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, | 114 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT}, |
| 115 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT}, |
| 115 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | 116 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
| 116 IDS_BLOCKED_DOWNLOADS_EXPLANATION}, | 117 IDS_BLOCKED_DOWNLOADS_EXPLANATION}, |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 ContentSettingsType type = get_content_settings_type(); | 120 ContentSettingsType type = get_content_settings_type(); |
| 120 int icon_id = GetIdForContentType( | 121 int icon_id = GetIdForContentType( |
| 121 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); | 122 kBlockedIconIDs, arraysize(kBlockedIconIDs), type); |
| 122 int tooltip_id = GetIdForContentType( | 123 int tooltip_id = GetIdForContentType( |
| 123 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); | 124 kBlockedTooltipIDs, arraysize(kBlockedTooltipIDs), type); |
| 124 int explanation_id = GetIdForContentType( | 125 int explanation_id = GetIdForContentType( |
| 125 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); | 126 kBlockedExplanatoryTextIDs, arraysize(kBlockedExplanatoryTextIDs), type); |
| 126 | 127 |
| 127 // If a content type is blocked by default and was accessed, display the | 128 // If a content type is blocked by default and was accessed, display the |
| 128 // accessed icon. | 129 // accessed icon. |
| 129 TabSpecificContentSettings* content_settings = | 130 TabSpecificContentSettings* content_settings = |
| 130 TabSpecificContentSettings::FromWebContents(web_contents); | 131 TabSpecificContentSettings::FromWebContents(web_contents); |
| 131 if (!content_settings) | 132 if (!content_settings) |
| 132 return; | 133 return; |
| 133 Profile* profile = | 134 Profile* profile = |
| 134 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 135 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 136 if (get_content_settings_type() == CONTENT_SETTINGS_TYPE_PLUGINS && |
| 137 (profile->GetHostContentSettingsMap()-> |
| 138 GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS, NULL) != |
| 139 CONTENT_SETTING_ALLOW)) |
| 140 explanation_id = 0; |
| 141 |
| 142 |
| 135 if (!content_settings->IsContentBlocked(get_content_settings_type())) { | 143 if (!content_settings->IsContentBlocked(get_content_settings_type())) { |
| 136 if (!content_settings->IsContentAllowed(get_content_settings_type())) | 144 if (!content_settings->IsContentAllowed(get_content_settings_type())) |
| 137 return; | 145 return; |
| 138 | 146 |
| 139 // For cookies, only show the accessed bubble if cookies are blocked by | 147 // For cookies, only show the accessed bubble if cookies are blocked by |
| 140 // default. | 148 // default. |
| 141 if (get_content_settings_type() == CONTENT_SETTINGS_TYPE_COOKIES && | 149 if (get_content_settings_type() == CONTENT_SETTINGS_TYPE_COOKIES && |
| 142 (profile->GetHostContentSettingsMap()-> | 150 (profile->GetHostContentSettingsMap()-> |
| 143 GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, NULL) != | 151 GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, NULL) != |
| 144 CONTENT_SETTING_BLOCK)) | 152 CONTENT_SETTING_BLOCK)) |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 364 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 357 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 365 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 358 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 366 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 359 return new ContentSettingMediaImageModel(content_settings_type); | 367 return new ContentSettingMediaImageModel(content_settings_type); |
| 360 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | 368 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 361 return new ContentSettingMIDISysExImageModel(); | 369 return new ContentSettingMIDISysExImageModel(); |
| 362 default: | 370 default: |
| 363 return new ContentSettingBlockedImageModel(content_settings_type); | 371 return new ContentSettingBlockedImageModel(content_settings_type); |
| 364 } | 372 } |
| 365 } | 373 } |
| OLD | NEW |