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/active_script_controller.h" | 7 #include "chrome/browser/extensions/active_script_controller.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/navigation_details.h" | 9 #include "content/public/browser/navigation_details.h" |
10 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
| 11 #include "content/public/browser/render_view_host.h" |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "extensions/browser/extension_registry.h" | 13 #include "extensions/browser/extension_registry.h" |
13 #include "extensions/common/extension_messages.h" | 14 #include "extensions/common/extension_messages.h" |
14 #include "extensions/common/feature_switch.h" | 15 #include "extensions/common/feature_switch.h" |
15 #include "extensions/common/permissions/permission_set.h" | 16 #include "extensions/common/permissions/permission_set.h" |
16 #include "extensions/common/permissions/permissions_data.h" | 17 #include "extensions/common/permissions/permissions_data.h" |
17 #include "extensions/common/user_script.h" | 18 #include "extensions/common/user_script.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 using content::RenderProcessHost; | 21 using content::RenderProcessHost; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 59 |
59 if (!new_apis.empty() || !new_hosts.is_empty()) { | 60 if (!new_apis.empty() || !new_hosts.is_empty()) { |
60 granted_extensions_.Insert(extension); | 61 granted_extensions_.Insert(extension); |
61 scoped_refptr<const PermissionSet> new_permissions = | 62 scoped_refptr<const PermissionSet> new_permissions = |
62 new PermissionSet(new_apis, ManifestPermissionSet(), | 63 new PermissionSet(new_apis, ManifestPermissionSet(), |
63 new_hosts, URLPatternSet()); | 64 new_hosts, URLPatternSet()); |
64 permissions_data->UpdateTabSpecificPermissions(tab_id_, new_permissions); | 65 permissions_data->UpdateTabSpecificPermissions(tab_id_, new_permissions); |
65 const content::NavigationEntry* navigation_entry = | 66 const content::NavigationEntry* navigation_entry = |
66 web_contents()->GetController().GetVisibleEntry(); | 67 web_contents()->GetController().GetVisibleEntry(); |
67 if (navigation_entry) { | 68 if (navigation_entry) { |
68 Send(new ExtensionMsg_UpdateTabSpecificPermissions( | 69 content::RenderViewHost* render_view_host = |
| 70 web_contents()->GetRenderViewHost(); |
| 71 render_view_host->Send(new ExtensionMsg_UpdateTabSpecificPermissions( |
| 72 render_view_host->GetRoutingID(), |
69 navigation_entry->GetURL(), | 73 navigation_entry->GetURL(), |
70 tab_id_, | |
71 extension->id(), | 74 extension->id(), |
72 new_hosts)); | 75 new_hosts)); |
73 // If more things ever need to know about this, we should consider making | 76 // If more things ever need to know about this, we should consider making |
74 // an observer class. | 77 // an observer class. |
75 // It's important that this comes after the IPC is sent to the renderer, | 78 // It's important that this comes after the IPC is sent to the renderer, |
76 // so that any tasks executing in the renderer occur after it has the | 79 // so that any tasks executing in the renderer occur after it has the |
77 // updated permissions. | 80 // updated permissions. |
78 ActiveScriptController::GetForWebContents(web_contents()) | 81 ActiveScriptController::GetForWebContents(web_contents()) |
79 ->OnActiveTabPermissionGranted(extension); | 82 ->OnActiveTabPermissionGranted(extension); |
80 } | 83 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return; | 129 return; |
127 | 130 |
128 std::vector<std::string> extension_ids; | 131 std::vector<std::string> extension_ids; |
129 | 132 |
130 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); | 133 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); |
131 it != granted_extensions_.end(); ++it) { | 134 it != granted_extensions_.end(); ++it) { |
132 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); | 135 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
133 extension_ids.push_back((*it)->id()); | 136 extension_ids.push_back((*it)->id()); |
134 } | 137 } |
135 | 138 |
136 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 139 content::RenderViewHost* render_view_host = |
| 140 web_contents()->GetRenderViewHost(); |
| 141 render_view_host->Send(new ExtensionMsg_ClearTabSpecificPermissions( |
| 142 render_view_host->GetRoutingID(), extension_ids)); |
137 granted_extensions_.Clear(); | 143 granted_extensions_.Clear(); |
138 } | 144 } |
139 | 145 |
140 } // namespace extensions | 146 } // namespace extensions |
OLD | NEW |