| 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/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
| 9 #include "content/public/browser/navigation_entry.h" | 9 #include "content/public/browser/navigation_entry.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 Profile* profile) | 25 Profile* profile) |
| 26 : WebContentsObserver(web_contents), | 26 : WebContentsObserver(web_contents), |
| 27 tab_id_(tab_id), | 27 tab_id_(tab_id), |
| 28 extension_registry_observer_(this) { | 28 extension_registry_observer_(this) { |
| 29 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 29 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} | 32 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} |
| 33 | 33 |
| 34 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { | 34 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { |
| 35 // Active tab grant request implies there was a user gesture. | |
| 36 web_contents()->UserGestureDone(); | |
| 37 | |
| 38 if (granted_extensions_.Contains(extension->id())) | 35 if (granted_extensions_.Contains(extension->id())) |
| 39 return; | 36 return; |
| 40 | 37 |
| 41 APIPermissionSet new_apis; | 38 APIPermissionSet new_apis; |
| 42 URLPatternSet new_hosts; | 39 URLPatternSet new_hosts; |
| 43 | 40 |
| 44 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { | 41 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { |
| 45 URLPattern pattern(UserScript::ValidUserScriptSchemes()); | 42 URLPattern pattern(UserScript::ValidUserScriptSchemes()); |
| 46 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 43 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. |
| 47 if (pattern.Parse(web_contents()->GetURL().spec()) == | 44 if (pattern.Parse(web_contents()->GetURL().spec()) == |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 it != granted_extensions_.end(); ++it) { | 103 it != granted_extensions_.end(); ++it) { |
| 107 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); | 104 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); |
| 108 extension_ids.push_back((*it)->id()); | 105 extension_ids.push_back((*it)->id()); |
| 109 } | 106 } |
| 110 | 107 |
| 111 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
| 112 granted_extensions_.Clear(); | 109 granted_extensions_.Clear(); |
| 113 } | 110 } |
| 114 | 111 |
| 115 } // namespace extensions | 112 } // namespace extensions |
| OLD | NEW |