Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/ui/search/search_model.cc

Issue 10944016: Switch SearchTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_model.h" 5 #include "chrome/browser/ui/search/search_model.h"
6 6
7 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/ui/search/search.h" 8 #include "chrome/browser/ui/search/search.h"
8 #include "chrome/browser/ui/search/search_model_observer.h" 9 #include "chrome/browser/ui/search/search_model_observer.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "content/public/browser/web_contents.h"
10 11
11 namespace chrome { 12 namespace chrome {
12 namespace search { 13 namespace search {
13 14
14 SearchModel::SearchModel(TabContents* contents) 15 SearchModel::SearchModel(content::WebContents* web_contents)
15 : contents_(contents) { 16 : web_contents_(web_contents) {
16 } 17 }
17 18
18 SearchModel::~SearchModel() { 19 SearchModel::~SearchModel() {
19 } 20 }
20 21
21 void SearchModel::SetMode(const Mode& new_mode) { 22 void SearchModel::SetMode(const Mode& new_mode) {
22 if (!contents_) 23 if (!web_contents_)
23 return; 24 return;
24 25
25 DCHECK(IsInstantExtendedAPIEnabled(contents_->profile())) 26 Profile* profile =
27 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
28 DCHECK(IsInstantExtendedAPIEnabled(profile))
26 << "Please do not try to set the SearchModel mode without first " 29 << "Please do not try to set the SearchModel mode without first "
27 << "checking if Search is enabled."; 30 << "checking if Search is enabled.";
28 31
29 if (mode_ == new_mode) 32 if (mode_ == new_mode)
30 return; 33 return;
31 34
32 const Mode old_mode = mode_; 35 const Mode old_mode = mode_;
33 mode_ = new_mode; 36 mode_ = new_mode;
34 37
35 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 38 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
36 ModeChanged(old_mode, mode_)); 39 ModeChanged(old_mode, mode_));
37 40
38 // Animation is transient, it is cleared after observers are notified. 41 // Animation is transient, it is cleared after observers are notified.
39 mode_.animate = false; 42 mode_.animate = false;
40 } 43 }
41 44
42 void SearchModel::AddObserver(SearchModelObserver* observer) { 45 void SearchModel::AddObserver(SearchModelObserver* observer) {
43 observers_.AddObserver(observer); 46 observers_.AddObserver(observer);
44 } 47 }
45 48
46 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 49 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
47 observers_.RemoveObserver(observer); 50 observers_.RemoveObserver(observer);
48 } 51 }
49 52
50 } // namespace search 53 } // namespace search
51 } // namespace chrome 54 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698