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