OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/policy/device_token_fetcher.h" | 5 #include "chrome/browser/policy/device_token_fetcher.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "chrome/browser/guid.h" | 10 #include "chrome/browser/guid.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 device_id_)); | 71 device_id_)); |
72 SetState(kStateHasDeviceToken); | 72 SetState(kStateHasDeviceToken); |
73 } else { | 73 } else { |
74 NOTREACHED(); | 74 NOTREACHED(); |
75 SetState(kStateFailure); | 75 SetState(kStateFailure); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) { | 79 void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) { |
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 81 // For privacy reasons, delete all identifying data when this device is not |
| 82 // managed. |
| 83 if (code == DeviceManagementBackend::kErrorServiceManagementNotSupported) { |
| 84 device_token_ = std::string(); |
| 85 device_id_ = std::string(); |
| 86 file_util::Delete(token_path_, false); |
| 87 } |
81 SetState(kStateFailure); | 88 SetState(kStateFailure); |
82 } | 89 } |
83 | 90 |
84 void DeviceTokenFetcher::StartFetching() { | 91 void DeviceTokenFetcher::StartFetching() { |
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
86 if (state_ == kStateNotStarted) { | 93 if (state_ == kStateNotStarted) { |
87 SetState(kStateLoadDeviceTokenFromDisk); | 94 SetState(kStateLoadDeviceTokenFromDisk); |
88 // The file calls for loading the persisted token must be deferred to the | 95 // The file calls for loading the persisted token must be deferred to the |
89 // FILE thread. | 96 // FILE thread. |
90 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 std::string data; | 206 std::string data; |
200 DCHECK(device_credentials.SerializeToString(&data)); | 207 DCHECK(device_credentials.SerializeToString(&data)); |
201 file_util::WriteFile(path, data.c_str(), data.length()); | 208 file_util::WriteFile(path, data.c_str(), data.length()); |
202 } | 209 } |
203 | 210 |
204 // static | 211 // static |
205 std::string DeviceTokenFetcher::GenerateNewDeviceID() { | 212 std::string DeviceTokenFetcher::GenerateNewDeviceID() { |
206 return guid::GenerateGUID(); | 213 return guid::GenerateGUID(); |
207 } | 214 } |
208 | 215 |
209 } | 216 } // namespace policy |
OLD | NEW |