| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 void SearchTabHelper::ToggleVoiceSearch() { | 215 void SearchTabHelper::ToggleVoiceSearch() { |
| 216 ipc_router_.ToggleVoiceSearch(); | 216 ipc_router_.ToggleVoiceSearch(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void SearchTabHelper::RenderViewCreated( | 219 void SearchTabHelper::RenderViewCreated( |
| 220 content::RenderViewHost* render_view_host) { | 220 content::RenderViewHost* render_view_host) { |
| 221 ipc_router_.SetPromoInformation(IsAppLauncherEnabled()); | 221 ipc_router_.SetPromoInformation(IsAppLauncherEnabled()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void SearchTabHelper::DidStartNavigationToPendingEntry( |
| 225 const GURL& url, |
| 226 content::NavigationController::ReloadType /* reload_type */) { |
| 227 if (chrome::IsNTPURL(url, profile())) { |
| 228 // Set the title on any pending entry corresponding to the NTP. This |
| 229 // prevents any flickering of the tab title. |
| 230 content::NavigationEntry* entry = |
| 231 web_contents_->GetController().GetPendingEntry(); |
| 232 if (entry) |
| 233 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); |
| 234 } |
| 235 } |
| 236 |
| 224 void SearchTabHelper::DidNavigateMainFrame( | 237 void SearchTabHelper::DidNavigateMainFrame( |
| 225 const content::LoadCommittedDetails& details, | 238 const content::LoadCommittedDetails& details, |
| 226 const content::FrameNavigateParams& params) { | 239 const content::FrameNavigateParams& params) { |
| 227 if (IsCacheableNTP(web_contents_)) { | 240 if (IsCacheableNTP(web_contents_)) { |
| 228 if (details.http_status_code == 204 || details.http_status_code >= 400) { | 241 if (details.http_status_code == 204 || details.http_status_code >= 400) { |
| 229 RedirectToLocalNTP(); | 242 RedirectToLocalNTP(); |
| 230 RecordCacheableNTPLoadHistogram(false); | 243 RecordCacheableNTPLoadHistogram(false); |
| 231 return; | 244 return; |
| 232 } | 245 } |
| 233 RecordCacheableNTPLoadHistogram(true); | 246 RecordCacheableNTPLoadHistogram(true); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 void SearchTabHelper::RedirectToLocalNTP() { | 560 void SearchTabHelper::RedirectToLocalNTP() { |
| 548 // Extra parentheses to declare a variable. | 561 // Extra parentheses to declare a variable. |
| 549 content::NavigationController::LoadURLParams load_params( | 562 content::NavigationController::LoadURLParams load_params( |
| 550 (GURL(chrome::kChromeSearchLocalNtpUrl))); | 563 (GURL(chrome::kChromeSearchLocalNtpUrl))); |
| 551 load_params.referrer = content::Referrer(); | 564 load_params.referrer = content::Referrer(); |
| 552 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; | 565 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; |
| 553 // Don't push a history entry. | 566 // Don't push a history entry. |
| 554 load_params.should_replace_current_entry = true; | 567 load_params.should_replace_current_entry = true; |
| 555 web_contents_->GetController().LoadURLWithParams(load_params); | 568 web_contents_->GetController().LoadURLWithParams(load_params); |
| 556 } | 569 } |
| OLD | NEW |