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

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

Issue 7065052: Improve large tab strip by leveraging touch icons when present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ' Created 9 years, 6 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) 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"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 int model_index, 321 int model_index,
322 bool active) { 322 bool active) {
323 DCHECK(contents); 323 DCHECK(contents);
324 DCHECK(model_index == TabStripModel::kNoTab || 324 DCHECK(model_index == TabStripModel::kNoTab ||
325 model_->ContainsIndex(model_index)); 325 model_->ContainsIndex(model_index));
326 326
327 // Cancel any pending tab transition. 327 // Cancel any pending tab transition.
328 hover_tab_selector_.CancelTabTransition(); 328 hover_tab_selector_.CancelTabTransition();
329 329
330 TabRendererData data; 330 TabRendererData data;
331 SetTabRendererDataFromModel(contents->tab_contents(), model_index, &data); 331 SetTabRendererDataFromModel(contents->tab_contents(), model_index, &data,
332 true);
sky 2011/06/16 15:43:41 align with ( on 331.
Emmanuel Saint-loubert-Bié 2011/06/17 00:01:44 OK I agree this is probably more readable. Here is
332 tabstrip_->AddTabAt(model_index, data); 333 tabstrip_->AddTabAt(model_index, data);
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::ActiveTabChanged(
344 TabContentsWrapper* old_contents, 345 TabContentsWrapper* old_contents,
345 TabContentsWrapper* contents, 346 TabContentsWrapper* contents,
346 int model_index, 347 int model_index,
347 bool user_gesture) { 348 bool user_gesture) {
348 tabstrip_->SelectTabAt(model_->GetIndexOfTabContents(old_contents), 349 tabstrip_->SelectTabAt(model_->GetIndexOfTabContents(old_contents),
349 model_index); 350 model_index);
350 } 351 }
351 352
352 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents, 353 void BrowserTabStripController::TabMoved(TabContentsWrapper* contents,
353 int from_model_index, 354 int from_model_index,
354 int to_model_index) { 355 int to_model_index) {
355 // Cancel any pending tab transition. 356 // Cancel any pending tab transition.
356 hover_tab_selector_.CancelTabTransition(); 357 hover_tab_selector_.CancelTabTransition();
357 358
358 // Update the data first as the pinned state may have changed. 359 // Update the data first as the pinned state may have changed.
359 TabRendererData data; 360 TabRendererData data;
360 SetTabRendererDataFromModel(contents->tab_contents(), to_model_index, &data); 361 SetTabRendererDataFromModel(contents->tab_contents(), to_model_index, &data,
362 false);
sky 2011/06/16 15:43:41 nit: align with ( on 361
Emmanuel Saint-loubert-Bié 2011/06/17 00:01:44 Done.
361 tabstrip_->SetTabData(from_model_index, data); 363 tabstrip_->SetTabData(from_model_index, data);
362 364
363 tabstrip_->MoveTab(from_model_index, to_model_index); 365 tabstrip_->MoveTab(from_model_index, to_model_index);
364 } 366 }
365 367
366 void BrowserTabStripController::TabChangedAt(TabContentsWrapper* contents, 368 void BrowserTabStripController::TabChangedAt(TabContentsWrapper* contents,
367 int model_index, 369 int model_index,
368 TabChangeType change_type) { 370 TabChangeType change_type) {
369 if (change_type == TITLE_NOT_LOADING) { 371 if (change_type == TITLE_NOT_LOADING) {
370 tabstrip_->TabTitleChangedNotLoading(model_index); 372 tabstrip_->TabTitleChangedNotLoading(model_index);
(...skipping 26 matching lines...) Expand all
397 void BrowserTabStripController::TabBlockedStateChanged( 399 void BrowserTabStripController::TabBlockedStateChanged(
398 TabContentsWrapper* contents, 400 TabContentsWrapper* contents,
399 int model_index) { 401 int model_index) {
400 SetTabDataAt(contents, model_index); 402 SetTabDataAt(contents, model_index);
401 } 403 }
402 404
403 void BrowserTabStripController::SetTabDataAt( 405 void BrowserTabStripController::SetTabDataAt(
404 TabContentsWrapper* contents, 406 TabContentsWrapper* contents,
405 int model_index) { 407 int model_index) {
406 TabRendererData data; 408 TabRendererData data;
407 SetTabRendererDataFromModel(contents->tab_contents(), model_index, &data); 409 SetTabRendererDataFromModel(contents->tab_contents(), model_index, &data,
410 false);
sky 2011/06/16 15:43:41 nit: align with ( on 409.
408 tabstrip_->SetTabData(model_index, data); 411 tabstrip_->SetTabData(model_index, data);
409 } 412 }
410 413
411 void BrowserTabStripController::SetTabRendererDataFromModel( 414 void BrowserTabStripController::SetTabRendererDataFromModel(
412 TabContents* contents, 415 TabContents* contents,
413 int model_index, 416 int model_index,
414 TabRendererData* data) { 417 TabRendererData* data,
418 bool new_tab_insertion) {
415 SkBitmap* app_icon = NULL; 419 SkBitmap* app_icon = NULL;
416 TabContentsWrapper* wrapper = 420 TabContentsWrapper* wrapper =
417 TabContentsWrapper::GetCurrentWrapperForContents(contents); 421 TabContentsWrapper::GetCurrentWrapperForContents(contents);
418 422
419 // Extension App icons are slightly larger than favicons, so only allow 423 // Extension App icons are slightly larger than favicons, so only allow
420 // them if permitted by the model. 424 // them if permitted by the model.
421 if (model_->delegate()->LargeIconsPermitted()) 425 if (model_->delegate()->LargeIconsPermitted())
422 app_icon = wrapper->extension_tab_helper()->GetExtensionAppIcon(); 426 app_icon = wrapper->extension_tab_helper()->GetExtensionAppIcon();
423 427
424 if (app_icon) 428 if (app_icon)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); 476 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED);
473 // Note that this notification may be fired during a model mutation and 477 // Note that this notification may be fired during a model mutation and
474 // possibly before the tabstrip has processed the change. 478 // possibly before the tabstrip has processed the change.
475 // Here, we just re-layout each existing tab to reflect the change in its 479 // Here, we just re-layout each existing tab to reflect the change in its
476 // closeable state, and then schedule paint for entire tabstrip. 480 // closeable state, and then schedule paint for entire tabstrip.
477 for (int i = 0; i < tabstrip_->tab_count(); ++i) { 481 for (int i = 0; i < tabstrip_->tab_count(); ++i) {
478 tabstrip_->base_tab_at_tab_index(i)->Layout(); 482 tabstrip_->base_tab_at_tab_index(i)->Layout();
479 } 483 }
480 tabstrip_->SchedulePaint(); 484 tabstrip_->SchedulePaint();
481 } 485 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698