| 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" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // See if we have a last known good position for this extension. | 311 // See if we have a last known good position for this extension. |
| 312 bool is_new_extension = | 312 bool is_new_extension = |
| 313 std::find(last_known_positions_.begin(), | 313 std::find(last_known_positions_.begin(), |
| 314 last_known_positions_.end(), | 314 last_known_positions_.end(), |
| 315 extension->id()) == last_known_positions_.end(); | 315 extension->id()) == last_known_positions_.end(); |
| 316 | 316 |
| 317 // New extensions go at the right (end) of the visible extensions. Other | 317 // New extensions go at the right (end) of the visible extensions. Other |
| 318 // extensions go at their previous position. | 318 // extensions go at their previous position. |
| 319 size_t new_index = 0; | 319 size_t new_index = 0; |
| 320 if (is_new_extension) { | 320 if (is_new_extension) { |
| 321 new_index = visible_icon_count(); | 321 new_index = Manifest::IsComponentLocation(extension->location()) ? |
| 322 0 : visible_icon_count(); |
| 322 // For the last-known position, we use the index of the extension that is | 323 // For the last-known position, we use the index of the extension that is |
| 323 // just before this extension, plus one. (Note that this isn't the same | 324 // just before this extension, plus one. (Note that this isn't the same |
| 324 // as new_index + 1, because last_known_positions_ can include disabled | 325 // as new_index + 1, because last_known_positions_ can include disabled |
| 325 // extensions.) | 326 // extensions.) |
| 326 int new_last_known_index = | 327 int new_last_known_index = |
| 327 new_index == 0 ? 0 : | 328 new_index == 0 ? 0 : |
| 328 std::find(last_known_positions_.begin(), | 329 std::find(last_known_positions_.begin(), |
| 329 last_known_positions_.end(), | 330 last_known_positions_.end(), |
| 330 toolbar_items_[new_index - 1]->id()) - | 331 toolbar_items_[new_index - 1]->id()) - |
| 331 last_known_positions_.begin() + 1; | 332 last_known_positions_.begin() + 1; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 if (is_highlighting_) { | 734 if (is_highlighting_) { |
| 734 highlighted_items_.clear(); | 735 highlighted_items_.clear(); |
| 735 is_highlighting_ = false; | 736 is_highlighting_ = false; |
| 736 if (old_visible_icon_count_ != visible_icon_count_) | 737 if (old_visible_icon_count_ != visible_icon_count_) |
| 737 SetVisibleIconCount(old_visible_icon_count_); | 738 SetVisibleIconCount(old_visible_icon_count_); |
| 738 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false)); | 739 FOR_EACH_OBSERVER(Observer, observers_, ToolbarHighlightModeChanged(false)); |
| 739 } | 740 } |
| 740 } | 741 } |
| 741 | 742 |
| 742 } // namespace extensions | 743 } // namespace extensions |
| OLD | NEW |