Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 845973005: [New Tab Page] Change the mechanism to intercept online NTP errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved to profile_io_data Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index b610cee66d12737eae90c302ed706a810bbaeaf9..b0768e70df66f038296f8d1fbb64e6218e1ce08b 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -55,20 +55,6 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper);
namespace {
-// For reporting Cacheable NTP navigations.
-enum CacheableNTPLoad {
- CACHEABLE_NTP_LOAD_FAILED = 0,
- CACHEABLE_NTP_LOAD_SUCCEEDED = 1,
- CACHEABLE_NTP_LOAD_MAX = 2
-};
-
-void RecordCacheableNTPLoadHistogram(bool succeeded) {
- UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad",
- succeeded ? CACHEABLE_NTP_LOAD_SUCCEEDED :
- CACHEABLE_NTP_LOAD_FAILED,
- CACHEABLE_NTP_LOAD_MAX);
-}
-
bool IsCacheableNTP(const content::WebContents* contents) {
const content::NavigationEntry* entry =
contents->GetController().GetLastCommittedEntry();
@@ -310,12 +296,9 @@ void SearchTabHelper::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
if (IsCacheableNTP(web_contents_)) {
- if (details.http_status_code == 204 || details.http_status_code >= 400) {
- RedirectToLocalNTP();
- RecordCacheableNTPLoadHistogram(false);
- return;
- }
- RecordCacheableNTPLoadHistogram(true);
+ UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad",
+ chrome::CACHEABLE_NTP_LOAD_SUCCEEDED,
+ chrome::CACHEABLE_NTP_LOAD_MAX);
}
// Always set the title on the new tab page to be the one from our UI
@@ -337,21 +320,6 @@ void SearchTabHelper::DidNavigateMainFrame(
}
}
-void SearchTabHelper::DidFailProvisionalLoad(
- content::RenderFrameHost* render_frame_host,
- const GURL& validated_url,
- int error_code,
- const base::string16& /* error_description */) {
- // If error_code is ERR_ABORTED means that the user has canceled this
- // navigation so it shouldn't be redirected.
- if (!render_frame_host->GetParent() && error_code != net::ERR_ABORTED &&
- validated_url != GURL(chrome::kChromeSearchLocalNtpUrl) &&
- chrome::IsNTPURL(validated_url, profile())) {
- RedirectToLocalNTP();
- RecordCacheableNTPLoadHistogram(false);
- }
-}
-
void SearchTabHelper::DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& /* validated_url */) {
if (!render_frame_host->GetParent()) {
@@ -618,17 +586,6 @@ Profile* SearchTabHelper::profile() const {
return Profile::FromBrowserContext(web_contents_->GetBrowserContext());
}
-void SearchTabHelper::RedirectToLocalNTP() {
- // Extra parentheses to declare a variable.
- content::NavigationController::LoadURLParams load_params(
- (GURL(chrome::kChromeSearchLocalNtpUrl)));
- load_params.referrer = content::Referrer();
- load_params.transition_type = ui::PAGE_TRANSITION_SERVER_REDIRECT;
- // Don't push a history entry.
- load_params.should_replace_current_entry = true;
- web_contents_->GetController().LoadURLWithParams(load_params);
-}
-
bool SearchTabHelper::IsInputInProgress() const {
OmniboxView* omnibox = GetOmniboxView();
return !model_.mode().is_ntp() && omnibox &&
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | chrome/browser/ui/search/search_tab_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698