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_model.h" | |
| 6 | |
| 7 #include "chrome/browser/google/google_util.h" | |
|
tfarina
2012/06/21 22:49:55
do you need this, url_constants.h and web_contents
dhollowa
2012/06/21 23:53:42
Done.
| |
| 8 #include "chrome/browser/ui/search/search.h" | |
| 9 #include "chrome/browser/ui/search/search_model_observer.h" | |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 11 #include "chrome/common/url_constants.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 | |
| 14 namespace chrome { | |
| 15 namespace search { | |
| 16 | |
| 17 SearchModel::SearchModel(TabContents* contents) | |
| 18 : contents_(contents) { | |
| 19 } | |
| 20 | |
| 21 SearchModel::~SearchModel() { | |
| 22 } | |
| 23 | |
| 24 void SearchModel::SetMode(const Mode& mode) { | |
| 25 if (contents_ == NULL) | |
|
tfarina
2012/06/21 22:49:55
nit: if (!contents_)
return;
dhollowa
2012/06/21 23:53:42
Done.
| |
| 26 return; | |
| 27 | |
| 28 DCHECK(IsInstantExtendedAPIEnabled(contents_->profile())) | |
| 29 << "Please do not try to set the SearchModel mode without first " | |
| 30 << "checking if Search is enabled."; | |
| 31 | |
| 32 if (mode_ == mode) | |
| 33 return; | |
| 34 | |
| 35 mode_ = mode; | |
| 36 | |
| 37 FOR_EACH_OBSERVER(SearchModelObserver, observers_, ModeChanged(mode_)); | |
| 38 | |
| 39 // Animation is transient, it is cleared after observers are notified. | |
| 40 mode_.animate = false; | |
| 41 } | |
| 42 | |
| 43 void SearchModel::MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode) { | |
| 44 if (mode_.mode == from_mode) { | |
| 45 Mode mode(to_mode, true); | |
| 46 SetMode(mode); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 void SearchModel::AddObserver(SearchModelObserver* observer) { | |
| 51 observers_.AddObserver(observer); | |
| 52 } | |
| 53 | |
| 54 void SearchModel::RemoveObserver(SearchModelObserver* observer) { | |
| 55 observers_.RemoveObserver(observer); | |
| 56 } | |
| 57 | |
| 58 } // namespace search | |
| 59 } // namespace chrome | |
| OLD | NEW |