| 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/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} | 35 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} |
| 36 | 36 |
| 37 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { | 37 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { |
| 38 if (!extension->HasAPIPermission(extensions::APIPermission::kActiveTab)) | 38 if (!extension->HasAPIPermission(extensions::APIPermission::kActiveTab)) |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 if (IsGranted(extension)) | 41 if (IsGranted(extension)) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 NOTREACHED(); |
| 45 |
| 44 URLPattern pattern(UserScript::kValidUserScriptSchemes); | 46 URLPattern pattern(UserScript::kValidUserScriptSchemes); |
| 45 if (pattern.Parse(web_contents()->GetURL().spec()) != | 47 if (pattern.Parse(web_contents()->GetURL().spec()) != |
| 46 URLPattern::PARSE_SUCCESS) { | 48 URLPattern::PARSE_SUCCESS) { |
| 47 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 49 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. |
| 48 return; | 50 return; |
| 49 } | 51 } |
| 50 | 52 |
| 51 APIPermissionSet new_apis; | 53 APIPermissionSet new_apis; |
| 52 new_apis.insert(APIPermission::kTab); | 54 new_apis.insert(APIPermission::kTab); |
| 53 URLPatternSet new_hosts; | 55 URLPatternSet new_hosts; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 109 |
| 108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 110 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
| 109 granted_extensions_.Clear(); | 111 granted_extensions_.Clear(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 int32 ActiveTabPermissionGranter::GetPageID() { | 114 int32 ActiveTabPermissionGranter::GetPageID() { |
| 113 return web_contents()->GetController().GetActiveEntry()->GetPageID(); | 115 return web_contents()->GetController().GetActiveEntry()->GetPageID(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 } // namespace extensions | 118 } // namespace extensions |
| OLD | NEW |