 Chromium Code Reviews
 Chromium Code Reviews Issue 5610005:
  Makes instant run before unload listeners.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome
    
  
    Issue 5610005:
  Makes instant run before unload listeners.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome| Index: chrome/browser/instant/instant_unload_handler.h | 
| diff --git a/chrome/browser/instant/instant_unload_handler.h b/chrome/browser/instant/instant_unload_handler.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..aaad2be77f61b7ce3340fa97d585ac9f08ed7ece | 
| --- /dev/null | 
| +++ b/chrome/browser/instant/instant_unload_handler.h | 
| @@ -0,0 +1,46 @@ | 
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef CHROME_BROWSER_INSTANT_INSTANT_UNLOAD_HANDLER_H_ | 
| +#define CHROME_BROWSER_INSTANT_INSTANT_UNLOAD_HANDLER_H_ | 
| +#pragma once | 
| + | 
| +#include "base/scoped_vector.h" | 
| + | 
| +class Browser; | 
| +class TabContentsWrapper; | 
| + | 
| +// InstantUnloadHandler makes sure the before unload handler is run when using | 
| 
Charlie Reis
2010/12/08 01:26:12
Shouldn't this class handle unload handlers as wel
 
sky
2010/12/08 03:04:22
Done.
 | 
| +// instant. When the user navigates with instant the existing TabContentsWrapper | 
| 
Charlie Reis
2010/12/08 01:26:12
What does "navigates" mean here?  That the instant
 
sky
2010/12/08 03:04:22
Done.
 
sky
2010/12/08 03:04:22
Done.
 | 
| +// is passed to |Own|. If the tab has no before unload listener the tab is | 
| +// deleted, otherwise the before unload listener is executed. If the before | 
| +// unload listener shows a dialog the tab is added back to the tabstrip. | 
| 
Charlie Reis
2010/12/08 01:26:12
..., next to the new instant page?
 | 
| +class InstantUnloadHandler { | 
| + public: | 
| + explicit InstantUnloadHandler(Browser* browser); | 
| + ~InstantUnloadHandler(); | 
| + | 
| + // See class description for details on what this does. | 
| + void Own(TabContentsWrapper* tab_contents, int index); | 
| 
Charlie Reis
2010/12/08 01:26:12
This name isn't really indicative of what's going
 
sky
2010/12/08 03:04:22
I'm open to another name, but AttemptTransition do
 
Charlie Reis
2010/12/08 05:50:11
I like it.  Don't forget to update the class-level
 | 
| + | 
| + private: | 
| + class TabContentsDelegateImpl; | 
| + | 
| + // Invoked if the tab is to be shown. This happens if the before unload | 
| + // listener returns a string. | 
| + void Activate(TabContentsDelegateImpl* delegate); | 
| + | 
| + // Destroys the tab. This is invoked if script tries to close the page. | 
| 
Charlie Reis
2010/12/08 01:26:12
Are you referring to window.close() within the bef
 
sky
2010/12/08 03:04:22
All methods here refer to the previous page, the o
 
Charlie Reis
2010/12/08 05:50:11
Saying "old" in the comment helps already, or you
 | 
| + void Destroy(TabContentsDelegateImpl* delegate); | 
| + | 
| + // TODO(sky): browser really needs to wait to close until there are no more | 
| + // tabs managed by InstantUnloadHandler. | 
| 
Charlie Reis
2010/12/08 01:26:12
Are there memory problems waiting to happen becaus
 
sky
2010/12/08 03:04:22
Not that I'm aware of.
Browser owns this object,
 
Charlie Reis
2010/12/08 05:50:11
Ah, yes, that will be important to resolve.  Later
 | 
| + Browser* browser_; | 
| + | 
| + ScopedVector<TabContentsDelegateImpl> delegates_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(InstantUnloadHandler); | 
| +}; | 
| + | 
| +#endif // CHROME_BROWSER_INSTANT_INSTANT_UNLOAD_HANDLER_H_ |