Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: chrome/browser/extensions/extension_sorting.cc

Issue 11318008: cros: Allow default app order to be loaded from an external file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for comments in #1 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/extension_scoped_prefs.h" 10 #include "chrome/browser/extensions/extension_scoped_prefs.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 16
17 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/chromeos/extensions/default_app_order.h"
19 #endif
20
17 using extensions::ExtensionPrefs; 21 using extensions::ExtensionPrefs;
18 22
19 namespace { 23 namespace {
20 24
21 // The number of apps per page. This isn't a hard limit, but new apps installed 25 // The number of apps per page. This isn't a hard limit, but new apps installed
22 // from the webstore will overflow onto a new page if this limit is reached. 26 // from the webstore will overflow onto a new page if this limit is reached.
23 const size_t kNaturalAppPageSize = 18; 27 const size_t kNaturalAppPageSize = 18;
24 28
25 // A preference determining the order of which the apps appear on the NTP. 29 // A preference determining the order of which the apps appear on the NTP.
26 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index"; 30 const char kPrefAppLaunchIndexDeprecated[] = "app_launcher_index";
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 ClearOrdinals(extension_id); 538 ClearOrdinals(extension_id);
535 539
536 extension_service_->SyncExtensionChangeIfNeeded(*ext); 540 extension_service_->SyncExtensionChangeIfNeeded(*ext);
537 } 541 }
538 } 542 }
539 } 543 }
540 544
541 void ExtensionSorting::CreateDefaultOrdinals() { 545 void ExtensionSorting::CreateDefaultOrdinals() {
542 // The following defines the default order of apps. 546 // The following defines the default order of apps.
543 #if defined(OS_CHROMEOS) 547 #if defined(OS_CHROMEOS)
544 const char* kDefaultAppOrder[] = { 548 std::vector<std::string> app_ids;
545 extension_misc::kChromeAppId, 549 chromeos::default_app_order::Get(&app_ids);
546 extension_misc::kWebStoreAppId,
547 "coobgpohoikkiipiblmjeljniedjpjpf", // Search
548 "blpcfgokakmgnkcojhhkbfbldkacnbeo", // Youtube
549 "pjkljhegncpnkpknbcohdijeoejaedia", // Gmail
550 "ejjicmeblgpmajnghnpcppodonldlgfn", // Calendar
551 "kjebfhglflhjjjiceimfkgicifkhjlnm", // Scratchpad
552 "lneaknkopdijkpnocmklfnjbeapigfbh", // Google Maps
553 "apdfllckaahabafndbhieahigkjlhalf", // Drive
554 "aohghmighlieiainnegkcijnfilokake", // Docs
555 "felcaaldnbdncclmgdcncolpebgiejap", // Sheets
556 "aapocclcgogkmnckokdopfmhonfmgoek", // Slides
557 "dlppkpafhbajpcmmoheippocdidnckmm", // Google+
558 "kbpgddbgniojgndnhlkjbkpknjhppkbk", // Google+ Hangouts
559 "hhaomjibdihmijegdhdafkllkbggdgoj", // Files
560 "hkhhlkdconhgemhegnplaldnmnmkaemd", // Tips & Tricks
561 "icppfcnhkcmnfdhfhphakoifcfokfdhg", // Play Music
562 "mmimngoggfoobjdlefbcabngfnmieonb", // Play Books
563 "fppdphmgcddhjeddoeghpjefkdlccljb", // Play Movies
564 "fobcpibfeplaikcclojfdhfdmbbeofai", // Games
565 "joodangkbfjnajiiifokapkpmhfnpleo", // Calculator
566 "hfhhnacclhffhdffklopdkcgdhifgngh", // Camera
567 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
568 };
569 #else 550 #else
570 const char* kDefaultAppOrder[] = { 551 const char* kDefaultAppOrder[] = {
571 extension_misc::kWebStoreAppId, 552 extension_misc::kWebStoreAppId,
572 }; 553 };
554 const std::vector<const char*> app_ids(
555 kDefaultAppOrder, kDefaultAppOrder + arraysize(kDefaultAppOrder));
573 #endif 556 #endif
574 557
575 syncer::StringOrdinal page_ordinal = CreateFirstAppPageOrdinal(); 558 syncer::StringOrdinal page_ordinal = CreateFirstAppPageOrdinal();
576 syncer::StringOrdinal app_launch_ordinal = 559 syncer::StringOrdinal app_launch_ordinal =
577 CreateFirstAppLaunchOrdinal(page_ordinal); 560 CreateFirstAppLaunchOrdinal(page_ordinal);
578 for (size_t i = 0; i < arraysize(kDefaultAppOrder); ++i) { 561 for (size_t i = 0; i < app_ids.size(); ++i) {
579 const std::string extension_id = kDefaultAppOrder[i]; 562 const std::string extension_id = app_ids[i];
580 default_ordinals_[extension_id].page_ordinal = page_ordinal; 563 default_ordinals_[extension_id].page_ordinal = page_ordinal;
581 default_ordinals_[extension_id].app_launch_ordinal = app_launch_ordinal; 564 default_ordinals_[extension_id].app_launch_ordinal = app_launch_ordinal;
582 app_launch_ordinal = app_launch_ordinal.CreateAfter(); 565 app_launch_ordinal = app_launch_ordinal.CreateAfter();
583 } 566 }
584 } 567 }
585 568
586 bool ExtensionSorting::GetDefaultOrdinals( 569 bool ExtensionSorting::GetDefaultOrdinals(
587 const std::string& extension_id, 570 const std::string& extension_id,
588 syncer::StringOrdinal* page_ordinal, 571 syncer::StringOrdinal* page_ordinal,
589 syncer::StringOrdinal* app_launch_ordinal) const { 572 syncer::StringOrdinal* app_launch_ordinal) const {
(...skipping 30 matching lines...) Expand all
620 ++app_it; 603 ++app_it;
621 604
622 // If there is no next after the collision, returns the next ordinal. 605 // If there is no next after the collision, returns the next ordinal.
623 if (app_it == page.end()) 606 if (app_it == page.end())
624 return app_launch_ordinal.CreateAfter(); 607 return app_launch_ordinal.CreateAfter();
625 608
626 // Otherwise, returns the ordinal between the collision and the next ordinal. 609 // Otherwise, returns the ordinal between the collision and the next ordinal.
627 return app_launch_ordinal.CreateBetween(app_it->first); 610 return app_launch_ordinal.CreateBetween(app_it->first);
628 } 611 }
629 612
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/default_app_order_unittest.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698