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

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

Issue 137993020: (Try 2) InstantExtended: remove dead code related to the non-cacheable NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable InstantPolicyTests 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::ShouldUseCacheableNTP() && 73 return chrome::NavEntryIsInstantNTP(contents, entry) &&
74 chrome::NavEntryIsInstantNTP(contents, entry) &&
75 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl); 74 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl);
76 } 75 }
77 76
78 bool IsNTP(const content::WebContents* contents) { 77 bool IsNTP(const content::WebContents* contents) {
79 // We can't use WebContents::GetURL() because that uses the active entry, 78 // We can't use WebContents::GetURL() because that uses the active entry,
80 // whereas we want the visible entry. 79 // whereas we want the visible entry.
81 const content::NavigationEntry* entry = 80 const content::NavigationEntry* entry =
82 contents->GetController().GetVisibleEntry(); 81 contents->GetController().GetVisibleEntry();
83 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL)) 82 if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL))
84 return true; 83 return true;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 const base::string16& /* frame_unique_name */, 287 const base::string16& /* frame_unique_name */,
289 bool is_main_frame, 288 bool is_main_frame,
290 const GURL& validated_url, 289 const GURL& validated_url,
291 int error_code, 290 int error_code,
292 const base::string16& /* error_description */, 291 const base::string16& /* error_description */,
293 content::RenderViewHost* /* render_view_host */) { 292 content::RenderViewHost* /* render_view_host */) {
294 // If error_code is ERR_ABORTED means that the user has canceled this 293 // If error_code is ERR_ABORTED means that the user has canceled this
295 // navigation so it shouldn't be redirected. 294 // navigation so it shouldn't be redirected.
296 if (is_main_frame && 295 if (is_main_frame &&
297 error_code != net::ERR_ABORTED && 296 error_code != net::ERR_ABORTED &&
298 chrome::ShouldUseCacheableNTP() &&
299 validated_url != GURL(chrome::kChromeSearchLocalNtpUrl) && 297 validated_url != GURL(chrome::kChromeSearchLocalNtpUrl) &&
300 chrome::IsNTPURL(validated_url, profile())) { 298 chrome::IsNTPURL(validated_url, profile())) {
301 RedirectToLocalNTP(); 299 RedirectToLocalNTP();
302 RecordCacheableNTPLoadHistogram(false); 300 RecordCacheableNTPLoadHistogram(false);
303 } 301 }
304 } 302 }
305 303
306 void SearchTabHelper::DidFinishLoad( 304 void SearchTabHelper::DidFinishLoad(
307 int64 /* frame_id */, 305 int64 /* frame_id */,
308 const GURL& /* validated_url */, 306 const GURL& /* validated_url */,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 void SearchTabHelper::RedirectToLocalNTP() { 592 void SearchTabHelper::RedirectToLocalNTP() {
595 // Extra parentheses to declare a variable. 593 // Extra parentheses to declare a variable.
596 content::NavigationController::LoadURLParams load_params( 594 content::NavigationController::LoadURLParams load_params(
597 (GURL(chrome::kChromeSearchLocalNtpUrl))); 595 (GURL(chrome::kChromeSearchLocalNtpUrl)));
598 load_params.referrer = content::Referrer(); 596 load_params.referrer = content::Referrer();
599 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; 597 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT;
600 // Don't push a history entry. 598 // Don't push a history entry.
601 load_params.should_replace_current_entry = true; 599 load_params.should_replace_current_entry = true;
602 web_contents_->GetController().LoadURLWithParams(load_params); 600 web_contents_->GetController().LoadURLWithParams(load_params);
603 } 601 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/local_ntp_browsertest.cc ('k') | chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698