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

Side by Side Diff: chrome/browser/extensions/active_tab_permission_granter.cc

Issue 314113010: Remove deprecated permissions functions from Extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/active_tab_permission_granter.h" 5 #include "chrome/browser/extensions/active_tab_permission_granter.h"
6 6
7 #include "chrome/browser/extensions/active_script_controller.h" 7 #include "chrome/browser/extensions/active_script_controller.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/navigation_details.h" 9 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/navigation_entry.h" 10 #include "content/public/browser/navigation_entry.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // If the extension requires action for script execution, we grant it 48 // If the extension requires action for script execution, we grant it
49 // active tab-style permissions, even if it doesn't have the activeTab 49 // active tab-style permissions, even if it doesn't have the activeTab
50 // permission in the manifest. 50 // permission in the manifest.
51 // We don't take tab id into account, because we want to know if the extension 51 // We don't take tab id into account, because we want to know if the extension
52 // should require active tab in general (not for the current tab). 52 // should require active tab in general (not for the current tab).
53 bool requires_action_for_script_execution = 53 bool requires_action_for_script_execution =
54 permissions_data->RequiresActionForScriptExecution(extension, 54 permissions_data->RequiresActionForScriptExecution(extension,
55 -1, // No tab id. 55 -1, // No tab id.
56 GURL()); 56 GURL());
57 57
58 if (extension->HasAPIPermission(APIPermission::kActiveTab) || 58 if (extension->permissions_data()->HasAPIPermission(
59 APIPermission::kActiveTab) ||
59 requires_action_for_script_execution) { 60 requires_action_for_script_execution) {
60 URLPattern pattern(UserScript::ValidUserScriptSchemes()); 61 URLPattern pattern(UserScript::ValidUserScriptSchemes());
61 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. 62 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
62 if (pattern.Parse(web_contents()->GetURL().spec()) == 63 if (pattern.Parse(web_contents()->GetURL().spec()) ==
63 URLPattern::PARSE_SUCCESS) { 64 URLPattern::PARSE_SUCCESS) {
64 new_hosts.AddPattern(pattern); 65 new_hosts.AddPattern(pattern);
65 } 66 }
66 new_apis.insert(APIPermission::kTab); 67 new_apis.insert(APIPermission::kTab);
67 } 68 }
68 69
69 if (extension->HasAPIPermission(APIPermission::kTabCapture)) 70 if (extension->permissions_data()->HasAPIPermission(
71 APIPermission::kTabCapture))
70 new_apis.insert(APIPermission::kTabCaptureForTab); 72 new_apis.insert(APIPermission::kTabCaptureForTab);
71 73
72 if (!new_apis.empty() || !new_hosts.is_empty()) { 74 if (!new_apis.empty() || !new_hosts.is_empty()) {
73 granted_extensions_.Insert(extension); 75 granted_extensions_.Insert(extension);
74 scoped_refptr<const PermissionSet> new_permissions = 76 scoped_refptr<const PermissionSet> new_permissions =
75 new PermissionSet(new_apis, ManifestPermissionSet(), 77 new PermissionSet(new_apis, ManifestPermissionSet(),
76 new_hosts, URLPatternSet()); 78 new_hosts, URLPatternSet());
77 permissions_data->UpdateTabSpecificPermissions(tab_id_, new_permissions); 79 permissions_data->UpdateTabSpecificPermissions(tab_id_, new_permissions);
78 const content::NavigationEntry* navigation_entry = 80 const content::NavigationEntry* navigation_entry =
79 web_contents()->GetController().GetVisibleEntry(); 81 web_contents()->GetController().GetVisibleEntry();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 it != granted_extensions_.end(); ++it) { 128 it != granted_extensions_.end(); ++it) {
127 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); 129 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_);
128 extension_ids.push_back((*it)->id()); 130 extension_ids.push_back((*it)->id());
129 } 131 }
130 132
131 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 133 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
132 granted_extensions_.Clear(); 134 granted_extensions_.Clear();
133 } 135 }
134 136
135 } // namespace extensions 137 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | chrome/browser/extensions/api/alarms/alarm_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698