summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordzhioev <dzhioev@chromium.org>2014-09-19 10:09:18 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-19 17:09:47 +0000
commit958e55816c7f9960588b3da7021cd37ec910846b (patch)
tree5802e12df712f1abd5628c3b5299f600b498ebaf
parent1fce1ab55d2128dcb3bcf9945b4c8b388a354484 (diff)
downloadchromium_src-958e55816c7f9960588b3da7021cd37ec910846b.zip
chromium_src-958e55816c7f9960588b3da7021cd37ec910846b.tar.gz
chromium_src-958e55816c7f9960588b3da7021cd37ec910846b.tar.bz2
Host pairing OOBE starts at the right time.
The following behaviour implmented: * If "new-remora-oobe" switch is not set, OOBE starts with with the regular "remora" UI. At the same time wizard controller we start to listen for incoming connection from shark controller. If connection is established, we switch UI to the new one. * Otherwise, we launch the new UI from the beginning of OOBE. Several small issues fixed as well. BUG=405150 TEST=manually Review URL: https://codereview.chromium.org/528803002 Cr-Commit-Position: refs/heads/master@{#295721}
-rw-r--r--chrome/browser/chromeos/login/screens/host_pairing_screen.cc4
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc73
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h22
-rw-r--r--chromeos/chromeos_switches.cc7
-rw-r--r--chromeos/chromeos_switches.h2
-rw-r--r--components/pairing.gypi2
-rw-r--r--components/pairing/shark_connection_listener.cc46
-rw-r--r--components/pairing/shark_connection_listener.h48
8 files changed, 175 insertions, 29 deletions
diff --git a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
index 81aa58f..9862e48 100644
--- a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
+++ b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
@@ -46,7 +46,7 @@ void HostPairingScreen::PrepareToShow() {
void HostPairingScreen::Show() {
if (actor_)
actor_->Show();
- controller_->StartPairing();
+ PairingStageChanged(controller_->GetCurrentStage());
}
void HostPairingScreen::Hide() {
@@ -59,8 +59,6 @@ std::string HostPairingScreen::GetName() const {
}
void HostPairingScreen::PairingStageChanged(Stage new_stage) {
- DCHECK(new_stage != current_stage_);
-
std::string desired_page;
switch (new_stage) {
case HostPairingController::STAGE_NONE:
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 9fd8269..78c1824 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -75,6 +75,7 @@
#include "components/crash/app/breakpad_linux.h"
#include "components/pairing/bluetooth_controller_pairing_controller.h"
#include "components/pairing/bluetooth_host_pairing_controller.h"
+#include "components/pairing/shark_connection_listener.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_types.h"
@@ -108,16 +109,6 @@ bool CanShowHIDDetectionScreen() {
chromeos::switches::kDisableHIDDetectionOnOOBE);
}
-// Checks if we are a remora waiting for a shark.
-bool ShouldShowHostPairingScreen() {
- const bool is_remora =
- g_browser_process->platform_part()->browser_policy_connector_chromeos()->
- GetDeviceCloudPolicyManager()->IsRemoraRequisition();
- const bool pairing_demo = CommandLine::ForCurrentProcess()->HasSwitch(
- chromeos::switches::kShowHostPairingDemo);
- return is_remora && pairing_demo;
-}
-
bool IsResumableScreen(const std::string& screen) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kResumableScreens); ++i) {
if (screen == kResumableScreens[i])
@@ -142,6 +133,13 @@ void RecordUMAHistogramForOOBEStepCompletionTime(std::string screen_name,
histogram->AddTime(step_time);
}
+bool IsRemoraRequisition() {
+ return g_browser_process->platform_part()
+ ->browser_policy_connector_chromeos()
+ ->GetDeviceCloudPolicyManager()
+ ->IsRemoraRequisition();
+}
+
} // namespace
namespace chromeos {
@@ -211,6 +209,7 @@ WizardController::WizardController(chromeos::LoginDisplayHost* host,
login_screen_started_(false),
user_image_screen_return_to_previous_hack_(false),
timezone_resolved_(false),
+ shark_controller_detected_(false),
weak_factory_(this) {
DCHECK(default_controller_ == NULL);
default_controller_ = this;
@@ -269,9 +268,9 @@ void WizardController::Init(
// Use the saved screen preference from Local State.
const std::string screen_pref =
GetLocalState()->GetString(prefs::kOobeScreenPending);
- if (is_out_of_box_ && !screen_pref.empty() &&
- !ShouldShowHostPairingScreen() && (first_screen_name.empty() ||
- first_screen_name == WizardController::kTestNoScreenName)) {
+ if (is_out_of_box_ && !screen_pref.empty() && !IsHostPairingOobe() &&
+ (first_screen_name.empty() ||
+ first_screen_name == WizardController::kTestNoScreenName)) {
first_screen_name_ = screen_pref;
}
@@ -341,6 +340,7 @@ WizardScreen* WizardController::CreateScreen(const std::string& screen_name) {
if (!host_pairing_controller_) {
host_pairing_controller_.reset(
new pairing_chromeos::BluetoothHostPairingController());
+ host_pairing_controller_->StartPairing();
}
return new HostPairingScreen(this,
oobe_display_->GetHostPairingScreenActor(),
@@ -355,6 +355,8 @@ void WizardController::ShowNetworkScreen() {
// in. Keep it visible if the user goes back to the existing network screen.
SetStatusAreaVisible(HasScreen(kNetworkScreenName));
SetCurrentScreen(GetScreen(kNetworkScreenName));
+
+ MaybeStartListeningForSharkConnection();
}
void WizardController::ShowLoginScreen(const LoginScreenContext& context) {
@@ -498,6 +500,7 @@ void WizardController::ShowHIDDetectionScreen() {
VLOG(1) << "Showing HID discovery screen.";
SetStatusAreaVisible(true);
SetCurrentScreen(GetScreen(kHIDDetectionScreenName));
+ MaybeStartListeningForSharkConnection();
}
void WizardController::ShowControllerPairingScreen() {
@@ -572,11 +575,10 @@ void WizardController::OnConnectionFailed() {
}
void WizardController::OnUpdateCompleted() {
- // TODO(dzhioev): place checks related to pairing in a proper place.
- const bool is_shark =
- g_browser_process->platform_part()->browser_policy_connector_chromeos()->
- GetDeviceCloudPolicyManager()->IsSharkRequisition();
-
+ const bool is_shark = g_browser_process->platform_part()
+ ->browser_policy_connector_chromeos()
+ ->GetDeviceCloudPolicyManager()
+ ->IsSharkRequisition();
if (is_shark) {
ShowControllerPairingScreen();
} else if (!auth_token_.empty()) {
@@ -638,8 +640,7 @@ void WizardController::EnableUserImageScreenReturnToPreviousHack() {
user_image_screen_return_to_previous_hack_ = true;
}
-void WizardController::OnEnrollmentAuthTokenReceived(
- const std::string& token) {
+void WizardController::OnEnrollmentAuthTokenReceived(const std::string& token) {
VLOG(1) << "OnEnrollmentAuthTokenReceived " << token;
if (ShouldAutoStartEnrollment() || ShouldRecoverEnrollment()) {
StartupUtils::MarkEulaAccepted();
@@ -908,7 +909,7 @@ void WizardController::AdvanceToScreen(const std::string& screen_name) {
} else if (screen_name != kTestNoScreenName) {
if (is_out_of_box_) {
time_oobe_started_ = base::Time::Now();
- if (ShouldShowHostPairingScreen()) {
+ if (IsHostPairingOobe()) {
ShowHostPairingScreen();
} else if (CanShowHIDDetectionScreen()) {
base::Callback<void(bool)> on_check = base::Bind(
@@ -1240,4 +1241,34 @@ bool WizardController::SetOnTimeZoneResolvedForTesting(
return true;
}
+bool WizardController::IsHostPairingOobe() const {
+ return IsRemoraRequisition() &&
+ (CommandLine::ForCurrentProcess()->HasSwitch(switches::kHostPairingOobe) ||
+ shark_controller_detected_);
+}
+
+void WizardController::MaybeStartListeningForSharkConnection() {
+ if (!IsRemoraRequisition())
+ return;
+
+ // We shouldn't be here if we are running pairing OOBE already.
+ DCHECK(!IsHostPairingOobe());
+
+ if (!shark_connection_listener_) {
+ shark_connection_listener_.reset(
+ new pairing_chromeos::SharkConnectionListener(
+ base::Bind(&WizardController::OnSharkConnected,
+ weak_factory_.GetWeakPtr())));
+ }
+}
+
+void WizardController::OnSharkConnected(
+ scoped_ptr<pairing_chromeos::HostPairingController> pairing_controller) {
+ host_pairing_controller_ = pairing_controller.Pass();
+ base::MessageLoop::current()->DeleteSoon(
+ FROM_HERE, shark_connection_listener_.release());
+ shark_controller_detected_ = true;
+ ShowHostPairingScreen();
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index 5956852..91f6a6f 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -30,6 +30,7 @@ class DictionaryValue;
}
namespace pairing_chromeos {
+class SharkConnectionListener;
class ControllerPairingController;
class HostPairingController;
}
@@ -302,6 +303,18 @@ class WizardController : public ScreenObserver, public ScreenManager {
// Returns false if timezone has already been resolved.
bool SetOnTimeZoneResolvedForTesting(const base::Closure& callback);
+ // Returns true for pairing remora OOBE.
+ bool IsHostPairingOobe() const;
+
+ // Starts listening for an incoming shark controller connection, if we are
+ // running remora OOBE.
+ void MaybeStartListeningForSharkConnection();
+
+ // Called when a connection to controller has been established. Wizard
+ // controller takes the ownership of |pairing_controller| after that call.
+ void OnSharkConnected(
+ scoped_ptr<pairing_chromeos::HostPairingController> pairing_controller);
+
// Whether to skip any screens that may normally be shown after login
// (registration, Terms of Service, user image selection).
static bool skip_post_login_screens_;
@@ -397,6 +410,15 @@ class WizardController : public ScreenObserver, public ScreenManager {
bool timezone_resolved_;
base::Closure on_timezone_resolved_for_testing_;
+ // True if shark device initiated connection to this device.
+ bool shark_controller_detected_;
+
+ // Listens for incoming connection from a shark controller if a regular (not
+ // pairing) remora OOBE is active. If connection is established, wizard
+ // conroller swithces to a pairing OOBE.
+ scoped_ptr<pairing_chromeos::SharkConnectionListener>
+ shark_connection_listener_;
+
base::WeakPtrFactory<WizardController> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WizardController);
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc
index 67071ee..e426eff 100644
--- a/chromeos/chromeos_switches.cc
+++ b/chromeos/chromeos_switches.cc
@@ -154,6 +154,9 @@ const char kHasChromeOSDiamondKey[] = "has-chromeos-diamond-key";
// Defines user homedir. This defaults to primary user homedir.
const char kHomedir[] = "homedir";
+// With this switch, start remora OOBE with the pairing screen.
+const char kHostPairingOobe[] = "host-pairing-oobe";
+
// If true, profile selection in UserManager will always return active user's
// profile.
// TODO(nkostlyev): http://crbug.com/364604 - Get rid of this switch after we
@@ -213,10 +216,6 @@ const char kPowerStub[] = "power-stub";
// 'interactive=3' - Interactive mode, connect/scan/etc requests take 3 secs
const char kShillStub[] = "shill-stub";
-// If this switch is set, controller pairing process is displayed after update
-// stage of OOBE.
-const char kShowHostPairingDemo[] = "show-host-pairing-demo";
-
// Sends test messages on first call to RequestUpdate (stub only).
const char kSmsTestMessages[] = "sms-test-messages";
diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h
index 4b270e5..e67a10c 100644
--- a/chromeos/chromeos_switches.h
+++ b/chromeos/chromeos_switches.h
@@ -62,6 +62,7 @@ CHROMEOS_EXPORT extern const char kGuestSession[];
CHROMEOS_EXPORT extern const char kHasChromeOSDiamondKey[];
CHROMEOS_EXPORT extern const char kHasChromeOSKeyboard[];
CHROMEOS_EXPORT extern const char kHomedir[];
+CHROMEOS_EXPORT extern const char kHostPairingOobe[];
CHROMEOS_EXPORT extern const char kIgnoreUserProfileMappingForTests[];
CHROMEOS_EXPORT extern const char kKioskModeScreensaverPath[];
CHROMEOS_EXPORT extern const char kLoginManager[];
@@ -73,7 +74,6 @@ CHROMEOS_EXPORT extern const char kOobeSkipPostLogin[];
CHROMEOS_EXPORT extern const char kOobeTimerInterval[];
CHROMEOS_EXPORT extern const char kPowerStub[];
CHROMEOS_EXPORT extern const char kShillStub[];
-CHROMEOS_EXPORT extern const char kShowHostPairingDemo[];
CHROMEOS_EXPORT extern const char kSmsTestMessages[];
CHROMEOS_EXPORT extern const char kStubCrosSettings[];
CHROMEOS_EXPORT extern const char kTestAutoUpdateUI[];
diff --git a/components/pairing.gypi b/components/pairing.gypi
index 6feb729..6fea47c 100644
--- a/components/pairing.gypi
+++ b/components/pairing.gypi
@@ -35,6 +35,8 @@
'pairing/message_buffer.h',
'pairing/proto_decoder.cc',
'pairing/proto_decoder.h',
+ 'pairing/shark_connection_listener.cc',
+ 'pairing/shark_connection_listener.h',
],
},
{
diff --git a/components/pairing/shark_connection_listener.cc b/components/pairing/shark_connection_listener.cc
new file mode 100644
index 0000000..ce63aa0
--- /dev/null
+++ b/components/pairing/shark_connection_listener.cc
@@ -0,0 +1,46 @@
+// 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 "components/pairing/shark_connection_listener.h"
+
+#include "base/logging.h"
+#include "base/threading/thread_restrictions.h"
+#include "components/pairing/bluetooth_host_pairing_controller.h"
+
+namespace pairing_chromeos {
+
+SharkConnectionListener::SharkConnectionListener(OnConnectedCallback callback)
+ : callback_(callback) {
+ controller_.reset(new BluetoothHostPairingController());
+ controller_->AddObserver(this);
+ controller_->StartPairing();
+}
+
+SharkConnectionListener::~SharkConnectionListener() {
+ if (controller_)
+ controller_->RemoveObserver(this);
+}
+
+void SharkConnectionListener::PairingStageChanged(Stage new_stage) {
+ if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION) {
+ controller_->RemoveObserver(this);
+ callback_.Run(controller_.Pass());
+ callback_.Reset();
+ }
+}
+
+void SharkConnectionListener::ConfigureHost(
+ bool accepted_eula,
+ const std::string& lang,
+ const std::string& timezone,
+ bool send_reports,
+ const std::string& keyboard_layout) {
+ NOTREACHED();
+}
+
+void SharkConnectionListener::EnrollHost(const std::string& auth_token) {
+ NOTREACHED();
+}
+
+} // namespace pairing_chromeos
diff --git a/components/pairing/shark_connection_listener.h b/components/pairing/shark_connection_listener.h
new file mode 100644
index 0000000..e2e786b
--- /dev/null
+++ b/components/pairing/shark_connection_listener.h
@@ -0,0 +1,48 @@
+// 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 COMPONENTS_PAIRING_SHARK_CONNECTION_LISTENER_H_
+#define COMPONENTS_PAIRING_SHARK_CONNECTION_LISTENER_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "components/pairing/host_pairing_controller.h"
+
+namespace pairing_chromeos {
+
+// Listens for incoming connection from shark controller. If connection
+// is established, invokes callback passing HostPairingController
+// as an argument.
+class SharkConnectionListener : public HostPairingController::Observer {
+ public:
+ typedef base::Callback<void(scoped_ptr<HostPairingController>)>
+ OnConnectedCallback;
+
+ explicit SharkConnectionListener(OnConnectedCallback callback);
+ virtual ~SharkConnectionListener();
+
+ private:
+ typedef HostPairingController::Stage Stage;
+
+ // HostPairingController::Observer overrides:
+ virtual void PairingStageChanged(Stage new_stage) OVERRIDE;
+ virtual void ConfigureHost(bool accepted_eula,
+ const std::string& lang,
+ const std::string& timezone,
+ bool send_reports,
+ const std::string& keyboard_layout) OVERRIDE;
+ virtual void EnrollHost(const std::string& auth_token) OVERRIDE;
+
+ OnConnectedCallback callback_;
+ scoped_ptr<HostPairingController> controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharkConnectionListener);
+};
+
+} // namespace pairing_chromeos
+
+#endif // COMPONENTS_PAIRING_SHARK_CONNECTION_LISTENER_H_