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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void InstantPage::DidCommitProvisionalLoadForFrame( | 188 void InstantPage::DidCommitProvisionalLoadForFrame( |
187 int64 /* frame_id */, | 189 int64 /* frame_id */, |
188 bool is_main_frame, | 190 bool is_main_frame, |
189 const GURL& url, | 191 const GURL& url, |
190 content::PageTransition /* transition_type */, | 192 content::PageTransition /* transition_type */, |
191 content::RenderViewHost* /* render_view_host */) { | 193 content::RenderViewHost* /* render_view_host */) { |
192 if (is_main_frame && ShouldProcessAboutToNavigateMainFrame()) | 194 if (is_main_frame && ShouldProcessAboutToNavigateMainFrame()) |
193 delegate_->InstantPageAboutToNavigateMainFrame(contents(), url); | 195 delegate_->InstantPageAboutToNavigateMainFrame(contents(), url); |
194 } | 196 } |
195 | 197 |
| 198 void InstantPage::DidNavigateMainFrame( |
| 199 const content::LoadCommittedDetails& details, |
| 200 const content::FrameNavigateParams& /* params */) { |
| 201 // A 204 can be sent by the search provider as a lightweight signal |
| 202 // to fall back to the local page, and we obviously want to fall back |
| 203 // if we get any response code that indicates an error. |
| 204 if (details.http_status_code == 204 || details.http_status_code >= 400) |
| 205 delegate_->InstantPageLoadFailed(contents()); |
| 206 } |
| 207 |
| 208 void InstantPage::DidFailProvisionalLoad( |
| 209 int64 /* frame_id */, |
| 210 bool is_main_frame, |
| 211 const GURL& /* validated_url */, |
| 212 int /* error_code */, |
| 213 const string16& /* error_description */, |
| 214 content::RenderViewHost* /* render_view_host */) { |
| 215 if (is_main_frame) |
| 216 delegate_->InstantPageLoadFailed(contents()); |
| 217 } |
| 218 |
196 void InstantPage::OnSetSuggestions( | 219 void InstantPage::OnSetSuggestions( |
197 int page_id, | 220 int page_id, |
198 const std::vector<InstantSuggestion>& suggestions) { | 221 const std::vector<InstantSuggestion>& suggestions) { |
199 if (contents()->IsActiveEntry(page_id)) { | 222 if (contents()->IsActiveEntry(page_id)) { |
200 OnInstantSupportDetermined(page_id, true); | 223 OnInstantSupportDetermined(page_id, true); |
201 if (ShouldProcessSetSuggestions()) | 224 if (ShouldProcessSetSuggestions()) |
202 delegate_->SetSuggestions(contents(), suggestions); | 225 delegate_->SetSuggestions(contents(), suggestions); |
203 } | 226 } |
204 } | 227 } |
205 | 228 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 delegate_->DeleteMostVisitedItem(restricted_id); | 274 delegate_->DeleteMostVisitedItem(restricted_id); |
252 } | 275 } |
253 | 276 |
254 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { | 277 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { |
255 delegate_->UndoMostVisitedDeletion(restricted_id); | 278 delegate_->UndoMostVisitedDeletion(restricted_id); |
256 } | 279 } |
257 | 280 |
258 void InstantPage::OnUndoAllMostVisitedDeletions() { | 281 void InstantPage::OnUndoAllMostVisitedDeletions() { |
259 delegate_->UndoAllMostVisitedDeletions(); | 282 delegate_->UndoAllMostVisitedDeletions(); |
260 } | 283 } |
OLD | NEW |