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