Chromium Code Reviews| 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 <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Sets the preference value for the display with the given |display_id|. | 109 // Sets the preference value for the display with the given |display_id|. |
| 110 void SetPerDisplayPref(PrefService* prefs, | 110 void SetPerDisplayPref(PrefService* prefs, |
| 111 int64_t display_id, | 111 int64_t display_id, |
| 112 const char* pref_key, | 112 const char* pref_key, |
| 113 const std::string& value) { | 113 const std::string& value) { |
| 114 if (display_id < 0) | 114 if (display_id < 0) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 // Avoid DictionaryPrefUpdate's notifications for unchanged prefs. | |
| 118 if (GetPerDisplayPref(prefs, display_id, pref_key, pref_key) == value) | |
| 119 return; | |
| 120 | |
| 117 DictionaryPrefUpdate update(prefs, prefs::kShelfPreferences); | 121 DictionaryPrefUpdate update(prefs, prefs::kShelfPreferences); |
| 118 base::DictionaryValue* shelf_prefs = update.Get(); | 122 base::DictionaryValue* shelf_prefs = update.Get(); |
| 119 base::DictionaryValue* pref_dictionary = nullptr; | 123 base::DictionaryValue* pref_dictionary = nullptr; |
| 120 std::string key = base::Int64ToString(display_id); | 124 std::string key = base::Int64ToString(display_id); |
| 121 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { | 125 if (!shelf_prefs->GetDictionary(key, &pref_dictionary)) { |
| 122 pref_dictionary = new base::DictionaryValue(); | 126 pref_dictionary = new base::DictionaryValue(); |
| 123 shelf_prefs->Set(key, pref_dictionary); | 127 shelf_prefs->Set(key, pref_dictionary); |
|
James Cook
2017/01/19 01:54:25
Do we rely on this side-effect to create the new p
msw
2017/01/19 02:19:15
Hmm, good question... it would probably be more pr
| |
| 124 } | 128 } |
| 125 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); | 129 pref_dictionary->SetStringWithoutPathExpansion(pref_key, value); |
| 126 } | 130 } |
| 127 | 131 |
| 128 ShelfAlignment AlignmentFromPref(const std::string& value) { | 132 ShelfAlignment AlignmentFromPref(const std::string& value) { |
| 129 if (value == kShelfAlignmentLeft) | 133 if (value == kShelfAlignmentLeft) |
| 130 return SHELF_ALIGNMENT_LEFT; | 134 return SHELF_ALIGNMENT_LEFT; |
| 131 else if (value == kShelfAlignmentRight) | 135 else if (value == kShelfAlignmentRight) |
| 132 return SHELF_ALIGNMENT_RIGHT; | 136 return SHELF_ALIGNMENT_RIGHT; |
| 133 // Default to bottom. | 137 // Default to bottom. |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 pin_position = position_before.CreateAfter(); | 743 pin_position = position_before.CreateAfter(); |
| 740 else if (position_after.IsValid()) | 744 else if (position_after.IsValid()) |
| 741 pin_position = position_after.CreateBefore(); | 745 pin_position = position_after.CreateBefore(); |
| 742 else | 746 else |
| 743 pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); | 747 pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); |
| 744 app_service->SetPinPosition(app_launcher_id_str, pin_position); | 748 app_service->SetPinPosition(app_launcher_id_str, pin_position); |
| 745 } | 749 } |
| 746 | 750 |
| 747 } // namespace launcher | 751 } // namespace launcher |
| 748 } // namespace ash | 752 } // namespace ash |
| OLD | NEW |