Skip to content

Commit

Permalink
Enable bootstrapping feature by default.
Browse files Browse the repository at this point in the history
Currently it was kept disabled behind a command switch --oobe-bootstrapping-slave.

BUG=597039

Review URL: https://codereview.chromium.org/1829453002

Cr-Commit-Position: refs/heads/master@{#383764}
  • Loading branch information
xdai authored and Commit bot committed Mar 29, 2016
1 parent 9c54157 commit cfe5984
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 76 deletions.
7 changes: 2 additions & 5 deletions chrome/app/chromeos_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -6007,7 +6007,7 @@ All users must sign out to continue.
<message name="IDS_PAIRING_CONTROLLER_HOST_NETWORK_ERROR_TITLE" desc="Title of the controller page which says that the host device's network is not set up successfully.">
Failed to set up your Chromebox's network
</message>
<message name="IDS_PAIRING_ENROLL_TITLE" desc="Title of the enroll page of the 'Chromebox for meeting' setup process.">
<message name="IDS_PAIRING_CONTROLLER_ENROLL_TITLE" desc="Title of the enroll page of the 'Chromebox for meeting' setup process.">
Enroll in your organization
</message>
<message name="IDS_PAIRING_CONTROLLER_ENROLL_TEXT_1" desc="First paragraph of text shown on the controller's enroll page of the 'Chromebox for meeting' setup process. Second paragraph is: 'This will only happen once, and your credentials will not be stored.'">
Expand All @@ -6019,7 +6019,7 @@ All users must sign out to continue.
<message name="IDS_PAIRING_CONTROLLER_CONTINUE" desc="Text on buttons leading to the next step of the 'Chromebox for meeting' setup process.">
Continue
</message>
<message name="IDS_PAIRING_ENROLLMENT_IN_PROGRESS" desc="Message shown on enroll screens of the 'Chromebox for meeting' setup process.">
<message name="IDS_PAIRING_CONTROLLER_ENROLLMENT_IN_PROGRESS" desc="Message shown on enroll screens of the 'Chromebox for meeting' setup process.">
Enrolling in <ph name="BEGIN_BOLD">&lt;strong&gt;</ph><ph name="DOMAIN_NAME">$1<ex>example.com</ex></ph><ph name="END_BOLD">&lt;/strong&gt;</ph>...
</message>
<message name="IDS_PAIRING_ENROLLMENT_ERROR_TITLE" desc="Title of the page shown when enrollment attempt is failed during the 'Chromebox for meeting' setup process.">
Expand All @@ -6043,9 +6043,6 @@ All users must sign out to continue.
<message name="IDS_PAIRING_HOST_WELCOME_TEXT" desc="Text on the host's welcome page of the 'Chromebox for meeting' setup process.">
Turn on your touch controller to set me up
</message>
<message name="IDS_PAIRING_HOST_CONFIRMATION_TITLE" desc="Title of the host's confirmation page of the 'Chromebox for meeting' setup process. 6-digit confirmation code is displayed below.">
Pair with a controller
</message>
<message name="IDS_PAIRING_HOST_UPDATING_TITLE" desc="Title of the host's update page of the 'Chromebox for meeting' setup process.">
Updating Chromebox...
</message>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ class ExistingUserControllerPublicSessionTest
WizardController* controller = WizardController::default_controller();
if (controller && controller->current_screen())
controller->current_screen()->Hide();

if (LoginDisplayHost::default_host())
LoginDisplayHost::default_host()->Finalize();
base::MessageLoop::current()->RunUntilIdle();
}

void ExpectSuccessfulLogin(const UserContext& user_context) {
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/chromeos/login/startup_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1);
registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false);
registry->RegisterStringPref(prefs::kInitialLocale, "en-US");
registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false);
}

// static
Expand Down
47 changes: 27 additions & 20 deletions chrome/browser/chromeos/login/wizard_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,17 @@ bool IsRemoraRequisition() {
->IsRemoraRequisition();
}

// Checks if the device is a "Slave" device in the bootstrapping process.
bool IsBootstrappingSlave() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kOobeBootstrappingSlave);
// Checks if a controller device ("Master") is detected during the bootstrapping
// or shark/remora setup process.
bool IsControllerDetected() {
return g_browser_process->local_state()->GetBoolean(
prefs::kOobeControllerDetected);
}

