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

Unified Diff: chrome/browser/ui/search/search_model.h

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_model.h
diff --git a/chrome/browser/ui/search/search_model.h b/chrome/browser/ui/search/search_model.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ec97c13c83b7cb5176f36da9343efd4af3798e5
--- /dev/null
+++ b/chrome/browser/ui/search/search_model.h
@@ -0,0 +1,92 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
+#define CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/observer_list.h"
+#include "chrome/browser/ui/search/search_types.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/rect.h"
+
+class TabContents;
+
+namespace content {
+class WebContents;
+}
+
+namespace chrome {
+namespace search {
+
+// Background color of the NTP.
+extern const SkColor kNTPBackgroundColor;
sky 2012/06/21 18:26:49 These don't really feel like model state. Should w
dhollowa 2012/06/21 22:16:43 Agreed. I've split them off into search_ui.h/cc.
+
+// Color for the separator between results and the page.
+extern const SkColor kResultsSeparatorColor;
+
+// Background color for search results.
+extern const SkColor kSearchBackgroundColor;
+
+// Y-coordinate of the omnibox when over the page.
+extern const int kOmniboxYPosition;
+
+// Initial height of the search results.
+extern const int kSearchResultsHeight;
+
+class SearchModelObserver;
+
+// An observable model for UI components that care about search model state
+// changes.
+class SearchModel {
+ public:
+ explicit SearchModel(TabContents* contents);
+ ~SearchModel();
+
+ // Change the mode. Change notifications are sent to observers. An animated
+ // transition may be requested.
+ void SetMode(const Mode& mode);
+
+ // Get the active mode.
+ const Mode& mode() const { return mode_; }
+
+ // Change the mode to |to_mode| only if |from_mode| is the active mode.
+ void MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode);
+
+ // Add and remove observers.
+ void AddObserver(SearchModelObserver* observer);
+ void RemoveObserver(SearchModelObserver* observer);
+
+ // This can be NULL if this is the browser model and it's accessed during
+ // startup or shutdown.
+ const TabContents* tab_contents() const {
+ return contents_;
+ }
+
+ void set_tab_contents(TabContents* contents) {
+ contents_ = contents;
+ }
+
+ private:
+ // The display mode of UI elements such as the toolbar, the tab strip, etc.
+ Mode mode_;
+
+ // Weak. Used to access current profile to determine incognito status.
+ TabContents* contents_;
+
+ // Observers.
+ ObserverList<SearchModelObserver> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(SearchModel);
+};
+
+// Get location of NTP omnibox in |web_contents_size|. A height of 0 is
+// returned, it is platform-specific.
+gfx::Rect GetNTPOmniboxBounds(const gfx::Size& web_contents_size);
+
+} // namespace search
+} // namespace chrome
+
+#endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_

Powered by Google App Engine
This is Rietveld 408576698