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

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

Issue 13877028: Renderer initiated navigations from non instant process should not fall into instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments & ensure InstantLoader pages start in the right SiteInstance. Created 7 years, 7 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/search/search.h" 5 #include "chrome/browser/search/search.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return GetBoolValueForFlagWithDefault(kLocalNTPFlagName, false, flags); 490 return GetBoolValueForFlagWithDefault(kLocalNTPFlagName, false, flags);
491 } 491 }
492 492
493 return false; 493 return false;
494 } 494 }
495 495
496 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) { 496 bool MatchesOriginAndPath(const GURL& my_url, const GURL& other_url) {
497 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path(); 497 return MatchesOrigin(my_url, other_url) && my_url.path() == other_url.path();
498 } 498 }
499 499
500 GURL GetPrivilegedURLForInstant(const GURL& url, Profile* profile) {
501 CHECK(ShouldAssignURLToInstantRenderer(url, profile))
502 << "Error granting Instant access.";
503
504 if (IsPrivilegedURLForInstant(url))
505 return url;
506
507 GURL privileged_url(url);
508
509 // Replace the scheme with "chrome-search:".
510 url_canon::Replacements<char> replacements;
511 std::string search_scheme(chrome::kChromeSearchScheme);
512 replacements.SetScheme(search_scheme.data(),
513 url_parse::Component(0, search_scheme.length()));
514 privileged_url = privileged_url.ReplaceComponents(replacements);
515 return privileged_url;
516 }
517
518 bool IsPrivilegedURLForInstant(const GURL& url) {
519 return url.SchemeIs(chrome::kChromeSearchScheme);
520 }
521
500 void EnableInstantExtendedAPIForTesting() { 522 void EnableInstantExtendedAPIForTesting() {
501 CommandLine* cl = CommandLine::ForCurrentProcess(); 523 CommandLine* cl = CommandLine::ForCurrentProcess();
502 cl->AppendSwitch(switches::kEnableInstantExtendedAPI); 524 cl->AppendSwitch(switches::kEnableInstantExtendedAPI);
503 } 525 }
504 526
505 bool GetFieldTrialInfo(const std::string& group_name, 527 bool GetFieldTrialInfo(const std::string& group_name,
506 FieldTrialFlags* flags, 528 FieldTrialFlags* flags,
507 uint64* group_number) { 529 uint64* group_number) {
508 if (EndsWith(group_name, kDisablingSuffix, true) || 530 if (EndsWith(group_name, kDisablingSuffix, true) ||
509 !StartsWithASCII(group_name, kGroupNumberPrefix, true)) 531 !StartsWithASCII(group_name, kGroupNumberPrefix, true))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 622
601 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(), 623 GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref(),
602 kDisableStartMargin); 624 kDisableStartMargin);
603 // Extended mode instant requires a search terms replacement key. 625 // Extended mode instant requires a search terms replacement key.
604 return instant_url.is_valid() && 626 return instant_url.is_valid() &&
605 (!IsInstantExtendedAPIEnabled() || 627 (!IsInstantExtendedAPIEnabled() ||
606 template_url->HasSearchTermsReplacementKey(instant_url)); 628 template_url->HasSearchTermsReplacementKey(instant_url));
607 } 629 }
608 630
609 } // namespace chrome 631 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698