Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Remove hacks added to workaround a system salt issue for M31
Browse files Browse the repository at this point in the history
In crrev.com/228189, we had to add horrible hacks to workaround an urgent
P1 issue, which needed to be merged to M31 branch immediately.

The hacks are no longer necesssary, as the system salt is obtained
before DeviceOAuth2TokenService is created. See crbug.com/309959
for details.

BUG=306547
TEST=see the bug comment #9
[email protected]

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230969 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Oct 25, 2013
1 parent 5da0c63 commit 98b026a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 38 deletions.
20 changes: 3 additions & 17 deletions chrome/browser/chromeos/app_mode/startup_app_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/manifest_handlers/kiosk_mode_info.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
Expand Down Expand Up @@ -250,7 +249,7 @@ void StartupAppLauncher::BeginInstall() {
<< net::NetworkChangeNotifier::GetConnectionType();

if (IsAppInstalled(profile_, app_id_)) {
EnsureSystemSaltIsLoaded();
OnReadyToLaunch();
return;
}

Expand All @@ -271,7 +270,7 @@ void StartupAppLauncher::InstallCallback(bool success,
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&StartupAppLauncher::EnsureSystemSaltIsLoaded,
base::Bind(&StartupAppLauncher::OnReadyToLaunch,
AsWeakPtr()));
return;
}
Expand All @@ -280,20 +279,7 @@ void StartupAppLauncher::InstallCallback(bool success,
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
}

void StartupAppLauncher::EnsureSystemSaltIsLoaded() {
// Defer app launch until system salt is loaded to make sure that identity
// api works with the enterprise kiosk app.
SystemSaltGetter::Get()->GetSystemSalt(
base::Bind(&StartupAppLauncher::OnReadyToLaunch, AsWeakPtr()));
}

void StartupAppLauncher::OnReadyToLaunch(const std::string& system_salt) {
if (system_salt.empty()) {
LOG(ERROR) << "Could not load system salt.";
OnLaunchFailure(KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING);
return;
}

void StartupAppLauncher::OnReadyToLaunch() {
ready_to_launch_ = true;
FOR_EACH_OBSERVER(Observer, observer_list_, OnReadyToLaunch());
}
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/chromeos/app_mode/startup_app_launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ class StartupAppLauncher

void BeginInstall();
void InstallCallback(bool success, const std::string& error);
void EnsureSystemSaltIsLoaded();
void OnReadyToLaunch(const std::string& system_salt);
void OnReadyToLaunch();

void InitializeTokenService();
void InitializeNetwork();
Expand Down
19 changes: 0 additions & 19 deletions chrome/browser/chromeos/settings/device_oauth2_token_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
#include "chrome/common/pref_names.h"
#include "chromeos/cryptohome/system_salt_getter.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
Expand Down Expand Up @@ -237,20 +236,6 @@ void DeviceOAuth2TokenService::SetAndSaveRefreshToken(
const std::string& refresh_token) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));

// TODO(xiyuan): Use async GetSystemSalt after merging to M31.
const std::string system_salt = SystemSaltGetter::Get()->GetSystemSaltSync();
if (system_salt.empty()) {
const int64 kRequestSystemSaltDelayMs = 500;
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&DeviceOAuth2TokenService::SetAndSaveRefreshToken,
weak_ptr_factory_.GetWeakPtr(),
refresh_token),
base::TimeDelta::FromMilliseconds(kRequestSystemSaltDelayMs));
return;
}

std::string encrypted_refresh_token =
token_encryptor_->EncryptWithSystemSalt(refresh_token);

Expand All @@ -265,10 +250,6 @@ std::string DeviceOAuth2TokenService::GetRefreshToken(
std::string encrypted_refresh_token =
local_state_->GetString(prefs::kDeviceRobotAnyApiRefreshToken);

// TODO(xiyuan): This needs a proper fix after M31.
LOG_IF(ERROR, SystemSaltGetter::Get()->GetSystemSaltSync().empty())
<< "System salt is not available for decryption";

refresh_token_ = token_encryptor_->DecryptWithSystemSalt(
encrypted_refresh_token);
}
Expand Down

0 comments on commit 98b026a

Please sign in to comment.