Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc

Issue 291093005: Removes --enable-stacked-tab-strip flag (Stacked Tabs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes --enable-stacked-tab-strip flag (more refactoring) Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 TabRendererData::NetworkState TabContentsNetworkState( 53 TabRendererData::NetworkState TabContentsNetworkState(
54 WebContents* contents) { 54 WebContents* contents) {
55 if (!contents || !contents->IsLoading()) 55 if (!contents || !contents->IsLoading())
56 return TabRendererData::NETWORK_STATE_NONE; 56 return TabRendererData::NETWORK_STATE_NONE;
57 if (contents->IsWaitingForResponse()) 57 if (contents->IsWaitingForResponse())
58 return TabRendererData::NETWORK_STATE_WAITING; 58 return TabRendererData::NETWORK_STATE_WAITING;
59 return TabRendererData::NETWORK_STATE_LOADING; 59 return TabRendererData::NETWORK_STATE_LOADING;
60 } 60 }
61 61
62 TabStripLayoutType DetermineTabStripLayout( 62 bool DetermineTabStripLayoutStacked(
63 PrefService* prefs, 63 PrefService* prefs,
64 chrome::HostDesktopType host_desktop_type, 64 chrome::HostDesktopType host_desktop_type,
65 bool* adjust_layout) { 65 bool* adjust_layout) {
66 *adjust_layout = false; 66 *adjust_layout = false;
67 if (CommandLine::ForCurrentProcess()->HasSwitch(
68 switches::kEnableStackedTabStrip)) {
69 return TAB_STRIP_LAYOUT_STACKED;
70 }
71 // For ash, always allow entering stacked mode. 67 // For ash, always allow entering stacked mode.
72 if (host_desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) 68 if (host_desktop_type != chrome::HOST_DESKTOP_TYPE_ASH)
73 return TAB_STRIP_LAYOUT_SHRINK; 69 return false;
74 *adjust_layout = true; 70 *adjust_layout = true;
75 switch (prefs->GetInteger(prefs::kTabStripLayoutType)) { 71 return prefs->GetBoolean(prefs::kTabStripStackedLayout);
76 case TAB_STRIP_LAYOUT_STACKED:
77 return TAB_STRIP_LAYOUT_STACKED;
78 default:
79 return TAB_STRIP_LAYOUT_SHRINK;
80 }
81 } 72 }
82 73
83 // Get the MIME type of the file pointed to by the url, based on the file's 74 // Get the MIME type of the file pointed to by the url, based on the file's
84 // extension. Must be called on a thread that allows IO. 75 // extension. Must be called on a thread that allows IO.
85 std::string FindURLMimeType(const GURL& url) { 76 std::string FindURLMimeType(const GURL& url) {
86 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 77 DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
87 base::FilePath full_path; 78 base::FilePath full_path;
88 net::FileURLToFilePath(url, &full_path); 79 net::FileURLToFilePath(url, &full_path);
89 80
90 // Get the MIME type based on the filename. 81 // Get the MIME type based on the filename.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 TabStripModel* model) 185 TabStripModel* model)
195 : model_(model), 186 : model_(model),
196 tabstrip_(NULL), 187 tabstrip_(NULL),
197 browser_(browser), 188 browser_(browser),
198 hover_tab_selector_(model), 189 hover_tab_selector_(model),
199 weak_ptr_factory_(this) { 190 weak_ptr_factory_(this) {
200 model_->AddObserver(this); 191 model_->AddObserver(this);
201 192
202 local_pref_registrar_.Init(g_browser_process->local_state()); 193 local_pref_registrar_.Init(g_browser_process->local_state());
203 local_pref_registrar_.Add( 194 local_pref_registrar_.Add(
204 prefs::kTabStripLayoutType, 195 prefs::kTabStripStackedLayout,
205 base::Bind(&BrowserTabStripController::UpdateLayoutType, 196 base::Bind(&BrowserTabStripController::UpdateLayoutType,
206 base::Unretained(this))); 197 base::Unretained(this)));
207 } 198 }
208 199
209 BrowserTabStripController::~BrowserTabStripController() { 200 BrowserTabStripController::~BrowserTabStripController() {
210 // When we get here the TabStrip is being deleted. We need to explicitly 201 // When we get here the TabStrip is being deleted. We need to explicitly
211 // cancel the menu, otherwise it may try to invoke something on the tabstrip 202 // cancel the menu, otherwise it may try to invoke something on the tabstrip
212 // from its destructor. 203 // from its destructor.
213 if (context_menu_contents_.get()) 204 if (context_menu_contents_.get())
214 context_menu_contents_->Cancel(); 205 context_menu_contents_->Cancel();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (match.destination_url.is_valid()) 376 if (match.destination_url.is_valid())
386 model_->delegate()->AddTabAt(match.destination_url, -1, true); 377 model_->delegate()->AddTabAt(match.destination_url, -1, true);
387 } 378 }
388 379
389 bool BrowserTabStripController::IsIncognito() { 380 bool BrowserTabStripController::IsIncognito() {
390 return browser_->profile()->IsOffTheRecord(); 381 return browser_->profile()->IsOffTheRecord();
391 } 382 }
392 383
393 void BrowserTabStripController::LayoutTypeMaybeChanged() { 384 void BrowserTabStripController::LayoutTypeMaybeChanged() {
394 bool adjust_layout = false; 385 bool adjust_layout = false;
395 TabStripLayoutType layout_type = 386 bool stacked_layout =
396 DetermineTabStripLayout(g_browser_process->local_state(), 387 DetermineTabStripLayoutStacked(g_browser_process->local_state(),
397 browser_->host_desktop_type(), &adjust_layout); 388 browser_->host_desktop_type(),
398 if (!adjust_layout || layout_type == tabstrip_->layout_type()) 389 &adjust_layout);
390 if (!adjust_layout || stacked_layout == tabstrip_->stacked_layout())
399 return; 391 return;
400 392
401 g_browser_process->local_state()->SetInteger( 393 g_browser_process->local_state()->SetBoolean(prefs::kTabStripStackedLayout,
402 prefs::kTabStripLayoutType, 394 tabstrip_->stacked_layout());
403 static_cast<int>(tabstrip_->layout_type()));
404 } 395 }
405 396
406 void BrowserTabStripController::OnStartedDraggingTabs() { 397 void BrowserTabStripController::OnStartedDraggingTabs() {
407 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_); 398 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser_);
408 if (browser_view && !immersive_reveal_lock_.get()) { 399 if (browser_view && !immersive_reveal_lock_.get()) {
409 // The top-of-window views should be revealed while the user is dragging 400 // The top-of-window views should be revealed while the user is dragging
410 // tabs in immersive fullscreen. The top-of-window views may not be already 401 // tabs in immersive fullscreen. The top-of-window views may not be already
411 // revealed if the user is attempting to attach a tab to a tabstrip 402 // revealed if the user is attempting to attach a tab to a tabstrip
412 // belonging to an immersive fullscreen window. 403 // belonging to an immersive fullscreen window.
413 immersive_reveal_lock_.reset( 404 immersive_reveal_lock_.reset(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // Cancel any pending tab transition. 554 // Cancel any pending tab transition.
564 hover_tab_selector_.CancelTabTransition(); 555 hover_tab_selector_.CancelTabTransition();
565 556
566 TabRendererData data; 557 TabRendererData data;
567 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB); 558 SetTabRendererDataFromModel(contents, index, &data, NEW_TAB);
568 tabstrip_->AddTabAt(index, data, is_active); 559 tabstrip_->AddTabAt(index, data, is_active);
569 } 560 }
570 561
571 void BrowserTabStripController::UpdateLayoutType() { 562 void BrowserTabStripController::UpdateLayoutType() {
572 bool adjust_layout = false; 563 bool adjust_layout = false;
573 TabStripLayoutType layout_type = 564 bool stacked_layout =
574 DetermineTabStripLayout(g_browser_process->local_state(), 565 DetermineTabStripLayoutStacked(g_browser_process->local_state(),
575 browser_->host_desktop_type(), &adjust_layout); 566 browser_->host_desktop_type(),
576 tabstrip_->SetLayoutType(layout_type, adjust_layout); 567 &adjust_layout);
568 tabstrip_->set_adjust_layout(adjust_layout);
569 tabstrip_->SetStackedLayout(stacked_layout);
577 } 570 }
578 571
579 void BrowserTabStripController::OnFindURLMimeTypeCompleted( 572 void BrowserTabStripController::OnFindURLMimeTypeCompleted(
580 const GURL& url, 573 const GURL& url,
581 const std::string& mime_type) { 574 const std::string& mime_type) {
582 // Check whether the mime type, if given, is known to be supported or whether 575 // Check whether the mime type, if given, is known to be supported or whether
583 // there is a plugin that supports the mime type (e.g. PDF). 576 // there is a plugin that supports the mime type (e.g. PDF).
584 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not 577 // TODO(bauerb): This possibly uses stale information, but it's guaranteed not
585 // to do disk access. 578 // to do disk access.
586 content::WebPluginInfo plugin; 579 content::WebPluginInfo plugin;
587 tabstrip_->FileSupported( 580 tabstrip_->FileSupported(
588 url, 581 url,
589 mime_type.empty() || 582 mime_type.empty() ||
590 net::IsSupportedMimeType(mime_type) || 583 net::IsSupportedMimeType(mime_type) ||
591 content::PluginService::GetInstance()->GetPluginInfo( 584 content::PluginService::GetInstance()->GetPluginInfo(
592 -1, // process ID 585 -1, // process ID
593 MSG_ROUTING_NONE, // routing ID 586 MSG_ROUTING_NONE, // routing ID
594 model_->profile()->GetResourceContext(), 587 model_->profile()->GetResourceContext(),
595 url, GURL(), mime_type, false, 588 url, GURL(), mime_type, false,
596 NULL, &plugin, NULL)); 589 NULL, &plugin, NULL));
597 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698