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/common/extensions/manifest_handlers/app_icon_color_info.h" | 5 #include "chrome/common/extensions/manifest_handlers/app_icon_color_info.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 11 #include "base/values.h" |
10 #include "extensions/common/image_util.h" | 12 #include "extensions/common/image_util.h" |
11 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
12 #include "extensions/common/manifest_constants.h" | 14 #include "extensions/common/manifest_constants.h" |
13 | 15 |
14 namespace extensions { | 16 namespace extensions { |
15 | 17 |
16 namespace keys = manifest_keys; | 18 namespace keys = manifest_keys; |
(...skipping 29 matching lines...) Expand all Loading... |
46 return GetInfo(extension).icon_color_string_; | 48 return GetInfo(extension).icon_color_string_; |
47 } | 49 } |
48 | 50 |
49 AppIconColorHandler::AppIconColorHandler() { | 51 AppIconColorHandler::AppIconColorHandler() { |
50 } | 52 } |
51 | 53 |
52 AppIconColorHandler::~AppIconColorHandler() { | 54 AppIconColorHandler::~AppIconColorHandler() { |
53 } | 55 } |
54 | 56 |
55 bool AppIconColorHandler::Parse(Extension* extension, base::string16* error) { | 57 bool AppIconColorHandler::Parse(Extension* extension, base::string16* error) { |
56 scoped_ptr<AppIconColorInfo> app_icon_color_info(new AppIconColorInfo); | 58 std::unique_ptr<AppIconColorInfo> app_icon_color_info(new AppIconColorInfo); |
57 | 59 |
58 const base::Value* temp = NULL; | 60 const base::Value* temp = NULL; |
59 if (extension->manifest()->Get(keys::kAppIconColor, &temp)) { | 61 if (extension->manifest()->Get(keys::kAppIconColor, &temp)) { |
60 if (!temp->GetAsString(&app_icon_color_info->icon_color_string_)) { | 62 if (!temp->GetAsString(&app_icon_color_info->icon_color_string_)) { |
61 *error = | 63 *error = |
62 base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor); | 64 base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor); |
63 return false; | 65 return false; |
64 } | 66 } |
65 | 67 |
66 if (!image_util::ParseHexColorString( | 68 if (!image_util::ParseHexColorString( |
67 app_icon_color_info->icon_color_string_, | 69 app_icon_color_info->icon_color_string_, |
68 &app_icon_color_info->icon_color_)) { | 70 &app_icon_color_info->icon_color_)) { |
69 *error = | 71 *error = |
70 base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor); | 72 base::UTF8ToUTF16(extensions::manifest_errors::kInvalidAppIconColor); |
71 return false; | 73 return false; |
72 } | 74 } |
73 } | 75 } |
74 | 76 |
75 extension->SetManifestData(keys::kAppIconColor, | 77 extension->SetManifestData(keys::kAppIconColor, |
76 app_icon_color_info.release()); | 78 app_icon_color_info.release()); |
77 return true; | 79 return true; |
78 } | 80 } |
79 | 81 |
80 const std::vector<std::string> AppIconColorHandler::Keys() const { | 82 const std::vector<std::string> AppIconColorHandler::Keys() const { |
81 return SingleKey(keys::kAppIconColor); | 83 return SingleKey(keys::kAppIconColor); |
82 } | 84 } |
83 | 85 |
84 } // namespace extensions | 86 } // namespace extensions |
OLD | NEW |