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

Unified Diff: chrome/common/extensions/extension.cc

Issue 10695070: Implement scriptBadge.requestToAct. (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
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index abb94debfcd4bde74c5cbd4fe48839709aa8e91d..3a7349885fb5c50573732709777e67514e568d7e 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -3527,11 +3527,8 @@ bool Extension::HasMultipleUISurfaces() const {
return num_surfaces > 1;
}
-bool Extension::CanExecuteScriptOnPage(const GURL& page_url,
- int tab_id,
- const UserScript* script,
- std::string* error) const {
- base::AutoLock auto_lock(runtime_data_lock_);
+bool Extension::IsPageTooSensitiveForScript(const GURL& page_url,
+ std::string* error) const {
// The gallery is special-cased as a restricted URL for scripting to prevent
// access to special JS bindings we expose to the gallery (and avoid things
// like extensions removing the "report abuse" link).
@@ -3544,13 +3541,24 @@ bool Extension::CanExecuteScriptOnPage(const GURL& page_url,
switches::kAllowScriptingGallery)) {
if (error)
*error = errors::kCannotScriptGallery;
- return false;
+ return true;
}
if (page_url.SchemeIs(chrome::kChromeUIScheme) &&
!CanExecuteScriptEverywhere())
+ return true;
+
+ return false;
+}
+
+bool Extension::CanExecuteScriptOnPage(const GURL& page_url,
+ int tab_id,
+ const UserScript* script,
+ std::string* error) const {
+ if (IsPageTooSensitiveForScript(page_url, error))
return false;
+ base::AutoLock auto_lock(runtime_data_lock_);
// If a tab ID is specified, try the tab-specific permissions.
if (tab_id >= 0) {
const URLPatternSet* tab_permissions =
@@ -3579,6 +3587,13 @@ bool Extension::CanExecuteScriptOnPage(const GURL& page_url,
return false;
}
+bool Extension::CanRequestToActOnPage(const GURL& page_url,
+ int tab_id) const {
+ if (IsPageTooSensitiveForScript(page_url, NULL))
Aaron Boodman 2012/07/03 01:29:31 I think this should just be IsPageTooSensitive...
Jeffrey Yasskin 2012/07/10 21:52:33 Done.
+ return false;
+ return !CanExecuteScriptOnPage(page_url, tab_id, NULL, NULL);
+}
+
bool Extension::ShowConfigureContextMenus() const {
// Don't show context menu for component extensions. We might want to show
// options for component extension button but now there is no component
« chrome/common/extensions/extension.h ('K') | « chrome/common/extensions/extension.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698