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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc

Issue 1865213004: Convert //chrome/browser/ui 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/app_list/arc/arc_app_list_prefs.h" 5 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 NOTREACHED(); 185 NOTREACHED();
186 return; 186 return;
187 } 187 }
188 arc::AppInstance* app_instance = bridge_service->app_instance(); 188 arc::AppInstance* app_instance = bridge_service->app_instance();
189 if (!app_instance) { 189 if (!app_instance) {
190 VLOG(2) << "Request to load icon when bridge service is not ready: " 190 VLOG(2) << "Request to load icon when bridge service is not ready: "
191 << app_id << "."; 191 << app_id << ".";
192 return; 192 return;
193 } 193 }
194 194
195 scoped_ptr<AppInfo> app_info = GetApp(app_id); 195 std::unique_ptr<AppInfo> app_info = GetApp(app_id);
196 if (!app_info) { 196 if (!app_info) {
197 VLOG(2) << "Failed to get app info: " << app_id << "."; 197 VLOG(2) << "Failed to get app info: " << app_id << ".";
198 return; 198 return;
199 } 199 }
200 200
201 app_instance->RequestAppIcon(app_info->package_name, app_info->activity, 201 app_instance->RequestAppIcon(app_info->package_name, app_info->activity,
202 static_cast<arc::ScaleFactor>(scale_factor)); 202 static_cast<arc::ScaleFactor>(scale_factor));
203 } 203 }
204 204
205 void ArcAppListPrefs::AddObserver(Observer* observer) { 205 void ArcAppListPrefs::AddObserver(Observer* observer) {
(...skipping 13 matching lines...) Expand all
219 !app_id.IsAtEnd(); app_id.Advance()) { 219 !app_id.IsAtEnd(); app_id.Advance()) {
220 if (!crx_file::id_util::IdIsValid(app_id.key())) 220 if (!crx_file::id_util::IdIsValid(app_id.key()))
221 continue; 221 continue;
222 222
223 ids.push_back(app_id.key()); 223 ids.push_back(app_id.key());
224 } 224 }
225 225
226 return ids; 226 return ids;
227 } 227 }
228 228
229 scoped_ptr<ArcAppListPrefs::AppInfo> ArcAppListPrefs::GetApp( 229 std::unique_ptr<ArcAppListPrefs::AppInfo> ArcAppListPrefs::GetApp(
230 const std::string& app_id) const { 230 const std::string& app_id) const {
231 const base::DictionaryValue* app = nullptr; 231 const base::DictionaryValue* app = nullptr;
232 const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps); 232 const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps);
233 if (!apps || !apps->GetDictionaryWithoutPathExpansion(app_id, &app)) 233 if (!apps || !apps->GetDictionaryWithoutPathExpansion(app_id, &app))
234 return scoped_ptr<AppInfo>(); 234 return std::unique_ptr<AppInfo>();
235 235
236 std::string name; 236 std::string name;
237 std::string package_name; 237 std::string package_name;
238 std::string activity; 238 std::string activity;
239 bool sticky = false; 239 bool sticky = false;
240 app->GetString(kName, &name); 240 app->GetString(kName, &name);
241 app->GetString(kPackageName, &package_name); 241 app->GetString(kPackageName, &package_name);
242 app->GetString(kActivity, &activity); 242 app->GetString(kActivity, &activity);
243 app->GetBoolean(kSticky, &sticky); 243 app->GetBoolean(kSticky, &sticky);
244 244
245 base::Time last_launch_time; 245 base::Time last_launch_time;
246 std::string last_launch_time_str; 246 std::string last_launch_time_str;
247 if (app->GetString(kLastLaunchTime, &last_launch_time_str)) { 247 if (app->GetString(kLastLaunchTime, &last_launch_time_str)) {
248 int64_t last_launch_time_i64 = 0; 248 int64_t last_launch_time_i64 = 0;
249 if (base::StringToInt64(last_launch_time_str, &last_launch_time_i64)) { 249 if (base::StringToInt64(last_launch_time_str, &last_launch_time_i64)) {
250 last_launch_time = base::Time::FromInternalValue(last_launch_time_i64); 250 last_launch_time = base::Time::FromInternalValue(last_launch_time_i64);
251 } else { 251 } else {
252 NOTREACHED(); 252 NOTREACHED();
253 } 253 }
254 } 254 }
255 255
256 scoped_ptr<AppInfo> app_info(new AppInfo(name, 256 std::unique_ptr<AppInfo> app_info(new AppInfo(name, package_name, activity,
257 package_name, 257 last_launch_time, sticky,
258 activity, 258 ready_apps_.count(app_id) > 0));
259 last_launch_time,
260 sticky,
261 ready_apps_.count(app_id) > 0));
262 return app_info; 259 return app_info;
263 } 260 }
264 261
265 bool ArcAppListPrefs::IsRegistered(const std::string& app_id) const { 262 bool ArcAppListPrefs::IsRegistered(const std::string& app_id) const {
266 const base::DictionaryValue* app = nullptr; 263 const base::DictionaryValue* app = nullptr;
267 const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps); 264 const base::DictionaryValue* apps = prefs_->GetDictionary(prefs::kArcApps);
268 if (!apps || !apps->GetDictionary(app_id, &app)) 265 if (!apps || !apps->GetDictionary(app_id, &app))
269 return false; 266 return false;
270 267
271 return true; 268 return true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 void ArcAppListPrefs::AddApp(const arc::AppInfo& app) { 315 void ArcAppListPrefs::AddApp(const arc::AppInfo& app) {
319 if (app.name.get().empty() || app.package_name.get().empty() || 316 if (app.name.get().empty() || app.package_name.get().empty() ||
320 app.activity.get().empty()) { 317 app.activity.get().empty()) {
321 VLOG(2) << "Name, package name, and activity cannot be empty."; 318 VLOG(2) << "Name, package name, and activity cannot be empty.";
322 return; 319 return;
323 } 320 }
324 std::string app_id = GetAppId(app.package_name, app.activity); 321 std::string app_id = GetAppId(app.package_name, app.activity);
325 bool was_registered = IsRegistered(app_id); 322 bool was_registered = IsRegistered(app_id);
326 323
327 if (was_registered) { 324 if (was_registered) {
328 scoped_ptr<ArcAppListPrefs::AppInfo> app_old_info = GetApp(app_id); 325 std::unique_ptr<ArcAppListPrefs::AppInfo> app_old_info = GetApp(app_id);
329 if (app.name != app_old_info->name) { 326 if (app.name != app_old_info->name) {
330 FOR_EACH_OBSERVER(Observer, observer_list_, 327 FOR_EACH_OBSERVER(Observer, observer_list_,
331 OnAppNameUpdated(app_id, app.name)); 328 OnAppNameUpdated(app_id, app.name));
332 } 329 }
333 } 330 }
334 331
335 ScopedArcAppListPrefUpdate update(prefs_, app_id); 332 ScopedArcAppListPrefUpdate update(prefs_, app_id);
336 base::DictionaryValue* app_dict = update.Get(); 333 base::DictionaryValue* app_dict = update.Get();
337 app_dict->SetString(kName, app.name); 334 app_dict->SetString(kName, app.name);
338 app_dict->SetString(kPackageName, app.package_name); 335 app_dict->SetString(kPackageName, app.package_name);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 const std::string& activity, 491 const std::string& activity,
495 const base::Time& last_launch_time, 492 const base::Time& last_launch_time,
496 bool sticky, 493 bool sticky,
497 bool ready) 494 bool ready)
498 : name(name), 495 : name(name),
499 package_name(package_name), 496 package_name(package_name),
500 activity(activity), 497 activity(activity),
501 last_launch_time(last_launch_time), 498 last_launch_time(last_launch_time),
502 sticky(sticky), 499 sticky(sticky),
503 ready(ready) {} 500 ready(ready) {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.h ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698