Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4591)

Unified Diff: chrome/browser/content_setting_image_model.cc

Issue 650180: Initial Geolocation location bar icons. (Closed)
Patch Set: Addresses Peter and Brett's comments. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_setting_image_model.cc
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index 96430f7b8d7968101ffc4074064f8b5e1aaea0d3..9dd2ac39bf4efdbcf7c55ec1543de67952e0ddd0 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -12,40 +12,21 @@
class ContentSettingBlockedImageModel : public ContentSettingImageModel {
public:
explicit ContentSettingBlockedImageModel(
- ContentSettingsType content_settings_type)
- : ContentSettingImageModel(content_settings_type) {
- }
+ ContentSettingsType content_settings_type);
- virtual void UpdateFromTabContents(const TabContents* tab_contents) {
- if (tab_contents &&
- tab_contents->IsContentBlocked(get_content_settings_type())) {
- set_icon(kBlockedIconIDs[get_content_settings_type()]);
- set_tooltip(
- l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()]));
- set_visible(true);
- } else {
- set_visible(false);
- }
- }
+ virtual void UpdateFromTabContents(const TabContents* tab_contents);
private:
static const int kBlockedIconIDs[];
static const int kTooltipIDs[];
-
};
-ContentSettingImageModel::ContentSettingImageModel(
- ContentSettingsType content_settings_type)
- : content_settings_type_(content_settings_type),
- is_visible_(false),
- icon_(0) {
-}
+class ContentSettingGeolocationImageModel : public ContentSettingImageModel {
+ public:
+ ContentSettingGeolocationImageModel();
-// static
-ContentSettingImageModel* ContentSettingImageModel::
- CreateContentSettingImageModel(ContentSettingsType content_settings_type) {
- return new ContentSettingBlockedImageModel(content_settings_type);
-}
+ virtual void UpdateFromTabContents(const TabContents* tab_contents);
+};
const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = {
IDR_BLOCKED_COOKIES,
@@ -62,3 +43,76 @@ const int ContentSettingBlockedImageModel::kTooltipIDs[] = {
IDS_BLOCKED_PLUGINS_TITLE,
IDS_BLOCKED_POPUPS_TOOLTIP,
};
+
+
+ContentSettingBlockedImageModel::ContentSettingBlockedImageModel(
+ ContentSettingsType content_settings_type)
+ : ContentSettingImageModel(content_settings_type) {
+}
+
+void ContentSettingBlockedImageModel::UpdateFromTabContents(
+ const TabContents* tab_contents) {
+ if (tab_contents &&
+ tab_contents->IsContentBlocked(get_content_settings_type())) {
+ set_icon(kBlockedIconIDs[get_content_settings_type()]);
+ set_tooltip(
+ l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()]));
+ set_visible(true);
+ } else {
+ set_visible(false);
+ }
+}
+
+ContentSettingGeolocationImageModel::ContentSettingGeolocationImageModel()
+ : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_GEOLOCATION) {
+}
+
+void ContentSettingGeolocationImageModel::UpdateFromTabContents(
+ const TabContents* tab_contents) {
+ if (!tab_contents) {
+ set_visible(false);
+ return;
+ }
+ const TabContents::GeolocationContentSettings& settings =
+ tab_contents->geolocation_content_settings();
+ if (settings.empty()) {
+ set_visible(false);
+ return;
+ }
+ bool is_content_blocked = tab_contents->IsContentBlocked(
+ CONTENT_SETTINGS_TYPE_GEOLOCATION);
+ set_icon(is_content_blocked ?
+ IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON :
+ IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON);
+ std::string tooltip;
+ if (settings.size() == 1) {
+ tooltip = l10n_util::GetStringFUTF8(
+ is_content_blocked ?
+ IDS_GEOLOCATION_BLOCKED_TOOLTIP :
+ IDS_GEOLOCATION_ALLOWED_TOOLTIP,
+ UTF8ToUTF16(settings.begin()->first));
+ } else {
+ tooltip = l10n_util::GetStringUTF8(
+ is_content_blocked ?
+ IDS_GEOLOCATION_MULTIPLE_BLOCKED_TOOLTIP :
+ IDS_GEOLOCATION_MULTIPLE_ALLOWED_TOOLTIP);
+
+ }
+ set_tooltip(tooltip);
+ set_visible(true);
+}
+
+ContentSettingImageModel::ContentSettingImageModel(
+ ContentSettingsType content_settings_type)
+ : content_settings_type_(content_settings_type),
+ is_visible_(false),
+ icon_(0) {
+}
+
+// static
+ContentSettingImageModel* ContentSettingImageModel::
+ CreateContentSettingImageModel(ContentSettingsType content_settings_type) {
+ if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
+ return new ContentSettingGeolocationImageModel();
+ return new ContentSettingBlockedImageModel(content_settings_type);
+}
« no previous file with comments | « chrome/browser/content_setting_bubble_model.cc ('k') | chrome/browser/geolocation/geolocation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698