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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 7 years, 11 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
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 namespace chrome { 10 namespace chrome {
(...skipping 13 matching lines...) Expand all
24 browser_model_->SetMode(new_mode); 24 browser_model_->SetMode(new_mode);
25 } 25 }
26 26
27 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) { 27 void SearchDelegate::OnTabActivated(content::WebContents* web_contents) {
28 if (tab_model_) 28 if (tab_model_)
29 tab_model_->RemoveObserver(this); 29 tab_model_->RemoveObserver(this);
30 tab_model_ = 30 tab_model_ =
31 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model(); 31 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model();
32 DCHECK_EQ(tab_model_->web_contents(), web_contents); 32 DCHECK_EQ(tab_model_->web_contents(), web_contents);
33 browser_model_->set_web_contents(web_contents); 33 browser_model_->set_web_contents(web_contents);
34 // TODO: ok that this gets called with mode DEFAULT when new tab is created?
34 browser_model_->SetMode(tab_model_->mode()); 35 browser_model_->SetMode(tab_model_->mode());
35 tab_model_->AddObserver(this); 36 tab_model_->AddObserver(this);
36 } 37 }
37 38
38 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) { 39 void SearchDelegate::OnTabDeactivated(content::WebContents* web_contents) {
39 StopObservingTab(web_contents); 40 StopObservingTab(web_contents);
40 } 41 }
41 42
42 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) { 43 void SearchDelegate::OnTabDetached(content::WebContents* web_contents) {
43 StopObservingTab(web_contents); 44 StopObservingTab(web_contents);
44 } 45 }
45 46
46 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) { 47 void SearchDelegate::StopObservingTab(content::WebContents* web_contents) {
47 chrome::search::SearchTabHelper* search_tab_helper = 48 chrome::search::SearchTabHelper* search_tab_helper =
48 chrome::search::SearchTabHelper::FromWebContents(web_contents); 49 chrome::search::SearchTabHelper::FromWebContents(web_contents);
49 if (search_tab_helper->model() == tab_model_) { 50 if (search_tab_helper->model() == tab_model_) {
50 tab_model_->RemoveObserver(this); 51 tab_model_->RemoveObserver(this);
51 browser_model_->set_web_contents(NULL); 52 browser_model_->set_web_contents(NULL);
52 tab_model_ = NULL; 53 tab_model_ = NULL;
53 } 54 }
54 } 55 }
55 56
56 } // namespace search 57 } // namespace search
57 } // namespace chrome 58 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698