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

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

Issue 62131: Ask for user confirmation when closing a browser with in-progress downloads (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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/app/generated_resources.grd ('k') | chrome/browser/browser.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 (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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_BROWSER_H_ 5 #ifndef CHROME_BROWSER_BROWSER_H_
6 #define CHROME_BROWSER_BROWSER_H_ 6 #define CHROME_BROWSER_BROWSER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 9
10 #include <set> 10 #include <set>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // OnBeforeUnload handling ////////////////////////////////////////////////// 176 // OnBeforeUnload handling //////////////////////////////////////////////////
177 177
178 // Gives beforeunload handlers the chance to cancel the close. 178 // Gives beforeunload handlers the chance to cancel the close.
179 bool ShouldCloseWindow(); 179 bool ShouldCloseWindow();
180 180
181 // Invoked when the window containing us is closing. Performs the necessary 181 // Invoked when the window containing us is closing. Performs the necessary
182 // cleanup. 182 // cleanup.
183 void OnWindowClosing(); 183 void OnWindowClosing();
184 184
185 // In-progress download termination handling /////////////////////////////////
186
187 // Called when the user has decided whether to proceed or not with the browser
188 // closure. |cancel_downloads| is true if the downloads should be canceled
189 // and the browser closed, false if the browser should stay open and the
190 // downloads running.
191 void InProgressDownloadResponse(bool cancel_downloads);
192
185 // TabStripModel pass-thrus ///////////////////////////////////////////////// 193 // TabStripModel pass-thrus /////////////////////////////////////////////////
186 194
187 TabStripModel* tabstrip_model() const { 195 TabStripModel* tabstrip_model() const {
188 return const_cast<TabStripModel*>(&tabstrip_model_); 196 return const_cast<TabStripModel*>(&tabstrip_model_);
189 } 197 }
190 198
191 int tab_count() const { return tabstrip_model_.count(); } 199 int tab_count() const { return tabstrip_model_.count(); }
192 int selected_index() const { return tabstrip_model_.selected_index(); } 200 int selected_index() const { return tabstrip_model_.selected_index(); }
193 int GetIndexOfController(const NavigationController* controller) const { 201 int GetIndexOfController(const NavigationController* controller) const {
194 return tabstrip_model_.GetIndexOfController(controller); 202 return tabstrip_model_.GetIndexOfController(controller);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // Returns whether the tab was in the set in the first place. 542 // Returns whether the tab was in the set in the first place.
535 // TODO(beng): this method needs a better name! 543 // TODO(beng): this method needs a better name!
536 bool RemoveFromSet(UnloadListenerSet* set, TabContents* tab); 544 bool RemoveFromSet(UnloadListenerSet* set, TabContents* tab);
537 545
538 // Cleans up state appropriately when we are trying to close the browser and 546 // Cleans up state appropriately when we are trying to close the browser and
539 // the tab has finished firing its unload handler. We also use this in the 547 // the tab has finished firing its unload handler. We also use this in the
540 // cases where a tab crashes or hangs even if the beforeunload/unload haven't 548 // cases where a tab crashes or hangs even if the beforeunload/unload haven't
541 // successfully fired. 549 // successfully fired.
542 void ClearUnloadState(TabContents* tab); 550 void ClearUnloadState(TabContents* tab);
543 551
552 // In-progress download termination handling /////////////////////////////////
553
554 // Called when the window is closing to check if potential in-progress
555 // downloads should prevent it from closing.
556 // Returns true if the window can close, false otherwise.
557 bool CanCloseWithInProgressDownloads();
558
544 // Assorted utility functions /////////////////////////////////////////////// 559 // Assorted utility functions ///////////////////////////////////////////////
545 560
546 // Retrieve the last active tabbed browser with the same profile as the 561 // Retrieve the last active tabbed browser with the same profile as the
547 // receiving Browser. Creates a new Browser if none are available. 562 // receiving Browser. Creates a new Browser if none are available.
548 Browser* GetOrCreateTabbedBrowser(); 563 Browser* GetOrCreateTabbedBrowser();
549 564
550 // Creates a new popup window with its own Browser object with the 565 // Creates a new popup window with its own Browser object with the
551 // incoming sizing information. |initial_pos|'s origin() is the 566 // incoming sizing information. |initial_pos|'s origin() is the
552 // window origin, and its size() is the size of the content area. 567 // window origin, and its size() is the size of the content area.
553 void BuildPopupWindow(TabContents* source, 568 void BuildPopupWindow(TabContents* source,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 UnloadListenerSet tabs_needing_before_unload_fired_; 663 UnloadListenerSet tabs_needing_before_unload_fired_;
649 664
650 // Tracks tabs that need there unload event fired before we can 665 // Tracks tabs that need there unload event fired before we can
651 // close the browser. Only gets populated when we try to close the browser. 666 // close the browser. Only gets populated when we try to close the browser.
652 UnloadListenerSet tabs_needing_unload_fired_; 667 UnloadListenerSet tabs_needing_unload_fired_;
653 668
654 // Whether we are processing the beforeunload and unload events of each tab 669 // Whether we are processing the beforeunload and unload events of each tab
655 // in preparation for closing the browser. 670 // in preparation for closing the browser.
656 bool is_attempting_to_close_browser_; 671 bool is_attempting_to_close_browser_;
657 672
673 // In-progress download termination handling /////////////////////////////////
674
675 enum CancelDownloadConfirmationState {
676 NOT_PROMPTED, // We have not asked the user.
677 WAITING_FOR_RESPONSE, // We have asked the user and have not received a
678 // reponse yet.
679 RESPONSE_RECEIVED // The user was prompted and made a decision already.
680 };
681
682 // State used to figure-out whether we should prompt the user for confirmation
683 // when the browser is closed with in-progress downloads.
684 CancelDownloadConfirmationState cancel_download_confirmation_state_;
685
658 ///////////////////////////////////////////////////////////////////////////// 686 /////////////////////////////////////////////////////////////////////////////
659 687
660 // Override values for the bounds of the window and its maximized state. 688 // Override values for the bounds of the window and its maximized state.
661 // These are supplied by callers that don't want to use the default values. 689 // These are supplied by callers that don't want to use the default values.
662 // The default values are typically loaded from local state (last session), 690 // The default values are typically loaded from local state (last session),
663 // obtained from the last window of the same type, or obtained from the 691 // obtained from the last window of the same type, or obtained from the
664 // shell shortcut's startup info. 692 // shell shortcut's startup info.
665 gfx::Rect override_bounds_; 693 gfx::Rect override_bounds_;
666 MaximizedState maximized_state_; 694 MaximizedState maximized_state_;
667 695
(...skipping 13 matching lines...) Expand all
681 // The browser idle task helps cleanup unused memory resources when idle. 709 // The browser idle task helps cleanup unused memory resources when idle.
682 scoped_ptr<BrowserIdleTimer> idle_task_; 710 scoped_ptr<BrowserIdleTimer> idle_task_;
683 711
684 // Keep track of the encoding auto detect pref. 712 // Keep track of the encoding auto detect pref.
685 BooleanPrefMember encoding_auto_detect_; 713 BooleanPrefMember encoding_auto_detect_;
686 714
687 DISALLOW_COPY_AND_ASSIGN(Browser); 715 DISALLOW_COPY_AND_ASSIGN(Browser);
688 }; 716 };
689 717
690 #endif // CHROME_BROWSER_BROWSER_H_ 718 #endif // CHROME_BROWSER_BROWSER_H_
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698