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

Side by Side Diff: chrome/browser/chromeos/extensions/default_app_order.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
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/chromeos/extensions/default_app_order.h" 5 #include "chrome/browser/chromeos/extensions/default_app_order.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 "gdijeikdkaembjbdobgfkoidjkpbmlkd", // Play Movies & TV 54 "gdijeikdkaembjbdobgfkoidjkpbmlkd", // Play Movies & TV
55 "fobcpibfeplaikcclojfdhfdmbbeofai", // Games 55 "fobcpibfeplaikcclojfdhfdmbbeofai", // Games
56 "joodangkbfjnajiiifokapkpmhfnpleo", // Calculator 56 "joodangkbfjnajiiifokapkpmhfnpleo", // Calculator
57 "hfhhnacclhffhdffklopdkcgdhifgngh", // Camera 57 "hfhhnacclhffhdffklopdkcgdhifgngh", // Camera
58 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop 58 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
59 }; 59 };
60 60
61 // Reads external ordinal json file and returned the parsed value. Returns NULL 61 // Reads external ordinal json file and returned the parsed value. Returns NULL
62 // if the file does not exist or could not be parsed properly. Caller takes 62 // if the file does not exist or could not be parsed properly. Caller takes
63 // ownership of the returned value. 63 // ownership of the returned value.
64 scoped_ptr<base::ListValue> ReadExternalOrdinalFile( 64 std::unique_ptr<base::ListValue> ReadExternalOrdinalFile(
65 const base::FilePath& path) { 65 const base::FilePath& path) {
66 if (!base::PathExists(path)) 66 if (!base::PathExists(path))
67 return NULL; 67 return NULL;
68 68
69 JSONFileValueDeserializer deserializer(path); 69 JSONFileValueDeserializer deserializer(path);
70 std::string error_msg; 70 std::string error_msg;
71 scoped_ptr<base::Value> value = deserializer.Deserialize(NULL, &error_msg); 71 std::unique_ptr<base::Value> value =
72 deserializer.Deserialize(NULL, &error_msg);
72 if (!value) { 73 if (!value) {
73 LOG(WARNING) << "Unable to deserialize default app ordinals json data:" 74 LOG(WARNING) << "Unable to deserialize default app ordinals json data:"
74 << error_msg << ", file=" << path.value(); 75 << error_msg << ", file=" << path.value();
75 return NULL; 76 return NULL;
76 } 77 }
77 78
78 scoped_ptr<base::ListValue> ordinal_list_value = 79 std::unique_ptr<base::ListValue> ordinal_list_value =
79 base::ListValue::From(std::move(value)); 80 base::ListValue::From(std::move(value));
80 if (!ordinal_list_value) 81 if (!ordinal_list_value)
81 LOG(WARNING) << "Expect a JSON list in file " << path.value(); 82 LOG(WARNING) << "Expect a JSON list in file " << path.value();
82 83
83 return ordinal_list_value; 84 return ordinal_list_value;
84 } 85 }
85 86
86 std::string GetLocaleSpecificStringImpl( 87 std::string GetLocaleSpecificStringImpl(
87 const base::DictionaryValue* root, 88 const base::DictionaryValue* root,
88 const std::string& locale, 89 const std::string& locale,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const std::string& ExternalLoader::GetOemAppsFolderName() { 148 const std::string& ExternalLoader::GetOemAppsFolderName() {
148 if (!loaded_.IsSignaled()) 149 if (!loaded_.IsSignaled())
149 LOG(ERROR) << "GetOemAppsFolderName() called before loaded."; 150 LOG(ERROR) << "GetOemAppsFolderName() called before loaded.";
150 return oem_apps_folder_name_; 151 return oem_apps_folder_name_;
151 } 152 }
152 153
153 void ExternalLoader::Load() { 154 void ExternalLoader::Load() {
154 base::FilePath ordinals_file; 155 base::FilePath ordinals_file;
155 CHECK(PathService::Get(chromeos::FILE_DEFAULT_APP_ORDER, &ordinals_file)); 156 CHECK(PathService::Get(chromeos::FILE_DEFAULT_APP_ORDER, &ordinals_file));
156 157
157 scoped_ptr<base::ListValue> ordinals_value = 158 std::unique_ptr<base::ListValue> ordinals_value =
158 ReadExternalOrdinalFile(ordinals_file); 159 ReadExternalOrdinalFile(ordinals_file);
159 if (ordinals_value) { 160 if (ordinals_value) {
160 std::string locale = g_browser_process->GetApplicationLocale(); 161 std::string locale = g_browser_process->GetApplicationLocale();
161 for (size_t i = 0; i < ordinals_value->GetSize(); ++i) { 162 for (size_t i = 0; i < ordinals_value->GetSize(); ++i) {
162 std::string app_id; 163 std::string app_id;
163 base::DictionaryValue* dict = NULL; 164 base::DictionaryValue* dict = NULL;
164 if (ordinals_value->GetString(i, &app_id)) { 165 if (ordinals_value->GetString(i, &app_id)) {
165 app_ids_.push_back(app_id); 166 app_ids_.push_back(app_id);
166 } else if (ordinals_value->GetDictionary(i, &dict)) { 167 } else if (ordinals_value->GetDictionary(i, &dict)) {
167 bool flag = false; 168 bool flag = false;
(...skipping 29 matching lines...) Expand all
197 std::string GetOemAppsFolderName() { 198 std::string GetOemAppsFolderName() {
198 // |loader_instance| could be NULL for test. 199 // |loader_instance| could be NULL for test.
199 if (!loader_instance) 200 if (!loader_instance)
200 return std::string(); 201 return std::string();
201 else 202 else
202 return loader_instance->GetOemAppsFolderName(); 203 return loader_instance->GetOemAppsFolderName();
203 } 204 }
204 205
205 } // namespace default_app_order 206 } // namespace default_app_order
206 } // namespace chromeos 207 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698