Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/ui/browser_instant_controller.h

Issue 11413018: alternate ntp: implement searchbox api for instant overlay to adopt themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed scott's comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/public/pref_change_registrar.h" 11 #include "base/prefs/public/pref_change_registrar.h"
12 #include "base/prefs/public/pref_observer.h" 12 #include "base/prefs/public/pref_observer.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/instant/instant_unload_handler.h" 14 #include "chrome/browser/instant/instant_unload_handler.h"
15 #include "chrome/browser/ui/search/search_model_observer.h" 15 #include "chrome/browser/ui/search/search_model_observer.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
17 #include "chrome/common/instant_types.h" 17 #include "chrome/common/instant_types.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
18 #include "webkit/glue/window_open_disposition.h" 20 #include "webkit/glue/window_open_disposition.h"
19 21
20 class Browser; 22 class Browser;
21 class InstantController; 23 class InstantController;
22 class InstantTest; 24 class InstantTest;
23 class TabContents; 25 class TabContents;
24 26
25 namespace gfx { 27 namespace gfx {
26 class Rect; 28 class Rect;
27 } 29 }
28 30
31 namespace ui {
32 class ThemeProvider;
33 };
34
29 namespace chrome { 35 namespace chrome {
30 36
31 class BrowserInstantController : public TabStripModelObserver, 37 class BrowserInstantController : public TabStripModelObserver,
32 public search::SearchModelObserver, 38 public search::SearchModelObserver,
33 public PrefObserver { 39 public PrefObserver,
40 public content::NotificationObserver {
34 public: 41 public:
35 explicit BrowserInstantController(Browser* browser); 42 explicit BrowserInstantController(Browser* browser);
36 virtual ~BrowserInstantController(); 43 virtual ~BrowserInstantController();
37 44
38 // Commits the current Instant, returning true on success. This is intended 45 // Commits the current Instant, returning true on success. This is intended
39 // for use from OpenCurrentURL. 46 // for use from OpenCurrentURL.
40 bool OpenInstant(WindowOpenDisposition disposition); 47 bool OpenInstant(WindowOpenDisposition disposition);
41 48
42 // Returns the InstantController or NULL if there is no InstantController for 49 // Returns the InstantController or NULL if there is no InstantController for
43 // this BrowserInstantController. 50 // this BrowserInstantController.
(...skipping 11 matching lines...) Expand all
55 gfx::Rect GetInstantBounds(); 62 gfx::Rect GetInstantBounds();
56 63
57 // Invoked by |instant_| to notify that the preview gained focus, usually due 64 // Invoked by |instant_| to notify that the preview gained focus, usually due
58 // to the user clicking on it. 65 // to the user clicking on it.
59 void InstantPreviewFocused(); 66 void InstantPreviewFocused();
60 67
61 // 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
62 // preview would be shown. 69 // preview would be shown.
63 TabContents* GetActiveTabContents() const; 70 TabContents* GetActiveTabContents() const;
64 71
72 // Invoked by |BrowserWindow| during layout to set content height which is
73 // used as theme area height, i.e. the height of the area that the entire
74 // theme background image should fill up.
75 void SetContentHeight(int height);
76
77 // Invoked by |instant_| to update theme-related information in preview.
78 void UpdateThemeRelatedInfoForPreview();
79
65 // Overridden from PrefObserver: 80 // Overridden from PrefObserver:
66 virtual void OnPreferenceChanged(PrefServiceBase* service, 81 virtual void OnPreferenceChanged(PrefServiceBase* service,
67 const std::string& pref_name) OVERRIDE; 82 const std::string& pref_name) OVERRIDE;
68 83
69 // Overridden from TabStripModelObserver: 84 // Overridden from TabStripModelObserver:
70 virtual void ActiveTabChanged(content::WebContents* old_contents, 85 virtual void ActiveTabChanged(content::WebContents* old_contents,
71 content::WebContents* new_contents, 86 content::WebContents* new_contents,
72 int index, 87 int index,
73 bool user_gesture) OVERRIDE; 88 bool user_gesture) OVERRIDE;
74 virtual void TabStripEmpty() OVERRIDE; 89 virtual void TabStripEmpty() OVERRIDE;
75 90
76 // Overridden from search::SearchModelObserver: 91 // Overridden from search::SearchModelObserver:
77 virtual void ModeChanged(const search::Mode& old_mode, 92 virtual void ModeChanged(const search::Mode& old_mode,
78 const search::Mode& new_mode) OVERRIDE; 93 const search::Mode& new_mode) OVERRIDE;
79 94
80 private: 95 private:
96 // content::NotificationObserver implementation.
97 virtual void Observe(int type,
98 const content::NotificationSource& source,
99 const content::NotificationDetails& details) OVERRIDE;
100
81 // If this browser should have Instant, a new InstantController created; 101 // If this browser should have Instant, a new InstantController created;
82 // otherwise any existing InstantController is destroyed. 102 // otherwise any existing InstantController is destroyed.
83 void ResetInstant(); 103 void ResetInstant();
84 104
105 // Helper for handling theme change.
106 void OnThemeChanged(ui::ThemeProvider* theme_provider);
107
108 // Helper for handling theme area height change.
109 void OnThemeAreaHeightChanged(int height);
110
85 Browser* browser_; 111 Browser* browser_;
86 112
87 scoped_ptr<InstantController> instant_; 113 scoped_ptr<InstantController> instant_;
88 InstantUnloadHandler instant_unload_handler_; 114 InstantUnloadHandler instant_unload_handler_;
89 115
116 // Theme-related data for NTP preview to adopt themes.
117 ThemeBackgroundInfo theme_info_;
118 int theme_image_alignment_;
119 int theme_area_height_;
120
90 PrefChangeRegistrar profile_pref_registrar_; 121 PrefChangeRegistrar profile_pref_registrar_;
91 122
123 content::NotificationRegistrar registrar_;
124
92 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); 125 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
93 }; 126 };
94 127
95 } // namespace chrome 128 } // namespace chrome
96 129
97 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 130 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698