| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/system/drm_settings.h" | 5 #include "chrome/browser/chromeos/system/drm_settings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 16 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 16 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 17 #include "chrome/browser/chromeos/login/user_manager.h" | 17 #include "chrome/browser/chromeos/login/user_manager.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chromeos/chromeos_switches.h" | |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "crypto/encryptor.h" | 21 #include "crypto/encryptor.h" |
| 23 #include "crypto/sha2.h" | 22 #include "crypto/sha2.h" |
| 24 | 23 |
| 25 using content::BrowserThread; | 24 using content::BrowserThread; |
| 26 | 25 |
| 27 namespace { | 26 namespace { |
| 28 | 27 |
| 29 // This constant is mirrored in | 28 // This constant is mirrored in |
| 30 // content/browser/renderer_host/pepper_message_filter.cc | 29 // content/browser/renderer_host/pepper_message_filter.cc |
| 31 // for OnGetDeviceID. | 30 // for OnGetDeviceID. |
| 32 // | 31 // |
| 33 // This ID file is solely for use via the private pepper API. | 32 // This ID file is solely for use via the private pepper API. |
| 34 // | 33 // |
| 35 // NOTE! Changing this value will also change the generated value | 34 // NOTE! Changing this value will also change the generated value |
| 36 // do not do so without accounting for the change. | 35 // do not do so without accounting for the change. |
| 37 const char kDRMIdentifierFile[] = "Pepper DRM ID.0"; | 36 const char kDRMIdentifierFile[] = "Pepper DRM ID.0"; |
| 38 | 37 |
| 39 void ManageDrmIdentifierOnFileThread(bool enable, const std::string& email) { | 38 void ManageDrmIdentifierOnFileThread(bool enable, const std::string& email) { |
| 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 41 | 40 |
| 42 // Drop the file under <data>/<profile>/<drm id file>. | 41 // Drop the file under <data>/<profile>/<drm id file>. |
| 43 // TODO(wad) get the profile directory in a more succinct fashion. | 42 // TODO(wad) get the profile directory in a more succinct fashion. |
| 44 base::FilePath drm_id_file; | 43 base::FilePath drm_id_file; |
| 45 PathService::Get(chrome::DIR_USER_DATA, &drm_id_file); | 44 PathService::Get(chrome::DIR_USER_DATA, &drm_id_file); |
| 46 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 45 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 47 base::FilePath profile = cmd_line.GetSwitchValuePath( | 46 base::FilePath profile = cmd_line.GetSwitchValuePath(switches::kLoginProfile); |
| 48 chromeos::switches::kLoginProfile); | |
| 49 if (profile.empty()) { | 47 if (profile.empty()) { |
| 50 LOG(ERROR) << "called with no login-profile!"; | 48 LOG(ERROR) << "called with no login-profile!"; |
| 51 return; | 49 return; |
| 52 } | 50 } |
| 53 drm_id_file = drm_id_file.AppendASCII(profile.value()); | 51 drm_id_file = drm_id_file.AppendASCII(profile.value()); |
| 54 drm_id_file = drm_id_file.AppendASCII(kDRMIdentifierFile); | 52 drm_id_file = drm_id_file.AppendASCII(kDRMIdentifierFile); |
| 55 | 53 |
| 56 // The file will be regenerated or deleted at toggle-time. | 54 // The file will be regenerated or deleted at toggle-time. |
| 57 file_util::Delete(drm_id_file, false); | 55 file_util::Delete(drm_id_file, false); |
| 58 | 56 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // by privileged pepper plugins specifically for deriving | 123 // by privileged pepper plugins specifically for deriving |
| 126 // per-content-provider identifiers. The user must be able to clear it, | 124 // per-content-provider identifiers. The user must be able to clear it, |
| 127 // reset it, and deny its use. | 125 // reset it, and deny its use. |
| 128 BrowserThread::PostTask( | 126 BrowserThread::PostTask( |
| 129 BrowserThread::FILE, FROM_HERE, | 127 BrowserThread::FILE, FROM_HERE, |
| 130 base::Bind(&ManageDrmIdentifierOnFileThread, enable, email)); | 128 base::Bind(&ManageDrmIdentifierOnFileThread, enable, email)); |
| 131 } | 129 } |
| 132 | 130 |
| 133 } // namespace system | 131 } // namespace system |
| 134 } // namespace chromeos | 132 } // namespace chromeos |
| OLD | NEW |