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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // updated. | 105 // updated. |
106 enum Type { | 106 enum Type { |
107 // If you add a new type, consider updating the test | 107 // If you add a new type, consider updating the test |
108 // BrowserTest.StartMaximized. | 108 // BrowserTest.StartMaximized. |
109 TYPE_TABBED = 1, | 109 TYPE_TABBED = 1, |
110 TYPE_POPUP = 2, | 110 TYPE_POPUP = 2, |
111 TYPE_PANEL = 3 | 111 TYPE_PANEL = 3 |
112 }; | 112 }; |
113 | 113 |
114 // Distinguishes between browsers that host an app (opened from | 114 // Distinguishes between browsers that host an app (opened from |
115 // Browser::OpenApplication), and child browsers created by an app from | 115 // ApplicationLauncher::OpenApplication), and child browsers created by an app |
116 // Browser::CreateForApp (e.g. by windows.open or the extension API). | 116 // from Browser::CreateForApp (e.g. by windows.open or the extension API). |
117 // TODO(stevenjb): This is currently only needed by the ash Launcher for | 117 // TODO(stevenjb): This is currently only needed by the ash Launcher for |
118 // identifying child panels. Remove this once panels are no longer | 118 // identifying child panels. Remove this once panels are no longer |
119 // implemented as Browsers, crbug.com/112198. | 119 // implemented as Browsers, crbug.com/112198. |
120 enum AppType { | 120 enum AppType { |
121 APP_TYPE_HOST = 1, | 121 APP_TYPE_HOST = 1, |
122 APP_TYPE_CHILD = 2 | 122 APP_TYPE_CHILD = 2 |
123 }; | 123 }; |
124 | 124 |
125 // Possible elements of the Browser window. | 125 // Possible elements of the Browser window. |
126 enum WindowFeature { | 126 enum WindowFeature { |
(...skipping 15 matching lines...) Expand all Loading... |
142 | 142 |
143 // The browser is shutting down and there are active downloads | 143 // The browser is shutting down and there are active downloads |
144 // that would be cancelled. | 144 // that would be cancelled. |
145 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN, | 145 DOWNLOAD_CLOSE_BROWSER_SHUTDOWN, |
146 | 146 |
147 // There are active downloads associated with this incognito profile | 147 // There are active downloads associated with this incognito profile |
148 // that would be canceled. | 148 // that would be canceled. |
149 DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, | 149 DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE, |
150 }; | 150 }; |
151 | 151 |
| 152 // Different types of action when web app info is available. |
| 153 // OnDidGetApplicationInfo uses this to dispatch calls. |
| 154 enum WebAppAction { |
| 155 NONE, // No action at all. |
| 156 CREATE_SHORTCUT, // Bring up create application shortcut dialog. |
| 157 UPDATE_SHORTCUT // Update icon for app shortcut. |
| 158 }; |
| 159 |
152 struct CreateParams { | 160 struct CreateParams { |
153 CreateParams(); | 161 CreateParams(); |
154 CreateParams(Type type, Profile* profile); | 162 CreateParams(Type type, Profile* profile); |
155 | 163 |
156 static CreateParams CreateForApp(Type type, | 164 static CreateParams CreateForApp(Type type, |
157 const std::string& app_name, | 165 const std::string& app_name, |
158 const gfx::Rect& window_bounds, | 166 const gfx::Rect& window_bounds, |
159 Profile* profile); | 167 Profile* profile); |
160 | 168 |
161 static CreateParams CreateForDevTools(Profile* profile); | 169 static CreateParams CreateForDevTools(Profile* profile); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 static Browser* OpenEmptyWindow(Profile* profile); | 289 static Browser* OpenEmptyWindow(Profile* profile); |
282 | 290 |
283 // Opens a new window with the tabs from |profile|'s TabRestoreService. | 291 // Opens a new window with the tabs from |profile|'s TabRestoreService. |
284 static void OpenWindowWithRestoredTabs(Profile* profile); | 292 static void OpenWindowWithRestoredTabs(Profile* profile); |
285 | 293 |
286 // Opens the specified URL in a new browser window in an incognito session. | 294 // Opens the specified URL in a new browser window in an incognito session. |
287 // If there is already an existing active incognito session for the specified | 295 // If there is already an existing active incognito session for the specified |
288 // |profile|, that session is re-used. | 296 // |profile|, that session is re-used. |
289 static void OpenURLOffTheRecord(Profile* profile, const GURL& url); | 297 static void OpenURLOffTheRecord(Profile* profile, const GURL& url); |
290 | 298 |
291 // Open |extension| in |container|, using |disposition| if container type is | |
292 // TAB. Returns the WebContents* that was created or NULL. If non-empty, | |
293 // |override_url| is used in place of the app launch url. | |
294 static content::WebContents* OpenApplication( | |
295 Profile* profile, | |
296 const extensions::Extension* extension, | |
297 extension_misc::LaunchContainer container, | |
298 const GURL& override_url, | |
299 WindowOpenDisposition disposition); | |
300 | |
301 #if defined(USE_ASH) | |
302 // Opens |url| in a new application panel window for the specified url. | |
303 static content::WebContents* OpenApplicationPanel( | |
304 Profile* profile, | |
305 const extensions::Extension* extension, | |
306 const GURL& url); | |
307 #endif | |
308 | |
309 // Opens a new application window for the specified url. If |as_panel| | |
310 // is true, the application will be opened as a Browser::Type::APP_PANEL in | |
311 // app panel window, otherwise it will be opened as as either | |
312 // Browser::Type::APP a.k.a. "thin frame" (if |extension| is NULL) or | |
313 // Browser::Type::EXTENSION_APP (if |extension| is non-NULL). | |
314 // If |app_browser| is not NULL, it is set to the browser that hosts the | |
315 // returned tab. | |
316 static content::WebContents* OpenApplicationWindow( | |
317 Profile* profile, | |
318 const extensions::Extension* extension, | |
319 extension_misc::LaunchContainer container, | |
320 const GURL& url, | |
321 Browser** app_browser); | |
322 | |
323 // Open |url| in an app shortcut window. If |update_shortcut| is true, | |
324 // update the name, description, and favicon of the shortcut. | |
325 // There are two kinds of app shortcuts: Shortcuts to a URL, | |
326 // and shortcuts that open an installed application. This function | |
327 // is used to open the former. To open the latter, use | |
328 // Browser::OpenApplicationWindow(). | |
329 static content::WebContents* OpenAppShortcutWindow(Profile* profile, | |
330 const GURL& url, | |
331 bool update_shortcut); | |
332 | |
333 // Open an application for |extension| using |disposition|. Returns NULL if | |
334 // there are no appropriate existing browser windows for |profile|. If | |
335 // non-empty, |override_url| is used in place of the app launch url. | |
336 static content::WebContents* OpenApplicationTab( | |
337 Profile* profile, | |
338 const extensions::Extension* extension, | |
339 const GURL& override_url, | |
340 WindowOpenDisposition disposition); | |
341 | |
342 // Opens a new window and opens the bookmark manager. | 299 // Opens a new window and opens the bookmark manager. |
343 static void OpenBookmarkManagerWindow(Profile* profile); | 300 static void OpenBookmarkManagerWindow(Profile* profile); |
344 | 301 |
345 #if defined(OS_MACOSX) | 302 #if defined(OS_MACOSX) |
346 // Open a new window with history/downloads/help/options (needed on Mac when | 303 // Open a new window with history/downloads/help/options (needed on Mac when |
347 // there are no windows). | 304 // there are no windows). |
348 static void OpenAboutWindow(Profile* profile); | 305 static void OpenAboutWindow(Profile* profile); |
349 static void OpenHistoryWindow(Profile* profile); | 306 static void OpenHistoryWindow(Profile* profile); |
350 static void OpenDownloadsWindow(Profile* profile); | 307 static void OpenDownloadsWindow(Profile* profile); |
351 static void OpenHelpWindow(Profile* profile); | 308 static void OpenHelpWindow(Profile* profile); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 | 803 |
847 // True when the mouse cursor is locked. | 804 // True when the mouse cursor is locked. |
848 bool IsMouseLocked() const; | 805 bool IsMouseLocked() const; |
849 | 806 |
850 // Called each time the browser window is shown. | 807 // Called each time the browser window is shown. |
851 void OnWindowDidShow(); | 808 void OnWindowDidShow(); |
852 | 809 |
853 // Show the first run search engine bubble on the location bar. | 810 // Show the first run search engine bubble on the location bar. |
854 void ShowFirstRunBubble(); | 811 void ShowFirstRunBubble(); |
855 | 812 |
| 813 void set_pending_web_app_action(WebAppAction action) { |
| 814 pending_web_app_action_ = action; |
| 815 } |
| 816 |
856 ExtensionWindowController* extension_window_controller() const { | 817 ExtensionWindowController* extension_window_controller() const { |
857 return extension_window_controller_.get(); | 818 return extension_window_controller_.get(); |
858 } | 819 } |
859 | 820 |
860 protected: | 821 protected: |
861 // Wrapper for the factory method in BrowserWindow. This allows subclasses to | 822 // Wrapper for the factory method in BrowserWindow. This allows subclasses to |
862 // set their own window. | 823 // set their own window. |
863 virtual BrowserWindow* CreateBrowserWindow(); | 824 virtual BrowserWindow* CreateBrowserWindow(); |
864 | 825 |
865 private: | 826 private: |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 | 1365 |
1405 // Indicates if command execution is blocked. | 1366 // Indicates if command execution is blocked. |
1406 bool block_command_execution_; | 1367 bool block_command_execution_; |
1407 | 1368 |
1408 // Stores the last blocked command id when |block_command_execution_| is true. | 1369 // Stores the last blocked command id when |block_command_execution_| is true. |
1409 int last_blocked_command_id_; | 1370 int last_blocked_command_id_; |
1410 | 1371 |
1411 // Stores the disposition type of the last blocked command. | 1372 // Stores the disposition type of the last blocked command. |
1412 WindowOpenDisposition last_blocked_command_disposition_; | 1373 WindowOpenDisposition last_blocked_command_disposition_; |
1413 | 1374 |
1414 // Different types of action when web app info is available. | |
1415 // OnDidGetApplicationInfo uses this to dispatch calls. | |
1416 enum WebAppAction { | |
1417 NONE, // No action at all. | |
1418 CREATE_SHORTCUT, // Bring up create application shortcut dialog. | |
1419 UPDATE_SHORTCUT // Update icon for app shortcut. | |
1420 }; | |
1421 | |
1422 // Which deferred action to perform when OnDidGetApplicationInfo is notified | 1375 // Which deferred action to perform when OnDidGetApplicationInfo is notified |
1423 // from a WebContents. Currently, only one pending action is allowed. | 1376 // from a WebContents. Currently, only one pending action is allowed. |
1424 WebAppAction pending_web_app_action_; | 1377 WebAppAction pending_web_app_action_; |
1425 | 1378 |
1426 // The profile's tab restore service. The service is owned by the profile, | 1379 // The profile's tab restore service. The service is owned by the profile, |
1427 // and we install ourselves as an observer. | 1380 // and we install ourselves as an observer. |
1428 TabRestoreService* tab_restore_service_; | 1381 TabRestoreService* tab_restore_service_; |
1429 | 1382 |
1430 // Helper which implements the ContentSettingBubbleModel interface. | 1383 // Helper which implements the ContentSettingBubbleModel interface. |
1431 scoped_ptr<BrowserContentSettingBubbleModelDelegate> | 1384 scoped_ptr<BrowserContentSettingBubbleModelDelegate> |
(...skipping 21 matching lines...) Expand all Loading... |
1453 bool window_has_shown_; | 1406 bool window_has_shown_; |
1454 | 1407 |
1455 // Currently open color chooser. Non-NULL after OpenColorChooser is called and | 1408 // Currently open color chooser. Non-NULL after OpenColorChooser is called and |
1456 // before DidEndColorChooser is called. | 1409 // before DidEndColorChooser is called. |
1457 scoped_ptr<content::ColorChooser> color_chooser_; | 1410 scoped_ptr<content::ColorChooser> color_chooser_; |
1458 | 1411 |
1459 DISALLOW_COPY_AND_ASSIGN(Browser); | 1412 DISALLOW_COPY_AND_ASSIGN(Browser); |
1460 }; | 1413 }; |
1461 | 1414 |
1462 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 1415 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
OLD | NEW |