Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: extensions/common/manifest_handlers/icons_handler.cc

Issue 229813002: Move extensions manifest IconsHandler to //extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (icons-handler) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/common/manifest_handlers/icons_handler.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/manifest_handlers/icons_handler.h" 5 #include "extensions/common/manifest_handlers/icons_handler.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/common/extensions/extension_file_util.h"
14 #include "extensions/common/constants.h" 13 #include "extensions/common/constants.h"
15 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
15 #include "extensions/common/file_util.h"
16 #include "extensions/common/manifest_constants.h" 16 #include "extensions/common/manifest_constants.h"
17 #include "extensions/common/manifest_handler_helpers.h" 17 #include "extensions/common/manifest_handler_helpers.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "third_party/skia/include/core/SkBitmap.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
23 22
24 namespace extensions { 23 namespace extensions {
25 24
26 namespace keys = manifest_keys; 25 namespace keys = manifest_keys;
27 26
28 static base::LazyInstance<ExtensionIconSet> g_empty_icon_set = 27 static base::LazyInstance<ExtensionIconSet> g_empty_icon_set =
29 LAZY_INSTANCE_INITIALIZER; 28 LAZY_INSTANCE_INITIALIZER;
30 29
31 const int IconsInfo::kPageActionIconMaxSize = 19;
32 const int IconsInfo::kBrowserActionIconMaxSize = 19;
33
34 // static 30 // static
35 const ExtensionIconSet& IconsInfo::GetIcons(const Extension* extension) { 31 const ExtensionIconSet& IconsInfo::GetIcons(const Extension* extension) {
36 IconsInfo* info = static_cast<IconsInfo*>( 32 IconsInfo* info = static_cast<IconsInfo*>(
37 extension->GetManifestData(keys::kIcons)); 33 extension->GetManifestData(keys::kIcons));
38 return info ? info->icons : g_empty_icon_set.Get(); 34 return info ? info->icons : g_empty_icon_set.Get();
39 } 35 }
40 36
41 // static 37 // static
42 const gfx::ImageSkia& IconsInfo::GetDefaultAppIcon() { 38 const gfx::ImageSkia& IconsInfo::GetDefaultAppIcon() {
43 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 39 return *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return false; 86 return false;
91 } 87 }
92 88
93 extension->SetManifestData(keys::kIcons, icons_info.release()); 89 extension->SetManifestData(keys::kIcons, icons_info.release());
94 return true; 90 return true;
95 } 91 }
96 92
97 bool IconsHandler::Validate(const Extension* extension, 93 bool IconsHandler::Validate(const Extension* extension,
98 std::string* error, 94 std::string* error,
99 std::vector<InstallWarning>* warnings) const { 95 std::vector<InstallWarning>* warnings) const {
100 return extension_file_util::ValidateExtensionIconSet( 96 return file_util::ValidateExtensionIconSet(IconsInfo::GetIcons(extension),
101 IconsInfo::GetIcons(extension), 97 extension,
102 extension, 98 IDS_EXTENSION_LOAD_ICON_FAILED,
103 IDS_EXTENSION_LOAD_ICON_FAILED, 99 error);
104 error);
105 } 100 }
106 101
107 const std::vector<std::string> IconsHandler::Keys() const { 102 const std::vector<std::string> IconsHandler::Keys() const {
108 return SingleKey(keys::kIcons); 103 return SingleKey(keys::kIcons);
109 } 104 }
110 105
111 } // namespace extensions 106 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_handlers/icons_handler.h ('k') | extensions/extensions.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698