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

Side by Side Diff: chrome/browser/extensions/convert_web_app.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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
OLDNEW
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/convert_web_app.h" 5 #include "chrome/browser/extensions/convert_web_app.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cmath> 10 #include <cmath>
11 #include <limits> 11 #include <limits>
12 #include <memory>
12 #include <string> 13 #include <string>
14 #include <utility>
13 #include <vector> 15 #include <vector>
14 16
15 #include "base/base64.h" 17 #include "base/base64.h"
16 #include "base/files/file_path.h" 18 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
18 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
19 #include "base/json/json_file_value_serializer.h" 21 #include "base/json/json_file_value_serializer.h"
20 #include "base/logging.h" 22 #include "base/logging.h"
21 #include "base/numerics/safe_conversions.h" 23 #include "base/numerics/safe_conversions.h"
22 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 root->Set(keys::kIcons, icons); 120 root->Set(keys::kIcons, icons);
119 base::ListValue* linked_icons = new base::ListValue(); 121 base::ListValue* linked_icons = new base::ListValue();
120 root->Set(keys::kLinkedAppIcons, linked_icons); 122 root->Set(keys::kLinkedAppIcons, linked_icons);
121 for (const auto& icon : web_app.icons) { 123 for (const auto& icon : web_app.icons) {
122 std::string size = base::StringPrintf("%i", icon.width); 124 std::string size = base::StringPrintf("%i", icon.width);
123 std::string icon_path = base::StringPrintf("%s/%s.png", kIconsDirName, 125 std::string icon_path = base::StringPrintf("%s/%s.png", kIconsDirName,
124 size.c_str()); 126 size.c_str());
125 icons->SetString(size, icon_path); 127 icons->SetString(size, icon_path);
126 128
127 if (icon.url.is_valid()) { 129 if (icon.url.is_valid()) {
128 base::DictionaryValue* linked_icon = new base::DictionaryValue(); 130 std::unique_ptr<base::DictionaryValue> linked_icon(
131 new base::DictionaryValue());
129 linked_icon->SetString(keys::kLinkedAppIconURL, icon.url.spec()); 132 linked_icon->SetString(keys::kLinkedAppIconURL, icon.url.spec());
130 linked_icon->SetInteger(keys::kLinkedAppIconSize, icon.width); 133 linked_icon->SetInteger(keys::kLinkedAppIconSize, icon.width);
131 linked_icons->Append(linked_icon); 134 linked_icons->Append(std::move(linked_icon));
132 } 135 }
133 } 136 }
134 137
135 // Write the manifest. 138 // Write the manifest.
136 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); 139 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename);
137 JSONFileValueSerializer serializer(manifest_path); 140 JSONFileValueSerializer serializer(manifest_path);
138 if (!serializer.Serialize(*root)) { 141 if (!serializer.Serialize(*root)) {
139 LOG(ERROR) << "Could not serialize manifest."; 142 LOG(ERROR) << "Could not serialize manifest.";
140 return NULL; 143 return NULL;
141 } 144 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (!extension.get()) { 183 if (!extension.get()) {
181 LOG(ERROR) << error; 184 LOG(ERROR) << error;
182 return NULL; 185 return NULL;
183 } 186 }
184 187
185 temp_dir.Take(); // The caller takes ownership of the directory. 188 temp_dir.Take(); // The caller takes ownership of the directory.
186 return extension; 189 return extension;
187 } 190 }
188 191
189 } // namespace extensions 192 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/convert_user_script.cc ('k') | chrome/browser/extensions/extension_messages_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698