OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/instant/instant_unload_handler.h" | 5 #include "chrome/browser/instant/instant_unload_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // called twice, leading to double deletion (http://crbug.com/155848). | 32 // called twice, leading to double deletion (http://crbug.com/155848). |
33 contents_->SetDelegate(NULL); | 33 contents_->SetDelegate(NULL); |
34 handler_->Destroy(this); | 34 handler_->Destroy(this); |
35 } | 35 } |
36 | 36 |
37 virtual void WillRunBeforeUnloadConfirm() OVERRIDE { | 37 virtual void WillRunBeforeUnloadConfirm() OVERRIDE { |
38 contents_->SetDelegate(NULL); | 38 contents_->SetDelegate(NULL); |
39 handler_->Activate(this, contents_.Pass(), index_); | 39 handler_->Activate(this, contents_.Pass(), index_); |
40 } | 40 } |
41 | 41 |
42 virtual bool ShouldSuppressDialogs() OVERRIDE { | |
43 return true; | |
44 } | |
45 | |
46 private: | 42 private: |
47 InstantUnloadHandler* const handler_; | 43 InstantUnloadHandler* const handler_; |
48 scoped_ptr<content::WebContents> contents_; | 44 scoped_ptr<content::WebContents> contents_; |
49 | 45 |
50 // The tab strip index |contents_| was originally at. If we add the tab back | 46 // The tab strip index |contents_| was originally at. If we add the tab back |
51 // to the tabstrip, we add it at this index. | 47 // to the tabstrip, we add it at this index. |
52 const int index_; | 48 const int index_; |
53 | 49 |
54 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); | 50 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl); |
55 }; | 51 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { | 93 void InstantUnloadHandler::Destroy(WebContentsDelegateImpl* delegate) { |
98 ScopedVector<WebContentsDelegateImpl>::iterator i = | 94 ScopedVector<WebContentsDelegateImpl>::iterator i = |
99 std::find(delegates_.begin(), delegates_.end(), delegate); | 95 std::find(delegates_.begin(), delegates_.end(), delegate); |
100 DCHECK(i != delegates_.end()); | 96 DCHECK(i != delegates_.end()); |
101 | 97 |
102 // The delegate's method is a caller on the stack, so schedule the deletion | 98 // The delegate's method is a caller on the stack, so schedule the deletion |
103 // for later. | 99 // for later. |
104 delegates_.weak_erase(i); | 100 delegates_.weak_erase(i); |
105 MessageLoop::current()->DeleteSoon(FROM_HERE, delegate); | 101 MessageLoop::current()->DeleteSoon(FROM_HERE, delegate); |
106 } | 102 } |
OLD | NEW |