| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
| 9 #include "chrome/browser/favicon/favicon_tab_helper.h" | 9 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 10 #include "chrome/browser/history/history_tab_helper.h" | 10 #include "chrome/browser/history/history_tab_helper.h" |
| 11 #include "chrome/browser/instant/instant_controller.h" | 11 #include "chrome/browser/instant/instant_controller.h" |
| 12 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
| 13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 14 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 14 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 15 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" | 15 #include "chrome/browser/ui/constrained_window_tab_helper_delegate.h" |
| 16 #include "chrome/browser/ui/search/search_tab_helper.h" | 16 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 17 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 18 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 18 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
| 19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/notification_types.h" | 20 #include "content/public/browser/notification_types.h" |
| 21 #include "content/public/browser/page_navigator.h" |
| 21 #include "content/public/browser/render_widget_host_view.h" | 22 #include "content/public/browser/render_widget_host_view.h" |
| 22 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
| 23 #include "ipc/ipc_message.h" | 24 #include "ipc/ipc_message.h" |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 int kUserDataKey; | 28 int kUserDataKey; |
| 28 | 29 |
| 29 class InstantLoaderUserData : public base::SupportsUserData::Data { | 30 class InstantLoaderUserData : public base::SupportsUserData::Data { |
| 30 public: | 31 public: |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 MaybeCommitFromPointerRelease(); | 158 MaybeCommitFromPointerRelease(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { | 161 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) { |
| 161 return false; | 162 return false; |
| 162 } | 163 } |
| 163 | 164 |
| 164 content::WebContents* InstantLoader::WebContentsDelegateImpl::OpenURLFromTab( | 165 content::WebContents* InstantLoader::WebContentsDelegateImpl::OpenURLFromTab( |
| 165 content::WebContents* source, | 166 content::WebContents* source, |
| 166 const content::OpenURLParams& params) { | 167 const content::OpenURLParams& params) { |
| 168 if (!loader_->supports_instant_) { |
| 169 // If the page doesn't yet support Instant, it hasn't fully loaded. |
| 170 // This is a redirect that we should allow. http://crbug.com/177948 |
| 171 content::NavigationController::LoadURLParams load_params(params.url); |
| 172 load_params.transition_type = params.transition; |
| 173 load_params.referrer = params.referrer; |
| 174 load_params.extra_headers = params.extra_headers; |
| 175 load_params.is_renderer_initiated = params.is_renderer_initiated; |
| 176 load_params.transferred_global_request_id = |
| 177 params.transferred_global_request_id; |
| 178 load_params.is_cross_site_redirect = params.is_cross_site_redirect; |
| 179 |
| 180 loader_->contents_->GetController().LoadURLWithParams(load_params); |
| 181 return loader_->contents_.get(); |
| 182 } |
| 183 |
| 167 content::WebContents* preview = loader_->contents_.get(); | 184 content::WebContents* preview = loader_->contents_.get(); |
| 168 if (loader_->controller_->CommitIfPossible(INSTANT_COMMIT_NAVIGATED)) | 185 if (loader_->controller_->CommitIfPossible(INSTANT_COMMIT_NAVIGATED)) |
| 169 return preview->GetDelegate()->OpenURLFromTab(source, params); | 186 return preview->GetDelegate()->OpenURLFromTab(source, params); |
| 170 return NULL; | 187 return NULL; |
| 171 } | 188 } |
| 172 | 189 |
| 173 void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() { | 190 void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() { |
| 174 if (loader_->is_pointer_down_from_activate_) { | 191 if (loader_->is_pointer_down_from_activate_) { |
| 175 loader_->is_pointer_down_from_activate_ = false; | 192 loader_->is_pointer_down_from_activate_ = false; |
| 176 loader_->controller_->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); | 193 loader_->controller_->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 void InstantLoader::StopCapturingKeyStrokes() { | 333 void InstantLoader::StopCapturingKeyStrokes() { |
| 317 InstantSupportDetermined(true); | 334 InstantSupportDetermined(true); |
| 318 controller_->StopCapturingKeyStrokes(); | 335 controller_->StopCapturingKeyStrokes(); |
| 319 } | 336 } |
| 320 | 337 |
| 321 void InstantLoader::RenderViewGone() { | 338 void InstantLoader::RenderViewGone() { |
| 322 controller_->InstantLoaderRenderViewGone(); | 339 controller_->InstantLoaderRenderViewGone(); |
| 323 } | 340 } |
| 324 | 341 |
| 325 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) { | 342 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) { |
| 343 if (!supports_instant_) |
| 344 return; |
| 326 controller_->InstantLoaderAboutToNavigateMainFrame(url); | 345 controller_->InstantLoaderAboutToNavigateMainFrame(url); |
| 327 } | 346 } |
| 328 | 347 |
| 329 void InstantLoader::NavigateToURL(const GURL& url, | 348 void InstantLoader::NavigateToURL(const GURL& url, |
| 330 content::PageTransition transition) { | 349 content::PageTransition transition) { |
| 331 InstantSupportDetermined(true); | 350 InstantSupportDetermined(true); |
| 332 controller_->NavigateToURL(url, transition); | 351 controller_->NavigateToURL(url, transition); |
| 333 } | 352 } |
| 334 | 353 |
| 335 void InstantLoader::Observe(int type, | 354 void InstantLoader::Observe(int type, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 content::WebContents* new_contents) { | 446 content::WebContents* new_contents) { |
| 428 DCHECK_EQ(old_contents, contents()); | 447 DCHECK_EQ(old_contents, contents()); |
| 429 CleanupPreviewContents(); | 448 CleanupPreviewContents(); |
| 430 // We release here without deleting so that the caller still has the | 449 // We release here without deleting so that the caller still has the |
| 431 // responsibility for deleting the WebContents. | 450 // responsibility for deleting the WebContents. |
| 432 ignore_result(contents_.release()); | 451 ignore_result(contents_.release()); |
| 433 contents_.reset(new_contents); | 452 contents_.reset(new_contents); |
| 434 SetupPreviewContents(); | 453 SetupPreviewContents(); |
| 435 controller_->SwappedWebContents(); | 454 controller_->SwappedWebContents(); |
| 436 } | 455 } |
| OLD | NEW |