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_UI_BROWSER_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
11 #include "base/prefs/public/pref_observer.h" | 11 #include "base/prefs/public/pref_observer.h" |
12 #include "chrome/browser/instant/instant_controller.h" | 12 #include "chrome/browser/instant/instant_controller.h" |
13 #include "chrome/browser/instant/instant_unload_handler.h" | 13 #include "chrome/browser/instant/instant_unload_handler.h" |
14 #include "chrome/browser/ui/search/search_model_observer.h" | 14 #include "chrome/browser/ui/search/search_model_observer.h" |
15 #include "content/public/browser/notification_observer.h" | |
16 #include "content/public/browser/notification_registrar.h" | |
15 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
16 | 18 |
17 class Browser; | 19 class Browser; |
18 struct InstantSuggestion; | 20 struct InstantSuggestion; |
19 class PrefService; | 21 class PrefService; |
20 class Profile; | 22 class Profile; |
21 class TabContents; | 23 class TabContents; |
24 class ThemeService; | |
22 | 25 |
23 namespace gfx { | 26 namespace gfx { |
24 class Rect; | 27 class Rect; |
25 } | 28 } |
26 | 29 |
27 namespace chrome { | 30 namespace chrome { |
28 | 31 |
29 class BrowserInstantController : public PrefObserver, | 32 class BrowserInstantController : public PrefObserver, |
30 public search::SearchModelObserver { | 33 public search::SearchModelObserver, |
34 public content::NotificationObserver { | |
sreeram
2012/11/20 17:37:58
Nit: Swap the two lines above to keep alpha order.
kuan
2012/11/20 17:52:24
Done.
| |
31 public: | 35 public: |
32 explicit BrowserInstantController(Browser* browser); | 36 explicit BrowserInstantController(Browser* browser); |
33 virtual ~BrowserInstantController(); | 37 virtual ~BrowserInstantController(); |
34 | 38 |
35 // Returns true if Instant is enabled in a visible, preview-showing mode. | 39 // Returns true if Instant is enabled in a visible, preview-showing mode. |
36 static bool IsInstantEnabled(Profile* profile); | 40 static bool IsInstantEnabled(Profile* profile); |
37 | 41 |
38 // Registers Instant related preferences. | 42 // Registers Instant related preferences. |
39 static void RegisterUserPrefs(PrefService* prefs); | 43 static void RegisterUserPrefs(PrefService* prefs); |
40 | 44 |
(...skipping 20 matching lines...) Expand all Loading... | |
61 // to the user clicking on it. | 65 // to the user clicking on it. |
62 void InstantPreviewFocused(); | 66 void InstantPreviewFocused(); |
63 | 67 |
64 // Invoked by |instant_| to get the currently active tab, over which the | 68 // Invoked by |instant_| to get the currently active tab, over which the |
65 // preview would be shown. | 69 // preview would be shown. |
66 TabContents* GetActiveTabContents() const; | 70 TabContents* GetActiveTabContents() const; |
67 | 71 |
68 // Invoked by |browser_| when the active tab changes. | 72 // Invoked by |browser_| when the active tab changes. |
69 void ActiveTabChanged(); | 73 void ActiveTabChanged(); |
70 | 74 |
75 // Invoked by |BrowserWindow| during layout to set content height which is | |
76 // used as theme area height, i.e. the height of the area that the entire | |
77 // theme background image should fill up. | |
78 void SetContentHeight(int height); | |
79 | |
80 // Invoked by |instant_| to update theme information for preview. | |
81 void UpdateThemeInfoForPreview(); | |
82 | |
71 private: | 83 private: |
72 // Overridden from PrefObserver: | 84 // Overridden from PrefObserver: |
73 virtual void OnPreferenceChanged(PrefServiceBase* service, | 85 virtual void OnPreferenceChanged(PrefServiceBase* service, |
74 const std::string& pref_name) OVERRIDE; | 86 const std::string& pref_name) OVERRIDE; |
75 | 87 |
76 // Overridden from search::SearchModelObserver: | 88 // Overridden from search::SearchModelObserver: |
77 virtual void ModeChanged(const search::Mode& old_mode, | 89 virtual void ModeChanged(const search::Mode& old_mode, |
78 const search::Mode& new_mode) OVERRIDE; | 90 const search::Mode& new_mode) OVERRIDE; |
79 | 91 |
92 // content::NotificationObserver implementation. | |
93 virtual void Observe(int type, | |
94 const content::NotificationSource& source, | |
95 const content::NotificationDetails& details) OVERRIDE; | |
96 | |
97 // Helper for handling theme change. | |
98 void OnThemeChanged(ThemeService* theme_service); | |
99 | |
100 // Helper for handling theme area height change. | |
101 void OnThemeAreaHeightChanged(int height); | |
102 | |
80 Browser* const browser_; | 103 Browser* const browser_; |
81 | 104 |
82 InstantController instant_; | 105 InstantController instant_; |
83 InstantUnloadHandler instant_unload_handler_; | 106 InstantUnloadHandler instant_unload_handler_; |
84 | 107 |
108 // Theme-related data for NTP preview to adopt themes. | |
109 bool initialized_theme_info_; // True if theme_info_ has been initialized. | |
110 ThemeBackgroundInfo theme_info_; | |
111 int theme_area_height_; | |
112 | |
85 PrefChangeRegistrar profile_pref_registrar_; | 113 PrefChangeRegistrar profile_pref_registrar_; |
86 | 114 |
115 content::NotificationRegistrar registrar_; | |
116 | |
87 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 117 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
88 }; | 118 }; |
89 | 119 |
90 } // namespace chrome | 120 } // namespace chrome |
91 | 121 |
92 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 122 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
OLD | NEW |