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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 class PrefService; | 61 class PrefService; |
62 class Profile; | 62 class Profile; |
63 class SkBitmap; | 63 class SkBitmap; |
64 class StatusBubble; | 64 class StatusBubble; |
65 class TabNavigation; | 65 class TabNavigation; |
66 class TabStripModel; | 66 class TabStripModel; |
67 struct WebApplicationInfo; | 67 struct WebApplicationInfo; |
68 | 68 |
69 namespace chrome { | 69 namespace chrome { |
70 class BrowserCommandController; | 70 class BrowserCommandController; |
| 71 class UnloadController; |
71 namespace search { | 72 namespace search { |
72 class SearchDelegate; | 73 class SearchDelegate; |
73 class SearchModel; | 74 class SearchModel; |
74 } | 75 } |
75 } | 76 } |
76 | 77 |
77 namespace content { | 78 namespace content { |
78 class NavigationController; | 79 class NavigationController; |
79 class SessionStorageNamespace; | 80 class SessionStorageNamespace; |
80 } | 81 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 string16 GetWindowTitleForCurrentTab() const; | 300 string16 GetWindowTitleForCurrentTab() const; |
300 | 301 |
301 // Prepares a title string for display (removes embedded newlines, etc). | 302 // Prepares a title string for display (removes embedded newlines, etc). |
302 static void FormatTitleForDisplay(string16* title); | 303 static void FormatTitleForDisplay(string16* title); |
303 | 304 |
304 // OnBeforeUnload handling ////////////////////////////////////////////////// | 305 // OnBeforeUnload handling ////////////////////////////////////////////////// |
305 | 306 |
306 // Gives beforeunload handlers the chance to cancel the close. | 307 // Gives beforeunload handlers the chance to cancel the close. |
307 bool ShouldCloseWindow(); | 308 bool ShouldCloseWindow(); |
308 | 309 |
309 bool IsAttemptingToCloseBrowser() const { | 310 bool IsAttemptingToCloseBrowser() const; |
310 return is_attempting_to_close_browser_; | |
311 } | |
312 | 311 |
313 // Invoked when the window containing us is closing. Performs the necessary | 312 // Invoked when the window containing us is closing. Performs the necessary |
314 // cleanup. | 313 // cleanup. |
315 void OnWindowClosing(); | 314 void OnWindowClosing(); |
316 | 315 |
317 // OnWindowActivationChanged handling /////////////////////////////////////// | 316 // OnWindowActivationChanged handling /////////////////////////////////////// |
318 | 317 |
319 // Invoked when the window containing us is activated. | 318 // Invoked when the window containing us is activated. |
320 void OnWindowActivated(); | 319 void OnWindowActivated(); |
321 | 320 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 // this to return NULL if called before the toolbar has initialized. | 788 // this to return NULL if called before the toolbar has initialized. |
790 // TODO(beng): remove this. | 789 // TODO(beng): remove this. |
791 StatusBubble* GetStatusBubble(); | 790 StatusBubble* GetStatusBubble(); |
792 | 791 |
793 // Session restore functions //////////////////////////////////////////////// | 792 // Session restore functions //////////////////////////////////////////////// |
794 | 793 |
795 // Notifies the history database of the index for all tabs whose index is | 794 // Notifies the history database of the index for all tabs whose index is |
796 // >= index. | 795 // >= index. |
797 void SyncHistoryWithTabs(int index); | 796 void SyncHistoryWithTabs(int index); |
798 | 797 |
799 // OnBeforeUnload handling ////////////////////////////////////////////////// | |
800 | |
801 typedef std::set<content::WebContents*> UnloadListenerSet; | |
802 | |
803 // Processes the next tab that needs it's beforeunload/unload event fired. | |
804 void ProcessPendingTabs(); | |
805 | |
806 // Whether we've completed firing all the tabs' beforeunload/unload events. | |
807 bool HasCompletedUnloadProcessing() const; | |
808 | |
809 // Clears all the state associated with processing tabs' beforeunload/unload | |
810 // events since the user cancelled closing the window. | |
811 void CancelWindowClose(); | |
812 | |
813 // Removes |web_contents| from the passed |set|. | |
814 // Returns whether the tab was in the set in the first place. | |
815 // TODO(beng): this method needs a better name! | |
816 bool RemoveFromSet(UnloadListenerSet* set, | |
817 content::WebContents* web_contents); | |
818 | |
819 // Cleans up state appropriately when we are trying to close the browser and | |
820 // the tab has finished firing its unload handler. We also use this in the | |
821 // cases where a tab crashes or hangs even if the beforeunload/unload haven't | |
822 // successfully fired. If |process_now| is true |ProcessPendingTabs| is | |
823 // invoked immediately, otherwise it is invoked after a delay (PostTask). | |
824 // | |
825 // Typically you'll want to pass in true for |process_now|. Passing in true | |
826 // may result in deleting |tab|. If you know that shouldn't happen (because of | |
827 // the state of the stack), pass in false. | |
828 void ClearUnloadState(content::WebContents* web_contents, bool process_now); | |
829 | |
830 // In-progress download termination handling ///////////////////////////////// | 798 // In-progress download termination handling ///////////////////////////////// |
831 | 799 |
832 // Called when the window is closing to check if potential in-progress | 800 // Called when the window is closing to check if potential in-progress |
833 // downloads should prevent it from closing. | 801 // downloads should prevent it from closing. |
834 // Returns true if the window can close, false otherwise. | 802 // Returns true if the window can close, false otherwise. |
835 bool CanCloseWithInProgressDownloads(); | 803 bool CanCloseWithInProgressDownloads(); |
836 | 804 |
837 // Assorted utility functions /////////////////////////////////////////////// | 805 // Assorted utility functions /////////////////////////////////////////////// |
838 | 806 |
839 // Sets the delegate of all the parts of the TabContents that | 807 // Sets the delegate of all the parts of the TabContents that |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 | 896 |
929 // Maps from WebContents to pending UI updates that need to be processed. | 897 // Maps from WebContents to pending UI updates that need to be processed. |
930 // We don't update things like the URL or tab title right away to avoid | 898 // We don't update things like the URL or tab title right away to avoid |
931 // flickering and extra painting. | 899 // flickering and extra painting. |
932 // See ScheduleUIUpdate and ProcessPendingUIUpdates. | 900 // See ScheduleUIUpdate and ProcessPendingUIUpdates. |
933 UpdateMap scheduled_updates_; | 901 UpdateMap scheduled_updates_; |
934 | 902 |
935 // The following factory is used for chrome update coalescing. | 903 // The following factory is used for chrome update coalescing. |
936 base::WeakPtrFactory<Browser> chrome_updater_factory_; | 904 base::WeakPtrFactory<Browser> chrome_updater_factory_; |
937 | 905 |
938 // OnBeforeUnload handling ////////////////////////////////////////////////// | |
939 | |
940 // Tracks tabs that need there beforeunload event fired before we can | |
941 // close the browser. Only gets populated when we try to close the browser. | |
942 UnloadListenerSet tabs_needing_before_unload_fired_; | |
943 | |
944 // Tracks tabs that need there unload event fired before we can | |
945 // close the browser. Only gets populated when we try to close the browser. | |
946 UnloadListenerSet tabs_needing_unload_fired_; | |
947 | |
948 // Whether we are processing the beforeunload and unload events of each tab | |
949 // in preparation for closing the browser. | |
950 bool is_attempting_to_close_browser_; | |
951 | |
952 // In-progress download termination handling ///////////////////////////////// | 906 // In-progress download termination handling ///////////////////////////////// |
953 | 907 |
954 enum CancelDownloadConfirmationState { | 908 enum CancelDownloadConfirmationState { |
955 NOT_PROMPTED, // We have not asked the user. | 909 NOT_PROMPTED, // We have not asked the user. |
956 WAITING_FOR_RESPONSE, // We have asked the user and have not received a | 910 WAITING_FOR_RESPONSE, // We have asked the user and have not received a |
957 // reponse yet. | 911 // reponse yet. |
958 RESPONSE_RECEIVED // The user was prompted and made a decision already. | 912 RESPONSE_RECEIVED // The user was prompted and made a decision already. |
959 }; | 913 }; |
960 | 914 |
961 // State used to figure-out whether we should prompt the user for confirmation | 915 // State used to figure-out whether we should prompt the user for confirmation |
962 // when the browser is closed with in-progress downloads. | 916 // when the browser is closed with in-progress downloads. |
963 CancelDownloadConfirmationState cancel_download_confirmation_state_; | 917 CancelDownloadConfirmationState cancel_download_confirmation_state_; |
964 | 918 |
965 ///////////////////////////////////////////////////////////////////////////// | 919 ///////////////////////////////////////////////////////////////////////////// |
966 | 920 |
967 // Override values for the bounds of the window and its maximized or minimized | 921 // Override values for the bounds of the window and its maximized or minimized |
968 // state. | 922 // state. |
969 // These are supplied by callers that don't want to use the default values. | 923 // These are supplied by callers that don't want to use the default values. |
970 // The default values are typically loaded from local state (last session), | 924 // The default values are typically loaded from local state (last session), |
971 // obtained from the last window of the same type, or obtained from the | 925 // obtained from the last window of the same type, or obtained from the |
972 // shell shortcut's startup info. | 926 // shell shortcut's startup info. |
973 gfx::Rect override_bounds_; | 927 gfx::Rect override_bounds_; |
974 ui::WindowShowState initial_show_state_; | 928 ui::WindowShowState initial_show_state_; |
975 | 929 |
976 // Tracks when this browser is being created by session restore. | 930 // Tracks when this browser is being created by session restore. |
977 bool is_session_restore_; | 931 bool is_session_restore_; |
978 | 932 |
| 933 scoped_ptr<chrome::UnloadController> unload_controller_; |
| 934 |
979 // The following factory is used to close the frame at a later time. | 935 // The following factory is used to close the frame at a later time. |
980 base::WeakPtrFactory<Browser> weak_factory_; | 936 base::WeakPtrFactory<Browser> weak_factory_; |
981 | 937 |
982 // The Find Bar. This may be NULL if there is no Find Bar, and if it is | 938 // The Find Bar. This may be NULL if there is no Find Bar, and if it is |
983 // non-NULL, it may or may not be visible. | 939 // non-NULL, it may or may not be visible. |
984 scoped_ptr<FindBarController> find_bar_controller_; | 940 scoped_ptr<FindBarController> find_bar_controller_; |
985 | 941 |
986 // Dialog box used for opening and saving files. | 942 // Dialog box used for opening and saving files. |
987 scoped_refptr<SelectFileDialog> select_file_dialog_; | 943 scoped_refptr<SelectFileDialog> select_file_dialog_; |
988 | 944 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 bool window_has_shown_; | 978 bool window_has_shown_; |
1023 | 979 |
1024 // Currently open color chooser. Non-NULL after OpenColorChooser is called and | 980 // Currently open color chooser. Non-NULL after OpenColorChooser is called and |
1025 // before DidEndColorChooser is called. | 981 // before DidEndColorChooser is called. |
1026 scoped_ptr<content::ColorChooser> color_chooser_; | 982 scoped_ptr<content::ColorChooser> color_chooser_; |
1027 | 983 |
1028 DISALLOW_COPY_AND_ASSIGN(Browser); | 984 DISALLOW_COPY_AND_ASSIGN(Browser); |
1029 }; | 985 }; |
1030 | 986 |
1031 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 987 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
OLD | NEW |