Chromium Code Reviews| 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::DidFailProvisionalLoad( | |
|
samarth
2013/05/03 04:39:17
nit: keep functions in same order as in the header
David Black
2013/05/03 06:14:44
Done.
sreeram
2013/05/03 23:17:31
Not done?
David Black
2013/05/04 00:49:23
Done.
| |
| 199 int64 /* frame_id */, | |
| 200 bool /* is_main_frame */, | |
| 201 const GURL& /* validated_url */, | |
| 202 int /* error_code */, | |
| 203 const string16& /* error_description */, | |
| 204 content::RenderViewHost* /* render_view_host */) { | |
| 205 delegate_->InstantPageLoadFailed(contents()); | |
|
sreeram
2013/05/03 23:17:31
Shouldn't you do this only for "if (is_main_frame)
David Black
2013/05/04 00:49:23
Sure, I guess that sanity check makes sense. Done
| |
| 206 } | |
| 207 | |
| 196 void InstantPage::OnSetSuggestions( | 208 void InstantPage::OnSetSuggestions( |
| 197 int page_id, | 209 int page_id, |
| 198 const std::vector<InstantSuggestion>& suggestions) { | 210 const std::vector<InstantSuggestion>& suggestions) { |
| 199 if (contents()->IsActiveEntry(page_id)) { | 211 if (contents()->IsActiveEntry(page_id)) { |
| 200 OnInstantSupportDetermined(page_id, true); | 212 OnInstantSupportDetermined(page_id, true); |
| 201 if (ShouldProcessSetSuggestions()) | 213 if (ShouldProcessSetSuggestions()) |
| 202 delegate_->SetSuggestions(contents(), suggestions); | 214 delegate_->SetSuggestions(contents(), suggestions); |
| 203 } | 215 } |
| 204 } | 216 } |
| 205 | 217 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 delegate_->DeleteMostVisitedItem(restricted_id); | 263 delegate_->DeleteMostVisitedItem(restricted_id); |
| 252 } | 264 } |
| 253 | 265 |
| 254 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { | 266 void InstantPage::OnUndoMostVisitedDeletion(InstantRestrictedID restricted_id) { |
| 255 delegate_->UndoMostVisitedDeletion(restricted_id); | 267 delegate_->UndoMostVisitedDeletion(restricted_id); |
| 256 } | 268 } |
| 257 | 269 |
| 258 void InstantPage::OnUndoAllMostVisitedDeletions() { | 270 void InstantPage::OnUndoAllMostVisitedDeletions() { |
| 259 delegate_->UndoAllMostVisitedDeletions(); | 271 delegate_->UndoAllMostVisitedDeletions(); |
| 260 } | 272 } |
| 273 | |
| 274 void InstantPage::DidNavigateMainFrame( | |
| 275 const content::LoadCommittedDetails& details, | |
| 276 const content::FrameNavigateParams& /* params */) { | |
|
sreeram
2013/05/03 23:17:31
Strange indent. Either 4 from beginning of line, o
David Black
2013/05/04 00:49:23
Done.
| |
| 277 // A 204 can be sent by the search provider as a lightweight signal | |
| 278 // to fall back to the local page, and we obviously want to fall back | |
| 279 // if we get any response code that indicates an error. | |
| 280 if (details.http_status_code == 204 || details.http_status_code >= 400) | |
| 281 delegate_->InstantPageLoadFailed(contents()); | |
|
sreeram
2013/05/03 23:17:31
DidNavigateMainFrame() is called for all main page
David Black
2013/05/04 00:49:23
This does not seem like a coherent concern to me.
David Black
2013/05/04 00:53:51
I have verified that history.pushState does not re
| |
| 282 } | |
| OLD | NEW |