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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to PrefRegistrySyncable and PrefServiceSyncable to let sync know of pre-registered prefs. Created 7 years, 10 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/ui/browser_instant_controller.h" 5 #include "chrome/browser/ui/browser_instant_controller.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/prefs/pref_registry_syncable.h"
8 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/themes/theme_service.h" 11 #include "chrome/browser/themes/theme_service.h"
11 #include "chrome/browser/themes/theme_service_factory.h" 12 #include "chrome/browser/themes/theme_service_factory.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/omnibox/location_bar.h" 15 #include "chrome/browser/ui/omnibox/location_bar.h"
15 #include "chrome/browser/ui/omnibox/omnibox_view.h" 16 #include "chrome/browser/ui/omnibox/omnibox_view.h"
16 #include "chrome/browser/ui/search/search.h" 17 #include "chrome/browser/ui/search/search.h"
17 #include "chrome/browser/ui/search/search_tab_helper.h" 18 #include "chrome/browser/ui/search/search_tab_helper.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 BrowserInstantController::~BrowserInstantController() { 64 BrowserInstantController::~BrowserInstantController() {
64 browser_->search_model()->RemoveObserver(this); 65 browser_->search_model()->RemoveObserver(this);
65 } 66 }
66 67
67 bool BrowserInstantController::IsInstantEnabled(Profile* profile) { 68 bool BrowserInstantController::IsInstantEnabled(Profile* profile) {
68 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() && 69 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() &&
69 profile->GetPrefs()->GetBoolean(GetInstantPrefName(profile)); 70 profile->GetPrefs()->GetBoolean(GetInstantPrefName(profile));
70 } 71 }
71 72
72 void BrowserInstantController::RegisterUserPrefs(PrefServiceSyncable* prefs) { 73 void BrowserInstantController::RegisterUserPrefs(
73 prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false, 74 PrefService* prefs,
74 PrefServiceSyncable::SYNCABLE_PREF); 75 PrefRegistrySyncable* registry) {
75 prefs->RegisterBooleanPref(prefs::kInstantEnabled, false, 76 // TODO(joi): Get rid of the need for PrefService param above.
76 PrefServiceSyncable::SYNCABLE_PREF); 77 registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false,
78 PrefRegistrySyncable::SYNCABLE_PREF);
79 registry->RegisterBooleanPref(prefs::kInstantEnabled, false,
80 PrefRegistrySyncable::SYNCABLE_PREF);
77 81
78 search::InstantExtendedDefault instant_extended_default_setting = 82 search::InstantExtendedDefault instant_extended_default_setting =
79 search::GetInstantExtendedDefaultSetting(); 83 search::GetInstantExtendedDefaultSetting();
80 84
81 bool instant_extended_value = true; 85 bool instant_extended_value = true;
82 switch (instant_extended_default_setting) { 86 switch (instant_extended_default_setting) {
83 case search::INSTANT_FORCE_ON: 87 case search::INSTANT_FORCE_ON:
84 break; 88 break;
85 case search::INSTANT_USE_EXISTING: 89 case search::INSTANT_USE_EXISTING:
86 instant_extended_value = prefs->GetBoolean(prefs::kInstantEnabled); 90 instant_extended_value = prefs->GetBoolean(prefs::kInstantEnabled);
87 break; 91 break;
88 case search::INSTANT_FORCE_OFF: 92 case search::INSTANT_FORCE_OFF:
89 instant_extended_value = false; 93 instant_extended_value = false;
90 break; 94 break;
91 } 95 }
92 96
93 prefs->RegisterBooleanPref(prefs::kInstantExtendedEnabled, 97 registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled,
94 instant_extended_value, 98 instant_extended_value,
95 PrefServiceSyncable::SYNCABLE_PREF); 99 PrefRegistrySyncable::SYNCABLE_PREF);
96 } 100 }
97 101
98 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) { 102 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
99 // Unsupported dispositions. 103 // Unsupported dispositions.
100 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW) 104 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW)
101 return false; 105 return false;
102 106
103 // The omnibox currently doesn't use other dispositions, so we don't attempt 107 // The omnibox currently doesn't use other dispositions, so we don't attempt
104 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add 108 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add
105 // support for the new disposition. 109 // support for the new disposition.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // part of the image overlay should draw, 'cos the origin is top-left. 317 // part of the image overlay should draw, 'cos the origin is top-left.
314 if (!browser_->search_model()->mode().is_ntp() || 318 if (!browser_->search_model()->mode().is_ntp() ||
315 theme_info_.theme_id.empty() || 319 theme_info_.theme_id.empty() ||
316 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { 320 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) {
317 return; 321 return;
318 } 322 }
319 instant_.ThemeAreaHeightChanged(theme_area_height_); 323 instant_.ThemeAreaHeightChanged(theme_area_height_);
320 } 324 }
321 325
322 } // namespace chrome 326 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698