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 URLPattern pattern(UserScript::kValidUserScriptSchemes); | 44 URLPattern pattern(UserScript::ValidUserScriptSchemes()); |
45 if (pattern.Parse(web_contents()->GetURL().spec()) != | 45 if (pattern.Parse(web_contents()->GetURL().spec()) != |
46 URLPattern::PARSE_SUCCESS) { | 46 URLPattern::PARSE_SUCCESS) { |
47 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. | 47 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 APIPermissionSet new_apis; | 51 APIPermissionSet new_apis; |
52 new_apis.insert(APIPermission::kTab); | 52 new_apis.insert(APIPermission::kTab); |
53 URLPatternSet new_hosts; | 53 URLPatternSet new_hosts; |
54 new_hosts.AddPattern(pattern); | 54 new_hosts.AddPattern(pattern); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
109 granted_extensions_.Clear(); | 109 granted_extensions_.Clear(); |
110 } | 110 } |
111 | 111 |
112 int32 ActiveTabPermissionGranter::GetPageID() { | 112 int32 ActiveTabPermissionGranter::GetPageID() { |
113 return web_contents()->GetController().GetActiveEntry()->GetPageID(); | 113 return web_contents()->GetController().GetActiveEntry()->GetPageID(); |
114 } | 114 } |
115 | 115 |
116 } // namespace extensions | 116 } // namespace extensions |
OLD | NEW |