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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_model.cc

Issue 2155293002: Show the Cast toolbar icon ephemerally when Cast is in use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months 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
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/ui/toolbar/toolbar_actions_model.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 DCHECK(actions_initialized_); 336 DCHECK(actions_initialized_);
337 337
338 // See if we have a last known good position for this extension. 338 // See if we have a last known good position for this extension.
339 bool is_new_extension = 339 bool is_new_extension =
340 !ContainsValue(last_known_positions_, item.id); 340 !ContainsValue(last_known_positions_, item.id);
341 341
342 // New extensions go at the right (end) of the visible extensions. Other 342 // New extensions go at the right (end) of the visible extensions. Other
343 // extensions go at their previous position. 343 // extensions go at their previous position.
344 size_t new_index = 0; 344 size_t new_index = 0;
345 if (is_new_extension) { 345 if (is_new_extension) {
346 new_index = is_component ? 0 : visible_icon_count(); 346 new_index = visible_icon_count();
347 // For the last-known position, we use the index of the extension that is 347 // For the last-known position, we use the index of the extension that is
348 // just before this extension, plus one. (Note that this isn't the same 348 // just before this extension, plus one. (Note that this isn't the same
349 // as new_index + 1, because last_known_positions_ can include disabled 349 // as new_index + 1, because last_known_positions_ can include disabled
350 // extensions.) 350 // extensions.)
351 int new_last_known_index = 351 int new_last_known_index =
352 new_index == 0 ? 0 : std::find(last_known_positions_.begin(), 352 new_index == 0 ? 0 : std::find(last_known_positions_.begin(),
353 last_known_positions_.end(), 353 last_known_positions_.end(),
354 toolbar_items_[new_index - 1].id) - 354 toolbar_items_[new_index - 1].id) -
355 last_known_positions_.begin() + 1; 355 last_known_positions_.begin() + 1;
356 // In theory, the extension before this one should always 356 // In theory, the extension before this one should always
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 prefs_->GetInteger(extensions::pref_names::kToolbarSize); 838 prefs_->GetInteger(extensions::pref_names::kToolbarSize);
839 if (saved_icon_count != visible_icon_count_) 839 if (saved_icon_count != visible_icon_count_)
840 SetVisibleIconCount(saved_icon_count); 840 SetVisibleIconCount(saved_icon_count);
841 } 841 }
842 } 842 }
843 843
844 const extensions::Extension* ToolbarActionsModel::GetExtensionById( 844 const extensions::Extension* ToolbarActionsModel::GetExtensionById(
845 const std::string& id) const { 845 const std::string& id) const {
846 return extension_registry_->enabled_extensions().GetByID(id); 846 return extension_registry_->enabled_extensions().GetByID(id);
847 } 847 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698