| OLD | NEW |
| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to | 128 // - Once the onunload handler is finished, a SwapOut_ACK message is sent to |
| 129 // the ResourceDispatcherHost, who unpauses the response. Data is then sent | 129 // the ResourceDispatcherHost, who unpauses the response. Data is then sent |
| 130 // to the pending RVH. | 130 // to the pending RVH. |
| 131 // - The pending renderer sends a FrameNavigate message that invokes the | 131 // - The pending renderer sends a FrameNavigate message that invokes the |
| 132 // DidNavigate method. This replaces the current RVH with the | 132 // DidNavigate method. This replaces the current RVH with the |
| 133 // pending RVH. | 133 // pending RVH. |
| 134 // - The previous renderer is kept swapped out in RenderViewHostManager in case | 134 // - The previous renderer is kept swapped out in RenderViewHostManager in case |
| 135 // the user goes back. The process only stays live if another tab is using | 135 // the user goes back. The process only stays live if another tab is using |
| 136 // it, but if so, the existing frame relationships will be maintained. | 136 // it, but if so, the existing frame relationships will be maintained. |
| 137 | 137 |
| 138 using content::BrowserContext; | |
| 139 using content::DevToolsAgentHost; | |
| 140 using content::DevToolsAgentHostRegistry; | |
| 141 using content::DevToolsManagerImpl; | |
| 142 using content::DownloadItem; | |
| 143 using content::DownloadManager; | |
| 144 using content::DownloadUrlParameters; | |
| 145 using content::GlobalRequestID; | |
| 146 using content::HostZoomMap; | |
| 147 using content::InterstitialPage; | |
| 148 using content::LoadNotificationDetails; | |
| 149 using content::NativeWebKeyboardEvent; | |
| 150 using content::NavigationController; | |
| 151 using content::NavigationEntry; | |
| 152 using content::NavigationEntryImpl; | |
| 153 using content::OpenURLParams; | |
| 154 using content::RenderViewHost; | |
| 155 using content::RenderViewHostDelegate; | |
| 156 using content::RenderViewHostDelegateView; | |
| 157 using content::RenderViewHostImpl; | |
| 158 using content::RenderWidgetHost; | |
| 159 using content::RenderWidgetHostImpl; | |
| 160 using content::RenderWidgetHostView; | |
| 161 using content::RenderWidgetHostViewPort; | |
| 162 using content::ResourceDispatcherHostImpl; | |
| 163 using content::SSLStatus; | |
| 164 using content::SessionStorageNamespace; | |
| 165 using content::SiteInstance; | |
| 166 using content::UserMetricsAction; | |
| 167 using content::WebContents; | |
| 168 using content::WebContentsDelegate; | |
| 169 using content::WebContentsObserver; | |
| 170 using content::WebUI; | |
| 171 using content::WebUIController; | |
| 172 using content::WebUIControllerFactory; | |
| 173 using webkit_glue::WebPreferences; | 138 using webkit_glue::WebPreferences; |
| 174 | 139 |
| 140 namespace content { |
| 175 namespace { | 141 namespace { |
| 176 | 142 |
| 177 // Amount of time we wait between when a key event is received and the renderer | 143 // Amount of time we wait between when a key event is received and the renderer |
| 178 // is queried for its state and pushed to the NavigationEntry. | 144 // is queried for its state and pushed to the NavigationEntry. |
| 179 const int kQueryStateDelay = 5000; | 145 const int kQueryStateDelay = 5000; |
| 180 | 146 |
| 181 const int kSyncWaitDelay = 40; | 147 const int kSyncWaitDelay = 40; |
| 182 | 148 |
| 183 const char kDotGoogleDotCom[] = ".google.com"; | 149 const char kDotGoogleDotCom[] = ".google.com"; |
| 184 | 150 |
| 185 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
| 186 | 152 |
| 187 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 153 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
| 188 // Note: erase is required to properly paint some widgets borders. This can | 154 // Note: erase is required to properly paint some widgets borders. This can |
| 189 // be seen with textfields. | 155 // be seen with textfields. |
| 190 InvalidateRect(hwnd, NULL, TRUE); | 156 InvalidateRect(hwnd, NULL, TRUE); |
| 191 return TRUE; | 157 return TRUE; |
| 192 } | 158 } |
| 193 #endif | 159 #endif |
| 194 | 160 |
| 195 ViewMsg_Navigate_Type::Value GetNavigationType( | 161 ViewMsg_Navigate_Type::Value GetNavigationType( |
| 196 content::BrowserContext* browser_context, const NavigationEntryImpl& entry, | 162 BrowserContext* browser_context, const NavigationEntryImpl& entry, |
| 197 NavigationController::ReloadType reload_type) { | 163 NavigationController::ReloadType reload_type) { |
| 198 switch (reload_type) { | 164 switch (reload_type) { |
| 199 case NavigationControllerImpl::RELOAD: | 165 case NavigationControllerImpl::RELOAD: |
| 200 return ViewMsg_Navigate_Type::RELOAD; | 166 return ViewMsg_Navigate_Type::RELOAD; |
| 201 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: | 167 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: |
| 202 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 168 return ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 203 case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: | 169 case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: |
| 204 return ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; | 170 return ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
| 205 case NavigationControllerImpl::NO_RELOAD: | 171 case NavigationControllerImpl::NO_RELOAD: |
| 206 break; // Fall through to rest of function. | 172 break; // Fall through to rest of function. |
| 207 } | 173 } |
| 208 | 174 |
| 209 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates | 175 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates |
| 210 // between |RESTORE_WITH_POST| and |RESTORE|. | 176 // between |RESTORE_WITH_POST| and |RESTORE|. |
| 211 if (entry.restore_type() == | 177 if (entry.restore_type() == |
| 212 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { | 178 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { |
| 213 if (entry.GetHasPostData()) | 179 if (entry.GetHasPostData()) |
| 214 return ViewMsg_Navigate_Type::RESTORE_WITH_POST; | 180 return ViewMsg_Navigate_Type::RESTORE_WITH_POST; |
| 215 return ViewMsg_Navigate_Type::RESTORE; | 181 return ViewMsg_Navigate_Type::RESTORE; |
| 216 } | 182 } |
| 217 | 183 |
| 218 return ViewMsg_Navigate_Type::NORMAL; | 184 return ViewMsg_Navigate_Type::NORMAL; |
| 219 } | 185 } |
| 220 | 186 |
| 221 void MakeNavigateParams(const NavigationEntryImpl& entry, | 187 void MakeNavigateParams(const NavigationEntryImpl& entry, |
| 222 const NavigationControllerImpl& controller, | 188 const NavigationControllerImpl& controller, |
| 223 content::WebContentsDelegate* delegate, | 189 WebContentsDelegate* delegate, |
| 224 NavigationController::ReloadType reload_type, | 190 NavigationController::ReloadType reload_type, |
| 225 const std::string& embedder_channel_name, | 191 const std::string& embedder_channel_name, |
| 226 int embedder_container_id, | 192 int embedder_container_id, |
| 227 ViewMsg_Navigate_Params* params) { | 193 ViewMsg_Navigate_Params* params) { |
| 228 params->page_id = entry.GetPageID(); | 194 params->page_id = entry.GetPageID(); |
| 229 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 195 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
| 230 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); | 196 params->current_history_list_offset = controller.GetLastCommittedEntryIndex(); |
| 231 params->current_history_list_length = controller.GetEntryCount(); | 197 params->current_history_list_length = controller.GetEntryCount(); |
| 232 if (!entry.GetBaseURLForDataURL().is_empty()) { | 198 if (!entry.GetBaseURLForDataURL().is_empty()) { |
| 233 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); | 199 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 248 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
| 283 int int_value; | 249 int int_value; |
| 284 if (base::StringToInt(string_value, &int_value)) | 250 if (base::StringToInt(string_value, &int_value)) |
| 285 return std::max(min_value, int_value); | 251 return std::max(min_value, int_value); |
| 286 else | 252 else |
| 287 return min_value; | 253 return min_value; |
| 288 } | 254 } |
| 289 | 255 |
| 290 } // namespace | 256 } // namespace |
| 291 | 257 |
| 292 namespace content { | |
| 293 | |
| 294 WebContents* WebContents::Create( | 258 WebContents* WebContents::Create( |
| 295 BrowserContext* browser_context, | 259 BrowserContext* browser_context, |
| 296 SiteInstance* site_instance, | 260 SiteInstance* site_instance, |
| 297 int routing_id, | 261 int routing_id, |
| 298 const WebContents* base_web_contents) { | 262 const WebContents* base_web_contents) { |
| 299 return WebContentsImpl::Create( | 263 return WebContentsImpl::Create( |
| 300 browser_context, site_instance, routing_id, | 264 browser_context, site_instance, routing_id, |
| 301 static_cast<const WebContentsImpl*>(base_web_contents)); | 265 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 302 } | 266 } |
| 303 | 267 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 319 | 283 |
| 320 new_contents->Init(browser_context, site_instance, routing_id, | 284 new_contents->Init(browser_context, site_instance, routing_id, |
| 321 static_cast<const WebContentsImpl*>(base_web_contents)); | 285 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 322 return new_contents; | 286 return new_contents; |
| 323 } | 287 } |
| 324 | 288 |
| 325 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { | 289 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { |
| 326 return rvh->GetDelegate()->GetAsWebContents(); | 290 return rvh->GetDelegate()->GetAsWebContents(); |
| 327 } | 291 } |
| 328 | 292 |
| 329 } | |
| 330 | |
| 331 // WebContentsImpl ------------------------------------------------------------- | 293 // WebContentsImpl ------------------------------------------------------------- |
| 332 | 294 |
| 333 WebContentsImpl::WebContentsImpl( | 295 WebContentsImpl::WebContentsImpl( |
| 334 content::BrowserContext* browser_context, | 296 BrowserContext* browser_context, |
| 335 WebContentsImpl* opener) | 297 WebContentsImpl* opener) |
| 336 : delegate_(NULL), | 298 : delegate_(NULL), |
| 337 ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, browser_context)), | 299 ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, browser_context)), |
| 338 render_view_host_delegate_view_(NULL), | 300 render_view_host_delegate_view_(NULL), |
| 339 opener_(opener), | 301 opener_(opener), |
| 340 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), | 302 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), |
| 341 is_loading_(false), | 303 is_loading_(false), |
| 342 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 304 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 343 crashed_error_code_(0), | 305 crashed_error_code_(0), |
| 344 waiting_for_response_(false), | 306 waiting_for_response_(false), |
| 345 load_state_(net::LOAD_STATE_IDLE, string16()), | 307 load_state_(net::LOAD_STATE_IDLE, string16()), |
| 346 upload_size_(0), | 308 upload_size_(0), |
| 347 upload_position_(0), | 309 upload_position_(0), |
| 348 displayed_insecure_content_(false), | 310 displayed_insecure_content_(false), |
| 349 capturing_contents_(false), | 311 capturing_contents_(false), |
| 350 is_being_destroyed_(false), | 312 is_being_destroyed_(false), |
| 351 notify_disconnection_(false), | 313 notify_disconnection_(false), |
| 352 dialog_creator_(NULL), | 314 dialog_creator_(NULL), |
| 353 #if defined(OS_WIN) | 315 #if defined(OS_WIN) |
| 354 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 316 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
| 355 #endif | 317 #endif |
| 356 is_showing_before_unload_dialog_(false), | 318 is_showing_before_unload_dialog_(false), |
| 357 opener_web_ui_type_(WebUI::kNoWebUI), | 319 opener_web_ui_type_(WebUI::kNoWebUI), |
| 358 closed_by_user_gesture_(false), | 320 closed_by_user_gesture_(false), |
| 359 minimum_zoom_percent_( | 321 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), |
| 360 static_cast<int>(content::kMinimumZoomFactor * 100)), | 322 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), |
| 361 maximum_zoom_percent_( | |
| 362 static_cast<int>(content::kMaximumZoomFactor * 100)), | |
| 363 temporary_zoom_settings_(false), | 323 temporary_zoom_settings_(false), |
| 364 content_restrictions_(0), | 324 content_restrictions_(0), |
| 365 color_chooser_(NULL) { | 325 color_chooser_(NULL) { |
| 366 } | 326 } |
| 367 | 327 |
| 368 WebContentsImpl::~WebContentsImpl() { | 328 WebContentsImpl::~WebContentsImpl() { |
| 369 is_being_destroyed_ = true; | 329 is_being_destroyed_ = true; |
| 370 | 330 |
| 371 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 331 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
| 372 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 332 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
| 373 (*iter)->DetachDelegate(); | 333 (*iter)->DetachDelegate(); |
| 374 } | 334 } |
| 375 created_widgets_.clear(); | 335 created_widgets_.clear(); |
| 376 | 336 |
| 377 // Clear out any JavaScript state. | 337 // Clear out any JavaScript state. |
| 378 if (dialog_creator_) | 338 if (dialog_creator_) |
| 379 dialog_creator_->ResetJavaScriptState(this); | 339 dialog_creator_->ResetJavaScriptState(this); |
| 380 | 340 |
| 381 if (color_chooser_) | 341 if (color_chooser_) |
| 382 color_chooser_->End(); | 342 color_chooser_->End(); |
| 383 | 343 |
| 384 NotifyDisconnected(); | 344 NotifyDisconnected(); |
| 385 | 345 |
| 386 // Notify any observer that have a reference on this WebContents. | 346 // Notify any observer that have a reference on this WebContents. |
| 387 content::NotificationService::current()->Notify( | 347 NotificationService::current()->Notify( |
| 388 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 348 NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 389 content::Source<WebContents>(this), | 349 Source<WebContents>(this), |
| 390 content::NotificationService::NoDetails()); | 350 NotificationService::NoDetails()); |
| 391 | 351 |
| 392 // TODO(brettw) this should be moved to the view. | 352 // TODO(brettw) this should be moved to the view. |
| 393 #if defined(OS_WIN) && !defined(USE_AURA) | 353 #if defined(OS_WIN) && !defined(USE_AURA) |
| 394 // If we still have a window handle, destroy it. GetNativeView can return | 354 // If we still have a window handle, destroy it. GetNativeView can return |
| 395 // NULL if this contents was part of a window that closed. | 355 // NULL if this contents was part of a window that closed. |
| 396 if (GetNativeView()) { | 356 if (GetNativeView()) { |
| 397 RenderViewHost* host = GetRenderViewHost(); | 357 RenderViewHost* host = GetRenderViewHost(); |
| 398 if (host && host->GetView()) | 358 if (host && host->GetView()) |
| 399 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 359 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
| 400 } | 360 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 browser_context, | 413 browser_context, |
| 454 guest_site_instance, | 414 guest_site_instance, |
| 455 MSG_ROUTING_NONE, | 415 MSG_ROUTING_NONE, |
| 456 NULL); // base WebContents | 416 NULL); // base WebContents |
| 457 WebContentsImpl* new_contents_impl = | 417 WebContentsImpl* new_contents_impl = |
| 458 static_cast<WebContentsImpl*>(new_contents); | 418 static_cast<WebContentsImpl*>(new_contents); |
| 459 | 419 |
| 460 // This makes |new_contents| act as a guest. | 420 // This makes |new_contents| act as a guest. |
| 461 // For more info, see comment above class BrowserPluginGuest. | 421 // For more info, see comment above class BrowserPluginGuest. |
| 462 new_contents_impl->browser_plugin_guest_.reset( | 422 new_contents_impl->browser_plugin_guest_.reset( |
| 463 content::BrowserPluginGuest::Create( | 423 BrowserPluginGuest::Create( |
| 464 guest_instance_id, | 424 guest_instance_id, |
| 465 new_contents_impl, | 425 new_contents_impl, |
| 466 new_contents_impl->GetRenderViewHost())); | 426 new_contents_impl->GetRenderViewHost())); |
| 467 return new_contents; | 427 return new_contents; |
| 468 } | 428 } |
| 469 | 429 |
| 470 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, | 430 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, |
| 471 const GURL& url) { | 431 const GURL& url) { |
| 472 WebPreferences prefs; | 432 WebPreferences prefs; |
| 473 | 433 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 if (command_line.HasSwitch(switches::kDisableSmoothScrolling)) | 560 if (command_line.HasSwitch(switches::kDisableSmoothScrolling)) |
| 601 prefs.enable_scroll_animator = false; | 561 prefs.enable_scroll_animator = false; |
| 602 | 562 |
| 603 prefs.visual_word_movement_enabled = | 563 prefs.visual_word_movement_enabled = |
| 604 command_line.HasSwitch(switches::kEnableVisualWordMovement); | 564 command_line.HasSwitch(switches::kEnableVisualWordMovement); |
| 605 | 565 |
| 606 { // Certain GPU features might have been blacklisted. | 566 { // Certain GPU features might have been blacklisted. |
| 607 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 567 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 608 DCHECK(gpu_data_manager); | 568 DCHECK(gpu_data_manager); |
| 609 uint32 blacklist_type = gpu_data_manager->GetBlacklistedFeatures(); | 569 uint32 blacklist_type = gpu_data_manager->GetBlacklistedFeatures(); |
| 610 if (blacklist_type & content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) | 570 if (blacklist_type & GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) |
| 611 prefs.accelerated_compositing_enabled = false; | 571 prefs.accelerated_compositing_enabled = false; |
| 612 if (blacklist_type & content::GPU_FEATURE_TYPE_WEBGL) | 572 if (blacklist_type & GPU_FEATURE_TYPE_WEBGL) |
| 613 prefs.experimental_webgl_enabled = false; | 573 prefs.experimental_webgl_enabled = false; |
| 614 if (blacklist_type & content::GPU_FEATURE_TYPE_FLASH3D) | 574 if (blacklist_type & GPU_FEATURE_TYPE_FLASH3D) |
| 615 prefs.flash_3d_enabled = false; | 575 prefs.flash_3d_enabled = false; |
| 616 if (blacklist_type & content::GPU_FEATURE_TYPE_FLASH_STAGE3D) | 576 if (blacklist_type & GPU_FEATURE_TYPE_FLASH_STAGE3D) |
| 617 prefs.flash_stage3d_enabled = false; | 577 prefs.flash_stage3d_enabled = false; |
| 618 if (blacklist_type & content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | 578 if (blacklist_type & GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
| 619 prefs.accelerated_2d_canvas_enabled = false; | 579 prefs.accelerated_2d_canvas_enabled = false; |
| 620 if (blacklist_type & content::GPU_FEATURE_TYPE_MULTISAMPLING) | 580 if (blacklist_type & GPU_FEATURE_TYPE_MULTISAMPLING) |
| 621 prefs.gl_multisampling_enabled = false; | 581 prefs.gl_multisampling_enabled = false; |
| 622 if (blacklist_type & content::GPU_FEATURE_TYPE_3D_CSS) { | 582 if (blacklist_type & GPU_FEATURE_TYPE_3D_CSS) { |
| 623 prefs.accelerated_layers_enabled = false; | 583 prefs.accelerated_layers_enabled = false; |
| 624 prefs.accelerated_animation_enabled = false; | 584 prefs.accelerated_animation_enabled = false; |
| 625 } | 585 } |
| 626 if (blacklist_type & content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO) | 586 if (blacklist_type & GPU_FEATURE_TYPE_ACCELERATED_VIDEO) |
| 627 prefs.accelerated_video_enabled = false; | 587 prefs.accelerated_video_enabled = false; |
| 628 | 588 |
| 629 // Accelerated video and animation are slower than regular when using a | 589 // Accelerated video and animation are slower than regular when using a |
| 630 // software 3d rasterizer. 3D CSS may also be too slow to be worthwhile. | 590 // software 3d rasterizer. 3D CSS may also be too slow to be worthwhile. |
| 631 if (gpu_data_manager->ShouldUseSoftwareRendering()) { | 591 if (gpu_data_manager->ShouldUseSoftwareRendering()) { |
| 632 prefs.accelerated_video_enabled = false; | 592 prefs.accelerated_video_enabled = false; |
| 633 prefs.accelerated_animation_enabled = false; | 593 prefs.accelerated_animation_enabled = false; |
| 634 prefs.accelerated_layers_enabled = false; | 594 prefs.accelerated_layers_enabled = false; |
| 635 prefs.accelerated_plugins_enabled = false; | 595 prefs.accelerated_plugins_enabled = false; |
| 636 } | 596 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 switches::kDisableFixedPositionCreatesStackingContext); | 639 switches::kDisableFixedPositionCreatesStackingContext); |
| 680 | 640 |
| 681 prefs.gesture_tap_highlight_enabled = command_line.HasSwitch( | 641 prefs.gesture_tap_highlight_enabled = command_line.HasSwitch( |
| 682 switches::kEnableGestureTapHighlight); | 642 switches::kEnableGestureTapHighlight); |
| 683 | 643 |
| 684 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); | 644 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); |
| 685 | 645 |
| 686 prefs.apply_page_scale_factor_in_compositor = | 646 prefs.apply_page_scale_factor_in_compositor = |
| 687 command_line.HasSwitch(cc::switches::kEnablePinchInCompositor); | 647 command_line.HasSwitch(cc::switches::kEnablePinchInCompositor); |
| 688 | 648 |
| 689 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 649 GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
| 690 | 650 |
| 691 // Disable compositing in guests until we have compositing path implemented | 651 // Disable compositing in guests until we have compositing path implemented |
| 692 // for guests. | 652 // for guests. |
| 693 if (rvh->GetProcess()->IsGuest()) { | 653 if (rvh->GetProcess()->IsGuest()) { |
| 694 prefs.force_compositing_mode = false; | 654 prefs.force_compositing_mode = false; |
| 695 prefs.accelerated_compositing_enabled = false; | 655 prefs.accelerated_compositing_enabled = false; |
| 696 } | 656 } |
| 697 | 657 |
| 698 return prefs; | 658 return prefs; |
| 699 } | 659 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) | 720 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) |
| 761 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, | 721 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission, |
| 762 OnRequestPpapiBrokerPermission) | 722 OnRequestPpapiBrokerPermission) |
| 763 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, | 723 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CreateGuest, |
| 764 OnBrowserPluginCreateGuest) | 724 OnBrowserPluginCreateGuest) |
| 765 IPC_MESSAGE_UNHANDLED(handled = false) | 725 IPC_MESSAGE_UNHANDLED(handled = false) |
| 766 IPC_END_MESSAGE_MAP_EX() | 726 IPC_END_MESSAGE_MAP_EX() |
| 767 message_source_ = NULL; | 727 message_source_ = NULL; |
| 768 | 728 |
| 769 if (!message_is_ok) { | 729 if (!message_is_ok) { |
| 770 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); | 730 RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); |
| 771 GetRenderProcessHost()->ReceivedBadMessage(); | 731 GetRenderProcessHost()->ReceivedBadMessage(); |
| 772 } | 732 } |
| 773 | 733 |
| 774 return handled; | 734 return handled; |
| 775 } | 735 } |
| 776 | 736 |
| 777 void WebContentsImpl::RunFileChooser( | 737 void WebContentsImpl::RunFileChooser( |
| 778 RenderViewHost* render_view_host, | 738 RenderViewHost* render_view_host, |
| 779 const content::FileChooserParams& params) { | 739 const FileChooserParams& params) { |
| 780 if (delegate_) | 740 if (delegate_) |
| 781 delegate_->RunFileChooser(this, params); | 741 delegate_->RunFileChooser(this, params); |
| 782 } | 742 } |
| 783 | 743 |
| 784 NavigationControllerImpl& WebContentsImpl::GetController() { | 744 NavigationControllerImpl& WebContentsImpl::GetController() { |
| 785 return controller_; | 745 return controller_; |
| 786 } | 746 } |
| 787 | 747 |
| 788 const NavigationControllerImpl& WebContentsImpl::GetController() const { | 748 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
| 789 return controller_; | 749 return controller_; |
| 790 } | 750 } |
| 791 | 751 |
| 792 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { | 752 BrowserContext* WebContentsImpl::GetBrowserContext() const { |
| 793 return controller_.GetBrowserContext(); | 753 return controller_.GetBrowserContext(); |
| 794 } | 754 } |
| 795 | 755 |
| 796 const GURL& WebContentsImpl::GetURL() const { | 756 const GURL& WebContentsImpl::GetURL() const { |
| 797 // We may not have a navigation entry yet | 757 // We may not have a navigation entry yet |
| 798 NavigationEntry* entry = controller_.GetActiveEntry(); | 758 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 799 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | 759 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
| 800 } | 760 } |
| 801 | 761 |
| 802 content::WebContentsDelegate* WebContentsImpl::GetDelegate() { | 762 WebContentsDelegate* WebContentsImpl::GetDelegate() { |
| 803 return delegate_; | 763 return delegate_; |
| 804 } | 764 } |
| 805 | 765 |
| 806 void WebContentsImpl::SetDelegate(content::WebContentsDelegate* delegate) { | 766 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { |
| 807 // TODO(cbentzel): remove this debugging code? | 767 // TODO(cbentzel): remove this debugging code? |
| 808 if (delegate == delegate_) | 768 if (delegate == delegate_) |
| 809 return; | 769 return; |
| 810 if (delegate_) | 770 if (delegate_) |
| 811 delegate_->Detach(this); | 771 delegate_->Detach(this); |
| 812 delegate_ = delegate; | 772 delegate_ = delegate; |
| 813 if (delegate_) | 773 if (delegate_) |
| 814 delegate_->Attach(this); | 774 delegate_->Attach(this); |
| 815 } | 775 } |
| 816 | 776 |
| 817 content::RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 777 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
| 818 RenderViewHostImpl* host = render_manager_.current_host(); | 778 RenderViewHostImpl* host = render_manager_.current_host(); |
| 819 return host ? host->GetProcess() : NULL; | 779 return host ? host->GetProcess() : NULL; |
| 820 } | 780 } |
| 821 | 781 |
| 822 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { | 782 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { |
| 823 return render_manager_.current_host(); | 783 return render_manager_.current_host(); |
| 824 } | 784 } |
| 825 | 785 |
| 826 int WebContentsImpl::GetRoutingID() const { | 786 int WebContentsImpl::GetRoutingID() const { |
| 827 if (!GetRenderViewHost()) | 787 if (!GetRenderViewHost()) |
| 828 return MSG_ROUTING_NONE; | 788 return MSG_ROUTING_NONE; |
| 829 | 789 |
| 830 return GetRenderViewHost()->GetRoutingID(); | 790 return GetRenderViewHost()->GetRoutingID(); |
| 831 } | 791 } |
| 832 | 792 |
| 833 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 793 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
| 834 return render_manager_.GetRenderWidgetHostView(); | 794 return render_manager_.GetRenderWidgetHostView(); |
| 835 } | 795 } |
| 836 | 796 |
| 837 content::WebContentsView* WebContentsImpl::GetView() const { | 797 WebContentsView* WebContentsImpl::GetView() const { |
| 838 return view_.get(); | 798 return view_.get(); |
| 839 } | 799 } |
| 840 | 800 |
| 841 content::WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 801 WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
| 842 WebUIControllerFactory* factory = | 802 WebUIControllerFactory* factory = |
| 843 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 803 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 844 if (!factory) | 804 if (!factory) |
| 845 return NULL; | 805 return NULL; |
| 846 WebUIImpl* web_ui = new WebUIImpl(this); | 806 WebUIImpl* web_ui = new WebUIImpl(this); |
| 847 WebUIController* controller = | 807 WebUIController* controller = |
| 848 factory->CreateWebUIControllerForURL(web_ui, url); | 808 factory->CreateWebUIControllerForURL(web_ui, url); |
| 849 if (controller) { | 809 if (controller) { |
| 850 web_ui->SetController(controller); | 810 web_ui->SetController(controller); |
| 851 return web_ui; | 811 return web_ui; |
| 852 } | 812 } |
| 853 | 813 |
| 854 delete web_ui; | 814 delete web_ui; |
| 855 return NULL; | 815 return NULL; |
| 856 } | 816 } |
| 857 | 817 |
| 858 content::WebUI* WebContentsImpl::GetWebUI() const { | 818 WebUI* WebContentsImpl::GetWebUI() const { |
| 859 return render_manager_.web_ui() ? render_manager_.web_ui() | 819 return render_manager_.web_ui() ? render_manager_.web_ui() |
| 860 : render_manager_.pending_web_ui(); | 820 : render_manager_.pending_web_ui(); |
| 861 } | 821 } |
| 862 | 822 |
| 863 content::WebUI* WebContentsImpl::GetCommittedWebUI() const { | 823 WebUI* WebContentsImpl::GetCommittedWebUI() const { |
| 864 return render_manager_.web_ui(); | 824 return render_manager_.web_ui(); |
| 865 } | 825 } |
| 866 | 826 |
| 867 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { | 827 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { |
| 868 if (GetUserAgentOverride() == override) | 828 if (GetUserAgentOverride() == override) |
| 869 return; | 829 return; |
| 870 | 830 |
| 871 renderer_preferences_.user_agent_override = override; | 831 renderer_preferences_.user_agent_override = override; |
| 872 | 832 |
| 873 // Send the new override string to the renderer. | 833 // Send the new override string to the renderer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 887 | 847 |
| 888 const std::string& WebContentsImpl::GetUserAgentOverride() const { | 848 const std::string& WebContentsImpl::GetUserAgentOverride() const { |
| 889 return renderer_preferences_.user_agent_override; | 849 return renderer_preferences_.user_agent_override; |
| 890 } | 850 } |
| 891 | 851 |
| 892 const string16& WebContentsImpl::GetTitle() const { | 852 const string16& WebContentsImpl::GetTitle() const { |
| 893 // Transient entries take precedence. They are used for interstitial pages | 853 // Transient entries take precedence. They are used for interstitial pages |
| 894 // that are shown on top of existing pages. | 854 // that are shown on top of existing pages. |
| 895 NavigationEntry* entry = controller_.GetTransientEntry(); | 855 NavigationEntry* entry = controller_.GetTransientEntry(); |
| 896 std::string accept_languages = | 856 std::string accept_languages = |
| 897 content::GetContentClient()->browser()->GetAcceptLangs( | 857 GetContentClient()->browser()->GetAcceptLangs( |
| 898 GetBrowserContext()); | 858 GetBrowserContext()); |
| 899 if (entry) { | 859 if (entry) { |
| 900 return entry->GetTitleForDisplay(accept_languages); | 860 return entry->GetTitleForDisplay(accept_languages); |
| 901 } | 861 } |
| 902 WebUI* our_web_ui = render_manager_.pending_web_ui() ? | 862 WebUI* our_web_ui = render_manager_.pending_web_ui() ? |
| 903 render_manager_.pending_web_ui() : render_manager_.web_ui(); | 863 render_manager_.pending_web_ui() : render_manager_.web_ui(); |
| 904 if (our_web_ui) { | 864 if (our_web_ui) { |
| 905 // Don't override the title in view source mode. | 865 // Don't override the title in view source mode. |
| 906 entry = controller_.GetActiveEntry(); | 866 entry = controller_.GetActiveEntry(); |
| 907 if (!(entry && entry->IsViewSourceMode())) { | 867 if (!(entry && entry->IsViewSourceMode())) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); | 965 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
| 1006 } | 966 } |
| 1007 | 967 |
| 1008 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, | 968 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, |
| 1009 int error_code) { | 969 int error_code) { |
| 1010 if (status == crashed_status_) | 970 if (status == crashed_status_) |
| 1011 return; | 971 return; |
| 1012 | 972 |
| 1013 crashed_status_ = status; | 973 crashed_status_ = status; |
| 1014 crashed_error_code_ = error_code; | 974 crashed_error_code_ = error_code; |
| 1015 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB); | 975 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
| 1016 } | 976 } |
| 1017 | 977 |
| 1018 base::TerminationStatus WebContentsImpl::GetCrashedStatus() const { | 978 base::TerminationStatus WebContentsImpl::GetCrashedStatus() const { |
| 1019 return crashed_status_; | 979 return crashed_status_; |
| 1020 } | 980 } |
| 1021 | 981 |
| 1022 bool WebContentsImpl::IsBeingDestroyed() const { | 982 bool WebContentsImpl::IsBeingDestroyed() const { |
| 1023 return is_being_destroyed_; | 983 return is_being_destroyed_; |
| 1024 } | 984 } |
| 1025 | 985 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1049 | 1009 |
| 1050 // The resize rect might have changed while this was inactive -- send the new | 1010 // The resize rect might have changed while this was inactive -- send the new |
| 1051 // one to make sure it's up to date. | 1011 // one to make sure it's up to date. |
| 1052 RenderViewHostImpl* rvh = | 1012 RenderViewHostImpl* rvh = |
| 1053 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 1013 static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
| 1054 if (rvh) { | 1014 if (rvh) { |
| 1055 rvh->ResizeRectChanged(GetRootWindowResizerRect()); | 1015 rvh->ResizeRectChanged(GetRootWindowResizerRect()); |
| 1056 } | 1016 } |
| 1057 | 1017 |
| 1058 bool is_visible = true; | 1018 bool is_visible = true; |
| 1059 content::NotificationService::current()->Notify( | 1019 NotificationService::current()->Notify( |
| 1060 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 1020 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 1061 content::Source<WebContents>(this), | 1021 Source<WebContents>(this), |
| 1062 content::Details<bool>(&is_visible)); | 1022 Details<bool>(&is_visible)); |
| 1063 } | 1023 } |
| 1064 | 1024 |
| 1065 void WebContentsImpl::WasHidden() { | 1025 void WebContentsImpl::WasHidden() { |
| 1066 if (!capturing_contents_) { | 1026 if (!capturing_contents_) { |
| 1067 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1027 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
| 1068 // open a tab in then background, then closes the tab before selecting it. | 1028 // open a tab in then background, then closes the tab before selecting it. |
| 1069 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1029 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
| 1070 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1030 // removes the |GetRenderViewHost()|; then when we actually destroy the |
| 1071 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1031 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
| 1072 // calls us). | 1032 // calls us). |
| 1073 RenderWidgetHostViewPort* rwhv = | 1033 RenderWidgetHostViewPort* rwhv = |
| 1074 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 1034 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
| 1075 if (rwhv) | 1035 if (rwhv) |
| 1076 rwhv->WasHidden(); | 1036 rwhv->WasHidden(); |
| 1077 } | 1037 } |
| 1078 | 1038 |
| 1079 bool is_visible = false; | 1039 bool is_visible = false; |
| 1080 content::NotificationService::current()->Notify( | 1040 NotificationService::current()->Notify( |
| 1081 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 1041 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 1082 content::Source<WebContents>(this), | 1042 Source<WebContents>(this), |
| 1083 content::Details<bool>(&is_visible)); | 1043 Details<bool>(&is_visible)); |
| 1084 } | 1044 } |
| 1085 | 1045 |
| 1086 bool WebContentsImpl::NeedToFireBeforeUnload() { | 1046 bool WebContentsImpl::NeedToFireBeforeUnload() { |
| 1087 // TODO(creis): Should we fire even for interstitial pages? | 1047 // TODO(creis): Should we fire even for interstitial pages? |
| 1088 return WillNotifyDisconnection() && | 1048 return WillNotifyDisconnection() && |
| 1089 !ShowingInterstitialPage() && | 1049 !ShowingInterstitialPage() && |
| 1090 !static_cast<RenderViewHostImpl*>( | 1050 !static_cast<RenderViewHostImpl*>( |
| 1091 GetRenderViewHost())->SuddenTerminationAllowed(); | 1051 GetRenderViewHost())->SuddenTerminationAllowed(); |
| 1092 } | 1052 } |
| 1093 | 1053 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1120 | 1080 |
| 1121 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { | 1081 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { |
| 1122 view_->GetContainerBounds(out); | 1082 view_->GetContainerBounds(out); |
| 1123 } | 1083 } |
| 1124 | 1084 |
| 1125 void WebContentsImpl::Focus() { | 1085 void WebContentsImpl::Focus() { |
| 1126 view_->Focus(); | 1086 view_->Focus(); |
| 1127 } | 1087 } |
| 1128 | 1088 |
| 1129 void WebContentsImpl::Observe(int type, | 1089 void WebContentsImpl::Observe(int type, |
| 1130 const content::NotificationSource& source, | 1090 const NotificationSource& source, |
| 1131 const content::NotificationDetails& details) { | 1091 const NotificationDetails& details) { |
| 1132 switch (type) { | 1092 switch (type) { |
| 1133 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 1093 case NOTIFICATION_WEB_CONTENTS_DESTROYED: |
| 1134 OnWebContentsDestroyed( | 1094 OnWebContentsDestroyed(Source<WebContents>(source).ptr()); |
| 1135 content::Source<content::WebContents>(source).ptr()); | |
| 1136 break; | 1095 break; |
| 1137 case content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 1096 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 1138 RenderWidgetHost* host = content::Source<RenderWidgetHost>(source).ptr(); | 1097 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); |
| 1139 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); | 1098 for (PendingWidgetViews::iterator i = pending_widget_views_.begin(); |
| 1140 i != pending_widget_views_.end(); ++i) { | 1099 i != pending_widget_views_.end(); ++i) { |
| 1141 if (host->GetView() == i->second) { | 1100 if (host->GetView() == i->second) { |
| 1142 pending_widget_views_.erase(i); | 1101 pending_widget_views_.erase(i); |
| 1143 break; | 1102 break; |
| 1144 } | 1103 } |
| 1145 } | 1104 } |
| 1146 break; | 1105 break; |
| 1147 } | 1106 } |
| 1148 default: | 1107 default: |
| 1149 NOTREACHED(); | 1108 NOTREACHED(); |
| 1150 } | 1109 } |
| 1151 } | 1110 } |
| 1152 | 1111 |
| 1153 void WebContentsImpl::Init(BrowserContext* browser_context, | 1112 void WebContentsImpl::Init(BrowserContext* browser_context, |
| 1154 SiteInstance* site_instance, | 1113 SiteInstance* site_instance, |
| 1155 int routing_id, | 1114 int routing_id, |
| 1156 const WebContents* base_web_contents) { | 1115 const WebContents* base_web_contents) { |
| 1157 render_manager_.Init(browser_context, site_instance, routing_id); | 1116 render_manager_.Init(browser_context, site_instance, routing_id); |
| 1158 | 1117 |
| 1159 view_.reset(content::GetContentClient()->browser()-> | 1118 view_.reset(GetContentClient()->browser()-> |
| 1160 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | 1119 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
| 1161 if (view_.get()) { | 1120 if (view_.get()) { |
| 1162 CHECK(render_view_host_delegate_view_); | 1121 CHECK(render_view_host_delegate_view_); |
| 1163 } else { | 1122 } else { |
| 1164 content::WebContentsViewDelegate* delegate = | 1123 WebContentsViewDelegate* delegate = |
| 1165 content::GetContentClient()->browser()->GetWebContentsViewDelegate( | 1124 GetContentClient()->browser()->GetWebContentsViewDelegate( |
| 1166 this); | 1125 this); |
| 1167 view_.reset(CreateWebContentsView( | 1126 view_.reset(CreateWebContentsView( |
| 1168 this, delegate, &render_view_host_delegate_view_)); | 1127 this, delegate, &render_view_host_delegate_view_)); |
| 1169 CHECK(render_view_host_delegate_view_); | 1128 CHECK(render_view_host_delegate_view_); |
| 1170 } | 1129 } |
| 1171 CHECK(view_.get()); | 1130 CHECK(view_.get()); |
| 1172 | 1131 |
| 1173 // We have the initial size of the view be based on the size of the view of | 1132 // We have the initial size of the view be based on the size of the view of |
| 1174 // the passed in WebContents. | 1133 // the passed in WebContents. |
| 1175 view_->CreateView(base_web_contents ? | 1134 view_->CreateView(base_web_contents ? |
| 1176 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); | 1135 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); |
| 1177 | 1136 |
| 1178 // Listen for whether our opener gets destroyed. | 1137 // Listen for whether our opener gets destroyed. |
| 1179 if (opener_) { | 1138 if (opener_) { |
| 1180 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1139 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1181 content::Source<WebContents>(opener_)); | 1140 Source<WebContents>(opener_)); |
| 1182 } | 1141 } |
| 1183 | 1142 |
| 1184 registrar_.Add(this, | 1143 registrar_.Add(this, |
| 1185 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1144 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1186 content::NotificationService::AllBrowserContextsAndSources()); | 1145 NotificationService::AllBrowserContextsAndSources()); |
| 1187 #if defined(ENABLE_JAVA_BRIDGE) | 1146 #if defined(ENABLE_JAVA_BRIDGE) |
| 1188 java_bridge_dispatcher_host_manager_.reset( | 1147 java_bridge_dispatcher_host_manager_.reset( |
| 1189 new JavaBridgeDispatcherHostManager(this)); | 1148 new JavaBridgeDispatcherHostManager(this)); |
| 1190 #endif | 1149 #endif |
| 1191 | 1150 |
| 1192 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); | 1151 old_browser_plugin_host_.reset(new old::BrowserPluginHost(this)); |
| 1193 } | 1152 } |
| 1194 | 1153 |
| 1195 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { | 1154 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { |
| 1196 // Clear the opener if it has been closed. | 1155 // Clear the opener if it has been closed. |
| 1197 if (web_contents == opener_) { | 1156 if (web_contents == opener_) { |
| 1198 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1157 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1199 content::Source<WebContents>(opener_)); | 1158 Source<WebContents>(opener_)); |
| 1200 opener_ = NULL; | 1159 opener_ = NULL; |
| 1201 } | 1160 } |
| 1202 } | 1161 } |
| 1203 | 1162 |
| 1204 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { | 1163 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { |
| 1205 observers_.AddObserver(observer); | 1164 observers_.AddObserver(observer); |
| 1206 } | 1165 } |
| 1207 | 1166 |
| 1208 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { | 1167 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { |
| 1209 observers_.RemoveObserver(observer); | 1168 observers_.RemoveObserver(observer); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 // Create the new web contents. This will automatically create the new | 1279 // Create the new web contents. This will automatically create the new |
| 1321 // WebContentsView. In the future, we may want to create the view separately. | 1280 // WebContentsView. In the future, we may want to create the view separately. |
| 1322 WebContentsImpl* new_contents = | 1281 WebContentsImpl* new_contents = |
| 1323 new WebContentsImpl(GetBrowserContext(), | 1282 new WebContentsImpl(GetBrowserContext(), |
| 1324 params.opener_suppressed ? NULL : this); | 1283 params.opener_suppressed ? NULL : this); |
| 1325 | 1284 |
| 1326 // We must assign the SessionStorageNamespace before calling Init(). | 1285 // We must assign the SessionStorageNamespace before calling Init(). |
| 1327 // | 1286 // |
| 1328 // http://crbug.com/142685 | 1287 // http://crbug.com/142685 |
| 1329 const std::string& partition_id = | 1288 const std::string& partition_id = |
| 1330 content::GetContentClient()->browser()-> | 1289 GetContentClient()->browser()-> |
| 1331 GetStoragePartitionIdForSite(GetBrowserContext(), | 1290 GetStoragePartitionIdForSite(GetBrowserContext(), |
| 1332 site_instance->GetSiteURL()); | 1291 site_instance->GetSiteURL()); |
| 1333 content::StoragePartition* partition = | 1292 StoragePartition* partition = |
| 1334 BrowserContext::GetStoragePartition(GetBrowserContext(), | 1293 BrowserContext::GetStoragePartition(GetBrowserContext(), |
| 1335 site_instance); | 1294 site_instance); |
| 1336 DOMStorageContextImpl* dom_storage_context = | 1295 DOMStorageContextImpl* dom_storage_context = |
| 1337 static_cast<DOMStorageContextImpl*>(partition->GetDOMStorageContext()); | 1296 static_cast<DOMStorageContextImpl*>(partition->GetDOMStorageContext()); |
| 1338 SessionStorageNamespaceImpl* session_storage_namespace_impl = | 1297 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1339 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); | 1298 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1340 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); | 1299 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1341 new_contents->GetController().SetSessionStorageNamespace( | 1300 new_contents->GetController().SetSessionStorageNamespace( |
| 1342 partition_id, | 1301 partition_id, |
| 1343 session_storage_namespace); | 1302 session_storage_namespace); |
| 1344 new_contents->Init(GetBrowserContext(), site_instance, route_id, this); | 1303 new_contents->Init(GetBrowserContext(), site_instance, route_id, this); |
| 1345 | 1304 |
| 1346 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); | 1305 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); |
| 1347 | 1306 |
| 1348 if (!params.opener_suppressed) { | 1307 if (!params.opener_suppressed) { |
| 1349 content::WebContentsView* new_view = new_contents->GetView(); | 1308 WebContentsView* new_view = new_contents->GetView(); |
| 1350 | 1309 |
| 1351 // TODO(brettw): It seems bogus that we have to call this function on the | 1310 // TODO(brettw): It seems bogus that we have to call this function on the |
| 1352 // newly created object and give it one of its own member variables. | 1311 // newly created object and give it one of its own member variables. |
| 1353 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1312 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
| 1354 | 1313 |
| 1355 // Save the created window associated with the route so we can show it | 1314 // Save the created window associated with the route so we can show it |
| 1356 // later. | 1315 // later. |
| 1357 DCHECK_NE(MSG_ROUTING_NONE, route_id); | 1316 DCHECK_NE(MSG_ROUTING_NONE, route_id); |
| 1358 pending_contents_[route_id] = new_contents; | 1317 pending_contents_[route_id] = new_contents; |
| 1359 } | 1318 } |
| 1360 | 1319 |
| 1361 if (delegate_) { | 1320 if (delegate_) { |
| 1362 delegate_->WebContentsCreated( | 1321 delegate_->WebContentsCreated( |
| 1363 this, params.opener_frame_id, params.target_url, new_contents); | 1322 this, params.opener_frame_id, params.target_url, new_contents); |
| 1364 } | 1323 } |
| 1365 | 1324 |
| 1366 if (params.opener_suppressed) { | 1325 if (params.opener_suppressed) { |
| 1367 // When the opener is suppressed, the original renderer cannot access the | 1326 // When the opener is suppressed, the original renderer cannot access the |
| 1368 // new window. As a result, we need to show and navigate the window here. | 1327 // new window. As a result, we need to show and navigate the window here. |
| 1369 bool was_blocked = false; | 1328 bool was_blocked = false; |
| 1370 if (delegate_) { | 1329 if (delegate_) { |
| 1371 gfx::Rect initial_pos; | 1330 gfx::Rect initial_pos; |
| 1372 delegate_->AddNewContents( | 1331 delegate_->AddNewContents( |
| 1373 this, new_contents, params.disposition, initial_pos, | 1332 this, new_contents, params.disposition, initial_pos, |
| 1374 params.user_gesture, &was_blocked); | 1333 params.user_gesture, &was_blocked); |
| 1375 } | 1334 } |
| 1376 if (!was_blocked) { | 1335 if (!was_blocked) { |
| 1377 content::OpenURLParams open_params(params.target_url, | 1336 OpenURLParams open_params(params.target_url, |
| 1378 content::Referrer(), | 1337 Referrer(), |
| 1379 CURRENT_TAB, | 1338 CURRENT_TAB, |
| 1380 content::PAGE_TRANSITION_LINK, | 1339 PAGE_TRANSITION_LINK, |
| 1381 true /* is_renderer_initiated */); | 1340 true /* is_renderer_initiated */); |
| 1382 new_contents->OpenURL(open_params); | 1341 new_contents->OpenURL(open_params); |
| 1383 } | 1342 } |
| 1384 } | 1343 } |
| 1385 } | 1344 } |
| 1386 | 1345 |
| 1387 void WebContentsImpl::CreateNewWidget(int route_id, | 1346 void WebContentsImpl::CreateNewWidget(int route_id, |
| 1388 WebKit::WebPopupType popup_type) { | 1347 WebKit::WebPopupType popup_type) { |
| 1389 CreateNewWidget(route_id, false, popup_type); | 1348 CreateNewWidget(route_id, false, popup_type); |
| 1390 } | 1349 } |
| 1391 | 1350 |
| 1392 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { | 1351 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { |
| 1393 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); | 1352 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); |
| 1394 } | 1353 } |
| 1395 | 1354 |
| 1396 void WebContentsImpl::CreateNewWidget(int route_id, | 1355 void WebContentsImpl::CreateNewWidget(int route_id, |
| 1397 bool is_fullscreen, | 1356 bool is_fullscreen, |
| 1398 WebKit::WebPopupType popup_type) { | 1357 WebKit::WebPopupType popup_type) { |
| 1399 content::RenderProcessHost* process = GetRenderProcessHost(); | 1358 RenderProcessHost* process = GetRenderProcessHost(); |
| 1400 RenderWidgetHostImpl* widget_host = | 1359 RenderWidgetHostImpl* widget_host = |
| 1401 new RenderWidgetHostImpl(this, process, route_id); | 1360 new RenderWidgetHostImpl(this, process, route_id); |
| 1402 created_widgets_.insert(widget_host); | 1361 created_widgets_.insert(widget_host); |
| 1403 | 1362 |
| 1404 RenderWidgetHostViewPort* widget_view = | 1363 RenderWidgetHostViewPort* widget_view = |
| 1405 RenderWidgetHostViewPort::CreateViewForWidget(widget_host); | 1364 RenderWidgetHostViewPort::CreateViewForWidget(widget_host); |
| 1406 if (!is_fullscreen) { | 1365 if (!is_fullscreen) { |
| 1407 // Popups should not get activated. | 1366 // Popups should not get activated. |
| 1408 widget_view->SetPopupType(popup_type); | 1367 widget_view->SetPopupType(popup_type); |
| 1409 } | 1368 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); | 1464 RenderWidgetHost* widget_host = widget_host_view->GetRenderWidgetHost(); |
| 1506 if (!widget_host->GetProcess()->HasConnection()) { | 1465 if (!widget_host->GetProcess()->HasConnection()) { |
| 1507 // The view has gone away or the renderer crashed. Nothing to do. | 1466 // The view has gone away or the renderer crashed. Nothing to do. |
| 1508 return NULL; | 1467 return NULL; |
| 1509 } | 1468 } |
| 1510 | 1469 |
| 1511 return widget_host_view; | 1470 return widget_host_view; |
| 1512 } | 1471 } |
| 1513 | 1472 |
| 1514 void WebContentsImpl::ShowContextMenu( | 1473 void WebContentsImpl::ShowContextMenu( |
| 1515 const content::ContextMenuParams& params, | 1474 const ContextMenuParams& params, |
| 1516 content::ContextMenuSourceType type) { | 1475 ContextMenuSourceType type) { |
| 1517 // Allow WebContentsDelegates to handle the context menu operation first. | 1476 // Allow WebContentsDelegates to handle the context menu operation first. |
| 1518 if (delegate_ && delegate_->HandleContextMenu(params)) | 1477 if (delegate_ && delegate_->HandleContextMenu(params)) |
| 1519 return; | 1478 return; |
| 1520 | 1479 |
| 1521 render_view_host_delegate_view_->ShowContextMenu(params, type); | 1480 render_view_host_delegate_view_->ShowContextMenu(params, type); |
| 1522 } | 1481 } |
| 1523 | 1482 |
| 1524 void WebContentsImpl::RequestMediaAccessPermission( | 1483 void WebContentsImpl::RequestMediaAccessPermission( |
| 1525 const content::MediaStreamRequest* request, | 1484 const MediaStreamRequest* request, |
| 1526 const content::MediaResponseCallback& callback) { | 1485 const MediaResponseCallback& callback) { |
| 1527 if (delegate_) | 1486 if (delegate_) |
| 1528 delegate_->RequestMediaAccessPermission(this, request, callback); | 1487 delegate_->RequestMediaAccessPermission(this, request, callback); |
| 1529 else | 1488 else |
| 1530 callback.Run(content::MediaStreamDevices()); | 1489 callback.Run(MediaStreamDevices()); |
| 1531 } | 1490 } |
| 1532 | 1491 |
| 1533 #if defined(OS_ANDROID) | 1492 #if defined(OS_ANDROID) |
| 1534 void WebContentsImpl::AttachLayer(WebKit::WebLayer* layer) { | 1493 void WebContentsImpl::AttachLayer(WebKit::WebLayer* layer) { |
| 1535 if (delegate_) | 1494 if (delegate_) |
| 1536 delegate_->AttachLayer(this, layer); | 1495 delegate_->AttachLayer(this, layer); |
| 1537 } | 1496 } |
| 1538 | 1497 |
| 1539 void WebContentsImpl::RemoveLayer(WebKit::WebLayer* layer) { | 1498 void WebContentsImpl::RemoveLayer(WebKit::WebLayer* layer) { |
| 1540 if (delegate_) | 1499 if (delegate_) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 } | 1534 } |
| 1576 | 1535 |
| 1577 bool WebContentsImpl::NavigateToPendingEntry( | 1536 bool WebContentsImpl::NavigateToPendingEntry( |
| 1578 NavigationController::ReloadType reload_type) { | 1537 NavigationController::ReloadType reload_type) { |
| 1579 return NavigateToEntry( | 1538 return NavigateToEntry( |
| 1580 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), | 1539 *NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()), |
| 1581 reload_type); | 1540 reload_type); |
| 1582 } | 1541 } |
| 1583 | 1542 |
| 1584 void WebContentsImpl::RenderViewForInterstitialPageCreated( | 1543 void WebContentsImpl::RenderViewForInterstitialPageCreated( |
| 1585 content::RenderViewHost* render_view_host) { | 1544 RenderViewHost* render_view_host) { |
| 1586 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1545 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1587 RenderViewForInterstitialPageCreated(render_view_host)); | 1546 RenderViewForInterstitialPageCreated(render_view_host)); |
| 1588 } | 1547 } |
| 1589 | 1548 |
| 1590 bool WebContentsImpl::NavigateToEntry( | 1549 bool WebContentsImpl::NavigateToEntry( |
| 1591 const NavigationEntryImpl& entry, | 1550 const NavigationEntryImpl& entry, |
| 1592 NavigationController::ReloadType reload_type) { | 1551 NavigationController::ReloadType reload_type) { |
| 1593 // The renderer will reject IPC messages with URLs longer than | 1552 // The renderer will reject IPC messages with URLs longer than |
| 1594 // this limit, so don't attempt to navigate with a longer URL. | 1553 // this limit, so don't attempt to navigate with a longer URL. |
| 1595 if (entry.GetURL().spec().size() > content::kMaxURLChars) | 1554 if (entry.GetURL().spec().size() > kMaxURLChars) |
| 1596 return false; | 1555 return false; |
| 1597 | 1556 |
| 1598 RenderViewHostImpl* dest_render_view_host = | 1557 RenderViewHostImpl* dest_render_view_host = |
| 1599 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1558 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); |
| 1600 if (!dest_render_view_host) | 1559 if (!dest_render_view_host) |
| 1601 return false; // Unable to create the desired render view host. | 1560 return false; // Unable to create the desired render view host. |
| 1602 | 1561 |
| 1603 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1562 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 1604 // Double check that here. | 1563 // Double check that here. |
| 1605 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1564 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
| 1606 WebUIControllerFactory* factory = | 1565 WebUIControllerFactory* factory = |
| 1607 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 1566 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1608 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1567 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
| 1609 bool is_allowed_in_web_ui_renderer = | 1568 bool is_allowed_in_web_ui_renderer = |
| 1610 factory && | 1569 factory && |
| 1611 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), | 1570 factory->IsURLAcceptableForWebUI(GetBrowserContext(), entry.GetURL(), |
| 1612 data_urls_allowed); | 1571 data_urls_allowed); |
| 1613 if ((enabled_bindings & content::BINDINGS_POLICY_WEB_UI) && | 1572 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
| 1614 !is_allowed_in_web_ui_renderer) { | 1573 !is_allowed_in_web_ui_renderer) { |
| 1615 // Log the URL to help us diagnose any future failures of this CHECK. | 1574 // Log the URL to help us diagnose any future failures of this CHECK. |
| 1616 content::GetContentClient()->SetActiveURL(entry.GetURL()); | 1575 GetContentClient()->SetActiveURL(entry.GetURL()); |
| 1617 CHECK(0); | 1576 CHECK(0); |
| 1618 } | 1577 } |
| 1619 | 1578 |
| 1620 // Tell DevTools agent that it is attached prior to the navigation. | 1579 // Tell DevTools agent that it is attached prior to the navigation. |
| 1621 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( | 1580 DevToolsManagerImpl::GetInstance()->OnNavigatingToPendingEntry( |
| 1622 GetRenderViewHost(), | 1581 GetRenderViewHost(), |
| 1623 dest_render_view_host, | 1582 dest_render_view_host, |
| 1624 entry.GetURL()); | 1583 entry.GetURL()); |
| 1625 | 1584 |
| 1626 // Notify observers that we will navigate in this RV. | 1585 // Notify observers that we will navigate in this RV. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 contents_mime_type_ == "text/plain" || | 1673 contents_mime_type_ == "text/plain" || |
| 1715 contents_mime_type_ == "text/css" || | 1674 contents_mime_type_ == "text/css" || |
| 1716 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); | 1675 net::IsSupportedJavascriptMimeType(contents_mime_type_.c_str()); |
| 1717 } | 1676 } |
| 1718 | 1677 |
| 1719 void WebContentsImpl::OnSavePage() { | 1678 void WebContentsImpl::OnSavePage() { |
| 1720 // If we can not save the page, try to download it. | 1679 // If we can not save the page, try to download it. |
| 1721 if (!IsSavable()) { | 1680 if (!IsSavable()) { |
| 1722 download_stats::RecordDownloadSource( | 1681 download_stats::RecordDownloadSource( |
| 1723 download_stats::INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); | 1682 download_stats::INITIATED_BY_SAVE_PACKAGE_ON_NON_HTML); |
| 1724 SaveURL(GetURL(), content::Referrer(), true); | 1683 SaveURL(GetURL(), Referrer(), true); |
| 1725 return; | 1684 return; |
| 1726 } | 1685 } |
| 1727 | 1686 |
| 1728 Stop(); | 1687 Stop(); |
| 1729 | 1688 |
| 1730 // Create the save package and possibly prompt the user for the name to save | 1689 // Create the save package and possibly prompt the user for the name to save |
| 1731 // the page as. The user prompt is an asynchronous operation that runs on | 1690 // the page as. The user prompt is an asynchronous operation that runs on |
| 1732 // another thread. | 1691 // another thread. |
| 1733 save_package_ = new SavePackage(this); | 1692 save_package_ = new SavePackage(this); |
| 1734 save_package_->GetSaveInfo(); | 1693 save_package_->GetSaveInfo(); |
| 1735 } | 1694 } |
| 1736 | 1695 |
| 1737 // Used in automated testing to bypass prompting the user for file names. | 1696 // Used in automated testing to bypass prompting the user for file names. |
| 1738 // Instead, the names and paths are hard coded rather than running them through | 1697 // Instead, the names and paths are hard coded rather than running them through |
| 1739 // file name sanitation and extension / mime checking. | 1698 // file name sanitation and extension / mime checking. |
| 1740 bool WebContentsImpl::SavePage(const FilePath& main_file, | 1699 bool WebContentsImpl::SavePage(const FilePath& main_file, |
| 1741 const FilePath& dir_path, | 1700 const FilePath& dir_path, |
| 1742 content::SavePageType save_type) { | 1701 SavePageType save_type) { |
| 1743 // Stop the page from navigating. | 1702 // Stop the page from navigating. |
| 1744 Stop(); | 1703 Stop(); |
| 1745 | 1704 |
| 1746 save_package_ = new SavePackage(this, save_type, main_file, dir_path); | 1705 save_package_ = new SavePackage(this, save_type, main_file, dir_path); |
| 1747 return save_package_->Init(content::SavePackageDownloadCreatedCallback()); | 1706 return save_package_->Init(SavePackageDownloadCreatedCallback()); |
| 1748 } | 1707 } |
| 1749 | 1708 |
| 1750 void WebContentsImpl::GenerateMHTML( | 1709 void WebContentsImpl::GenerateMHTML( |
| 1751 const FilePath& file, | 1710 const FilePath& file, |
| 1752 const base::Callback<void(const FilePath&, int64)>& callback) { | 1711 const base::Callback<void(const FilePath&, int64)>& callback) { |
| 1753 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); | 1712 MHTMLGenerationManager::GetInstance()->GenerateMHTML(this, file, callback); |
| 1754 } | 1713 } |
| 1755 | 1714 |
| 1756 bool WebContentsImpl::IsActiveEntry(int32 page_id) { | 1715 bool WebContentsImpl::IsActiveEntry(int32 page_id) { |
| 1757 NavigationEntryImpl* active_entry = | 1716 NavigationEntryImpl* active_entry = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1772 void WebContentsImpl::SetOverrideEncoding(const std::string& encoding) { | 1731 void WebContentsImpl::SetOverrideEncoding(const std::string& encoding) { |
| 1773 SetEncoding(encoding); | 1732 SetEncoding(encoding); |
| 1774 Send(new ViewMsg_SetPageEncoding(GetRoutingID(), encoding)); | 1733 Send(new ViewMsg_SetPageEncoding(GetRoutingID(), encoding)); |
| 1775 } | 1734 } |
| 1776 | 1735 |
| 1777 void WebContentsImpl::ResetOverrideEncoding() { | 1736 void WebContentsImpl::ResetOverrideEncoding() { |
| 1778 encoding_.clear(); | 1737 encoding_.clear(); |
| 1779 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); | 1738 Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID())); |
| 1780 } | 1739 } |
| 1781 | 1740 |
| 1782 content::RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { | 1741 RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { |
| 1783 return &renderer_preferences_; | 1742 return &renderer_preferences_; |
| 1784 } | 1743 } |
| 1785 | 1744 |
| 1786 void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) { | 1745 void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) { |
| 1787 new_tab_start_time_ = time; | 1746 new_tab_start_time_ = time; |
| 1788 } | 1747 } |
| 1789 | 1748 |
| 1790 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { | 1749 base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { |
| 1791 return new_tab_start_time_; | 1750 return new_tab_start_time_; |
| 1792 } | 1751 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 gfx::Size WebContentsImpl::GetPreferredSize() const { | 1853 gfx::Size WebContentsImpl::GetPreferredSize() const { |
| 1895 return preferred_size_; | 1854 return preferred_size_; |
| 1896 } | 1855 } |
| 1897 | 1856 |
| 1898 int WebContentsImpl::GetContentRestrictions() const { | 1857 int WebContentsImpl::GetContentRestrictions() const { |
| 1899 return content_restrictions_; | 1858 return content_restrictions_; |
| 1900 } | 1859 } |
| 1901 | 1860 |
| 1902 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { | 1861 WebUI::TypeID WebContentsImpl::GetWebUITypeForCurrentState() { |
| 1903 WebUIControllerFactory* factory = | 1862 WebUIControllerFactory* factory = |
| 1904 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 1863 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 1905 if (!factory) | 1864 if (!factory) |
| 1906 return WebUI::kNoWebUI; | 1865 return WebUI::kNoWebUI; |
| 1907 return factory->GetWebUIType(GetBrowserContext(), GetURL()); | 1866 return factory->GetWebUIType(GetBrowserContext(), GetURL()); |
| 1908 } | 1867 } |
| 1909 | 1868 |
| 1910 content::WebUI* WebContentsImpl::GetWebUIForCurrentState() { | 1869 WebUI* WebContentsImpl::GetWebUIForCurrentState() { |
| 1911 // When there is a pending navigation entry, we want to use the pending WebUI | 1870 // When there is a pending navigation entry, we want to use the pending WebUI |
| 1912 // that goes along with it to control the basic flags. For example, we want to | 1871 // that goes along with it to control the basic flags. For example, we want to |
| 1913 // show the pending URL in the URL bar, so we want the display_url flag to | 1872 // show the pending URL in the URL bar, so we want the display_url flag to |
| 1914 // be from the pending entry. | 1873 // be from the pending entry. |
| 1915 // | 1874 // |
| 1916 // The confusion comes because there are multiple possibilities for the | 1875 // The confusion comes because there are multiple possibilities for the |
| 1917 // initial load in a tab as a side effect of the way the RenderViewHostManager | 1876 // initial load in a tab as a side effect of the way the RenderViewHostManager |
| 1918 // works. | 1877 // works. |
| 1919 // | 1878 // |
| 1920 // - For the very first tab the load looks "normal". The new tab Web UI is | 1879 // - For the very first tab the load looks "normal". The new tab Web UI is |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 } | 1922 } |
| 1964 | 1923 |
| 1965 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { | 1924 void WebContentsImpl::DidEndColorChooser(int color_chooser_id) { |
| 1966 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); | 1925 Send(new ViewMsg_DidEndColorChooser(GetRoutingID(), color_chooser_id)); |
| 1967 if (delegate_) | 1926 if (delegate_) |
| 1968 delegate_->DidEndColorChooser(); | 1927 delegate_->DidEndColorChooser(); |
| 1969 color_chooser_ = NULL; | 1928 color_chooser_ = NULL; |
| 1970 } | 1929 } |
| 1971 | 1930 |
| 1972 bool WebContentsImpl::FocusLocationBarByDefault() { | 1931 bool WebContentsImpl::FocusLocationBarByDefault() { |
| 1973 content::WebUI* web_ui = GetWebUIForCurrentState(); | 1932 WebUI* web_ui = GetWebUIForCurrentState(); |
| 1974 if (web_ui) | 1933 if (web_ui) |
| 1975 return web_ui->ShouldFocusLocationBarByDefault(); | 1934 return web_ui->ShouldFocusLocationBarByDefault(); |
| 1976 NavigationEntry* entry = controller_.GetActiveEntry(); | 1935 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 1977 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); | 1936 return (entry && entry->GetURL() == GURL(chrome::kAboutBlankURL)); |
| 1978 } | 1937 } |
| 1979 | 1938 |
| 1980 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 1939 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
| 1981 if (delegate_) | 1940 if (delegate_) |
| 1982 delegate_->SetFocusToLocationBar(select_all); | 1941 delegate_->SetFocusToLocationBar(select_all); |
| 1983 } | 1942 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1994 int intent_id) { | 1953 int intent_id) { |
| 1995 if (!delegate_) | 1954 if (!delegate_) |
| 1996 return; | 1955 return; |
| 1997 | 1956 |
| 1998 WebIntentsDispatcherImpl* intents_dispatcher = | 1957 WebIntentsDispatcherImpl* intents_dispatcher = |
| 1999 new WebIntentsDispatcherImpl(this, intent, intent_id); | 1958 new WebIntentsDispatcherImpl(this, intent, intent_id); |
| 2000 delegate_->WebIntentDispatch(this, intents_dispatcher); | 1959 delegate_->WebIntentDispatch(this, intents_dispatcher); |
| 2001 } | 1960 } |
| 2002 | 1961 |
| 2003 void WebContentsImpl::DidStartProvisionalLoadForFrame( | 1962 void WebContentsImpl::DidStartProvisionalLoadForFrame( |
| 2004 content::RenderViewHost* render_view_host, | 1963 RenderViewHost* render_view_host, |
| 2005 int64 frame_id, | 1964 int64 frame_id, |
| 2006 int64 parent_frame_id, | 1965 int64 parent_frame_id, |
| 2007 bool is_main_frame, | 1966 bool is_main_frame, |
| 2008 const GURL& opener_url, | 1967 const GURL& opener_url, |
| 2009 const GURL& url) { | 1968 const GURL& url) { |
| 2010 bool is_error_page = (url.spec() == content::kUnreachableWebDataURL); | 1969 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
| 2011 GURL validated_url(url); | 1970 GURL validated_url(url); |
| 2012 GURL validated_opener_url(opener_url); | 1971 GURL validated_opener_url(opener_url); |
| 2013 content::RenderProcessHost* render_process_host = | 1972 RenderProcessHost* render_process_host = |
| 2014 render_view_host->GetProcess(); | 1973 render_view_host->GetProcess(); |
| 2015 RenderViewHost::FilterURL( | 1974 RenderViewHost::FilterURL( |
| 2016 render_process_host->GetID(), | 1975 render_process_host->GetID(), |
| 2017 false, | 1976 false, |
| 2018 &validated_url); | 1977 &validated_url); |
| 2019 RenderViewHost::FilterURL( | 1978 RenderViewHost::FilterURL( |
| 2020 render_process_host->GetID(), | 1979 render_process_host->GetID(), |
| 2021 true, | 1980 true, |
| 2022 &validated_opener_url); | 1981 &validated_opener_url); |
| 2023 | 1982 |
| 2024 // Notify observers about the start of the provisional load. | 1983 // Notify observers about the start of the provisional load. |
| 2025 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1984 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2026 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, | 1985 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, |
| 2027 is_main_frame, validated_url, is_error_page, | 1986 is_main_frame, validated_url, is_error_page, |
| 2028 render_view_host)); | 1987 render_view_host)); |
| 2029 | 1988 |
| 2030 if (is_main_frame) { | 1989 if (is_main_frame) { |
| 2031 // Notify observers about the provisional change in the main frame URL. | 1990 // Notify observers about the provisional change in the main frame URL. |
| 2032 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1991 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2033 ProvisionalChangeToMainFrameUrl(validated_url, | 1992 ProvisionalChangeToMainFrameUrl(validated_url, |
| 2034 validated_opener_url, | 1993 validated_opener_url, |
| 2035 render_view_host)); | 1994 render_view_host)); |
| 2036 } | 1995 } |
| 2037 } | 1996 } |
| 2038 | 1997 |
| 2039 void WebContentsImpl::DidRedirectProvisionalLoad( | 1998 void WebContentsImpl::DidRedirectProvisionalLoad( |
| 2040 content::RenderViewHost* render_view_host, | 1999 RenderViewHost* render_view_host, |
| 2041 int32 page_id, | 2000 int32 page_id, |
| 2042 const GURL& opener_url, | 2001 const GURL& opener_url, |
| 2043 const GURL& source_url, | 2002 const GURL& source_url, |
| 2044 const GURL& target_url) { | 2003 const GURL& target_url) { |
| 2045 // TODO(creis): Remove this method and have the pre-rendering code listen to | 2004 // TODO(creis): Remove this method and have the pre-rendering code listen to |
| 2046 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 2005 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
| 2047 // instead. See http://crbug.com/78512. | 2006 // instead. See http://crbug.com/78512. |
| 2048 GURL validated_source_url(source_url); | 2007 GURL validated_source_url(source_url); |
| 2049 GURL validated_target_url(target_url); | 2008 GURL validated_target_url(target_url); |
| 2050 GURL validated_opener_url(opener_url); | 2009 GURL validated_opener_url(opener_url); |
| 2051 content::RenderProcessHost* render_process_host = | 2010 RenderProcessHost* render_process_host = |
| 2052 render_view_host->GetProcess(); | 2011 render_view_host->GetProcess(); |
| 2053 RenderViewHostImpl::FilterURL( | 2012 RenderViewHostImpl::FilterURL( |
| 2054 ChildProcessSecurityPolicyImpl::GetInstance(), | 2013 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 2055 render_process_host->GetID(), | 2014 render_process_host->GetID(), |
| 2056 false, | 2015 false, |
| 2057 &validated_source_url); | 2016 &validated_source_url); |
| 2058 RenderViewHostImpl::FilterURL( | 2017 RenderViewHostImpl::FilterURL( |
| 2059 ChildProcessSecurityPolicyImpl::GetInstance(), | 2018 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 2060 render_process_host->GetID(), | 2019 render_process_host->GetID(), |
| 2061 false, | 2020 false, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2076 return; | 2035 return; |
| 2077 | 2036 |
| 2078 // Notify observers about the provisional change in the main frame URL. | 2037 // Notify observers about the provisional change in the main frame URL. |
| 2079 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2038 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2080 ProvisionalChangeToMainFrameUrl(validated_target_url, | 2039 ProvisionalChangeToMainFrameUrl(validated_target_url, |
| 2081 validated_opener_url, | 2040 validated_opener_url, |
| 2082 render_view_host)); | 2041 render_view_host)); |
| 2083 } | 2042 } |
| 2084 | 2043 |
| 2085 void WebContentsImpl::DidFailProvisionalLoadWithError( | 2044 void WebContentsImpl::DidFailProvisionalLoadWithError( |
| 2086 content::RenderViewHost* render_view_host, | 2045 RenderViewHost* render_view_host, |
| 2087 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 2046 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
| 2088 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 2047 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
| 2089 << ", error_code: " << params.error_code | 2048 << ", error_code: " << params.error_code |
| 2090 << ", error_description: " << params.error_description | 2049 << ", error_description: " << params.error_description |
| 2091 << ", is_main_frame: " << params.is_main_frame | 2050 << ", is_main_frame: " << params.is_main_frame |
| 2092 << ", showing_repost_interstitial: " << | 2051 << ", showing_repost_interstitial: " << |
| 2093 params.showing_repost_interstitial | 2052 params.showing_repost_interstitial |
| 2094 << ", frame_id: " << params.frame_id; | 2053 << ", frame_id: " << params.frame_id; |
| 2095 GURL validated_url(params.url); | 2054 GURL validated_url(params.url); |
| 2096 content::RenderProcessHost* render_process_host = | 2055 RenderProcessHost* render_process_host = |
| 2097 render_view_host->GetProcess(); | 2056 render_view_host->GetProcess(); |
| 2098 RenderViewHost::FilterURL( | 2057 RenderViewHost::FilterURL( |
| 2099 render_process_host->GetID(), | 2058 render_process_host->GetID(), |
| 2100 false, | 2059 false, |
| 2101 &validated_url); | 2060 &validated_url); |
| 2102 | 2061 |
| 2103 if (net::ERR_ABORTED == params.error_code) { | 2062 if (net::ERR_ABORTED == params.error_code) { |
| 2104 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 2063 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
| 2105 // This means that the interstitial won't be torn down properly, which is | 2064 // This means that the interstitial won't be torn down properly, which is |
| 2106 // bad. But if we have an interstitial, go back to another tab type, and | 2065 // bad. But if we have an interstitial, go back to another tab type, and |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 const std::string& mime_type, | 2107 const std::string& mime_type, |
| 2149 ResourceType::Type resource_type) { | 2108 ResourceType::Type resource_type) { |
| 2150 base::StatsCounter cache("WebKit.CacheHit"); | 2109 base::StatsCounter cache("WebKit.CacheHit"); |
| 2151 cache.Increment(); | 2110 cache.Increment(); |
| 2152 | 2111 |
| 2153 // Send out a notification that we loaded a resource from our memory cache. | 2112 // Send out a notification that we loaded a resource from our memory cache. |
| 2154 int cert_id = 0; | 2113 int cert_id = 0; |
| 2155 net::CertStatus cert_status = 0; | 2114 net::CertStatus cert_status = 0; |
| 2156 int security_bits = -1; | 2115 int security_bits = -1; |
| 2157 int connection_status = 0; | 2116 int connection_status = 0; |
| 2158 content::DeserializeSecurityInfo(security_info, &cert_id, &cert_status, | 2117 DeserializeSecurityInfo(security_info, &cert_id, &cert_status, |
| 2159 &security_bits, &connection_status); | 2118 &security_bits, &connection_status); |
| 2160 content::LoadFromMemoryCacheDetails details( | 2119 LoadFromMemoryCacheDetails details( |
| 2161 url, GetRenderProcessHost()->GetID(), cert_id, cert_status, http_method, | 2120 url, GetRenderProcessHost()->GetID(), cert_id, cert_status, http_method, |
| 2162 mime_type, resource_type); | 2121 mime_type, resource_type); |
| 2163 | 2122 |
| 2164 content::NotificationService::current()->Notify( | 2123 NotificationService::current()->Notify( |
| 2165 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 2124 NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
| 2166 content::Source<NavigationController>(&controller_), | 2125 Source<NavigationController>(&controller_), |
| 2167 content::Details<content::LoadFromMemoryCacheDetails>(&details)); | 2126 Details<LoadFromMemoryCacheDetails>(&details)); |
| 2168 } | 2127 } |
| 2169 | 2128 |
| 2170 void WebContentsImpl::OnDidDisplayInsecureContent() { | 2129 void WebContentsImpl::OnDidDisplayInsecureContent() { |
| 2171 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 2130 RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
| 2172 displayed_insecure_content_ = true; | 2131 displayed_insecure_content_ = true; |
| 2173 SSLManager::NotifySSLInternalStateChanged(&GetController()); | 2132 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
| 2174 } | 2133 } |
| 2175 | 2134 |
| 2176 void WebContentsImpl::OnDidRunInsecureContent( | 2135 void WebContentsImpl::OnDidRunInsecureContent( |
| 2177 const std::string& security_origin, const GURL& target_url) { | 2136 const std::string& security_origin, const GURL& target_url) { |
| 2178 LOG(INFO) << security_origin << " ran insecure content from " | 2137 LOG(INFO) << security_origin << " ran insecure content from " |
| 2179 << target_url.possibly_invalid_spec(); | 2138 << target_url.possibly_invalid_spec(); |
| 2180 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); | 2139 RecordAction(UserMetricsAction("SSL.RanInsecureContent")); |
| 2181 if (EndsWith(security_origin, kDotGoogleDotCom, false)) | 2140 if (EndsWith(security_origin, kDotGoogleDotCom, false)) |
| 2182 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); | 2141 RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); |
| 2183 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | 2142 controller_.ssl_manager()->DidRunInsecureContent(security_origin); |
| 2184 displayed_insecure_content_ = true; | 2143 displayed_insecure_content_ = true; |
| 2185 SSLManager::NotifySSLInternalStateChanged(&GetController()); | 2144 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
| 2186 } | 2145 } |
| 2187 | 2146 |
| 2188 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { | 2147 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { |
| 2189 controller_.DocumentLoadedInFrame(); | 2148 controller_.DocumentLoadedInFrame(); |
| 2190 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2149 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2191 DocumentLoadedInFrame(frame_id, message_source_)); | 2150 DocumentLoadedInFrame(frame_id, message_source_)); |
| 2192 } | 2151 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2221 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 2180 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { |
| 2222 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { | 2181 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) { |
| 2223 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 2182 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
| 2224 controller_.GetEntryAtOffset(offset)); | 2183 controller_.GetEntryAtOffset(offset)); |
| 2225 if (!entry) | 2184 if (!entry) |
| 2226 return; | 2185 return; |
| 2227 // Note that we don't call NavigationController::GotToOffset() as we don't | 2186 // Note that we don't call NavigationController::GotToOffset() as we don't |
| 2228 // want to create a pending navigation entry (it might end up lingering | 2187 // want to create a pending navigation entry (it might end up lingering |
| 2229 // http://crbug.com/51680). | 2188 // http://crbug.com/51680). |
| 2230 entry->SetTransitionType( | 2189 entry->SetTransitionType( |
| 2231 content::PageTransitionFromInt( | 2190 PageTransitionFromInt( |
| 2232 entry->GetTransitionType() | | 2191 entry->GetTransitionType() | |
| 2233 content::PAGE_TRANSITION_FORWARD_BACK)); | 2192 PAGE_TRANSITION_FORWARD_BACK)); |
| 2234 NavigateToEntry(*entry, NavigationControllerImpl::NO_RELOAD); | 2193 NavigateToEntry(*entry, NavigationControllerImpl::NO_RELOAD); |
| 2235 | 2194 |
| 2236 // If the entry is being restored and doesn't have a SiteInstance yet, fill | 2195 // If the entry is being restored and doesn't have a SiteInstance yet, fill |
| 2237 // it in now that we know. This allows us to find the entry when it commits. | 2196 // it in now that we know. This allows us to find the entry when it commits. |
| 2238 if (!entry->site_instance() && | 2197 if (!entry->site_instance() && |
| 2239 entry->restore_type() != NavigationEntryImpl::RESTORE_NONE) { | 2198 entry->restore_type() != NavigationEntryImpl::RESTORE_NONE) { |
| 2240 entry->set_site_instance( | 2199 entry->set_site_instance( |
| 2241 static_cast<SiteInstanceImpl*>(GetPendingSiteInstance())); | 2200 static_cast<SiteInstanceImpl*>(GetPendingSiteInstance())); |
| 2242 } | 2201 } |
| 2243 } | 2202 } |
| 2244 } | 2203 } |
| 2245 | 2204 |
| 2246 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 2205 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
| 2247 int maximum_percent, | 2206 int maximum_percent, |
| 2248 bool remember) { | 2207 bool remember) { |
| 2249 minimum_zoom_percent_ = minimum_percent; | 2208 minimum_zoom_percent_ = minimum_percent; |
| 2250 maximum_zoom_percent_ = maximum_percent; | 2209 maximum_zoom_percent_ = maximum_percent; |
| 2251 temporary_zoom_settings_ = !remember; | 2210 temporary_zoom_settings_ = !remember; |
| 2252 } | 2211 } |
| 2253 | 2212 |
| 2254 void WebContentsImpl::OnSaveURL(const GURL& url, | 2213 void WebContentsImpl::OnSaveURL(const GURL& url, |
| 2255 const content::Referrer& referrer) { | 2214 const Referrer& referrer) { |
| 2256 download_stats::RecordDownloadSource( | 2215 download_stats::RecordDownloadSource( |
| 2257 download_stats::INITIATED_BY_PEPPER_SAVE); | 2216 download_stats::INITIATED_BY_PEPPER_SAVE); |
| 2258 // Check if the URL to save matches the URL of the main frame. Since this | 2217 // Check if the URL to save matches the URL of the main frame. Since this |
| 2259 // message originates from Pepper plugins, it may not be the case if the | 2218 // message originates from Pepper plugins, it may not be the case if the |
| 2260 // plugin is an embedded element. | 2219 // plugin is an embedded element. |
| 2261 GURL main_frame_url = GetURL(); | 2220 GURL main_frame_url = GetURL(); |
| 2262 if (!main_frame_url.is_valid()) | 2221 if (!main_frame_url.is_valid()) |
| 2263 return; | 2222 return; |
| 2264 bool is_main_frame = (url == main_frame_url); | 2223 bool is_main_frame = (url == main_frame_url); |
| 2265 SaveURL(url, referrer, is_main_frame); | 2224 SaveURL(url, referrer, is_main_frame); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2403 // For more info, see comment above classes BrowserPluginEmbedder and | 2362 // For more info, see comment above classes BrowserPluginEmbedder and |
| 2404 // BrowserPluginGuest. | 2363 // BrowserPluginGuest. |
| 2405 // The first BrowserPluginHostMsg_CreateGuest message from this WebContents' | 2364 // The first BrowserPluginHostMsg_CreateGuest message from this WebContents' |
| 2406 // embedder render process is handled here. Once BrowserPluginEmbedder is | 2365 // embedder render process is handled here. Once BrowserPluginEmbedder is |
| 2407 // created, all subsequent BrowserPluginHostMsg_CreateGuest messages are | 2366 // created, all subsequent BrowserPluginHostMsg_CreateGuest messages are |
| 2408 // intercepted by the BrowserPluginEmbedderHelper and handled by the | 2367 // intercepted by the BrowserPluginEmbedderHelper and handled by the |
| 2409 // BrowserPluginEmbedder. Thus, this code will not be executed if a | 2368 // BrowserPluginEmbedder. Thus, this code will not be executed if a |
| 2410 // BrowserPluginEmbedder exists for this WebContents. | 2369 // BrowserPluginEmbedder exists for this WebContents. |
| 2411 CHECK(!browser_plugin_embedder_.get()); | 2370 CHECK(!browser_plugin_embedder_.get()); |
| 2412 browser_plugin_embedder_.reset( | 2371 browser_plugin_embedder_.reset( |
| 2413 content::BrowserPluginEmbedder::Create(this, GetRenderViewHost())); | 2372 BrowserPluginEmbedder::Create(this, GetRenderViewHost())); |
| 2414 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), | 2373 browser_plugin_embedder_->CreateGuest(GetRenderViewHost(), |
| 2415 instance_id, | 2374 instance_id, |
| 2416 storage_partition_id, | 2375 storage_partition_id, |
| 2417 persist_storage); | 2376 persist_storage); |
| 2418 } | 2377 } |
| 2419 | 2378 |
| 2420 // Notifies the RenderWidgetHost instance about the fact that the page is | 2379 // Notifies the RenderWidgetHost instance about the fact that the page is |
| 2421 // loading, or done loading and calls the base implementation. | 2380 // loading, or done loading and calls the base implementation. |
| 2422 void WebContentsImpl::SetIsLoading(bool is_loading, | 2381 void WebContentsImpl::SetIsLoading(bool is_loading, |
| 2423 LoadNotificationDetails* details) { | 2382 LoadNotificationDetails* details) { |
| 2424 if (is_loading == is_loading_) | 2383 if (is_loading == is_loading_) |
| 2425 return; | 2384 return; |
| 2426 | 2385 |
| 2427 if (!is_loading) { | 2386 if (!is_loading) { |
| 2428 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2387 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
| 2429 load_state_host_.clear(); | 2388 load_state_host_.clear(); |
| 2430 upload_size_ = 0; | 2389 upload_size_ = 0; |
| 2431 upload_position_ = 0; | 2390 upload_position_ = 0; |
| 2432 } | 2391 } |
| 2433 | 2392 |
| 2434 render_manager_.SetIsLoading(is_loading); | 2393 render_manager_.SetIsLoading(is_loading); |
| 2435 | 2394 |
| 2436 is_loading_ = is_loading; | 2395 is_loading_ = is_loading; |
| 2437 waiting_for_response_ = is_loading; | 2396 waiting_for_response_ = is_loading; |
| 2438 | 2397 |
| 2439 if (delegate_) | 2398 if (delegate_) |
| 2440 delegate_->LoadingStateChanged(this); | 2399 delegate_->LoadingStateChanged(this); |
| 2441 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_LOAD); | 2400 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
| 2442 | 2401 |
| 2443 int type = is_loading ? content::NOTIFICATION_LOAD_START : | 2402 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP; |
| 2444 content::NOTIFICATION_LOAD_STOP; | 2403 NotificationDetails det = NotificationService::NoDetails(); |
| 2445 content::NotificationDetails det = content::NotificationService::NoDetails(); | |
| 2446 if (details) | 2404 if (details) |
| 2447 det = content::Details<LoadNotificationDetails>(details); | 2405 det = Details<LoadNotificationDetails>(details); |
| 2448 content::NotificationService::current()->Notify(type, | 2406 NotificationService::current()->Notify( |
| 2449 content::Source<NavigationController>(&controller_), | 2407 type, Source<NavigationController>(&controller_), det); |
| 2450 det); | |
| 2451 } | 2408 } |
| 2452 | 2409 |
| 2453 void WebContentsImpl::DidNavigateMainFramePostCommit( | 2410 void WebContentsImpl::DidNavigateMainFramePostCommit( |
| 2454 const content::LoadCommittedDetails& details, | 2411 const LoadCommittedDetails& details, |
| 2455 const ViewHostMsg_FrameNavigate_Params& params) { | 2412 const ViewHostMsg_FrameNavigate_Params& params) { |
| 2456 if (opener_web_ui_type_ != WebUI::kNoWebUI) { | 2413 if (opener_web_ui_type_ != WebUI::kNoWebUI) { |
| 2457 // If this is a window.open navigation, use the same WebUI as the renderer | 2414 // If this is a window.open navigation, use the same WebUI as the renderer |
| 2458 // that opened the window, as long as both renderers have the same | 2415 // that opened the window, as long as both renderers have the same |
| 2459 // privileges. | 2416 // privileges. |
| 2460 if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) { | 2417 if (delegate_ && opener_web_ui_type_ == GetWebUITypeForCurrentState()) { |
| 2461 WebUIImpl* web_ui = static_cast<WebUIImpl*>(CreateWebUI(GetURL())); | 2418 WebUIImpl* web_ui = static_cast<WebUIImpl*>(CreateWebUI(GetURL())); |
| 2462 // web_ui might be NULL if the URL refers to a non-existent extension. | 2419 // web_ui might be NULL if the URL refers to a non-existent extension. |
| 2463 if (web_ui) { | 2420 if (web_ui) { |
| 2464 render_manager_.SetWebUIPostCommit(web_ui); | 2421 render_manager_.SetWebUIPostCommit(web_ui); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2484 displayed_insecure_content_ = false; | 2441 displayed_insecure_content_ = false; |
| 2485 } | 2442 } |
| 2486 | 2443 |
| 2487 // Notify observers about navigation. | 2444 // Notify observers about navigation. |
| 2488 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2445 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2489 DidNavigateMainFrame(details, params)); | 2446 DidNavigateMainFrame(details, params)); |
| 2490 } | 2447 } |
| 2491 | 2448 |
| 2492 void WebContentsImpl::DidNavigateAnyFramePostCommit( | 2449 void WebContentsImpl::DidNavigateAnyFramePostCommit( |
| 2493 RenderViewHost* render_view_host, | 2450 RenderViewHost* render_view_host, |
| 2494 const content::LoadCommittedDetails& details, | 2451 const LoadCommittedDetails& details, |
| 2495 const ViewHostMsg_FrameNavigate_Params& params) { | 2452 const ViewHostMsg_FrameNavigate_Params& params) { |
| 2496 // If we navigate off the page, reset JavaScript state. This does nothing | 2453 // If we navigate off the page, reset JavaScript state. This does nothing |
| 2497 // to prevent a malicious script from spamming messages, since the script | 2454 // to prevent a malicious script from spamming messages, since the script |
| 2498 // could just reload the page to stop blocking. | 2455 // could just reload the page to stop blocking. |
| 2499 if (dialog_creator_ && !details.is_in_page) { | 2456 if (dialog_creator_ && !details.is_in_page) { |
| 2500 dialog_creator_->ResetJavaScriptState(this); | 2457 dialog_creator_->ResetJavaScriptState(this); |
| 2501 dialog_creator_ = NULL; | 2458 dialog_creator_ = NULL; |
| 2502 } | 2459 } |
| 2503 | 2460 |
| 2504 // Notify observers about navigation. | 2461 // Notify observers about navigation. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2546 } else { | 2503 } else { |
| 2547 if (page_title_when_no_navigation_entry_ == final_title) | 2504 if (page_title_when_no_navigation_entry_ == final_title) |
| 2548 return false; // Nothing changed, don't bother. | 2505 return false; // Nothing changed, don't bother. |
| 2549 | 2506 |
| 2550 page_title_when_no_navigation_entry_ = final_title; | 2507 page_title_when_no_navigation_entry_ = final_title; |
| 2551 } | 2508 } |
| 2552 | 2509 |
| 2553 // Lastly, set the title for the view. | 2510 // Lastly, set the title for the view. |
| 2554 view_->SetPageTitle(final_title); | 2511 view_->SetPageTitle(final_title); |
| 2555 | 2512 |
| 2556 std::pair<content::NavigationEntry*, bool> details = | 2513 std::pair<NavigationEntry*, bool> details = |
| 2557 std::make_pair(entry, explicit_set); | 2514 std::make_pair(entry, explicit_set); |
| 2558 | 2515 |
| 2559 content::NotificationService::current()->Notify( | 2516 NotificationService::current()->Notify( |
| 2560 content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 2517 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
| 2561 content::Source<WebContents>(this), | 2518 Source<WebContents>(this), |
| 2562 content::Details<std::pair<content::NavigationEntry*, bool> >(&details)); | 2519 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 2563 | 2520 |
| 2564 return true; | 2521 return true; |
| 2565 } | 2522 } |
| 2566 | 2523 |
| 2567 void WebContentsImpl::NotifySwapped() { | 2524 void WebContentsImpl::NotifySwapped() { |
| 2568 // After sending out a swap notification, we need to send a disconnect | 2525 // After sending out a swap notification, we need to send a disconnect |
| 2569 // notification so that clients that pick up a pointer to |this| can NULL the | 2526 // notification so that clients that pick up a pointer to |this| can NULL the |
| 2570 // pointer. See Bug 1230284. | 2527 // pointer. See Bug 1230284. |
| 2571 notify_disconnection_ = true; | 2528 notify_disconnection_ = true; |
| 2572 content::NotificationService::current()->Notify( | 2529 NotificationService::current()->Notify( |
| 2573 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2530 NOTIFICATION_WEB_CONTENTS_SWAPPED, |
| 2574 content::Source<WebContents>(this), | 2531 Source<WebContents>(this), |
| 2575 content::NotificationService::NoDetails()); | 2532 NotificationService::NoDetails()); |
| 2576 | 2533 |
| 2577 // Ensure that the associated embedder gets cleared after a RenderViewHost | 2534 // Ensure that the associated embedder gets cleared after a RenderViewHost |
| 2578 // gets swapped, so we don't reuse the same embedder next time a | 2535 // gets swapped, so we don't reuse the same embedder next time a |
| 2579 // RenderViewHost is attached to this WebContents. | 2536 // RenderViewHost is attached to this WebContents. |
| 2580 RemoveBrowserPluginEmbedder(); | 2537 RemoveBrowserPluginEmbedder(); |
| 2581 } | 2538 } |
| 2582 | 2539 |
| 2583 void WebContentsImpl::NotifyConnected() { | 2540 void WebContentsImpl::NotifyConnected() { |
| 2584 notify_disconnection_ = true; | 2541 notify_disconnection_ = true; |
| 2585 content::NotificationService::current()->Notify( | 2542 NotificationService::current()->Notify( |
| 2586 content::NOTIFICATION_WEB_CONTENTS_CONNECTED, | 2543 NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 2587 content::Source<WebContents>(this), | 2544 Source<WebContents>(this), |
| 2588 content::NotificationService::NoDetails()); | 2545 NotificationService::NoDetails()); |
| 2589 } | 2546 } |
| 2590 | 2547 |
| 2591 void WebContentsImpl::NotifyDisconnected() { | 2548 void WebContentsImpl::NotifyDisconnected() { |
| 2592 if (!notify_disconnection_) | 2549 if (!notify_disconnection_) |
| 2593 return; | 2550 return; |
| 2594 | 2551 |
| 2595 notify_disconnection_ = false; | 2552 notify_disconnection_ = false; |
| 2596 content::NotificationService::current()->Notify( | 2553 NotificationService::current()->Notify( |
| 2597 content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 2554 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 2598 content::Source<WebContents>(this), | 2555 Source<WebContents>(this), |
| 2599 content::NotificationService::NoDetails()); | 2556 NotificationService::NoDetails()); |
| 2600 } | 2557 } |
| 2601 | 2558 |
| 2602 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { | 2559 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
| 2603 return render_view_host_delegate_view_; | 2560 return render_view_host_delegate_view_; |
| 2604 } | 2561 } |
| 2605 | 2562 |
| 2606 RenderViewHostDelegate::RendererManagement* | 2563 RenderViewHostDelegate::RendererManagement* |
| 2607 WebContentsImpl::GetRendererManagementDelegate() { | 2564 WebContentsImpl::GetRendererManagementDelegate() { |
| 2608 return &render_manager_; | 2565 return &render_manager_; |
| 2609 } | 2566 } |
| 2610 | 2567 |
| 2611 content::RendererPreferences WebContentsImpl::GetRendererPrefs( | 2568 RendererPreferences WebContentsImpl::GetRendererPrefs( |
| 2612 content::BrowserContext* browser_context) const { | 2569 BrowserContext* browser_context) const { |
| 2613 return renderer_preferences_; | 2570 return renderer_preferences_; |
| 2614 } | 2571 } |
| 2615 | 2572 |
| 2616 WebContents* WebContentsImpl::GetAsWebContents() { | 2573 WebContents* WebContentsImpl::GetAsWebContents() { |
| 2617 return this; | 2574 return this; |
| 2618 } | 2575 } |
| 2619 | 2576 |
| 2620 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { | 2577 gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const { |
| 2621 if (delegate_) | 2578 if (delegate_) |
| 2622 return delegate_->GetRootWindowResizerRect(); | 2579 return delegate_->GetRootWindowResizerRect(); |
| 2623 return gfx::Rect(); | 2580 return gfx::Rect(); |
| 2624 } | 2581 } |
| 2625 | 2582 |
| 2626 void WebContentsImpl::RemoveBrowserPluginEmbedder() { | 2583 void WebContentsImpl::RemoveBrowserPluginEmbedder() { |
| 2627 if (browser_plugin_embedder_.get()) | 2584 if (browser_plugin_embedder_.get()) |
| 2628 browser_plugin_embedder_.reset(); | 2585 browser_plugin_embedder_.reset(); |
| 2629 } | 2586 } |
| 2630 | 2587 |
| 2631 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 2588 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
| 2632 // Don't send notifications if we are just creating a swapped-out RVH for | 2589 // Don't send notifications if we are just creating a swapped-out RVH for |
| 2633 // the opener chain. These won't be used for view-source or WebUI, so it's | 2590 // the opener chain. These won't be used for view-source or WebUI, so it's |
| 2634 // ok to return early. | 2591 // ok to return early. |
| 2635 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) | 2592 if (static_cast<RenderViewHostImpl*>(render_view_host)->is_swapped_out()) |
| 2636 return; | 2593 return; |
| 2637 | 2594 |
| 2638 content::NotificationService::current()->Notify( | 2595 NotificationService::current()->Notify( |
| 2639 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2596 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 2640 content::Source<WebContents>(this), | 2597 Source<WebContents>(this), |
| 2641 content::Details<RenderViewHost>(render_view_host)); | 2598 Details<RenderViewHost>(render_view_host)); |
| 2642 NavigationEntry* entry = controller_.GetActiveEntry(); | 2599 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 2643 if (!entry) | 2600 if (!entry) |
| 2644 return; | 2601 return; |
| 2645 | 2602 |
| 2646 // When we're creating views, we're still doing initial setup, so we always | 2603 // When we're creating views, we're still doing initial setup, so we always |
| 2647 // use the pending Web UI rather than any possibly existing committed one. | 2604 // use the pending Web UI rather than any possibly existing committed one. |
| 2648 if (render_manager_.pending_web_ui()) | 2605 if (render_manager_.pending_web_ui()) |
| 2649 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 2606 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); |
| 2650 | 2607 |
| 2651 if (entry->IsViewSourceMode()) { | 2608 if (entry->IsViewSourceMode()) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2700 } | 2657 } |
| 2701 | 2658 |
| 2702 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2659 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| 2703 render_manager_.RenderViewDeleted(rvh); | 2660 render_manager_.RenderViewDeleted(rvh); |
| 2704 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 2661 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); |
| 2705 } | 2662 } |
| 2706 | 2663 |
| 2707 void WebContentsImpl::DidNavigate( | 2664 void WebContentsImpl::DidNavigate( |
| 2708 RenderViewHost* rvh, | 2665 RenderViewHost* rvh, |
| 2709 const ViewHostMsg_FrameNavigate_Params& params) { | 2666 const ViewHostMsg_FrameNavigate_Params& params) { |
| 2710 if (content::PageTransitionIsMainFrame(params.transition)) | 2667 if (PageTransitionIsMainFrame(params.transition)) |
| 2711 render_manager_.DidNavigateMainFrame(rvh); | 2668 render_manager_.DidNavigateMainFrame(rvh); |
| 2712 | 2669 |
| 2713 // Update the site of the SiteInstance if it doesn't have one yet, unless | 2670 // Update the site of the SiteInstance if it doesn't have one yet, unless |
| 2714 // this is for about:blank. In that case, the SiteInstance can still be | 2671 // this is for about:blank. In that case, the SiteInstance can still be |
| 2715 // considered unused until a navigation to a real page. | 2672 // considered unused until a navigation to a real page. |
| 2716 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 2673 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
| 2717 params.url != GURL(chrome::kAboutBlankURL)) { | 2674 params.url != GURL(chrome::kAboutBlankURL)) { |
| 2718 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 2675 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
| 2719 } | 2676 } |
| 2720 | 2677 |
| 2721 // Need to update MIME type here because it's referred to in | 2678 // Need to update MIME type here because it's referred to in |
| 2722 // UpdateNavigationCommands() called by RendererDidNavigate() to | 2679 // UpdateNavigationCommands() called by RendererDidNavigate() to |
| 2723 // determine whether or not to enable the encoding menu. | 2680 // determine whether or not to enable the encoding menu. |
| 2724 // It's updated only for the main frame. For a subframe, | 2681 // It's updated only for the main frame. For a subframe, |
| 2725 // RenderView::UpdateURL does not set params.contents_mime_type. | 2682 // RenderView::UpdateURL does not set params.contents_mime_type. |
| 2726 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) | 2683 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) |
| 2727 // TODO(jungshik): Add a test for the encoding menu to avoid | 2684 // TODO(jungshik): Add a test for the encoding menu to avoid |
| 2728 // regressing it again. | 2685 // regressing it again. |
| 2729 if (content::PageTransitionIsMainFrame(params.transition)) | 2686 if (PageTransitionIsMainFrame(params.transition)) |
| 2730 contents_mime_type_ = params.contents_mime_type; | 2687 contents_mime_type_ = params.contents_mime_type; |
| 2731 | 2688 |
| 2732 content::LoadCommittedDetails details; | 2689 LoadCommittedDetails details; |
| 2733 bool did_navigate = controller_.RendererDidNavigate(params, &details); | 2690 bool did_navigate = controller_.RendererDidNavigate(params, &details); |
| 2734 | 2691 |
| 2735 // Send notification about committed provisional loads. This notification is | 2692 // Send notification about committed provisional loads. This notification is |
| 2736 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 2693 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
| 2737 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 2694 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
| 2738 if (details.type != content::NAVIGATION_TYPE_NAV_IGNORE) { | 2695 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { |
| 2739 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 2696 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
| 2740 // that is not recorded in the navigation history. For the purpose of | 2697 // that is not recorded in the navigation history. For the purpose of |
| 2741 // tracking navigation events, we treat this event as a sub frame navigation | 2698 // tracking navigation events, we treat this event as a sub frame navigation |
| 2742 // event. | 2699 // event. |
| 2743 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 2700 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
| 2744 content::PageTransition transition_type = params.transition; | 2701 PageTransition transition_type = params.transition; |
| 2745 // Whether or not a page transition was triggered by going backward or | 2702 // Whether or not a page transition was triggered by going backward or |
| 2746 // forward in the history is only stored in the navigation controller's | 2703 // forward in the history is only stored in the navigation controller's |
| 2747 // entry list. | 2704 // entry list. |
| 2748 if (did_navigate && | 2705 if (did_navigate && |
| 2749 (controller_.GetActiveEntry()->GetTransitionType() & | 2706 (controller_.GetActiveEntry()->GetTransitionType() & |
| 2750 content::PAGE_TRANSITION_FORWARD_BACK)) { | 2707 PAGE_TRANSITION_FORWARD_BACK)) { |
| 2751 transition_type = content::PageTransitionFromInt( | 2708 transition_type = PageTransitionFromInt( |
| 2752 params.transition | content::PAGE_TRANSITION_FORWARD_BACK); | 2709 params.transition | PAGE_TRANSITION_FORWARD_BACK); |
| 2753 } | 2710 } |
| 2754 // Notify observers about the commit of the provisional load. | 2711 // Notify observers about the commit of the provisional load. |
| 2755 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2712 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2756 DidCommitProvisionalLoadForFrame(params.frame_id, | 2713 DidCommitProvisionalLoadForFrame(params.frame_id, |
| 2757 is_main_frame, params.url, transition_type, rvh)); | 2714 is_main_frame, params.url, transition_type, rvh)); |
| 2758 } | 2715 } |
| 2759 | 2716 |
| 2760 if (!did_navigate) | 2717 if (!did_navigate) |
| 2761 return; // No navigation happened. | 2718 return; // No navigation happened. |
| 2762 | 2719 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 if (!entry && rvh != GetRenderViewHost()) | 2774 if (!entry && rvh != GetRenderViewHost()) |
| 2818 return; | 2775 return; |
| 2819 | 2776 |
| 2820 // TODO(evan): make use of title_direction. | 2777 // TODO(evan): make use of title_direction. |
| 2821 // http://code.google.com/p/chromium/issues/detail?id=27094 | 2778 // http://code.google.com/p/chromium/issues/detail?id=27094 |
| 2822 if (!UpdateTitleForEntry(entry, title)) | 2779 if (!UpdateTitleForEntry(entry, title)) |
| 2823 return; | 2780 return; |
| 2824 | 2781 |
| 2825 // Broadcast notifications when the UI should be updated. | 2782 // Broadcast notifications when the UI should be updated. |
| 2826 if (entry == controller_.GetEntryAtOffset(0)) | 2783 if (entry == controller_.GetEntryAtOffset(0)) |
| 2827 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); | 2784 NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); |
| 2828 } | 2785 } |
| 2829 | 2786 |
| 2830 void WebContentsImpl::UpdateEncoding(RenderViewHost* render_view_host, | 2787 void WebContentsImpl::UpdateEncoding(RenderViewHost* render_view_host, |
| 2831 const std::string& encoding) { | 2788 const std::string& encoding) { |
| 2832 SetEncoding(encoding); | 2789 SetEncoding(encoding); |
| 2833 } | 2790 } |
| 2834 | 2791 |
| 2835 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { | 2792 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { |
| 2836 if (delegate_) | 2793 if (delegate_) |
| 2837 delegate_->UpdateTargetURL(this, page_id, url); | 2794 delegate_->UpdateTargetURL(this, page_id, url); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2858 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 2815 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
| 2859 if (delegate_ && rvh == GetRenderViewHost()) | 2816 if (delegate_ && rvh == GetRenderViewHost()) |
| 2860 delegate_->SwappedOut(this); | 2817 delegate_->SwappedOut(this); |
| 2861 } | 2818 } |
| 2862 | 2819 |
| 2863 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 2820 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 2864 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 2821 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 2865 delegate_->MoveContents(this, new_bounds); | 2822 delegate_->MoveContents(this, new_bounds); |
| 2866 } | 2823 } |
| 2867 | 2824 |
| 2868 void WebContentsImpl::DidStartLoading( | 2825 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { |
| 2869 content::RenderViewHost* render_view_host) { | |
| 2870 SetIsLoading(true, NULL); | 2826 SetIsLoading(true, NULL); |
| 2871 | 2827 |
| 2872 if (delegate_ && content_restrictions_) | 2828 if (delegate_ && content_restrictions_) |
| 2873 OnUpdateContentRestrictions(0); | 2829 OnUpdateContentRestrictions(0); |
| 2874 | 2830 |
| 2875 // Notify observers about navigation. | 2831 // Notify observers about navigation. |
| 2876 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2832 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2877 DidStartLoading(render_view_host)); | 2833 DidStartLoading(render_view_host)); |
| 2878 } | 2834 } |
| 2879 | 2835 |
| 2880 void WebContentsImpl::DidStopLoading( | 2836 void WebContentsImpl::DidStopLoading(RenderViewHost* render_view_host) { |
| 2881 content::RenderViewHost* render_view_host) { | |
| 2882 scoped_ptr<LoadNotificationDetails> details; | 2837 scoped_ptr<LoadNotificationDetails> details; |
| 2883 | 2838 |
| 2884 NavigationEntry* entry = controller_.GetActiveEntry(); | 2839 NavigationEntry* entry = controller_.GetActiveEntry(); |
| 2885 // An entry may not exist for a stop when loading an initial blank page or | 2840 // An entry may not exist for a stop when loading an initial blank page or |
| 2886 // if an iframe injected by script into a blank page finishes loading. | 2841 // if an iframe injected by script into a blank page finishes loading. |
| 2887 if (entry) { | 2842 if (entry) { |
| 2888 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; | 2843 base::TimeDelta elapsed = base::TimeTicks::Now() - current_load_start_; |
| 2889 | 2844 |
| 2890 details.reset(new LoadNotificationDetails( | 2845 details.reset(new LoadNotificationDetails( |
| 2891 entry->GetVirtualURL(), | 2846 entry->GetVirtualURL(), |
| 2892 entry->GetTransitionType(), | 2847 entry->GetTransitionType(), |
| 2893 elapsed, | 2848 elapsed, |
| 2894 &controller_, | 2849 &controller_, |
| 2895 controller_.GetCurrentEntryIndex())); | 2850 controller_.GetCurrentEntryIndex())); |
| 2896 } | 2851 } |
| 2897 | 2852 |
| 2898 SetIsLoading(false, details.get()); | 2853 SetIsLoading(false, details.get()); |
| 2899 | 2854 |
| 2900 // Notify observers about navigation. | 2855 // Notify observers about navigation. |
| 2901 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2856 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2902 DidStopLoading(render_view_host)); | 2857 DidStopLoading(render_view_host)); |
| 2903 } | 2858 } |
| 2904 | 2859 |
| 2905 void WebContentsImpl::DidCancelLoading() { | 2860 void WebContentsImpl::DidCancelLoading() { |
| 2906 controller_.DiscardNonCommittedEntries(); | 2861 controller_.DiscardNonCommittedEntries(); |
| 2907 | 2862 |
| 2908 // Update the URL display. | 2863 // Update the URL display. |
| 2909 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | 2864 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 2910 } | 2865 } |
| 2911 | 2866 |
| 2912 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 2867 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
| 2913 if (delegate_) | 2868 if (delegate_) |
| 2914 delegate_->LoadProgressChanged(this, progress); | 2869 delegate_->LoadProgressChanged(this, progress); |
| 2915 } | 2870 } |
| 2916 | 2871 |
| 2917 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { | 2872 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { |
| 2918 render_manager_.DidUpdateFrameTree(rvh); | 2873 render_manager_.DidUpdateFrameTree(rvh); |
| 2919 } | 2874 } |
| 2920 | 2875 |
| 2921 void WebContentsImpl::DocumentAvailableInMainFrame( | 2876 void WebContentsImpl::DocumentAvailableInMainFrame( |
| 2922 RenderViewHost* render_view_host) { | 2877 RenderViewHost* render_view_host) { |
| 2923 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2878 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2924 DocumentAvailableInMainFrame()); | 2879 DocumentAvailableInMainFrame()); |
| 2925 } | 2880 } |
| 2926 | 2881 |
| 2927 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( | 2882 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( |
| 2928 RenderViewHost* render_view_host, | 2883 RenderViewHost* render_view_host, |
| 2929 int32 page_id) { | 2884 int32 page_id) { |
| 2930 content::NotificationService::current()->Notify( | 2885 NotificationService::current()->Notify( |
| 2931 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 2886 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 2932 content::Source<WebContents>(this), | 2887 Source<WebContents>(this), |
| 2933 content::Details<int>(&page_id)); | 2888 Details<int>(&page_id)); |
| 2934 } | 2889 } |
| 2935 | 2890 |
| 2936 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, | 2891 void WebContentsImpl::RequestOpenURL(RenderViewHost* rvh, |
| 2937 const GURL& url, | 2892 const GURL& url, |
| 2938 const content::Referrer& referrer, | 2893 const Referrer& referrer, |
| 2939 WindowOpenDisposition disposition, | 2894 WindowOpenDisposition disposition, |
| 2940 int64 source_frame_id) { | 2895 int64 source_frame_id) { |
| 2941 // If this came from a swapped out RenderViewHost, we only allow the request | 2896 // If this came from a swapped out RenderViewHost, we only allow the request |
| 2942 // if we are still in the same BrowsingInstance. | 2897 // if we are still in the same BrowsingInstance. |
| 2943 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && | 2898 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() && |
| 2944 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { | 2899 !rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) { |
| 2945 return; | 2900 return; |
| 2946 } | 2901 } |
| 2947 | 2902 |
| 2948 // Delegate to RequestTransferURL because this is just the generic | 2903 // Delegate to RequestTransferURL because this is just the generic |
| 2949 // case where |old_request_id| is empty. | 2904 // case where |old_request_id| is empty. |
| 2950 RequestTransferURL(url, referrer, disposition, source_frame_id, | 2905 RequestTransferURL(url, referrer, disposition, source_frame_id, |
| 2951 GlobalRequestID()); | 2906 GlobalRequestID()); |
| 2952 } | 2907 } |
| 2953 | 2908 |
| 2954 void WebContentsImpl::RequestTransferURL( | 2909 void WebContentsImpl::RequestTransferURL( |
| 2955 const GURL& url, | 2910 const GURL& url, |
| 2956 const content::Referrer& referrer, | 2911 const Referrer& referrer, |
| 2957 WindowOpenDisposition disposition, | 2912 WindowOpenDisposition disposition, |
| 2958 int64 source_frame_id, | 2913 int64 source_frame_id, |
| 2959 const GlobalRequestID& old_request_id) { | 2914 const GlobalRequestID& old_request_id) { |
| 2960 WebContents* new_contents = NULL; | 2915 WebContents* new_contents = NULL; |
| 2961 content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; | 2916 PageTransition transition_type = PAGE_TRANSITION_LINK; |
| 2962 if (render_manager_.web_ui()) { | 2917 if (render_manager_.web_ui()) { |
| 2963 // When we're a Web UI, it will provide a page transition type for us (this | 2918 // When we're a Web UI, it will provide a page transition type for us (this |
| 2964 // is so the new tab page can specify AUTO_BOOKMARK for automatically | 2919 // is so the new tab page can specify AUTO_BOOKMARK for automatically |
| 2965 // generated suggestions). | 2920 // generated suggestions). |
| 2966 // | 2921 // |
| 2967 // Note also that we hide the referrer for Web UI pages. We don't really | 2922 // Note also that we hide the referrer for Web UI pages. We don't really |
| 2968 // want web sites to see a referrer of "chrome://blah" (and some | 2923 // want web sites to see a referrer of "chrome://blah" (and some |
| 2969 // chrome: URLs might have search terms or other stuff we don't want to | 2924 // chrome: URLs might have search terms or other stuff we don't want to |
| 2970 // send to the site), so we send no referrer. | 2925 // send to the site), so we send no referrer. |
| 2971 OpenURLParams params(url, content::Referrer(), source_frame_id, disposition, | 2926 OpenURLParams params(url, Referrer(), source_frame_id, disposition, |
| 2972 render_manager_.web_ui()->GetLinkTransitionType(), | 2927 render_manager_.web_ui()->GetLinkTransitionType(), |
| 2973 false /* is_renderer_initiated */); | 2928 false /* is_renderer_initiated */); |
| 2974 params.transferred_global_request_id = old_request_id; | 2929 params.transferred_global_request_id = old_request_id; |
| 2975 new_contents = OpenURL(params); | 2930 new_contents = OpenURL(params); |
| 2976 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); | 2931 transition_type = render_manager_.web_ui()->GetLinkTransitionType(); |
| 2977 } else { | 2932 } else { |
| 2978 OpenURLParams params(url, referrer, source_frame_id, disposition, | 2933 OpenURLParams params(url, referrer, source_frame_id, disposition, |
| 2979 content::PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); | 2934 PAGE_TRANSITION_LINK, true /* is_renderer_initiated */); |
| 2980 params.transferred_global_request_id = old_request_id; | 2935 params.transferred_global_request_id = old_request_id; |
| 2981 new_contents = OpenURL(params); | 2936 new_contents = OpenURL(params); |
| 2982 } | 2937 } |
| 2983 if (new_contents) { | 2938 if (new_contents) { |
| 2984 // Notify observers. | 2939 // Notify observers. |
| 2985 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2940 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2986 DidOpenRequestedURL(new_contents, | 2941 DidOpenRequestedURL(new_contents, |
| 2987 url, | 2942 url, |
| 2988 referrer, | 2943 referrer, |
| 2989 disposition, | 2944 disposition, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 // It is possible to receive it from one that has just been swapped in, | 3013 // It is possible to receive it from one that has just been swapped in, |
| 3059 // in which case we might as well deliver the message anyway. | 3014 // in which case we might as well deliver the message anyway. |
| 3060 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params)); | 3015 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params)); |
| 3061 } | 3016 } |
| 3062 | 3017 |
| 3063 void WebContentsImpl::RunJavaScriptMessage( | 3018 void WebContentsImpl::RunJavaScriptMessage( |
| 3064 RenderViewHost* rvh, | 3019 RenderViewHost* rvh, |
| 3065 const string16& message, | 3020 const string16& message, |
| 3066 const string16& default_prompt, | 3021 const string16& default_prompt, |
| 3067 const GURL& frame_url, | 3022 const GURL& frame_url, |
| 3068 content::JavaScriptMessageType javascript_message_type, | 3023 JavaScriptMessageType javascript_message_type, |
| 3069 IPC::Message* reply_msg, | 3024 IPC::Message* reply_msg, |
| 3070 bool* did_suppress_message) { | 3025 bool* did_suppress_message) { |
| 3071 // Suppress JavaScript dialogs when requested. Also suppress messages when | 3026 // Suppress JavaScript dialogs when requested. Also suppress messages when |
| 3072 // showing an interstitial as it's shown over the previous page and we don't | 3027 // showing an interstitial as it's shown over the previous page and we don't |
| 3073 // want the hidden page's dialogs to interfere with the interstitial. | 3028 // want the hidden page's dialogs to interfere with the interstitial. |
| 3074 bool suppress_this_message = | 3029 bool suppress_this_message = |
| 3075 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || | 3030 static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out() || |
| 3076 ShowingInterstitialPage() || | 3031 ShowingInterstitialPage() || |
| 3077 !delegate_ || | 3032 !delegate_ || |
| 3078 delegate_->ShouldSuppressDialogs() || | 3033 delegate_->ShouldSuppressDialogs() || |
| 3079 !delegate_->GetJavaScriptDialogCreator(); | 3034 !delegate_->GetJavaScriptDialogCreator(); |
| 3080 | 3035 |
| 3081 if (!suppress_this_message) { | 3036 if (!suppress_this_message) { |
| 3082 std::string accept_lang = content::GetContentClient()->browser()-> | 3037 std::string accept_lang = GetContentClient()->browser()-> |
| 3083 GetAcceptLangs(GetBrowserContext()); | 3038 GetAcceptLangs(GetBrowserContext()); |
| 3084 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); | 3039 dialog_creator_ = delegate_->GetJavaScriptDialogCreator(); |
| 3085 dialog_creator_->RunJavaScriptDialog( | 3040 dialog_creator_->RunJavaScriptDialog( |
| 3086 this, | 3041 this, |
| 3087 frame_url.GetOrigin(), | 3042 frame_url.GetOrigin(), |
| 3088 accept_lang, | 3043 accept_lang, |
| 3089 javascript_message_type, | 3044 javascript_message_type, |
| 3090 message, | 3045 message, |
| 3091 default_prompt, | 3046 default_prompt, |
| 3092 base::Bind(&WebContentsImpl::OnDialogClosed, | 3047 base::Bind(&WebContentsImpl::OnDialogClosed, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3144 | 3099 |
| 3145 WebPreferences WebContentsImpl::GetWebkitPrefs() { | 3100 WebPreferences WebContentsImpl::GetWebkitPrefs() { |
| 3146 // We want to base the page config off of the real URL, rather than the | 3101 // We want to base the page config off of the real URL, rather than the |
| 3147 // display URL. | 3102 // display URL. |
| 3148 GURL url = controller_.GetActiveEntry() | 3103 GURL url = controller_.GetActiveEntry() |
| 3149 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3104 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
| 3150 return GetWebkitPrefs(GetRenderViewHost(), url); | 3105 return GetWebkitPrefs(GetRenderViewHost(), url); |
| 3151 } | 3106 } |
| 3152 | 3107 |
| 3153 int WebContentsImpl::CreateSwappedOutRenderView( | 3108 int WebContentsImpl::CreateSwappedOutRenderView( |
| 3154 content::SiteInstance* instance) { | 3109 SiteInstance* instance) { |
| 3155 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); | 3110 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); |
| 3156 } | 3111 } |
| 3157 | 3112 |
| 3158 void WebContentsImpl::OnUserGesture() { | 3113 void WebContentsImpl::OnUserGesture() { |
| 3159 // Notify observers. | 3114 // Notify observers. |
| 3160 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3115 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
| 3161 | 3116 |
| 3162 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3117 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 3163 if (rdh) // NULL in unittests. | 3118 if (rdh) // NULL in unittests. |
| 3164 rdh->OnUserGesture(this); | 3119 rdh->OnUserGesture(this); |
| 3165 } | 3120 } |
| 3166 | 3121 |
| 3167 void WebContentsImpl::OnIgnoredUIEvent() { | 3122 void WebContentsImpl::OnIgnoredUIEvent() { |
| 3168 // Notify observers. | 3123 // Notify observers. |
| 3169 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); | 3124 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); |
| 3170 } | 3125 } |
| 3171 | 3126 |
| 3172 void WebContentsImpl::RendererUnresponsive(RenderViewHost* rvh, | 3127 void WebContentsImpl::RendererUnresponsive(RenderViewHost* rvh, |
| 3173 bool is_during_unload) { | 3128 bool is_during_unload) { |
| 3174 // Don't show hung renderer dialog for a swapped out RVH. | 3129 // Don't show hung renderer dialog for a swapped out RVH. |
| 3175 if (rvh != GetRenderViewHost()) | 3130 if (rvh != GetRenderViewHost()) |
| 3176 return; | 3131 return; |
| 3177 | 3132 |
| 3178 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3133 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
| 3179 | 3134 |
| 3180 // Ignore renderer unresponsive event if debugger is attached to the tab | 3135 // Ignore renderer unresponsive event if debugger is attached to the tab |
| 3181 // since the event may be a result of the renderer sitting on a breakpoint. | 3136 // since the event may be a result of the renderer sitting on a breakpoint. |
| 3182 // See http://crbug.com/65458 | 3137 // See http://crbug.com/65458 |
| 3183 DevToolsAgentHost* agent = | 3138 DevToolsAgentHost* agent = |
| 3184 content::DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); | 3139 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh); |
| 3185 if (agent && | 3140 if (agent && |
| 3186 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) | 3141 DevToolsManagerImpl::GetInstance()->GetDevToolsClientHostFor(agent)) |
| 3187 return; | 3142 return; |
| 3188 | 3143 |
| 3189 if (is_during_unload) { | 3144 if (is_during_unload) { |
| 3190 // Hang occurred while firing the beforeunload/unload handler. | 3145 // Hang occurred while firing the beforeunload/unload handler. |
| 3191 // Pretend the handler fired so tab closing continues as if it had. | 3146 // Pretend the handler fired so tab closing continues as if it had. |
| 3192 rvhi->set_sudden_termination_allowed(true); | 3147 rvhi->set_sudden_termination_allowed(true); |
| 3193 | 3148 |
| 3194 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) | 3149 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3216 | 3171 |
| 3217 void WebContentsImpl::LoadStateChanged( | 3172 void WebContentsImpl::LoadStateChanged( |
| 3218 const GURL& url, | 3173 const GURL& url, |
| 3219 const net::LoadStateWithParam& load_state, | 3174 const net::LoadStateWithParam& load_state, |
| 3220 uint64 upload_position, | 3175 uint64 upload_position, |
| 3221 uint64 upload_size) { | 3176 uint64 upload_size) { |
| 3222 load_state_ = load_state; | 3177 load_state_ = load_state; |
| 3223 upload_position_ = upload_position; | 3178 upload_position_ = upload_position; |
| 3224 upload_size_ = upload_size; | 3179 upload_size_ = upload_size; |
| 3225 load_state_host_ = net::IDNToUnicode(url.host(), | 3180 load_state_host_ = net::IDNToUnicode(url.host(), |
| 3226 content::GetContentClient()->browser()->GetAcceptLangs( | 3181 GetContentClient()->browser()->GetAcceptLangs( |
| 3227 GetBrowserContext())); | 3182 GetBrowserContext())); |
| 3228 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) | 3183 if (load_state_.state == net::LOAD_STATE_READING_RESPONSE) |
| 3229 SetNotWaitingForResponse(); | 3184 SetNotWaitingForResponse(); |
| 3230 if (IsLoading()) { | 3185 if (IsLoading()) { |
| 3231 NotifyNavigationStateChanged( | 3186 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB); |
| 3232 content::INVALIDATE_TYPE_LOAD | content::INVALIDATE_TYPE_TAB); | |
| 3233 } | 3187 } |
| 3234 } | 3188 } |
| 3235 | 3189 |
| 3236 void WebContentsImpl::WorkerCrashed() { | 3190 void WebContentsImpl::WorkerCrashed() { |
| 3237 if (delegate_) | 3191 if (delegate_) |
| 3238 delegate_->WorkerCrashed(this); | 3192 delegate_->WorkerCrashed(this); |
| 3239 } | 3193 } |
| 3240 | 3194 |
| 3241 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 3195 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
| 3242 bool proceed, const base::TimeTicks& proceed_time, | 3196 bool proceed, const base::TimeTicks& proceed_time, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 | 3318 |
| 3365 close_start_time_ = base::TimeTicks(); | 3319 close_start_time_ = base::TimeTicks(); |
| 3366 before_unload_end_time_ = base::TimeTicks(); | 3320 before_unload_end_time_ = base::TimeTicks(); |
| 3367 } | 3321 } |
| 3368 is_showing_before_unload_dialog_ = false; | 3322 is_showing_before_unload_dialog_ = false; |
| 3369 static_cast<RenderViewHostImpl*>( | 3323 static_cast<RenderViewHostImpl*>( |
| 3370 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); | 3324 rvh)->JavaScriptDialogClosed(reply_msg, success, user_input); |
| 3371 } | 3325 } |
| 3372 | 3326 |
| 3373 void WebContentsImpl::SetEncoding(const std::string& encoding) { | 3327 void WebContentsImpl::SetEncoding(const std::string& encoding) { |
| 3374 encoding_ = content::GetContentClient()->browser()-> | 3328 encoding_ = GetContentClient()->browser()-> |
| 3375 GetCanonicalEncodingNameByAliasName(encoding); | 3329 GetCanonicalEncodingNameByAliasName(encoding); |
| 3376 } | 3330 } |
| 3377 | 3331 |
| 3378 void WebContentsImpl::SaveURL(const GURL& url, | 3332 void WebContentsImpl::SaveURL(const GURL& url, |
| 3379 const content::Referrer& referrer, | 3333 const Referrer& referrer, |
| 3380 bool is_main_frame) { | 3334 bool is_main_frame) { |
| 3381 DownloadManager* dlm = | 3335 DownloadManager* dlm = |
| 3382 BrowserContext::GetDownloadManager(GetBrowserContext()); | 3336 BrowserContext::GetDownloadManager(GetBrowserContext()); |
| 3383 if (!dlm) | 3337 if (!dlm) |
| 3384 return; | 3338 return; |
| 3385 int64 post_id = -1; | 3339 int64 post_id = -1; |
| 3386 if (is_main_frame) { | 3340 if (is_main_frame) { |
| 3387 const NavigationEntry* entry = controller_.GetActiveEntry(); | 3341 const NavigationEntry* entry = controller_.GetActiveEntry(); |
| 3388 if (entry) | 3342 if (entry) |
| 3389 post_id = entry->GetPostID(); | 3343 post_id = entry->GetPostID(); |
| 3390 } | 3344 } |
| 3391 scoped_ptr<content::DownloadSaveInfo> save_info( | 3345 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); |
| 3392 new content::DownloadSaveInfo()); | |
| 3393 save_info->prompt_for_save_location = true; | 3346 save_info->prompt_for_save_location = true; |
| 3394 scoped_ptr<DownloadUrlParameters> params( | 3347 scoped_ptr<DownloadUrlParameters> params( |
| 3395 DownloadUrlParameters::FromWebContents(this, url, save_info.Pass())); | 3348 DownloadUrlParameters::FromWebContents(this, url, save_info.Pass())); |
| 3396 params->set_referrer(referrer); | 3349 params->set_referrer(referrer); |
| 3397 params->set_post_id(post_id); | 3350 params->set_post_id(post_id); |
| 3398 params->set_prefer_cache(true); | 3351 params->set_prefer_cache(true); |
| 3399 if (post_id >= 0) | 3352 if (post_id >= 0) |
| 3400 params->set_method("POST"); | 3353 params->set_method("POST"); |
| 3401 dlm->DownloadUrl(params.Pass()); | 3354 dlm->DownloadUrl(params.Pass()); |
| 3402 } | 3355 } |
| 3403 | 3356 |
| 3404 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3357 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
| 3405 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 3358 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
| 3406 // Can be NULL during tests. | 3359 // Can be NULL during tests. |
| 3407 if (rwh_view) | 3360 if (rwh_view) |
| 3408 rwh_view->SetSize(GetView()->GetContainerSize()); | 3361 rwh_view->SetSize(GetView()->GetContainerSize()); |
| 3409 } | 3362 } |
| 3410 | 3363 |
| 3411 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 3364 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
| 3412 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 3365 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
| 3413 } | 3366 } |
| 3414 | 3367 |
| 3415 void WebContentsImpl::GetBrowserPluginEmbedderInfo( | 3368 void WebContentsImpl::GetBrowserPluginEmbedderInfo( |
| 3416 content::RenderViewHost* render_view_host, | 3369 RenderViewHost* render_view_host, |
| 3417 std::string* embedder_channel_name, | 3370 std::string* embedder_channel_name, |
| 3418 int* embedder_container_id) { | 3371 int* embedder_container_id) { |
| 3419 content::RenderProcessHost* embedder_render_process_host = | 3372 RenderProcessHost* embedder_render_process_host = |
| 3420 old_browser_plugin_host()->embedder_render_process_host(); | 3373 old_browser_plugin_host()->embedder_render_process_host(); |
| 3421 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3374 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
| 3422 int embedder_process_id = | 3375 int embedder_process_id = |
| 3423 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3376 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 3424 if (embedder_process_id != -1) { | 3377 if (embedder_process_id != -1) { |
| 3425 *embedder_channel_name = | 3378 *embedder_channel_name = |
| 3426 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3379 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 3427 embedder_process_id); | 3380 embedder_process_id); |
| 3428 } | 3381 } |
| 3429 } | 3382 } |
| 3430 | 3383 |
| 3431 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3384 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3432 return browser_plugin_guest_.get(); | 3385 return browser_plugin_guest_.get(); |
| 3433 } | 3386 } |
| 3434 | 3387 |
| 3435 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3388 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3436 return browser_plugin_embedder_.get(); | 3389 return browser_plugin_embedder_.get(); |
| 3437 } | 3390 } |
| 3391 |
| 3392 } // namespace content |
| OLD | NEW |