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/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" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 bool BrowserTabStripController::IsValidIndex(int index) const { | 194 bool BrowserTabStripController::IsValidIndex(int index) const { |
195 return model_->ContainsIndex(index); | 195 return model_->ContainsIndex(index); |
196 } | 196 } |
197 | 197 |
198 bool BrowserTabStripController::IsActiveTab(int model_index) const { | 198 bool BrowserTabStripController::IsActiveTab(int model_index) const { |
199 return model_->active_index() == model_index; | 199 return model_->active_index() == model_index; |
200 } | 200 } |
201 | 201 |
| 202 int BrowserTabStripController::GetActiveIndex() const { |
| 203 return model_->active_index(); |
| 204 } |
| 205 |
202 bool BrowserTabStripController::IsTabSelected(int model_index) const { | 206 bool BrowserTabStripController::IsTabSelected(int model_index) const { |
203 return model_->IsTabSelected(model_index); | 207 return model_->IsTabSelected(model_index); |
204 } | 208 } |
205 | 209 |
206 bool BrowserTabStripController::IsTabPinned(int model_index) const { | 210 bool BrowserTabStripController::IsTabPinned(int model_index) const { |
207 return model_->ContainsIndex(model_index) && model_->IsTabPinned(model_index); | 211 return model_->ContainsIndex(model_index) && model_->IsTabPinned(model_index); |
208 } | 212 } |
209 | 213 |
210 bool BrowserTabStripController::IsTabCloseable(int model_index) const { | 214 bool BrowserTabStripController::IsTabCloseable(int model_index) const { |
211 return !model_->ContainsIndex(model_index) || | 215 return !model_->ContainsIndex(model_index) || |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 320 |
317 bool BrowserTabStripController::IsIncognito() { | 321 bool BrowserTabStripController::IsIncognito() { |
318 return browser_->profile()->IsOffTheRecord(); | 322 return browser_->profile()->IsOffTheRecord(); |
319 } | 323 } |
320 | 324 |
321 //////////////////////////////////////////////////////////////////////////////// | 325 //////////////////////////////////////////////////////////////////////////////// |
322 // BrowserTabStripController, TabStripModelObserver implementation: | 326 // BrowserTabStripController, TabStripModelObserver implementation: |
323 | 327 |
324 void BrowserTabStripController::TabInsertedAt(TabContentsWrapper* contents, | 328 void BrowserTabStripController::TabInsertedAt(TabContentsWrapper* contents, |
325 int model_index, | 329 int model_index, |
326 bool active) { | 330 bool is_active) { |
327 DCHECK(contents); | 331 DCHECK(contents); |
328 DCHECK(model_index == TabStripModel::kNoTab || | 332 DCHECK(model_index == TabStripModel::kNoTab || |
329 model_->ContainsIndex(model_index)); | 333 model_->ContainsIndex(model_index)); |
330 | 334 |
331 // Cancel any pending tab transition. | 335 // Cancel any pending tab transition. |
332 hover_tab_selector_.CancelTabTransition(); | 336 hover_tab_selector_.CancelTabTransition(); |
333 | 337 |
334 TabRendererData data; | 338 TabRendererData data; |
335 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, | 339 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, |
336 NEW_TAB); | 340 NEW_TAB); |
337 tabstrip_->AddTabAt(model_index, data); | 341 tabstrip_->AddTabAt(model_index, data, is_active); |
338 } | 342 } |
339 | 343 |
340 void BrowserTabStripController::TabDetachedAt(TabContentsWrapper* contents, | 344 void BrowserTabStripController::TabDetachedAt(TabContentsWrapper* contents, |
341 int model_index) { | 345 int model_index) { |
342 // Cancel any pending tab transition. | 346 // Cancel any pending tab transition. |
343 hover_tab_selector_.CancelTabTransition(); | 347 hover_tab_selector_.CancelTabTransition(); |
344 | 348 |
345 tabstrip_->RemoveTabAt(model_index); | 349 tabstrip_->RemoveTabAt(model_index); |
346 } | 350 } |
347 | 351 |
348 void BrowserTabStripController::TabSelectionChanged( | 352 void BrowserTabStripController::TabSelectionChanged( |
349 TabStripModel* tab_strip_model, | 353 TabStripModel* tab_strip_model, |
350 const TabStripSelectionModel& old_model) { | 354 const TabStripSelectionModel& old_model) { |
351 tabstrip_->SetSelection(old_model, model_->selection_model()); | 355 tabstrip_->SetSelection(old_model, model_->selection_model()); |
352 } | 356 } |
353 | 357 |
354 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents, | 358 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents, |
355 int from_model_index, | 359 int from_model_index, |
356 int to_model_index) { | 360 int to_model_index) { |
357 // Cancel any pending tab transition. | 361 // Cancel any pending tab transition. |
358 hover_tab_selector_.CancelTabTransition(); | 362 hover_tab_selector_.CancelTabTransition(); |
359 | 363 |
360 // Update the data first as the pinned state may have changed. | 364 // Pass in the TabRendererData as the pinned state may have changed. |
361 TabRendererData data; | 365 TabRendererData data; |
362 SetTabRendererDataFromModel(contents->web_contents(), to_model_index, &data, | 366 SetTabRendererDataFromModel(contents->web_contents(), to_model_index, &data, |
363 EXISTING_TAB); | 367 EXISTING_TAB); |
364 tabstrip_->SetTabData(from_model_index, data); | 368 tabstrip_->MoveTab(from_model_index, to_model_index, data); |
365 | |
366 tabstrip_->MoveTab(from_model_index, to_model_index); | |
367 } | 369 } |
368 | 370 |
369 void BrowserTabStripController::TabChangedAt(TabContentsWrapper* contents, | 371 void BrowserTabStripController::TabChangedAt(TabContentsWrapper* contents, |
370 int model_index, | 372 int model_index, |
371 TabChangeType change_type) { | 373 TabChangeType change_type) { |
372 if (change_type == TITLE_NOT_LOADING) { | 374 if (change_type == TITLE_NOT_LOADING) { |
373 tabstrip_->TabTitleChangedNotLoading(model_index); | 375 tabstrip_->TabTitleChangedNotLoading(model_index); |
374 // We'll receive another notification of the change asynchronously. | 376 // We'll receive another notification of the change asynchronously. |
375 return; | 377 return; |
376 } | 378 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 479 |
478 void BrowserTabStripController::StopHighlightTabsForCommand( | 480 void BrowserTabStripController::StopHighlightTabsForCommand( |
479 TabStripModel::ContextMenuCommand command_id, | 481 TabStripModel::ContextMenuCommand command_id, |
480 BaseTab* tab) { | 482 BaseTab* tab) { |
481 if (command_id == TabStripModel::CommandCloseTabsToRight || | 483 if (command_id == TabStripModel::CommandCloseTabsToRight || |
482 command_id == TabStripModel::CommandCloseOtherTabs) { | 484 command_id == TabStripModel::CommandCloseOtherTabs) { |
483 // Just tell all Tabs to stop pulsing - it's safe. | 485 // Just tell all Tabs to stop pulsing - it's safe. |
484 tabstrip_->StopAllHighlighting(); | 486 tabstrip_->StopAllHighlighting(); |
485 } | 487 } |
486 } | 488 } |
OLD | NEW |