void SetControllerDetectedPref(bool value) {
PrefService* prefs = g_browser_process->local_state();
prefs->SetBoolean(prefs::kOobeControllerDetected, value);
prefs->CommitPendingWrite();
}

// Checks if the device is a "Master" device in the bootstrapping process.
Expand Down Expand Up @@ -238,6 +245,10 @@ WizardController::WizardController(LoginDisplayHost* host, OobeUI* oobe_ui)
}

WizardController::~WizardController() {
if (shark_connection_listener_.get()) {
base::MessageLoop::current()->DeleteSoon(
FROM_HERE, shark_connection_listener_.release());
}
if (default_controller_ == this) {
default_controller_ = nullptr;
} else {
Expand Down Expand Up @@ -285,11 +296,15 @@ void WizardController::Init(const std::string& first_screen_name) {
const std::string screen_pref =
GetLocalState()->GetString(prefs::kOobeScreenPending);
if (is_out_of_box_ && !screen_pref.empty() && !IsRemoraPairingOobe() &&
!IsBootstrappingSlave() &&
!IsControllerDetected() &&
(first_screen_name.empty() ||
first_screen_name == WizardController::kTestNoScreenName)) {
first_screen_name_ = screen_pref;
}
// We need to reset the kOobeControllerDetected pref to allow the user to have
// the choice to setup the device manually. The pref will be set properly if
// an eligible controller is detected later.
SetControllerDetectedPref(false);

AdvanceToScreen(first_screen_name_);
if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
Expand Down Expand Up @@ -593,7 +608,7 @@ void WizardController::OnUpdateCompleted() {
->IsSharkRequisition();
if (is_shark || IsBootstrappingMaster()) {
ShowControllerPairingScreen();
} else if (IsBootstrappingSlave() && shark_controller_detected_) {
} else if (IsControllerDetected()) {
ShowHostPairingScreen();
} else {
ShowAutoEnrollmentCheckScreen();
Expand Down Expand Up @@ -932,7 +947,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 (IsRemoraPairingOobe() || IsSlavePairingOobe()) {
if (IsRemoraPairingOobe() || IsControllerDetected()) {
ShowHostPairingScreen();
} else if (CanShowHIDDetectionScreen()) {
hid_screen_ = GetScreen(kHIDDetectionScreenName);
Expand Down Expand Up @@ -1309,22 +1324,14 @@ bool WizardController::SetOnTimeZoneResolvedForTesting(
}

bool WizardController::IsRemoraPairingOobe() const {
return IsRemoraRequisition() &&
(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kHostPairingOobe) ||
shark_controller_detected_);
}

bool WizardController::IsSlavePairingOobe() const {
return IsBootstrappingSlave() && shark_controller_detected_;
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kHostPairingOobe);
}

void WizardController::MaybeStartListeningForSharkConnection() {
if (!IsRemoraRequisition() && !IsBootstrappingSlave())
return;

// We shouldn't be here if we are running pairing OOBE already.
DCHECK(!IsRemoraPairingOobe() && !IsSlavePairingOobe());
if (IsControllerDetected())
return;

if (!shark_connection_listener_) {
shark_connection_listener_.reset(
Expand All @@ -1340,7 +1347,7 @@ void WizardController::OnSharkConnected(
remora_controller_ = std::move(remora_controller);
base::MessageLoop::current()->DeleteSoon(
FROM_HERE, shark_connection_listener_.release());
shark_controller_detected_ = true;
SetControllerDetectedPref(true);
ShowHostPairingScreen();
}

Expand Down
10 changes: 3 additions & 7 deletions chrome/browser/chromeos/login/wizard_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,11 @@ class WizardController : public BaseScreenDelegate,
// Returns false if timezone has already been resolved.
bool SetOnTimeZoneResolvedForTesting(const base::Closure& callback);

// Returns true for pairing remora OOBE.
// Returns true if kHostPairingOobe perf has been set. If it's set, launch the
// pairing remora OOBE from the beginning no matter an eligible controller is
// detected or not.
bool IsRemoraPairingOobe() const;

// Returns true for pairing slave OOBE.
bool IsSlavePairingOobe() const;

// Starts listening for an incoming shark controller connection, if we are
// running remora OOBE.
void MaybeStartListeningForSharkConnection();
Expand Down Expand Up @@ -429,9 +428,6 @@ class WizardController : public BaseScreenDelegate,
bool timezone_resolved_ = false;
base::Closure on_timezone_resolved_for_testing_;

// True if shark device initiated connection to this device.
bool shark_controller_detected_ = false;

// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/test/https_forwarder.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/policy/affiliation_test_helper.h"
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
#include "chrome/browser/extensions/extension_apitest.h"
Expand Down Expand Up @@ -323,6 +324,10 @@ class EnterprisePlatformKeysTest
void TearDownOnMainThread() override {
ExtensionApiTest::TearDownOnMainThread();

if (chromeos::LoginDisplayHost::default_host())
chromeos::LoginDisplayHost::default_host()->Finalize();
base::MessageLoop::current()->RunUntilIdle();

if (GetParam().system_token_ == SYSTEM_TOKEN_EXISTS) {
base::RunLoop loop;
content::BrowserThread::PostTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void ControllerPairingScreenHandler::DeclareLocalizedValues(
std::string prefix;
base::RemoveChars(kJsScreenPath, ".", &prefix);

// TODO(xdai): Remove unnecessary strings.
builder->Add(prefix + "WelcomeTitle", IDS_PAIRING_CONTROLLER_WELCOME);
builder->Add(prefix + "Searching", IDS_PAIRING_CONTROLLER_SEARCHING);
builder->Add(prefix + "HelpBtn", IDS_PAIRING_NEED_HELP);
Expand All @@ -95,12 +96,12 @@ void ControllerPairingScreenHandler::DeclareLocalizedValues(
IDS_PAIRING_CONTROLLER_CONNECTION_LOST_TEXT);
builder->Add(prefix + "HostNetworkErrorTitle",
IDS_PAIRING_CONTROLLER_HOST_NETWORK_ERROR_TITLE);
builder->Add(prefix + "EnrollTitle", IDS_PAIRING_ENROLL_TITLE);
builder->Add(prefix + "EnrollTitle", IDS_PAIRING_CONTROLLER_ENROLL_TITLE);
builder->Add(prefix + "EnrollText1", IDS_PAIRING_CONTROLLER_ENROLL_TEXT_1);
builder->Add(prefix + "EnrollText2", IDS_PAIRING_CONTROLLER_ENROLL_TEXT_2);
builder->Add(prefix + "ContinueBtn", IDS_PAIRING_CONTROLLER_CONTINUE);
builder->Add(prefix + "EnrollmentInProgress",
IDS_PAIRING_ENROLLMENT_IN_PROGRESS);
IDS_PAIRING_CONTROLLER_ENROLLMENT_IN_PROGRESS);
builder->Add(prefix + "EnrollmentErrorTitle",
IDS_PAIRING_ENROLLMENT_ERROR_TITLE);
builder->Add(prefix + "EnrollmentErrorHostRestarts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ const char kMethodContextChanged[] = "contextChanged";
// all screens migrate to context-based communications.
const char kCallbackContextReady[] = "contextReady";

bool IsBootstrappingSlave() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kOobeBootstrappingSlave);
}

} // namespace

HostPairingScreenHandler::HostPairingScreenHandler()
Expand Down Expand Up @@ -65,19 +60,18 @@ void HostPairingScreenHandler::DeclareLocalizedValues(
std::string prefix;
base::RemoveChars(kJsScreenPath, ".", &prefix);

// TODO(xdai): Clean up all unrelated strings and rename others if necessary.
builder->Add(prefix + "WelcomeTitle", IDS_PAIRING_HOST_WELCOME_TITLE);
builder->Add(prefix + "WelcomeText", IDS_PAIRING_HOST_WELCOME_TEXT);
builder->Add(prefix + "ConfirmationTitle",
IDS_PAIRING_HOST_CONFIRMATION_TITLE);
builder->Add(prefix + "ConfirmationTitle", IDS_SLAVE_CONFIRMATION_TITLE);
builder->Add(prefix + "UpdatingTitle", IDS_PAIRING_HOST_UPDATING_TITLE);
builder->Add(prefix + "UpdatingText", IDS_PAIRING_HOST_UPDATING_TEXT);
builder->Add(prefix + "EnrollTitle", IDS_PAIRING_ENROLL_TITLE);
builder->Add(prefix + "EnrollingTitle",
IDS_PAIRING_ENROLLMENT_IN_PROGRESS);
builder->Add(prefix + "EnrollTitle", IDS_SLAVE_ENROLL_TITLE);
builder->Add(prefix + "EnrollingTitle", IDS_SLAVE_ENROLLMENT_IN_PROGRESS);
builder->Add(prefix + "DoneTitle", IDS_PAIRING_HOST_DONE_TITLE);
builder->Add(prefix + "DoneText", IDS_PAIRING_HOST_DONE_TEXT);
builder->Add(prefix + "EnrollmentErrorTitle",
IDS_PAIRING_ENROLLMENT_ERROR_TITLE);
IDS_SLAVE_ENROLLMENT_ERROR_TITLE);
builder->Add(prefix + "ErrorNeedsRestart",
IDS_PAIRING_HOST_ERROR_NEED_RESTART_TEXT);
builder->Add(prefix + "SetupBasicConfigTitle",
Expand All @@ -92,14 +86,6 @@ void HostPairingScreenHandler::DeclareLocalizedValues(
IDS_PAIRING_HOST_ERROR_NEED_RESTART_TEXT);
builder->Add(prefix + "ErrorNeedsRestart",
IDS_PAIRING_HOST_ERROR_NEED_RESTART_TEXT);

if (IsBootstrappingSlave()) {
builder->Add(prefix + "ConfirmationTitle", IDS_SLAVE_CONFIRMATION_TITLE);
builder->Add(prefix + "EnrollTitle", IDS_SLAVE_ENROLL_TITLE);
builder->Add(prefix + "EnrollingTitle", IDS_SLAVE_ENROLLMENT_IN_PROGRESS);
builder->Add(prefix + "EnrollmentErrorTitle",
IDS_SLAVE_ENROLLMENT_ERROR_TITLE);
}
}

void HostPairingScreenHandler::RegisterMessages() {
Expand Down
20 changes: 7 additions & 13 deletions chrome/browser/ui/webui/chromeos/login/network_screen_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,15 @@ void NetworkScreenHandler::GetAdditionalParameters(
// So we need to disable activation of login layouts if we are already in
// active user session.
//
// 3) This is the bootstrapping process for the remora/"Slave" device. The
// locale & input of the remora/"Slave" device is set up by a shark/"Master"
// device. In this case we don't want EnableLoginLayout() to reset the input
// method to the hardware default method.
const bool is_remora = g_browser_process->platform_part()
->browser_policy_connector_chromeos()
->GetDeviceCloudPolicyManager()
->IsRemoraRequisition();

const bool is_slave = base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kOobeBootstrappingSlave);
// 3) This is the bootstrapping process for a "Slave" device. The locale &
// input of the "Slave" device is set up by a "Master" device. In this case we
// don't want EnableLoginLayout() to reset the input method to the hardware
// default method.
const bool is_slave = g_browser_process->local_state()->GetBoolean(
prefs::kOobeControllerDetected);

const bool enable_layouts =
!user_manager::UserManager::Get()->IsUserLoggedIn() && !is_slave &&
!is_remora;
!user_manager::UserManager::Get()->IsUserLoggedIn() && !is_slave;

dict->Set("languageList", language_list.release());
dict->Set(
Expand Down
6 changes: 6 additions & 0 deletions chrome/common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,12 @@ const char kOobeComplete[] = "OobeComplete";
// The name of the screen that has to be shown if OOBE has been interrupted.
const char kOobeScreenPending[] = "OobeScreenPending";

// A boolean pref to indicate if an eligible controller (either a Chrome OS
// device, or an Android device) is detected during bootstrapping or
// shark/remora setup process. A controller can help the device go through OOBE
// and get enrolled into a domain automatically.
const char kOobeControllerDetected[] = "OobeControllerDetected";

// A boolean pref for whether the Goodies promotion webpage has been displayed,
// or otherwise disqualified for auto-display, on this device.
const char kCanShowOobeGoodiesPage[] = "CanShowOobeGoodiesPage";
Expand Down
1 change: 1 addition & 0 deletions chrome/common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ extern const char kCachedMultiProfileUserBehavior[];
extern const char kInitialLocale[];
extern const char kOobeComplete[];
extern const char kOobeScreenPending[];
extern const char kOobeControllerDetected[];
extern const char kCanShowOobeGoodiesPage[];
extern const char kDeviceRegistered[];
extern const char kEnrollmentRecoveryRequired[];
Expand Down
3 changes: 1 addition & 2 deletions chromeos/chromeos_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ const char kOobeTimerInterval[] = "oobe-timer-interval";
// Indicates that a guest session has been started before OOBE completion.
const char kOobeGuestSession[] = "oobe-guest-session";

// Indicates that if we should start bootstrapping Master/Slave OOBE.
// Indicates that if we should start bootstrapping Master OOBE.
const char kOobeBootstrappingMaster[] = "oobe-bootstrapping-master";
const char kOobeBootstrappingSlave[] = "oobe-bootstrapping-slave";

// Specifies power stub behavior:
// 'cycle=2' - Cycles power states every 2 seconds.
Expand Down
1 change: 0 additions & 1 deletion chromeos/chromeos_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ CHROMEOS_EXPORT extern const char kAggressiveTabDiscardThreshold[];
CHROMEOS_EXPORT extern const char kAggressiveThreshold[];
CHROMEOS_EXPORT extern const char kNaturalScrollDefault[];
CHROMEOS_EXPORT extern const char kOobeBootstrappingMaster[];
CHROMEOS_EXPORT extern const char kOobeBootstrappingSlave[];
CHROMEOS_EXPORT extern const char kOobeGuestSession[];
CHROMEOS_EXPORT extern const char kOobeSkipPostLogin[];
CHROMEOS_EXPORT extern const char kOobeTimerInterval[];
Expand Down
21 changes: 14 additions & 7 deletions components/pairing/bluetooth_host_pairing_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ BluetoothHostPairingController::BluetoothHostPairingController()

BluetoothHostPairingController::~BluetoothHostPairingController() {
Reset();
if (adapter_.get()) {
if (adapter_->IsDiscoverable()) {
adapter_->SetDiscoverable(false, base::Closure(), base::Closure());
}
adapter_->RemoveObserver(this);
adapter_ = NULL;
}
}

void BluetoothHostPairingController::ChangeStage(Stage new_stage) {
Expand Down Expand Up @@ -159,6 +152,19 @@ void BluetoothHostPairingController::Reset() {
service_socket_->Close();
service_socket_ = NULL;
}

if (adapter_.get()) {
if (adapter_->IsDiscoverable()) {
adapter_->SetDiscoverable(false, base::Bind(&base::DoNothing),
base::Bind(&base::DoNothing));
}
if (!was_powered_) {
adapter_->SetPowered(false, base::Bind(&base::DoNothing),
base::Bind(&base::DoNothing));
}
adapter_->RemoveObserver(this);
adapter_ = NULL;
}
ChangeStage(STAGE_NONE);
}

Expand Down Expand Up @@ -194,6 +200,7 @@ void BluetoothHostPairingController::SetName() {
void BluetoothHostPairingController::OnSetName() {
DCHECK(thread_checker_.CalledOnValidThread());
if (adapter_->IsPowered()) {
was_powered_ = true;
OnSetPowered();
} else {
adapter_->SetPowered(
Expand Down
1 change: 1 addition & 0 deletions components/pairing/bluetooth_host_pairing_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class BluetoothHostPairingController
UpdateStatus update_status_;
EnrollmentStatus enrollment_status_;
std::string permanent_id_;
bool was_powered_ = false;

scoped_refptr<device::BluetoothAdapter> adapter_;
scoped_refptr<device::BluetoothSocket> service_socket_;
Expand Down

0 comments on commit cfe5984

Please sign in to comment.