| 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" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
| 13 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.h" |
| 18 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 18 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 21 #include "chrome/browser/ui/tabs/tab_utils.h" | 21 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 22 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 23 #include "chrome/browser/ui/views/tabs/tab.h" | 23 #include "chrome/browser/ui/views/tabs/tab.h" |
| 24 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" | 24 #include "chrome/browser/ui/views/tabs/tab_renderer_data.h" |
| 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
| 30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 31 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 32 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 33 #include "ui/base/layout.h" | 32 #include "ui/base/layout.h" |
| 34 #include "ui/base/models/list_selection_model.h" | 33 #include "ui/base/models/list_selection_model.h" |
| 35 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
| 36 #include "ui/views/controls/menu/menu_item_view.h" | 35 #include "ui/views/controls/menu/menu_item_view.h" |
| 37 #include "ui/views/controls/menu/menu_runner.h" | 36 #include "ui/views/controls/menu/menu_runner.h" |
| 38 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 39 | 38 |
| 40 using content::UserMetricsAction; | 39 using content::UserMetricsAction; |
| 41 using content::WebContents; | 40 using content::WebContents; |
| 42 using web_modal::WebContentsModalDialogManager; | |
| 43 | 41 |
| 44 namespace { | 42 namespace { |
| 45 | 43 |
| 46 TabRendererData::NetworkState TabContentsNetworkState( | 44 TabRendererData::NetworkState TabContentsNetworkState( |
| 47 WebContents* contents) { | 45 WebContents* contents) { |
| 48 if (!contents || !contents->IsLoading()) | 46 if (!contents || !contents->IsLoading()) |
| 49 return TabRendererData::NETWORK_STATE_NONE; | 47 return TabRendererData::NETWORK_STATE_NONE; |
| 50 if (contents->IsWaitingForResponse()) | 48 if (contents->IsWaitingForResponse()) |
| 51 return TabRendererData::NETWORK_STATE_WAITING; | 49 return TabRendererData::NETWORK_STATE_WAITING; |
| 52 return TabRendererData::NETWORK_STATE_LOADING; | 50 return TabRendererData::NETWORK_STATE_LOADING; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 TabStripLayoutType layout_type = | 357 TabStripLayoutType layout_type = |
| 360 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 358 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); |
| 361 if (!adjust_layout || layout_type == tabstrip_->layout_type()) | 359 if (!adjust_layout || layout_type == tabstrip_->layout_type()) |
| 362 return; | 360 return; |
| 363 | 361 |
| 364 g_browser_process->local_state()->SetInteger( | 362 g_browser_process->local_state()->SetInteger( |
| 365 prefs::kTabStripLayoutType, | 363 prefs::kTabStripLayoutType, |
| 366 static_cast<int>(tabstrip_->layout_type())); | 364 static_cast<int>(tabstrip_->layout_type())); |
| 367 } | 365 } |
| 368 | 366 |
| 369 bool BrowserTabStripController::IsTabShowingWebViewModalDialog(int index) { | |
| 370 DCHECK(model_->ContainsIndex(index)); | |
| 371 WebContentsModalDialogManager* contents_modal_dialog_manager = | |
| 372 WebContentsModalDialogManager::FromWebContents( | |
| 373 model_->GetWebContentsAt(index)); | |
| 374 return contents_modal_dialog_manager && | |
| 375 contents_modal_dialog_manager->IsShowingDialog(); | |
| 376 } | |
| 377 | |
| 378 void BrowserTabStripController::OnStartedDraggingTabs() { | 367 void BrowserTabStripController::OnStartedDraggingTabs() { |
| 379 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); | 368 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); |
| 380 if (browser_view && !immersive_reveal_lock_.get()) { | 369 if (browser_view && !immersive_reveal_lock_.get()) { |
| 381 // The top-of-window views should be revealed while the user is dragging | 370 // The top-of-window views should be revealed while the user is dragging |
| 382 // tabs in immersive fullscreen. The top-of-window views may not be already | 371 // tabs in immersive fullscreen. The top-of-window views may not be already |
| 383 // revealed if the user is attempting to attach a tab to a tabstrip | 372 // revealed if the user is attempting to attach a tab to a tabstrip |
| 384 // belonging to an immersive fullscreen window. | 373 // belonging to an immersive fullscreen window. |
| 385 immersive_reveal_lock_.reset( | 374 immersive_reveal_lock_.reset( |
| 386 browser_view->immersive_mode_controller()->GetRevealedLock( | 375 browser_view->immersive_mode_controller()->GetRevealedLock( |
| 387 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 376 ImmersiveModeController::ANIMATE_REVEAL_NO)); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); | 528 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); |
| 540 tabstrip_->AddTabAt(index, data, is_active); | 529 tabstrip_->AddTabAt(index, data, is_active); |
| 541 } | 530 } |
| 542 | 531 |
| 543 void BrowserTabStripController::UpdateLayoutType() { | 532 void BrowserTabStripController::UpdateLayoutType() { |
| 544 bool adjust_layout = false; | 533 bool adjust_layout = false; |
| 545 TabStripLayoutType layout_type = | 534 TabStripLayoutType layout_type = |
| 546 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 535 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); |
| 547 tabstrip_->SetLayoutType(layout_type, adjust_layout); | 536 tabstrip_->SetLayoutType(layout_type, adjust_layout); |
| 548 } | 537 } |
| OLD | NEW |