Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/aura/launcher_icon_updater.h" | 5 #include "chrome/browser/ui/views/aura/launcher_icon_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_tab_helper.h" | 9 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 10 #include "chrome/browser/favicon/favicon_tab_helper.h" | 10 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 int index, | 79 int index, |
| 80 TabStripModelObserver::TabChangeType change_type) { | 80 TabStripModelObserver::TabChangeType change_type) { |
| 81 if (change_type != TabStripModelObserver::LOADING_ONLY && | 81 if (change_type != TabStripModelObserver::LOADING_ONLY && |
| 82 change_type != TabStripModelObserver::TITLE_NOT_LOADING) { | 82 change_type != TabStripModelObserver::TITLE_NOT_LOADING) { |
| 83 Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), tab); | 83 Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), tab); |
| 84 if (i != tabs_.end() && (i - tabs_.begin()) < kMaxCount) | 84 if (i != tabs_.end() && (i - tabs_.begin()) < kMaxCount) |
| 85 UpdateLauncher(); | 85 UpdateLauncher(); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 void LauncherIconUpdater::TabReplacedAt(TabStripModel* tab_strip_model, | |
| 90 TabContentsWrapper* old_contents, | |
| 91 TabContentsWrapper* new_contents, | |
| 92 int index) { | |
| 93 Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), old_contents); | |
| 94 if (i != tabs_.end()) { | |
| 95 tabs_.erase(i); | |
|
sky
2011/11/17 05:04:23
This should replace the value at i with new_conten
alicet1
2011/11/17 05:33:39
Done.
| |
| 96 tabs_.push_back(new_contents); | |
| 97 } | |
| 98 } | |
| 99 | |
| 89 void LauncherIconUpdater::UpdateLauncher() { | 100 void LauncherIconUpdater::UpdateLauncher() { |
| 90 if (tabs_.empty()) | 101 if (tabs_.empty()) |
| 91 return; // Assume the window is going to be closed if there are no tabs. | 102 return; // Assume the window is going to be closed if there are no tabs. |
| 92 | 103 |
| 93 int item_index = launcher_model_->ItemIndexByWindow(window_); | 104 int item_index = launcher_model_->ItemIndexByWindow(window_); |
| 94 if (item_index == -1) | 105 if (item_index == -1) |
| 95 return; | 106 return; |
| 96 | 107 |
| 97 if (launcher_model_->items()[item_index].type == aura_shell::TYPE_APP) { | 108 if (launcher_model_->items()[item_index].type == aura_shell::TYPE_APP) { |
| 98 // Use the app icon if we can. | 109 // Use the app icon if we can. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 112 // TODO: needs to be updated for apps. | 123 // TODO: needs to be updated for apps. |
| 113 images[i].image = tabs_[i]->favicon_tab_helper()->GetFavicon(); | 124 images[i].image = tabs_[i]->favicon_tab_helper()->GetFavicon(); |
| 114 if (images[i].image.empty()) { | 125 if (images[i].image.empty()) { |
| 115 images[i].image = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 126 images[i].image = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 116 IDR_DEFAULT_FAVICON); | 127 IDR_DEFAULT_FAVICON); |
| 117 } | 128 } |
| 118 images[i].user_data = tabs_[i]; | 129 images[i].user_data = tabs_[i]; |
| 119 } | 130 } |
| 120 launcher_model_->SetTabbedImages(item_index, images); | 131 launcher_model_->SetTabbedImages(item_index, images); |
| 121 } | 132 } |
| OLD | NEW |