| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/chrome_app_sorting.h" | 5 #include "chrome/browser/extensions/chrome_app_sorting.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 unique_app_launch = lower_bound_ordinal.CreateAfter(); | 211 unique_app_launch = lower_bound_ordinal.CreateAfter(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 SetAppLaunchOrdinal(conflicting_ids[i], unique_app_launch); | 214 SetAppLaunchOrdinal(conflicting_ids[i], unique_app_launch); |
| 215 lower_bound_ordinal = unique_app_launch; | 215 lower_bound_ordinal = unique_app_launch; |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 content::NotificationService::current()->Notify( | 220 content::NotificationService::current()->Notify( |
| 221 chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 221 chrome::NOTIFICATION_APP_LAUNCHER_REORDERED, |
| 222 content::Source<ChromeAppSorting>(this), | 222 content::Source<ChromeAppSorting>(this), |
| 223 content::NotificationService::NoDetails()); | 223 content::NotificationService::NoDetails()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void ChromeAppSorting::EnsureValidOrdinals( | 226 void ChromeAppSorting::EnsureValidOrdinals( |
| 227 const std::string& extension_id, | 227 const std::string& extension_id, |
| 228 const syncer::StringOrdinal& suggested_page) { | 228 const syncer::StringOrdinal& suggested_page) { |
| 229 syncer::StringOrdinal page_ordinal = GetPageOrdinal(extension_id); | 229 syncer::StringOrdinal page_ordinal = GetPageOrdinal(extension_id); |
| 230 if (!page_ordinal.IsValid()) { | 230 if (!page_ordinal.IsValid()) { |
| 231 if (suggested_page.IsValid()) { | 231 if (suggested_page.IsValid()) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 const syncer::StringOrdinal& successor_ordinal = | 274 const syncer::StringOrdinal& successor_ordinal = |
| 275 GetAppLaunchOrdinal(successor_extension_id); | 275 GetAppLaunchOrdinal(successor_extension_id); |
| 276 SetAppLaunchOrdinal(moved_extension_id, | 276 SetAppLaunchOrdinal(moved_extension_id, |
| 277 predecessor_ordinal.CreateBetween(successor_ordinal)); | 277 predecessor_ordinal.CreateBetween(successor_ordinal)); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 SyncIfNeeded(moved_extension_id); | 281 SyncIfNeeded(moved_extension_id); |
| 282 | 282 |
| 283 content::NotificationService::current()->Notify( | 283 content::NotificationService::current()->Notify( |
| 284 chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED, | 284 chrome::NOTIFICATION_APP_LAUNCHER_REORDERED, |
| 285 content::Source<ChromeAppSorting>(this), | 285 content::Source<ChromeAppSorting>(this), |
| 286 content::Details<const std::string>(&moved_extension_id)); | 286 content::Details<const std::string>(&moved_extension_id)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 syncer::StringOrdinal ChromeAppSorting::GetAppLaunchOrdinal( | 290 syncer::StringOrdinal ChromeAppSorting::GetAppLaunchOrdinal( |
| 291 const std::string& extension_id) const { | 291 const std::string& extension_id) const { |
| 292 std::string raw_value; | 292 std::string raw_value; |
| 293 // If the preference read fails then raw_value will still be unset and we | 293 // If the preference read fails then raw_value will still be unset and we |
| 294 // will return an invalid StringOrdinal to signal that no app launch ordinal | 294 // will return an invalid StringOrdinal to signal that no app launch ordinal |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); | 618 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); |
| 619 ++it) { | 619 ++it) { |
| 620 const std::string& id = it->second; | 620 const std::string& id = it->second; |
| 621 if (ntp_hidden_extensions_.count(id) == 0) | 621 if (ntp_hidden_extensions_.count(id) == 0) |
| 622 result++; | 622 result++; |
| 623 } | 623 } |
| 624 return result; | 624 return result; |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // namespace extensions | 627 } // namespace extensions |
| OLD | NEW |