diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 16:16:30 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-05 16:16:30 +0000 |
commit | d695bb139a93f2c0cab08b1801c2cddba1a39773 (patch) | |
tree | b6ee5cfc101d0506d87200f0b09d6189754834ff /extensions/renderer | |
parent | 32e8a26ae2917d695551f1e37701e0eff52879de (diff) | |
download | chromium_src-d695bb139a93f2c0cab08b1801c2cddba1a39773.zip chromium_src-d695bb139a93f2c0cab08b1801c2cddba1a39773.tar.gz chromium_src-d695bb139a93f2c0cab08b1801c2cddba1a39773.tar.bz2 |
Refactor PermissionsData pt1
In this CL, we:
- Make PermissionsData not-so-static. Only methods which either don't rely on
knowledge of specific permissions or methods to get/create the object are
static.
- Separate runtime permissions knowledge from manifest parsing (PermissionsData
vs PermissionsParser)
- Move required/optional permissions access into PermissionsParser.
- Handle the locking issues.
BUG=379356
TBR=sky@chromium.org (for c/b/ui/, no functional changes)
Review URL: https://codereview.chromium.org/309533007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275142 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/renderer')
-rw-r--r-- | extensions/renderer/dispatcher.cc | 4 | ||||
-rw-r--r-- | extensions/renderer/script_injection.cc | 23 | ||||
-rw-r--r-- | extensions/renderer/user_script_scheduler.cc | 15 |
3 files changed, 22 insertions, 20 deletions
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc index dde54db..96de05b 100644 --- a/extensions/renderer/dispatcher.cc +++ b/extensions/renderer/dispatcher.cc @@ -750,7 +750,7 @@ void Dispatcher::OnUpdatePermissions( break; } - PermissionsData::SetActivePermissions(extension, new_active); + PermissionsData::ForExtension(extension)->SetActivePermissions(new_active); UpdateOriginPermissions(reason, extension, explicit_hosts); UpdateBindings(extension->id()); } @@ -803,7 +803,7 @@ void Dispatcher::InitOriginPermissions(const Extension* extension, UpdateOriginPermissions( UpdatedExtensionPermissionsInfo::ADDED, extension, - PermissionsData::GetEffectiveHostPermissions(extension)); + PermissionsData::ForExtension(extension)->GetEffectiveHostPermissions()); } void Dispatcher::UpdateOriginPermissions( diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc index 036dfc7..5299bd4 100644 --- a/extensions/renderer/script_injection.cc +++ b/extensions/renderer/script_injection.cc @@ -154,10 +154,10 @@ void ScriptInjection::InjectIfAllowed(blink::WebFrame* frame, // valid tab id (if we don't have a tab id, we have no UI surface to ask for // user consent). if (tab_id != -1 && - PermissionsData::RequiresActionForScriptExecution( - extension, - tab_id, - frame->top()->document().url())) { + PermissionsData::ForExtension(extension) + ->RequiresActionForScriptExecution(extension, + tab_id, + frame->top()->document().url())) { int64 request_id = kInvalidRequestId; int page_id = top_render_view->GetPageId(); @@ -256,13 +256,14 @@ bool ScriptInjection::WantsToRun(blink::WebFrame* frame, GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL( frame, document_url, script_->match_about_blank()); - if (!PermissionsData::CanExecuteScriptOnPage(extension, - effective_document_url, - frame->top()->document().url(), - kNoTabId, - script_.get(), - kNoProcessId, - NULL /* ignore error */)) { + if (!PermissionsData::ForExtension(extension) + ->CanExecuteScriptOnPage(extension, + effective_document_url, + frame->top()->document().url(), + kNoTabId, + script_.get(), + kNoProcessId, + NULL /* ignore error */)) { return false; } diff --git a/extensions/renderer/user_script_scheduler.cc b/extensions/renderer/user_script_scheduler.cc index cc0d84b..2214c77 100644 --- a/extensions/renderer/user_script_scheduler.cc +++ b/extensions/renderer/user_script_scheduler.cc @@ -192,13 +192,14 @@ void UserScriptScheduler::ExecuteCodeImpl( GURL document_url = ScriptContext::GetEffectiveDocumentURL( child_frame, child_frame->document().url(), params.match_about_blank); bool can_execute_script = - PermissionsData::CanExecuteScriptOnPage(extension, - document_url, - top_url, - extension_helper->tab_id(), - NULL, - -1, - NULL); + PermissionsData::ForExtension(extension) + ->CanExecuteScriptOnPage(extension, + document_url, + top_url, + extension_helper->tab_id(), + NULL, + -1, + NULL); if ((!params.is_web_view && !can_execute_script) || (params.is_web_view && document_url != params.webview_src)) { if (child_frame->parent()) { |