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 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 | 1152 |
1153 // Load the instant URL. We don't reflect the url we load in url() as | 1153 // Load the instant URL. We don't reflect the url we load in url() as |
1154 // callers expect that we're loading the URL they tell us to. | 1154 // callers expect that we're loading the URL they tell us to. |
1155 // | 1155 // |
1156 // This uses an empty string for the replacement text as the url doesn't | 1156 // This uses an empty string for the replacement text as the url doesn't |
1157 // really have the search params, but we need to use the replace | 1157 // really have the search params, but we need to use the replace |
1158 // functionality so that embeded tags (like {google:baseURL}) are escaped | 1158 // functionality so that embeded tags (like {google:baseURL}) are escaped |
1159 // correctly. | 1159 // correctly. |
1160 // TODO(sky): having to use a replaceable url is a bit of a hack here. | 1160 // TODO(sky): having to use a replaceable url is a bit of a hack here. |
1161 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( | 1161 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( |
1162 string16(), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); | 1162 TemplateURLRef::SearchTermsArgs(string16()))); |
1163 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1163 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1164 if (cl->HasSwitch(switches::kInstantURL)) | 1164 if (cl->HasSwitch(switches::kInstantURL)) |
1165 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); | 1165 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); |
1166 | 1166 |
1167 preview_contents_->web_contents()->GetController(). | 1167 preview_contents_->web_contents()->GetController(). |
1168 LoadURLWithUserAgentOverride(instant_url, content::Referrer(), | 1168 LoadURLWithUserAgentOverride(instant_url, content::Referrer(), |
1169 transition_type, false, std::string(), override_user_agent); | 1169 transition_type, false, std::string(), override_user_agent); |
1170 | 1170 |
1171 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); | 1171 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); |
1172 preview_contents_->web_contents()->HideContents(); | 1172 preview_contents_->web_contents()->HideContents(); |
1173 | 1173 |
1174 // If user_text is empty, this must be a preload of the search homepage. In | 1174 // If user_text is empty, this must be a preload of the search homepage. In |
1175 // that case, send down a SearchBoxResize message, which will switch the page | 1175 // that case, send down a SearchBoxResize message, which will switch the page |
1176 // to "search results" UI. This avoids flicker when the page is shown with | 1176 // to "search results" UI. This avoids flicker when the page is shown with |
1177 // results. In addition, we don't want the page accidentally causing the | 1177 // results. In addition, we don't want the page accidentally causing the |
1178 // preloaded page to be displayed yet (by calling setSuggestions), so don't | 1178 // preloaded page to be displayed yet (by calling setSuggestions), so don't |
1179 // send a SearchBoxChange message. | 1179 // send a SearchBoxChange message. |
1180 if (user_text.empty()) { | 1180 if (user_text.empty()) { |
1181 host->Send(new ChromeViewMsg_SearchBoxResize( | 1181 host->Send(new ChromeViewMsg_SearchBoxResize( |
1182 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); | 1182 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); |
1183 } else { | 1183 } else { |
1184 host->Send(new ChromeViewMsg_SearchBoxChange( | 1184 host->Send(new ChromeViewMsg_SearchBoxChange( |
1185 host->GetRoutingID(), user_text, verbatim, 0, 0)); | 1185 host->GetRoutingID(), user_text, verbatim, 0, 0)); |
1186 } | 1186 } |
1187 | 1187 |
1188 frame_load_observer_.reset(new FrameLoadObserver( | 1188 frame_load_observer_.reset(new FrameLoadObserver( |
1189 this, preview_contents()->web_contents(), user_text, verbatim)); | 1189 this, preview_contents()->web_contents(), user_text, verbatim)); |
1190 } | 1190 } |
OLD | NEW |