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

Side by Side Diff: extensions/common/permissions/permissions_data.cc

Issue 1414223005: Remove URLs from chrome.tabs.executeScript permission warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test case Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/common/permissions/permissions_data.h" 5 #include "extensions/common/permissions/permissions_data.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/common/url_constants.h" 8 #include "content/public/common/url_constants.h"
9 #include "extensions/common/constants.h" 9 #include "extensions/common/constants.h"
10 #include "extensions/common/error_utils.h" 10 #include "extensions/common/error_utils.h"
11 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
12 #include "extensions/common/extensions_client.h" 12 #include "extensions/common/extensions_client.h"
13 #include "extensions/common/manifest.h" 13 #include "extensions/common/manifest.h"
14 #include "extensions/common/manifest_constants.h" 14 #include "extensions/common/manifest_constants.h"
15 #include "extensions/common/manifest_handlers/permissions_parser.h" 15 #include "extensions/common/manifest_handlers/permissions_parser.h"
16 #include "extensions/common/permissions/api_permission.h"
16 #include "extensions/common/permissions/permission_message_provider.h" 17 #include "extensions/common/permissions/permission_message_provider.h"
17 #include "extensions/common/switches.h" 18 #include "extensions/common/switches.h"
18 #include "extensions/common/url_pattern_set.h" 19 #include "extensions/common/url_pattern_set.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 #include "url/url_constants.h" 21 #include "url/url_constants.h"
21 22
22 namespace extensions { 23 namespace extensions {
23 24
24 namespace { 25 namespace {
25 26
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bool PermissionsData::IsRestrictedUrl(const GURL& document_url, 83 bool PermissionsData::IsRestrictedUrl(const GURL& document_url,
83 const Extension* extension, 84 const Extension* extension,
84 std::string* error) { 85 std::string* error) {
85 if (extension && CanExecuteScriptEverywhere(extension)) 86 if (extension && CanExecuteScriptEverywhere(extension))
86 return false; 87 return false;
87 88
88 // Check if the scheme is valid for extensions. If not, return. 89 // Check if the scheme is valid for extensions. If not, return.
89 if (!URLPattern::IsValidSchemeForExtensions(document_url.scheme()) && 90 if (!URLPattern::IsValidSchemeForExtensions(document_url.scheme()) &&
90 document_url.spec() != url::kAboutBlankURL) { 91 document_url.spec() != url::kAboutBlankURL) {
91 if (error) { 92 if (error) {
92 *error = ErrorUtils::FormatErrorMessage( 93 if (extension->permissions_data()->active_permissions().HasAPIPermission(
93 manifest_errors::kCannotAccessPage, 94 APIPermission::kTab)) {
94 document_url.spec()); 95 *error = ErrorUtils::FormatErrorMessage(
96 manifest_errors::kCannotAccessPageWithUrl, document_url.spec());
97 } else {
98 *error = manifest_errors::kCannotAccessPage;
99 }
95 } 100 }
96 return true; 101 return true;
97 } 102 }
98 103
99 if (!ExtensionsClient::Get()->IsScriptableURL(document_url, error)) 104 if (!ExtensionsClient::Get()->IsScriptableURL(document_url, error))
100 return true; 105 return true;
101 106
102 bool allow_on_chrome_urls = base::CommandLine::ForCurrentProcess()->HasSwitch( 107 bool allow_on_chrome_urls = base::CommandLine::ForCurrentProcess()->HasSwitch(
103 switches::kExtensionsOnChromeURLs); 108 switches::kExtensionsOnChromeURLs);
104 if (document_url.SchemeIs(content::kChromeUIScheme) && 109 if (document_url.SchemeIs(content::kChromeUIScheme) &&
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (HasTabSpecificPermissionToExecuteScript(tab_id, document_url)) 347 if (HasTabSpecificPermissionToExecuteScript(tab_id, document_url))
343 return ACCESS_ALLOWED; 348 return ACCESS_ALLOWED;
344 349
345 if (permitted_url_patterns.MatchesURL(document_url)) 350 if (permitted_url_patterns.MatchesURL(document_url))
346 return ACCESS_ALLOWED; 351 return ACCESS_ALLOWED;
347 352
348 if (withheld_url_patterns.MatchesURL(document_url)) 353 if (withheld_url_patterns.MatchesURL(document_url))
349 return ACCESS_WITHHELD; 354 return ACCESS_WITHHELD;
350 355
351 if (error) { 356 if (error) {
352 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, 357 if (extension->permissions_data()->active_permissions().HasAPIPermission(
353 document_url.spec()); 358 APIPermission::kTab)) {
359 *error = ErrorUtils::FormatErrorMessage(
360 manifest_errors::kCannotAccessPageWithUrl, document_url.spec());
361 } else {
362 *error = manifest_errors::kCannotAccessPage;
363 }
354 } 364 }
365
355 return ACCESS_DENIED; 366 return ACCESS_DENIED;
356 } 367 }
357 368
358 } // namespace extensions 369 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_constants.cc ('k') | extensions/renderer/programmatic_script_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698