summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_setting_image_model.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 09:39:48 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 09:39:48 +0000
commitb2d8f363a11f1e674eb14a297d0a20c3b2134906 (patch)
treec57623fe575da463685e426ebed7e68d773b67ab /chrome/browser/content_setting_image_model.cc
parent7c64b2dd993a3835e4d9e7934e235d11846c143e (diff)
downloadchromium_src-b2d8f363a11f1e674eb14a297d0a20c3b2134906.zip
chromium_src-b2d8f363a11f1e674eb14a297d0a20c3b2134906.tar.gz
chromium_src-b2d8f363a11f1e674eb14a297d0a20c3b2134906.tar.bz2
Reland r55382. When blocking cookies, also show an icon in the location bar when cookies are accessed.
If the user choses to block cookies per default, this will grant access to the collected cookies dialog as soon as the page accesses cookies. Right now, the icon is only shown if cookies were actually blocked. BUG=45230 TEST=Canned*.*:ContentSettingImage*.*:TabSpecific*.* Review URL: http://codereview.chromium.org/3014056 Review URL: http://codereview.chromium.org/3148002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_image_model.cc')
-rw-r--r--chrome/browser/content_setting_image_model.cc62
1 files changed, 51 insertions, 11 deletions
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index 26e349ac..e45aead 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -5,7 +5,11 @@
#include "chrome/browser/content_setting_image_model.h"
#include "app/l10n_util.h"
+#include "base/command_line.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/chrome_switches.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -17,8 +21,10 @@ class ContentSettingBlockedImageModel : public ContentSettingImageModel {
virtual void UpdateFromTabContents(const TabContents* tab_contents);
private:
+ static const int kAccessedIconIDs[];
static const int kBlockedIconIDs[];
- static const int kTooltipIDs[];
+ static const int kAccessedTooltipIDs[];
+ static const int kBlockedTooltipIDs[];
};
class ContentSettingGeolocationImageModel : public ContentSettingImageModel {
@@ -43,14 +49,29 @@ const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = {
IDR_BLOCKED_POPUPS,
};
-const int ContentSettingBlockedImageModel::kTooltipIDs[] = {
- IDS_BLOCKED_COOKIES_TITLE,
- IDS_BLOCKED_IMAGES_TITLE,
- IDS_BLOCKED_JAVASCRIPT_TITLE,
- IDS_BLOCKED_PLUGINS_TITLE,
- IDS_BLOCKED_POPUPS_TOOLTIP,
+const int ContentSettingBlockedImageModel::kAccessedIconIDs[] = {
+ IDR_ACCESSED_COOKIES,
+ 0,
+ 0,
+ 0,
+ 0,
};
+const int ContentSettingBlockedImageModel::kBlockedTooltipIDs[] = {
+ IDS_BLOCKED_COOKIES_TITLE,
+ IDS_BLOCKED_IMAGES_TITLE,
+ IDS_BLOCKED_JAVASCRIPT_TITLE,
+ IDS_BLOCKED_PLUGINS_TITLE,
+ IDS_BLOCKED_POPUPS_TOOLTIP,
+};
+
+const int ContentSettingBlockedImageModel::kAccessedTooltipIDs[] = {
+ IDS_ACCESSED_COOKIES_TITLE,
+ 0,
+ 0,
+ 0,
+ 0,
+};
ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
ContentSettingsType content_settings_type)
@@ -61,14 +82,33 @@ void ContentSettingBlockedImageModel::UpdateFromTabContents(
const TabContents* tab_contents) {
TabSpecificContentSettings* content_settings = tab_contents ?
tab_contents->GetTabSpecificContentSettings() : NULL;
- if (!content_settings ||
- !content_settings->IsContentBlocked(get_content_settings_type())) {
+ const int* icon_ids;
+ const int* tooltip_ids;
+
+ if (!content_settings) {
+ set_visible(false);
+ return;
+ }
+ if (content_settings->IsContentBlocked(get_content_settings_type())) {
+ icon_ids = kBlockedIconIDs;
+ tooltip_ids = kBlockedTooltipIDs;
+ } else if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableCookiePrompt) &&
+ tab_contents->profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(get_content_settings_type()) ==
+ CONTENT_SETTING_BLOCK &&
+ content_settings->IsContentAccessed(get_content_settings_type())) {
+ // If a content type is blocked by default and was accessed, display the
+ // accessed icon.
+ icon_ids = kAccessedIconIDs;
+ tooltip_ids = kAccessedTooltipIDs;
+ } else {
set_visible(false);
return;
}
- set_icon(kBlockedIconIDs[get_content_settings_type()]);
+ set_icon(icon_ids[get_content_settings_type()]);
set_tooltip(
- l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()]));
+ l10n_util::GetStringUTF8(tooltip_ids[get_content_settings_type()]));
set_visible(true);
}