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

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 9271054: Send replies to sync IPCs from swapped out renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Send JS replies to right RVH. Created 8 years, 11 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 | « content/browser/tab_contents/tab_contents.h ('k') | content/common/swapped_out_messages.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 "content/browser/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 DidOpenRequestedURL(new_contents, 2001 DidOpenRequestedURL(new_contents,
2002 url, 2002 url,
2003 referrer, 2003 referrer,
2004 disposition, 2004 disposition,
2005 transition_type, 2005 transition_type,
2006 source_frame_id)); 2006 source_frame_id));
2007 } 2007 }
2008 } 2008 }
2009 2009
2010 void TabContents::RunJavaScriptMessage( 2010 void TabContents::RunJavaScriptMessage(
2011 const RenderViewHost* rvh, 2011 RenderViewHost* rvh,
2012 const string16& message, 2012 const string16& message,
2013 const string16& default_prompt, 2013 const string16& default_prompt,
2014 const GURL& frame_url, 2014 const GURL& frame_url,
2015 ui::JavascriptMessageType javascript_message_type, 2015 ui::JavascriptMessageType javascript_message_type,
2016 IPC::Message* reply_msg, 2016 IPC::Message* reply_msg,
2017 bool* did_suppress_message) { 2017 bool* did_suppress_message) {
2018 // Suppress JavaScript dialogs when requested. Also suppress messages when 2018 // Suppress JavaScript dialogs when requested. Also suppress messages when
2019 // showing an interstitial as it's shown over the previous page and we don't 2019 // showing an interstitial as it's shown over the previous page and we don't
2020 // want the hidden page's dialogs to interfere with the interstitial. 2020 // want the hidden page's dialogs to interfere with the interstitial.
2021 bool suppress_this_message = 2021 bool suppress_this_message =
(...skipping 23 matching lines...) Expand all
2045 javascript_message_type, 2045 javascript_message_type,
2046 message, 2046 message,
2047 default_prompt, 2047 default_prompt,
2048 reply_msg, 2048 reply_msg,
2049 &suppress_this_message); 2049 &suppress_this_message);
2050 } 2050 }
2051 2051
2052 if (suppress_this_message) { 2052 if (suppress_this_message) {
2053 // If we are suppressing messages, just reply as if the user immediately 2053 // If we are suppressing messages, just reply as if the user immediately
2054 // pressed "Cancel". 2054 // pressed "Cancel".
2055 OnDialogClosed(reply_msg, false, string16()); 2055 OnDialogClosed(rvh, reply_msg, false, string16());
2056 } 2056 }
2057 2057
2058 *did_suppress_message = suppress_this_message; 2058 *did_suppress_message = suppress_this_message;
2059 } 2059 }
2060 2060
2061 void TabContents::RunBeforeUnloadConfirm(const RenderViewHost* rvh, 2061 void TabContents::RunBeforeUnloadConfirm(RenderViewHost* rvh,
2062 const string16& message, 2062 const string16& message,
2063 IPC::Message* reply_msg) { 2063 IPC::Message* reply_msg) {
2064 if (delegate_) 2064 if (delegate_)
2065 delegate_->WillRunBeforeUnloadConfirm(); 2065 delegate_->WillRunBeforeUnloadConfirm();
2066 2066
2067 bool suppress_this_message = 2067 bool suppress_this_message =
2068 rvh->is_swapped_out() || 2068 rvh->is_swapped_out() ||
2069 !delegate_ || 2069 !delegate_ ||
2070 delegate_->ShouldSuppressDialogs(); 2070 delegate_->ShouldSuppressDialogs();
2071 if (suppress_this_message) { 2071 if (suppress_this_message) {
2072 GetRenderViewHost()->JavaScriptDialogClosed(reply_msg, true, string16()); 2072 // The reply must be sent to the RVH that sent the request.
2073 rvh->JavaScriptDialogClosed(reply_msg, true, string16());
2073 return; 2074 return;
2074 } 2075 }
2075 2076
2076 is_showing_before_unload_dialog_ = true; 2077 is_showing_before_unload_dialog_ = true;
2077 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); 2078 dialog_creator_ = delegate_->GetJavaScriptDialogCreator();
2078 dialog_creator_->RunBeforeUnloadDialog(this, 2079 dialog_creator_->RunBeforeUnloadDialog(this,
2079 message, 2080 message,
2080 reply_msg); 2081 reply_msg);
2081 } 2082 }
2082 2083
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 // linux. See crbug.com/83941. 2249 // linux. See crbug.com/83941.
2249 if (rwh_view) { 2250 if (rwh_view) {
2250 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) 2251 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost())
2251 render_widget_host->WasResized(); 2252 render_widget_host->WasResized();
2252 } 2253 }
2253 #endif 2254 #endif
2254 2255
2255 return true; 2256 return true;
2256 } 2257 }
2257 2258
2258 void TabContents::OnDialogClosed(IPC::Message* reply_msg, 2259 void TabContents::OnDialogClosed(RenderViewHost* rvh,
2260 IPC::Message* reply_msg,
2259 bool success, 2261 bool success,
2260 const string16& user_input) { 2262 const string16& user_input) {
2261 if (is_showing_before_unload_dialog_ && !success) { 2263 if (is_showing_before_unload_dialog_ && !success) {
2262 // If a beforeunload dialog is canceled, we need to stop the throbber from 2264 // If a beforeunload dialog is canceled, we need to stop the throbber from
2263 // spinning, since we forced it to start spinning in Navigate. 2265 // spinning, since we forced it to start spinning in Navigate.
2264 DidStopLoading(); 2266 DidStopLoading();
2265 2267
2266 tab_close_start_time_ = base::TimeTicks(); 2268 tab_close_start_time_ = base::TimeTicks();
2267 } 2269 }
2268 is_showing_before_unload_dialog_ = false; 2270 is_showing_before_unload_dialog_ = false;
2269 GetRenderViewHost()->JavaScriptDialogClosed(reply_msg, success, user_input); 2271 // The reply must be sent to the RVH that sent the request.
2272 // TODO(creis): Eliminate cases where we pass in null.
2273 if (!rvh)
2274 rvh = GetRenderViewHost();
2275 rvh->JavaScriptDialogClosed(reply_msg, success, user_input);
2270 } 2276 }
2271 2277
2272 gfx::NativeWindow TabContents::GetDialogRootWindow() const { 2278 gfx::NativeWindow TabContents::GetDialogRootWindow() const {
2273 return view_->GetTopLevelNativeWindow(); 2279 return view_->GetTopLevelNativeWindow();
2274 } 2280 }
2275 2281
2276 void TabContents::OnDialogShown() { 2282 void TabContents::OnDialogShown() {
2277 Activate(); 2283 Activate();
2278 } 2284 }
2279 2285
2280 void TabContents::SetEncoding(const std::string& encoding) { 2286 void TabContents::SetEncoding(const std::string& encoding) {
2281 encoding_ = content::GetContentClient()->browser()-> 2287 encoding_ = content::GetContentClient()->browser()->
2282 GetCanonicalEncodingNameByAliasName(encoding); 2288 GetCanonicalEncodingNameByAliasName(encoding);
2283 } 2289 }
2284 2290
2285 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 2291 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
2286 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); 2292 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh);
2287 // Can be NULL during tests. 2293 // Can be NULL during tests.
2288 if (rwh_view) 2294 if (rwh_view)
2289 rwh_view->SetSize(GetView()->GetContainerSize()); 2295 rwh_view->SetSize(GetView()->GetContainerSize());
2290 } 2296 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/common/swapped_out_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698