OLD | NEW |
| (Empty) |
1 // Copyright 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_INSTANT_OVERLAY_MODEL_H_ | |
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_MODEL_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/observer_list.h" | |
10 #include "chrome/common/instant_types.h" | |
11 #include "chrome/common/search_types.h" | |
12 | |
13 class InstantController; | |
14 class InstantOverlayModelObserver; | |
15 | |
16 namespace content { | |
17 class WebContents; | |
18 } | |
19 | |
20 // Holds state that is important to any views concerned with visibility and | |
21 // layout of the Instant overlay. | |
22 class InstantOverlayModel { | |
23 public: | |
24 explicit InstantOverlayModel(InstantController* controller); | |
25 ~InstantOverlayModel(); | |
26 | |
27 // InstantOverlayModel only uses Mode::mode internally. Other parts of Mode, | |
28 // such as Mode::origin, may have arbitrary values, and should be ignored. | |
29 const SearchMode& mode() const { return mode_; } | |
30 int height() const { return height_; } | |
31 InstantSizeUnits height_units() const { return height_units_; } | |
32 | |
33 void SetOverlayState(const SearchMode& mode, | |
34 int height, | |
35 InstantSizeUnits height_units); | |
36 | |
37 void SetOverlayContents(content::WebContents* overlay_contents); | |
38 content::WebContents* GetOverlayContents() const; | |
39 | |
40 // Add and remove observers. | |
41 void AddObserver(InstantOverlayModelObserver* observer); | |
42 void RemoveObserver(InstantOverlayModelObserver* observer); | |
43 | |
44 private: | |
45 SearchMode mode_; | |
46 int height_; | |
47 InstantSizeUnits height_units_; | |
48 | |
49 // Weak. Remembers the last set overlay contents to detect changes. Actual | |
50 // overlay contents is fetched from the |controller_| as this may not always | |
51 // reflect the actual overlay in effect. | |
52 content::WebContents* overlay_contents_; | |
53 | |
54 // Weak. The controller currently holds some model state. | |
55 // TODO(dhollowa): Remove this, transfer all state to InstantOverlayModel. | |
56 InstantController* const controller_; | |
57 | |
58 // Observers. | |
59 ObserverList<InstantOverlayModelObserver> observers_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(InstantOverlayModel); | |
62 }; | |
63 | |
64 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_OVERLAY_MODEL_H_ | |
OLD | NEW |