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/common/extensions/api/extension_action/script_badge_handler.h" | 5 #include "chrome/common/extensions/api/extension_action/script_badge_handler.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 extension->AddInstallWarning( | 73 extension->AddInstallWarning( |
74 InstallWarning(InstallWarning::FORMAT_TEXT, | 74 InstallWarning(InstallWarning::FORMAT_TEXT, |
75 errors::kScriptBadgeIconIgnored)); | 75 errors::kScriptBadgeIconIgnored)); |
76 } | 76 } |
77 | 77 |
78 SetActionInfoDefaults(extension, action_info.get()); | 78 SetActionInfoDefaults(extension, action_info.get()); |
79 ActionInfo::SetScriptBadgeInfo(extension, action_info.release()); | 79 ActionInfo::SetScriptBadgeInfo(extension, action_info.release()); |
80 return true; | 80 return true; |
81 } | 81 } |
82 | 82 |
83 bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) { | 83 bool ScriptBadgeHandler::AlwaysParseForType(Manifest::Type type) const { |
84 return type == Manifest::TYPE_EXTENSION; | 84 return type == Manifest::TYPE_EXTENSION; |
85 } | 85 } |
86 | 86 |
87 void ScriptBadgeHandler::SetActionInfoDefaults(const Extension* extension, | 87 void ScriptBadgeHandler::SetActionInfoDefaults(const Extension* extension, |
88 ActionInfo* info) { | 88 ActionInfo* info) { |
89 info->default_title = extension->name(); | 89 info->default_title = extension->name(); |
90 info->default_icon.Clear(); | 90 info->default_icon.Clear(); |
91 for (size_t i = 0; i < extension_misc::kNumScriptBadgeIconSizes; ++i) { | 91 for (size_t i = 0; i < extension_misc::kNumScriptBadgeIconSizes; ++i) { |
92 std::string path = extension->icons().Get( | 92 std::string path = extension->icons().Get( |
93 extension_misc::kScriptBadgeIconSizes[i], | 93 extension_misc::kScriptBadgeIconSizes[i], |
94 ExtensionIconSet::MATCH_BIGGER); | 94 ExtensionIconSet::MATCH_BIGGER); |
95 if (!path.empty()) { | 95 if (!path.empty()) { |
96 info->default_icon.Add( | 96 info->default_icon.Add( |
97 extension_misc::kScriptBadgeIconSizes[i], path); | 97 extension_misc::kScriptBadgeIconSizes[i], path); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 } // namespace extensions | 102 } // namespace extensions |
OLD | NEW |