Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chrome_app_list_item.h" | 5 #include "chrome/browser/ui/app_list/chrome_app_list_item.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/app_list/app_list_service.h" | 8 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 9 #include "extensions/browser/app_sorting.h" | 9 #include "extensions/browser/app_sorting.h" |
| 10 #include "extensions/browser/extension_system.h" | 10 #include "extensions/browser/extension_system.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 // An existing synced position exists, use that. | 55 // An existing synced position exists, use that. |
| 56 set_position(sync_item->item_ordinal); | 56 set_position(sync_item->item_ordinal); |
| 57 // Only set the name from the sync item if it is empty. | 57 // Only set the name from the sync item if it is empty. |
| 58 if (name().empty()) | 58 if (name().empty()) |
| 59 SetName(sync_item->item_name); | 59 SetName(sync_item->item_name); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ChromeAppListItem::SetDefaultPositionIfApplicable() { | 62 void ChromeAppListItem::SetDefaultPositionIfApplicable() { |
| 63 syncer::StringOrdinal page_ordinal; | 63 syncer::StringOrdinal page_ordinal; |
| 64 syncer::StringOrdinal launch_ordinal; | 64 syncer::StringOrdinal launch_ordinal; |
| 65 if (GetAppSorting()->GetDefaultOrdinals(id(), &page_ordinal, | 65 extensions::AppSorting* app_sorting = GetAppSorting(); |
|
khmel
2017/01/04 20:22:52
This does not guaranty generating position for all
stevenjb
2017/01/04 20:34:26
Aha. Good catch.
khmel
2017/01/04 21:15:12
:( Kind of late. Also removed double set_position
| |
| 66 &launch_ordinal) && | 66 if (!app_sorting->GetDefaultOrdinals(id(), &page_ordinal, |
| 67 page_ordinal.IsValid() && launch_ordinal.IsValid()) { | 67 &launch_ordinal) || |
| 68 set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() + | 68 !page_ordinal.IsValid() || !launch_ordinal.IsValid()) { |
| 69 launch_ordinal.ToInternalValue())); | 69 app_sorting->EnsureValidOrdinals(id(), syncer::StringOrdinal()); |
| 70 page_ordinal = app_sorting->GetPageOrdinal(id()); | |
| 71 launch_ordinal = app_sorting->GetAppLaunchOrdinal(id()); | |
| 72 set_position(syncer::StringOrdinal( | |
| 73 page_ordinal.ToInternalValue() + launch_ordinal.ToInternalValue())); | |
| 70 } | 74 } |
| 75 DCHECK(page_ordinal.IsValid()); | |
| 76 DCHECK(launch_ordinal.IsValid()); | |
| 77 set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() + | |
| 78 launch_ordinal.ToInternalValue())); | |
| 71 } | 79 } |
| OLD | NEW |