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/extension_action_manager.h" | 5 #include "chrome/browser/extensions/extension_action_manager.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage
r_factory.h" | 7 #include "chrome/browser/extensions/api/system_indicator/system_indicator_manage
r_factory.h" |
8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 | 126 |
127 ExtensionAction* ExtensionActionManager::GetBrowserAction( | 127 ExtensionAction* ExtensionActionManager::GetBrowserAction( |
128 const Extension& extension) const { | 128 const Extension& extension) const { |
129 return GetOrCreateOrNull(&browser_actions_, extension, | 129 return GetOrCreateOrNull(&browser_actions_, extension, |
130 ActionInfo::TYPE_BROWSER, | 130 ActionInfo::TYPE_BROWSER, |
131 ActionInfo::GetBrowserActionInfo(&extension), | 131 ActionInfo::GetBrowserActionInfo(&extension), |
132 profile_); | 132 profile_); |
133 } | 133 } |
134 | 134 |
135 scoped_ptr<ExtensionAction> ExtensionActionManager::GetBestFitAction( | 135 std::unique_ptr<ExtensionAction> ExtensionActionManager::GetBestFitAction( |
136 const Extension& extension, | 136 const Extension& extension, |
137 ActionInfo::Type type) const { | 137 ActionInfo::Type type) const { |
138 const ActionInfo* info = ActionInfo::GetBrowserActionInfo(&extension); | 138 const ActionInfo* info = ActionInfo::GetBrowserActionInfo(&extension); |
139 if (!info) | 139 if (!info) |
140 info = ActionInfo::GetPageActionInfo(&extension); | 140 info = ActionInfo::GetPageActionInfo(&extension); |
141 | 141 |
142 // Create a new ExtensionAction of |type| with |extension|'s ActionInfo. | 142 // Create a new ExtensionAction of |type| with |extension|'s ActionInfo. |
143 // If no ActionInfo exists for |extension|, create and return a new action | 143 // If no ActionInfo exists for |extension|, create and return a new action |
144 // with a blank ActionInfo. | 144 // with a blank ActionInfo. |
145 // Populate any missing values from |extension|'s manifest. | 145 // Populate any missing values from |extension|'s manifest. |
146 scoped_ptr<ExtensionAction> new_action(new ExtensionAction( | 146 std::unique_ptr<ExtensionAction> new_action( |
147 extension, type, info ? *info : ActionInfo())); | 147 new ExtensionAction(extension, type, info ? *info : ActionInfo())); |
148 return new_action; | 148 return new_action; |
149 } | 149 } |
150 | 150 |
151 ExtensionAction* ExtensionActionManager::GetSystemIndicator( | 151 ExtensionAction* ExtensionActionManager::GetSystemIndicator( |
152 const Extension& extension) const { | 152 const Extension& extension) const { |
153 // If it does not already exist, create the SystemIndicatorManager for the | 153 // If it does not already exist, create the SystemIndicatorManager for the |
154 // given profile. This could return NULL if the system indicator area is | 154 // given profile. This could return NULL if the system indicator area is |
155 // unavailable on the current system. If so, return NULL to signal that | 155 // unavailable on the current system. If so, return NULL to signal that |
156 // the system indicator area is unusable. | 156 // the system indicator area is unusable. |
157 if (!SystemIndicatorManagerFactory::GetForProfile(profile_)) | 157 if (!SystemIndicatorManagerFactory::GetForProfile(profile_)) |
158 return NULL; | 158 return NULL; |
159 | 159 |
160 return GetOrCreateOrNull(&system_indicators_, extension, | 160 return GetOrCreateOrNull(&system_indicators_, extension, |
161 ActionInfo::TYPE_SYSTEM_INDICATOR, | 161 ActionInfo::TYPE_SYSTEM_INDICATOR, |
162 ActionInfo::GetSystemIndicatorInfo(&extension), | 162 ActionInfo::GetSystemIndicatorInfo(&extension), |
163 profile_); | 163 profile_); |
164 } | 164 } |
165 | 165 |
166 ExtensionAction* ExtensionActionManager::GetExtensionAction( | 166 ExtensionAction* ExtensionActionManager::GetExtensionAction( |
167 const Extension& extension) const { | 167 const Extension& extension) const { |
168 ExtensionAction* action = GetBrowserAction(extension); | 168 ExtensionAction* action = GetBrowserAction(extension); |
169 return action ? action : GetPageAction(extension); | 169 return action ? action : GetPageAction(extension); |
170 } | 170 } |
171 | 171 |
172 } // namespace extensions | 172 } // namespace extensions |
OLD | NEW |