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/extensions/extension_sorting.h" | 5 #include "chrome/browser/extensions/extension_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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 GetAppLaunchOrdinal(extension_id))) { | 299 GetAppLaunchOrdinal(extension_id))) { |
300 return; | 300 return; |
301 } | 301 } |
302 | 302 |
303 syncer::StringOrdinal page_ordinal = GetPageOrdinal(extension_id); | 303 syncer::StringOrdinal page_ordinal = GetPageOrdinal(extension_id); |
304 RemoveOrdinalMapping( | 304 RemoveOrdinalMapping( |
305 extension_id, page_ordinal, GetAppLaunchOrdinal(extension_id)); | 305 extension_id, page_ordinal, GetAppLaunchOrdinal(extension_id)); |
306 AddOrdinalMapping(extension_id, page_ordinal, new_app_launch_ordinal); | 306 AddOrdinalMapping(extension_id, page_ordinal, new_app_launch_ordinal); |
307 | 307 |
308 Value* new_value = new_app_launch_ordinal.IsValid() ? | 308 Value* new_value = new_app_launch_ordinal.IsValid() ? |
309 Value::CreateStringValue(new_app_launch_ordinal.ToInternalValue()) : | 309 new base::StringValue(new_app_launch_ordinal.ToInternalValue()) : |
310 NULL; | 310 NULL; |
311 | 311 |
312 extension_scoped_prefs_->UpdateExtensionPref( | 312 extension_scoped_prefs_->UpdateExtensionPref( |
313 extension_id, | 313 extension_id, |
314 kPrefAppLaunchOrdinal, | 314 kPrefAppLaunchOrdinal, |
315 new_value); | 315 new_value); |
316 SyncIfNeeded(extension_id); | 316 SyncIfNeeded(extension_id); |
317 } | 317 } |
318 | 318 |
319 syncer::StringOrdinal ExtensionSorting::CreateFirstAppLaunchOrdinal( | 319 syncer::StringOrdinal ExtensionSorting::CreateFirstAppLaunchOrdinal( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // No work is required if the old and new values are the same. | 378 // No work is required if the old and new values are the same. |
379 if (new_page_ordinal.EqualsOrBothInvalid(GetPageOrdinal(extension_id))) | 379 if (new_page_ordinal.EqualsOrBothInvalid(GetPageOrdinal(extension_id))) |
380 return; | 380 return; |
381 | 381 |
382 syncer::StringOrdinal app_launch_ordinal = GetAppLaunchOrdinal(extension_id); | 382 syncer::StringOrdinal app_launch_ordinal = GetAppLaunchOrdinal(extension_id); |
383 RemoveOrdinalMapping( | 383 RemoveOrdinalMapping( |
384 extension_id, GetPageOrdinal(extension_id), app_launch_ordinal); | 384 extension_id, GetPageOrdinal(extension_id), app_launch_ordinal); |
385 AddOrdinalMapping(extension_id, new_page_ordinal, app_launch_ordinal); | 385 AddOrdinalMapping(extension_id, new_page_ordinal, app_launch_ordinal); |
386 | 386 |
387 Value* new_value = new_page_ordinal.IsValid() ? | 387 Value* new_value = new_page_ordinal.IsValid() ? |
388 Value::CreateStringValue(new_page_ordinal.ToInternalValue()) : | 388 new base::StringValue(new_page_ordinal.ToInternalValue()) : |
389 NULL; | 389 NULL; |
390 | 390 |
391 extension_scoped_prefs_->UpdateExtensionPref( | 391 extension_scoped_prefs_->UpdateExtensionPref( |
392 extension_id, | 392 extension_id, |
393 kPrefPageOrdinal, | 393 kPrefPageOrdinal, |
394 new_value); | 394 new_value); |
395 SyncIfNeeded(extension_id); | 395 SyncIfNeeded(extension_id); |
396 } | 396 } |
397 | 397 |
398 void ExtensionSorting::ClearOrdinals(const std::string& extension_id) { | 398 void ExtensionSorting::ClearOrdinals(const std::string& extension_id) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 const AppLaunchOrdinalMap& m) const { | 616 const AppLaunchOrdinalMap& m) const { |
617 size_t result = 0; | 617 size_t result = 0; |
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 } |
OLD | NEW |