| 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 "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 TabRendererData::NetworkState TabContentsNetworkState( | 44 TabRendererData::NetworkState TabContentsNetworkState( |
| 45 WebContents* contents) { | 45 WebContents* contents) { |
| 46 if (!contents || !contents->IsLoading()) | 46 if (!contents || !contents->IsLoading()) |
| 47 return TabRendererData::NETWORK_STATE_NONE; | 47 return TabRendererData::NETWORK_STATE_NONE; |
| 48 if (contents->IsWaitingForResponse()) | 48 if (contents->IsWaitingForResponse()) |
| 49 return TabRendererData::NETWORK_STATE_WAITING; | 49 return TabRendererData::NETWORK_STATE_WAITING; |
| 50 return TabRendererData::NETWORK_STATE_LOADING; | 50 return TabRendererData::NETWORK_STATE_LOADING; |
| 51 } | 51 } |
| 52 | 52 |
| 53 TabStripLayoutType DetermineTabStripLayout(PrefService* prefs, | 53 TabStripLayoutType DetermineTabStripLayout( |
| 54 bool* adjust_layout) { | 54 PrefService* prefs, |
| 55 chrome::HostDesktopType host_desktop_type, |
| 56 bool* adjust_layout) { |
| 55 *adjust_layout = false; | 57 *adjust_layout = false; |
| 56 if (CommandLine::ForCurrentProcess()->HasSwitch( | 58 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 57 switches::kEnableStackedTabStrip)) { | 59 switches::kEnableStackedTabStrip)) { |
| 58 return TAB_STRIP_LAYOUT_STACKED; | 60 return TAB_STRIP_LAYOUT_STACKED; |
| 59 } | 61 } |
| 60 // For chromeos always allow entering stacked mode. | 62 // For chromeos always allow entering stacked mode. |
| 61 #if !defined(OS_CHROMEOS) | 63 #if defined(USE_AURA) |
| 64 if (host_desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) |
| 65 return TAB_STRIP_LAYOUT_SHRINK; |
| 66 #else |
| 62 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 67 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
| 63 return TAB_STRIP_LAYOUT_SHRINK; | 68 return TAB_STRIP_LAYOUT_SHRINK; |
| 64 #endif | 69 #endif |
| 65 *adjust_layout = true; | 70 *adjust_layout = true; |
| 66 switch (prefs->GetInteger(prefs::kTabStripLayoutType)) { | 71 switch (prefs->GetInteger(prefs::kTabStripLayoutType)) { |
| 67 case TAB_STRIP_LAYOUT_STACKED: | 72 case TAB_STRIP_LAYOUT_STACKED: |
| 68 return TAB_STRIP_LAYOUT_STACKED; | 73 return TAB_STRIP_LAYOUT_STACKED; |
| 69 default: | 74 default: |
| 70 return TAB_STRIP_LAYOUT_SHRINK; | 75 return TAB_STRIP_LAYOUT_SHRINK; |
| 71 } | 76 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 model_->delegate()->AddBlankTabAt(-1, true); | 353 model_->delegate()->AddBlankTabAt(-1, true); |
| 349 } | 354 } |
| 350 | 355 |
| 351 bool BrowserTabStripController::IsIncognito() { | 356 bool BrowserTabStripController::IsIncognito() { |
| 352 return browser_->profile()->IsOffTheRecord(); | 357 return browser_->profile()->IsOffTheRecord(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 void BrowserTabStripController::LayoutTypeMaybeChanged() { | 360 void BrowserTabStripController::LayoutTypeMaybeChanged() { |
| 356 bool adjust_layout = false; | 361 bool adjust_layout = false; |
| 357 TabStripLayoutType layout_type = | 362 TabStripLayoutType layout_type = |
| 358 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 363 DetermineTabStripLayout(g_browser_process->local_state(), |
| 364 browser_->host_desktop_type(), &adjust_layout); |
| 359 if (!adjust_layout || layout_type == tabstrip_->layout_type()) | 365 if (!adjust_layout || layout_type == tabstrip_->layout_type()) |
| 360 return; | 366 return; |
| 361 | 367 |
| 362 g_browser_process->local_state()->SetInteger( | 368 g_browser_process->local_state()->SetInteger( |
| 363 prefs::kTabStripLayoutType, | 369 prefs::kTabStripLayoutType, |
| 364 static_cast<int>(tabstrip_->layout_type())); | 370 static_cast<int>(tabstrip_->layout_type())); |
| 365 } | 371 } |
| 366 | 372 |
| 367 void BrowserTabStripController::OnStartedDraggingTabs() { | 373 void BrowserTabStripController::OnStartedDraggingTabs() { |
| 368 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 374 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 hover_tab_selector_.CancelTabTransition(); | 521 hover_tab_selector_.CancelTabTransition(); |
| 516 | 522 |
| 517 TabRendererData data; | 523 TabRendererData data; |
| 518 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); | 524 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); |
| 519 tabstrip_->AddTabAt(index, data, is_active); | 525 tabstrip_->AddTabAt(index, data, is_active); |
| 520 } | 526 } |
| 521 | 527 |
| 522 void BrowserTabStripController::UpdateLayoutType() { | 528 void BrowserTabStripController::UpdateLayoutType() { |
| 523 bool adjust_layout = false; | 529 bool adjust_layout = false; |
| 524 TabStripLayoutType layout_type = | 530 TabStripLayoutType layout_type = |
| 525 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 531 DetermineTabStripLayout(g_browser_process->local_state(), |
| 532 browser_->host_desktop_type(), &adjust_layout); |
| 526 tabstrip_->SetLayoutType(layout_type, adjust_layout); | 533 tabstrip_->SetLayoutType(layout_type, adjust_layout); |
| 527 } | 534 } |
| OLD | NEW |