OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "chrome/common/instant_types.h" | 10 #include "chrome/common/instant_types.h" |
11 #include "chrome/common/search_types.h" | |
12 | 11 |
13 class InstantController; | |
14 class InstantOverlayModelObserver; | 12 class InstantOverlayModelObserver; |
| 13 class InstantService; |
15 | 14 |
16 namespace content { | 15 namespace content { |
17 class WebContents; | 16 class WebContents; |
18 } | 17 } |
19 | 18 |
20 // Holds state that is important to any views concerned with visibility and | 19 // Holds state that is important to any views concerned with visibility and |
21 // layout of the Instant overlay. | 20 // layout of the Instant overlay. |
22 class InstantOverlayModel { | 21 class InstantOverlayModel { |
23 public: | 22 public: |
24 explicit InstantOverlayModel(InstantController* controller); | 23 explicit InstantOverlayModel(InstantService* service); |
25 ~InstantOverlayModel(); | 24 ~InstantOverlayModel(); |
26 | 25 |
27 // InstantOverlayModel only uses Mode::mode internally. Other parts of Mode, | 26 content::WebContents* contents() const { return contents_; } |
28 // such as Mode::origin, may have arbitrary values, and should be ignored. | |
29 const chrome::search::Mode& mode() const { return mode_; } | |
30 int height() const { return height_; } | 27 int height() const { return height_; } |
31 InstantSizeUnits height_units() const { return height_units_; } | 28 InstantSizeUnits height_units() const { return height_units_; } |
32 | 29 |
33 void SetOverlayState(const chrome::search::Mode& mode, | 30 void SetOverlayState(content::WebContents* contents, |
34 int height, | 31 int height, |
35 InstantSizeUnits height_units); | 32 InstantSizeUnits height_units); |
36 | 33 |
37 void SetOverlayContents(content::WebContents* overlay_contents); | |
38 content::WebContents* GetOverlayContents() const; | |
39 | |
40 // Add and remove observers. | 34 // Add and remove observers. |
41 void AddObserver(InstantOverlayModelObserver* observer); | 35 void AddObserver(InstantOverlayModelObserver* observer); |
42 void RemoveObserver(InstantOverlayModelObserver* observer); | 36 void RemoveObserver(InstantOverlayModelObserver* observer); |
43 | 37 |
44 private: | 38 private: |
45 chrome::search::Mode mode_; | 39 content::WebContents* contents_; |
46 int height_; | 40 int height_; |
47 InstantSizeUnits height_units_; | 41 InstantSizeUnits height_units_; |
48 | 42 |
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. | 43 // Observers. |
59 ObserverList<InstantOverlayModelObserver> observers_; | 44 ObserverList<InstantOverlayModelObserver> observers_; |
60 | 45 |
| 46 InstantService* const service_; |
| 47 |
61 DISALLOW_COPY_AND_ASSIGN(InstantOverlayModel); | 48 DISALLOW_COPY_AND_ASSIGN(InstantOverlayModel); |
62 }; | 49 }; |
63 | 50 |
64 #endif // CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ | 51 #endif // CHROME_BROWSER_INSTANT_INSTANT_OVERLAY_MODEL_H_ |
OLD | NEW |