Skip to content

Commit

Permalink
Implement Pepper GetDeviceID for Windows
Browse files Browse the repository at this point in the history
The device ID is generated by mixing a salt which is specific to the users profile and with machine-specific information. This CL also connects the action of clearing the salt with the "Clear browsing data > Deauthrorize content licenses" action.

The ChromeOS implementation of GetDeviceID is unified with the Windows implementation and the old method of generating the IDs has been deprecated.

BUG=235193

Review URL: https://chromiumcodereview.appspot.com/12701002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196522 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
raymes@chromium.org committed Apr 25, 2013
1 parent 07e8d44 commit bb9c975
Show file tree
Hide file tree
Showing 20 changed files with 451 additions and 332 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/browsing_data/browsing_data_remover.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
new PepperFlashSettingsManager(this, profile_));
}
deauthorize_content_licenses_request_id_ =
pepper_flash_settings_manager_->DeauthorizeContentLicenses();
pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs);
}
#endif

Expand Down
14 changes: 0 additions & 14 deletions chrome/browser/chromeos/preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/system/drm_settings.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/browser/download/download_util.h"
Expand Down Expand Up @@ -273,12 +272,6 @@ void Preferences::RegisterUserPrefs(PrefRegistrySyncable* registry) {
"0.0.0.0",
PrefRegistrySyncable::SYNCABLE_PREF);

// TODO(wad): Once UI is connected, a final default can be set. At that point
// change this pref from UNSYNCABLE to SYNCABLE.
registry->RegisterBooleanPref(prefs::kEnableCrosDRM,
true,
PrefRegistrySyncable::UNSYNCABLE_PREF);

registry->RegisterBooleanPref(prefs::kExternalStorageDisabled,
false,
PrefRegistrySyncable::UNSYNCABLE_PREF);
Expand Down Expand Up @@ -426,8 +419,6 @@ void Preferences::InitUserPrefs(PrefServiceSyncable* prefs) {

enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback);

enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback);

power_ac_screen_dim_delay_ms_.Init(
prefs::kPowerAcScreenDimDelayMs, prefs, callback);
power_ac_screen_off_delay_ms_.Init(
Expand Down Expand Up @@ -750,11 +741,6 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
}
}

// Init or update protected content (DRM) support.
if (!pref_name || *pref_name == prefs::kEnableCrosDRM) {
system::ToggleDrm(enable_drm_.GetValue());
}

// Change the download directory to the default value if a Drive directory is
// selected and Drive is disabled.
if (!pref_name || *pref_name == prefs::kDisableDrive) {
Expand Down
132 changes: 0 additions & 132 deletions chrome/browser/chromeos/system/drm_settings.cc

This file was deleted.

17 changes: 0 additions & 17 deletions chrome/browser/chromeos/system/drm_settings.h

This file was deleted.

4 changes: 1 addition & 3 deletions chrome/browser/extensions/api/preference/preference_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ const char kConversionErrorMessage[] =
"properly.";

PrefMappingEntry kPrefMapping[] = {
#if defined(OS_CHROMEOS)
{ "protectedContentEnabled",
prefs::kEnableCrosDRM,
prefs::kEnableDRM,
APIPermission::kPrivacy
},
#endif // defined(OS_CHROMEOS)
{ "alternateErrorPagesEnabled",
prefs::kAlternateErrorPagesEnabled,
APIPermission::kPrivacy
Expand Down
49 changes: 48 additions & 1 deletion chrome/browser/pepper_flash_settings_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/prefs/pref_service.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/browser_context.h"
Expand Down Expand Up @@ -124,6 +126,10 @@ class PepperFlashSettingsManager::Core

void InitializeOnIOThread();
void DeauthorizeContentLicensesOnIOThread(uint32 request_id);
void DeauthorizeContentLicensesOnBlockingPool(
uint32 request_id,
const base::FilePath& profile_path);
void DeauthorizeContentLicensesInPlugin(uint32 request_id, bool success);
void GetPermissionSettingsOnIOThread(
uint32 request_id,
PP_Flash_BrowserOperations_SettingType setting_type);
Expand Down Expand Up @@ -436,6 +442,41 @@ void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread(
return;
}

#if defined(OS_CHROMEOS)
BrowserThread::PostBlockingPoolTask(FROM_HERE,
base::Bind(&Core::DeauthorizeContentLicensesOnBlockingPool, this,
request_id, browser_context_path_));
#else
DeauthorizeContentLicensesInPlugin(request_id, true);
#endif
}

// TODO(raymes): This is temporary code to migrate ChromeOS devices to the new
// scheme for generating device IDs. Delete this once we are sure most ChromeOS
// devices have been migrated.
void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnBlockingPool(
uint32 request_id,
const base::FilePath& profile_path) {
// ChromeOS used to store the device ID in a file but this is no longer used.
// Wipe that file.
const base::FilePath& device_id_path =
chrome::DeviceIDFetcher::GetLegacyDeviceIDPath(profile_path);
bool success = file_util::Delete(device_id_path, false);

BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&Core::DeauthorizeContentLicensesInPlugin, this, request_id,
success));
}

void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesInPlugin(
uint32 request_id,
bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (!success) {
NotifyErrorFromIOThread();
return;
}
IPC::Message* msg =
new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_);
if (!channel_->Send(msg)) {
Expand Down Expand Up @@ -939,9 +980,15 @@ void PepperFlashSettingsManager::RegisterUserPrefs(
PrefRegistrySyncable::UNSYNCABLE_PREF);
}

uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses() {
uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses(
PrefService* prefs) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

// Clear the device ID salt which has the effect of regenerating a device
// ID. Since this happens synchronously (and on the UI thread), we don't have
// to add it to a pending request.
prefs->ClearPref(prefs::kDRMSalt);

EnsureCoreExists();
uint32 id = GetNextRequestId();
core_->DeauthorizeContentLicenses(id);
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/pepper_flash_settings_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class PluginPrefs;
class PrefRegistrySyncable;
class PrefService;

namespace content {
class BrowserContext;
Expand Down Expand Up @@ -69,7 +70,7 @@ class PepperFlashSettingsManager {
// operation is completed.
// The return value is the same as the request ID passed into
// Client::OnDeauthorizeContentLicensesCompleted().
uint32 DeauthorizeContentLicenses();
uint32 DeauthorizeContentLicenses(PrefService* prefs);

// Gets permission settings.
// Client::OnGetPermissionSettingsCompleted() will be called when the
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/prefs/browser_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
Expand Down Expand Up @@ -337,6 +338,7 @@ void RegisterUserPrefs(PrefRegistrySyncable* registry) {
#if !defined(OS_ANDROID)
TabsCaptureVisibleTabFunction::RegisterUserPrefs(registry);
ChromeToMobileService::RegisterUserPrefs(registry);
DeviceIDFetcher::RegisterUserPrefs(registry);
DevToolsWindow::RegisterUserPrefs(registry);
extensions::CommandService::RegisterUserPrefs(registry);
ExtensionSettingsHandler::RegisterUserPrefs(registry);
Expand Down
Loading

0 comments on commit bb9c975

Please sign in to comment.