Chromium Code Reviews| 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 | 9 |
| 10 namespace chrome { | 10 namespace chrome { |
| 11 namespace search { | 11 namespace search { |
| 12 | 12 |
| 13 SearchDelegate::SearchDelegate(SearchModel* browser_search_model, | 13 SearchDelegate::SearchDelegate(SearchModel* browser_search_model, |
| 14 ToolbarModel* toolbar_model) | 14 ToolbarModel* toolbar_model) |
| 15 : browser_model_(browser_search_model), | 15 : browser_model_(browser_search_model), |
| 16 tab_model_() { | 16 tab_model_() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 SearchDelegate::~SearchDelegate() { | 19 SearchDelegate::~SearchDelegate() { |
| 20 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; | 20 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; |
| 21 } | 21 } |
| 22 | 22 |
| 23 void SearchDelegate::ModeChanged(const Mode& old_mode, const Mode& new_mode) { | 23 void SearchDelegate::ModelChanged(const Mode& old_mode, const Mode& new_mode, |
| 24 bool top_bars_visible) { | |
| 24 browser_model_->SetMode(new_mode); | 25 browser_model_->SetMode(new_mode); |
| 26 browser_model_->SetTopBarsVisible(top_bars_visible); | |
|
dhollowa
2013/03/13 17:21:55
This is a potential problem (having two model-chan
kuan
2013/03/13 22:21:07
Done.
| |
| 25 } | 27 } |
| 26 | 28 |
| 27 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) { | 29 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) { |
| 28 if (tab_model_) | 30 if (tab_model_) |
| 29 tab_model_->RemoveObserver(this); | 31 tab_model_->RemoveObserver(this); |
| 30 tab_model_ = | 32 tab_model_ = |
| 31 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model(); | 33 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model(); |
| 32 browser_model_->SetMode(tab_model_->mode()); | 34 browser_model_->SetMode(tab_model_->mode()); |
| 35 browser_model_->SetTopBarsVisible(tab_model_->top_bars_visible()); | |
|
dhollowa
2013/03/13 17:21:55
Ditto.
kuan
2013/03/13 22:21:07
Done.
| |
| 33 tab_model_->AddObserver(this); | 36 tab_model_->AddObserver(this); |
| 34 } | 37 } |
| 35 | 38 |
| 36 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) { | 39 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) { |
| 37 StopObservingTab(web_contents); | 40 StopObservingTab(web_contents); |
| 38 } | 41 } |
| 39 | 42 |
| 40 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) { | 43 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) { |
| 41 StopObservingTab(web_contents); | 44 StopObservingTab(web_contents); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) { | 47 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) { |
| 45 chrome::search::SearchTabHelper* search_tab_helper = | 48 chrome::search::SearchTabHelper* search_tab_helper = |
| 46 chrome::search::SearchTabHelper::FromWebContents(web_contents); | 49 chrome::search::SearchTabHelper::FromWebContents(web_contents); |
| 47 if (search_tab_helper->model() == tab_model_) { | 50 if (search_tab_helper->model() == tab_model_) { |
| 48 tab_model_->RemoveObserver(this); | 51 tab_model_->RemoveObserver(this); |
| 49 tab_model_ = NULL; | 52 tab_model_ = NULL; |
| 50 } | 53 } |
| 51 } | 54 } |
| 52 | 55 |
| 53 } // namespace search | 56 } // namespace search |
| 54 } // namespace chrome | 57 } // namespace chrome |
| OLD | NEW |