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

Unified Diff: chrome/browser/ui/search/search_delegate.cc

Issue 10644002: Add core plumbing for Instant Extended work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address pkasting, tfarina, and remaining nits. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/search_delegate.h ('k') | chrome/browser/ui/search/search_delegate_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_delegate.cc
diff --git a/chrome/browser/ui/search/search_delegate.cc b/chrome/browser/ui/search/search_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9af5648e24f2935c65407b44aef070c7b988c5e4
--- /dev/null
+++ b/chrome/browser/ui/search/search_delegate.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/search/search_delegate.h"
+
+#include "chrome/browser/ui/search/search_model.h"
+#include "chrome/browser/ui/search/search_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+
+namespace chrome {
+namespace search {
+
+SearchDelegate::SearchDelegate(SearchModel* browser_model)
+ : browser_model_(browser_model),
+ tab_model_(NULL) {
+}
+
+SearchDelegate::~SearchDelegate() {
+ DCHECK(!tab_model_) << "All tabs should have been deactivated or closed.";
+}
+
+void SearchDelegate::ModeChanged(const Mode& mode) {
+ browser_model_->SetMode(mode);
+}
+
+void SearchDelegate::OnTabActivated(TabContents* contents) {
+ if (tab_model_)
+ tab_model_->RemoveObserver(this);
+ tab_model_ = contents->search_tab_helper()->model();
+ DCHECK_EQ(tab_model_->tab_contents(), contents);
+ browser_model_->set_tab_contents(contents);
+ browser_model_->SetMode(tab_model_->mode());
+ tab_model_->AddObserver(this);
+}
+
+void SearchDelegate::OnTabDeactivated(TabContents* contents) {
+ StopObserveringTab(contents);
+}
+
+void SearchDelegate::OnTabDetached(TabContents* contents) {
+ StopObserveringTab(contents);
+}
+
+void SearchDelegate::StopObserveringTab(
+ TabContents* contents) {
+ if (contents->search_tab_helper()->model() == tab_model_) {
+ tab_model_->RemoveObserver(this);
+ browser_model_->set_tab_contents(NULL);
+ tab_model_ = NULL;
+ }
+}
+
+} // namespace search
+} // namespace chrome
« no previous file with comments | « chrome/browser/ui/search/search_delegate.h ('k') | chrome/browser/ui/search/search_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698