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

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 sreeram's and chris'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;
26 class ThemeService;
24 27
25 namespace gfx { 28 namespace gfx {
26 class Rect; 29 class Rect;
27 } 30 }
28 31
29 namespace chrome { 32 namespace chrome {
30 33
31 class BrowserInstantController : public TabStripModelObserver, 34 class BrowserInstantController : public TabStripModelObserver,
32 public search::SearchModelObserver, 35 public search::SearchModelObserver,
33 public PrefObserver { 36 public PrefObserver,
37 public content::NotificationObserver {
34 public: 38 public:
35 explicit BrowserInstantController(Browser* browser); 39 explicit BrowserInstantController(Browser* browser);
36 virtual ~BrowserInstantController(); 40 virtual ~BrowserInstantController();
37 41
38 // Commits the current Instant, returning true on success. This is intended 42 // Commits the current Instant, returning true on success. This is intended
39 // for use from OpenCurrentURL. 43 // for use from OpenCurrentURL.
40 bool OpenInstant(WindowOpenDisposition disposition); 44 bool OpenInstant(WindowOpenDisposition disposition);
41 45
42 // Returns the InstantController or NULL if there is no InstantController for 46 // Returns the InstantController or NULL if there is no InstantController for
43 // this BrowserInstantController. 47 // this BrowserInstantController.
(...skipping 11 matching lines...) Expand all
55 gfx::Rect GetInstantBounds(); 59 gfx::Rect GetInstantBounds();
56 60
57 // Invoked by |instant_| to notify that the preview gained focus, usually due 61 // Invoked by |instant_| to notify that the preview gained focus, usually due
58 // to the user clicking on it. 62 // to the user clicking on it.
59 void InstantPreviewFocused(); 63 void InstantPreviewFocused();
60 64
61 // Invoked by |instant_| to get the currently active tab, over which the 65 // Invoked by |instant_| to get the currently active tab, over which the
62 // preview would be shown. 66 // preview would be shown.
63 TabContents* GetActiveTabContents() const; 67 TabContents* GetActiveTabContents() const;
64 68
69 // Invoked by |BrowserWindow| during layout to set content height which is
70 // used as theme area height, i.e. the height of the area that the entire
71 // theme background image should fill up.
72 void SetContentHeight(int height);
73
74 // Invoked by |instant_| to update theme information for preview.
75 void UpdateThemeInfoForPreview();
76
65 // Overridden from PrefObserver: 77 // Overridden from PrefObserver:
66 virtual void OnPreferenceChanged(PrefServiceBase* service, 78 virtual void OnPreferenceChanged(PrefServiceBase* service,
67 const std::string& pref_name) OVERRIDE; 79 const std::string& pref_name) OVERRIDE;
68 80
69 // Overridden from TabStripModelObserver: 81 // Overridden from TabStripModelObserver:
70 virtual void ActiveTabChanged(content::WebContents* old_contents, 82 virtual void ActiveTabChanged(content::WebContents* old_contents,
71 content::WebContents* new_contents, 83 content::WebContents* new_contents,
72 int index, 84 int index,
73 bool user_gesture) OVERRIDE; 85 bool user_gesture) OVERRIDE;
74 virtual void TabStripEmpty() OVERRIDE; 86 virtual void TabStripEmpty() 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
80 private: 92 private:
93 // content::NotificationObserver implementation.
94 virtual void Observe(int type,
95 const content::NotificationSource& source,
96 const content::NotificationDetails& details) OVERRIDE;
97
81 // If this browser should have Instant, a new InstantController created; 98 // If this browser should have Instant, a new InstantController created;
82 // otherwise any existing InstantController is destroyed. 99 // otherwise any existing InstantController is destroyed.
83 void ResetInstant(); 100 void ResetInstant();
84 101
102 // Helper for handling theme change.
103 void OnThemeChanged(ThemeService* theme_service);
104
105 // Helper for handling theme area height change.
106 void OnThemeAreaHeightChanged(int height);
107
85 Browser* browser_; 108 Browser* browser_;
86 109
87 scoped_ptr<InstantController> instant_; 110 scoped_ptr<InstantController> instant_;
88 InstantUnloadHandler instant_unload_handler_; 111 InstantUnloadHandler instant_unload_handler_;
89 112
113 // Theme-related data for NTP preview to adopt themes.
114 bool initialized_theme_info_; // True if theme_info_ has been initialized.
115 ThemeBackgroundInfo theme_info_;
116 int theme_area_height_;
117
90 PrefChangeRegistrar profile_pref_registrar_; 118 PrefChangeRegistrar profile_pref_registrar_;
91 119
120 content::NotificationRegistrar registrar_;
121
92 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); 122 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
93 }; 123 };
94 124
95 } // namespace chrome 125 } // namespace chrome
96 126
97 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 127 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698