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_toolbar_model.h" | 5 #include "chrome/browser/extensions/extension_toolbar_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/histogram_base.h" | 12 #include "base/metrics/histogram_base.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/profiler/scoped_tracker.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 16 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
16 #include "chrome/browser/extensions/extension_action_manager.h" | 17 #include "chrome/browser/extensions/extension_action_manager.h" |
17 #include "chrome/browser/extensions/extension_tab_util.h" | 18 #include "chrome/browser/extensions/extension_tab_util.h" |
18 #include "chrome/browser/extensions/extension_toolbar_model_factory.h" | 19 #include "chrome/browser/extensions/extension_toolbar_model_factory.h" |
19 #include "chrome/browser/extensions/extension_util.h" | 20 #include "chrome/browser/extensions/extension_util.h" |
20 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // Combine the currently enabled extensions that have browser actions (which | 419 // Combine the currently enabled extensions that have browser actions (which |
419 // we get from the ExtensionRegistry) with the ordering we get from the | 420 // we get from the ExtensionRegistry) with the ordering we get from the |
420 // pref service. For robustness we use a somewhat inefficient process: | 421 // pref service. For robustness we use a somewhat inefficient process: |
421 // 1. Create a vector of extensions sorted by their pref values. This vector may | 422 // 1. Create a vector of extensions sorted by their pref values. This vector may |
422 // have holes. | 423 // have holes. |
423 // 2. Create a vector of extensions that did not have a pref value. | 424 // 2. Create a vector of extensions that did not have a pref value. |
424 // 3. Remove holes from the sorted vector and append the unsorted vector. | 425 // 3. Remove holes from the sorted vector and append the unsorted vector. |
425 void ExtensionToolbarModel::InitializeExtensionList() { | 426 void ExtensionToolbarModel::InitializeExtensionList() { |
426 DCHECK(toolbar_items_.empty()); // We shouldn't have any items yet. | 427 DCHECK(toolbar_items_.empty()); // We shouldn't have any items yet. |
427 | 428 |
| 429 // TODO(robliao): Remove ScopedTracker below once crbug.com/463337 is fixed. |
| 430 tracked_objects::ScopedTracker tracking_profile1( |
| 431 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 432 "463337 ExtensionToolbarModel::InitializeExtensionList1")); |
428 last_known_positions_ = extension_prefs_->GetToolbarOrder(); | 433 last_known_positions_ = extension_prefs_->GetToolbarOrder(); |
429 if (profile_->IsOffTheRecord()) | 434 if (profile_->IsOffTheRecord()) { |
| 435 // TODO(robliao): Remove ScopedTracker below once crbug.com/463337 is fixed. |
| 436 tracked_objects::ScopedTracker tracking_profile2( |
| 437 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 438 "463337 ExtensionToolbarModel::InitializeExtensionList2")); |
430 IncognitoPopulate(); | 439 IncognitoPopulate(); |
431 else | 440 } else { |
| 441 // TODO(robliao): Remove ScopedTracker below once crbug.com/463337 is fixed. |
| 442 tracked_objects::ScopedTracker tracking_profile3( |
| 443 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 444 "463337 ExtensionToolbarModel::InitializeExtensionList3")); |
432 Populate(&last_known_positions_); | 445 Populate(&last_known_positions_); |
| 446 } |
433 | 447 |
434 extensions_initialized_ = true; | 448 extensions_initialized_ = true; |
| 449 |
| 450 // TODO(robliao): Remove ScopedTracker below once crbug.com/463337 is fixed. |
| 451 tracked_objects::ScopedTracker tracking_profile4( |
| 452 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 453 "463337 ExtensionToolbarModel::InitializeExtensionList4")); |
435 MaybeUpdateVisibilityPrefs(); | 454 MaybeUpdateVisibilityPrefs(); |
| 455 |
| 456 // TODO(robliao): Remove ScopedTracker below once crbug.com/463337 is fixed. |
| 457 tracked_objects::ScopedTracker tracking_profile5( |
| 458 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 459 "463337 ExtensionToolbarModel::InitializeExtensionList5")); |
436 FOR_EACH_OBSERVER(Observer, observers_, OnToolbarModelInitialized()); | 460 FOR_EACH_OBSERVER(Observer, observers_, OnToolbarModelInitialized()); |
437 } | 461 } |
438 | 462 |
439 void ExtensionToolbarModel::Populate(ExtensionIdList* positions) { | 463 void ExtensionToolbarModel::Populate(ExtensionIdList* positions) { |
440 DCHECK(!profile_->IsOffTheRecord()); | 464 DCHECK(!profile_->IsOffTheRecord()); |
441 const ExtensionSet& extensions = | 465 const ExtensionSet& extensions = |
442 ExtensionRegistry::Get(profile_)->enabled_extensions(); | 466 ExtensionRegistry::Get(profile_)->enabled_extensions(); |
443 // Items that have explicit positions. | 467 // Items that have explicit positions. |
444 ExtensionList sorted(positions->size(), NULL); | 468 ExtensionList sorted(positions->size(), NULL); |
445 // The items that don't have explicit positions. | 469 // The items that don't have explicit positions. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 if (is_highlighting_) { | 733 if (is_highlighting_) { |
710 highlighted_items_.clear(); | 734 highlighted_items_.clear(); |
711 is_highlighting_ = false; | 735 is_highlighting_ = false; |
712 if (old_visible_icon_count_ != visible_icon_count_) | 736 if (old_visible_icon_count_ != visible_icon_count_) |
713 SetVisibleIconCount(old_visible_icon_count_); | 737 SetVisibleIconCount(old_visible_icon_count_); |
714 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false)); | 738 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false)); |
715 } | 739 } |
716 } | 740 } |
717 | 741 |
718 } // namespace extensions | 742 } // namespace extensions |
OLD | NEW |