Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1474)

Side by Side Diff: chrome/browser/google_apis/gdata_util.cc

Issue 10920091: Move Drive API files to google_apis directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "base/tracked_objects.h" 21 #include "base/tracked_objects.h"
22 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
yoshiki 2012/09/10 05:43:43 Don't include files under chrome/browser/chromeos/
nhiroki 2012/09/10 07:17:39 Done in the separate patch (http://codereview.chro
23 #include "chrome/browser/prefs/pref_service.h" 23 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 30
31 namespace gdata { 31 namespace gdata {
32 namespace util { 32 namespace util {
(...skipping 25 matching lines...) Expand all
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) {
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.
88 return false;
89 #endif
84 } 90 }
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) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698