| 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/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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 visible_count_delta = 1; | 381 visible_count_delta = 1; |
| 382 } else if (profile_->IsOffTheRecord()) { | 382 } else if (profile_->IsOffTheRecord()) { |
| 383 // If this is an incognito profile, we also have to check to make sure the | 383 // If this is an incognito profile, we also have to check to make sure the |
| 384 // overflow matches the main bar's status. | 384 // overflow matches the main bar's status. |
| 385 ToolbarActionsModel* main_model = | 385 ToolbarActionsModel* main_model = |
| 386 ToolbarActionsModel::Get(profile_->GetOriginalProfile()); | 386 ToolbarActionsModel::Get(profile_->GetOriginalProfile()); |
| 387 // Find what the index will be in the main bar. Because Observer calls are | 387 // Find what the index will be in the main bar. Because Observer calls are |
| 388 // nondeterministic, we can't just assume the main bar will have the | 388 // nondeterministic, we can't just assume the main bar will have the |
| 389 // extension and look it up. | 389 // extension and look it up. |
| 390 size_t main_index = main_model->FindNewPositionFromLastKnownGood(item); | 390 size_t main_index = main_model->FindNewPositionFromLastKnownGood(item); |
| 391 bool visible = main_index < main_model->visible_icon_count(); | 391 bool visible = |
| 392 is_new_extension || main_index < main_model->visible_icon_count(); |
| 392 // We may need to adjust the visible count if the incognito bar isn't | 393 // We may need to adjust the visible count if the incognito bar isn't |
| 393 // showing all icons and this one is visible, or if it is showing all | 394 // showing all icons and this one is visible, or if it is showing all |
| 394 // icons and this is hidden. | 395 // icons and this is hidden. |
| 395 if (visible && !all_icons_visible()) | 396 if (visible && !all_icons_visible()) |
| 396 visible_count_delta = 1; | 397 visible_count_delta = 1; |
| 397 else if (!visible && all_icons_visible()) | 398 else if (!visible && all_icons_visible()) |
| 398 visible_count_delta = -1; | 399 visible_count_delta = -1; |
| 399 } | 400 } |
| 400 | 401 |
| 401 if (visible_count_delta) | 402 if (visible_count_delta) |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 return extension_registry_->enabled_extensions().GetByID(id); | 860 return extension_registry_->enabled_extensions().GetByID(id); |
| 860 } | 861 } |
| 861 | 862 |
| 862 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { | 863 bool ToolbarActionsModel::IsActionVisible(const std::string& action_id) const { |
| 863 size_t index = 0u; | 864 size_t index = 0u; |
| 864 while (toolbar_items().size() > index && | 865 while (toolbar_items().size() > index && |
| 865 toolbar_items()[index].id != action_id) | 866 toolbar_items()[index].id != action_id) |
| 866 ++index; | 867 ++index; |
| 867 return index < visible_icon_count(); | 868 return index < visible_icon_count(); |
| 868 } | 869 } |
| OLD | NEW |