From 64304a7356d23cbbe30cc7a61d2a63cc4de90990 Mon Sep 17 00:00:00 2001 From: "tengs@chromium.org" Date: Mon, 31 Mar 2014 00:52:51 +0000 Subject: Launch easy unlock setup app from chrome://settings. BUG=347709 Review URL: https://codereview.chromium.org/211333005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260479 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/prefs/browser_prefs.cc | 4 +- chrome/browser/signin/easy_unlock.cc | 43 ++++++++++++++++++++++ chrome/browser/signin/easy_unlock.h | 24 ++++++++++++ chrome/browser/signin/easy_unlock_controller.cc | 26 ------------- chrome/browser/signin/easy_unlock_controller.h | 18 --------- .../ui/webui/options/browser_options_handler.cc | 3 +- 6 files changed, 71 insertions(+), 47 deletions(-) create mode 100644 chrome/browser/signin/easy_unlock.cc create mode 100644 chrome/browser/signin/easy_unlock.h delete mode 100644 chrome/browser/signin/easy_unlock_controller.cc delete mode 100644 chrome/browser/signin/easy_unlock_controller.h (limited to 'chrome/browser') diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index f9cf121..fa6d8ad 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -69,7 +69,7 @@ #include "chrome/browser/search/search.h" #include "chrome/browser/search_engines/template_url_prepopulate_data.h" #include "chrome/browser/services/gcm/gcm_profile_service.h" -#include "chrome/browser/signin/easy_unlock_controller.h" +#include "chrome/browser/signin/easy_unlock.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_promo.h" #include "chrome/browser/task_manager/task_manager.h" @@ -350,7 +350,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { chrome_browser_net::Predictor::RegisterProfilePrefs(registry); chrome_prefs::RegisterProfilePrefs(registry); DownloadPrefs::RegisterProfilePrefs(registry); - EasyUnlockController::RegisterProfilePrefs(registry); + easy_unlock::RegisterProfilePrefs(registry); extensions::ExtensionPrefs::RegisterProfilePrefs(registry); extensions::launch_util::RegisterProfilePrefs(registry); ExtensionWebUI::RegisterProfilePrefs(registry); diff --git a/chrome/browser/signin/easy_unlock.cc b/chrome/browser/signin/easy_unlock.cc new file mode 100644 index 0000000..bf79edc --- /dev/null +++ b/chrome/browser/signin/easy_unlock.cc @@ -0,0 +1,43 @@ +// Copyright 2014 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/signin/easy_unlock.h" + +#include "base/values.h" +#include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/extensions/application_launch.h" +#include "chrome/common/pref_names.h" +#include "components/user_prefs/pref_registry_syncable.h" +#include "extensions/browser/extension_system.h" + +namespace easy_unlock { + +void RegisterProfilePrefs( + user_prefs::PrefRegistrySyncable* registry) { + registry->RegisterBooleanPref( + prefs::kEasyUnlockEnabled, + false, + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); + registry->RegisterBooleanPref( + prefs::kEasyUnlockShowTutorial, + false, + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); + registry->RegisterDictionaryPref( + prefs::kEasyUnlockPairing, + new base::DictionaryValue(), + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); +} + +void LaunchEasyUnlockSetup(Profile* profile) { + ExtensionService* service = + extensions::ExtensionSystem::Get(profile)->extension_service(); + const extensions::Extension* extension = + service->GetExtensionById(extension_misc::kEasyUnlockAppId, false); + + OpenApplication(AppLaunchParams( + profile, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); +} + +} // namespace easy_unlock diff --git a/chrome/browser/signin/easy_unlock.h b/chrome/browser/signin/easy_unlock.h new file mode 100644 index 0000000..48f9f0c --- /dev/null +++ b/chrome/browser/signin/easy_unlock.h @@ -0,0 +1,24 @@ +// Copyright 2014 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_SIGNIN_EASY_UNLOCK_H_ +#define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_H_ + +namespace user_prefs { +class PrefRegistrySyncable; +} + +class Profile; + +namespace easy_unlock { + +// Registers Easy Unlock profile preferences. +void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); + +// Launches Easy Unlock Setup app. +void LaunchEasyUnlockSetup(Profile* profile); + +} // namespace easy_unlock + +#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_H_ diff --git a/chrome/browser/signin/easy_unlock_controller.cc b/chrome/browser/signin/easy_unlock_controller.cc deleted file mode 100644 index d19a6d0..0000000 --- a/chrome/browser/signin/easy_unlock_controller.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 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/signin/easy_unlock_controller.h" - -#include "base/values.h" -#include "chrome/common/pref_names.h" -#include "components/user_prefs/pref_registry_syncable.h" - -// static. -void EasyUnlockController::RegisterProfilePrefs( - user_prefs::PrefRegistrySyncable* registry) { - registry->RegisterBooleanPref( - prefs::kEasyUnlockEnabled, - false, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - registry->RegisterBooleanPref( - prefs::kEasyUnlockShowTutorial, - false, - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); - registry->RegisterDictionaryPref( - prefs::kEasyUnlockPairing, - new base::DictionaryValue(), - user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); -} diff --git a/chrome/browser/signin/easy_unlock_controller.h b/chrome/browser/signin/easy_unlock_controller.h deleted file mode 100644 index b9d53a9..0000000 --- a/chrome/browser/signin/easy_unlock_controller.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 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_SIGNIN_EASY_UNLOCK_CONTROLLER_H_ -#define CHROME_BROWSER_SIGNIN_EASY_UNLOCK_CONTROLLER_H_ - -namespace user_prefs { -class PrefRegistrySyncable; -} - -// Stub class for Easy Unlock features. -class EasyUnlockController { - public: - static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); -}; - -#endif // CHROME_BROWSER_SIGNIN_EASY_UNLOCK_CONTROLLER_H_ diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc index b4a87c6..741b42b 100644 --- a/chrome/browser/ui/webui/options/browser_options_handler.cc +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc @@ -51,6 +51,7 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" +#include "chrome/browser/signin/easy_unlock.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/profile_sync_service.h" @@ -1630,7 +1631,7 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable( void BrowserOptionsHandler::HandleLaunchEasyUnlockSetup( const base::ListValue* args) { - // TODO(tengs): launch Easy Unlock setup flow. + easy_unlock::LaunchEasyUnlockSetup(Profile::FromWebUI(web_ui())); } void BrowserOptionsHandler::HandleRequestHotwordSetupRetry( -- cgit v1.1