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

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

Issue 11555033: Adding local html page used in Instant Extended mode when instant is disabled or unavailable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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.h" 5 #include "chrome/browser/ui/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/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/chrome_version_info.h" 13 #include "chrome/common/chrome_version_info.h"
14 14
15 namespace chrome { 15 namespace chrome {
16 namespace search { 16 namespace search {
17 17
18 bool IsInstantExtendedAPIEnabled(const Profile* profile) { 18 bool IsInstantExtendedAPIEnabled(const Profile* profile) {
19 return EmbeddedSearchPageVersion(profile) != 0; 19 return EmbeddedSearchPageVersion(profile) != 0;
20 } 20 }
21 21
22 uint64 EmbeddedSearchPageVersion(const Profile* profile) { 22 uint64 EmbeddedSearchPageVersion(const Profile* profile) {
23 // Incognito windows do not currently use the embedded search API.
24 if (profile->IsOffTheRecord())
25 return 0;
26
27 // Check Finch field trials. 23 // Check Finch field trials.
28 base::FieldTrial* trial = base::FieldTrialList::Find("InstantExtended"); 24 base::FieldTrial* trial = base::FieldTrialList::Find("InstantExtended");
29 if (trial && StartsWithASCII(trial->group_name(), "Group", true)) { 25 if (trial && StartsWithASCII(trial->group_name(), "Group", true)) {
30 uint64 group_number; 26 uint64 group_number;
31 if (base::StringToUint64(trial->group_name().substr(5), &group_number)) { 27 if (base::StringToUint64(trial->group_name().substr(5), &group_number)) {
32 return group_number; 28 return group_number;
33 } 29 }
34 } 30 }
35 31
36 if (CommandLine::ForCurrentProcess()->HasSwitch( 32 if (CommandLine::ForCurrentProcess()->HasSwitch(
37 switches::kEnableInstantExtendedAPI)) { 33 switches::kEnableInstantExtendedAPI)) {
38 // The user has manually flipped the about:flags switch - give the default 34 // The user has manually flipped the about:flags switch - give the default
39 // UI version. 35 // UI version.
40 return 1; 36 return 1;
41 } 37 }
42 return 0; 38 return 0;
43 } 39 }
44 40
45 void EnableInstantExtendedAPIForTesting() { 41 void EnableInstantExtendedAPIForTesting() {
46 CommandLine::ForCurrentProcess()->AppendSwitch( 42 CommandLine::ForCurrentProcess()->AppendSwitch(
47 switches::kEnableInstantExtendedAPI); 43 switches::kEnableInstantExtendedAPI);
48 } 44 }
49 45
50 } // namespace search 46 } // namespace search
51 } // namespace chrome 47 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698