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

Unified Diff: chrome/browser/content_setting_bubble_model.cc

Issue 1344002: Adds geolocaiton support to the location bar content image model and content ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « chrome/browser/content_setting_bubble_model.h ('k') | chrome/browser/content_setting_image_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_setting_bubble_model.cc
===================================================================
--- chrome/browser/content_setting_bubble_model.cc (revision 42643)
+++ chrome/browser/content_setting_bubble_model.cc (working copy)
@@ -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 @@
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 @@
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 @@
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 @@
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,65 @@
}
};
+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.push_back(it->first);
+ }
+ MaybeAddDomainList(&domains[CONTENT_SETTING_ALLOW],
+ IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED);
+ MaybeAddDomainList(&domains[CONTENT_SETTING_BLOCK],
+ IDS_GEOLOCATION_BUBBLE_SECTION_DENIED);
+ MaybeAddDomainList(&domains[CONTENT_SETTING_ASK],
+ IDS_GEOLOCATION_BUBBLE_SECTION_PENDING);
+ }
+ 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 +228,10 @@
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);
}
Property changes on: chrome\browser\content_setting_bubble_model.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/content_setting_bubble_model.h ('k') | chrome/browser/content_setting_image_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698