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_manager.h" | 5 #include "chrome/browser/extensions/active_tab_permission_manager.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/extensions/extension_tab_helper.h" | 9 #include "chrome/browser/extensions/extension_tab_helper.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_messages.h" | 14 #include "chrome/common/extensions/extension_messages.h" |
15 #include "chrome/common/extensions/extension_permission_set.h" | 15 #include "chrome/common/extensions/permissions/permission_set.h" |
16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 | 22 |
23 using content::RenderProcessHost; | 23 using content::RenderProcessHost; |
24 using content::WebContentsObserver; | 24 using content::WebContentsObserver; |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 | 27 |
28 ActiveTabPermissionManager::ActiveTabPermissionManager( | 28 ActiveTabPermissionManager::ActiveTabPermissionManager( |
29 TabContents* tab_contents) | 29 TabContents* tab_contents) |
30 : WebContentsObserver(tab_contents->web_contents()), | 30 : WebContentsObserver(tab_contents->web_contents()), |
31 tab_contents_(tab_contents) { | 31 tab_contents_(tab_contents) { |
32 InsertActiveURL(web_contents()->GetURL()); | 32 InsertActiveURL(web_contents()->GetURL()); |
33 registrar_.Add(this, | 33 registrar_.Add(this, |
34 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 34 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
35 content::Source<Profile>(tab_contents->profile())); | 35 content::Source<Profile>(tab_contents->profile())); |
36 } | 36 } |
37 | 37 |
38 ActiveTabPermissionManager::~ActiveTabPermissionManager() {} | 38 ActiveTabPermissionManager::~ActiveTabPermissionManager() {} |
39 | 39 |
40 void ActiveTabPermissionManager::GrantIfRequested(const Extension* extension) { | 40 void ActiveTabPermissionManager::GrantIfRequested(const Extension* extension) { |
41 if (!extension->HasAPIPermission(ExtensionAPIPermission::kActiveTab)) | 41 if (!extension->HasAPIPermission(extensions::APIPermission::kActiveTab)) |
42 return; | 42 return; |
43 | 43 |
44 if (active_urls_.is_empty()) | 44 if (active_urls_.is_empty()) |
45 return; | 45 return; |
46 | 46 |
47 // Only need to check the number of permissions here rather than the URLs | 47 // Only need to check the number of permissions here rather than the URLs |
48 // themselves, because the set can only ever grow. | 48 // themselves, because the set can only ever grow. |
49 const URLPatternSet* old_permissions = | 49 const URLPatternSet* old_permissions = |
50 extension->GetTabSpecificHostPermissions(tab_id()); | 50 extension->GetTabSpecificHostPermissions(tab_id()); |
51 if (old_permissions && (old_permissions->size() == active_urls_.size())) | 51 if (old_permissions && (old_permissions->size() == active_urls_.size())) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 int32 ActiveTabPermissionManager::tab_id() { | 124 int32 ActiveTabPermissionManager::tab_id() { |
125 return tab_contents_->extension_tab_helper()->tab_id(); | 125 return tab_contents_->extension_tab_helper()->tab_id(); |
126 } | 126 } |
127 | 127 |
128 int32 ActiveTabPermissionManager::GetPageID() { | 128 int32 ActiveTabPermissionManager::GetPageID() { |
129 return tab_contents_->web_contents()->GetController().GetActiveEntry()-> | 129 return tab_contents_->web_contents()->GetController().GetActiveEntry()-> |
130 GetPageID(); | 130 GetPageID(); |
131 } | 131 } |
132 | 132 |
133 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |