| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { | 36 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { |
| 37 // Active tab grant request implies there was a user gesture. | 37 // Active tab grant request implies there was a user gesture. |
| 38 web_contents()->UserGestureDone(); | 38 web_contents()->UserGestureDone(); |
| 39 | 39 |
| 40 if (granted_extensions_.Contains(extension->id())) | 40 if (granted_extensions_.Contains(extension->id())) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 APIPermissionSet new_apis; | 43 APIPermissionSet new_apis; |
| 44 URLPatternSet new_hosts; | 44 URLPatternSet new_hosts; |
| 45 | 45 |
| 46 const PermissionsData* permissions_data = | 46 const PermissionsData* permissions_data = extension->permissions_data(); |
| 47 PermissionsData::ForExtension(extension); | |
| 48 | 47 |
| 49 // If the extension requires action for script execution, we grant it | 48 // If the extension requires action for script execution, we grant it |
| 50 // 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 |
| 51 // permission in the manifest. | 50 // permission in the manifest. |
| 52 // 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 |
| 53 // should require active tab in general (not for the current tab). | 52 // should require active tab in general (not for the current tab). |
| 54 bool requires_action_for_script_execution = | 53 bool requires_action_for_script_execution = |
| 55 permissions_data->RequiresActionForScriptExecution(extension, | 54 permissions_data->RequiresActionForScriptExecution(extension, |
| 56 -1, // No tab id. | 55 -1, // No tab id. |
| 57 GURL()); | 56 GURL()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 117 } |
| 119 | 118 |
| 120 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { | 119 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { |
| 121 if (granted_extensions_.is_empty()) | 120 if (granted_extensions_.is_empty()) |
| 122 return; | 121 return; |
| 123 | 122 |
| 124 std::vector<std::string> extension_ids; | 123 std::vector<std::string> extension_ids; |
| 125 | 124 |
| 126 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); | 125 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); |
| 127 it != granted_extensions_.end(); ++it) { | 126 it != granted_extensions_.end(); ++it) { |
| 128 PermissionsData::ForExtension(it->get()) | 127 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
| 129 ->ClearTabSpecificPermissions(tab_id_); | |
| 130 extension_ids.push_back((*it)->id()); | 128 extension_ids.push_back((*it)->id()); |
| 131 } | 129 } |
| 132 | 130 |
| 133 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 131 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
| 134 granted_extensions_.Clear(); | 132 granted_extensions_.Clear(); |
| 135 } | 133 } |
| 136 | 134 |
| 137 } // namespace extensions | 135 } // namespace extensions |
| OLD | NEW |