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

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: Header 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
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..6a6dd973e12d840bc5cf1a01adab1664082c4f12
--- /dev/null
+++ b/chrome/browser/ui/search/search_delegate.cc
@@ -0,0 +1,59 @@
+// 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(tab_model_->tab_contents() == contents);
sky 2012/06/21 18:26:49 DCHECK_EQ
dhollowa 2012/06/21 22:16:43 Done.
+ browser_model_->set_tab_contents(contents);
+ browser_model_->SetMode(tab_model_->mode());
+ tab_model_->AddObserver(this);
+}
+
+void SearchDelegate::OnTabClosing(TabContents* contents) {
+ StopObserveringTab(contents);
+}
+
+void SearchDelegate::OnTabDeactivated(TabContents* contents) {
+ StopObserveringTab(contents);
+}
+
+void SearchDelegate::OnTabDettached(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

Powered by Google App Engine
This is Rietveld 408576698