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

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

Issue 66993003: Most references to GetActiveEntry removed from chrome/browser/ui. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on ToT Created 7 years, 1 month 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
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().GetActiveEntry(); 72 contents->GetController().GetLastCommittedEntry();
73 return chrome::ShouldUseCacheableNTP() && 73 return chrome::ShouldUseCacheableNTP() &&
74 chrome::NavEntryIsInstantNTP(contents, entry) && 74 chrome::NavEntryIsInstantNTP(contents, entry) &&
75 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl); 75 entry->GetURL() != GURL(chrome::kChromeSearchLocalNtpUrl);
76 } 76 }
77 77
78 bool IsNTP(const content::WebContents* contents) { 78 bool IsNTP(const content::WebContents* contents) {
79 // 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,
80 // whereas we want the visible entry. 80 // whereas we want the visible entry.
81 const content::NavigationEntry* entry = 81 const content::NavigationEntry* entry =
82 contents->GetController().GetVisibleEntry(); 82 contents->GetController().GetVisibleEntry();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // resources. Normally, we set the title when we begin a NTP load, but it can 297 // resources. Normally, we set the title when we begin a NTP load, but it can
298 // get reset in several places (like when you press Reload). This check 298 // get reset in several places (like when you press Reload). This check
299 // ensures that the title is properly set to the string defined by the Chrome 299 // ensures that the title is properly set to the string defined by the Chrome
300 // UI language (rather than the server language) in all cases. 300 // UI language (rather than the server language) in all cases.
301 // 301 //
302 // We only override the title when it's nonempty to allow the page to set the 302 // We only override the title when it's nonempty to allow the page to set the
303 // title if it really wants. An empty title means to use the default. There's 303 // title if it really wants. An empty title means to use the default. There's
304 // also a race condition between this code and the page's SetTitle call which 304 // also a race condition between this code and the page's SetTitle call which
305 // this rule avoids. 305 // this rule avoids.
306 content::NavigationEntry* entry = 306 content::NavigationEntry* entry =
307 web_contents_->GetController().GetActiveEntry(); 307 web_contents_->GetController().GetLastCommittedEntry();
308 if (entry && entry->GetTitle().empty() && 308 if (entry && entry->GetTitle().empty() &&
309 (entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL) || 309 (entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL) ||
310 chrome::NavEntryIsInstantNTP(web_contents_, entry))) { 310 chrome::NavEntryIsInstantNTP(web_contents_, entry))) {
311 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); 311 entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
312 } 312 }
313 } 313 }
314 314
315 void SearchTabHelper::DidFailProvisionalLoad( 315 void SearchTabHelper::DidFailProvisionalLoad(
316 int64 /* frame_id */, 316 int64 /* frame_id */,
317 const string16& frame_unique_name, 317 const string16& frame_unique_name,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 void SearchTabHelper::RedirectToLocalNTP() { 558 void SearchTabHelper::RedirectToLocalNTP() {
559 // Extra parentheses to declare a variable. 559 // Extra parentheses to declare a variable.
560 content::NavigationController::LoadURLParams load_params( 560 content::NavigationController::LoadURLParams load_params(
561 (GURL(chrome::kChromeSearchLocalNtpUrl))); 561 (GURL(chrome::kChromeSearchLocalNtpUrl)));
562 load_params.referrer = content::Referrer(); 562 load_params.referrer = content::Referrer();
563 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT; 563 load_params.transition_type = content::PAGE_TRANSITION_SERVER_REDIRECT;
564 // Don't push a history entry. 564 // Don't push a history entry.
565 load_params.should_replace_current_entry = true; 565 load_params.should_replace_current_entry = true;
566 web_contents_->GetController().LoadURLWithParams(load_params); 566 web_contents_->GetController().LoadURLWithParams(load_params);
567 } 567 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698