OLD | NEW |
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_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_H_ |
6 #define CHROME_BROWSER_UI_BROWSER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // that would be cancelled. | 148 // that would be cancelled. |
149 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN, | 149 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN, |
150 | 150 |
151 // There are active downloads associated with this incognito profile | 151 // There are active downloads associated with this incognito profile |
152 // that would be canceled. | 152 // that would be canceled. |
153 DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, | 153 DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, |
154 }; | 154 }; |
155 | 155 |
156 struct CreateParams { | 156 struct CreateParams { |
157 CreateParams(); | 157 CreateParams(); |
| 158 explicit CreateParams(Profile* profile); |
158 CreateParams(Type type, Profile* profile); | 159 CreateParams(Type type, Profile* profile); |
159 | 160 |
160 static CreateParams CreateForApp(Type type, | 161 static CreateParams CreateForApp(Type type, |
161 const std::string& app_name, | 162 const std::string& app_name, |
162 const gfx::Rect& window_bounds, | 163 const gfx::Rect& window_bounds, |
163 Profile* profile); | 164 Profile* profile); |
164 | 165 |
165 static CreateParams CreateForDevTools(Profile* profile); | 166 static CreateParams CreateForDevTools(Profile* profile); |
166 | 167 |
167 // The browser type. | 168 // The browser type. |
(...skipping 10 matching lines...) Expand all Loading... |
178 | 179 |
179 // Type of app (host or child). See description of AppType. | 180 // Type of app (host or child). See description of AppType. |
180 AppType app_type; | 181 AppType app_type; |
181 | 182 |
182 // The bounds of the window to open. | 183 // The bounds of the window to open. |
183 gfx::Rect initial_bounds; | 184 gfx::Rect initial_bounds; |
184 | 185 |
185 ui::WindowShowState initial_show_state; | 186 ui::WindowShowState initial_show_state; |
186 | 187 |
187 bool is_session_restore; | 188 bool is_session_restore; |
| 189 |
| 190 // Supply a custom BrowserWindow implementation, to be used instead of the |
| 191 // default. Intended for testing. |
| 192 BrowserWindow* window; |
188 }; | 193 }; |
189 | 194 |
190 // Constructors, Creation, Showing ////////////////////////////////////////// | 195 // Constructors, Creation, Showing ////////////////////////////////////////// |
191 | 196 |
192 // Creates a new browser of the given |type| and for the given |profile|. The | 197 explicit Browser(const CreateParams& params); |
193 // Browser has a NULL window after its construction, InitBrowserWindow must | |
194 // be called after configuration for window() to be valid. | |
195 // Avoid using this constructor directly if you can use one of the Create*() | |
196 // methods below. This applies to almost all non-testing code. | |
197 Browser(Type type, Profile* profile); | |
198 virtual ~Browser(); | 198 virtual ~Browser(); |
199 | 199 |
200 // Creates a normal tabbed browser with the specified profile. The Browser's | |
201 // window is created by this function call. | |
202 static Browser* Create(Profile* profile); | |
203 | |
204 // Like Create, but creates a browser of the specified parameters. | |
205 static Browser* CreateWithParams(const CreateParams& params); | |
206 | |
207 // Set overrides for the initial window bounds and maximized state. | 200 // Set overrides for the initial window bounds and maximized state. |
208 void set_override_bounds(const gfx::Rect& bounds) { | 201 void set_override_bounds(const gfx::Rect& bounds) { |
209 override_bounds_ = bounds; | 202 override_bounds_ = bounds; |
210 } | 203 } |
211 ui::WindowShowState initial_show_state() const { return initial_show_state_; } | 204 ui::WindowShowState initial_show_state() const { return initial_show_state_; } |
212 void set_initial_show_state(ui::WindowShowState initial_show_state) { | 205 void set_initial_show_state(ui::WindowShowState initial_show_state) { |
213 initial_show_state_ = initial_show_state; | 206 initial_show_state_ = initial_show_state; |
214 } | 207 } |
215 // Return true if the initial window bounds have been overridden. | 208 // Return true if the initial window bounds have been overridden. |
216 bool bounds_overridden() const { | 209 bool bounds_overridden() const { |
217 return !override_bounds_.IsEmpty(); | 210 return !override_bounds_.IsEmpty(); |
218 } | 211 } |
219 // Set indicator that this browser is being created via session restore. | 212 // Set indicator that this browser is being created via session restore. |
220 // This is used on the Mac (only) to determine animation style when the | 213 // This is used on the Mac (only) to determine animation style when the |
221 // browser window is shown. | 214 // browser window is shown. |
222 void set_is_session_restore(bool is_session_restore) { | 215 void set_is_session_restore(bool is_session_restore) { |
223 is_session_restore_ = is_session_restore; | 216 is_session_restore_ = is_session_restore; |
224 } | 217 } |
225 bool is_session_restore() const { | 218 bool is_session_restore() const { |
226 return is_session_restore_; | 219 return is_session_restore_; |
227 } | 220 } |
228 | 221 |
229 // Creates the Browser Window. Prefer to use the static helpers above where | |
230 // possible. This does not show the window. You need to call window()->Show() | |
231 // to show it. | |
232 void InitBrowserWindow(); | |
233 | |
234 // Sets the BrowserWindow. This is intended for tests only. | |
235 // Use CreateBrowserWindow outside of testing, or the static convenience | |
236 // methods that create a BrowserWindow for you. | |
237 void SetWindowForTesting(BrowserWindow* window); | |
238 | |
239 // Accessors //////////////////////////////////////////////////////////////// | 222 // Accessors //////////////////////////////////////////////////////////////// |
240 | 223 |
241 Type type() const { return type_; } | 224 Type type() const { return type_; } |
242 const std::string& app_name() const { return app_name_; } | 225 const std::string& app_name() const { return app_name_; } |
243 AppType app_type() const { return app_type_; } | 226 AppType app_type() const { return app_type_; } |
244 Profile* profile() const { return profile_; } | 227 Profile* profile() const { return profile_; } |
245 gfx::Rect override_bounds() const { return override_bounds_; } | 228 gfx::Rect override_bounds() const { return override_bounds_; } |
246 | 229 |
247 // |window()| will return NULL if called before |CreateBrowserWindow()| | 230 // |window()| will return NULL if called before |CreateBrowserWindow()| |
248 // is done. | 231 // is done. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 void ShowFirstRunBubble(); | 460 void ShowFirstRunBubble(); |
478 | 461 |
479 FullscreenController* fullscreen_controller() { | 462 FullscreenController* fullscreen_controller() { |
480 return fullscreen_controller_.get(); | 463 return fullscreen_controller_.get(); |
481 } | 464 } |
482 | 465 |
483 extensions::WindowController* extension_window_controller() const { | 466 extensions::WindowController* extension_window_controller() const { |
484 return extension_window_controller_.get(); | 467 return extension_window_controller_.get(); |
485 } | 468 } |
486 | 469 |
487 protected: | |
488 // Funnel for the factory method in BrowserWindow. This allows subclasses to | |
489 // set their own window. | |
490 virtual BrowserWindow* CreateBrowserWindow(); | |
491 | |
492 private: | 470 private: |
493 friend class BrowserTest; | 471 friend class BrowserTest; |
494 friend class FullscreenControllerTest; | 472 friend class FullscreenControllerTest; |
495 FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest); | 473 FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest); |
496 FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); | 474 FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); |
497 FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); | 475 FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); |
498 FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp); | 476 FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp); |
499 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); | 477 FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch); |
500 FRIEND_TEST_ALL_PREFIXES(FullscreenControllerTest, | 478 FRIEND_TEST_ALL_PREFIXES(FullscreenControllerTest, |
501 TabEntersPresentationModeFromWindowed); | 479 TabEntersPresentationModeFromWindowed); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 bool window_has_shown_; | 903 bool window_has_shown_; |
926 | 904 |
927 // Currently open color chooser. Non-NULL after OpenColorChooser is called and | 905 // Currently open color chooser. Non-NULL after OpenColorChooser is called and |
928 // before DidEndColorChooser is called. | 906 // before DidEndColorChooser is called. |
929 scoped_ptr<content::ColorChooser> color_chooser_; | 907 scoped_ptr<content::ColorChooser> color_chooser_; |
930 | 908 |
931 DISALLOW_COPY_AND_ASSIGN(Browser); | 909 DISALLOW_COPY_AND_ASSIGN(Browser); |
932 }; | 910 }; |
933 | 911 |
934 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 912 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
OLD | NEW |