| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/observer_list.h" |
| 11 #include "chrome/browser/ui/search/search_types.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "ui/gfx/rect.h" |
| 14 |
| 15 class TabContents; |
| 16 |
| 17 namespace content { |
| 18 class WebContents; |
| 19 } |
| 20 |
| 21 namespace chrome { |
| 22 namespace search { |
| 23 |
| 24 // Background color of the NTP. |
| 25 extern const SkColor kNTPBackgroundColor; |
| 26 |
| 27 // Color for the separator between results and the page. |
| 28 extern const SkColor kResultsSeparatorColor; |
| 29 |
| 30 // Background color for search results. |
| 31 extern const SkColor kSearchBackgroundColor; |
| 32 |
| 33 // Y-coordinate of the omnibox when over the page. |
| 34 extern const int kOmniboxYPosition; |
| 35 |
| 36 // Initial height of the search results. |
| 37 extern const int kSearchResultsHeight; |
| 38 |
| 39 class SearchModelObserver; |
| 40 |
| 41 // An observable model for UI components that care about search model state |
| 42 // changes. |
| 43 class SearchModel { |
| 44 public: |
| 45 explicit SearchModel(TabContents* contents); |
| 46 ~SearchModel(); |
| 47 |
| 48 // Change the mode. Change notifications are sent to observers. An animated |
| 49 // transition may be requested. |
| 50 void SetMode(const Mode& mode); |
| 51 |
| 52 // Get the active mode. |
| 53 const Mode& mode() const { return mode_; } |
| 54 |
| 55 // Change the mode to |to_mode| only if |from_mode| is the active mode. |
| 56 void MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode); |
| 57 |
| 58 // Add and remove observers. |
| 59 void AddObserver(SearchModelObserver* observer); |
| 60 void RemoveObserver(SearchModelObserver* observer); |
| 61 |
| 62 // This can be NULL if this is the browser model and it's accessed during |
| 63 // startup or shutdown. |
| 64 const TabContents* tab_contents() const { |
| 65 return contents_; |
| 66 } |
| 67 |
| 68 void set_tab_contents(TabContents* contents) { |
| 69 contents_ = contents; |
| 70 } |
| 71 |
| 72 private: |
| 73 // The display mode of UI elements such as the toolbar, the tab strip, etc. |
| 74 Mode mode_; |
| 75 |
| 76 // Weak. Used to access current profile to determine incognito status. |
| 77 TabContents* contents_; |
| 78 |
| 79 // Observers. |
| 80 ObserverList<SearchModelObserver> observers_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(SearchModel); |
| 83 }; |
| 84 |
| 85 // Get location of NTP omnibox in |web_contents_size|. A height of 0 is |
| 86 // returned, it is platform-specific. |
| 87 gfx::Rect GetNTPOmniboxBounds(const gfx::Size& web_contents_size); |
| 88 |
| 89 } // namespace search |
| 90 } // namespace chrome |
| 91 |
| 92 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_MODEL_H_ |
| OLD | NEW |