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-09 06:55:01 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 06:55:01 +0000
commit18e001a7c9575037eda35bed4a0e35984945323d (patch)
tree7536f72a9227e8bc1a53c5b5fad00534a38c6133 /chrome/browser/content_setting_image_model.cc
parent09a8baca4d9887ff96fae636cc6ed4c6fd2ae992 (diff)
downloadchromium_src-18e001a7c9575037eda35bed4a0e35984945323d.zip
chromium_src-18e001a7c9575037eda35bed4a0e35984945323d.tar.gz
chromium_src-18e001a7c9575037eda35bed4a0e35984945323d.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55382 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);
}