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

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

Issue 2409423005: Compare GURLs to kUrlConstants with .spec() and string equality (Closed)
Patch Set: rebase on dependent patch Created 4 years, 2 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
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/search/search.h" 5 #include "chrome/browser/search/search.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return ShouldAssignURLToInstantRenderer(url, profile) && 292 return ShouldAssignURLToInstantRenderer(url, profile) &&
293 (url.host() == chrome::kChromeSearchLocalNtpHost || 293 (url.host() == chrome::kChromeSearchLocalNtpHost ||
294 url.host() == chrome::kChromeSearchRemoteNtpHost); 294 url.host() == chrome::kChromeSearchRemoteNtpHost);
295 } 295 }
296 296
297 bool IsNTPURL(const GURL& url, Profile* profile) { 297 bool IsNTPURL(const GURL& url, Profile* profile) {
298 if (!url.is_valid()) 298 if (!url.is_valid())
299 return false; 299 return false;
300 300
301 if (!IsInstantExtendedAPIEnabled()) 301 if (!IsInstantExtendedAPIEnabled())
302 return url == GURL(chrome::kChromeUINewTabURL); 302 return url == chrome::kChromeUINewTabURL;
303 303
304 const base::string16 search_terms = ExtractSearchTermsFromURL(profile, url); 304 const base::string16 search_terms = ExtractSearchTermsFromURL(profile, url);
305 return profile && 305 return profile && ((IsInstantURL(url, profile) && search_terms.empty()) ||
306 ((IsInstantURL(url, profile) && search_terms.empty()) || 306 url == chrome::kChromeSearchLocalNtpUrl);
307 url == GURL(chrome::kChromeSearchLocalNtpUrl));
308 } 307 }
309 308
310 bool IsInstantNTP(const content::WebContents* contents) { 309 bool IsInstantNTP(const content::WebContents* contents) {
311 if (!contents) 310 if (!contents)
312 return false; 311 return false;
313 312
314 return NavEntryIsInstantNTP(contents, 313 return NavEntryIsInstantNTP(contents,
315 contents->GetController().GetVisibleEntry()); 314 contents->GetController().GetVisibleEntry());
316 } 315 }
317 316
318 bool NavEntryIsInstantNTP(const content::WebContents* contents, 317 bool NavEntryIsInstantNTP(const content::WebContents* contents,
319 const content::NavigationEntry* entry) { 318 const content::NavigationEntry* entry) {
320 if (!contents || !entry || !IsInstantExtendedAPIEnabled()) 319 if (!contents || !entry || !IsInstantExtendedAPIEnabled())
321 return false; 320 return false;
322 321
323 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 322 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
324 if (!IsRenderedInInstantProcess(contents, profile)) 323 if (!IsRenderedInInstantProcess(contents, profile))
325 return false; 324 return false;
326 325
327 return IsInstantNTPURL(entry->GetURL(), profile); 326 return IsInstantNTPURL(entry->GetURL(), profile);
328 } 327 }
329 328
330 bool IsInstantNTPURL(const GURL& url, Profile* profile) { 329 bool IsInstantNTPURL(const GURL& url, Profile* profile) {
331 if (!IsInstantExtendedAPIEnabled()) 330 if (!IsInstantExtendedAPIEnabled())
332 return false; 331 return false;
333 332
334 if (url == GURL(chrome::kChromeSearchLocalNtpUrl)) 333 if (url == chrome::kChromeSearchLocalNtpUrl)
335 return true; 334 return true;
336 335
337 GURL new_tab_url(GetNewTabPageURL(profile)); 336 GURL new_tab_url(GetNewTabPageURL(profile));
338 return new_tab_url.is_valid() && MatchesOriginAndPath(url, new_tab_url); 337 return new_tab_url.is_valid() && MatchesOriginAndPath(url, new_tab_url);
339 } 338 }
340 339
341 bool IsSuggestPrefEnabled(Profile* profile) { 340 bool IsSuggestPrefEnabled(Profile* profile) {
342 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() && 341 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() &&
343 profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled); 342 profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
344 } 343 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 454
456 if (IsInstantNTPURL(*url, profile)) { 455 if (IsInstantNTPURL(*url, profile)) {
457 *url = GURL(chrome::kChromeUINewTabURL); 456 *url = GURL(chrome::kChromeUINewTabURL);
458 return true; 457 return true;
459 } 458 }
460 459
461 return false; 460 return false;
462 } 461 }
463 462
464 } // namespace search 463 } // namespace search
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698