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

Unified Diff: chrome/browser/ui/webui/settings/site_settings_handler.cc

Issue 2350303004: Site Settings Desktop: Fix crash when altering exception. (Closed)
Patch Set: Address feedback Created 4 years, 3 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/ui/webui/settings/site_settings_handler.cc
diff --git a/chrome/browser/ui/webui/settings/site_settings_handler.cc b/chrome/browser/ui/webui/settings/site_settings_handler.cc
index 90f2b508f7b82ece96fd8a309d3654a832afd331..99b417a3a863916063df84e6e33690b013d58533 100644
--- a/chrome/browser/ui/webui/settings/site_settings_handler.cc
+++ b/chrome/browser/ui/webui/settings/site_settings_handler.cc
@@ -40,8 +40,6 @@ namespace settings {
namespace {
-const char kAppName[] = "appName";
-const char kAppId[] = "appId";
const char kZoom[] = "zoom";
// Return an appropriate API Permission ID for the given string name.
@@ -61,25 +59,6 @@ extensions::APIPermission::APIPermission::ID APIPermissionFromGroupName(
return extensions::APIPermission::APIPermission::kInvalid;
}
-// Add an "Allow"-entry to the list of |exceptions| for a |url_pattern| from
-// the web extent of a hosted |app|.
-void AddExceptionForHostedApp(const std::string& url_pattern,
- const extensions::Extension& app, base::ListValue* exceptions) {
- std::unique_ptr<base::DictionaryValue> exception(new base::DictionaryValue());
-
- std::string setting_string =
- content_settings::ContentSettingToString(CONTENT_SETTING_ALLOW);
- DCHECK(!setting_string.empty());
-
- exception->SetString(site_settings::kSetting, setting_string);
- exception->SetString(site_settings::kOrigin, url_pattern);
- exception->SetString(site_settings::kEmbeddingOrigin, url_pattern);
- exception->SetString(site_settings::kSource, "HostedApp");
- exception->SetString(kAppName, app.name());
- exception->SetString(kAppId, app.id());
- exceptions->Append(std::move(exception));
-}
-
// Asks the |profile| for hosted apps which have the |permission| set, and
// adds their web extent and launch URL to the |exceptions| list.
void AddExceptionsGrantedByHostedApps(content::BrowserContext* context,
@@ -98,7 +77,8 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context,
for (extensions::URLPatternSet::const_iterator pattern = web_extent.begin();
pattern != web_extent.end(); ++pattern) {
std::string url_pattern = pattern->GetAsString();
- AddExceptionForHostedApp(url_pattern, *extension->get(), exceptions);
+ site_settings::AddExceptionForHostedApp(
+ url_pattern, *extension->get(), exceptions);
}
// Retrieve the launch URL.
GURL launch_url =
@@ -106,7 +86,8 @@ void AddExceptionsGrantedByHostedApps(content::BrowserContext* context,
// Skip adding the launch URL if it is part of the web extent.
if (web_extent.MatchesURL(launch_url))
continue;
- AddExceptionForHostedApp(launch_url.spec(), *extension->get(), exceptions);
+ site_settings::AddExceptionForHostedApp(
+ launch_url.spec(), *extension->get(), exceptions);
}
}

Powered by Google App Engine
This is Rietveld 408576698