Chromium Code Reviews| 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/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "extensions/browser/extension_registry.h" | 12 #include "extensions/browser/extension_registry.h" |
| 13 #include "extensions/common/extension_messages.h" | 13 #include "extensions/common/extension_messages.h" |
| 14 #include "extensions/common/feature_switch.h" | |
| 14 #include "extensions/common/permissions/permission_set.h" | 15 #include "extensions/common/permissions/permission_set.h" |
| 15 #include "extensions/common/permissions/permissions_data.h" | 16 #include "extensions/common/permissions/permissions_data.h" |
| 16 #include "extensions/common/user_script.h" | 17 #include "extensions/common/user_script.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 using content::RenderProcessHost; | 20 using content::RenderProcessHost; |
| 20 using content::WebContentsObserver; | 21 using content::WebContentsObserver; |
| 21 | 22 |
| 22 namespace extensions { | 23 namespace extensions { |
| 23 | 24 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 | 87 |
| 87 void ActiveTabPermissionGranter::DidNavigateMainFrame( | 88 void ActiveTabPermissionGranter::DidNavigateMainFrame( |
| 88 const content::LoadCommittedDetails& details, | 89 const content::LoadCommittedDetails& details, |
| 89 const content::FrameNavigateParams& params) { | 90 const content::FrameNavigateParams& params) { |
| 90 if (details.is_in_page) | 91 if (details.is_in_page) |
| 91 return; | 92 return; |
| 92 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! | 93 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! |
| 93 ClearActiveExtensionsAndNotify(); | 94 |
| 95 // See http://crbug.com/404243 for why we do this. Only do this when the | |
| 96 // script-require-action flag is on, since it's not clear it's generally a | |
| 97 // good idea. However, the scripts-require-action feature is all-but unusable | |
| 98 // without this behaviour. | |
| 99 if (details.previous_url.GetOrigin() != details.entry->GetURL().GetOrigin() || | |
|
Devlin
2014/08/15 21:24:00
I seem to recall that NavigationEntries are one of
not at google - send to devlin
2014/08/15 21:38:29
Ah yes, good point. Fixed.
| |
| 100 !FeatureSwitch::scripts_require_action()->IsEnabled()) { | |
| 101 ClearActiveExtensionsAndNotify(); | |
| 102 } | |
| 94 } | 103 } |
| 95 | 104 |
| 96 void ActiveTabPermissionGranter::WebContentsDestroyed() { | 105 void ActiveTabPermissionGranter::WebContentsDestroyed() { |
| 97 ClearActiveExtensionsAndNotify(); | 106 ClearActiveExtensionsAndNotify(); |
| 98 } | 107 } |
| 99 | 108 |
| 100 void ActiveTabPermissionGranter::OnExtensionUnloaded( | 109 void ActiveTabPermissionGranter::OnExtensionUnloaded( |
| 101 content::BrowserContext* browser_context, | 110 content::BrowserContext* browser_context, |
| 102 const Extension* extension, | 111 const Extension* extension, |
| 103 UnloadedExtensionInfo::Reason reason) { | 112 UnloadedExtensionInfo::Reason reason) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 116 it != granted_extensions_.end(); ++it) { | 125 it != granted_extensions_.end(); ++it) { |
| 117 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); | 126 it->get()->permissions_data()->ClearTabSpecificPermissions(tab_id_); |
| 118 extension_ids.push_back((*it)->id()); | 127 extension_ids.push_back((*it)->id()); |
| 119 } | 128 } |
| 120 | 129 |
| 121 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); | 130 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); |
| 122 granted_extensions_.Clear(); | 131 granted_extensions_.Clear(); |
| 123 } | 132 } |
| 124 | 133 |
| 125 } // namespace extensions | 134 } // namespace extensions |
| OLD | NEW |