Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_script_controller.h" | 5 #include "chrome/browser/extensions/active_script_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 // TODO(devlin): Make sure that the permission is removed from | 132 // TODO(devlin): Make sure that the permission is removed from |
| 133 // withheld_permissions if appropriate. | 133 // withheld_permissions if appropriate. |
| 134 PermissionsUpdater(web_contents()->GetBrowserContext()) | 134 PermissionsUpdater(web_contents()->GetBrowserContext()) |
| 135 .AddPermissions(extension, new_permissions.get()); | 135 .AddPermissions(extension, new_permissions.get()); |
| 136 | 136 |
| 137 // Allow current tab to run injection. | 137 // Allow current tab to run injection. |
| 138 OnClicked(extension); | 138 OnClicked(extension); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool ActiveScriptController::HasActiveScriptAction(const Extension* extension) { | 141 bool ActiveScriptController::HasActiveScriptAction(const Extension* extension) { |
| 142 return enabled_ && active_script_actions_.count(extension->id()) > 0; | 142 return enabled_ && pending_requests_.count(extension->id()) > 0; |
|
not at google - send to devlin
2014/08/20 20:27:07
active_script_actions_ seems like the right check
| |
| 143 } | 143 } |
| 144 | 144 |
| 145 ExtensionAction* ActiveScriptController::GetActionForExtension( | 145 ExtensionAction* ActiveScriptController::GetActionForExtension( |
| 146 const Extension* extension) { | 146 const Extension* extension) { |
| 147 if (!enabled_ || pending_requests_.count(extension->id()) == 0) | 147 if (!enabled_ || pending_requests_.count(extension->id()) == 0) |
| 148 return NULL; // No action for this extension. | 148 return NULL; // No action for this extension. |
| 149 | 149 |
| 150 ActiveScriptMap::iterator existing = | 150 ActiveScriptMap::iterator existing = |
| 151 active_script_actions_.find(extension->id()); | 151 active_script_actions_.find(extension->id()); |
| 152 if (existing != active_script_actions_.end()) | 152 if (existing != active_script_actions_.end()) |
| 153 return existing->second.get(); | 153 return existing->second.get(); |
| 154 | 154 |
| 155 linked_ptr<ExtensionAction> action(ExtensionActionManager::Get( | 155 linked_ptr<ExtensionAction> action(ExtensionActionManager::Get( |
| 156 Profile::FromBrowserContext(web_contents()->GetBrowserContext())) | 156 Profile::FromBrowserContext(web_contents()->GetBrowserContext())) |
| 157 ->GetBestFitAction(*extension, ActionInfo::TYPE_PAGE).release()); | 157 ->GetBestFitAction(*extension, ActionInfo::TYPE_PAGE).release()); |
| 158 action->SetIsVisible(ExtensionAction::kDefaultTabId, true); | 158 action->SetIsVisible(ExtensionAction::kDefaultTabId, true); |
| 159 | 159 |
| 160 active_script_actions_[extension->id()] = action; | 160 active_script_actions_[extension->id()] = action; |
|
gpdavis
2014/08/21 21:39:11
active_script_actions_ is only manipulated in this
| |
| 161 return action.get(); | 161 return action.get(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 ExtensionAction::ShowAction ActiveScriptController::OnClicked( | 164 ExtensionAction::ShowAction ActiveScriptController::OnClicked( |
| 165 const Extension* extension) { | 165 const Extension* extension) { |
| 166 DCHECK(ContainsKey(pending_requests_, extension->id())); | 166 DCHECK(ContainsKey(pending_requests_, extension->id())); |
| 167 RunPendingForExtension(extension); | 167 RunPendingForExtension(extension); |
| 168 return ExtensionAction::ACTION_NONE; | 168 return ExtensionAction::ACTION_NONE; |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 UMA_HISTOGRAM_COUNTS_100( | 346 UMA_HISTOGRAM_COUNTS_100( |
| 347 "Extensions.ActiveScriptController.PermittedExtensions", | 347 "Extensions.ActiveScriptController.PermittedExtensions", |
| 348 permitted_extensions_.size()); | 348 permitted_extensions_.size()); |
| 349 UMA_HISTOGRAM_COUNTS_100( | 349 UMA_HISTOGRAM_COUNTS_100( |
| 350 "Extensions.ActiveScriptController.DeniedExtensions", | 350 "Extensions.ActiveScriptController.DeniedExtensions", |
| 351 pending_requests_.size()); | 351 pending_requests_.size()); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 } // namespace extensions | 355 } // namespace extensions |
| OLD | NEW |