Chromium Code Reviews| Index: chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc |
| diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc |
| index 391643ecb216e836487042777be37a7f0decf607..5a3747bebedf87aed01a26ed2e7530ae67611ae5 100644 |
| --- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc |
| +++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc |
| @@ -4,9 +4,15 @@ |
| #include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h" |
| +#include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/common/extensions/permissions/permissions_data.h" |
| +#include "chrome/common/extensions/permissions/settings_override_permission.h" |
| #include "extensions/common/error_utils.h" |
| #include "extensions/common/manifest_constants.h" |
| +#include "extensions/common/permissions/api_permission_set.h" |
| +#include "extensions/common/permissions/permissions_info.h" |
| +#include "url/gurl.h" |
| using extensions::api::manifest_types::ChromeSettingsOverrides; |
| @@ -54,6 +60,16 @@ std::vector<GURL> ParseStartupPage(const ChromeSettingsOverrides& overrides, |
| return urls; |
| } |
| +// When we display a full URL for a permission confirmation, we don't want to |
| +// see the scheme, and also remove www. if present. |
|
gab
2013/11/01 22:35:40
I would quote the "www." here; otherwise the '.' f
MAD
2013/11/03 02:21:20
Done.
|
| +std::string GetURLDisplayText(const GURL& url) { |
| + // GetContent skips the scheme. |
| + std::string result(url.GetContent()); |
|
gab
2013/11/01 22:35:40
static const char kWwwPrefix[] = "www.";
and use
MAD
2013/11/03 02:21:20
Done.
|
| + if (StartsWithASCII(result, "www.", false)) |
| + result = result.substr(4); |
| + return result; |
| +} |
| + |
| } // namespace |
| SettingsOverrides::SettingsOverrides() {} |
| @@ -86,6 +102,25 @@ bool SettingsOverridesHandler::Parse(Extension* extension, string16* error) { |
| *error = ASCIIToUTF16(manifest_errors::kInvalidEmptySettingsOverrides); |
| return false; |
| } |
| + APIPermissionSet* permission_set = |
| + PermissionsData::GetInitialAPIPermissions(extension); |
|
gab
2013/11/01 22:35:40
Feels kind of weird to use a static call to get da
gab
2013/11/01 22:35:40
This method states this is only non-NULL during ex
MAD
2013/11/03 02:21:20
Done.
MAD
2013/11/03 02:21:20
It's because it needs to go through private data..
|
| + if (info->search_engine) { |
| + permission_set->insert(new SettingsOverrideAPIPermission( |
| + PermissionsInfo::GetInstance()->GetByID(APIPermission::kSearchSettings), |
| + CreateManifestURL(info->search_engine->search_url)-> |
|
gab
2013/11/01 22:35:40
Why doesn't this use GetURLDisplayText()?
MAD
2013/11/03 02:21:20
This was because it doesn't have the same needs, s
|
| + GetOrigin().host())); |
| + } |
| + if (!info->startup_pages.empty()) { |
| + permission_set->insert(new SettingsOverrideAPIPermission( |
| + PermissionsInfo::GetInstance()->GetByID(APIPermission::kStartupPages), |
| + // We only support one startup page. |
| + GetURLDisplayText(info->startup_pages[0]))); |
| + } |
| + if (info->homepage) { |
| + permission_set->insert(new SettingsOverrideAPIPermission( |
| + PermissionsInfo::GetInstance()->GetByID(APIPermission::kHomePage), |
| + GetURLDisplayText(*info->homepage.get()))); |
| + } |
| extension->SetManifestData(manifest_keys::kSettingsOverride, |
| info.release()); |
| return true; |