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

Side by Side Diff: chrome/browser/chromeos/drive/file_system_util.cc

Issue 197013007: Set drive as the default download folder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes build errors Created 6 years, 9 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
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/drive/file_system_util.h" 5 #include "chrome/browser/chromeos/drive/file_system_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 (kDriveGrandRootDirName)); 120 (kDriveGrandRootDirName));
121 return grand_root_path; 121 return grand_root_path;
122 } 122 }
123 123
124 const base::FilePath& GetDriveMyDriveRootPath() { 124 const base::FilePath& GetDriveMyDriveRootPath() {
125 CR_DEFINE_STATIC_LOCAL(base::FilePath, drive_root_path, 125 CR_DEFINE_STATIC_LOCAL(base::FilePath, drive_root_path,
126 (kDriveMyDriveRootPath)); 126 (kDriveMyDriveRootPath));
127 return drive_root_path; 127 return drive_root_path;
128 } 128 }
129 129
130 base::FilePath GetDriveMountPointPathUsingUserHash(
131 const std::string user_id_hash) {
132 return base::FilePath(kSpecialMountPointRoot).AppendASCII(
133 net::EscapePath(kDriveMountPointNameBase +
134 (user_id_hash.empty() ? "" : "-" + user_id_hash)));
135 }
136
130 base::FilePath GetDriveMountPointPath(Profile* profile) { 137 base::FilePath GetDriveMountPointPath(Profile* profile) {
131 std::string id = chromeos::ProfileHelper::GetUserIdHashFromProfile(profile); 138 std::string id = chromeos::ProfileHelper::GetUserIdHashFromProfile(profile);
132 if (id.empty()) { 139 if (id.empty()) {
133 // ProfileHelper::GetUserIdHashFromProfile works only when multi-profile is 140 // ProfileHelper::GetUserIdHashFromProfile works only when multi-profile is
134 // enabled. In that case, we fall back to use UserManager (it basically just 141 // enabled. In that case, we fall back to use UserManager (it basically just
135 // returns currently active users's hash in such a case.) I still try 142 // returns currently active users's hash in such a case.) I still try
136 // ProfileHelper first because it works better in tests. 143 // ProfileHelper first because it works better in tests.
137 chromeos::User* const user = 144 chromeos::User* const user =
138 chromeos::UserManager::IsInitialized() ? 145 chromeos::UserManager::IsInitialized() ?
139 chromeos::UserManager::Get()->GetUserByProfile( 146 chromeos::UserManager::Get()->GetUserByProfile(
140 profile->GetOriginalProfile()) : NULL; 147 profile->GetOriginalProfile()) : NULL;
141 if (user) 148 if (user)
142 id = user->username_hash(); 149 id = user->username_hash();
143 } 150 }
144 return base::FilePath(kSpecialMountPointRoot).AppendASCII( 151 return GetDriveMountPointPathUsingUserHash(id);
145 net::EscapePath(kDriveMountPointNameBase + (id.empty() ? "" : "-" + id)));
146 } 152 }
147 153
148 FileSystemInterface* GetFileSystemByProfile(Profile* profile) { 154 FileSystemInterface* GetFileSystemByProfile(Profile* profile) {
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
150 156
151 DriveIntegrationService* integration_service = 157 DriveIntegrationService* integration_service =
152 GetIntegrationServiceByProfile(profile); 158 GetIntegrationServiceByProfile(profile);
153 return integration_service ? integration_service->file_system() : NULL; 159 return integration_service ? integration_service->file_system() : NULL;
154 } 160 }
155 161
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const bool disable_sync_over_celluar = 420 const bool disable_sync_over_celluar =
415 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); 421 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular);
416 422
417 if (is_connection_cellular && disable_sync_over_celluar) 423 if (is_connection_cellular && disable_sync_over_celluar)
418 return DRIVE_CONNECTED_METERED; 424 return DRIVE_CONNECTED_METERED;
419 return DRIVE_CONNECTED; 425 return DRIVE_CONNECTED;
420 } 426 }
421 427
422 } // namespace util 428 } // namespace util
423 } // namespace drive 429 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698