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

Side by Side Diff: trunk/src/chrome/browser/ui/search/search_tab_helper.cc

Issue 135903002: Revert 244407 "InstantExtended: remove dead code related to the ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void RecordCacheableNTPLoadHistogram(bool succeeded) { 63 void RecordCacheableNTPLoadHistogram(bool succeeded) {
64 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad", 64 UMA_HISTOGRAM_ENUMERATION("InstantExtended.CacheableNTPLoad",
65 succeeded ? CACHEABLE_NTP_LOAD_SUCCEEDED : 65 succeeded ? CACHEABLE_NTP_LOAD_SUCCEEDED :
66 CACHEABLE_NTP_LOAD_FAILED, 66 CACHEABLE_NTP_LOAD_FAILED,
67 CACHEABLE_NTP_LOAD_MAX); 67 CACHEABLE_NTP_LOAD_MAX);
68 } 68 }
69 69
70 bool IsCacheableNTP(const content::WebContents* contents) { 70 bool IsCacheableNTP(const content::WebContents* contents) {
71 const content::NavigationEntry* entry = 71 const content::NavigationEntry* entry =
72 contents->GetController().GetLastCommittedEntry(); 72 contents->GetController().GetLastCommittedEntry();
73 return chrome::NavEntryIsInstantNTP(contents, entry) && 73 return chrome::ShouldUseCacheableNTP() &&
74 chrome::NavEntryIsInstantNTP(contents, entry) &&
74 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl); 75 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl);
75 } 76 }
76 77
77 bool IsNTP(const content::WebContents* contents) { 78 bool IsNTP(const content::WebContents* contents) {
78 // We can't use WebContents::GetURL() because that uses the active entry, 79 // We can't use WebContents::GetURL() because that uses the active entry,
79 // whereas we want the visible entry. 80 // whereas we want the visible entry.
80 const content::NavigationEntry* entry = 81 const content::NavigationEntry* entry =
81 contents->GetController().GetVisibleEntry(); 82 contents->GetController().GetVisibleEntry();
82 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL)) 83 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL))
83 return true; 84 return true;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const base::string16& /* frame_unique_name */, 288 const base::string16& /* frame_unique_name */,
288 bool is_main_frame, 289 bool is_main_frame,
289 const GURL& validated_url, 290 const GURL& validated_url,
290 int error_code, 291 int error_code,
291 const base::string16& /* error_description */, 292 const base::string16& /* error_description */,
292 content::RenderViewHost* /* render_view_host */) { 293 content::RenderViewHost* /* render_view_host */) {
293 // If error_code is ERR_ABORTED means that the user has canceled this 294 // If error_code is ERR_ABORTED means that the user has canceled this
294 // navigation so it shouldn't be redirected. 295 // navigation so it shouldn't be redirected.
295 if (is_main_frame && 296 if (is_main_frame &&
296 error_code != net::ERR_ABORTED && 297 error_code != net::ERR_ABORTED &&
298 chrome::ShouldUseCacheableNTP() &&
297 validated_url != GURL(chrome::kChromeSearchLocalNtpUrl) && 299 validated_url != GURL(chrome::kChromeSearchLocalNtpUrl) &&
298 chrome::IsNTPURL(validated_url, profile())) { 300 chrome::IsNTPURL(validated_url, profile())) {
299 RedirectToLocalNTP(); 301 RedirectToLocalNTP();
300 RecordCacheableNTPLoadHistogram(false); 302 RecordCacheableNTPLoadHistogram(false);
301 } 303 }
302 } 304 }
303 305
304 void SearchTabHelper::DidFinishLoad( 306 void SearchTabHelper::DidFinishLoad(
305 int64 /* frame_id */, 307 int64 /* frame_id */,
306 const GURL& /* validated_url */, 308 const GURL& /* validated_url */,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 void SearchTabHelper::RedirectToLocalNTP() { 594 void SearchTabHelper::RedirectToLocalNTP() {
593 // Extra parentheses to declare a variable. 595 // Extra parentheses to declare a variable.
594 content::NavigationController::LoadURLParams load_params( 596 content::NavigationController::LoadURLParams load_params(
595 (GURL(chrome::kChromeSearchLocalNtpUrl))); 597 (GURL(chrome::kChromeSearchLocalNtpUrl)));
596 load_params.referrer = content::Referrer(); 598 load_params.referrer = content::Referrer();
597 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; 599 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT;
598 // Don't push a history entry. 600 // Don't push a history entry.
599 load_params.should_replace_current_entry = true; 601 load_params.should_replace_current_entry = true;
600 web_contents_->GetController().LoadURLWithParams(load_params); 602 web_contents_->GetController().LoadURLWithParams(load_params);
601 } 603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698