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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 12082123: Rename JavaScriptDialogCreator to JavaScriptDialogManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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/web_contents/web_contents_impl.h ('k') | content/content_browser.gypi » ('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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/port/browser/render_view_host_delegate_view.h" 48 #include "content/port/browser/render_view_host_delegate_view.h"
49 #include "content/port/browser/render_widget_host_view_port.h" 49 #include "content/port/browser/render_widget_host_view_port.h"
50 #include "content/public/browser/browser_context.h" 50 #include "content/public/browser/browser_context.h"
51 #include "content/public/browser/color_chooser.h" 51 #include "content/public/browser/color_chooser.h"
52 #include "content/public/browser/compositor_util.h" 52 #include "content/public/browser/compositor_util.h"
53 #include "content/public/browser/content_browser_client.h" 53 #include "content/public/browser/content_browser_client.h"
54 #include "content/public/browser/devtools_agent_host.h" 54 #include "content/public/browser/devtools_agent_host.h"
55 #include "content/public/browser/download_manager.h" 55 #include "content/public/browser/download_manager.h"
56 #include "content/public/browser/download_url_parameters.h" 56 #include "content/public/browser/download_url_parameters.h"
57 #include "content/public/browser/invalidate_type.h" 57 #include "content/public/browser/invalidate_type.h"
58 #include "content/public/browser/javascript_dialogs.h" 58 #include "content/public/browser/javascript_dialog_manager.h"
59 #include "content/public/browser/load_from_memory_cache_details.h" 59 #include "content/public/browser/load_from_memory_cache_details.h"
60 #include "content/public/browser/load_notification_details.h" 60 #include "content/public/browser/load_notification_details.h"
61 #include "content/public/browser/navigation_details.h" 61 #include "content/public/browser/navigation_details.h"
62 #include "content/public/browser/notification_details.h" 62 #include "content/public/browser/notification_details.h"
63 #include "content/public/browser/notification_service.h" 63 #include "content/public/browser/notification_service.h"
64 #include "content/public/browser/resource_request_details.h" 64 #include "content/public/browser/resource_request_details.h"
65 #include "content/public/browser/storage_partition.h" 65 #include "content/public/browser/storage_partition.h"
66 #include "content/public/browser/user_metrics.h" 66 #include "content/public/browser/user_metrics.h"
67 #include "content/public/browser/web_contents_delegate.h" 67 #include "content/public/browser/web_contents_delegate.h"
68 #include "content/public/browser/web_contents_observer.h" 68 #include "content/public/browser/web_contents_observer.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
306 crashed_error_code_(0), 306 crashed_error_code_(0),
307 waiting_for_response_(false), 307 waiting_for_response_(false),
308 load_state_(net::LOAD_STATE_IDLE, string16()), 308 load_state_(net::LOAD_STATE_IDLE, string16()),
309 upload_size_(0), 309 upload_size_(0),
310 upload_position_(0), 310 upload_position_(0),
311 displayed_insecure_content_(false), 311 displayed_insecure_content_(false),
312 capturing_contents_(false), 312 capturing_contents_(false),
313 is_being_destroyed_(false), 313 is_being_destroyed_(false),
314 notify_disconnection_(false), 314 notify_disconnection_(false),
315 dialog_creator_(NULL), 315 dialog_manager_(NULL),
316 is_showing_before_unload_dialog_(false), 316 is_showing_before_unload_dialog_(false),
317 opener_web_ui_type_(WebUI::kNoWebUI), 317 opener_web_ui_type_(WebUI::kNoWebUI),
318 closed_by_user_gesture_(false), 318 closed_by_user_gesture_(false),
319 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 319 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
320 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 320 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
321 temporary_zoom_settings_(false), 321 temporary_zoom_settings_(false),
322 content_restrictions_(0), 322 content_restrictions_(0),
323 color_chooser_(NULL), 323 color_chooser_(NULL),
324 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) { 324 fullscreen_widget_routing_id_(MSG_ROUTING_NONE) {
325 } 325 }
326 326
327 WebContentsImpl::~WebContentsImpl() { 327 WebContentsImpl::~WebContentsImpl() {
328 is_being_destroyed_ = true; 328 is_being_destroyed_ = true;
329 329
330 for (std::set<RenderWidgetHostImpl*>::iterator iter = 330 for (std::set<RenderWidgetHostImpl*>::iterator iter =
331 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { 331 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) {
332 (*iter)->DetachDelegate(); 332 (*iter)->DetachDelegate();
333 } 333 }
334 created_widgets_.clear(); 334 created_widgets_.clear();
335 335
336 // Clear out any JavaScript state. 336 // Clear out any JavaScript state.
337 if (dialog_creator_) 337 if (dialog_manager_)
338 dialog_creator_->ResetJavaScriptState(this); 338 dialog_manager_->ResetJavaScriptState(this);
339 339
340 if (color_chooser_) 340 if (color_chooser_)
341 color_chooser_->End(); 341 color_chooser_->End();
342 342
343 NotifyDisconnected(); 343 NotifyDisconnected();
344 344
345 // Notify any observer that have a reference on this WebContents. 345 // Notify any observer that have a reference on this WebContents.
346 NotificationService::current()->Notify( 346 NotificationService::current()->Notify(
347 NOTIFICATION_WEB_CONTENTS_DESTROYED, 347 NOTIFICATION_WEB_CONTENTS_DESTROYED,
348 Source<WebContents>(this), 348 Source<WebContents>(this),
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 DidNavigateMainFrame(details, params)); 2510 DidNavigateMainFrame(details, params));
2511 } 2511 }
2512 2512
2513 void WebContentsImpl::DidNavigateAnyFramePostCommit( 2513 void WebContentsImpl::DidNavigateAnyFramePostCommit(
2514 RenderViewHost* render_view_host, 2514 RenderViewHost* render_view_host,
2515 const LoadCommittedDetails& details, 2515 const LoadCommittedDetails& details,
2516 const ViewHostMsg_FrameNavigate_Params& params) { 2516 const ViewHostMsg_FrameNavigate_Params& params) {
2517 // If we navigate off the page, reset JavaScript state. This does nothing 2517 // If we navigate off the page, reset JavaScript state. This does nothing
2518 // to prevent a malicious script from spamming messages, since the script 2518 // to prevent a malicious script from spamming messages, since the script
2519 // could just reload the page to stop blocking. 2519 // could just reload the page to stop blocking.
2520 if (dialog_creator_ && !details.is_in_page) { 2520 if (dialog_manager_ && !details.is_in_page) {
2521 dialog_creator_->ResetJavaScriptState(this); 2521 dialog_manager_->ResetJavaScriptState(this);
2522 dialog_creator_ = NULL; 2522 dialog_manager_ = NULL;
2523 } 2523 }
2524 2524
2525 // Notify observers about navigation. 2525 // Notify observers about navigation.
2526 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2526 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2527 DidNavigateAnyFrame(details, params)); 2527 DidNavigateAnyFrame(details, params));
2528 } 2528 }
2529 2529
2530 void WebContentsImpl::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) { 2530 void WebContentsImpl::UpdateMaxPageIDIfNecessary(RenderViewHost* rvh) {
2531 // If we are creating a RVH for a restored controller, then we need to make 2531 // If we are creating a RVH for a restored controller, then we need to make
2532 // sure the RenderView starts with a next_page_id_ larger than the number 2532 // sure the RenderView starts with a next_page_id_ larger than the number
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 IPC::Message* reply_msg, 3114 IPC::Message* reply_msg,
3115 bool* did_suppress_message) { 3115 bool* did_suppress_message) {
3116 // Suppress JavaScript dialogs when requested. Also suppress messages when 3116 // Suppress JavaScript dialogs when requested. Also suppress messages when
3117 // showing an interstitial as it's shown over the previous page and we don't 3117 // showing an interstitial as it's shown over the previous page and we don't
3118 // want the hidden page's dialogs to interfere with the interstitial. 3118 // want the hidden page's dialogs to interfere with the interstitial.
3119 bool suppress_this_message = 3119 bool suppress_this_message =
3120 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || 3120 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() ||
3121 ShowingInterstitialPage() || 3121 ShowingInterstitialPage() ||
3122 !delegate_ || 3122 !delegate_ ||
3123 delegate_->ShouldSuppressDialogs() || 3123 delegate_->ShouldSuppressDialogs() ||
3124 !delegate_->GetJavaScriptDialogCreator(); 3124 !delegate_->GetJavaScriptDialogManager();
3125 3125
3126 if (!suppress_this_message) { 3126 if (!suppress_this_message) {
3127 std::string accept_lang = GetContentClient()->browser()-> 3127 std::string accept_lang = GetContentClient()->browser()->
3128 GetAcceptLangs(GetBrowserContext()); 3128 GetAcceptLangs(GetBrowserContext());
3129 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); 3129 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
3130 dialog_creator_->RunJavaScriptDialog( 3130 dialog_manager_->RunJavaScriptDialog(
3131 this, 3131 this,
3132 frame_url.GetOrigin(), 3132 frame_url.GetOrigin(),
3133 accept_lang, 3133 accept_lang,
3134 javascript_message_type, 3134 javascript_message_type,
3135 message, 3135 message,
3136 default_prompt, 3136 default_prompt,
3137 base::Bind(&WebContentsImpl::OnDialogClosed, 3137 base::Bind(&WebContentsImpl::OnDialogClosed,
3138 base::Unretained(this), 3138 base::Unretained(this),
3139 rvh, 3139 rvh,
3140 reply_msg), 3140 reply_msg),
(...skipping 14 matching lines...) Expand all
3155 bool is_reload, 3155 bool is_reload,
3156 IPC::Message* reply_msg) { 3156 IPC::Message* reply_msg) {
3157 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); 3157 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
3158 if (delegate_) 3158 if (delegate_)
3159 delegate_->WillRunBeforeUnloadConfirm(); 3159 delegate_->WillRunBeforeUnloadConfirm();
3160 3160
3161 bool suppress_this_message = 3161 bool suppress_this_message =
3162 rvhi->is_swapped_out() || 3162 rvhi->is_swapped_out() ||
3163 !delegate_ || 3163 !delegate_ ||
3164 delegate_->ShouldSuppressDialogs() || 3164 delegate_->ShouldSuppressDialogs() ||
3165 !delegate_->GetJavaScriptDialogCreator(); 3165 !delegate_->GetJavaScriptDialogManager();
3166 if (suppress_this_message) { 3166 if (suppress_this_message) {
3167 // The reply must be sent to the RVH that sent the request. 3167 // The reply must be sent to the RVH that sent the request.
3168 rvhi->JavaScriptDialogClosed(reply_msg, true, string16()); 3168 rvhi->JavaScriptDialogClosed(reply_msg, true, string16());
3169 return; 3169 return;
3170 } 3170 }
3171 3171
3172 is_showing_before_unload_dialog_ = true; 3172 is_showing_before_unload_dialog_ = true;
3173 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); 3173 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
3174 dialog_creator_->RunBeforeUnloadDialog( 3174 dialog_manager_->RunBeforeUnloadDialog(
3175 this, message, is_reload, 3175 this, message, is_reload,
3176 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), rvh, 3176 base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this), rvh,
3177 reply_msg)); 3177 reply_msg));
3178 } 3178 }
3179 3179
3180 bool WebContentsImpl::AddMessageToConsole(int32 level, 3180 bool WebContentsImpl::AddMessageToConsole(int32 level,
3181 const string16& message, 3181 const string16& message,
3182 int32 line_no, 3182 int32 line_no,
3183 const string16& source_id) { 3183 const string16& source_id) {
3184 if (!delegate_) 3184 if (!delegate_)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 3446
3447 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3447 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3448 return browser_plugin_guest_.get(); 3448 return browser_plugin_guest_.get();
3449 } 3449 }
3450 3450
3451 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3451 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3452 return browser_plugin_embedder_.get(); 3452 return browser_plugin_embedder_.get();
3453 } 3453 }
3454 3454
3455 } // namespace content 3455 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698