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/gdata/gdata_util.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/json/json_reader.h" | 16 #include "base/json/json_reader.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
22 #include "chrome/common/libxml_utils.h" | 22 #include "chrome/common/libxml_utils.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
25 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 27 #include "chrome/browser/chromeos/login/user.h" |
| 28 #include "chrome/browser/chromeos/login/user_manager.h" |
27 #include "chrome/browser/prefs/pref_service.h" | 29 #include "chrome/browser/prefs/pref_service.h" |
28 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
31 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/child_process_security_policy.h" | 34 #include "content/public/browser/child_process_security_policy.h" |
33 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
34 | 36 |
35 namespace gdata { | 37 namespace gdata { |
36 namespace util { | 38 namespace util { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 kReadOnlyFilePermissions)); | 231 kReadOnlyFilePermissions)); |
230 cache_paths->push_back(std::make_pair( | 232 cache_paths->push_back(std::make_pair( |
231 file_system->GetCacheFilePath(resource_id, file_md5, | 233 file_system->GetCacheFilePath(resource_id, file_md5, |
232 GDataRootDirectory::CACHE_TYPE_TMP, | 234 GDataRootDirectory::CACHE_TYPE_TMP, |
233 GDataFileSystem::CACHED_FILE_FROM_SERVER), | 235 GDataFileSystem::CACHED_FILE_FROM_SERVER), |
234 kReadOnlyFilePermissions)); | 236 kReadOnlyFilePermissions)); |
235 | 237 |
236 } | 238 } |
237 | 239 |
238 bool IsGDataAvailable(Profile* profile) { | 240 bool IsGDataAvailable(Profile* profile) { |
| 241 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || |
| 242 chromeos::UserManager::Get()->IsLoggedInAsGuest() || |
| 243 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) |
| 244 return false; |
| 245 |
239 // Do not allow GData for incognito windows / guest mode. | 246 // Do not allow GData for incognito windows / guest mode. |
240 if (profile->IsOffTheRecord()) | 247 if (profile->IsOffTheRecord()) |
241 return false; | 248 return false; |
242 | 249 |
243 // Disable gdata if preference is set. This can happen with commandline flag | 250 // Disable gdata if preference is set. This can happen with commandline flag |
244 // --disable-gdata or enterprise policy, or probably with user settings too | 251 // --disable-gdata or enterprise policy, or probably with user settings too |
245 // in the future. | 252 // in the future. |
246 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 253 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
247 return false; | 254 return false; |
248 | 255 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // Assign the extracted extensions to md5 and extra_extension. | 314 // Assign the extracted extensions to md5 and extra_extension. |
308 int extension_count = extensions.size(); | 315 int extension_count = extensions.size(); |
309 *md5 = (extension_count > 0) ? extensions[extension_count - 1] : | 316 *md5 = (extension_count > 0) ? extensions[extension_count - 1] : |
310 std::string(); | 317 std::string(); |
311 *extra_extension = (extension_count > 1) ? extensions[extension_count - 2] : | 318 *extra_extension = (extension_count > 1) ? extensions[extension_count - 2] : |
312 std::string(); | 319 std::string(); |
313 } | 320 } |
314 | 321 |
315 } // namespace util | 322 } // namespace util |
316 } // namespace gdata | 323 } // namespace gdata |
OLD | NEW |