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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1129 |
1130 // Load the instant URL. We don't reflect the url we load in url() as | 1130 // Load the instant URL. We don't reflect the url we load in url() as |
1131 // callers expect that we're loading the URL they tell us to. | 1131 // callers expect that we're loading the URL they tell us to. |
1132 // | 1132 // |
1133 // This uses an empty string for the replacement text as the url doesn't | 1133 // This uses an empty string for the replacement text as the url doesn't |
1134 // really have the search params, but we need to use the replace | 1134 // really have the search params, but we need to use the replace |
1135 // functionality so that embeded tags (like {google:baseURL}) are escaped | 1135 // functionality so that embeded tags (like {google:baseURL}) are escaped |
1136 // correctly. | 1136 // correctly. |
1137 // TODO(sky): having to use a replaceable url is a bit of a hack here. | 1137 // TODO(sky): having to use a replaceable url is a bit of a hack here. |
1138 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( | 1138 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( |
1139 string16(), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); | 1139 SearchTermsArgs(string16()))); |
1140 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1140 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1141 if (cl->HasSwitch(switches::kInstantURL)) | 1141 if (cl->HasSwitch(switches::kInstantURL)) |
1142 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); | 1142 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); |
1143 preview_contents_->web_contents()->GetController().LoadURL( | 1143 preview_contents_->web_contents()->GetController().LoadURL( |
1144 instant_url, content::Referrer(), transition_type, std::string()); | 1144 instant_url, content::Referrer(), transition_type, std::string()); |
1145 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); | 1145 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); |
1146 preview_contents_->web_contents()->HideContents(); | 1146 preview_contents_->web_contents()->HideContents(); |
1147 | 1147 |
1148 // If user_text is empty, this must be a preload of the search homepage. In | 1148 // If user_text is empty, this must be a preload of the search homepage. In |
1149 // that case, send down a SearchBoxResize message, which will switch the page | 1149 // that case, send down a SearchBoxResize message, which will switch the page |
1150 // to "search results" UI. This avoids flicker when the page is shown with | 1150 // to "search results" UI. This avoids flicker when the page is shown with |
1151 // results. In addition, we don't want the page accidentally causing the | 1151 // results. In addition, we don't want the page accidentally causing the |
1152 // preloaded page to be displayed yet (by calling setSuggestions), so don't | 1152 // preloaded page to be displayed yet (by calling setSuggestions), so don't |
1153 // send a SearchBoxChange message. | 1153 // send a SearchBoxChange message. |
1154 if (user_text.empty()) { | 1154 if (user_text.empty()) { |
1155 host->Send(new ChromeViewMsg_SearchBoxResize( | 1155 host->Send(new ChromeViewMsg_SearchBoxResize( |
1156 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); | 1156 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); |
1157 } else { | 1157 } else { |
1158 host->Send(new ChromeViewMsg_SearchBoxChange( | 1158 host->Send(new ChromeViewMsg_SearchBoxChange( |
1159 host->GetRoutingID(), user_text, verbatim, 0, 0)); | 1159 host->GetRoutingID(), user_text, verbatim, 0, 0)); |
1160 } | 1160 } |
1161 | 1161 |
1162 frame_load_observer_.reset(new FrameLoadObserver( | 1162 frame_load_observer_.reset(new FrameLoadObserver( |
1163 this, preview_contents()->web_contents(), user_text, verbatim)); | 1163 this, preview_contents()->web_contents(), user_text, verbatim)); |
1164 } | 1164 } |
OLD | NEW |