diff options
Diffstat (limited to 'chrome/browser/instant')
-rw-r--r-- | chrome/browser/instant/instant_confirm_dialog.cc | 38 | ||||
-rw-r--r-- | chrome/browser/instant/instant_confirm_dialog.h | 31 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.cc | 9 | ||||
-rw-r--r-- | chrome/browser/instant/instant_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/instant/instant_opt_in.cc | 9 | ||||
-rw-r--r-- | chrome/browser/instant/instant_opt_in.h | 6 |
6 files changed, 93 insertions, 4 deletions
diff --git a/chrome/browser/instant/instant_confirm_dialog.cc b/chrome/browser/instant/instant_confirm_dialog.cc new file mode 100644 index 0000000..680cdf3 --- /dev/null +++ b/chrome/browser/instant/instant_confirm_dialog.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/instant/instant_confirm_dialog.h" + +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profile.h" +#include "chrome/common/pref_names.h" + +namespace browser { + +// TODO: get the right url. +const char kInstantLearnMoreURL[] = "http://www.google.com"; + +void ShowInstantConfirmDialogIfNecessary(gfx::NativeWindow parent, + Profile* profile) { + PrefService* prefs = profile->GetPrefs(); + if (!prefs) + return; + + if (prefs->GetBoolean(prefs::kInstantConfirmDialogShown)) { + prefs->SetBoolean(prefs::kInstantEnabled, true); + return; + } + + prefs->SetBoolean(prefs::kInstantConfirmDialogShown, true); + ShowInstantConfirmDialog(parent, profile); +} + +#if !defined(TOOLKIT_VIEWS) +void ShowInstantConfirmDialog(gfx::NativeWindow parent, + Profile* profile) { + NOTIMPLEMENTED(); +} +#endif + +} // namespace browser diff --git a/chrome/browser/instant/instant_confirm_dialog.h b/chrome/browser/instant/instant_confirm_dialog.h new file mode 100644 index 0000000..54daaf5 --- /dev/null +++ b/chrome/browser/instant/instant_confirm_dialog.h @@ -0,0 +1,31 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_INSTANT_INSTANT_CONFIRM_DIALOG_H_ +#define CHROME_BROWSER_INSTANT_INSTANT_CONFIRM_DIALOG_H_ +#pragma once + +#include "gfx/native_widget_types.h" + +class Profile; + +namespace browser { + +// URL for learning more about instant. +extern const char kInstantLearnMoreURL[]; + +// Invoked from the opt-in and preferences when the user toggles instant. If the +// instant confirm dialog hasn't been shown, it's shown. If the instant dialog +// has already been shown the dialog is not shown but the preference is toggled. +void ShowInstantConfirmDialogIfNecessary(gfx::NativeWindow parent, + Profile* profile); + +// Shows the platform specific dialog to confirm if the user really wants to +// enable opt-in. +void ShowInstantConfirmDialog(gfx::NativeWindow parent, + Profile* profile); + +} // namespace browser + +#endif // CHROME_BROWSER_INSTANT_INSTANT_CONFIRM_DIALOG_H_ diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index cc4afa4..3c30c44 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -9,18 +9,27 @@ #include "chrome/browser/instant/instant_delegate.h" #include "chrome/browser/instant/instant_loader.h" #include "chrome/browser/instant/instant_loader_manager.h" +#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" // Number of ms to delay between loading urls. static const int kUpdateDelayMS = 200; // static +void InstantController::RegisterUserPrefs(PrefService* prefs) { + prefs->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false); + prefs->RegisterBooleanPref(prefs::kInstantEnabled, false); +} + +// static bool InstantController::IsEnabled() { + // TODO: convert to kInstantEnabled once pref lands. static bool enabled = false; static bool checked = false; if (!checked) { diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 992d927..84a15a2 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -22,6 +22,7 @@ struct AutocompleteMatch; class InstantDelegate; class InstantLoaderManager; +class PrefService; class TabContents; class TemplateURL; @@ -38,6 +39,9 @@ class InstantController : public InstantLoaderDelegate { explicit InstantController(InstantDelegate* delegate); ~InstantController(); + // Registers instant related preferences. + static void RegisterUserPrefs(PrefService* prefs); + // Is InstantController enabled? static bool IsEnabled(); diff --git a/chrome/browser/instant/instant_opt_in.cc b/chrome/browser/instant/instant_opt_in.cc index 611625a..0264881 100644 --- a/chrome/browser/instant/instant_opt_in.cc +++ b/chrome/browser/instant/instant_opt_in.cc @@ -4,6 +4,7 @@ #include "chrome/browser/instant/instant_opt_in.h" +#include "chrome/browser/instant/instant_confirm_dialog.h" #include "chrome/browser/profile.h" namespace browser { @@ -13,8 +14,12 @@ bool ShouldShowInstantOptIn(Profile* profile) { return false; } -void UserPickedInstantOptIn(Profile* profile, bool opt_in) { - // TODO(sky): implement me. +void UserPickedInstantOptIn(gfx::NativeWindow parent, + Profile* profile, + bool opt_in) { + // TODO: set pref so don't show opt-in again. + if (opt_in) + browser::ShowInstantConfirmDialogIfNecessary(parent, profile); } } // namespace browser diff --git a/chrome/browser/instant/instant_opt_in.h b/chrome/browser/instant/instant_opt_in.h index a6505fb..55c62fb 100644 --- a/chrome/browser/instant/instant_opt_in.h +++ b/chrome/browser/instant/instant_opt_in.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_INSTANT_INSTANT_OPT_IN_H_ #pragma once -#include "base/basictypes.h" +#include "gfx/native_widget_types.h" class Profile; @@ -16,7 +16,9 @@ namespace browser { bool ShouldShowInstantOptIn(Profile* profile); // Invoked if the user clicks on the opt-in promo. -void UserPickedInstantOptIn(Profile* profile, bool opt_in); +void UserPickedInstantOptIn(gfx::NativeWindow parent, + Profile* profile, + bool opt_in); } // namespace browser |