summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_setting_image_model.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 20:59:27 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 20:59:27 +0000
commit9fdff480c99405601b20f4b23a9a64fc711ce9a7 (patch)
tree61fde4f652e11ab26071767fc08a88805dc3cbfb /chrome/browser/content_setting_image_model.cc
parentb92e05de97b1dd960974c78be4f392142871df3d (diff)
downloadchromium_src-9fdff480c99405601b20f4b23a9a64fc711ce9a7.zip
chromium_src-9fdff480c99405601b20f4b23a9a64fc711ce9a7.tar.gz
chromium_src-9fdff480c99405601b20f4b23a9a64fc711ce9a7.tar.bz2
Revert 42665 - broke build as I missed a unit test when building locally.
Adds geolocaiton support to the location bar content image model and content bubble model. Most of these edits were lifted out of http://codereview.chromium.org/650180 TODO: add geolocation support to the views in the three UI platforms for the bubble model. (NOTE this change results in poorly formed bubble contents for the geolocaiton bubble, this will be fixed up in the following CLs) BUG=11246 TEST=open a site that uses geolocaiton, select allow/deny & click the icon. Review URL: http://codereview.chromium.org/1344002 TBR=joth@chromium.org Review URL: http://codereview.chromium.org/1367002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_image_model.cc')
-rw-r--r--chrome/browser/content_setting_image_model.cc99
1 files changed, 26 insertions, 73 deletions
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index 77b2f1a..96430f7 100644
--- a/chrome/browser/content_setting_image_model.cc
+++ b/chrome/browser/content_setting_image_model.cc
@@ -12,21 +12,40 @@
class ContentSettingBlockedImageModel : public ContentSettingImageModel {
public:
explicit ContentSettingBlockedImageModel(
- ContentSettingsType content_settings_type);
+ ContentSettingsType content_settings_type)
+ : ContentSettingImageModel(content_settings_type) {
+ }
- virtual void UpdateFromTabContents(const TabContents* tab_contents);
+ 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);
+ }
+ }
private:
static const int kBlockedIconIDs[];
static const int kTooltipIDs[];
+
};
-class ContentSettingGeolocationImageModel : public ContentSettingImageModel {
- public:
- ContentSettingGeolocationImageModel();
+ContentSettingImageModel::ContentSettingImageModel(
+ ContentSettingsType content_settings_type)
+ : content_settings_type_(content_settings_type),
+ is_visible_(false),
+ icon_(0) {
+}
- virtual void UpdateFromTabContents(const TabContents* tab_contents);
-};
+// static
+ContentSettingImageModel* ContentSettingImageModel::
+ CreateContentSettingImageModel(ContentSettingsType content_settings_type) {
+ return new ContentSettingBlockedImageModel(content_settings_type);
+}
const int ContentSettingBlockedImageModel::kBlockedIconIDs[] = {
IDR_BLOCKED_COOKIES,
@@ -43,69 +62,3 @@ 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_visible(false);
- return;
- }
- set_icon(kBlockedIconIDs[get_content_settings_type()]);
- set_tooltip(
- l10n_util::GetStringUTF8(kTooltipIDs[get_content_settings_type()]));
- set_visible(true);
-}
-
-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;
- }
- set_visible(true);
- // If any embedded site has access the allowed icon takes priority over the
- // blocked icon.
- for (TabContents::GeolocationContentSettings::const_iterator it =
- settings.begin(); it != settings.end(); ++it ) {
- if (it->second == CONTENT_SETTING_ALLOW) {
- set_icon(IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON);
- set_tooltip(l10n_util::GetStringUTF8(IDS_GEOLOCATION_ALLOWED_TOOLTIP));
- return;
- }
- }
- set_icon(IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON);
- set_tooltip(l10n_util::GetStringUTF8(IDS_GEOLOCATION_BLOCKED_TOOLTIP));
-}
-
-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);
-}