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

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

Issue 16413002: Moved theme related state from BrowserInstantController to InstantService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 months 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_instant_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/prefs/pref_change_registrar.h" 12 #include "base/prefs/pref_change_registrar.h"
13 #include "chrome/browser/ui/search/instant_controller.h" 13 #include "chrome/browser/ui/search/instant_controller.h"
14 #include "chrome/browser/ui/search/instant_unload_handler.h" 14 #include "chrome/browser/ui/search/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 "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "ui/base/window_open_disposition.h" 16 #include "ui/base/window_open_disposition.h"
19 17
20 class Browser; 18 class Browser;
21 struct InstantSuggestion; 19 struct InstantSuggestion;
22 class Profile; 20 class Profile;
23 class ThemeService;
24 21
25 namespace content { 22 namespace content {
26 class WebContents; 23 class WebContents;
27 } 24 }
28 25
29 namespace gfx { 26 namespace gfx {
30 class Rect; 27 class Rect;
31 } 28 }
32 29
33 class BrowserInstantController : public content::NotificationObserver, 30 class BrowserInstantController : public SearchModelObserver {
34 public SearchModelObserver {
35 public: 31 public:
36 explicit BrowserInstantController(Browser* browser); 32 explicit BrowserInstantController(Browser* browser);
37 virtual ~BrowserInstantController(); 33 virtual ~BrowserInstantController();
38 34
39 // If |url| is the new tab page URL, set |target_contents| to the preloaded 35 // If |url| is the new tab page URL, set |target_contents| to the preloaded
40 // NTP contents from InstantController. If |source_contents| is not NULL, we 36 // NTP contents from InstantController. If |source_contents| is not NULL, we
41 // replace it with the new |target_contents| in the tabstrip and delete 37 // replace it with the new |target_contents| in the tabstrip and delete
42 // |source_contents|. Otherwise, the caller owns |target_contents| and is 38 // |source_contents|. Otherwise, the caller owns |target_contents| and is
43 // responsible for inserting it into the tabstrip. 39 // responsible for inserting it into the tabstrip.
44 // 40 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Invoked by |instant_| to get the currently active tab, over which the 77 // Invoked by |instant_| to get the currently active tab, over which the
82 // overlay would be shown. 78 // overlay would be shown.
83 content::WebContents* GetActiveWebContents() const; 79 content::WebContents* GetActiveWebContents() const;
84 80
85 // Invoked by |browser_| when the active tab changes. 81 // Invoked by |browser_| when the active tab changes.
86 void ActiveTabChanged(); 82 void ActiveTabChanged();
87 83
88 // Invoked by |browser_| when the active tab is about to be deactivated. 84 // Invoked by |browser_| when the active tab is about to be deactivated.
89 void TabDeactivated(content::WebContents* contents); 85 void TabDeactivated(content::WebContents* contents);
90 86
91 // Invoked by |instant_| to update theme information for NTP.
92 void UpdateThemeInfo();
93
94 // Invoked by the InstantController when it wants to open a URL. 87 // Invoked by the InstantController when it wants to open a URL.
95 void OpenURL(const GURL& url, 88 void OpenURL(const GURL& url,
96 content::PageTransition transition, 89 content::PageTransition transition,
97 WindowOpenDisposition disposition); 90 WindowOpenDisposition disposition);
98 91
99 // Sets the stored omnibox bounds. 92 // Sets the stored omnibox bounds.
100 void SetOmniboxBounds(const gfx::Rect& bounds); 93 void SetOmniboxBounds(const gfx::Rect& bounds);
101 94
102 // Notifies |instant_| to toggle voice search. 95 // Notifies |instant_| to toggle voice search.
103 void ToggleVoiceSearch(); 96 void ToggleVoiceSearch();
104 97
105 private: 98 private:
106 // Sets the value of |instant_| based on value from profile. Invoked 99 // Sets the value of |instant_| based on value from profile. Invoked
107 // on pref change. 100 // on pref change.
108 void ResetInstant(const std::string& pref_name); 101 void ResetInstant(const std::string& pref_name);
109 102
110 // Overridden from search::SearchModelObserver: 103 // Overridden from search::SearchModelObserver:
111 virtual void ModelChanged(const SearchModel::State& old_state, 104 virtual void ModelChanged(const SearchModel::State& old_state,
112 const SearchModel::State& new_state) OVERRIDE; 105 const SearchModel::State& new_state) OVERRIDE;
113 106
114 // content::NotificationObserver implementation.
115 virtual void Observe(int type,
116 const content::NotificationSource& source,
117 const content::NotificationDetails& details) OVERRIDE;
118
119 // Helper for handling theme change.
120 void OnThemeChanged(ThemeService* theme_service);
121
122 // Called when the default search provider changes. Revokes the searchbox API 107 // Called when the default search provider changes. Revokes the searchbox API
123 // privileges for any existing WebContents (that belong to the erstwhile 108 // privileges for any existing WebContents (that belong to the erstwhile
124 // default search provider) by simply reloading all such WebContents. This 109 // default search provider) by simply reloading all such WebContents. This
125 // ensures that they are reloaded in a non-privileged renderer process. 110 // ensures that they are reloaded in a non-privileged renderer process.
126 void OnDefaultSearchProviderChanged(const std::string& pref_name); 111 void OnDefaultSearchProviderChanged(const std::string& pref_name);
127 112
128 // Replaces the contents at tab |index| with |new_contents| and deletes the 113 // Replaces the contents at tab |index| with |new_contents| and deletes the
129 // existing contents. 114 // existing contents.
130 void ReplaceWebContentsAt(int index, 115 void ReplaceWebContentsAt(int index,
131 scoped_ptr<content::WebContents> new_contents); 116 scoped_ptr<content::WebContents> new_contents);
132 117
133 Browser* const browser_; 118 Browser* const browser_;
134 119
135 InstantController instant_; 120 InstantController instant_;
136 InstantUnloadHandler instant_unload_handler_; 121 InstantUnloadHandler instant_unload_handler_;
137 122
138 // Theme-related data for NTP overlay to adopt themes.
139 bool initialized_theme_info_; // True if theme_info_ has been initialized.
140 ThemeBackgroundInfo theme_info_;
141
142 PrefChangeRegistrar profile_pref_registrar_; 123 PrefChangeRegistrar profile_pref_registrar_;
143 124
144 content::NotificationRegistrar registrar_;
145
146 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); 125 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
147 }; 126 };
148 127
149 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ 128 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698