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

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: Version 1 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(std::string username_hash) {
131 return base::FilePath(kSpecialMountPointRoot).AppendASCII(
132 net::EscapePath(kDriveMountPointNameBase +
133 (username_hash.empty() ? "" : "-" + username_hash)));
134 }
135
130 base::FilePath GetDriveMountPointPath(Profile* profile) { 136 base::FilePath GetDriveMountPointPath(Profile* profile) {
131 std::string id = chromeos::ProfileHelper::GetUserIdHashFromProfile(profile); 137 std::string id = chromeos::ProfileHelper::GetUserIdHashFromProfile(profile);
132 if (id.empty()) { 138 if (id.empty()) {
133 // ProfileHelper::GetUserIdHashFromProfile works only when multi-profile is 139 // ProfileHelper::GetUserIdHashFromProfile works only when multi-profile is
134 // enabled. In that case, we fall back to use UserManager (it basically just 140 // 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 141 // returns currently active users's hash in such a case.) I still try
136 // ProfileHelper first because it works better in tests. 142 // ProfileHelper first because it works better in tests.
137 chromeos::User* const user = 143 chromeos::User* const user =
138 chromeos::UserManager::IsInitialized() ? 144 chromeos::UserManager::IsInitialized() ?
139 chromeos::UserManager::Get()->GetUserByProfile( 145 chromeos::UserManager::Get()->GetUserByProfile(
140 profile->GetOriginalProfile()) : NULL; 146 profile->GetOriginalProfile()) : NULL;
141 if (user) 147 if (user)
142 id = user->username_hash(); 148 id = user->username_hash();
143 } 149 }
144 return base::FilePath(kSpecialMountPointRoot).AppendASCII( 150 return GetDriveMountPointPathUsingUserHash(id);
145 net::EscapePath(kDriveMountPointNameBase + (id.empty() ? "" : "-" + id)));
146 } 151 }
147 152
148 FileSystemInterface* GetFileSystemByProfile(Profile* profile) { 153 FileSystemInterface* GetFileSystemByProfile(Profile* profile) {
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
150 155
151 DriveIntegrationService* integration_service = 156 DriveIntegrationService* integration_service =
152 GetIntegrationServiceByProfile(profile); 157 GetIntegrationServiceByProfile(profile);
153 return integration_service ? integration_service->file_system() : NULL; 158 return integration_service ? integration_service->file_system() : NULL;
154 } 159 }
155 160
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const bool disable_sync_over_celluar = 419 const bool disable_sync_over_celluar =
415 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); 420 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular);
416 421
417 if (is_connection_cellular && disable_sync_over_celluar) 422 if (is_connection_cellular && disable_sync_over_celluar)
418 return DRIVE_CONNECTED_METERED; 423 return DRIVE_CONNECTED_METERED;
419 return DRIVE_CONNECTED; 424 return DRIVE_CONNECTED;
420 } 425 }
421 426
422 } // namespace util 427 } // namespace util
423 } // namespace drive 428 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698