| 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/location_bar_controller.h" | 5 #include "chrome/browser/extensions/location_bar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 10 #include "chrome/browser/extensions/extension_action_manager.h" | 10 #include "chrome/browser/extensions/extension_action_manager.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Right now, we can consolidate these actions because we only want to show | 49 // Right now, we can consolidate these actions because we only want to show |
| 50 // one action per extension. If clicking on an active script action ever | 50 // one action per extension. If clicking on an active script action ever |
| 51 // has a response, then we will need to split the actions. | 51 // has a response, then we will need to split the actions. |
| 52 ExtensionAction* action = action_manager_->GetPageAction(*extension); | 52 ExtensionAction* action = action_manager_->GetPageAction(*extension); |
| 53 if (!action && action_executor->WantsToRun(extension.get())) { | 53 if (!action && action_executor->WantsToRun(extension.get())) { |
| 54 ExtensionActionMap::iterator existing = | 54 ExtensionActionMap::iterator existing = |
| 55 active_script_actions_.find(extension->id()); | 55 active_script_actions_.find(extension->id()); |
| 56 if (existing != active_script_actions_.end()) { | 56 if (existing != active_script_actions_.end()) { |
| 57 action = existing->second.get(); | 57 action = existing->second.get(); |
| 58 } else { | 58 } else { |
| 59 linked_ptr<ExtensionAction> active_script_action( | 59 std::unique_ptr<ExtensionAction> active_script_action = |
| 60 ExtensionActionManager::Get(browser_context_)-> | 60 ExtensionActionManager::Get(browser_context_) |
| 61 GetBestFitAction(*extension, ActionInfo::TYPE_PAGE).release()); | 61 ->GetBestFitAction(*extension, ActionInfo::TYPE_PAGE); |
| 62 active_script_action->SetIsVisible( | 62 active_script_action->SetIsVisible( |
| 63 ExtensionAction::kDefaultTabId, true); | 63 ExtensionAction::kDefaultTabId, true); |
| 64 active_script_actions_[extension->id()] = active_script_action; | |
| 65 action = active_script_action.get(); | 64 action = active_script_action.get(); |
| 65 active_script_actions_[extension->id()] = |
| 66 std::move(active_script_action); |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 if (action) | 70 if (action) |
| 70 current_actions.push_back(action); | 71 current_actions.push_back(action); |
| 71 } | 72 } |
| 72 | 73 |
| 73 // Sort by id to guarantee the extension actions are returned in the same | 74 // Sort by id to guarantee the extension actions are returned in the same |
| 74 // order every time this function is called. | 75 // order every time this function is called. |
| 75 std::sort(current_actions.begin(), current_actions.end(), | 76 std::sort(current_actions.begin(), current_actions.end(), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 content::BrowserContext* browser_context, | 122 content::BrowserContext* browser_context, |
| 122 const Extension* extension, | 123 const Extension* extension, |
| 123 UnloadedExtensionInfo::Reason reason) { | 124 UnloadedExtensionInfo::Reason reason) { |
| 124 if (should_show_page_actions_ && action_manager_->GetPageAction(*extension)) { | 125 if (should_show_page_actions_ && action_manager_->GetPageAction(*extension)) { |
| 125 ExtensionActionAPI::Get(browser_context)-> | 126 ExtensionActionAPI::Get(browser_context)-> |
| 126 NotifyPageActionsChanged(web_contents_); | 127 NotifyPageActionsChanged(web_contents_); |
| 127 } | 128 } |
| 128 } | 129 } |
| 129 | 130 |
| 130 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |