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

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

Issue 448883002: Fix permission regression where warnings aren't shown in the dialog (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
« no previous file with comments | « extensions/common/permissions/permissions_data.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extensions_client.h" 11 #include "extensions/common/extensions_client.h"
12 #include "extensions/common/manifest.h" 12 #include "extensions/common/manifest.h"
13 #include "extensions/common/manifest_constants.h" 13 #include "extensions/common/manifest_constants.h"
14 #include "extensions/common/manifest_handlers/permissions_parser.h" 14 #include "extensions/common/manifest_handlers/permissions_parser.h"
15 #include "extensions/common/permissions/permission_message_provider.h" 15 #include "extensions/common/permissions/permission_message_provider.h"
16 #include "extensions/common/switches.h" 16 #include "extensions/common/switches.h"
17 #include "extensions/common/url_pattern_set.h" 17 #include "extensions/common/url_pattern_set.h"
18 #include "extensions/common/user_script.h" 18 #include "extensions/common/user_script.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 #include "url/url_constants.h" 20 #include "url/url_constants.h"
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 namespace { 24 namespace {
25 25
26 PermissionsData::PolicyDelegate* g_policy_delegate = NULL; 26 PermissionsData::PolicyDelegate* g_policy_delegate = NULL;
27 27
28 // Returns true if this extension id is from a trusted provider.
29 bool ShouldSkipPermissionWarnings(const std::string& extension_id) {
30 // See http://b/4946060 for more details.
31 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
32 }
33
34 } // namespace 28 } // namespace
35 29
36 PermissionsData::PermissionsData(const Extension* extension) 30 PermissionsData::PermissionsData(const Extension* extension)
37 : extension_id_(extension->id()), manifest_type_(extension->GetType()) { 31 : extension_id_(extension->id()), manifest_type_(extension->GetType()) {
38 base::AutoLock auto_lock(runtime_lock_); 32 base::AutoLock auto_lock(runtime_lock_);
39 scoped_refptr<const PermissionSet> required_permissions = 33 scoped_refptr<const PermissionSet> required_permissions =
40 PermissionsParser::GetRequiredPermissions(extension); 34 PermissionsParser::GetRequiredPermissions(extension);
41 active_permissions_unsafe_ = 35 active_permissions_unsafe_ =
42 new PermissionSet(required_permissions->apis(), 36 new PermissionSet(required_permissions->apis(),
43 required_permissions->manifest_permissions(), 37 required_permissions->manifest_permissions(),
(...skipping 21 matching lines...) Expand all
65 if (extension->location() == Manifest::COMPONENT) 59 if (extension->location() == Manifest::COMPONENT)
66 return true; 60 return true;
67 61
68 const ExtensionsClient::ScriptingWhitelist& whitelist = 62 const ExtensionsClient::ScriptingWhitelist& whitelist =
69 ExtensionsClient::Get()->GetScriptingWhitelist(); 63 ExtensionsClient::Get()->GetScriptingWhitelist();
70 64
71 return std::find(whitelist.begin(), whitelist.end(), extension->id()) != 65 return std::find(whitelist.begin(), whitelist.end(), extension->id()) !=
72 whitelist.end(); 66 whitelist.end();
73 } 67 }
74 68
69 bool PermissionsData::ShouldSkipPermissionWarnings(
70 const std::string& extension_id) {
71 // See http://b/4946060 for more details.
72 return extension_id == std::string("nckgahadagoaajjgafhacjanaoiihapd");
73 }
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 (CanExecuteScriptEverywhere(extension))
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()) &&
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return ACCESS_WITHHELD; 360 return ACCESS_WITHHELD;
361 361
362 if (error) { 362 if (error) {
363 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage, 363 *error = ErrorUtils::FormatErrorMessage(manifest_errors::kCannotAccessPage,
364 document_url.spec()); 364 document_url.spec());
365 } 365 }
366 return ACCESS_DENIED; 366 return ACCESS_DENIED;
367 } 367 }
368 368
369 } // namespace extensions 369 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698