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/ui/search/instant_page.h" | 5 #include "chrome/browser/ui/search/instant_page.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/navigation_details.h" |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/frame_navigate_params.h" |
11 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
12 #include "ui/gfx/font.h" | 14 #include "ui/gfx/font.h" |
13 | 15 |
14 InstantPage::Delegate::~Delegate() { | 16 InstantPage::Delegate::~Delegate() { |
15 } | 17 } |
16 | 18 |
17 InstantPage::~InstantPage() { | 19 InstantPage::~InstantPage() { |
18 } | 20 } |
19 | 21 |
20 bool InstantPage::IsLocal() const { | 22 bool InstantPage::IsLocal() const { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void InstantPage::DidCommitProvisionalLoadForFrame( | 187 void InstantPage::DidCommitProvisionalLoadForFrame( |
186 int64 /* frame_id */, | 188 int64 /* frame_id */, |
187 bool is_main_frame, | 189 bool is_main_frame, |
188 const GURL& url, | 190 const GURL& url, |
189 content::PageTransition /* transition_type */, | 191 content::PageTransition /* transition_type */, |
190 content::RenderViewHost* /* render_view_host */) { | 192 content::RenderViewHost* /* render_view_host */) { |
191 if (is_main_frame && ShouldProcessAboutToNavigateMainFrame()) | 193 if (is_main_frame && ShouldProcessAboutToNavigateMainFrame()) |
192 delegate_->InstantPageAboutToNavigateMainFrame(contents(), url); | 194 delegate_->InstantPageAboutToNavigateMainFrame(contents(), url); |
193 } | 195 } |
194 | 196 |
| 197 void InstantPage::DidFailProvisionalLoad( |
| 198 int64 /* frame_id */, |
| 199 bool /* is_main_frame */, |
| 200 const GURL& /* validated_url */, |
| 201 int /* error_code */, |
| 202 const string16& /* error_description */, |
| 203 content::RenderViewHost* /* render_view_host */) { |
| 204 delegate_->InstantPageLoadFailed(contents()); |
| 205 } |
| 206 |
195 void InstantPage::OnSetSuggestions( | 207 void InstantPage::OnSetSuggestions( |
196 int page_id, | 208 int page_id, |
197 const std::vector<InstantSuggestion>& suggestions) { | 209 const std::vector<InstantSuggestion>& suggestions) { |
198 if (contents()->IsActiveEntry(page_id)) { | 210 if (contents()->IsActiveEntry(page_id)) { |
199 OnInstantSupportDetermined(page_id, true); | 211 OnInstantSupportDetermined(page_id, true); |
200 if (ShouldProcessSetSuggestions()) | 212 if (ShouldProcessSetSuggestions()) |
201 delegate_->SetSuggestions(contents(), suggestions); | 213 delegate_->SetSuggestions(contents(), suggestions); |
202 } | 214 } |
203 } | 215 } |
204 | 216 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 delegate_->DeleteMostVisitedItem(restricted_id); | 262 delegate_->DeleteMostVisitedItem(restricted_id); |
251 } | 263 } |
252 | 264 |
253 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { | 265 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { |
254 delegate_->UndoMostVisitedDeletion(restricted_id); | 266 delegate_->UndoMostVisitedDeletion(restricted_id); |
255 } | 267 } |
256 | 268 |
257 void InstantPage::OnUndoAllMostVisitedDeletions() { | 269 void InstantPage::OnUndoAllMostVisitedDeletions() { |
258 delegate_->UndoAllMostVisitedDeletions(); | 270 delegate_->UndoAllMostVisitedDeletions(); |
259 } | 271 } |
| 272 |
| 273 void InstantPage::DidNavigateMainFrame( |
| 274 const content::LoadCommittedDetails& details, |
| 275 const content::FrameNavigateParams& /* params */) { |
| 276 // A 204 can be sent by the search provider as a lightweight signal |
| 277 // to fall back to the local page, and we obviously want to fall back |
| 278 // if we get any response code that indicates an error. |
| 279 if (details.http_status_code == 204 || details.http_status_code >= 400) |
| 280 delegate_->InstantPageLoadFailed(contents()); |
| 281 } |
OLD | NEW |