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

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

Issue 2140383003: c/b/search/search.h|cc cleanups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 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
« no previous file with comments | « chrome/browser/search/search.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 kPrerenderInstantUrlOnOmniboxFocus, false, flags); 500 kPrerenderInstantUrlOnOmniboxFocus, false, flags);
501 } 501 }
502 502
503 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) { 503 GURL GetEffectiveURLForInstant(const GURL& url, Profile* profile) {
504 CHECK(ShouldAssignURLToInstantRenderer(url, profile)) 504 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
505 << "Error granting Instant access."; 505 << "Error granting Instant access.";
506 506
507 if (url.SchemeIs(chrome::kChromeSearchScheme)) 507 if (url.SchemeIs(chrome::kChromeSearchScheme))
508 return url; 508 return url;
509 509
510 GURL effective_url(url);
511
512 // Replace the scheme with "chrome-search:", and clear the port, since 510 // Replace the scheme with "chrome-search:", and clear the port, since
513 // chrome-search is a scheme without port. 511 // chrome-search is a scheme without port.
514 url::Replacements<char> replacements; 512 url::Replacements<char> replacements;
515 std::string search_scheme(chrome::kChromeSearchScheme); 513 std::string search_scheme(chrome::kChromeSearchScheme);
516 replacements.SetScheme(search_scheme.data(), 514 replacements.SetScheme(search_scheme.data(),
517 url::Component(0, search_scheme.length())); 515 url::Component(0, search_scheme.length()));
518 replacements.ClearPort(); 516 replacements.ClearPort();
519 517
520 // If this is the URL for a server-provided NTP, replace the host with 518 // If this is the URL for a server-provided NTP, replace the host with
521 // "remote-ntp". 519 // "remote-ntp".
522 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); 520 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost);
523 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); 521 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile);
524 if (details.state == NEW_TAB_URL_VALID && 522 if (details.state == NEW_TAB_URL_VALID &&
525 MatchesOriginAndPath(url, details.url)) { 523 MatchesOriginAndPath(url, details.url)) {
526 replacements.SetHost(remote_ntp_host.c_str(), 524 replacements.SetHost(remote_ntp_host.c_str(),
527 url::Component(0, remote_ntp_host.length())); 525 url::Component(0, remote_ntp_host.length()));
528 } 526 }
529 527
530 effective_url = effective_url.ReplaceComponents(replacements); 528 return url.ReplaceComponents(replacements);
531 return effective_url;
532 } 529 }
533 530
534 bool HandleNewTabURLRewrite(GURL* url, 531 bool HandleNewTabURLRewrite(GURL* url,
535 content::BrowserContext* browser_context) { 532 content::BrowserContext* browser_context) {
536 if (!IsInstantExtendedAPIEnabled()) 533 if (!IsInstantExtendedAPIEnabled())
537 return false; 534 return false;
538 535
539 if (!url->SchemeIs(content::kChromeUIScheme) || 536 if (!url->SchemeIs(content::kChromeUIScheme) ||
540 url->host() != chrome::kChromeUINewTabHost) 537 url->host() != chrome::kChromeUINewTabHost)
541 return false; 538 return false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 kUseAltInstantURL, false, flags); 596 kUseAltInstantURL, false, flags);
600 } 597 }
601 598
602 bool ShouldUseSearchPathForInstant() { 599 bool ShouldUseSearchPathForInstant() {
603 FieldTrialFlags flags; 600 FieldTrialFlags flags;
604 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 601 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
605 kUseSearchPathForInstant, false, flags); 602 kUseSearchPathForInstant, false, flags);
606 } 603 }
607 604
608 } // namespace search 605 } // namespace search
OLDNEW
« no previous file with comments | « chrome/browser/search/search.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698