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 30 matching lines...) Expand all Loading... |
516 data->title = contents->GetTitle(); | 518 data->title = contents->GetTitle(); |
517 data->url = contents->GetURL(); | 519 data->url = contents->GetURL(); |
518 data->loading = contents->IsLoading(); | 520 data->loading = contents->IsLoading(); |
519 data->crashed_status = contents->GetCrashedStatus(); | 521 data->crashed_status = contents->GetCrashedStatus(); |
520 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); | 522 data->incognito = contents->GetBrowserContext()->IsOffTheRecord(); |
521 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); | 523 data->show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); |
522 data->mini = model_->IsMiniTab(model_index); | 524 data->mini = model_->IsMiniTab(model_index); |
523 data->blocked = model_->IsTabBlocked(model_index); | 525 data->blocked = model_->IsTabBlocked(model_index); |
524 data->app = tab_contents->extension_tab_helper()->is_app(); | 526 data->app = tab_contents->extension_tab_helper()->is_app(); |
525 data->mode = browser_->search_model()->mode().mode; | 527 data->mode = browser_->search_model()->mode().mode; |
526 if (data->mode == chrome::search::Mode::MODE_SEARCH) { | 528 // Get current gradient background animation to paint. |
527 // Get current state of background animation to paint for SEARCH mode. | 529 data->gradient_background_opacity = browser_->search_delegate()-> |
528 browser_->search_delegate()->toolbar_search_animator(). | 530 toolbar_search_animator().GetGradientOpacity(); |
529 GetCurrentBackgroundState(&data->background_state, | |
530 &data->search_background_opacity); | |
531 } else { | |
532 data->background_state = | |
533 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_DEFAULT; | |
534 // Valid opacity value of double data type is 0f to 1f, so use -1f to | |
535 // indicate an invalid value. | |
536 data->search_background_opacity = -1.0f; | |
537 } | |
538 } | 531 } |
539 | 532 |
540 void BrowserTabStripController::SetTabDataAt( | 533 void BrowserTabStripController::SetTabDataAt( |
541 TabContents* contents, | 534 TabContents* contents, |
542 int model_index) { | 535 int model_index) { |
543 TabRendererData data; | 536 TabRendererData data; |
544 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, | 537 SetTabRendererDataFromModel(contents->web_contents(), model_index, &data, |
545 EXISTING_TAB); | 538 EXISTING_TAB); |
546 tabstrip_->SetTabData(model_index, data); | 539 tabstrip_->SetTabData(model_index, data); |
547 } | 540 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); | 576 SetTabRendererDataFromModel(contents->web_contents(), index, &data, NEW_TAB); |
584 tabstrip_->AddTabAt(index, data, is_active); | 577 tabstrip_->AddTabAt(index, data, is_active); |
585 } | 578 } |
586 | 579 |
587 void BrowserTabStripController::UpdateLayoutType() { | 580 void BrowserTabStripController::UpdateLayoutType() { |
588 bool adjust_layout = false; | 581 bool adjust_layout = false; |
589 TabStripLayoutType layout_type = | 582 TabStripLayoutType layout_type = |
590 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); | 583 DetermineTabStripLayout(g_browser_process->local_state(), &adjust_layout); |
591 tabstrip_->SetLayoutType(layout_type, adjust_layout); | 584 tabstrip_->SetLayoutType(layout_type, adjust_layout); |
592 } | 585 } |
OLD | NEW |