summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 09:32:20 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 09:32:20 +0000
commit1fa0c358faf8fef373aca6d30b97c2879539fe9a (patch)
tree56766650fa721e477d712d458827cc1ca391c804
parentd2e15f3732d66d495c64f759f258996140ad0a5a (diff)
downloadchromium_src-1fa0c358faf8fef373aca6d30b97c2879539fe9a.zip
chromium_src-1fa0c358faf8fef373aca6d30b97c2879539fe9a.tar.gz
chromium_src-1fa0c358faf8fef373aca6d30b97c2879539fe9a.tar.bz2
Re-attempt at http://codereview.chromium.org/1344002
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/1369002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42739 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd5
-rw-r--r--chrome/app/theme/theme_resources.grd2
-rw-r--r--chrome/browser/content_setting_bubble_model.cc69
-rw-r--r--chrome/browser/content_setting_bubble_model.h16
-rw-r--r--chrome/browser/content_setting_image_model.cc99
5 files changed, 160 insertions, 31 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 4189a25..bd93aca 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6964,11 +6964,8 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_GEOLOCATION_BUBBLE_SECTION_DENIED" desc="Heading for a section in the geolocation bubble listing all sites which are currently blocked from accessing the user's location">
The following sites have been blocked from tracking your location on this page:
</message>
- <message name="IDS_GEOLOCATION_BUBBLE_SECTION_PENDING" desc="Heading for a section in the geolocation bubble listing all sites which are currently requesting the user's location but have not yet been granted or denied access">
- The following sites are requesting access to your location:
- </message>
<message name="IDS_GEOLOCATION_BUBBLE_CLEAR_LINK" desc="Link on the geolocation bubble that resets the list of allowed and blocked sites">
- Clear settings for future visits
+ Clear these settings for future visits
</message>
<message name="IDS_GEOLOCATION_BUBBLE_MANAGE_LINK" desc="Link on the geolocation bubble that opens up the Content Settings management dialog">
Manage location settings...
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index a7520a8..da49a1a 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -331,6 +331,8 @@
<!-- Geolocation -->
<include name="IDR_GEOLOCATION_INFOBAR_ICON" file="geolocation_infobar_icon.png" type="BINDATA" />
+ <include name="IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON" file="geolocation_allowed_locationbar_icon.png" type="BINDATA" />
+ <include name="IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON" file="geolocation_denied_locationbar_icon.png" type="BINDATA" />
<if expr="pp_ifdef('_google_chrome')">
<include name="IDR_ABOUT_BACKGROUND" file="google_chrome/about_background.png" type="BINDATA" />
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index e361b12..bfa10a0 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -6,6 +6,7 @@
#include "app/l10n_util.h"
#include "chrome/browser/blocked_popup_container.h"
+#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
@@ -33,8 +34,10 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
IDS_BLOCKED_JAVASCRIPT_TITLE,
IDS_BLOCKED_PLUGINS_TITLE,
IDS_BLOCKED_POPUPS_TITLE,
+ 0, // Geolocation does not have an overall title.
};
- set_title(l10n_util::GetStringUTF8(kTitleIDs[content_type()]));
+ if (kTitleIDs[content_type()])
+ set_title(l10n_util::GetStringUTF8(kTitleIDs[content_type()]));
}
void SetManageLink() {
@@ -44,6 +47,7 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel {
IDS_BLOCKED_JAVASCRIPT_LINK,
IDS_BLOCKED_PLUGINS_LINK,
IDS_BLOCKED_POPUPS_LINK,
+ IDS_GEOLOCATION_BUBBLE_MANAGE_LINK,
};
set_manage_link(l10n_util::GetStringUTF8(kLinkIDs[content_type()]));
}
@@ -80,6 +84,7 @@ class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel {
IDS_BLOCKED_JAVASCRIPT_UNBLOCK,
IDS_BLOCKED_PLUGINS_UNBLOCK,
IDS_BLOCKED_POPUPS_UNBLOCK,
+ 0, // We don't manage geolocation here.
};
std::string radio_allow_label;
radio_allow_label = l10n_util::GetStringFUTF8(
@@ -91,6 +96,7 @@ class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel {
IDS_BLOCKED_JAVASCRIPT_NO_ACTION,
IDS_BLOCKED_PLUGINS_NO_ACTION,
IDS_BLOCKED_POPUPS_NO_ACTION,
+ 0, // We don't manage geolocation here.
};
std::string radio_block_label;
radio_block_label = l10n_util::GetStringFUTF8(
@@ -149,6 +155,63 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
}
};
+class ContentSettingDomainListBubbleModel
+ : public ContentSettingTitleAndLinkModel {
+ public:
+ ContentSettingDomainListBubbleModel(TabContents* tab_contents,
+ Profile* profile,
+ ContentSettingsType content_type)
+ : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) {
+ DCHECK_EQ(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) <<
+ "SetDomains currently only supports geolocation content type";
+ SetDomains();
+ SetClearLink();
+ }
+
+ private:
+ void MaybeAddDomainList(DomainList* domain_list, int title_id) {
+ if (!domain_list->hosts.empty()) {
+ domain_list->title = l10n_util::GetStringUTF8(title_id);
+ add_domain_list(*domain_list);
+ }
+ }
+ void SetDomains() {
+ const TabContents::GeolocationContentSettings& settings =
+ tab_contents()->geolocation_content_settings();
+
+ // Divide the tab's current geolocation users into sets according to their
+ // permission state.
+ DomainList domains[CONTENT_SETTING_NUM_SETTINGS];
+ for (TabContents::GeolocationContentSettings::const_iterator it =
+ settings.begin(); it != settings.end(); ++it) {
+ domains[it->second].hosts.insert(it->first.host());
+ }
+ MaybeAddDomainList(&domains[CONTENT_SETTING_ALLOW],
+ IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED);
+ MaybeAddDomainList(&domains[CONTENT_SETTING_BLOCK],
+ IDS_GEOLOCATION_BUBBLE_SECTION_DENIED);
+ }
+ void SetClearLink() {
+ set_clear_link(l10n_util::GetStringUTF8(IDS_GEOLOCATION_BUBBLE_CLEAR_LINK));
+ }
+ virtual void OnClearLinkClicked() {
+ if (!tab_contents())
+ return;
+ // Reset this embedder's entry to default for each of the requesting
+ // origins currently on the page.
+ const GURL& embedder_url = tab_contents()->GetURL();
+ const TabContents::GeolocationContentSettings& settings =
+ tab_contents()->geolocation_content_settings();
+ GeolocationContentSettingsMap* settings_map =
+ profile()->GetGeolocationContentSettingsMap();
+ for (TabContents::GeolocationContentSettings::const_iterator it =
+ settings.begin(); it != settings.end(); ++it) {
+ settings_map->SetContentSetting(it->first, embedder_url,
+ CONTENT_SETTING_DEFAULT);
+ }
+ }
+};
+
// static
ContentSettingBubbleModel*
ContentSettingBubbleModel::CreateContentSettingBubbleModel(
@@ -163,6 +226,10 @@ ContentSettingBubbleModel*
return new ContentSettingPopupBubbleModel(tab_contents, profile,
content_type);
}
+ if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
+ return new ContentSettingDomainListBubbleModel(tab_contents, profile,
+ content_type);
+ }
return new ContentSettingSingleRadioGroup(tab_contents, profile,
content_type);
}
diff --git a/chrome/browser/content_setting_bubble_model.h b/chrome/browser/content_setting_bubble_model.h
index dcbafb7..f506b48 100644
--- a/chrome/browser/content_setting_bubble_model.h
+++ b/chrome/browser/content_setting_bubble_model.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
#define CHROME_BROWSER_CONTENT_SETTING_BUBBLE_MODEL_H_
+#include <set>
#include <string>
#include <vector>
@@ -13,6 +14,7 @@
#include "chrome/common/notification_registrar.h"
#include "third_party/skia/include/core/SkBitmap.h"
+class GURL;
class Profile;
class SkBitmap;
class TabContents;
@@ -46,11 +48,18 @@ class ContentSettingBubbleModel : public NotificationObserver {
};
typedef std::vector<RadioGroup> RadioGroups;
+ struct DomainList {
+ std::string title;
+ std::set<std::string> hosts;
+ };
+
struct BubbleContent {
std::string title;
PopupItems popup_items;
RadioGroups radio_groups;
+ std::vector<DomainList> domain_lists;
std::string manage_link;
+ std::string clear_link;
};
const BubbleContent& bubble_content() const { return bubble_content_; }
@@ -63,6 +72,7 @@ class ContentSettingBubbleModel : public NotificationObserver {
virtual void OnRadioClicked(int radio_group, int radio_index) {}
virtual void OnPopupClicked(int index) {}
virtual void OnManageLinkClicked() {}
+ virtual void OnClearLinkClicked() {}
protected:
ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile,
@@ -78,9 +88,15 @@ class ContentSettingBubbleModel : public NotificationObserver {
void add_radio_group(const RadioGroup& radio_group) {
bubble_content_.radio_groups.push_back(radio_group);
}
+ void add_domain_list(const DomainList& domain_list) {
+ bubble_content_.domain_lists.push_back(domain_list);
+ }
void set_manage_link(const std::string& link) {
bubble_content_.manage_link = link;
}
+ void set_clear_link(const std::string& link) {
+ bubble_content_.clear_link = link;
+ }
private:
TabContents* tab_contents_;
diff --git a/chrome/browser/content_setting_image_model.cc b/chrome/browser/content_setting_image_model.cc
index 96430f7..77b2f1a 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,69 @@ 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);
+}