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

Side by Side Diff: chrome/browser/ui/ash/chrome_launcher_prefs.cc

Issue 2812953002: Stop passing raw pointers to base::Value API in c/b/ui (Closed)
Patch Set: No ListValue::SetDouble Created 3 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/ui/ash/chrome_launcher_prefs.h" 5 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
9 #include <set> 10 #include <set>
11 #include <utility>
10 12
11 #include "ash/public/cpp/app_launch_id.h" 13 #include "ash/public/cpp/app_launch_id.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
15 #include "base/values.h" 17 #include "base/values.h"
16 #include "chrome/browser/app_mode/app_mode_utils.h" 18 #include "chrome/browser/app_mode/app_mode_utils.h"
17 #include "chrome/browser/chromeos/arc/arc_support_host.h" 19 #include "chrome/browser/chromeos/arc/arc_support_host.h"
18 #include "chrome/browser/prefs/pref_service_syncable_util.h" 20 #include "chrome/browser/prefs/pref_service_syncable_util.h"
19 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 21 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const base::DictionaryValue* current_display_prefs = nullptr; 132 const base::DictionaryValue* current_display_prefs = nullptr;
131 std::string current_value; 133 std::string current_value;
132 if (current_shelf_prefs->GetDictionary(display_key, &current_display_prefs) && 134 if (current_shelf_prefs->GetDictionary(display_key, &current_display_prefs) &&
133 current_display_prefs->GetString(pref_key, &current_value) && 135 current_display_prefs->GetString(pref_key, &current_value) &&
134 current_value == value) { 136 current_value == value) {
135 return; 137 return;
136 } 138 }
137 139
138 DictionaryPrefUpdate update(prefs, prefs::kShelfPreferences); 140 DictionaryPrefUpdate update(prefs, prefs::kShelfPreferences);
139 base::DictionaryValue* shelf_prefs = update.Get(); 141 base::DictionaryValue* shelf_prefs = update.Get();
140 base::DictionaryValue* display_prefs = nullptr; 142 base::DictionaryValue* display_prefs_weak = nullptr;
141 if (!shelf_prefs->GetDictionary(display_key, &display_prefs)) { 143 if (!shelf_prefs->GetDictionary(display_key, &display_prefs_weak)) {
142 display_prefs = new base::DictionaryValue(); 144 auto display_prefs = base::MakeUnique<base::DictionaryValue>();
143 shelf_prefs->Set(display_key, display_prefs); 145 display_prefs_weak = display_prefs.get();
146 shelf_prefs->Set(display_key, std::move(display_prefs));
144 } 147 }
145 display_prefs->SetStringWithoutPathExpansion(pref_key, value); 148 display_prefs_weak->SetStringWithoutPathExpansion(pref_key, value);
146 } 149 }
147 150
148 ShelfAlignment AlignmentFromPref(const std::string& value) { 151 ShelfAlignment AlignmentFromPref(const std::string& value) {
149 if (value == kShelfAlignmentLeft) 152 if (value == kShelfAlignmentLeft)
150 return SHELF_ALIGNMENT_LEFT; 153 return SHELF_ALIGNMENT_LEFT;
151 else if (value == kShelfAlignmentRight) 154 else if (value == kShelfAlignmentRight)
152 return SHELF_ALIGNMENT_RIGHT; 155 return SHELF_ALIGNMENT_RIGHT;
153 // Default to bottom. 156 // Default to bottom.
154 return SHELF_ALIGNMENT_BOTTOM; 157 return SHELF_ALIGNMENT_BOTTOM;
155 } 158 }
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 pin_position = position_before.CreateAfter(); 764 pin_position = position_before.CreateAfter();
762 else if (position_after.IsValid()) 765 else if (position_after.IsValid())
763 pin_position = position_after.CreateBefore(); 766 pin_position = position_after.CreateBefore();
764 else 767 else
765 pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); 768 pin_position = syncer::StringOrdinal::CreateInitialOrdinal();
766 app_service->SetPinPosition(app_id, pin_position); 769 app_service->SetPinPosition(app_id, pin_position);
767 } 770 }
768 771
769 } // namespace launcher 772 } // namespace launcher
770 } // namespace ash 773 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698