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

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

Issue 1910693002: Avoid the long merge session throttle interstitial page for NTP on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: treib's comments Created 4 years, 8 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/chromeos/login/signin/merge_session_throttling_utils.cc ('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 24 matching lines...) Expand all
35 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/render_process_host.h" 36 #include "content/public/browser/render_process_host.h"
37 #include "content/public/browser/web_contents.h" 37 #include "content/public/browser/web_contents.h"
38 38
39 #if defined(ENABLE_SUPERVISED_USERS) 39 #if defined(ENABLE_SUPERVISED_USERS)
40 #include "chrome/browser/supervised_user/supervised_user_service.h" 40 #include "chrome/browser/supervised_user/supervised_user_service.h"
41 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 41 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
42 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" 42 #include "chrome/browser/supervised_user/supervised_user_url_filter.h"
43 #endif 43 #endif
44 44
45 #if defined(OS_CHROMEOS)
46 #include "chrome/browser/chromeos/login/signin/merge_session_throttling_utils.h"
47 #endif // defined(OS_CHROMEOS)
48
45 namespace search { 49 namespace search {
46 50
47 namespace { 51 namespace {
48 52
49 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; 53 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp";
50 const char kPrerenderInstantUrlOnOmniboxFocus[] = 54 const char kPrerenderInstantUrlOnOmniboxFocus[] =
51 "prerender_instant_url_on_omnibox_focus"; 55 "prerender_instant_url_on_omnibox_focus";
52 56
53 // Controls whether to use the alternate Instant search base URL. This allows 57 // Controls whether to use the alternate Instant search base URL. This allows
54 // experimentation of Instant search. 58 // experimentation of Instant search.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return NEW_TAB_URL_INCOGNITO; 236 return NEW_TAB_URL_INCOGNITO;
233 if (!new_tab_url.is_valid()) 237 if (!new_tab_url.is_valid())
234 return NEW_TAB_URL_NOT_SET; 238 return NEW_TAB_URL_NOT_SET;
235 if (!new_tab_url.SchemeIsCryptographic()) 239 if (!new_tab_url.SchemeIsCryptographic())
236 return NEW_TAB_URL_INSECURE; 240 return NEW_TAB_URL_INSECURE;
237 if (!IsURLAllowedForSupervisedUser(new_tab_url, profile)) 241 if (!IsURLAllowedForSupervisedUser(new_tab_url, profile))
238 return NEW_TAB_URL_BLOCKED; 242 return NEW_TAB_URL_BLOCKED;
239 return NEW_TAB_URL_VALID; 243 return NEW_TAB_URL_VALID;
240 } 244 }
241 245
246 // On Chrome OS, if the session hasn't merged yet, we need to avoid loading the
247 // remote NTP because that will trigger showing the merge session throttle
248 // interstitial page, which can show for 5+ seconds. crbug.com/591530.
249 bool ShouldShowLocalNewTab(const GURL& url, Profile* profile) {
250 #if defined(OS_CHROMEOS)
251 if (!merge_session_throttling_utils::ShouldDelayUrl(url) ||
252 !merge_session_throttling_utils::ShouldDelayRequest(profile)) {
Marc Treib 2016/04/21 19:53:38 Can you please swap the if around, to if (ShouldDe
afakhry 2016/04/22 00:41:14 Done. Regarding combining them into one function,
253 return false;
254 }
255
256 return true;
257 #else
258 return false;
259 #endif // defined(OS_CHROMEOS)
260 }
261
242 // Used to look up the URL to use for the New Tab page. Also tracks how we 262 // Used to look up the URL to use for the New Tab page. Also tracks how we
243 // arrived at that URL so it can be logged with UMA. 263 // arrived at that URL so it can be logged with UMA.
244 struct NewTabURLDetails { 264 struct NewTabURLDetails {
245 NewTabURLDetails(const GURL& url, NewTabURLState state) 265 NewTabURLDetails(const GURL& url, NewTabURLState state)
246 : url(url), state(state) {} 266 : url(url), state(state) {}
247 267
248 static NewTabURLDetails ForProfile(Profile* profile) { 268 static NewTabURLDetails ForProfile(Profile* profile) {
249 const GURL local_url(chrome::kChromeSearchLocalNtpUrl); 269 const GURL local_url(chrome::kChromeSearchLocalNtpUrl);
250 270
251 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 271 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
252 if (command_line->HasSwitch(switches::kForceLocalNtp)) 272 if (command_line->HasSwitch(switches::kForceLocalNtp))
253 return NewTabURLDetails(local_url, NEW_TAB_URL_VALID); 273 return NewTabURLDetails(local_url, NEW_TAB_URL_VALID);
254 274
255 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); 275 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
256 if (!profile || !template_url) 276 if (!profile || !template_url)
257 return NewTabURLDetails(local_url, NEW_TAB_URL_BAD); 277 return NewTabURLDetails(local_url, NEW_TAB_URL_BAD);
258 278
259 GURL search_provider_url = TemplateURLRefToGURL( 279 GURL search_provider_url = TemplateURLRefToGURL(
260 template_url->new_tab_url_ref(), UIThreadSearchTermsData(profile), 280 template_url->new_tab_url_ref(), UIThreadSearchTermsData(profile),
261 false, false); 281 false, false);
282
283 if (ShouldShowLocalNewTab(search_provider_url, profile))
284 return NewTabURLDetails(local_url, NEW_TAB_URL_VALID);
285
262 NewTabURLState state = IsValidNewTabURL(profile, search_provider_url); 286 NewTabURLState state = IsValidNewTabURL(profile, search_provider_url);
263 switch (state) { 287 switch (state) {
264 case NEW_TAB_URL_VALID: 288 case NEW_TAB_URL_VALID:
265 // We can use the search provider's page. 289 // We can use the search provider's page.
266 return NewTabURLDetails(search_provider_url, state); 290 return NewTabURLDetails(search_provider_url, state);
267 case NEW_TAB_URL_INCOGNITO: 291 case NEW_TAB_URL_INCOGNITO:
268 // Incognito has its own New Tab. 292 // Incognito has its own New Tab.
269 return NewTabURLDetails(GURL(), state); 293 return NewTabURLDetails(GURL(), state);
270 default: 294 default:
271 // Use the local New Tab otherwise. 295 // Use the local New Tab otherwise.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 kUseAltInstantURL, false, flags); 608 kUseAltInstantURL, false, flags);
585 } 609 }
586 610
587 bool ShouldUseSearchPathForInstant() { 611 bool ShouldUseSearchPathForInstant() {
588 FieldTrialFlags flags; 612 FieldTrialFlags flags;
589 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( 613 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault(
590 kUseSearchPathForInstant, false, flags); 614 kUseSearchPathForInstant, false, flags);
591 } 615 }
592 616
593 } // namespace search 617 } // namespace search
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/signin/merge_session_throttling_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698