Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/extensions/extension_sync_service.h" | 11 #include "chrome/browser/extensions/extension_sync_service.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
|
Fady Samuel
2014/08/29 19:39:46
Is this still necessary?
Xi Han
2014/08/29 19:52:53
Yes, this one is needed.
| |
| 13 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 14 #include "extensions/browser/extension_scoped_prefs.h" | 14 #include "extensions/browser/extension_scoped_prefs.h" |
| 15 #include "extensions/common/constants.h" | |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 | 17 |
| 17 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 18 #include "chrome/browser/chromeos/extensions/default_app_order.h" | 19 #include "chrome/browser/chromeos/extensions/default_app_order.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 namespace extensions { | 22 namespace extensions { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 void ChromeAppSorting::InitializePageOrdinalMap( | 471 void ChromeAppSorting::InitializePageOrdinalMap( |
| 471 const extensions::ExtensionIdList& extension_ids) { | 472 const extensions::ExtensionIdList& extension_ids) { |
| 472 for (extensions::ExtensionIdList::const_iterator ext_it = | 473 for (extensions::ExtensionIdList::const_iterator ext_it = |
| 473 extension_ids.begin(); ext_it != extension_ids.end(); ++ext_it) { | 474 extension_ids.begin(); ext_it != extension_ids.end(); ++ext_it) { |
| 474 AddOrdinalMapping(*ext_it, | 475 AddOrdinalMapping(*ext_it, |
| 475 GetPageOrdinal(*ext_it), | 476 GetPageOrdinal(*ext_it), |
| 476 GetAppLaunchOrdinal(*ext_it)); | 477 GetAppLaunchOrdinal(*ext_it)); |
| 477 | 478 |
| 478 // Ensure that the web store app still isn't found in this list, since | 479 // Ensure that the web store app still isn't found in this list, since |
| 479 // it is added after this loop. | 480 // it is added after this loop. |
| 480 DCHECK(*ext_it != extension_misc::kWebStoreAppId); | 481 DCHECK(*ext_it != extensions::kWebStoreAppId); |
| 481 DCHECK(*ext_it != extension_misc::kChromeAppId); | 482 DCHECK(*ext_it != extension_misc::kChromeAppId); |
| 482 } | 483 } |
| 483 | 484 |
| 484 // Include the Web Store App since it is displayed on the NTP. | 485 // Include the Web Store App since it is displayed on the NTP. |
| 485 syncer::StringOrdinal web_store_app_page = | 486 syncer::StringOrdinal web_store_app_page = |
| 486 GetPageOrdinal(extension_misc::kWebStoreAppId); | 487 GetPageOrdinal(extensions::kWebStoreAppId); |
| 487 if (web_store_app_page.IsValid()) { | 488 if (web_store_app_page.IsValid()) { |
| 488 AddOrdinalMapping(extension_misc::kWebStoreAppId, | 489 AddOrdinalMapping(extensions::kWebStoreAppId, |
| 489 web_store_app_page, | 490 web_store_app_page, |
| 490 GetAppLaunchOrdinal(extension_misc::kWebStoreAppId)); | 491 GetAppLaunchOrdinal(extensions::kWebStoreAppId)); |
| 491 } | 492 } |
| 492 // Include the Chrome App since it is displayed in the app launcher. | 493 // Include the Chrome App since it is displayed in the app launcher. |
| 493 syncer::StringOrdinal chrome_app_page = | 494 syncer::StringOrdinal chrome_app_page = |
| 494 GetPageOrdinal(extension_misc::kChromeAppId); | 495 GetPageOrdinal(extension_misc::kChromeAppId); |
| 495 if (chrome_app_page.IsValid()) { | 496 if (chrome_app_page.IsValid()) { |
| 496 AddOrdinalMapping(extension_misc::kChromeAppId, | 497 AddOrdinalMapping(extension_misc::kChromeAppId, |
| 497 chrome_app_page, | 498 chrome_app_page, |
| 498 GetAppLaunchOrdinal(extension_misc::kChromeAppId)); | 499 GetAppLaunchOrdinal(extension_misc::kChromeAppId)); |
| 499 } | 500 } |
| 500 } | 501 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 return; | 544 return; |
| 544 default_ordinals_created_ = true; | 545 default_ordinals_created_ = true; |
| 545 | 546 |
| 546 // The following defines the default order of apps. | 547 // The following defines the default order of apps. |
| 547 #if defined(OS_CHROMEOS) | 548 #if defined(OS_CHROMEOS) |
| 548 std::vector<std::string> app_ids; | 549 std::vector<std::string> app_ids; |
| 549 chromeos::default_app_order::Get(&app_ids); | 550 chromeos::default_app_order::Get(&app_ids); |
| 550 #else | 551 #else |
| 551 const char* kDefaultAppOrder[] = { | 552 const char* kDefaultAppOrder[] = { |
| 552 extension_misc::kChromeAppId, | 553 extension_misc::kChromeAppId, |
| 553 extension_misc::kWebStoreAppId, | 554 extensions::kWebStoreAppId, |
| 554 }; | 555 }; |
| 555 const std::vector<const char*> app_ids( | 556 const std::vector<const char*> app_ids( |
| 556 kDefaultAppOrder, kDefaultAppOrder + arraysize(kDefaultAppOrder)); | 557 kDefaultAppOrder, kDefaultAppOrder + arraysize(kDefaultAppOrder)); |
| 557 #endif | 558 #endif |
| 558 | 559 |
| 559 syncer::StringOrdinal page_ordinal = CreateFirstAppPageOrdinal(); | 560 syncer::StringOrdinal page_ordinal = CreateFirstAppPageOrdinal(); |
| 560 syncer::StringOrdinal app_launch_ordinal = | 561 syncer::StringOrdinal app_launch_ordinal = |
| 561 CreateFirstAppLaunchOrdinal(page_ordinal); | 562 CreateFirstAppLaunchOrdinal(page_ordinal); |
| 562 for (size_t i = 0; i < app_ids.size(); ++i) { | 563 for (size_t i = 0; i < app_ids.size(); ++i) { |
| 563 const std::string extension_id = app_ids[i]; | 564 const std::string extension_id = app_ids[i]; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); | 619 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); |
| 619 ++it) { | 620 ++it) { |
| 620 const std::string& id = it->second; | 621 const std::string& id = it->second; |
| 621 if (ntp_hidden_extensions_.count(id) == 0) | 622 if (ntp_hidden_extensions_.count(id) == 0) |
| 622 result++; | 623 result++; |
| 623 } | 624 } |
| 624 return result; | 625 return result; |
| 625 } | 626 } |
| 626 | 627 |
| 627 } // namespace extensions | 628 } // namespace extensions |
| OLD | NEW |