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

Side by Side Diff: chrome/browser/instant/instant_controller.cc

Issue 7337007: Introduce a field trial for Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/instant/instant_controller.h" 5 #include "chrome/browser/instant/instant_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/browser/autocomplete/autocomplete_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/instant/instant_delegate.h" 12 #include "chrome/browser/instant/instant_delegate.h"
13 #include "chrome/browser/instant/instant_field_trial.h"
13 #include "chrome/browser/instant/instant_loader.h" 14 #include "chrome/browser/instant/instant_loader.h"
14 #include "chrome/browser/instant/instant_loader_manager.h" 15 #include "chrome/browser/instant/instant_loader_manager.h"
15 #include "chrome/browser/instant/promo_counter.h" 16 #include "chrome/browser/instant/promo_counter.h"
16 #include "chrome/browser/platform_util.h" 17 #include "chrome/browser/platform_util.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/prerender/prerender_manager.h" 19 #include "chrome/browser/prerender/prerender_manager.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/search_engines/template_url.h" 21 #include "chrome/browser/search_engines/template_url.h"
21 #include "chrome/browser/search_engines/template_url_service.h" 22 #include "chrome/browser/search_engines/template_url_service.h"
22 #include "chrome/browser/search_engines/template_url_service_factory.h" 23 #include "chrome/browser/search_engines/template_url_service_factory.h"
(...skipping 19 matching lines...) Expand all
42 InstantController::InstantController(Profile* profile, 43 InstantController::InstantController(Profile* profile,
43 InstantDelegate* delegate) 44 InstantDelegate* delegate)
44 : delegate_(delegate), 45 : delegate_(delegate),
45 tab_contents_(NULL), 46 tab_contents_(NULL),
46 is_active_(false), 47 is_active_(false),
47 displayable_loader_(NULL), 48 displayable_loader_(NULL),
48 commit_on_mouse_up_(false), 49 commit_on_mouse_up_(false),
49 last_transition_type_(PageTransition::LINK), 50 last_transition_type_(PageTransition::LINK),
50 ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) { 51 ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) {
51 PrefService* service = profile->GetPrefs(); 52 PrefService* service = profile->GetPrefs();
52 if (service) { 53 if (service && !instant_field_trial::IsExperiment(profile)) {
53 // kInstantWasEnabledOnce was added after instant, set it now to make sure 54 // kInstantEnabledOnce was added after instant, set it now to make sure it
54 // it is correctly set. 55 // is correctly set.
55 service->SetBoolean(prefs::kInstantEnabledOnce, true); 56 service->SetBoolean(prefs::kInstantEnabledOnce, true);
56 } 57 }
57 } 58 }
58 59
59 InstantController::~InstantController() { 60 InstantController::~InstantController() {
60 } 61 }
61 62
62 // static 63 // static
63 void InstantController::RegisterUserPrefs(PrefService* prefs) { 64 void InstantController::RegisterUserPrefs(PrefService* prefs) {
64 prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, 65 prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown,
(...skipping 28 matching lines...) Expand all
93 // Histogram from 1 hour to 30 days. 94 // Histogram from 1 hour to 30 days.
94 UMA_HISTOGRAM_CUSTOM_COUNTS("Instant.EnabledTime.Predictive", 95 UMA_HISTOGRAM_CUSTOM_COUNTS("Instant.EnabledTime.Predictive",
95 delta.InHours(), 1, 30 * 24, 50); 96 delta.InHours(), 1, 30 * 24, 50);
96 } 97 }
97 } 98 }
98 } 99 }
99 100
100 // static 101 // static
101 bool InstantController::IsEnabled(Profile* profile) { 102 bool InstantController::IsEnabled(Profile* profile) {
102 PrefService* prefs = profile->GetPrefs(); 103 PrefService* prefs = profile->GetPrefs();
103 return prefs->GetBoolean(prefs::kInstantEnabled); 104 return prefs->GetBoolean(prefs::kInstantEnabled) ||
105 instant_field_trial::IsExperiment(profile);
104 } 106 }
105 107
106 // static 108 // static
107 void InstantController::Enable(Profile* profile) { 109 void InstantController::Enable(Profile* profile) {
108 PromoCounter* promo_counter = profile->GetInstantPromoCounter(); 110 PromoCounter* promo_counter = profile->GetInstantPromoCounter();
109 if (promo_counter) 111 if (promo_counter)
110 promo_counter->Hide(); 112 promo_counter->Hide();
111 113
112 PrefService* service = profile->GetPrefs(); 114 PrefService* service = profile->GetPrefs();
113 if (!service) 115 if (!service)
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 699
698 // Extension keywords don't have a real destination URL. 700 // Extension keywords don't have a real destination URL.
699 if (match.template_url && match.template_url->IsExtensionKeyword()) 701 if (match.template_url && match.template_url->IsExtensionKeyword())
700 return PREVIEW_CONDITION_EXTENSION_KEYWORD; 702 return PREVIEW_CONDITION_EXTENSION_KEYWORD;
701 703
702 // Was the host blacklisted? 704 // Was the host blacklisted?
703 if (host_blacklist_ && host_blacklist_->count(match.destination_url.host())) 705 if (host_blacklist_ && host_blacklist_->count(match.destination_url.host()))
704 return PREVIEW_CONDITION_BLACKLISTED; 706 return PREVIEW_CONDITION_BLACKLISTED;
705 707
706 const CommandLine* cl = CommandLine::ForCurrentProcess(); 708 const CommandLine* cl = CommandLine::ForCurrentProcess();
707 if (cl->HasSwitch(switches::kRestrictInstantToSearch) && 709 if ((cl->HasSwitch(switches::kRestrictInstantToSearch) ||
710 instant_field_trial::IsExperiment(tab_contents_->profile())) &&
708 match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED && 711 match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED &&
709 match.type != AutocompleteMatch::SEARCH_HISTORY && 712 match.type != AutocompleteMatch::SEARCH_HISTORY &&
710 match.type != AutocompleteMatch::SEARCH_SUGGEST && 713 match.type != AutocompleteMatch::SEARCH_SUGGEST &&
711 match.type != AutocompleteMatch::SEARCH_OTHER_ENGINE) { 714 match.type != AutocompleteMatch::SEARCH_OTHER_ENGINE) {
712 return PREVIEW_CONDITION_INSTANT_SEARCH_ONLY; 715 return PREVIEW_CONDITION_INSTANT_SEARCH_ONLY;
713 } 716 }
714 717
715 return PREVIEW_CONDITION_SUCCESS; 718 return PREVIEW_CONDITION_SUCCESS;
716 } 719 }
717 720
(...skipping 14 matching lines...) Expand all
732 if (destroy_factory_.empty()) { 735 if (destroy_factory_.empty()) {
733 MessageLoop::current()->PostTask( 736 MessageLoop::current()->PostTask(
734 FROM_HERE, destroy_factory_.NewRunnableMethod( 737 FROM_HERE, destroy_factory_.NewRunnableMethod(
735 &InstantController::DestroyLoaders)); 738 &InstantController::DestroyLoaders));
736 } 739 }
737 } 740 }
738 741
739 void InstantController::DestroyLoaders() { 742 void InstantController::DestroyLoaders() {
740 loaders_to_destroy_.reset(); 743 loaders_to_destroy_.reset();
741 } 744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698