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

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

Issue 922403002: [Extensions] Adjust script injection reporting to the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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_constants.h" 14 #include "extensions/common/manifest_constants.h"
14 #include "extensions/common/manifest_handlers/permissions_parser.h" 15 #include "extensions/common/manifest_handlers/permissions_parser.h"
15 #include "extensions/common/permissions/permission_message_provider.h" 16 #include "extensions/common/permissions/permission_message_provider.h"
16 #include "extensions/common/switches.h" 17 #include "extensions/common/switches.h"
17 #include "extensions/common/url_pattern_set.h" 18 #include "extensions/common/url_pattern_set.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 #include "url/url_constants.h" 20 #include "url/url_constants.h"
20 21
21 namespace extensions { 22 namespace extensions {
22 23
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (extension->location() == Manifest::COMPONENT) 59 if (extension->location() == Manifest::COMPONENT)
59 return true; 60 return true;
60 61
61 const ExtensionsClient::ScriptingWhitelist& whitelist = 62 const ExtensionsClient::ScriptingWhitelist& whitelist =
62 ExtensionsClient::Get()->GetScriptingWhitelist(); 63 ExtensionsClient::Get()->GetScriptingWhitelist();
63 64
64 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != 65 return std::find(whitelist.begin(), whitelist.end(), extension->id()) !=
65 whitelist.end(); 66 whitelist.end();
66 } 67 }
67 68
69 // static
70 bool PermissionsData::ScriptsMayRequireActionForExtension(
71 const Extension* extension,
72 const PermissionSet* permissions) {
73 // An extension may require user action to execute scripts iff the extension
74 // shows up in chrome:extensions (so the user can grant withheld permissions),
75 // is not part of chrome or corporate policy, not on the scripting whitelist,
76 // and requires enough permissions that we should withhold them.
77 return extension->ShouldDisplayInExtensionSettings() &&
78 !Manifest::IsPolicyLocation(extension->location()) &&
79 !Manifest::IsComponentLocation(extension->location()) &&
80 !CanExecuteScriptEverywhere(extension) &&
81 permissions->ShouldWarnAllHosts();
82 }
83
68 bool PermissionsData::ShouldSkipPermissionWarnings( 84 bool PermissionsData::ShouldSkipPermissionWarnings(
69 const std::string& extension_id) { 85 const std::string& extension_id) {
70 // See http://b/4946060 for more details. 86 // See http://b/4946060 for more details.
71 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); 87 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
72 } 88 }
73 89
74 // static 90 // static
75 bool PermissionsData::IsRestrictedUrl(const GURL& document_url, 91 bool PermissionsData::IsRestrictedUrl(const GURL& document_url,
76 const GURL& top_frame_url, 92 const GURL& top_frame_url,
77 const Extension* extension, 93 const Extension* extension,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 return ACCESS_WITHHELD; 379 return ACCESS_WITHHELD;
364 380
365 if (error) { 381 if (error) {
366 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, 382 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage,
367 document_url.spec()); 383 document_url.spec());
368 } 384 }
369 return ACCESS_DENIED; 385 return ACCESS_DENIED;
370 } 386 }
371 387
372 } // namespace extensions 388 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data.h ('k') | extensions/renderer/extension_injection_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698