OLD | NEW |
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 Loading... |
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 bool PermissionsData::ScriptsMayRequireActionForExtension( |
| 70 const Extension* extension, |
| 71 const PermissionSet* permissions) { |
| 72 // An extension may require user action to execute scripts iff the extension |
| 73 // shows up in chrome:extensions (so the user can grant withheld permissions), |
| 74 // is not part of chrome or corporate policy, not on the scripting whitelist, |
| 75 // and requires enough permissions that we should withhold them. |
| 76 return extension->ShouldDisplayInExtensionSettings() && |
| 77 !Manifest::IsPolicyLocation(extension->location()) && |
| 78 !Manifest::IsComponentLocation(extension->location()) && |
| 79 !CanExecuteScriptEverywhere(extension) && |
| 80 permissions->ShouldWarnAllHosts(); |
| 81 } |
| 82 |
68 bool PermissionsData::ShouldSkipPermissionWarnings( | 83 bool PermissionsData::ShouldSkipPermissionWarnings( |
69 const std::string& extension_id) { | 84 const std::string& extension_id) { |
70 // See http://b/4946060 for more details. | 85 // See http://b/4946060 for more details. |
71 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); | 86 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); |
72 } | 87 } |
73 | 88 |
74 // static | 89 // static |
75 bool PermissionsData::IsRestrictedUrl(const GURL& document_url, | 90 bool PermissionsData::IsRestrictedUrl(const GURL& document_url, |
76 const GURL& top_frame_url, | 91 const GURL& top_frame_url, |
77 const Extension* extension, | 92 const Extension* extension, |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 return ACCESS_WITHHELD; | 378 return ACCESS_WITHHELD; |
364 | 379 |
365 if (error) { | 380 if (error) { |
366 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, | 381 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, |
367 document_url.spec()); | 382 document_url.spec()); |
368 } | 383 } |
369 return ACCESS_DENIED; | 384 return ACCESS_DENIED; |
370 } | 385 } |
371 | 386 |
372 } // namespace extensions | 387 } // namespace extensions |
OLD | NEW |