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.h" | 5 #include "chrome/browser/extensions/extension_action.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 }; | 51 }; |
52 | 52 |
53 template <class T> | 53 template <class T> |
54 bool HasValue(const std::map<int, T>& map, int tab_id) { | 54 bool HasValue(const std::map<int, T>& map, int tab_id) { |
55 return map.find(tab_id) != map.end(); | 55 return map.find(tab_id) != map.end(); |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 const int ExtensionAction::kDefaultTabId = -1; | 60 const int ExtensionAction::kDefaultTabId = -1; |
| 61 const int ExtensionAction::kPageActionIconMaxSize = 19; |
61 | 62 |
62 ExtensionAction::ExtensionAction(const std::string& extension_id, | 63 ExtensionAction::ExtensionAction(const std::string& extension_id, |
63 extensions::ActionInfo::Type action_type, | 64 extensions::ActionInfo::Type action_type, |
64 const extensions::ActionInfo& manifest_data) | 65 const extensions::ActionInfo& manifest_data) |
65 : extension_id_(extension_id), action_type_(action_type) { | 66 : extension_id_(extension_id), action_type_(action_type) { |
66 // Page/script actions are hidden/disabled by default, and browser actions are | 67 // Page/script actions are hidden/disabled by default, and browser actions are |
67 // visible/enabled by default. | 68 // visible/enabled by default. |
68 SetIsVisible(kDefaultTabId, | 69 SetIsVisible(kDefaultTabId, |
69 action_type == extensions::ActionInfo::TYPE_BROWSER); | 70 action_type == extensions::ActionInfo::TYPE_BROWSER); |
70 SetTitle(kDefaultTabId, manifest_data.default_title); | 71 SetTitle(kDefaultTabId, manifest_data.default_title); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // If there is a default icon, the icon width will be set depending on our | 245 // If there is a default icon, the icon width will be set depending on our |
245 // action type. | 246 // action type. |
246 if (default_icon_) | 247 if (default_icon_) |
247 return GetIconSizeForType(action_type()); | 248 return GetIconSizeForType(action_type()); |
248 | 249 |
249 // If no icon has been set and there is no default icon, we need favicon | 250 // If no icon has been set and there is no default icon, we need favicon |
250 // width. | 251 // width. |
251 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 252 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
252 IDR_EXTENSIONS_FAVICON).ToImageSkia()->width(); | 253 IDR_EXTENSIONS_FAVICON).ToImageSkia()->width(); |
253 } | 254 } |
OLD | NEW |