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

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

Issue 11785025: Do not commit InstantLoader server redirects till the page supports instant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/search/search_tab_helper.h" 14 #include "chrome/browser/ui/search/search_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
16 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 16 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
17 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 17 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
18 #include "chrome/browser/ui/web_contents_modal_dialog_manager_delegate.h" 18 #include "chrome/browser/ui/web_contents_modal_dialog_manager_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/render_widget_host_view.h" 21 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/browser/resource_request_details.h"
22 #include "content/public/browser/web_contents_delegate.h" 23 #include "content/public/browser/web_contents_delegate.h"
23 #include "content/public/browser/web_contents_view.h" 24 #include "content/public/browser/web_contents_view.h"
24 #include "ipc/ipc_message.h" 25 #include "ipc/ipc_message.h"
25 26
26 namespace { 27 namespace {
27 28
28 int kUserDataKey; 29 int kUserDataKey;
29 30
30 class InstantLoaderUserData : public base::SupportsUserData::Data { 31 class InstantLoaderUserData : public base::SupportsUserData::Data {
31 public: 32 public:
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 void InstantLoader::StopCapturingKeyStrokes() { 320 void InstantLoader::StopCapturingKeyStrokes() {
320 InstantSupportDetermined(true); 321 InstantSupportDetermined(true);
321 controller_->StopCapturingKeyStrokes(); 322 controller_->StopCapturingKeyStrokes();
322 } 323 }
323 324
324 void InstantLoader::RenderViewGone() { 325 void InstantLoader::RenderViewGone() {
325 controller_->InstantLoaderRenderViewGone(); 326 controller_->InstantLoaderRenderViewGone();
326 } 327 }
327 328
328 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) { 329 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) {
329 controller_->InstantLoaderAboutToNavigateMainFrame(url); 330 controller_->InstantLoaderAboutToNavigateMainFrame(
331 url, url == expected_redirect_);
332 expected_redirect_ = GURL();
330 } 333 }
331 334
332 void InstantLoader::NavigateToURL(const GURL& url, 335 void InstantLoader::NavigateToURL(const GURL& url,
333 content::PageTransition transition) { 336 content::PageTransition transition) {
334 InstantSupportDetermined(true); 337 InstantSupportDetermined(true);
335 controller_->NavigateToURL(url, transition); 338 controller_->NavigateToURL(url, transition);
336 } 339 }
337 340
338 void InstantLoader::Observe(int type, 341 void InstantLoader::Observe(int type,
339 const content::NotificationSource& source, 342 const content::NotificationSource& source,
340 const content::NotificationDetails& details) { 343 const content::NotificationDetails& details) {
344 if (type == content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT) {
345 content::ResourceRedirectDetails* resource_redirect_details =
346 content::Details<content::ResourceRedirectDetails>(details).ptr();
347 if (resource_redirect_details->resource_type == ResourceType::MAIN_FRAME)
348 expected_redirect_ = resource_redirect_details->new_url;
349 }
350
341 #if defined(OS_MACOSX) 351 #if defined(OS_MACOSX)
342 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { 352 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
343 if (content::RenderWidgetHostView* rwhv = 353 if (content::RenderWidgetHostView* rwhv =
344 contents_->GetRenderWidgetHostView()) 354 contents_->GetRenderWidgetHostView())
345 rwhv->SetTakesFocusOnlyOnMouseDown(true); 355 rwhv->SetTakesFocusOnlyOnMouseDown(true);
346 return; 356 return;
347 } 357 }
348 NOTREACHED(); 358 NOTREACHED();
349 #endif 359 #endif
350 } 360 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 #if defined(OS_MACOSX) 400 #if defined(OS_MACOSX)
391 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will 401 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will
392 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received. 402 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received.
393 if (content::RenderWidgetHostView* rwhv = 403 if (content::RenderWidgetHostView* rwhv =
394 contents_->GetRenderWidgetHostView()) 404 contents_->GetRenderWidgetHostView())
395 rwhv->SetTakesFocusOnlyOnMouseDown(true); 405 rwhv->SetTakesFocusOnlyOnMouseDown(true);
396 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 406 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
397 content::Source<content::NavigationController>( 407 content::Source<content::NavigationController>(
398 &contents_->GetController())); 408 &contents_->GetController()));
399 #endif 409 #endif
410
411 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
412 content::Source<content::WebContents>(contents()));
400 } 413 }
401 414
402 void InstantLoader::CleanupPreviewContents() { 415 void InstantLoader::CleanupPreviewContents() {
403 client_.SetContents(NULL); 416 client_.SetContents(NULL);
404 contents_->RemoveUserData(&kUserDataKey); 417 contents_->RemoveUserData(&kUserDataKey);
405 contents_->SetDelegate(NULL); 418 contents_->SetDelegate(NULL);
406 419
407 // Undo tab helper work done in SetupPreviewContents(). 420 // Undo tab helper work done in SetupPreviewContents().
408 421
409 BlockedContentTabHelper::FromWebContents(contents())-> 422 BlockedContentTabHelper::FromWebContents(contents())->
(...skipping 20 matching lines...) Expand all
430 content::WebContents* new_contents) { 443 content::WebContents* new_contents) {
431 DCHECK_EQ(old_contents, contents()); 444 DCHECK_EQ(old_contents, contents());
432 CleanupPreviewContents(); 445 CleanupPreviewContents();
433 // We release here without deleting so that the caller still has the 446 // We release here without deleting so that the caller still has the
434 // responsibility for deleting the WebContents. 447 // responsibility for deleting the WebContents.
435 ignore_result(contents_.release()); 448 ignore_result(contents_.release());
436 contents_.reset(new_contents); 449 contents_.reset(new_contents);
437 SetupPreviewContents(); 450 SetupPreviewContents();
438 controller_->SwappedWebContents(); 451 controller_->SwappedWebContents();
439 } 452 }
OLDNEW
« chrome/browser/instant/instant_controller.cc ('K') | « chrome/browser/instant/instant_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698