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/search/search_delegate.h" | 5 #include "chrome/browser/ui/search/search_delegate.h" |
6 | 6 |
7 #include "chrome/browser/ui/search/search_model.h" | 7 #include "chrome/browser/ui/search/search_model.h" |
8 #include "chrome/browser/ui/search/search_tab_helper.h" | 8 #include "chrome/browser/ui/search/search_tab_helper.h" |
9 #include "chrome/browser/ui/search/toolbar_search_animator.h" | 9 #include "chrome/browser/ui/search/toolbar_search_animator.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
11 | 11 |
12 namespace chrome { | 12 namespace chrome { |
13 namespace search { | 13 namespace search { |
14 | 14 |
15 SearchDelegate::SearchDelegate(SearchModel* browser_model) | 15 SearchDelegate::SearchDelegate(SearchModel* browser_model) |
16 : browser_model_(browser_model), | 16 : browser_model_(browser_model), |
17 tab_model_(NULL), | 17 tab_model_(NULL), |
18 toolbar_search_animator_(browser_model) { | 18 toolbar_search_animator_(browser_model) { |
19 } | 19 } |
20 | 20 |
21 SearchDelegate::~SearchDelegate() { | 21 SearchDelegate::~SearchDelegate() { |
22 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; | 22 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; |
23 } | 23 } |
24 | 24 |
25 void SearchDelegate::ModeChanged(const Mode& mode) { | 25 void SearchDelegate::ModeChanged(const Mode& old_mode, const Mode& new_mode) { |
26 browser_model_->SetMode(mode); | 26 browser_model_->SetMode(new_mode); |
27 } | 27 } |
28 | 28 |
29 void SearchDelegate::OnTabActivated(TabContents* contents) { | 29 void SearchDelegate::OnTabActivated(TabContents* contents) { |
30 if (tab_model_) | 30 if (tab_model_) |
31 tab_model_->RemoveObserver(this); | 31 tab_model_->RemoveObserver(this); |
32 tab_model_ = contents->search_tab_helper()->model(); | 32 tab_model_ = contents->search_tab_helper()->model(); |
33 DCHECK_EQ(tab_model_->tab_contents(), contents); | 33 DCHECK_EQ(tab_model_->tab_contents(), contents); |
34 browser_model_->set_tab_contents(contents); | 34 browser_model_->set_tab_contents(contents); |
35 browser_model_->SetMode(tab_model_->mode()); | 35 browser_model_->SetMode(tab_model_->mode()); |
36 tab_model_->AddObserver(this); | 36 tab_model_->AddObserver(this); |
(...skipping 12 matching lines...) Expand all Loading... |
49 if (contents->search_tab_helper()->model() == tab_model_) { | 49 if (contents->search_tab_helper()->model() == tab_model_) { |
50 tab_model_->RemoveObserver(this); | 50 tab_model_->RemoveObserver(this); |
51 browser_model_->set_tab_contents(NULL); | 51 browser_model_->set_tab_contents(NULL); |
52 tab_model_ = NULL; | 52 tab_model_ = NULL; |
53 toolbar_search_animator_.FinishAnimation(contents); | 53 toolbar_search_animator_.FinishAnimation(contents); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 } // namespace search | 57 } // namespace search |
58 } // namespace chrome | 58 } // namespace chrome |
OLD | NEW |