summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-06 05:04:36 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-06 05:04:36 +0000
commita6910e7458ad8ce393b97696307230ceb12a6b77 (patch)
tree24afa5b7b8a8c41a24755007e747a67b084d744f /chrome/browser
parentbebb1a87602202e572d4a817d5aa047d32a70cf0 (diff)
downloadchromium_src-a6910e7458ad8ce393b97696307230ceb12a6b77.zip
chromium_src-a6910e7458ad8ce393b97696307230ceb12a6b77.tar.gz
chromium_src-a6910e7458ad8ce393b97696307230ceb12a6b77.tar.bz2
Remove PermissionsData::ForExtension() completely
There's no reason to have this. It was originally because PermissionsData didn't really belong on Extension (and was to be taken off), but now that PermissionsData is refactored to only include active permissions, it belongs on the extension object. TBR=ben@chromium.org (c/b/ui - simple refactor, no functional changes) TBR=thestig@chromium.org (c/b/media_galleries - simple refactor, no functional changes) BUG=379356 Review URL: https://codereview.chromium.org/315573003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/apps/ephemeral_app_launcher.cc3
-rw-r--r--chrome/browser/chrome_content_browser_client.cc2
-rw-r--r--chrome/browser/extensions/active_script_controller.cc9
-rw-r--r--chrome/browser/extensions/active_tab_permission_granter.cc6
-rw-r--r--chrome/browser/extensions/active_tab_unittest.cc11
-rw-r--r--chrome/browser/extensions/api/automation_internal/automation_internal_api.cc2
-rw-r--r--chrome/browser/extensions/api/autotest_private/autotest_private_api.cc28
-rw-r--r--chrome/browser/extensions/api/commands/command_service.cc8
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api.cc3
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_helpers.cc3
-rw-r--r--chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc2
-rw-r--r--chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc4
-rw-r--r--chrome/browser/extensions/api/hid/hid_api.cc8
-rw-r--r--chrome/browser/extensions/api/management/management_api.cc2
-rw-r--r--chrome/browser/extensions/api/media_galleries/media_galleries_api.cc5
-rw-r--r--chrome/browser/extensions/api/tab_capture/tab_capture_api.cc4
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_api.cc40
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_api.cc4
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_permissions.cc6
-rw-r--r--chrome/browser/extensions/browser_permissions_policy_delegate_unittest.cc3
-rw-r--r--chrome/browser/extensions/bundle_installer.cc3
-rw-r--r--chrome/browser/extensions/crx_installer.cc9
-rw-r--r--chrome/browser/extensions/extension_gcm_app_handler.cc3
-rw-r--r--chrome/browser/extensions/extension_install_prompt.cc2
-rw-r--r--chrome/browser/extensions/extension_keybinding_apitest.cc2
-rw-r--r--chrome/browser/extensions/extension_service.cc6
-rw-r--r--chrome/browser/extensions/extension_tab_util.cc7
-rw-r--r--chrome/browser/extensions/permissions_updater.cc2
-rw-r--r--chrome/browser/media_galleries/media_galleries_dialog_controller.cc2
-rw-r--r--chrome/browser/media_galleries/media_galleries_preferences.cc7
-rw-r--r--chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.cc2
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm8
-rw-r--r--chrome/browser/ui/omnibox/location_bar.cc2
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc11
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc7
35 files changed, 102 insertions, 124 deletions
diff --git a/chrome/browser/apps/ephemeral_app_launcher.cc b/chrome/browser/apps/ephemeral_app_launcher.cc
index ed6405c..d95e833 100644
--- a/chrome/browser/apps/ephemeral_app_launcher.cc
+++ b/chrome/browser/apps/ephemeral_app_launcher.cc
@@ -175,8 +175,7 @@ EphemeralAppLauncher::CreateInstallPrompt() const {
// Skip the prompt by returning null if the app does not need to display
// permission warnings.
extensions::PermissionMessages permissions =
- extensions::PermissionsData::ForExtension(extension_)
- ->GetPermissionMessages();
+ extension_->permissions_data()->GetPermissionMessages();
if (permissions.empty())
return scoped_ptr<ExtensionInstallPrompt::Prompt>();
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 0c8f733..573d1c8 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -2508,7 +2508,7 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI(
const Extension* extension = extension_set->GetByID(url.host());
if (extension) {
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(extension);
+ extension->permissions_data();
if (params) {
extensions::SocketPermission::CheckParam check_params(
params->type, params->host, params->port);
diff --git a/chrome/browser/extensions/active_script_controller.cc b/chrome/browser/extensions/active_script_controller.cc
index 1ea6295..62d1ce5 100644
--- a/chrome/browser/extensions/active_script_controller.cc
+++ b/chrome/browser/extensions/active_script_controller.cc
@@ -73,11 +73,10 @@ ActiveScriptController* ActiveScriptController::GetForWebContents(
bool ActiveScriptController::RequiresUserConsentForScriptInjection(
const Extension* extension) {
CHECK(extension);
- if (!PermissionsData::ForExtension(extension)
- ->RequiresActionForScriptExecution(
- extension,
- SessionID::IdForTab(web_contents()),
- web_contents()->GetVisibleURL()) ||
+ if (!extension->permissions_data()->RequiresActionForScriptExecution(
+ extension,
+ SessionID::IdForTab(web_contents()),
+ web_contents()->GetVisibleURL()) ||
util::AllowedScriptingOnAllUrls(extension->id(),
web_contents()->GetBrowserContext())) {
return false;
diff --git a/chrome/browser/extensions/active_tab_permission_granter.cc b/chrome/browser/extensions/active_tab_permission_granter.cc
index 995cce4..978bbfc 100644
--- a/chrome/browser/extensions/active_tab_permission_granter.cc
+++ b/chrome/browser/extensions/active_tab_permission_granter.cc
@@ -43,8 +43,7 @@ void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
APIPermissionSet new_apis;
URLPatternSet new_hosts;
- const PermissionsData* permissions_data =
- PermissionsData::ForExtension(extension);
+ const PermissionsData* permissions_data = extension->permissions_data();
// If the extension requires action for script execution, we grant it
// active tab-style permissions, even if it doesn't have the activeTab
@@ -125,8 +124,7 @@ void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() {
for (ExtensionSet::const_iterator it = granted_extensions_.begin();
it != granted_extensions_.end(); ++it) {
- PermissionsData::ForExtension(it->get())
- ->ClearTabSpecificPermissions(tab_id_);
+ it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_);
extension_ids.push_back((*it)->id());
}
diff --git a/chrome/browser/extensions/active_tab_unittest.cc b/chrome/browser/extensions/active_tab_unittest.cc
index 93be34e..6f7823a 100644
--- a/chrome/browser/extensions/active_tab_unittest.cc
+++ b/chrome/browser/extensions/active_tab_unittest.cc
@@ -107,8 +107,7 @@ class ActiveTabTest : public ChromeRenderViewHostTestHarness {
const GURL& url,
PermittedFeature feature,
int tab_id) {
- const PermissionsData* permissions_data =
- PermissionsData::ForExtension(extension);
+ const PermissionsData* permissions_data = extension->permissions_data();
bool script = permissions_data->CanExecuteScriptOnPage(
extension, url, url, tab_id, NULL, -1, NULL);
bool capture = HasTabsPermission(extension, tab_id) &&
@@ -144,13 +143,13 @@ class ActiveTabTest : public ChromeRenderViewHostTestHarness {
bool HasTabsPermission(const scoped_refptr<const Extension>& extension,
int tab_id) {
- return PermissionsData::ForExtension(extension)
- ->HasAPIPermissionForTab(tab_id, APIPermission::kTab);
+ return extension->permissions_data()->HasAPIPermissionForTab(
+ tab_id, APIPermission::kTab);
}
bool IsGrantedForTab(const Extension* extension,
const content::WebContents* web_contents) {
- return PermissionsData::ForExtension(extension)->HasAPIPermissionForTab(
+ return extension->permissions_data()->HasAPIPermissionForTab(
SessionID::IdForTab(web_contents), APIPermission::kTab);
}
@@ -370,7 +369,7 @@ TEST_F(ActiveTabTest, ChromeUrlGrants) {
EXPECT_TRUE(IsAllowed(extension_with_tab_capture, internal,
PERMITTED_CAPTURE_ONLY));
const PermissionsData* permissions_data =
- PermissionsData::ForExtension(extension_with_tab_capture);
+ extension_with_tab_capture->permissions_data();
EXPECT_TRUE(permissions_data->HasAPIPermissionForTab(
tab_id(), APIPermission::kTabCaptureForTab));
diff --git a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
index ff816df..cf03b4b 100644
--- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
+++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc
@@ -59,7 +59,7 @@ bool CanRequestAutomation(const Extension* extension,
content::RenderProcessHost* process = contents->GetRenderProcessHost();
int process_id = process ? process->GetID() : -1;
std::string unused_error;
- return PermissionsData::ForExtension(extension)->CanExecuteScriptOnPage(
+ return extension->permissions_data()->CanExecuteScriptOnPage(
extension, url, url, tab_id, NULL, process_id, &unused_error);
}
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index d31c58e..d5a3fe6 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -32,17 +32,16 @@ namespace extensions {
namespace {
base::ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) {
- extensions::URLPatternSet pattern_set;
- if (effective_perm) {
- pattern_set = extensions::PermissionsData::ForExtension(ext)
- ->GetEffectiveHostPermissions();
- } else {
+ URLPatternSet pattern_set;
+ if (effective_perm)
+ pattern_set = ext->permissions_data()->GetEffectiveHostPermissions();
+ else
pattern_set = ext->GetActivePermissions()->explicit_hosts();
- }
base::ListValue* permissions = new base::ListValue;
- for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin();
- perm != pattern_set.end(); ++perm) {
+ for (URLPatternSet::const_iterator perm = pattern_set.begin();
+ perm != pattern_set.end();
+ ++perm) {
permissions->Append(new base::StringValue(perm->GetAsString()));
}
@@ -150,10 +149,9 @@ bool AutotestPrivateLockScreenFunction::RunSync() {
bool AutotestPrivateGetExtensionsInfoFunction::RunSync() {
DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction";
- ExtensionService* service = extensions::ExtensionSystem::Get(
- GetProfile())->extension_service();
- ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(GetProfile());
+ ExtensionService* service =
+ ExtensionSystem::Get(GetProfile())->extension_service();
+ ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
const ExtensionSet& extensions = registry->enabled_extensions();
const ExtensionSet& disabled_extensions = registry->disabled_extensions();
ExtensionActionManager* extension_action_manager =
@@ -173,10 +171,10 @@ bool AutotestPrivateGetExtensionsInfoFunction::RunSync() {
extension_value->SetString("name", extension->name());
extension_value->SetString("publicKey", extension->public_key());
extension_value->SetString("description", extension->description());
- extension_value->SetString("backgroundUrl",
- extensions::BackgroundInfo::GetBackgroundURL(extension).spec());
+ extension_value->SetString(
+ "backgroundUrl", BackgroundInfo::GetBackgroundURL(extension).spec());
extension_value->SetString("optionsUrl",
- extensions::ManifestURL::GetOptionsPage(extension).spec());
+ ManifestURL::GetOptionsPage(extension).spec());
extension_value->Set("hostPermissions",
GetHostPermissions(extension, false));
diff --git a/chrome/browser/extensions/api/commands/command_service.cc b/chrome/browser/extensions/api/commands/command_service.cc
index 89f8b2a..ff447eb 100644
--- a/chrome/browser/extensions/api/commands/command_service.cc
+++ b/chrome/browser/extensions/api/commands/command_service.cc
@@ -171,8 +171,8 @@ bool CommandService::RemovesBookmarkShortcut(const Extension* extension) {
SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) ||
(ui_overrides &&
UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) &&
- (PermissionsData::ForExtension(extension)
- ->HasAPIPermission(APIPermission::kBookmarkManagerPrivate) ||
+ (extension->permissions_data()->HasAPIPermission(
+ APIPermission::kBookmarkManagerPrivate) ||
FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled());
}
@@ -188,8 +188,8 @@ bool CommandService::RemovesBookmarkOpenPagesShortcut(
*settings_overrides)) ||
(ui_overrides &&
UIOverrides::RemovesBookmarkOpenPagesShortcut(*ui_overrides))) &&
- (PermissionsData::ForExtension(extension)
- ->HasAPIPermission(APIPermission::kBookmarkManagerPrivate) ||
+ (extension->permissions_data()->HasAPIPermission(
+ APIPermission::kBookmarkManagerPrivate) ||
FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled());
}
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index b03a05a..cbb93dc 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -62,8 +62,7 @@ bool ParseUrl(ChromeAsyncExtensionFunction* function,
}
// Check against host permissions if needed.
if (check_host_permissions &&
- !PermissionsData::ForExtension(function->GetExtension())
- ->HasHostPermission(*url)) {
+ !function->GetExtension()->permissions_data()->HasHostPermission(*url)) {
function->SetError(ErrorUtils::FormatErrorMessage(
keys::kNoHostPermissionsError, url->spec()));
return false;
diff --git a/chrome/browser/extensions/api/cookies/cookies_helpers.cc b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
index 71e5818..f22fc7d 100644
--- a/chrome/browser/extensions/api/cookies/cookies_helpers.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_helpers.cc
@@ -136,8 +136,7 @@ void AppendMatchingCookiesToVector(const net::CookieList& all_cookies,
// Ignore any cookie whose domain doesn't match the extension's
// host permissions.
GURL cookie_domain_url = GetURLFromCanonicalCookie(*it);
- if (!PermissionsData::ForExtension(extension)
- ->HasHostPermission(cookie_domain_url))
+ if (!extension->permissions_data()->HasHostPermission(cookie_domain_url))
continue;
// Filter the cookie using the match filter.
cookies_helpers::MatchFilter filter(details);
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
index 1ac200e..5def40b 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.cc
@@ -344,7 +344,7 @@ bool WebRequestRulesRegistry::HostPermissionsChecker(
const Extension* extension,
const WebRequestActionSet* actions,
std::string* error) {
- if (PermissionsData::ForExtension(extension)->HasEffectiveAccessToAllHosts())
+ if (extension->permissions_data()->HasEffectiveAccessToAllHosts())
return true;
// Without the permission for all URLs, actions with the STRATEGY_DEFAULT
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
index 2bb0177..7c1d6a0 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
@@ -196,8 +196,8 @@ IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
ASSERT_FALSE(
- PermissionsData::ForExtension(
- service->GetExtensionById(last_loaded_extension_id(), false))
+ service->GetExtensionById(last_loaded_extension_id(), false)
+ ->permissions_data()
->HasAPIPermissionForTab(
SessionID::IdForTab(
browser()->tab_strip_model()->GetActiveWebContents()),
diff --git a/chrome/browser/extensions/api/hid/hid_api.cc b/chrome/browser/extensions/api/hid/hid_api.cc
index 6d41ad8..2462384 100644
--- a/chrome/browser/extensions/api/hid/hid_api.cc
+++ b/chrome/browser/extensions/api/hid/hid_api.cc
@@ -87,8 +87,8 @@ void HidGetDevicesFunction::AsyncWorkStart() {
const uint16_t product_id = parameters_->options.product_id;
UsbDevicePermission::CheckParam param(
vendor_id, product_id, UsbDevicePermissionData::UNSPECIFIED_INTERFACE);
- if (!PermissionsData::ForExtension(GetExtension())
- ->CheckAPIPermissionWithParam(APIPermission::kUsbDevice, &param)) {
+ if (!GetExtension()->permissions_data()->CheckAPIPermissionWithParam(
+ APIPermission::kUsbDevice, &param)) {
LOG(WARNING) << "Insufficient permissions to access device.";
CompleteWithError(kErrorPermissionDenied);
return;
@@ -119,8 +119,8 @@ void HidConnectFunction::AsyncWorkStart() {
device_info.vendor_id,
device_info.product_id,
UsbDevicePermissionData::UNSPECIFIED_INTERFACE);
- if (!PermissionsData::ForExtension(GetExtension())
- ->CheckAPIPermissionWithParam(APIPermission::kUsbDevice, &param)) {
+ if (!GetExtension()->permissions_data()->CheckAPIPermissionWithParam(
+ APIPermission::kUsbDevice, &param)) {
LOG(WARNING) << "Insufficient permissions to access device.";
CompleteWithError(kErrorPermissionDenied);
return;
diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc
index fdc4b35..1e7d3f8 100644
--- a/chrome/browser/extensions/api/management/management_api.cc
+++ b/chrome/browser/extensions/api/management/management_api.cc
@@ -90,7 +90,7 @@ AutoConfirmForTest auto_confirm_for_test = DO_NOT_SKIP;
std::vector<std::string> CreateWarningsList(const Extension* extension) {
std::vector<std::string> warnings_list;
PermissionMessages warnings =
- PermissionsData::ForExtension(extension)->GetPermissionMessages();
+ extension->permissions_data()->GetPermissionMessages();
for (PermissionMessages::const_iterator iter = warnings.begin();
iter != warnings.end(); ++iter) {
warnings_list.push_back(base::UTF16ToUTF8(iter->message()));
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
index 77edb3e..21d205d 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -143,8 +143,7 @@ base::ListValue* ConstructFileSystemList(
MediaGalleriesPermission::CheckParam read_param(
MediaGalleriesPermission::kReadPermission);
- const PermissionsData* permissions_data =
- PermissionsData::ForExtension(extension);
+ const PermissionsData* permissions_data = extension->permissions_data();
bool has_read_permission = permissions_data->CheckAPIPermissionWithParam(
APIPermission::kMediaGalleries, &read_param);
MediaGalleriesPermission::CheckParam copy_to_param(
@@ -211,7 +210,7 @@ bool CheckScanPermission(const extensions::Extension* extension,
MediaGalleriesPermission::CheckParam scan_param(
MediaGalleriesPermission::kScanPermission);
bool has_scan_permission =
- PermissionsData::ForExtension(extension)->CheckAPIPermissionWithParam(
+ extension->permissions_data()->CheckAPIPermissionWithParam(
APIPermission::kMediaGalleries, &scan_param);
if (!has_scan_permission)
*error = kNoScanPermission;
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
index 5967dac..c88fbc9 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
@@ -89,8 +89,8 @@ bool TabCaptureCaptureFunction::RunSync() {
// Make sure either we have been granted permission to capture through an
// extension icon click or our extension is whitelisted.
- if (!PermissionsData::ForExtension(extension)
- ->HasAPIPermissionForTab(tab_id, APIPermission::kTabCaptureForTab) &&
+ if (!extension->permissions_data()->HasAPIPermissionForTab(
+ tab_id, APIPermission::kTabCaptureForTab) &&
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kWhitelistedExtensionID) != extension_id &&
!SimpleFeature::IsIdInList(
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index cf0bab4..876d5a2 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -1178,14 +1178,14 @@ bool TabsUpdateFunction::UpdateURL(const std::string &url_string,
// we need to check host permissions before allowing them.
if (url.SchemeIs(url::kJavaScriptScheme)) {
content::RenderProcessHost* process = web_contents_->GetRenderProcessHost();
- if (!PermissionsData::ForExtension(GetExtension())
- ->CanExecuteScriptOnPage(GetExtension(),
- web_contents_->GetURL(),
- web_contents_->GetURL(),
- tab_id,
- NULL,
- process ? process->GetID() : -1,
- &error_)) {
+ if (!GetExtension()->permissions_data()->CanExecuteScriptOnPage(
+ GetExtension(),
+ web_contents_->GetURL(),
+ web_contents_->GetURL(),
+ tab_id,
+ NULL,
+ process ? process->GetID() : -1,
+ &error_)) {
return false;
}
@@ -1504,8 +1504,8 @@ WebContents* TabsCaptureVisibleTabFunction::GetWebContentsForID(int window_id) {
return NULL;
}
- if (!PermissionsData::ForExtension(GetExtension())
- ->CanCaptureVisiblePage(SessionID::IdForTab(contents), &error_)) {
+ if (!GetExtension()->permissions_data()->CanCaptureVisiblePage(
+ SessionID::IdForTab(contents), &error_)) {
return NULL;
}
return contents;
@@ -1627,8 +1627,8 @@ ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {}
bool ExecuteCodeInTabFunction::HasPermission() {
if (Init() &&
- PermissionsData::ForExtension(extension_)
- ->HasAPIPermissionForTab(execute_tab_id_, APIPermission::kTab)) {
+ extension_->permissions_data()->HasAPIPermissionForTab(
+ execute_tab_id_, APIPermission::kTab)) {
return true;
}
return ExtensionFunction::HasPermission();
@@ -1656,14 +1656,14 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage() {
// NOTE: This can give the wrong answer due to race conditions, but it is OK,
// we check again in the renderer.
content::RenderProcessHost* process = contents->GetRenderProcessHost();
- if (!PermissionsData::ForExtension(GetExtension())
- ->CanExecuteScriptOnPage(GetExtension(),
- contents->GetURL(),
- contents->GetURL(),
- execute_tab_id_,
- NULL,
- process ? process->GetID() : -1,
- &error_)) {
+ if (!GetExtension()->permissions_data()->CanExecuteScriptOnPage(
+ GetExtension(),
+ contents->GetURL(),
+ contents->GetURL(),
+ execute_tab_id_,
+ NULL,
+ process ? process->GetID() : -1,
+ &error_)) {
return false;
}
diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc
index 005d58a..b4e8158d 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api.cc
@@ -2230,9 +2230,7 @@ bool WebRequestInternalAddEventListenerFunction::RunSync() {
// For this reason we do only a coarse check here to warn the extension
// developer if he does something obviously wrong.
if (!is_web_view_guest &&
- extensions::PermissionsData::ForExtension(extension)
- ->GetEffectiveHostPermissions()
- .is_empty()) {
+ extension->permissions_data()->GetEffectiveHostPermissions().is_empty()) {
error_ = keys::kHostPermissionsRequired;
return false;
}
diff --git a/chrome/browser/extensions/api/web_request/web_request_permissions.cc b/chrome/browser/extensions/api/web_request/web_request_permissions.cc
index 5d0d7a8..1617c72 100644
--- a/chrome/browser/extensions/api/web_request/web_request_permissions.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_permissions.cc
@@ -133,15 +133,13 @@ bool WebRequestPermissions::CanExtensionAccessURL(
// about: URLs are not covered in host permissions, but are allowed
// anyway.
if (!((url.SchemeIs(content::kAboutScheme) ||
- extensions::PermissionsData::ForExtension(extension)
- ->HasHostPermission(url) ||
+ extension->permissions_data()->HasHostPermission(url) ||
url.GetOrigin() == extension->url()))) {
return false;
}
break;
case REQUIRE_ALL_URLS:
- if (!extensions::PermissionsData::ForExtension(extension)
- ->HasEffectiveAccessToAllHosts())
+ if (!extension->permissions_data()->HasEffectiveAccessToAllHosts())
return false;
break;
}
diff --git a/chrome/browser/extensions/browser_permissions_policy_delegate_unittest.cc b/chrome/browser/extensions/browser_permissions_policy_delegate_unittest.cc
index ca96634..6c7e8d4 100644
--- a/chrome/browser/extensions/browser_permissions_policy_delegate_unittest.cc
+++ b/chrome/browser/extensions/browser_permissions_policy_delegate_unittest.cc
@@ -74,8 +74,7 @@ TEST_F(BrowserPermissionsPolicyDelegateTest, CanExecuteScriptOnPage) {
// The same call should succeed with a normal process, but fail with a signin
// process.
- const PermissionsData* permissions_data =
- PermissionsData::ForExtension(extension);
+ const PermissionsData* permissions_data = extension->permissions_data();
EXPECT_TRUE(permissions_data->CanExecuteScriptOnPage(extension,
kSigninUrl,
kSigninUrl,
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index 9cebb3b..9a77ff0 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -258,8 +258,7 @@ void BundleInstaller::ShowPrompt() {
for (size_t i = 0; i < dummy_extensions_.size(); ++i) {
permissions = PermissionSet::CreateUnion(
permissions.get(),
- PermissionsData::ForExtension(dummy_extensions_[i])
- ->active_permissions());
+ dummy_extensions_[i]->permissions_data()->active_permissions());
}
if (g_auto_approve_for_test == PROCEED) {
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 7d4a35e..7503b97 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -297,9 +297,7 @@ CrxInstallerError CrxInstaller::AllowInstall(const Extension* extension) {
// To skip manifest checking, the extension must be a shared module
// and not request any permissions.
if (SharedModuleInfo::IsSharedModule(extension) &&
- PermissionsData::ForExtension(extension)
- ->active_permissions()
- ->IsEmpty()) {
+ extension->permissions_data()->active_permissions()->IsEmpty()) {
valid = true;
}
} else {
@@ -315,11 +313,10 @@ CrxInstallerError CrxInstaller::AllowInstall(const Extension* extension) {
&error);
if (error.empty()) {
scoped_refptr<const PermissionSet> expected_permissions =
- PermissionsData::ForExtension(dummy_extension)
- ->active_permissions();
+ dummy_extension->permissions_data()->active_permissions();
valid = !(PermissionMessageProvider::Get()->IsPrivilegeIncrease(
expected_permissions,
- PermissionsData::ForExtension(extension)->active_permissions(),
+ extension->permissions_data()->active_permissions(),
extension->GetType()));
}
}
diff --git a/chrome/browser/extensions/extension_gcm_app_handler.cc b/chrome/browser/extensions/extension_gcm_app_handler.cc
index fd515ef..c55111e 100644
--- a/chrome/browser/extensions/extension_gcm_app_handler.cc
+++ b/chrome/browser/extensions/extension_gcm_app_handler.cc
@@ -29,8 +29,7 @@ base::LazyInstance<BrowserContextKeyedAPIFactory<ExtensionGCMAppHandler> >
g_factory = LAZY_INSTANCE_INITIALIZER;
bool IsGCMPermissionEnabled(const Extension* extension) {
- return PermissionsData::ForExtension(extension)
- ->HasAPIPermission(APIPermission::kGcm);
+ return extension->permissions_data()->HasAPIPermission(APIPermission::kGcm);
}
} // namespace
diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc
index ca5f86a..f0947c2 100644
--- a/chrome/browser/extensions/extension_install_prompt.cc
+++ b/chrome/browser/extensions/extension_install_prompt.cc
@@ -711,7 +711,7 @@ void ExtensionInstallPrompt::ShowConfirmation() {
if (permissions_.get()) {
if (extension_) {
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(extension_);
+ extension_->permissions_data();
prompt_.SetPermissions(permissions_data->GetPermissionMessageStrings());
prompt_.SetPermissionsDetails(
permissions_data->GetPermissionMessageDetailsStrings());
diff --git a/chrome/browser/extensions/extension_keybinding_apitest.cc b/chrome/browser/extensions/extension_keybinding_apitest.cc
index 0f4b073..1073f63 100644
--- a/chrome/browser/extensions/extension_keybinding_apitest.cc
+++ b/chrome/browser/extensions/extension_keybinding_apitest.cc
@@ -37,7 +37,7 @@ class CommandsApiTest : public ExtensionApiTest {
bool IsGrantedForTab(const Extension* extension,
const content::WebContents* web_contents) {
- return PermissionsData::ForExtension(extension)->HasAPIPermissionForTab(
+ return extension->permissions_data()->HasAPIPermissionForTab(
SessionID::IdForTab(web_contents), APIPermission::kTab);
}
};
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 1128e23..bb23964 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -979,8 +979,8 @@ void ExtensionService::RecordPermissionMessagesHistogram(
PermissionMessage::kEnumBoundary + 1,
base::HistogramBase::kUmaTargetedHistogramFlag);
- PermissionMessages permissions = extensions::PermissionsData::ForExtension(
- extension)->GetPermissionMessages();
+ PermissionMessages permissions =
+ extension->permissions_data()->GetPermissionMessages();
if (permissions.empty()) {
counter->Add(PermissionMessage::kNone);
} else {
@@ -1044,7 +1044,7 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) {
UpdateActiveExtensionsInCrashReporter();
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(extension);
+ extension->permissions_data();
// If the extension has permission to load chrome://favicon/ resources we need
// to make sure that the FaviconSource is registered with the
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index b0177e1..fc1d3c5 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -389,10 +389,9 @@ void ExtensionTabUtil::ScrubTabValueForExtension(
WebContents* contents,
const Extension* extension,
base::DictionaryValue* tab_info) {
- bool has_permission =
- extension &&
- PermissionsData::ForExtension(extension)
- ->HasAPIPermissionForTab(GetTabId(contents), APIPermission::kTab);
+ bool has_permission = extension &&
+ extension->permissions_data()->HasAPIPermissionForTab(
+ GetTabId(contents), APIPermission::kTab);
if (!has_permission) {
tab_info->Remove(keys::kUrlKey, NULL);
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index 09adfb9..c132adb 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -84,7 +84,7 @@ void PermissionsUpdater::UpdateActivePermissions(
const Extension* extension, const PermissionSet* permissions) {
ExtensionPrefs::Get(profile_)->SetActivePermissions(
extension->id(), permissions);
- PermissionsData::ForExtension(extension)->SetActivePermissions(permissions);
+ extension->permissions_data()->SetActivePermissions(permissions);
}
void PermissionsUpdater::DispatchEvent(
diff --git a/chrome/browser/media_galleries/media_galleries_dialog_controller.cc b/chrome/browser/media_galleries/media_galleries_dialog_controller.cc
index 93fb700..f4f39d4 100644
--- a/chrome/browser/media_galleries/media_galleries_dialog_controller.cc
+++ b/chrome/browser/media_galleries/media_galleries_dialog_controller.cc
@@ -123,7 +123,7 @@ base::string16 MediaGalleriesDialogController::GetSubtext() const {
extensions::MediaGalleriesPermission::CheckParam delete_param(
extensions::MediaGalleriesPermission::kDeletePermission);
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(extension_);
+ extension_->permissions_data();
bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam(
APIPermission::kMediaGalleries, &copy_to_param);
bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam(
diff --git a/chrome/browser/media_galleries/media_galleries_preferences.cc b/chrome/browser/media_galleries/media_galleries_preferences.cc
index f3ec78a..a780656 100644
--- a/chrome/browser/media_galleries/media_galleries_preferences.cc
+++ b/chrome/browser/media_galleries/media_galleries_preferences.cc
@@ -97,7 +97,7 @@ int NumberExtensionsUsingMediaGalleries(Profile* profile) {
for (extensions::ExtensionSet::const_iterator i = extensions->begin();
i != extensions->end(); ++i) {
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(*i);
+ (*i)->permissions_data();
if (permissions_data->HasAPIPermission(
extensions::APIPermission::kMediaGalleries) ||
permissions_data->HasAPIPermission(
@@ -279,9 +279,8 @@ base::DictionaryValue* CreateGalleryPrefInfoDictionary(
bool HasAutoDetectedGalleryPermission(const extensions::Extension& extension) {
extensions::MediaGalleriesPermission::CheckParam param(
extensions::MediaGalleriesPermission::kAllAutoDetectedPermission);
- return extensions::PermissionsData::ForExtension(&extension)->
- CheckAPIPermissionWithParam(extensions::APIPermission::kMediaGalleries,
- &param);
+ return extension.permissions_data()->CheckAPIPermissionWithParam(
+ extensions::APIPermission::kMediaGalleries, &param);
}
// Retrieves the MediaGalleryPermission from the given dictionary; DCHECKs on
diff --git a/chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.cc b/chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.cc
index b5cd3fe..91a3a5b 100644
--- a/chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.cc
+++ b/chrome/browser/media_galleries/media_galleries_scan_result_dialog_controller.cc
@@ -121,7 +121,7 @@ base::string16 MediaGalleriesScanResultDialogController::GetSubtext() const {
extensions::MediaGalleriesPermission::CheckParam delete_param(
extensions::MediaGalleriesPermission::kDeletePermission);
const extensions::PermissionsData* permissions_data =
- extensions::PermissionsData::ForExtension(extension_);
+ extension_->permissions_data();
bool has_copy_to_permission = permissions_data->CheckAPIPermissionWithParam(
extensions::APIPermission::kMediaGalleries, &copy_to_param);
bool has_delete_permission = permissions_data->CheckAPIPermissionWithParam(
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 8f10858..34c6f7f 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -93,10 +93,10 @@ class IsPageActionViewRightAligned {
: extension_service_(extension_service) {}
bool operator()(PageActionDecoration* page_action_decoration) {
- return extensions::PermissionsData::ForExtension(
- extension_service_->GetExtensionById(
- page_action_decoration->page_action()->extension_id(),
- false))
+ return extension_service_
+ ->GetExtensionById(
+ page_action_decoration->page_action()->extension_id(), false)
+ ->permissions_data()
->HasAPIPermission(extensions::APIPermission::kBookmarkManagerPrivate);
}
diff --git a/chrome/browser/ui/omnibox/location_bar.cc b/chrome/browser/ui/omnibox/location_bar.cc
index f51dfce..c41bb10 100644
--- a/chrome/browser/ui/omnibox/location_bar.cc
+++ b/chrome/browser/ui/omnibox/location_bar.cc
@@ -33,7 +33,7 @@ bool LocationBar::IsBookmarkStarHiddenByExtension() const {
if (((settings_overrides &&
SettingsOverrides::RemovesBookmarkButton(*settings_overrides)) ||
(ui_overrides && UIOverrides::RemovesBookmarkButton(*ui_overrides))) &&
- (extensions::PermissionsData::ForExtension(*i)->HasAPIPermission(
+ ((*i)->permissions_data()->HasAPIPermission(
extensions::APIPermission::kBookmarkManagerPrivate) ||
extensions::FeatureSwitch::enable_override_bookmarks_ui()
->IsEnabled()))
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 5e3bbdd..8a71d56 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -170,12 +170,11 @@ class IsPageActionViewRightAligned {
: extension_service_(extension_service) {}
bool operator()(PageActionWithBadgeView* page_action_view) {
- return extensions::PermissionsData::ForExtension(
- extension_service_->GetExtensionById(
- page_action_view->image_view()
- ->page_action()
- ->extension_id(),
- false))
+ return extension_service_
+ ->GetExtensionById(
+ page_action_view->image_view()->page_action()->extension_id(),
+ false)
+ ->permissions_data()
->HasAPIPermission(extensions::APIPermission::kBookmarkManagerPrivate);
}
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index 9511051..e50de2f 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -260,9 +260,10 @@ base::DictionaryValue* ExtensionSettingsHandler::CreateExtensionDetailValue(
// - The feature is enabled.
// - The extension has access to enough urls that we can't just let it run
// on those specified in the permissions.
- bool wants_all_urls = FeatureSwitch::scripts_require_action()->IsEnabled() &&
- PermissionsData::ForExtension(extension)
- ->RequiresActionForScriptExecution(extension);
+ bool wants_all_urls =
+ FeatureSwitch::scripts_require_action()->IsEnabled() &&
+ extension->permissions_data()->RequiresActionForScriptExecution(
+ extension);
extension_data->SetBoolean("wantsAllUrls", wants_all_urls);
extension_data->SetBoolean(
"allowAllUrls",