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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 ChromeAppSorting::ChromeAppSorting() | 50 ChromeAppSorting::ChromeAppSorting() |
51 : extension_scoped_prefs_(NULL), | 51 : extension_scoped_prefs_(NULL), |
52 extension_sync_service_(NULL), | 52 extension_sync_service_(NULL), |
53 default_ordinals_created_(false) { | 53 default_ordinals_created_(false) { |
54 } | 54 } |
55 | 55 |
56 ChromeAppSorting::~ChromeAppSorting() { | 56 ChromeAppSorting::~ChromeAppSorting() { |
57 } | 57 } |
58 | 58 |
59 void ChromeAppSorting::SetExtensionScopedPrefs(ExtensionScopedPrefs* prefs) { | 59 void ChromeAppSorting::SetExtensionScopedPrefs(ExtensionScopedPrefs* prefs) { |
60 extension_scoped_prefs_ = prefs; | 60 extension_scoped_prefs_ = prefs; |
not at google - send to devlin
2015/04/23 18:17:14
perhaps add 2 extra checks here, that |extension_s
Matt Giuca
2015/04/24 01:14:14
I don't want to alter this function. One of my the
| |
61 } | 61 } |
62 | 62 |
63 void ChromeAppSorting::CheckExtensionScopedPrefs() const { | |
64 CHECK(extension_scoped_prefs_); | |
65 } | |
66 | |
63 void ChromeAppSorting::SetExtensionSyncService( | 67 void ChromeAppSorting::SetExtensionSyncService( |
64 ExtensionSyncService* extension_sync_service) { | 68 ExtensionSyncService* extension_sync_service) { |
65 extension_sync_service_ = extension_sync_service; | 69 extension_sync_service_ = extension_sync_service; |
66 } | 70 } |
67 | 71 |
68 void ChromeAppSorting::Initialize( | 72 void ChromeAppSorting::Initialize( |
69 const extensions::ExtensionIdList& extension_ids) { | 73 const extensions::ExtensionIdList& extension_ids) { |
74 CHECK(extension_scoped_prefs_); | |
not at google - send to devlin
2015/04/23 18:17:14
For full debugging goodness, perhaps log |extensio
Matt Giuca
2015/04/24 01:14:14
The crash reports all have 0 extensions, so I assu
| |
70 InitializePageOrdinalMap(extension_ids); | 75 InitializePageOrdinalMap(extension_ids); |
71 | 76 |
72 MigrateAppIndex(extension_ids); | 77 MigrateAppIndex(extension_ids); |
73 } | 78 } |
74 | 79 |
75 void ChromeAppSorting::CreateOrdinalsIfNecessary(size_t minimum_size) { | 80 void ChromeAppSorting::CreateOrdinalsIfNecessary(size_t minimum_size) { |
76 // Create StringOrdinal values as required to ensure |ntp_ordinal_map_| has at | 81 // Create StringOrdinal values as required to ensure |ntp_ordinal_map_| has at |
77 // least |minimum_size| entries. | 82 // least |minimum_size| entries. |
78 if (ntp_ordinal_map_.empty() && minimum_size > 0) | 83 if (ntp_ordinal_map_.empty() && minimum_size > 0) |
79 ntp_ordinal_map_[syncer::StringOrdinal::CreateInitialOrdinal()]; | 84 ntp_ordinal_map_[syncer::StringOrdinal::CreateInitialOrdinal()]; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 return_value = app_list.rbegin()->first; | 468 return_value = app_list.rbegin()->first; |
464 else if (return_type == ChromeAppSorting::MIN_ORDINAL) | 469 else if (return_type == ChromeAppSorting::MIN_ORDINAL) |
465 return_value = app_list.begin()->first; | 470 return_value = app_list.begin()->first; |
466 } | 471 } |
467 | 472 |
468 return return_value; | 473 return return_value; |
469 } | 474 } |
470 | 475 |
471 void ChromeAppSorting::InitializePageOrdinalMap( | 476 void ChromeAppSorting::InitializePageOrdinalMap( |
472 const extensions::ExtensionIdList& extension_ids) { | 477 const extensions::ExtensionIdList& extension_ids) { |
478 // TODO(mgiuca): Added this CHECK to try and diagnose http://crbug.com/476648. | |
479 // Remove it after the investigation is concluded. | |
480 CHECK(extension_scoped_prefs_); | |
not at google - send to devlin
2015/04/23 18:17:14
Ditto
| |
473 for (extensions::ExtensionIdList::const_iterator ext_it = | 481 for (extensions::ExtensionIdList::const_iterator ext_it = |
474 extension_ids.begin(); ext_it != extension_ids.end(); ++ext_it) { | 482 extension_ids.begin(); ext_it != extension_ids.end(); ++ext_it) { |
475 AddOrdinalMapping(*ext_it, | 483 AddOrdinalMapping(*ext_it, |
476 GetPageOrdinal(*ext_it), | 484 GetPageOrdinal(*ext_it), |
477 GetAppLaunchOrdinal(*ext_it)); | 485 GetAppLaunchOrdinal(*ext_it)); |
478 | 486 |
479 // Ensure that the web store app still isn't found in this list, since | 487 // Ensure that the web store app still isn't found in this list, since |
480 // it is added after this loop. | 488 // it is added after this loop. |
481 DCHECK(*ext_it != extensions::kWebStoreAppId); | 489 DCHECK(*ext_it != extensions::kWebStoreAppId); |
482 DCHECK(*ext_it != extension_misc::kChromeAppId); | 490 DCHECK(*ext_it != extension_misc::kChromeAppId); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); | 627 for (AppLaunchOrdinalMap::const_iterator it = m.begin(); it != m.end(); |
620 ++it) { | 628 ++it) { |
621 const std::string& id = it->second; | 629 const std::string& id = it->second; |
622 if (ntp_hidden_extensions_.count(id) == 0) | 630 if (ntp_hidden_extensions_.count(id) == 0) |
623 result++; | 631 result++; |
624 } | 632 } |
625 return result; | 633 return result; |
626 } | 634 } |
627 | 635 |
628 } // namespace extensions | 636 } // namespace extensions |
OLD | NEW |