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

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

Issue 443723003: extensions: Register 'app' and 'webstore' bindings only if they are available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
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"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != 71 return std::find(whitelist.begin(), whitelist.end(), extension->id()) !=
72 whitelist.end(); 72 whitelist.end();
73 } 73 }
74 74
75 // static 75 // static
76 bool PermissionsData::IsRestrictedUrl(const GURL& document_url, 76 bool PermissionsData::IsRestrictedUrl(const GURL& document_url,
77 const GURL& top_frame_url, 77 const GURL& top_frame_url,
78 const Extension* extension, 78 const Extension* extension,
79 std::string* error) { 79 std::string* error) {
80 if (CanExecuteScriptEverywhere(extension)) 80 if (extension && CanExecuteScriptEverywhere(extension))
sadrul 2014/08/06 18:51:51 The null checks here are necessary since some test
not at google - send to devlin 2014/08/06 22:10:28 yeah this change is correct no matter what the con
81 return false; 81 return false;
82 82
83 // Check if the scheme is valid for extensions. If not, return. 83 // Check if the scheme is valid for extensions. If not, return.
84 if (!URLPattern::IsValidSchemeForExtensions(document_url.scheme()) && 84 if (!URLPattern::IsValidSchemeForExtensions(document_url.scheme()) &&
85 document_url.spec() != url::kAboutBlankURL) { 85 document_url.spec() != url::kAboutBlankURL) {
86 if (error) { 86 if (error) {
87 *error = ErrorUtils::FormatErrorMessage( 87 *error = ErrorUtils::FormatErrorMessage(
88 manifest_errors::kCannotAccessPage, 88 manifest_errors::kCannotAccessPage,
89 document_url.spec()); 89 document_url.spec());
90 } 90 }
91 return true; 91 return true;
92 } 92 }
93 93
94 if (!ExtensionsClient::Get()->IsScriptableURL(document_url, error)) 94 if (!ExtensionsClient::Get()->IsScriptableURL(document_url, error))
95 return true; 95 return true;
96 96
97 bool allow_on_chrome_urls = base::CommandLine::ForCurrentProcess()->HasSwitch( 97 bool allow_on_chrome_urls = base::CommandLine::ForCurrentProcess()->HasSwitch(
98 switches::kExtensionsOnChromeURLs); 98 switches::kExtensionsOnChromeURLs);
99 if (document_url.SchemeIs(content::kChromeUIScheme) && 99 if (document_url.SchemeIs(content::kChromeUIScheme) &&
100 !allow_on_chrome_urls) { 100 !allow_on_chrome_urls) {
101 if (error) 101 if (error)
102 *error = manifest_errors::kCannotAccessChromeUrl; 102 *error = manifest_errors::kCannotAccessChromeUrl;
103 return true; 103 return true;
104 } 104 }
105 105
106 if (top_frame_url.SchemeIs(kExtensionScheme) && 106 if (extension && top_frame_url.SchemeIs(kExtensionScheme) &&
107 top_frame_url.host() != extension->id() && 107 top_frame_url.host() != extension->id() && !allow_on_chrome_urls) {
108 !allow_on_chrome_urls) {
109 if (error) 108 if (error)
110 *error = manifest_errors::kCannotAccessExtensionUrl; 109 *error = manifest_errors::kCannotAccessExtensionUrl;
111 return true; 110 return true;
112 } 111 }
113 112
114 return false; 113 return false;
115 } 114 }
116 115
117 void PermissionsData::SetPermissions( 116 void PermissionsData::SetPermissions(
118 const scoped_refptr<const PermissionSet>& active, 117 const scoped_refptr<const PermissionSet>& active,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return ACCESS_WITHHELD; 359 return ACCESS_WITHHELD;
361 360
362 if (error) { 361 if (error) {
363 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, 362 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage,
364 document_url.spec()); 363 document_url.spec());
365 } 364 }
366 return ACCESS_DENIED; 365 return ACCESS_DENIED;
367 } 366 }
368 367
369 } // namespace extensions 368 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698