summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzork <zork@chromium.org>2014-09-10 14:17:23 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-10 21:21:46 +0000
commit11bb859312e520f71a291971bb2ee7bcb30a9a43 (patch)
treed87c604b174c951c363ff703acd34f142f6df2f2
parentc4d469ee57db15de353d6c3ce04c92b444f38f9b (diff)
downloadchromium_src-11bb859312e520f71a291971bb2ee7bcb30a9a43.zip
chromium_src-11bb859312e520f71a291971bb2ee7bcb30a9a43.tar.gz
chromium_src-11bb859312e520f71a291971bb2ee7bcb30a9a43.tar.bz2
Redirect to the enterprise enrollment screen during remora and shark pairing.
BUG=381007 Review URL: https://codereview.chromium.org/547503002 Cr-Commit-Position: refs/heads/master@{#294232}
-rw-r--r--chrome/browser/chromeos/login/enrollment/enrollment_screen.cc48
-rw-r--r--chrome/browser/chromeos/login/enrollment/enrollment_screen.h36
-rw-r--r--chrome/browser/chromeos/login/screens/controller_pairing_screen.cc10
-rw-r--r--chrome/browser/chromeos/login/screens/host_pairing_screen.cc16
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc30
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h5
-rw-r--r--components/pairing/bluetooth_host_pairing_controller.cc3
7 files changed, 106 insertions, 42 deletions
diff --git a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
index 27ba9d4..a3bfa3b 100644
--- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
+++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc
@@ -24,10 +24,13 @@
#include "chromeos/dbus/dbus_method_call_status.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
+#include "components/pairing/controller_pairing_controller.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "policy/proto/device_management_backend.pb.h"
+using namespace pairing_chromeos;
+
namespace chromeos {
// static
@@ -40,6 +43,8 @@ EnrollmentScreen::EnrollmentScreen(
ScreenObserver* observer,
EnrollmentScreenActor* actor)
: WizardScreen(observer),
+ shark_controller_(NULL),
+ remora_controller_(NULL),
actor_(actor),
enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL),
enrollment_failed_once_(false),
@@ -52,16 +57,26 @@ EnrollmentScreen::EnrollmentScreen(
EmptyVoidDBusMethodCallback());
}
-EnrollmentScreen::~EnrollmentScreen() {}
+EnrollmentScreen::~EnrollmentScreen() {
+ if (remora_controller_)
+ remora_controller_->RemoveObserver(this);
+}
void EnrollmentScreen::SetParameters(
EnrollmentScreenActor::EnrollmentMode enrollment_mode,
const std::string& management_domain,
const std::string& user,
- const std::string& auth_token) {
+ const std::string& auth_token,
+ pairing_chromeos::ControllerPairingController* shark_controller,
+ pairing_chromeos::HostPairingController* remora_controller) {
enrollment_mode_ = enrollment_mode;
user_ = user.empty() ? user : gaia::CanonicalizeEmail(user);
auth_token_ = auth_token;
+ shark_controller_ = shark_controller;
+ DCHECK(!remora_controller_);
+ remora_controller_ = remora_controller;
+ if (remora_controller_)
+ remora_controller_->AddObserver(this);
actor_->SetParameters(this, enrollment_mode_, management_domain);
}
@@ -95,6 +110,27 @@ std::string EnrollmentScreen::GetName() const {
return WizardController::kEnrollmentScreenName;
}
+void EnrollmentScreen::PairingStageChanged(Stage new_stage) {
+ DCHECK(remora_controller_);
+ if (new_stage == HostPairingController::STAGE_FINISHED) {
+ remora_controller_->RemoveObserver(this);
+ remora_controller_ = NULL;
+ // TODO(zork): Check that this is the best exit status. crbug.com/412798
+ get_screen_observer()->OnExit(
+ WizardController::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED);
+ }
+}
+
+void EnrollmentScreen::ConfigureHost(bool accepted_eula,
+ const std::string& lang,
+ const std::string& timezone,
+ bool send_reports,
+ const std::string& keyboard_layout) {
+}
+
+void EnrollmentScreen::EnrollHost(const std::string& auth_token) {
+}
+
void EnrollmentScreen::OnLoginDone(const std::string& user) {
user_ = gaia::CanonicalizeEmail(user);
@@ -239,7 +275,9 @@ void EnrollmentScreen::RegisterForDevicePolicy(const std::string& token) {
}
void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) {
- // TODO(achuith, zork): Send token via Bluetooth to remote device.
+ // TODO(achuith, zork): Extract and send domain.
+ if (shark_controller_)
+ shark_controller_->OnAuthenticationDone("", token);
}
void EnrollmentScreen::ShowEnrollmentStatusOnSuccess(
@@ -257,6 +295,8 @@ void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) {
status));
UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK
: policy::kMetricEnrollmentOK);
+ if (remora_controller_)
+ remora_controller_->SetEnrollmentComplete(true);
return;
case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED:
case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED:
@@ -331,6 +371,8 @@ void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) {
break;
}
+ if (remora_controller_)
+ remora_controller_->SetEnrollmentComplete(false);
enrollment_failed_once_ = true;
actor_->ShowEnrollmentStatus(status);
}
diff --git a/chrome/browser/chromeos/login/enrollment/enrollment_screen.h b/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
index d2d8516..912462a 100644
--- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
+++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.h
@@ -13,9 +13,14 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/login/enrollment/enrollment_screen_actor.h"
#include "chrome/browser/chromeos/login/screens/wizard_screen.h"
+#include "components/pairing/host_pairing_controller.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/enterprise_metrics.h"
+namespace pairing_chromeos {
+class ControllerPairingController;
+}
+
namespace chromeos {
class ScreenManager;
@@ -25,18 +30,30 @@ class ScreenObserver;
// OOBE wizard.
class EnrollmentScreen
: public WizardScreen,
+ public pairing_chromeos::HostPairingController::Observer,
public EnrollmentScreenActor::Controller {
public:
+ typedef pairing_chromeos::HostPairingController::Stage Stage;
+
EnrollmentScreen(ScreenObserver* observer,
EnrollmentScreenActor* actor);
virtual ~EnrollmentScreen();
static EnrollmentScreen* Get(ScreenManager* manager);
- void SetParameters(EnrollmentScreenActor::EnrollmentMode enrollment_mode,
- const std::string& management_domain,
- const std::string& enrollment_user,
- const std::string& auth_token);
+ // Setup how this screen will handle enrollment.
+ // |auth_token| is an optional OAuth token to attempt to enroll with.
+ // |shark_controller| is an interface that is used to communicate with a
+ // remora device for remote enrollment.
+ // |remora_controller| is an interface that is used to communicate with a
+ // shark device for remote enrollment.
+ void SetParameters(
+ EnrollmentScreenActor::EnrollmentMode enrollment_mode,
+ const std::string& management_domain,
+ const std::string& enrollment_user,
+ const std::string& auth_token,
+ pairing_chromeos::ControllerPairingController* shark_controller,
+ pairing_chromeos::HostPairingController* remora_controller);
// WizardScreen implementation:
virtual void PrepareToShow() OVERRIDE;
@@ -44,6 +61,15 @@ class EnrollmentScreen
virtual void Hide() OVERRIDE;
virtual std::string GetName() const OVERRIDE;
+ // pairing_chromeos::HostPairingController::Observer:
+ 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;
+
// EnrollmentScreenActor::Controller implementation:
virtual void OnLoginDone(const std::string& user) OVERRIDE;
virtual void OnAuthError(const GoogleServiceAuthError& error) OVERRIDE;
@@ -95,6 +121,8 @@ class EnrollmentScreen
return enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_AUTO;
}
+ pairing_chromeos::ControllerPairingController* shark_controller_;
+ pairing_chromeos::HostPairingController* remora_controller_;
EnrollmentScreenActor* actor_;
EnrollmentScreenActor::EnrollmentMode enrollment_mode_;
bool enrollment_failed_once_;
diff --git a/chrome/browser/chromeos/login/screens/controller_pairing_screen.cc b/chrome/browser/chromeos/login/screens/controller_pairing_screen.cc
index 382ad45..21d4999 100644
--- a/chrome/browser/chromeos/login/screens/controller_pairing_screen.cc
+++ b/chrome/browser/chromeos/login/screens/controller_pairing_screen.cc
@@ -12,10 +12,6 @@
using namespace chromeos::controller_pairing;
using namespace pairing_chromeos;
-namespace {
-const char* kTestAuthToken = "TestAuthToken";
-};
-
namespace chromeos {
ControllerPairingScreen::ControllerPairingScreen(
@@ -112,6 +108,10 @@ void ControllerPairingScreen::PairingStageChanged(Stage new_stage) {
break;
}
case ControllerPairingController::STAGE_WAITING_FOR_CREDENTIALS: {
+ controller_->RemoveObserver(this);
+ get_screen_observer()->OnExit(
+ WizardController::CONTROLLER_PAIRING_FINISHED);
+ // TODO: Move the rest of the stages to the proper location.
desired_page = kPageEnrollmentIntroduction;
break;
}
@@ -200,8 +200,6 @@ void ControllerPairingScreen::OnUserActed(const std::string& action) {
gaia::SanitizeEmail(context_.GetString(kContextKeyAccountId));
const std::string domain(gaia::ExtractDomainName(account_id));
context_.SetString(kContextKeyEnrollmentDomain, domain);
- // TODO(zork): Get proper credentials. (http://crbug.com/405744)
- controller_->OnAuthenticationDone(domain, kTestAuthToken);
} else if (action == kActionStartSession) {
controller_->StartSession();
}
diff --git a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
index 0752973..81aa58f 100644
--- a/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
+++ b/chrome/browser/chromeos/login/screens/host_pairing_screen.cc
@@ -63,6 +63,10 @@ void HostPairingScreen::PairingStageChanged(Stage new_stage) {
std::string desired_page;
switch (new_stage) {
+ case HostPairingController::STAGE_NONE:
+ case HostPairingController::STAGE_INITIALIZATION_ERROR: {
+ break;
+ }
case HostPairingController::STAGE_WAITING_FOR_CONTROLLER:
case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: {
desired_page = kPageWelcome;
@@ -98,11 +102,7 @@ void HostPairingScreen::PairingStageChanged(Stage new_stage) {
break;
}
case HostPairingController::STAGE_FINISHED: {
- get_screen_observer()->OnExit(WizardController::HOST_PAIRING_FINISHED);
- break;
- }
- default: {
- NOTREACHED();
+ // This page is closed in EnrollHost.
break;
}
}
@@ -122,9 +122,9 @@ void HostPairingScreen::ConfigureHost(bool accepted_eula,
}
void HostPairingScreen::EnrollHost(const std::string& auth_token) {
- // TODO(zork,achuith): Enroll device, send error on error.
- // (http://crbug.com/374990)
- controller_->SetEnrollmentComplete(true);
+ controller_->RemoveObserver(this);
+ WizardController::default_controller()->OnEnrollmentAuthTokenReceived(
+ auth_token);
}
void HostPairingScreen::OnActorDestroyed(HostPairingScreenActor* actor) {
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 121c5e9..563cfc5 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -427,7 +427,9 @@ void WizardController::ShowEnrollmentScreen() {
mode = EnrollmentScreenActor::ENROLLMENT_MODE_FORCED;
}
- screen->SetParameters(mode, enrollment_domain, user, auth_token_);
+ screen->SetParameters(mode, enrollment_domain, user, auth_token_,
+ controller_pairing_controller_.get(),
+ host_pairing_controller_.get());
SetCurrentScreen(screen);
}
@@ -626,6 +628,18 @@ void WizardController::EnableUserImageScreenReturnToPreviousHack() {
user_image_screen_return_to_previous_hack_ = true;
}
+void WizardController::OnEnrollmentAuthTokenReceived(
+ const std::string& token) {
+ VLOG(1) << "OnEnrollmentAuthTokenReceived " << token;
+ if (ShouldAutoStartEnrollment() || ShouldRecoverEnrollment()) {
+ StartupUtils::MarkEulaAccepted();
+ auth_token_ = token;
+ ShowEnrollmentScreen();
+ } else {
+ LOG(WARNING) << "Not in device enrollment.";
+ }
+}
+
void WizardController::OnUserImageSelected() {
if (user_image_screen_return_to_previous_hack_) {
user_image_screen_return_to_previous_hack_ = false;
@@ -1214,18 +1228,4 @@ bool WizardController::SetOnTimeZoneResolvedForTesting(
return true;
}
-void WizardController::OnEnrollmentAuthTokenReceived(
- const std::string& token) {
- // TODO(achuith, zork): This will be called via Bluetooth from a remote
- // controller.
- VLOG(1) << "OnEnrollmentAuthTokenReceived " << token;
- if (ShouldAutoStartEnrollment() || ShouldRecoverEnrollment()) {
- StartupUtils::MarkEulaAccepted();
- auth_token_ = token;
- InitiateOOBEUpdate();
- } else {
- LOG(WARNING) << "Not in device enrollment.";
- }
-}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index 5e4d3cb..d92d2e4 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -127,6 +127,8 @@ class WizardController : public ScreenObserver, public ScreenManager {
// reworked at hackaton.
void EnableUserImageScreenReturnToPreviousHack();
+ // Callback for enrollment auth token.
+ void OnEnrollmentAuthTokenReceived(const std::string& auth_token);
// Returns a pointer to the current screen or NULL if there's no such
// screen.
@@ -297,9 +299,6 @@ class WizardController : public ScreenObserver, public ScreenManager {
// Returns false if timezone has already been resolved.
bool SetOnTimeZoneResolvedForTesting(const base::Closure& callback);
- // Callback for enrollment auth token.
- void OnEnrollmentAuthTokenReceived(const std::string& auth_token);
-
// 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_;
diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
index 29d2bca..a22dfc3 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -266,9 +266,6 @@ void BluetoothHostPairingController::OnPairDevicesMessage(
}
ChangeStage(STAGE_ENROLLING);
- // TODO(zork,achuith): Enroll device, send error on error.
- // (http://crbug.com/374990)
- // For now, test domain is sent in the access token.
FOR_EACH_OBSERVER(Observer, observers_,
EnrollHost(message.parameters().admin_access_token()));
}