Chromium Code Reviews| 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" | |
| 11 #include "chrome/common/search_types.h" | |
| 12 | 10 |
| 13 class InstantController; | |
| 14 class InstantModelObserver; | 11 class InstantModelObserver; |
| 12 class InstantService; | |
| 15 | 13 |
| 16 namespace content { | 14 namespace content { |
| 17 class WebContents; | 15 class WebContents; |
| 18 } | 16 } |
| 19 | 17 |
| 20 // Holds state that is important to any views concerned with visibility and | 18 // Holds state that is important to any views concerned with visibility and |
| 21 // layout of the Instant preview. | 19 // layout of the Instant overlay. |
| 22 class InstantModel { | 20 class InstantModel { |
|
samarth
2013/03/01 17:59:53
Calling this InstantModel is very confusing since
sreeram
2013/03/07 18:18:46
Done.
| |
| 23 public: | 21 public: |
| 24 explicit InstantModel(InstantController* controller); | 22 explicit InstantModel(InstantService* service); |
| 25 ~InstantModel(); | 23 ~InstantModel(); |
| 26 | 24 |
| 27 // InstantModel only uses Mode::mode internally. Other parts of Mode, such as | 25 content::WebContents* overlay() const { return overlay_; } |
| 28 // 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_; } | 26 int height() const { return height_; } |
| 31 InstantSizeUnits height_units() const { return height_units_; } | 27 bool is_height_in_pixels() const { return is_height_in_pixels_; } |
|
samarth
2013/03/01 17:59:53
Eh, not a fan of this change; I like the explicit
sreeram
2013/03/07 18:18:46
Done. Agreed. Sorry I got overzealous. I also reve
| |
| 32 | 28 |
| 33 void SetPreviewState(const chrome::search::Mode& mode, | 29 void SetOverlayState(content::WebContents* overlay, |
| 34 int height, | 30 int height, |
| 35 InstantSizeUnits height_units); | 31 bool is_height_in_pixels); |
| 36 | |
| 37 void SetPreviewContents(content::WebContents* preview_contents); | |
| 38 content::WebContents* GetPreviewContents() const; | |
| 39 | 32 |
| 40 // Add and remove observers. | 33 // Add and remove observers. |
| 41 void AddObserver(InstantModelObserver* observer); | 34 void AddObserver(InstantModelObserver* observer); |
| 42 void RemoveObserver(InstantModelObserver* observer); | 35 void RemoveObserver(InstantModelObserver* observer); |
| 43 | 36 |
| 44 private: | 37 private: |
| 45 chrome::search::Mode mode_; | 38 content::WebContents* overlay_; |
| 46 int height_; | 39 int height_; |
| 47 InstantSizeUnits height_units_; | 40 bool is_height_in_pixels_; |
| 48 | |
| 49 // Weak. Remembers the last set preview contents to detect changes. Actual | |
| 50 // preview contents is fetched from the |controller_| as this may not always | |
| 51 // reflect the actual preview in effect. | |
| 52 content::WebContents* preview_contents_; | |
| 53 | |
| 54 // Weak. The controller currently holds some model state. | |
| 55 // TODO(dhollowa): Remove this, transfer all model state to InstantModel. | |
| 56 InstantController* const controller_; | |
| 57 | 41 |
| 58 // Observers. | 42 // Observers. |
| 59 ObserverList<InstantModelObserver> observers_; | 43 ObserverList<InstantModelObserver> observers_; |
| 60 | 44 |
| 45 InstantService* const service_; | |
| 46 | |
| 61 DISALLOW_COPY_AND_ASSIGN(InstantModel); | 47 DISALLOW_COPY_AND_ASSIGN(InstantModel); |
| 62 }; | 48 }; |
| 63 | 49 |
| 64 #endif // CHROME_BROWSER_INSTANT_INSTANT_MODEL_H_ | 50 #endif // CHROME_BROWSER_INSTANT_INSTANT_MODEL_H_ |
| OLD | NEW |