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

Side by Side Diff: chrome/browser/instant/instant_unload_handler.cc

Issue 10107002: TabContents -> WebContentsImpl, part 18. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/browser/instant/instant_loader_delegate.h ('k') | chrome/browser/memory_details.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) 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 #include "chrome/browser/instant/instant_unload_handler.h" 5 #include "chrome/browser/instant/instant_unload_handler.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_navigator.h" 8 #include "chrome/browser/ui/browser_navigator.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
11 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_contents_delegate.h" 12 #include "content/public/browser/web_contents_delegate.h"
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 using content::WebContents; 16 using content::WebContents;
17 17
18 // TabContentsDelegate implementation. This owns the TabContents supplied to the 18 // TabContentsDelegate implementation. This owns the TabContentsWrapper supplied
19 // constructor. 19 // to the constructor.
20 class InstantUnloadHandler::TabContentsDelegateImpl 20 class InstantUnloadHandler::TabContentsDelegateImpl
21 : public content::WebContentsDelegate { 21 : public content::WebContentsDelegate {
22 public: 22 public:
23 TabContentsDelegateImpl(InstantUnloadHandler* handler, 23 TabContentsDelegateImpl(InstantUnloadHandler* handler,
24 TabContentsWrapper* tab_contents, 24 TabContentsWrapper* tab_contents,
25 int index) 25 int index)
26 : handler_(handler), 26 : handler_(handler),
27 tab_contents_(tab_contents), 27 tab_contents_(tab_contents),
28 index_(index) { 28 index_(index) {
29 tab_contents->web_contents()->SetDelegate(this); 29 tab_contents->web_contents()->SetDelegate(this);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 TabContentsDelegateImpl* delegate = 86 TabContentsDelegateImpl* delegate =
87 new TabContentsDelegateImpl(this, tab, index); 87 new TabContentsDelegateImpl(this, tab, index);
88 delegates_.push_back(delegate); 88 delegates_.push_back(delegate);
89 // TODO: decide if we really want false here. false is used for tab closes, 89 // TODO: decide if we really want false here. false is used for tab closes,
90 // and is needed so that the tab correctly closes but it doesn't really match 90 // and is needed so that the tab correctly closes but it doesn't really match
91 // what's logically happening. 91 // what's logically happening.
92 tab->web_contents()->GetRenderViewHost()->FirePageBeforeUnload(false); 92 tab->web_contents()->GetRenderViewHost()->FirePageBeforeUnload(false);
93 } 93 }
94 94
95 void InstantUnloadHandler::Activate(TabContentsDelegateImpl* delegate) { 95 void InstantUnloadHandler::Activate(TabContentsDelegateImpl* delegate) {
96 // Take ownership of the TabContents from the delegate. 96 // Take ownership of the TabContentsWrapper from the delegate.
97 TabContentsWrapper* tab = delegate->ReleaseTab(); 97 TabContentsWrapper* tab = delegate->ReleaseTab();
98 browser::NavigateParams params(browser_, tab); 98 browser::NavigateParams params(browser_, tab);
99 params.disposition = NEW_FOREGROUND_TAB; 99 params.disposition = NEW_FOREGROUND_TAB;
100 params.tabstrip_index = delegate->index(); 100 params.tabstrip_index = delegate->index();
101 101
102 // Remove (and delete) the delegate. 102 // Remove (and delete) the delegate.
103 ScopedVector<TabContentsDelegateImpl>::iterator i = 103 ScopedVector<TabContentsDelegateImpl>::iterator i =
104 std::find(delegates_.begin(), delegates_.end(), delegate); 104 std::find(delegates_.begin(), delegates_.end(), delegate);
105 DCHECK(i != delegates_.end()); 105 DCHECK(i != delegates_.end());
106 delegates_.erase(i); 106 delegates_.erase(i);
107 delegate = NULL; 107 delegate = NULL;
108 108
109 // Add the tab back in. 109 // Add the tab back in.
110 browser::Navigate(&params); 110 browser::Navigate(&params);
111 } 111 }
112 112
113 void InstantUnloadHandler::Destroy(TabContentsDelegateImpl* delegate) { 113 void InstantUnloadHandler::Destroy(TabContentsDelegateImpl* delegate) {
114 ScopedVector<TabContentsDelegateImpl>::iterator i = 114 ScopedVector<TabContentsDelegateImpl>::iterator i =
115 std::find(delegates_.begin(), delegates_.end(), delegate); 115 std::find(delegates_.begin(), delegates_.end(), delegate);
116 DCHECK(i != delegates_.end()); 116 DCHECK(i != delegates_.end());
117 delegates_.erase(i); 117 delegates_.erase(i);
118 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/instant/instant_loader_delegate.h ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698