Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/search/search_delegate.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/search/search_model.h" | |
| 8 #include "chrome/browser/ui/search/search_tab_helper.h" | |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 10 | |
| 11 namespace chrome { | |
| 12 namespace search { | |
| 13 | |
| 14 SearchDelegate::SearchDelegate(SearchModel* browser_model) | |
| 15 : browser_model_(browser_model), | |
| 16 tab_model_(NULL) { | |
| 17 } | |
| 18 | |
| 19 SearchDelegate::~SearchDelegate() { | |
| 20 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; | |
| 21 } | |
| 22 | |
| 23 void SearchDelegate::ModeChanged(const Mode& mode) { | |
| 24 browser_model_->SetMode(mode); | |
| 25 } | |
| 26 | |
| 27 void SearchDelegate::OnTabActivated(TabContents* contents) { | |
| 28 if (tab_model_) | |
| 29 tab_model_->RemoveObserver(this); | |
| 30 tab_model_ = contents->search_tab_helper()->model(); | |
| 31 DCHECK(tab_model_->tab_contents() == contents); | |
|
sky
2012/06/21 18:26:49
DCHECK_EQ
dhollowa
2012/06/21 22:16:43
Done.
| |
| 32 browser_model_->set_tab_contents(contents); | |
| 33 browser_model_->SetMode(tab_model_->mode()); | |
| 34 tab_model_->AddObserver(this); | |
| 35 } | |
| 36 | |
| 37 void SearchDelegate::OnTabClosing(TabContents* contents) { | |
| 38 StopObserveringTab(contents); | |
| 39 } | |
| 40 | |
| 41 void SearchDelegate::OnTabDeactivated(TabContents* contents) { | |
| 42 StopObserveringTab(contents); | |
| 43 } | |
| 44 | |
| 45 void SearchDelegate::OnTabDettached(TabContents* contents) { | |
| 46 StopObserveringTab(contents); | |
| 47 } | |
| 48 | |
| 49 void SearchDelegate::StopObserveringTab( | |
| 50 TabContents* contents) { | |
| 51 if (contents->search_tab_helper()->model() == tab_model_) { | |
| 52 tab_model_->RemoveObserver(this); | |
| 53 browser_model_->set_tab_contents(NULL); | |
| 54 tab_model_ = NULL; | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 } // namespace search | |
| 59 } // namespace chrome | |
| OLD | NEW |