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

Unified Diff: chrome/browser/ui/webui/options2/content_settings_handler2.cc

Issue 10536103: Revert 141482 - Pepper Flash settings integration - camera and microphone. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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/ui/webui/options2/content_settings_handler2.h ('k') | chrome/tools/chromeactions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options2/content_settings_handler2.cc
===================================================================
--- chrome/browser/ui/webui/options2/content_settings_handler2.cc (revision 141490)
+++ chrome/browser/ui/webui/options2/content_settings_handler2.cc (working copy)
@@ -4,6 +4,8 @@
#include "chrome/browser/ui/webui/options2/content_settings_handler2.h"
+#include <map>
+#include <string>
#include <vector>
#include "base/bind.h"
@@ -39,7 +41,6 @@
#include "content/public/common/content_switches.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
-#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
@@ -50,10 +51,9 @@
namespace {
-enum ExContentSettingsTypeEnum {
- EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC =
- CONTENT_SETTINGS_NUM_TYPES,
- EX_CONTENT_SETTINGS_NUM_TYPES
+struct ContentSettingsTypeNameEntry {
+ ContentSettingsType type;
+ const char* name;
};
typedef std::map<ContentSettingsPattern, ContentSetting> OnePatternSettings;
@@ -67,9 +67,34 @@
const char* kAppName = "appName";
const char* kAppId = "appId";
const char* kEmbeddingOrigin = "embeddingOrigin";
-const char* kDefaultProviderID = "default";
-const char* kPreferencesSource = "preferences";
+const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
+ {CONTENT_SETTINGS_TYPE_COOKIES, "cookies"},
+ {CONTENT_SETTINGS_TYPE_IMAGES, "images"},
+ {CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript"},
+ {CONTENT_SETTINGS_TYPE_PLUGINS, "plugins"},
+ {CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
+ {CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
+ {CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
+ {CONTENT_SETTINGS_TYPE_INTENTS, "intents"},
+ {CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
+ {CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
+ {CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
+};
+COMPILE_ASSERT(arraysize(kContentSettingsTypeGroupNames) ==
+ CONTENT_SETTINGS_NUM_TYPES,
+ MISSING_CONTENT_SETTINGS_TYPE);
+
+ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
+ for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
+ if (name == kContentSettingsTypeGroupNames[i].name)
+ return kContentSettingsTypeGroupNames[i].type;
+ }
+
+ NOTREACHED() << name << " is not a recognized content settings type.";
+ return CONTENT_SETTINGS_TYPE_DEFAULT;
+}
+
std::string ContentSettingToString(ContentSetting setting) {
switch (setting) {
case CONTENT_SETTING_ALLOW:
@@ -219,109 +244,10 @@
}
}
-ContentSetting FlashPermissionToContentSetting(
- PP_Flash_BrowserOperations_Permission permission) {
- switch (permission) {
- case PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT:
- return CONTENT_SETTING_DEFAULT;
- case PP_FLASH_BROWSEROPERATIONS_PERMISSION_ALLOW:
- return CONTENT_SETTING_ALLOW;
- case PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK:
- return CONTENT_SETTING_BLOCK;
- case PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK:
- return CONTENT_SETTING_ASK;
- default:
- NOTREACHED();
- return CONTENT_SETTING_DEFAULT;
- }
-}
-
-PP_Flash_BrowserOperations_Permission FlashPermissionFromContentSetting(
- ContentSetting setting) {
- switch (setting) {
- case CONTENT_SETTING_DEFAULT:
- return PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT;
- case CONTENT_SETTING_ALLOW:
- return PP_FLASH_BROWSEROPERATIONS_PERMISSION_ALLOW;
- case CONTENT_SETTING_BLOCK:
- return PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK;
- case CONTENT_SETTING_ASK:
- return PP_FLASH_BROWSEROPERATIONS_PERMISSION_ASK;
- default:
- NOTREACHED();
- return PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT;
- }
-}
-
-std::string CanonicalizeHost(const std::string& host) {
- url_canon::CanonHostInfo info;
- return net::CanonicalizeHost(host, &info);
-}
-
-bool IsValidHost(const std::string& host) {
- std::string canonicalized_host = CanonicalizeHost(host);
- return !canonicalized_host.empty();
-}
-
} // namespace
namespace options2 {
-class ContentSettingsHandler::ExContentSettingsType {
- public:
- explicit ExContentSettingsType(int value) : value_(value) {
- DCHECK(value_ < EX_CONTENT_SETTINGS_NUM_TYPES);
- }
- explicit ExContentSettingsType(ContentSettingsType type) : value_(type) {}
- explicit ExContentSettingsType(ExContentSettingsTypeEnum type)
- : value_(type) {}
-
- bool IsExtraContentSettingsType() const {
- return value_ >= CONTENT_SETTINGS_NUM_TYPES;
- }
-
- operator int() const { return value_; }
-
- ContentSettingsType ToContentSettingsType() const {
- DCHECK(value_ < CONTENT_SETTINGS_NUM_TYPES);
- return static_cast<ContentSettingsType>(value_);
- }
-
- private:
- int value_;
-};
-
-ContentSettingsHandler::CachedPepperFlashSettings::CachedPepperFlashSettings()
- : default_permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_BLOCK),
- initialized(false) {
-}
-
-ContentSettingsHandler::CachedPepperFlashSettings::~CachedPepperFlashSettings() {
-}
-
-struct ContentSettingsHandler::ExContentSettingsTypeNameEntry {
- ExContentSettingsType type;
- const char* name;
-};
-
-const ContentSettingsHandler::ExContentSettingsTypeNameEntry
- ContentSettingsHandler::kExContentSettingsTypeGroupNames[] = {
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_COOKIES), "cookies"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_IMAGES), "images"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_JAVASCRIPT), "javascript"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_PLUGINS), "plugins"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_POPUPS), "popups"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_GEOLOCATION), "location"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS), "notifications"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_INTENTS), "intents"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE),
- "auto-select-certificate"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_FULLSCREEN), "fullscreen"},
- {ExContentSettingsType(CONTENT_SETTINGS_TYPE_MOUSELOCK), "mouselock"},
- {ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC),
- "pepper-flash-cameramic"},
-};
-
ContentSettingsHandler::ContentSettingsHandler() {
}
@@ -402,12 +328,6 @@
{ "mouselock_allow", IDS_MOUSE_LOCK_ALLOW_RADIO },
{ "mouselock_ask", IDS_MOUSE_LOCK_ASK_RADIO },
{ "mouselock_block", IDS_MOUSE_LOCK_BLOCK_RADIO },
- // Pepper Flash camera and microphone filter.
- { "pepperFlashCameramicTabLabel", IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL },
- // The header has to be named as <content_type_name>_header.
- { "pepper-flash-cameramic_header", IDS_PEPPER_FLASH_CAMERAMIC_HEADER },
- { "pepperFlashCameramicAsk", IDS_PEPPER_FLASH_CAMERAMIC_ASK_RADIO },
- { "pepperFlashCameramicBlock", IDS_PEPPER_FLASH_CAMERAMIC_BLOCK_RADIO },
#if defined(OS_CHROMEOS)
// Protected Content filter
{ "protectedContentTabLabel", IDS_PROTECTED_CONTENT_TAB_LABEL },
@@ -440,8 +360,6 @@
IDS_FULLSCREEN_TAB_LABEL);
RegisterTitle(localized_strings, "mouselock",
IDS_MOUSE_LOCK_TAB_LABEL);
- RegisterTitle(localized_strings, "pepper-flash-cameramic",
- IDS_PEPPER_FLASH_CAMERAMIC_TAB_LABEL);
Profile* profile = Profile::FromWebUI(web_ui());
localized_strings->SetBoolean(
@@ -475,18 +393,11 @@
PrefService* prefs = profile->GetPrefs();
pref_change_registrar_.Init(prefs);
pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
- pref_change_registrar_.Add(prefs::kPepperFlashSettingsEnabled, this);
-
- flash_settings_manager_.reset(new PepperFlashSettingsManager(this, profile));
}
void ContentSettingsHandler::InitializePage() {
UpdateHandlersEnabledRadios();
UpdateAllExceptionsViewsFromModel();
-
- flash_cameramic_settings_ = CachedPepperFlashSettings();
- flash_settings_manager_->GetPermissionSettings(
- PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC);
}
void ContentSettingsHandler::Observe(
@@ -520,27 +431,18 @@
content::Details<const ContentSettingsDetails>(details).ptr();
// TODO(estade): we pretend update_all() is always true.
- if (settings_details->update_all_types()) {
+ if (settings_details->update_all_types())
UpdateAllExceptionsViewsFromModel();
- } else {
- UpdateExceptionsViewFromModel(
- ExContentSettingsType(settings_details->type()));
- }
+ else
+ UpdateExceptionsViewFromModel(settings_details->type());
break;
}
case chrome::NOTIFICATION_PREF_CHANGED: {
const std::string& pref_name =
*content::Details<std::string>(details).ptr();
- if (pref_name == prefs::kGeolocationContentSettings) {
+ if (pref_name == prefs::kGeolocationContentSettings)
UpdateGeolocationExceptionsView();
- } else if (pref_name == prefs::kPepperFlashSettingsEnabled) {
- if (!flash_cameramic_settings_.initialized) {
- flash_settings_manager_->GetPermissionSettings(
- PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC);
- }
- }
-
break;
}
@@ -559,36 +461,15 @@
}
}
-void ContentSettingsHandler::OnGetPermissionSettingsCompleted(
- uint32 /* request_id */,
- bool success,
- PP_Flash_BrowserOperations_Permission default_permission,
- const ppapi::FlashSiteSettings& sites) {
- if (success && !flash_cameramic_settings_.initialized) {
- flash_cameramic_settings_.initialized = true;
- flash_cameramic_settings_.default_permission = default_permission;
- for (ppapi::FlashSiteSettings::const_iterator iter = sites.begin();
- iter != sites.end(); ++iter) {
- if (IsValidHost(iter->site))
- flash_cameramic_settings_.sites[iter->site] = iter->permission;
- }
- UpdateExceptionsViewFromModel(
- ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC));
-
- web_ui()->CallJavascriptFunction(
- "ContentSettings.enablePepperFlashCameraMicSettings");
- }
-}
-
void ContentSettingsHandler::UpdateSettingDefaultFromModel(
- const ExContentSettingsType& type) {
+ ContentSettingsType type) {
DictionaryValue filter_settings;
std::string provider_id;
+ filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
+ GetSettingDefaultFromModel(type, &provider_id));
filter_settings.SetString(
- ExContentSettingsTypeToGroupName(type) + ".value",
- GetSettingDefaultFromModel(type, &provider_id));
- filter_settings.SetString(
- ExContentSettingsTypeToGroupName(type) + ".managedBy", provider_id);
+ ContentSettingsTypeToGroupName(type) + ".managedBy",
+ provider_id);
web_ui()->CallJavascriptFunction(
"ContentSettings.setContentFilterSettingsValue", filter_settings);
@@ -597,21 +478,17 @@
}
std::string ContentSettingsHandler::GetSettingDefaultFromModel(
- const ExContentSettingsType& type, std::string* provider_id) {
+ ContentSettingsType type, std::string* provider_id) {
Profile* profile = Profile::FromWebUI(web_ui());
ContentSetting default_setting;
if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
default_setting =
DesktopNotificationServiceFactory::GetForProfile(profile)->
GetDefaultContentSetting(provider_id);
- } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) {
- default_setting = FlashPermissionToContentSetting(
- flash_cameramic_settings_.default_permission);
- *provider_id = kDefaultProviderID;
} else {
default_setting =
profile->GetHostContentSettingsMap()->
- GetDefaultContentSetting(type.ToContentSettingsType(), provider_id);
+ GetDefaultContentSetting(type, provider_id);
}
return ContentSettingToString(default_setting);
@@ -628,25 +505,25 @@
void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() {
for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1;
- type < EX_CONTENT_SETTINGS_NUM_TYPES; ++type) {
+ type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
// The content settings type CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE
// is supposed to be set by policy only. Hence there is no user facing UI
// for this content type and we skip it here.
if (type == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE)
continue;
- UpdateExceptionsViewFromModel(ExContentSettingsType(type));
+ UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type));
}
}
void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() {
for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1;
- type < EX_CONTENT_SETTINGS_NUM_TYPES; ++type) {
- UpdateOTRExceptionsViewFromModel(ExContentSettingsType(type));
+ type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
+ UpdateOTRExceptionsViewFromModel(static_cast<ContentSettingsType>(type));
}
}
void ContentSettingsHandler::UpdateExceptionsViewFromModel(
- const ExContentSettingsType& type) {
+ ContentSettingsType type) {
// Don't update intents settings at this point.
// Turn on when enable_web_intents_tag is enabled.
if (type == CONTENT_SETTINGS_TYPE_INTENTS)
@@ -659,28 +536,22 @@
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
UpdateNotificationExceptionsView();
break;
- case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC:
- UpdateFlashCameraMicExceptionsView();
- break;
default:
- UpdateExceptionsViewFromHostContentSettingsMap(
- type.ToContentSettingsType());
+ UpdateExceptionsViewFromHostContentSettingsMap(type);
break;
}
}
void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel(
- const ExContentSettingsType& type) {
+ ContentSettingsType type) {
switch (type) {
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
case CONTENT_SETTINGS_TYPE_INTENTS:
case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
- case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC:
break;
default:
- UpdateExceptionsViewFromOTRHostContentSettingsMap(
- type.ToContentSettingsType());
+ UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
break;
}
}
@@ -704,7 +575,7 @@
// Don't add default settings.
if (i->primary_pattern == ContentSettingsPattern::Wildcard() &&
i->secondary_pattern == ContentSettingsPattern::Wildcard() &&
- i->source != kPreferencesSource) {
+ i->source != "preferences") {
continue;
}
all_patterns_settings[i->primary_pattern][i->secondary_pattern] =
@@ -751,8 +622,7 @@
// This is mainly here to keep this function ideologically parallel to
// UpdateExceptionsViewFromHostContentSettingsMap().
- UpdateSettingDefaultFromModel(
- ExContentSettingsType(CONTENT_SETTINGS_TYPE_GEOLOCATION));
+ UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION);
}
void ContentSettingsHandler::UpdateNotificationExceptionsView() {
@@ -774,7 +644,7 @@
// Don't add default settings.
if (i->primary_pattern == ContentSettingsPattern::Wildcard() &&
i->secondary_pattern == ContentSettingsPattern::Wildcard() &&
- i->source != kPreferencesSource) {
+ i->source != "preferences") {
continue;
}
@@ -790,33 +660,9 @@
// This is mainly here to keep this function ideologically parallel to
// UpdateExceptionsViewFromHostContentSettingsMap().
- UpdateSettingDefaultFromModel(
- ExContentSettingsType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
+ UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
}
-void ContentSettingsHandler::UpdateFlashCameraMicExceptionsView() {
- ListValue exceptions;
- for (CachedPepperFlashSettings::SiteMap::iterator iter =
- flash_cameramic_settings_.sites.begin();
- iter != flash_cameramic_settings_.sites.end(); ++iter) {
- DictionaryValue* exception = new DictionaryValue();
- exception->SetString(kDisplayPattern, iter->first);
- exception->SetString(
- kSetting,
- ContentSettingToString(FlashPermissionToContentSetting(iter->second)));
- exception->SetString(kSource, kPreferencesSource);
- exceptions.Append(exception);
- }
-
- StringValue type_string(ExContentSettingsTypeToGroupName(
- ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC)));
- web_ui()->CallJavascriptFunction("ContentSettings.setExceptions",
- type_string, exceptions);
-
- UpdateSettingDefaultFromModel(
- ExContentSettingsType(EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC));
-}
-
void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
ContentSettingsType type) {
ContentSettingsForOneType entries;
@@ -860,7 +706,7 @@
// The default may also have changed (we won't get a separate notification).
// If it hasn't changed, this call will be harmless.
- UpdateSettingDefaultFromModel(ExContentSettingsType(type));
+ UpdateSettingDefaultFromModel(type);
}
void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
@@ -956,8 +802,7 @@
}
ContentSetting default_setting = ContentSettingFromString(setting);
- ExContentSettingsType content_type =
- ExContentSettingsTypeFromGroupName(group);
+ ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group);
Profile* profile = Profile::FromWebUI(web_ui());
#if defined(OS_CHROMEOS)
@@ -970,17 +815,10 @@
if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
DesktopNotificationServiceFactory::GetForProfile(profile)->
SetDefaultContentSetting(default_setting);
- } else if (content_type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) {
- flash_cameramic_settings_.default_permission =
- FlashPermissionFromContentSetting(default_setting);
- flash_settings_manager_->SetDefaultPermission(
- PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC,
- flash_cameramic_settings_.default_permission, false);
} else {
HostContentSettingsMap* map = profile->GetHostContentSettingsMap();
- ContentSettingsType converted_type = content_type.ToContentSettingsType();
- ApplyWhitelist(converted_type, default_setting);
- map->SetDefaultContentSetting(converted_type, default_setting);
+ ApplyWhitelist(content_type, default_setting);
+ map->SetDefaultContentSetting(content_type, default_setting);
}
switch (content_type) {
case CONTENT_SETTINGS_TYPE_COOKIES:
@@ -1019,10 +857,6 @@
content::RecordAction(
UserMetricsAction("Options_DefaultMouseLockSettingChanged"));
break;
- case EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC:
- content::RecordAction(
- UserMetricsAction("Options_DefaultFlashCameraMicSettingChanged"));
- break;
default:
break;
}
@@ -1034,8 +868,7 @@
CHECK(args->GetString(arg_i++, &type_string));
Profile* profile = Profile::FromWebUI(web_ui());
- ExContentSettingsType type = ExContentSettingsTypeFromGroupName(
- type_string);
+ ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
std::string origin;
std::string embedding_origin;
@@ -1072,37 +905,18 @@
rv = args->GetString(arg_i++, &pattern);
DCHECK(rv);
- if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) {
- DCHECK_EQ(mode, "normal");
-
- CachedPepperFlashSettings::SiteMap::iterator iter =
- flash_cameramic_settings_.sites.find(pattern);
- if (iter != flash_cameramic_settings_.sites.end()) {
- flash_cameramic_settings_.sites.erase(iter);
- ppapi::FlashSiteSettings site_settings(1,
- ppapi::FlashSiteSetting(
- pattern, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT));
- flash_settings_manager_->SetSitePermission(
- PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC,
- site_settings);
- } else {
- NOTREACHED();
- }
- UpdateFlashCameraMicExceptionsView();
- } else {
- HostContentSettingsMap* settings_map =
- mode == "normal" ? GetContentSettingsMap() :
- GetOTRContentSettingsMap();
- // The settings map could be null if the mode was OTR but the OTR profile
- // got destroyed before we received this message.
- if (settings_map) {
- settings_map->SetContentSetting(
- ContentSettingsPattern::FromString(pattern),
- ContentSettingsPattern::Wildcard(),
- type.ToContentSettingsType(),
- "",
- CONTENT_SETTING_DEFAULT);
- }
+ HostContentSettingsMap* settings_map =
+ mode == "normal" ? GetContentSettingsMap() :
+ GetOTRContentSettingsMap();
+ // The settings map could be null if the mode was OTR but the OTR profile
+ // got destroyed before we received this message.
+ if (settings_map) {
+ settings_map->SetContentSetting(
+ ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
+ ContentSettingsTypeFromGroupName(type_string),
+ "",
+ CONTENT_SETTING_DEFAULT);
}
}
}
@@ -1118,71 +932,48 @@
std::string setting;
CHECK(args->GetString(arg_i++, &setting));
- ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string);
+ ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
NOTREACHED();
- } else if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) {
- DCHECK(IsValidHost(pattern));
+ return;
+ }
- if (flash_cameramic_settings_.sites.find(pattern) ==
- flash_cameramic_settings_.sites.end()) {
- pattern = CanonicalizeHost(pattern);
- }
- PP_Flash_BrowserOperations_Permission permission =
- FlashPermissionFromContentSetting(ContentSettingFromString(setting));
- flash_cameramic_settings_.sites[pattern] = permission;
- ppapi::FlashSiteSettings
- site_settings(1, ppapi::FlashSiteSetting(pattern, permission));
- flash_settings_manager_->SetSitePermission(
- PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC,
- site_settings);
- UpdateFlashCameraMicExceptionsView();
- } else {
- HostContentSettingsMap* settings_map =
- mode == "normal" ? GetContentSettingsMap() :
- GetOTRContentSettingsMap();
+ HostContentSettingsMap* settings_map =
+ mode == "normal" ? GetContentSettingsMap() :
+ GetOTRContentSettingsMap();
- // The settings map could be null if the mode was OTR but the OTR profile
- // got destroyed before we received this message.
- if (!settings_map)
- return;
- settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
- ContentSettingsPattern::Wildcard(),
- type.ToContentSettingsType(),
- "",
- ContentSettingFromString(setting));
- }
+ // The settings map could be null if the mode was OTR but the OTR profile
+ // got destroyed before we received this message.
+ if (!settings_map)
+ return;
+ settings_map->SetContentSetting(ContentSettingsPattern::FromString(pattern),
+ ContentSettingsPattern::Wildcard(),
+ type,
+ "",
+ ContentSettingFromString(setting));
}
void ContentSettingsHandler::CheckExceptionPatternValidity(
const ListValue* args) {
size_t arg_i = 0;
- std::string type_string;
- CHECK(args->GetString(arg_i++, &type_string));
+ Value* type;
+ CHECK(args->Get(arg_i++, &type));
std::string mode_string;
CHECK(args->GetString(arg_i++, &mode_string));
std::string pattern_string;
CHECK(args->GetString(arg_i++, &pattern_string));
- ExContentSettingsType type = ExContentSettingsTypeFromGroupName(type_string);
- bool is_valid = false;
- if (type == EX_CONTENT_SETTINGS_TYPE_PEPPER_FLASH_CAMERAMIC) {
- is_valid = IsValidHost(pattern_string);
- } else {
- ContentSettingsPattern pattern =
- ContentSettingsPattern::FromString(pattern_string);
- is_valid = pattern.IsValid();
- }
+ ContentSettingsPattern pattern =
+ ContentSettingsPattern::FromString(pattern_string);
- scoped_ptr<Value> type_value(Value::CreateStringValue(type_string));
scoped_ptr<Value> mode_value(Value::CreateStringValue(mode_string));
scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string));
- scoped_ptr<Value> valid_value(Value::CreateBooleanValue(is_valid));
+ scoped_ptr<Value> valid_value(Value::CreateBooleanValue(pattern.IsValid()));
web_ui()->CallJavascriptFunction(
"ContentSettings.patternValidityCheckComplete",
- *type_value.get(),
+ *type,
*mode_value.get(),
*pattern_value.get(),
*valid_value.get());
@@ -1191,7 +982,13 @@
// static
std::string ContentSettingsHandler::ContentSettingsTypeToGroupName(
ContentSettingsType type) {
- return ExContentSettingsTypeToGroupName(ExContentSettingsType(type));
+ for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
+ if (type == kContentSettingsTypeGroupNames[i].type)
+ return kContentSettingsTypeGroupNames[i].name;
+ }
+
+ NOTREACHED();
+ return std::string();
}
HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() {
@@ -1210,33 +1007,4 @@
return NULL;
}
-// static
-ContentSettingsHandler::ExContentSettingsType
- ContentSettingsHandler::ExContentSettingsTypeFromGroupName(
- const std::string& name) {
- COMPILE_ASSERT(arraysize(kExContentSettingsTypeGroupNames) ==
- EX_CONTENT_SETTINGS_NUM_TYPES,
- MISSING_CONTENT_SETTINGS_TYPE);
-
- for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) {
- if (name == kExContentSettingsTypeGroupNames[i].name)
- return kExContentSettingsTypeGroupNames[i].type;
- }
-
- NOTREACHED() << name << " is not a recognized content settings type.";
- return ExContentSettingsType(CONTENT_SETTINGS_TYPE_DEFAULT);
-}
-
-// static
-std::string ContentSettingsHandler::ExContentSettingsTypeToGroupName(
- const ExContentSettingsType& type) {
- for (size_t i = 0; i < arraysize(kExContentSettingsTypeGroupNames); ++i) {
- if (type == kExContentSettingsTypeGroupNames[i].type)
- return kExContentSettingsTypeGroupNames[i].name;
- }
-
- NOTREACHED();
- return std::string();
-}
-
} // namespace options2
« no previous file with comments | « chrome/browser/ui/webui/options2/content_settings_handler2.h ('k') | chrome/tools/chromeactions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698