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

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

Issue 2885853002: Instant: remove InstantSupportState (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/search/search_delegate.h ('k') | chrome/browser/ui/search/search_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 SearchDelegate::SearchDelegate(SearchModel* browser_search_model) 10 SearchDelegate::SearchDelegate(SearchModel* browser_search_model)
11 : browser_model_(browser_search_model), 11 : browser_model_(browser_search_model), tab_model_(nullptr) {}
12 tab_model_() {
13 }
14 12
15 SearchDelegate::~SearchDelegate() { 13 SearchDelegate::~SearchDelegate() {
16 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed."; 14 DCHECK(!tab_model_) << "All tabs should have been deactivated or closed.";
17 } 15 }
18 16
19 void SearchDelegate::ModelChanged(const SearchModel::State& old_state, 17 void SearchDelegate::ModelChanged(const SearchMode& old_mode,
20 const SearchModel::State& new_state) { 18 const SearchMode& new_mode) {
21 browser_model_->SetState(new_state); 19 browser_model_->SetMode(new_mode);
22 } 20 }
23 21
24 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) { 22 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) {
25 if (tab_model_) 23 if (tab_model_)
26 tab_model_->RemoveObserver(this); 24 tab_model_->RemoveObserver(this);
27 tab_model_ = SearchTabHelper::FromWebContents(web_contents)->model(); 25 tab_model_ = SearchTabHelper::FromWebContents(web_contents)->model();
28 browser_model_->SetState(tab_model_->state()); 26 browser_model_->SetMode(tab_model_->mode());
29 tab_model_->AddObserver(this); 27 tab_model_->AddObserver(this);
30 } 28 }
31 29
32 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) { 30 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) {
33 StopObservingTab(web_contents); 31 StopObservingTab(web_contents);
34 } 32 }
35 33
36 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) { 34 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) {
37 StopObservingTab(web_contents); 35 StopObservingTab(web_contents);
38 } 36 }
39 37
40 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) { 38 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) {
41 SearchTabHelper* search_tab_helper = 39 SearchTabHelper* search_tab_helper =
42 SearchTabHelper::FromWebContents(web_contents); 40 SearchTabHelper::FromWebContents(web_contents);
43 if (search_tab_helper->model() == tab_model_) { 41 if (search_tab_helper->model() == tab_model_) {
44 tab_model_->RemoveObserver(this); 42 tab_model_->RemoveObserver(this);
45 tab_model_ = NULL; 43 tab_model_ = NULL;
46 } 44 }
47 } 45 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_delegate.h ('k') | chrome/browser/ui/search/search_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698