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/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 void BrowserTabStripController::TabBlockedStateChanged( | 437 void BrowserTabStripController::TabBlockedStateChanged( |
438 TabContents* contents, | 438 TabContents* contents, |
439 int model_index) { | 439 int model_index) { |
440 SetTabDataAt(contents, model_index); | 440 SetTabDataAt(contents, model_index); |
441 } | 441 } |
442 | 442 |
443 //////////////////////////////////////////////////////////////////////////////// | 443 //////////////////////////////////////////////////////////////////////////////// |
444 // BrowserTabStripController, chrome::search::SearchModelObserver: | 444 // BrowserTabStripController, chrome::search::SearchModelObserver: |
445 | 445 |
446 void BrowserTabStripController::ModeChanged(const chrome::search::Mode& mode) { | 446 void BrowserTabStripController::ModeChanged( |
| 447 const chrome::search::Mode& old_mode, |
| 448 const chrome::search::Mode& new_mode) { |
447 // Mode has changed, set tab data based on new mode, which will trigger | 449 // Mode has changed, set tab data based on new mode, which will trigger |
448 // repainting of tab's background. | 450 // repainting of tab's background. |
449 int active_index = GetActiveIndex(); | 451 int active_index = GetActiveIndex(); |
450 DCHECK_NE(active_index, -1); | 452 DCHECK_NE(active_index, -1); |
451 SetTabDataAt(chrome::GetTabContentsAt(browser_, active_index), active_index); | 453 SetTabDataAt(chrome::GetTabContentsAt(browser_, active_index), active_index); |
452 } | 454 } |
453 | 455 |
454 //////////////////////////////////////////////////////////////////////////////// | 456 //////////////////////////////////////////////////////////////////////////////// |
455 // BrowserTabStripController, chrome::search::ToolbarSearchAnimator::Observer: | 457 // BrowserTabStripController, chrome::search::ToolbarSearchAnimator::Observer: |
456 | 458 |
457 void BrowserTabStripController::OnToolbarBackgroundAnimatorProgressed() { | 459 void BrowserTabStripController::OnToolbarBackgroundAnimatorProgressed() { |
458 // We're fading in the tab background, set tab data based on new background | 460 // We're fading in the tab background, set tab data based on new background |
459 // state and possibly opacity value, which will trigger repainting of tab's | 461 // state and possibly opacity value, which will trigger repainting of tab's |
460 // background. | 462 // background. |
461 int active_index = GetActiveIndex(); | 463 int active_index = GetActiveIndex(); |
462 DCHECK_NE(active_index, -1); | 464 DCHECK_NE(active_index, -1); |
463 SetTabDataAt(chrome::GetTabContentsAt(browser_, active_index), active_index); | 465 SetTabDataAt(chrome::GetTabContentsAt(browser_, active_index), active_index); |
464 } | 466 } |
465 | 467 |
466 void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled( | 468 void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled( |
467 TabContents* tab_contents) { | 469 TabContents* tab_contents) { |
468 // Fade in of tab background has been canceled, which can happen in 2 | 470 // Fade in of tab background has been canceled, which can happen in 2 |
469 // scenarios: | 471 // scenarios: |
470 // 1) a deactivated or detached or closing tab, whose |tab_contents| is the | 472 // 1) a deactivated or detached or closing tab, whose |tab_contents| is the |
471 // the formal parameter: make sure |tab_contents| still exist in tab model. | 473 // the formal parameter: make sure |tab_contents| still exist in tab model. |
472 // 2) mode change of active tab, as indicated by a NULL |tab_contents|: make | 474 // 2) mode change of active tab, as indicated by a NULL |tab_contents|: make |
473 // sure active tab exists, and retrieve its |tab_contents|. | 475 // sure active tab exists, and retrieve its |tab_contents|. |
474 // If we proceed, set tab data so that |TabRendererData::background_state| and | 476 // If we proceed, set tab data so that |
475 // |TabRendererData::search_background_opacity| will be reset. | 477 // |TabRendererData::gradient_background_opacity| will be reset. |
476 // Repainting of tab's background will be triggered in the process. | 478 // Repainting of tab's background will be triggered in the process. |
477 int index = tab_contents ? model_->GetIndexOfTabContents(tab_contents) : | 479 int index = tab_contents ? model_->GetIndexOfTabContents(tab_contents) : |
478 GetActiveIndex(); | 480 GetActiveIndex(); |
479 if (index == -1) | 481 if (index == -1) |
480 return; | 482 return; |
481 SetTabDataAt(tab_contents ? tab_contents : | 483 SetTabDataAt(tab_contents ? tab_contents : |
482 chrome::GetTabContentsAt(browser_, index), index); | 484 chrome::GetTabContentsAt(browser_, index), index); |
483 } | 485 } |
484 | 486 |
485 //////////////////////////////////////////////////////////////////////////////// | 487 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 28 matching lines...) Expand all Loading... |
514 data->title = contents->GetTitle(); | 516 data->title = contents->GetTitle(); |
515 data->url = contents->GetURL(); | 517 data->url = contents->GetURL(); |
516 data->loading = contents->IsLoading(); | 518 data->loading = contents->IsLoading(); |
517 data->crashed_status = contents->GetCrashedStatus(); | 519 data->crashed_status = contents->GetCrashedStatus(); |
518 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 520 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
519 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); | 521 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); |
520 data->mini = model_->IsMiniTab(model_index); | 522 data->mini = model_->IsMiniTab(model_index); |
521 data->blocked = model_->IsTabBlocked(model_index); | 523 data->blocked = model_->IsTabBlocked(model_index); |
522 data->app = tab_contents->extension_tab_helper()->is_app(); | 524 data->app = tab_contents->extension_tab_helper()->is_app(); |
523 data->mode = browser_->search_model()->mode().mode; | 525 data->mode = browser_->search_model()->mode().mode; |
524 if (data->mode == chrome::search::Mode::MODE_SEARCH) { | 526 // Get current gradient background animation to paint. |
525 // Get current state of background animation to paint for SEARCH mode. | 527 data->gradient_background_opacity = browser_->search_delegate()-> |
526 browser_->search_delegate()->toolbar_search_animator(). | 528 toolbar_search_animator().GetGradientOpacity(); |
527 GetCurrentBackgroundState(&data->background_state, | |
528 &data->search_background_opacity); | |
529 } else { | |
530 data->background_state = | |
531 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; | |
532 // Valid opacity value of double data type is 0f to 1f, so use -1f to | |
533 // indicate an invalid value. | |
534 data->search_background_opacity = -1.0f; | |
535 } | |
536 } | 529 } |
537 | 530 |
538 void BrowserTabStripController::SetTabDataAt( | 531 void BrowserTabStripController::SetTabDataAt( |
539 TabContents* contents, | 532 TabContents* contents, |
540 int model_index) { | 533 int model_index) { |
541 TabRendererData data; | 534 TabRendererData data; |
542 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, | 535 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, |
543 EXISTING_TAB); | 536 EXISTING_TAB); |
544 tabstrip_->SetTabData(model_index, data); | 537 tabstrip_->SetTabData(model_index, data); |
545 } | 538 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); | 574 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); |
582 tabstrip_->AddTabAt(index, data, is_active); | 575 tabstrip_->AddTabAt(index, data, is_active); |
583 } | 576 } |
584 | 577 |
585 void BrowserTabStripController::UpdateLayoutType() { | 578 void BrowserTabStripController::UpdateLayoutType() { |
586 bool adjust_layout = false; | 579 bool adjust_layout = false; |
587 TabStripLayoutType layout_type = | 580 TabStripLayoutType layout_type = |
588 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 581 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); |
589 tabstrip_->SetLayoutType(layout_type, adjust_layout); | 582 tabstrip_->SetLayoutType(layout_type, adjust_layout); |
590 } | 583 } |
OLD | NEW |