OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
9 #include "chrome/browser/instant/instant_delegate.h" | 9 #include "chrome/browser/instant/instant_delegate.h" |
10 #include "chrome/browser/instant/instant_loader.h" | 10 #include "chrome/browser/instant/instant_loader.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Number of ms to delay between loading urls. | 21 // Number of ms to delay between loading urls. |
22 static const int kUpdateDelayMS = 200; | 22 static const int kUpdateDelayMS = 200; |
23 | 23 |
24 // static | 24 // static |
25 void InstantController::RegisterUserPrefs(PrefService* prefs) { | 25 void InstantController::RegisterUserPrefs(PrefService* prefs) { |
26 prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false); | 26 prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false); |
27 prefs->RegisterBooleanPref(prefs::kInstantEnabled, false); | 27 prefs->RegisterBooleanPref(prefs::kInstantEnabled, false); |
28 } | 28 } |
29 | 29 |
30 // static | 30 // static |
31 bool InstantController::IsEnabled(Profile* profile) { | 31 bool InstantController::IsEnabled() { |
| 32 // TODO: convert to kInstantEnabled once pref lands. |
32 static bool enabled = false; | 33 static bool enabled = false; |
33 static bool checked = false; | 34 static bool checked = false; |
34 if (!checked) { | 35 if (!checked) { |
35 checked = true; | 36 checked = true; |
36 enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 37 enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
37 switches::kEnableMatchPreview); | 38 switches::kEnableMatchPreview); |
38 } | 39 } |
39 PrefService* prefs = profile->GetPrefs(); | 40 return enabled; |
40 return (enabled || (prefs && prefs->GetBoolean(prefs::kInstantEnabled))); | |
41 } | 41 } |
42 | 42 |
43 InstantController::InstantController(InstantDelegate* delegate) | 43 InstantController::InstantController(InstantDelegate* delegate) |
44 : delegate_(delegate), | 44 : delegate_(delegate), |
45 tab_contents_(NULL), | 45 tab_contents_(NULL), |
46 is_active_(false), | 46 is_active_(false), |
47 commit_on_mouse_up_(false), | 47 commit_on_mouse_up_(false), |
48 last_transition_type_(PageTransition::LINK) { | 48 last_transition_type_(PageTransition::LINK) { |
49 } | 49 } |
50 | 50 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 template_url = model ? model->GetDefaultSearchProvider() : NULL; | 320 template_url = model ? model->GetDefaultSearchProvider() : NULL; |
321 } | 321 } |
322 if (template_url && template_url->id() && | 322 if (template_url && template_url->id() && |
323 template_url->instant_url() && | 323 template_url->instant_url() && |
324 !IsBlacklistedFromInstant(template_url->id()) && | 324 !IsBlacklistedFromInstant(template_url->id()) && |
325 template_url->instant_url()->SupportsReplacement()) { | 325 template_url->instant_url()->SupportsReplacement()) { |
326 return template_url; | 326 return template_url; |
327 } | 327 } |
328 return NULL; | 328 return NULL; |
329 } | 329 } |
OLD | NEW |