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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 464 } |
465 | 465 |
466 void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled( | 466 void BrowserTabStripController::OnToolbarBackgroundAnimatorCanceled( |
467 TabContents* tab_contents) { | 467 TabContents* tab_contents) { |
468 // Fade in of tab background has been canceled, which can happen in 2 | 468 // Fade in of tab background has been canceled, which can happen in 2 |
469 // scenarios: | 469 // scenarios: |
470 // 1) a deactivated or detached or closing tab, whose |tab_contents| is the | 470 // 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. | 471 // 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 | 472 // 2) mode change of active tab, as indicated by a NULL |tab_contents|: make |
473 // sure active tab exists, and retrieve its |tab_contents|. | 473 // sure active tab exists, and retrieve its |tab_contents|. |
474 // If we proceed, set tab data so that |TabRendererData::background_state| and | 474 // If we proceed, set tab data so that |
475 // |TabRendererData::search_background_opacity| will be reset. | 475 // |TabRendererData::gradient_background_opacity| will be reset. |
476 // Repainting of tab's background will be triggered in the process. | 476 // Repainting of tab's background will be triggered in the process. |
477 int index = tab_contents ? model_->GetIndexOfTabContents(tab_contents) : | 477 int index = tab_contents ? model_->GetIndexOfTabContents(tab_contents) : |
478 GetActiveIndex(); | 478 GetActiveIndex(); |
479 if (index == -1) | 479 if (index == -1) |
480 return; | 480 return; |
481 SetTabDataAt(tab_contents ? tab_contents : | 481 SetTabDataAt(tab_contents ? tab_contents : |
482 chrome::GetTabContentsAt(browser_, index), index); | 482 chrome::GetTabContentsAt(browser_, index), index); |
483 } | 483 } |
484 | 484 |
485 //////////////////////////////////////////////////////////////////////////////// | 485 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 data->title = contents->GetTitle(); | 518 data->title = contents->GetTitle(); |
519 data->url = contents->GetURL(); | 519 data->url = contents->GetURL(); |
520 data->loading = contents->IsLoading(); | 520 data->loading = contents->IsLoading(); |
521 data->crashed_status = contents->GetCrashedStatus(); | 521 data->crashed_status = contents->GetCrashedStatus(); |
522 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 522 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
523 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); | 523 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); |
524 data->mini = model_->IsMiniTab(model_index); | 524 data->mini = model_->IsMiniTab(model_index); |
525 data->blocked = model_->IsTabBlocked(model_index); | 525 data->blocked = model_->IsTabBlocked(model_index); |
526 data->app = tab_contents->extension_tab_helper()->is_app(); | 526 data->app = tab_contents->extension_tab_helper()->is_app(); |
527 data->mode = browser_->search_model()->mode().mode; | 527 data->mode = browser_->search_model()->mode().mode; |
528 if (data->mode == chrome::search::Mode::MODE_SEARCH) { | 528 // Get current gradient background animation to paint. |
529 // Get current state of background animation to paint for SEARCH mode. | 529 data->gradient_background_opacity = browser_->search_delegate()-> |
530 browser_->search_delegate()->toolbar_search_animator(). | 530 toolbar_search_animator().GetGradientOpacity(); |
531 GetCurrentBackgroundState(&data->background_state, | |
532 &data->search_background_opacity); | |
533 } else { | |
534 data->background_state = | |
535 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; | |
536 // Valid opacity value of double data type is 0f to 1f, so use -1f to | |
537 // indicate an invalid value. | |
538 data->search_background_opacity = -1.0f; | |
539 } | |
540 } | 531 } |
541 | 532 |
542 void BrowserTabStripController::SetTabDataAt( | 533 void BrowserTabStripController::SetTabDataAt( |
543 TabContents* contents, | 534 TabContents* contents, |
544 int model_index) { | 535 int model_index) { |
545 TabRendererData data; | 536 TabRendererData data; |
546 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, | 537 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, |
547 EXISTING_TAB); | 538 EXISTING_TAB); |
548 tabstrip_->SetTabData(model_index, data); | 539 tabstrip_->SetTabData(model_index, data); |
549 } | 540 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); | 576 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); |
586 tabstrip_->AddTabAt(index, data, is_active); | 577 tabstrip_->AddTabAt(index, data, is_active); |
587 } | 578 } |
588 | 579 |
589 void BrowserTabStripController::UpdateLayoutType() { | 580 void BrowserTabStripController::UpdateLayoutType() { |
590 bool adjust_layout = false; | 581 bool adjust_layout = false; |
591 TabStripLayoutType layout_type = | 582 TabStripLayoutType layout_type = |
592 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 583 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); |
593 tabstrip_->SetLayoutType(layout_type, adjust_layout); | 584 tabstrip_->SetLayoutType(layout_type, adjust_layout); |
594 } | 585 } |
OLD | NEW |