| 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 "chrome/browser/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 749 } |
| 750 } else { | 750 } else { |
| 751 LoadInstantURL(template_url, transition_type, user_text_, verbatim, | 751 LoadInstantURL(template_url, transition_type, user_text_, verbatim, |
| 752 override_user_agent); | 752 override_user_agent); |
| 753 } | 753 } |
| 754 } else { | 754 } else { |
| 755 DCHECK(template_url_id_ == 0); | 755 DCHECK(template_url_id_ == 0); |
| 756 preview_tab_contents_delegate_->PrepareForNewLoad(); | 756 preview_tab_contents_delegate_->PrepareForNewLoad(); |
| 757 frame_load_observer_.reset(NULL); | 757 frame_load_observer_.reset(NULL); |
| 758 | 758 |
| 759 content::NavigationController::LoadURLParams load_url_params(url_); |
| 760 load_url_params.transition_type = transition_type; |
| 761 load_url_params.override_user_agent = override_user_agent ? |
| 762 content::NavigationController::UA_OVERRIDE_TRUE : |
| 763 content::NavigationController::UA_OVERRIDE_FALSE; |
| 759 preview_contents_->web_contents()->GetController(). | 764 preview_contents_->web_contents()->GetController(). |
| 760 LoadURLWithUserAgentOverride(url_, content::Referrer(), transition_type, | 765 LoadURLWithParams(load_url_params); |
| 761 false, std::string(), override_user_agent); | |
| 762 } | 766 } |
| 763 return true; | 767 return true; |
| 764 } | 768 } |
| 765 | 769 |
| 766 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { | 770 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { |
| 767 if (omnibox_bounds_ == bounds) | 771 if (omnibox_bounds_ == bounds) |
| 768 return; | 772 return; |
| 769 | 773 |
| 770 // Don't update the page while the mouse is down. http://crbug.com/71952 | 774 // Don't update the page while the mouse is down. http://crbug.com/71952 |
| 771 if (IsPointerDownFromActivate()) | 775 if (IsPointerDownFromActivate()) |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 // really have the search params, but we need to use the replace | 1173 // really have the search params, but we need to use the replace |
| 1170 // functionality so that embeded tags (like {google:baseURL}) are escaped | 1174 // functionality so that embeded tags (like {google:baseURL}) are escaped |
| 1171 // correctly. | 1175 // correctly. |
| 1172 // TODO(sky): having to use a replaceable url is a bit of a hack here. | 1176 // TODO(sky): having to use a replaceable url is a bit of a hack here. |
| 1173 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( | 1177 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( |
| 1174 TemplateURLRef::SearchTermsArgs(string16()))); | 1178 TemplateURLRef::SearchTermsArgs(string16()))); |
| 1175 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1179 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 1176 if (cl->HasSwitch(switches::kInstantURL)) | 1180 if (cl->HasSwitch(switches::kInstantURL)) |
| 1177 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); | 1181 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); |
| 1178 | 1182 |
| 1183 content::NavigationController::LoadURLParams load_url_params( |
| 1184 instant_url); |
| 1185 load_url_params.transition_type = transition_type; |
| 1186 load_url_params.override_user_agent = override_user_agent ? |
| 1187 content::NavigationController::UA_OVERRIDE_TRUE : |
| 1188 content::NavigationController::UA_OVERRIDE_FALSE; |
| 1179 preview_contents_->web_contents()->GetController(). | 1189 preview_contents_->web_contents()->GetController(). |
| 1180 LoadURLWithUserAgentOverride(instant_url, content::Referrer(), | 1190 LoadURLWithParams(load_url_params); |
| 1181 transition_type, false, std::string(), override_user_agent); | |
| 1182 | 1191 |
| 1183 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); | 1192 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); |
| 1184 preview_contents_->web_contents()->WasHidden(); | 1193 preview_contents_->web_contents()->WasHidden(); |
| 1185 | 1194 |
| 1186 // If user_text is empty, this must be a preload of the search homepage. In | 1195 // If user_text is empty, this must be a preload of the search homepage. In |
| 1187 // that case, send down a SearchBoxResize message, which will switch the page | 1196 // that case, send down a SearchBoxResize message, which will switch the page |
| 1188 // to "search results" UI. This avoids flicker when the page is shown with | 1197 // to "search results" UI. This avoids flicker when the page is shown with |
| 1189 // results. In addition, we don't want the page accidentally causing the | 1198 // results. In addition, we don't want the page accidentally causing the |
| 1190 // preloaded page to be displayed yet (by calling setSuggestions), so don't | 1199 // preloaded page to be displayed yet (by calling setSuggestions), so don't |
| 1191 // send a SearchBoxChange message. | 1200 // send a SearchBoxChange message. |
| 1192 if (user_text.empty()) { | 1201 if (user_text.empty()) { |
| 1193 host->Send(new ChromeViewMsg_SearchBoxResize( | 1202 host->Send(new ChromeViewMsg_SearchBoxResize( |
| 1194 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); | 1203 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); |
| 1195 } else { | 1204 } else { |
| 1196 host->Send(new ChromeViewMsg_SearchBoxChange( | 1205 host->Send(new ChromeViewMsg_SearchBoxChange( |
| 1197 host->GetRoutingID(), user_text, verbatim, 0, 0)); | 1206 host->GetRoutingID(), user_text, verbatim, 0, 0)); |
| 1198 } | 1207 } |
| 1199 | 1208 |
| 1200 frame_load_observer_.reset(new FrameLoadObserver( | 1209 frame_load_observer_.reset(new FrameLoadObserver( |
| 1201 this, preview_contents()->web_contents(), user_text, verbatim)); | 1210 this, preview_contents()->web_contents(), user_text, verbatim)); |
| 1202 } | 1211 } |
| OLD | NEW |