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/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
9 #include "content/public/browser/navigation_entry.h" | 9 #include "content/public/browser/navigation_entry.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 void ActiveTabPermissionGranter::DidNavigateMainFrame( | 77 void ActiveTabPermissionGranter::DidNavigateMainFrame( |
78 const content::LoadCommittedDetails& details, | 78 const content::LoadCommittedDetails& details, |
79 const content::FrameNavigateParams& params) { | 79 const content::FrameNavigateParams& params) { |
80 if (details.is_in_page) | 80 if (details.is_in_page) |
81 return; | 81 return; |
82 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! | 82 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! |
83 ClearActiveExtensionsAndNotify(); | 83 ClearActiveExtensionsAndNotify(); |
84 } | 84 } |
85 | 85 |
86 void ActiveTabPermissionGranter::WebContentsDestroyed( | 86 void ActiveTabPermissionGranter::WebContentsDestroyed() { |
87 content::WebContents* web_contents) { | |
88 ClearActiveExtensionsAndNotify(); | 87 ClearActiveExtensionsAndNotify(); |
89 } | 88 } |
90 | 89 |
91 void ActiveTabPermissionGranter::OnExtensionUnloaded( | 90 void ActiveTabPermissionGranter::OnExtensionUnloaded( |
92 content::BrowserContext* browser_context, | 91 content::BrowserContext* browser_context, |
93 const Extension* extension, | 92 const Extension* extension, |
94 UnloadedExtensionInfo::Reason reason) { | 93 UnloadedExtensionInfo::Reason reason) { |
95 // Note: don't need to clear the permissions (nor tell the renderer about it) | 94 // Note: don't need to clear the permissions (nor tell the renderer about it) |
96 // because it's being unloaded anyway. | 95 // because it's being unloaded anyway. |
97 granted_extensions_.Remove(extension->id()); | 96 granted_extensions_.Remove(extension->id()); |
98 } | 97 } |
99 | 98 |
100 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { | 99 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { |
101 if (granted_extensions_.is_empty()) | 100 if (granted_extensions_.is_empty()) |
102 return; | 101 return; |
103 | 102 |
104 std::vector<std::string> extension_ids; | 103 std::vector<std::string> extension_ids; |
105 | 104 |
106 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); | 105 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); |
107 it != granted_extensions_.end(); ++it) { | 106 it != granted_extensions_.end(); ++it) { |
108 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); | 107 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); |
109 extension_ids.push_back((*it)->id()); | 108 extension_ids.push_back((*it)->id()); |
110 } | 109 } |
111 | 110 |
112 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 111 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
113 granted_extensions_.Clear(); | 112 granted_extensions_.Clear(); |
114 } | 113 } |
115 | 114 |
116 } // namespace extensions | 115 } // namespace extensions |
OLD | NEW |