| 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/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sessions/session_id.h" | 10 #include "chrome/browser/sessions/session_id.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 content::WebContents* web_contents, int tab_id, Profile* profile) | 30 content::WebContents* web_contents, int tab_id, Profile* profile) |
| 31 : WebContentsObserver(web_contents), tab_id_(tab_id) { | 31 : WebContentsObserver(web_contents), tab_id_(tab_id) { |
| 32 registrar_.Add(this, | 32 registrar_.Add(this, |
| 33 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 33 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 34 content::Source<Profile>(profile)); | 34 content::Source<Profile>(profile)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} | 37 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} |
| 38 | 38 |
| 39 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { | 39 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { |
| 40 // Active tab grant request implies there was a user gesture. |
| 41 web_contents()->UserGestureDone(); |
| 42 |
| 40 if (granted_extensions_.Contains(extension->id())) | 43 if (granted_extensions_.Contains(extension->id())) |
| 41 return; | 44 return; |
| 42 | 45 |
| 43 APIPermissionSet new_apis; | 46 APIPermissionSet new_apis; |
| 44 URLPatternSet new_hosts; | 47 URLPatternSet new_hosts; |
| 45 | 48 |
| 46 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { | 49 if (extension->HasAPIPermission(APIPermission::kActiveTab)) { |
| 47 URLPattern pattern(UserScript::ValidUserScriptSchemes()); | 50 URLPattern pattern(UserScript::ValidUserScriptSchemes()); |
| 48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 51 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. |
| 49 if (pattern.Parse(web_contents()->GetURL().spec()) == | 52 if (pattern.Parse(web_contents()->GetURL().spec()) == |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 it != granted_extensions_.end(); ++it) { | 115 it != granted_extensions_.end(); ++it) { |
| 113 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); | 116 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); |
| 114 extension_ids.push_back((*it)->id()); | 117 extension_ids.push_back((*it)->id()); |
| 115 } | 118 } |
| 116 | 119 |
| 117 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 120 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
| 118 granted_extensions_.Clear(); | 121 granted_extensions_.Clear(); |
| 119 } | 122 } |
| 120 | 123 |
| 121 } // namespace extensions | 124 } // namespace extensions |
| OLD | NEW |