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/tabs/browser_tab_strip_controller.h" | 5 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
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" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/tabs/tab_strip_model.h" | 12 #include "chrome/browser/tabs/tab_strip_model.h" |
| 13 #include "chrome/browser/tabs/tab_strip_selection_model.h" |
13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 16 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
16 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" | 17 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" |
17 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 18 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
18 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
19 #include "content/browser/renderer_host/render_view_host.h" | 20 #include "content/browser/renderer_host/render_view_host.h" |
20 #include "content/browser/tab_contents/tab_contents.h" | 21 #include "content/browser/tab_contents/tab_contents.h" |
21 #include "content/browser/user_metrics.h" | 22 #include "content/browser/user_metrics.h" |
22 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 } | 334 } |
334 | 335 |
335 void BrowserTabStripController::TabDetachedAt(TabContentsWrapper* contents, | 336 void BrowserTabStripController::TabDetachedAt(TabContentsWrapper* contents, |
336 int model_index) { | 337 int model_index) { |
337 // Cancel any pending tab transition. | 338 // Cancel any pending tab transition. |
338 hover_tab_selector_.CancelTabTransition(); | 339 hover_tab_selector_.CancelTabTransition(); |
339 | 340 |
340 tabstrip_->RemoveTabAt(model_index); | 341 tabstrip_->RemoveTabAt(model_index); |
341 } | 342 } |
342 | 343 |
343 void BrowserTabStripController::ActiveTabChanged( | 344 void BrowserTabStripController::TabSelectionChanged( |
344 TabContentsWrapper* old_contents, | 345 const TabStripSelectionModel& old_model) { |
345 TabContentsWrapper* contents, | 346 tabstrip_->SetSelection(old_model, model_->selection_model()); |
346 int model_index, | |
347 bool user_gesture) { | |
348 tabstrip_->SelectTabAt(model_->GetIndexOfTabContents(old_contents), | |
349 model_index); | |
350 } | 347 } |
351 | 348 |
352 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents, | 349 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents, |
353 int from_model_index, | 350 int from_model_index, |
354 int to_model_index) { | 351 int to_model_index) { |
355 // Cancel any pending tab transition. | 352 // Cancel any pending tab transition. |
356 hover_tab_selector_.CancelTabTransition(); | 353 hover_tab_selector_.CancelTabTransition(); |
357 | 354 |
358 // Update the data first as the pinned state may have changed. | 355 // Update the data first as the pinned state may have changed. |
359 TabRendererData data; | 356 TabRendererData data; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); | 469 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); |
473 // Note that this notification may be fired during a model mutation and | 470 // Note that this notification may be fired during a model mutation and |
474 // possibly before the tabstrip has processed the change. | 471 // possibly before the tabstrip has processed the change. |
475 // Here, we just re-layout each existing tab to reflect the change in its | 472 // Here, we just re-layout each existing tab to reflect the change in its |
476 // closeable state, and then schedule paint for entire tabstrip. | 473 // closeable state, and then schedule paint for entire tabstrip. |
477 for (int i = 0; i < tabstrip_->tab_count(); ++i) { | 474 for (int i = 0; i < tabstrip_->tab_count(); ++i) { |
478 tabstrip_->base_tab_at_tab_index(i)->Layout(); | 475 tabstrip_->base_tab_at_tab_index(i)->Layout(); |
479 } | 476 } |
480 tabstrip_->SchedulePaint(); | 477 tabstrip_->SchedulePaint(); |
481 } | 478 } |
OLD | NEW |