Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_overlay.h" | 5 #include "chrome/browser/instant/instant_overlay.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/supports_user_data.h" | 8 #include "base/supports_user_data.h" |
| 9 #include "chrome/browser/ui/search/search.h" | 9 #include "chrome/browser/ui/search/search.h" |
| 10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 void InstantOverlay::OnMouseUp() { | 127 void InstantOverlay::OnMouseUp() { |
| 128 if (is_pointer_down_from_activate_) { | 128 if (is_pointer_down_from_activate_) { |
| 129 is_pointer_down_from_activate_ = false; | 129 is_pointer_down_from_activate_ = false; |
| 130 instant_controller()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); | 130 instant_controller()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 content::WebContents* InstantOverlay::OpenURLFromTab( | 134 content::WebContents* InstantOverlay::OpenURLFromTab( |
| 135 content::WebContents* source, | 135 content::WebContents* source, |
| 136 const content::OpenURLParams& params) { | 136 const content::OpenURLParams& params) { |
| 137 if (!supports_instant()) { | |
| 138 // If the page doesn't yet support Instant, it hasn't fully loaded. | |
|
samarth
2013/02/25 17:15:05
If such a utility doesn't exist already, it would
sreeram
2013/02/25 17:48:01
I couldn't find a utility function. I doubt creati
| |
| 139 // This is a redirect that we should allow. http://crbug.com/177948 | |
| 140 content::NavigationController::LoadURLParams load_params(params.url); | |
| 141 load_params.transition_type = params.transition; | |
| 142 load_params.referrer = params.referrer; | |
| 143 load_params.extra_headers = params.extra_headers; | |
| 144 load_params.is_renderer_initiated = params.is_renderer_initiated; | |
| 145 load_params.transferred_global_request_id = | |
| 146 params.transferred_global_request_id; | |
| 147 load_params.is_cross_site_redirect = params.is_cross_site_redirect; | |
|
Shishir
2013/02/25 17:20:03
Shouldn't this always be true here? Maybe dcheck?
sreeram
2013/02/25 17:48:01
I am not entirely sure (I can't say that I've test
| |
| 148 | |
|
Shishir
2013/02/25 17:20:03
The WindowDisposition is not being carried over. I
sreeram
2013/02/25 17:48:01
The page may try, but we won't honour it. So, we'l
| |
| 149 contents()->GetController().LoadURLWithParams(load_params); | |
|
samarth
2013/02/25 17:15:05
Does this do the right thing with respect to the i
sreeram
2013/02/25 17:48:01
Yes. The process stuff is handled at a lower level
| |
| 150 return contents(); | |
| 151 } | |
| 152 | |
| 137 // We will allow the navigate to continue if we are able to commit the | 153 // We will allow the navigate to continue if we are able to commit the |
| 138 // overlay. | 154 // overlay. |
| 139 // | 155 // |
| 140 // First, cache the overlay contents since committing it will cause the | 156 // First, cache the overlay contents since committing it will cause the |
| 141 // contents to be released (and be set to NULL). | 157 // contents to be released (and be set to NULL). |
| 142 content::WebContents* overlay = contents(); | 158 content::WebContents* overlay = contents(); |
| 143 if (instant_controller()->CommitIfPossible(INSTANT_COMMIT_NAVIGATED)) { | 159 if (instant_controller()->CommitIfPossible(INSTANT_COMMIT_NAVIGATED)) { |
| 144 // If the commit was successful, the overlay's delegate should be the tab | 160 // If the commit was successful, the overlay's delegate should be the tab |
| 145 // strip, which will be able to handle the navigation. | 161 // strip, which will be able to handle the navigation. |
| 146 DCHECK_NE(&loader_, overlay->GetDelegate()); | 162 DCHECK_NE(&loader_, overlay->GetDelegate()); |
| 147 return overlay->GetDelegate()->OpenURLFromTab(source, params); | 163 return overlay->GetDelegate()->OpenURLFromTab(source, params); |
| 148 } | 164 } |
| 149 return NULL; | 165 return NULL; |
| 150 } | 166 } |
| 151 | 167 |
| 152 void InstantOverlay::HandleStalePage() { | 168 void InstantOverlay::HandleStalePage() { |
| 153 is_stale_ = true; | 169 is_stale_ = true; |
| 154 instant_controller()->ReloadOverlayIfStale(); | 170 instant_controller()->ReloadOverlayIfStale(); |
| 155 } | 171 } |
| OLD | NEW |