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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "content/public/browser/navigation_details.h" | 9 #include "content/public/browser/navigation_details.h" |
9 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
11 #include "extensions/browser/extension_registry.h" | 12 #include "extensions/browser/extension_registry.h" |
12 #include "extensions/common/extension_messages.h" | 13 #include "extensions/common/extension_messages.h" |
13 #include "extensions/common/permissions/permission_set.h" | 14 #include "extensions/common/permissions/permission_set.h" |
14 #include "extensions/common/permissions/permissions_data.h" | 15 #include "extensions/common/permissions/permissions_data.h" |
15 #include "extensions/common/user_script.h" | 16 #include "extensions/common/user_script.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 if (!new_apis.empty() || !new_hosts.is_empty()) { | 71 if (!new_apis.empty() || !new_hosts.is_empty()) { |
71 granted_extensions_.Insert(extension); | 72 granted_extensions_.Insert(extension); |
72 scoped_refptr<const PermissionSet> new_permissions = | 73 scoped_refptr<const PermissionSet> new_permissions = |
73 new PermissionSet(new_apis, ManifestPermissionSet(), | 74 new PermissionSet(new_apis, ManifestPermissionSet(), |
74 new_hosts, URLPatternSet()); | 75 new_hosts, URLPatternSet()); |
75 PermissionsData::UpdateTabSpecificPermissions(extension, | 76 PermissionsData::UpdateTabSpecificPermissions(extension, |
76 tab_id_, | 77 tab_id_, |
77 new_permissions); | 78 new_permissions); |
78 const content::NavigationEntry* navigation_entry = | 79 const content::NavigationEntry* navigation_entry = |
79 web_contents()->GetController().GetVisibleEntry(); | 80 web_contents()->GetController().GetVisibleEntry(); |
80 if (navigation_entry) { | 81 if (navigation_entry) { |
not at google - send to devlin
2014/05/22 20:44:49
I don't see why this should be gated on a navigati
Devlin
2014/05/22 22:12:36
Conceptually, if there's no navigation entry, we d
not at google - send to devlin
2014/05/22 22:21:47
Yeah so some of this is part of a larger question:
| |
81 Send(new ExtensionMsg_UpdateTabSpecificPermissions( | 82 Send(new ExtensionMsg_UpdateTabSpecificPermissions( |
82 navigation_entry->GetPageID(), | 83 navigation_entry->GetPageID(), |
83 tab_id_, | 84 tab_id_, |
84 extension->id(), | 85 extension->id(), |
85 new_hosts)); | 86 new_hosts)); |
87 // If more things ever need to know about this, we should consider making | |
88 // an observer class. | |
not at google - send to devlin
2014/05/22 20:44:49
yes indeed :)
which is to say, good comment, don'
| |
89 ActiveScriptController::GetForWebContents(web_contents()) | |
not at google - send to devlin
2014/05/22 20:44:49
also add a note to do this after the IPC has been
Devlin
2014/05/22 22:12:36
Done.
| |
90 ->OnActiveTabPermissionGranted(extension); | |
86 } | 91 } |
87 } | 92 } |
88 } | 93 } |
89 | 94 |
90 void ActiveTabPermissionGranter::DidNavigateMainFrame( | 95 void ActiveTabPermissionGranter::DidNavigateMainFrame( |
91 const content::LoadCommittedDetails& details, | 96 const content::LoadCommittedDetails& details, |
92 const content::FrameNavigateParams& params) { | 97 const content::FrameNavigateParams& params) { |
93 if (details.is_in_page) | 98 if (details.is_in_page) |
94 return; | 99 return; |
95 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! | 100 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! |
(...skipping 23 matching lines...) Expand all Loading... | |
119 it != granted_extensions_.end(); ++it) { | 124 it != granted_extensions_.end(); ++it) { |
120 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); | 125 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); |
121 extension_ids.push_back((*it)->id()); | 126 extension_ids.push_back((*it)->id()); |
122 } | 127 } |
123 | 128 |
124 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 129 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
125 granted_extensions_.Clear(); | 130 granted_extensions_.Clear(); |
126 } | 131 } |
127 | 132 |
128 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |