Chromium Code Reviews| 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/google_apis/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/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 int minute = 0; | 57 int minute = 0; |
| 58 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute)) | 58 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute)) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1); | 61 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1); |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 bool IsGDataAvailable(Profile* profile) { | 67 bool IsGDataAvailable(Profile* profile) { |
|
satorux1
2012/09/07 17:22:32
Seems to me that this is IsDriveAvailable() rather
nhiroki
2012/09/10 07:17:38
Renaming is not urgent. I will do in another CL.
| |
| 68 #if defined(OS_CHROMEOS) | |
| 68 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || | 69 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || |
| 69 chromeos::UserManager::Get()->IsLoggedInAsGuest() || | 70 chromeos::UserManager::Get()->IsLoggedInAsGuest() || |
| 70 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) | 71 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) |
| 71 return false; | 72 return false; |
| 72 | 73 |
| 73 // Do not allow GData for incognito windows / guest mode. | 74 // Do not allow GData for incognito windows / guest mode. |
| 74 if (profile->IsOffTheRecord()) | 75 if (profile->IsOffTheRecord()) |
| 75 return false; | 76 return false; |
| 76 | 77 |
| 77 // Disable gdata if preference is set. This can happen with commandline flag | 78 // Disable gdata if preference is set. This can happen with commandline flag |
| 78 // --disable-gdata or enterprise policy, or probably with user settings too | 79 // --disable-gdata or enterprise policy, or probably with user settings too |
| 79 // in the future. | 80 // in the future. |
| 80 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) | 81 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData)) |
| 81 return false; | 82 return false; |
| 82 | 83 |
| 83 return true; | 84 return true; |
| 85 #else | |
| 86 // TODO(nhiroki): Check if GData is available or not in a platform independent | |
| 87 // way. | |
|
satorux1
2012/09/07 17:22:32
Please file a bug and add a URL to it. s/GData/Dri
nhiroki
2012/09/10 07:17:38
Ditto.
| |
| 88 return false; | |
| 89 #endif | |
| 84 } | 90 } |
|
satorux1
2012/09/07 17:22:32
This patch is huge. I'd suggest to make changes li
nhiroki
2012/09/10 07:17:38
I made a separate patch to wrap with OS_CHROMEOS m
| |
| 85 | 91 |
| 86 bool IsDriveV2ApiEnabled() { | 92 bool IsDriveV2ApiEnabled() { |
| 87 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( | 93 static bool enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 88 switches::kEnableDriveV2Api); | 94 switches::kEnableDriveV2Api); |
| 89 return enabled; | 95 return enabled; |
| 90 } | 96 } |
| 91 | 97 |
| 92 base::PlatformFileError DriveFileErrorToPlatformError( | 98 base::PlatformFileError DriveFileErrorToPlatformError( |
| 93 gdata::DriveFileError error) { | 99 gdata::DriveFileError error) { |
| 94 switch (error) { | 100 switch (error) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 const base::Closure& reply_task) { | 291 const base::Closure& reply_task) { |
| 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 287 | 293 |
| 288 const bool posted = blocking_task_runner->PostTaskAndReply( | 294 const bool posted = blocking_task_runner->PostTaskAndReply( |
| 289 from_here, request_task, reply_task); | 295 from_here, request_task, reply_task); |
| 290 DCHECK(posted); | 296 DCHECK(posted); |
| 291 } | 297 } |
| 292 | 298 |
| 293 } // namespace util | 299 } // namespace util |
| 294 } // namespace gdata | 300 } // namespace gdata |
| OLD | NEW |