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 16 matching lines...) Expand all Loading... |
27 Profile* profile) | 27 Profile* profile) |
28 : WebContentsObserver(web_contents), | 28 : WebContentsObserver(web_contents), |
29 tab_id_(tab_id), | 29 tab_id_(tab_id), |
30 extension_registry_observer_(this) { | 30 extension_registry_observer_(this) { |
31 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 31 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
32 } | 32 } |
33 | 33 |
34 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} | 34 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} |
35 | 35 |
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. | |
38 web_contents()->UserGestureDone(); | |
39 | |
40 if (granted_extensions_.Contains(extension->id())) | 37 if (granted_extensions_.Contains(extension->id())) |
41 return; | 38 return; |
42 | 39 |
43 APIPermissionSet new_apis; | 40 APIPermissionSet new_apis; |
44 URLPatternSet new_hosts; | 41 URLPatternSet new_hosts; |
45 | 42 |
46 const PermissionsData* permissions_data = extension->permissions_data(); | 43 const PermissionsData* permissions_data = extension->permissions_data(); |
47 | 44 |
48 // If the extension requested all-hosts but has had it withheld, we grant it | 45 // If the extension requested all-hosts but has had it withheld, we grant it |
49 // active tab-style permissions, even if it doesn't have the activeTab | 46 // active tab-style permissions, even if it doesn't have the activeTab |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 it != granted_extensions_.end(); ++it) { | 116 it != granted_extensions_.end(); ++it) { |
120 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); | 117 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
121 extension_ids.push_back((*it)->id()); | 118 extension_ids.push_back((*it)->id()); |
122 } | 119 } |
123 | 120 |
124 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 121 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
125 granted_extensions_.Clear(); | 122 granted_extensions_.Clear(); |
126 } | 123 } |
127 | 124 |
128 } // namespace extensions | 125 } // namespace extensions |
OLD | NEW |