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/launcher/chrome_launcher_controller_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 } | 1389 } |
1390 | 1390 |
1391 // Walk the model and |pinned_apps| from the pref lockstep, adding and | 1391 // Walk the model and |pinned_apps| from the pref lockstep, adding and |
1392 // removing items as necessary. NB: This code uses plain old indexing instead | 1392 // removing items as necessary. NB: This code uses plain old indexing instead |
1393 // of iterators because of model mutations as part of the loop. | 1393 // of iterators because of model mutations as part of the loop. |
1394 std::vector<std::string>::const_iterator pref_app_id(pinned_apps.begin()); | 1394 std::vector<std::string>::const_iterator pref_app_id(pinned_apps.begin()); |
1395 int index = 0; | 1395 int index = 0; |
1396 int max_index = model_->item_count(); | 1396 int max_index = model_->item_count(); |
1397 // Using the alternate shelf layout the App Icon should be the first item in | 1397 // Using the alternate shelf layout the App Icon should be the first item in |
1398 // the list thus start adding items at slot 1 (instead of slot 0). | 1398 // the list thus start adding items at slot 1 (instead of slot 0). |
1399 if(ash::switches::UseAlternateShelfLayout()) { | 1399 if (ash::switches::UseAlternateShelfLayout()) { |
1400 ++index; | 1400 ++index; |
1401 ++max_index; | 1401 ++max_index; |
1402 } | 1402 } |
1403 for (; index < max_index && pref_app_id != pinned_apps.end(); ++index) { | 1403 for (; index < max_index && pref_app_id != pinned_apps.end(); ++index) { |
1404 // If the next app launcher according to the pref is present in the model, | 1404 // If the next app launcher according to the pref is present in the model, |
1405 // delete all app launcher entries in between. | 1405 // delete all app launcher entries in between. |
1406 if (*pref_app_id == extension_misc::kChromeAppId || | 1406 if (*pref_app_id == extension_misc::kChromeAppId || |
1407 IsAppPinned(*pref_app_id)) { | 1407 IsAppPinned(*pref_app_id)) { |
1408 for (; index < max_index; ++index) { | 1408 for (; index < max_index; ++index) { |
1409 const ash::LauncherItem& item(model_->items()[index]); | 1409 const ash::LauncherItem& item(model_->items()[index]); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 browser_to_close.pop_back(); | 1680 browser_to_close.pop_back(); |
1681 } | 1681 } |
1682 } | 1682 } |
1683 | 1683 |
1684 void | 1684 void |
1685 ChromeLauncherControllerPerApp::MoveItemWithoutPinnedStateChangeNotification( | 1685 ChromeLauncherControllerPerApp::MoveItemWithoutPinnedStateChangeNotification( |
1686 int source_index, int target_index) { | 1686 int source_index, int target_index) { |
1687 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true); | 1687 base::AutoReset<bool> auto_reset(&ignore_persist_pinned_state_change_, true); |
1688 model_->Move(source_index, target_index); | 1688 model_->Move(source_index, target_index); |
1689 } | 1689 } |
OLD | NEW |