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.should_inherit_user_agent_override = false; | |
gone
2012/08/03 20:17:37
Seems like this should automatically be set to fal
boliu
2012/08/03 20:46:27
I'm against doing this kind of hidden "magic" logi
| |
762 load_url_params.is_overriding_user_agent = override_user_agent; | |
759 preview_contents_->web_contents()->GetController(). | 763 preview_contents_->web_contents()->GetController(). |
760 LoadURLWithUserAgentOverride(url_, content::Referrer(), transition_type, | 764 LoadURLWithParams(load_url_params); |
761 false, std::string(), override_user_agent); | |
762 } | 765 } |
763 return true; | 766 return true; |
764 } | 767 } |
765 | 768 |
766 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { | 769 void InstantLoader::SetOmniboxBounds(const gfx::Rect& bounds) { |
767 if (omnibox_bounds_ == bounds) | 770 if (omnibox_bounds_ == bounds) |
768 return; | 771 return; |
769 | 772 |
770 // Don't update the page while the mouse is down. http://crbug.com/71952 | 773 // Don't update the page while the mouse is down. http://crbug.com/71952 |
771 if (IsPointerDownFromActivate()) | 774 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 | 1172 // really have the search params, but we need to use the replace |
1170 // functionality so that embeded tags (like {google:baseURL}) are escaped | 1173 // functionality so that embeded tags (like {google:baseURL}) are escaped |
1171 // correctly. | 1174 // correctly. |
1172 // TODO(sky): having to use a replaceable url is a bit of a hack here. | 1175 // 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( | 1176 GURL instant_url(template_url->instant_url_ref().ReplaceSearchTerms( |
1174 TemplateURLRef::SearchTermsArgs(string16()))); | 1177 TemplateURLRef::SearchTermsArgs(string16()))); |
1175 CommandLine* cl = CommandLine::ForCurrentProcess(); | 1178 CommandLine* cl = CommandLine::ForCurrentProcess(); |
1176 if (cl->HasSwitch(switches::kInstantURL)) | 1179 if (cl->HasSwitch(switches::kInstantURL)) |
1177 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); | 1180 instant_url = GURL(cl->GetSwitchValueASCII(switches::kInstantURL)); |
1178 | 1181 |
1182 content::NavigationController::LoadURLParams load_url_params( | |
1183 instant_url); | |
1184 load_url_params.transition_type = transition_type; | |
1185 load_url_params.should_inherit_user_agent_override = false; | |
1186 load_url_params.is_overriding_user_agent = override_user_agent; | |
1179 preview_contents_->web_contents()->GetController(). | 1187 preview_contents_->web_contents()->GetController(). |
1180 LoadURLWithUserAgentOverride(instant_url, content::Referrer(), | 1188 LoadURLWithParams(load_url_params); |
1181 transition_type, false, std::string(), override_user_agent); | |
1182 | 1189 |
1183 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); | 1190 RenderViewHost* host = preview_contents_->web_contents()->GetRenderViewHost(); |
1184 preview_contents_->web_contents()->WasHidden(); | 1191 preview_contents_->web_contents()->WasHidden(); |
1185 | 1192 |
1186 // If user_text is empty, this must be a preload of the search homepage. In | 1193 // 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 | 1194 // 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 | 1195 // 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 | 1196 // 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 | 1197 // preloaded page to be displayed yet (by calling setSuggestions), so don't |
1191 // send a SearchBoxChange message. | 1198 // send a SearchBoxChange message. |
1192 if (user_text.empty()) { | 1199 if (user_text.empty()) { |
1193 host->Send(new ChromeViewMsg_SearchBoxResize( | 1200 host->Send(new ChromeViewMsg_SearchBoxResize( |
1194 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); | 1201 host->GetRoutingID(), GetOmniboxBoundsInTermsOfPreview())); |
1195 } else { | 1202 } else { |
1196 host->Send(new ChromeViewMsg_SearchBoxChange( | 1203 host->Send(new ChromeViewMsg_SearchBoxChange( |
1197 host->GetRoutingID(), user_text, verbatim, 0, 0)); | 1204 host->GetRoutingID(), user_text, verbatim, 0, 0)); |
1198 } | 1205 } |
1199 | 1206 |
1200 frame_load_observer_.reset(new FrameLoadObserver( | 1207 frame_load_observer_.reset(new FrameLoadObserver( |
1201 this, preview_contents()->web_contents(), user_text, verbatim)); | 1208 this, preview_contents()->web_contents(), user_text, verbatim)); |
1202 } | 1209 } |
OLD | NEW |