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

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

Issue 11094061: drive: Move IsDriveEnabled() and DisableDrive() to DriveSystemService (Closed) Base URL: http://git.chromium.org/chromium/src.git@drive_available
Patch Set: address comments Created 8 years, 2 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
« no previous file with comments | « chrome/browser/google_apis/gdata_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/google_apis/gdata_util.h" 5 #include "chrome/browser/google_apis/gdata_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return false; 53 return false;
54 54
55 int minute = 0; 55 int minute = 0;
56 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute)) 56 if (num_of_token > 1 && !base::StringToInt(parts[1], &minute))
57 return false; 57 return false;
58 58
59 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1); 59 *out_offset_to_utc_in_minutes = (hour * 60 + minute) * (ahead ? +1 : -1);
60 return true; 60 return true;
61 } 61 }
62 62
63 // Map to collect profiles with Drive disabled.
64 std::map<Profile*, bool>* g_drive_disabled_map = NULL;
65
66 } // namespace 63 } // namespace
67 64
68 bool IsDriveEnabled(Profile* profile) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
70
71 if (!AuthService::CanAuthenticate(profile))
72 return false;
73
74 #if defined(OS_CHROMEOS)
75 // Disable gdata if preference is set. This can happen with commandline flag
76 // --disable-gdata or enterprise policy, or probably with user settings too
77 // in the future.
78 if (profile->GetPrefs()->GetBoolean(prefs::kDisableGData))
79 return false;
80
81 if (g_drive_disabled_map && g_drive_disabled_map->count(profile) > 0)
82 return false;
83
84 return true;
85 #else
86 // TODO(nhiroki): Check if GData is available or not in a platform
87 // independent way (http://crbug.com/147529).
88 return false;
89 #endif // OS_CHROMEOS
90 }
91
92 void DisableDrive(Profile* profile) {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
94
95 // We don't change kDisableGData preference here. If we do, we'll end up
96 // disabling Drive on other devices, as kDisableGData is a syncable
97 // preference. Hence the map is used here.
98 if (!g_drive_disabled_map)
99 g_drive_disabled_map = new std::map<Profile*, bool>;
100
101 g_drive_disabled_map->insert(std::make_pair(profile, true));
102 }
103
104 bool IsDriveV2ApiEnabled() { 65 bool IsDriveV2ApiEnabled() {
105 // TODO(kochi): Re-enable this. crbug.com/152230 66 // TODO(kochi): Re-enable this. crbug.com/152230
106 return false; 67 return false;
107 } 68 }
108 69
109 base::PlatformFileError DriveFileErrorToPlatformError( 70 base::PlatformFileError DriveFileErrorToPlatformError(
110 gdata::DriveFileError error) { 71 gdata::DriveFileError error) {
111 switch (error) { 72 switch (error) {
112 case gdata::DRIVE_FILE_OK: 73 case gdata::DRIVE_FILE_OK:
113 return base::PLATFORM_FILE_OK; 74 return base::PLATFORM_FILE_OK;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 const base::Closure& reply_task) { 263 const base::Closure& reply_task) {
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
304 265
305 const bool posted = blocking_task_runner->PostTaskAndReply( 266 const bool posted = blocking_task_runner->PostTaskAndReply(
306 from_here, request_task, reply_task); 267 from_here, request_task, reply_task);
307 DCHECK(posted); 268 DCHECK(posted);
308 } 269 }
309 270
310 } // namespace util 271 } // namespace util
311 } // namespace gdata 272 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698