| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/tracked_objects.h" | 17 #include "base/tracked_objects.h" |
| 18 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 19 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 23 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 24 | 23 |
| 24 #if defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/chromeos/login/user_manager.h" |
| 26 #endif // OS_CHROMEOS |
| 27 |
| 25 using content::BrowserThread; | 28 using content::BrowserThread; |
| 26 | 29 |
| 27 namespace gdata { | 30 namespace gdata { |
| 28 namespace util { | 31 namespace util { |
| 29 | 32 |
| 30 namespace { | 33 namespace { |
| 31 | 34 |
| 32 const char kGDataSpecialRootPath[] = "/special"; | 35 const char kGDataSpecialRootPath[] = "/special"; |
| 33 | 36 |
| 34 const char kGDataMountPointPath[] = "/special/drive"; | 37 const char kGDataMountPointPath[] = "/special/drive"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute)) | 57 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute)) |
| 55 return false; | 58 return false; |
| 56 | 59 |
| 57 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1); | 60 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1); |
| 58 return true; | 61 return true; |
| 59 } | 62 } |
| 60 | 63 |
| 61 } // namespace | 64 } // namespace |
| 62 | 65 |
| 63 bool IsGDataAvailable(Profile* profile) { | 66 bool IsGDataAvailable(Profile* profile) { |
| 67 #if defined(OS_CHROMEOS) |
| 64 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || | 68 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || |
| 65 chromeos::UserManager::Get()->IsLoggedInAsGuest() || | 69 chromeos::UserManager::Get()->IsLoggedInAsGuest() || |
| 66 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) | 70 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) |
| 67 return false; | 71 return false; |
| 68 | 72 |
| 69 // Do not allow GData for incognito windows / guest mode. | 73 // Do not allow GData for incognito windows / guest mode. |
| 70 if (profile->IsOffTheRecord()) | 74 if (profile->IsOffTheRecord()) |
| 71 return false; | 75 return false; |
| 72 | 76 |
| 73 // Disable gdata if preference is set. This can happen with commandline flag | 77 // Disable gdata if preference is set. This can happen with commandline flag |
| 74 // --disable-gdata or enterprise policy, or probably with user settings too | 78 // --disable-gdata or enterprise policy, or probably with user settings too |
| 75 // in the future. | 79 // in the future. |
| 76 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 80 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
| 77 return false; | 81 return false; |
| 78 | 82 |
| 79 return true; | 83 return true; |
| 84 #else |
| 85 // TODO(nhiroki): Check if GData is available or not in a platform |
| 86 // independent way (http://crbug.com/147529). |
| 87 return false; |
| 88 #endif // OS_CHROMEOS |
| 80 } | 89 } |
| 81 | 90 |
| 82 bool IsDriveV2ApiEnabled() { | 91 bool IsDriveV2ApiEnabled() { |
| 83 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 92 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 84 switches::kEnableDriveV2Api); | 93 switches::kEnableDriveV2Api); |
| 85 return enabled; | 94 return enabled; |
| 86 } | 95 } |
| 87 | 96 |
| 88 base::PlatformFileError DriveFileErrorToPlatformError( | 97 base::PlatformFileError DriveFileErrorToPlatformError( |
| 89 gdata::DriveFileError error) { | 98 gdata::DriveFileError error) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 const base::Closure& reply_task) { | 290 const base::Closure& reply_task) { |
| 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 283 | 292 |
| 284 const bool posted = blocking_task_runner->PostTaskAndReply( | 293 const bool posted = blocking_task_runner->PostTaskAndReply( |
| 285 from_here, request_task, reply_task); | 294 from_here, request_task, reply_task); |
| 286 DCHECK(posted); | 295 DCHECK(posted); |
| 287 } | 296 } |
| 288 | 297 |
| 289 } // namespace util | 298 } // namespace util |
| 290 } // namespace gdata | 299 } // namespace gdata |
| OLD | NEW |