| 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 633 } |
| 634 | 634 |
| 635 // Sort pins according their ordinals. | 635 // Sort pins according their ordinals. |
| 636 std::sort(pin_infos.begin(), pin_infos.end(), ComparePinInfo()); | 636 std::sort(pin_infos.begin(), pin_infos.end(), ComparePinInfo()); |
| 637 | 637 |
| 638 // Pinned by policy apps appear first, if they were not shown before. | 638 // Pinned by policy apps appear first, if they were not shown before. |
| 639 syncer::StringOrdinal front_position = GetFirstPinPosition(helper->profile()); | 639 syncer::StringOrdinal front_position = GetFirstPinPosition(helper->profile()); |
| 640 std::vector<AppLauncherId>::const_reverse_iterator it; | 640 std::vector<AppLauncherId>::const_reverse_iterator it; |
| 641 for (it = policy_apps.app_list().rbegin(); | 641 for (it = policy_apps.app_list().rbegin(); |
| 642 it != policy_apps.app_list().rend(); ++it) { | 642 it != policy_apps.app_list().rend(); ++it) { |
| 643 const std::string& app_id = (*it).ToString(); | 643 const std::string& app_launcher_id_str = (*it).ToString(); |
| 644 if (app_id == kPinnedAppsPlaceholder) | 644 if (app_launcher_id_str == kPinnedAppsPlaceholder) |
| 645 continue; | 645 continue; |
| 646 | 646 |
| 647 // Check if we already processed current app. | 647 // Check if we already processed current app. |
| 648 if (app_service->GetPinPosition(app_id).IsValid()) | 648 if (app_service->GetPinPosition(app_launcher_id_str).IsValid()) |
| 649 continue; | 649 continue; |
| 650 | 650 |
| 651 // Now move it to the front. | 651 // Now move it to the front. |
| 652 pin_infos.insert(pin_infos.begin(), | 652 pin_infos.insert(pin_infos.begin(), |
| 653 PinInfo(AppLauncherId(app_id), front_position)); | 653 PinInfo(AppLauncherId((*it).app_id(), (*it).launch_id()), |
| 654 app_service->SetPinPosition(app_id, front_position); | 654 front_position)); |
| 655 app_service->SetPinPosition(app_launcher_id_str, front_position); |
| 655 front_position = front_position.CreateBefore(); | 656 front_position = front_position.CreateBefore(); |
| 656 } | 657 } |
| 657 | 658 |
| 658 // Now insert Chrome browser app if needed. | 659 // Now insert Chrome browser app if needed. |
| 659 if (!app_service->GetPinPosition(extension_misc::kChromeAppId).IsValid()) { | 660 if (!app_service->GetPinPosition(extension_misc::kChromeAppId).IsValid()) { |
| 660 pin_infos.insert( | 661 pin_infos.insert( |
| 661 pin_infos.begin(), | 662 pin_infos.begin(), |
| 662 PinInfo(AppLauncherId(extension_misc::kChromeAppId), front_position)); | 663 PinInfo(AppLauncherId(extension_misc::kChromeAppId), front_position)); |
| 663 app_service->SetPinPosition(extension_misc::kChromeAppId, front_position); | 664 app_service->SetPinPosition(extension_misc::kChromeAppId, front_position); |
| 664 } | 665 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 pin_position = position_before.CreateAfter(); | 739 pin_position = position_before.CreateAfter(); |
| 739 else if (position_after.IsValid()) | 740 else if (position_after.IsValid()) |
| 740 pin_position = position_after.CreateBefore(); | 741 pin_position = position_after.CreateBefore(); |
| 741 else | 742 else |
| 742 pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); | 743 pin_position = syncer::StringOrdinal::CreateInitialOrdinal(); |
| 743 app_service->SetPinPosition(app_launcher_id_str, pin_position); | 744 app_service->SetPinPosition(app_launcher_id_str, pin_position); |
| 744 } | 745 } |
| 745 | 746 |
| 746 } // namespace launcher | 747 } // namespace launcher |
| 747 } // namespace ash | 748 } // namespace ash |
| OLD | NEW |