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/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 11 matching lines...) Expand all Loading... |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/threading/sequenced_worker_pool.h" | 23 #include "base/threading/sequenced_worker_pool.h" |
24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/chromeos/drive/drive.pb.h" | 25 #include "chrome/browser/chromeos/drive/drive.pb.h" |
26 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 26 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
27 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 27 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
28 #include "chrome/browser/chromeos/drive/job_list.h" | 28 #include "chrome/browser/chromeos/drive/job_list.h" |
29 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" | 29 #include "chrome/browser/chromeos/drive/write_on_cache_file.h" |
30 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 30 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
31 #include "chrome/browser/chromeos/profiles/profile_util.h" | 31 #include "chrome/browser/chromeos/profiles/profile_util.h" |
| 32 #include "chrome/browser/drive/drive_api_util.h" |
32 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/profiles/profile_manager.h" | 34 #include "chrome/browser/profiles/profile_manager.h" |
34 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
35 #include "chrome/common/chrome_paths_internal.h" | 36 #include "chrome/common/chrome_paths_internal.h" |
36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
37 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
38 #include "chromeos/chromeos_constants.h" | 39 #include "chromeos/chromeos_constants.h" |
39 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
40 #include "google_apis/drive/gdata_wapi_parser.h" | |
41 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
42 #include "webkit/browser/fileapi/file_system_url.h" | 42 #include "webkit/browser/fileapi/file_system_url.h" |
43 | 43 |
44 using content::BrowserThread; | 44 using content::BrowserThread; |
45 | 45 |
46 namespace drive { | 46 namespace drive { |
47 namespace util { | 47 namespace util { |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 const GURL& url, | 338 const GURL& url, |
339 const std::string& resource_id) { | 339 const std::string& resource_id) { |
340 std::string content = base::StringPrintf( | 340 std::string content = base::StringPrintf( |
341 "{\"url\": \"%s\", \"resource_id\": \"%s\"}", | 341 "{\"url\": \"%s\", \"resource_id\": \"%s\"}", |
342 url.spec().c_str(), resource_id.c_str()); | 342 url.spec().c_str(), resource_id.c_str()); |
343 return base::WriteFile(file_path, content.data(), content.size()) == | 343 return base::WriteFile(file_path, content.data(), content.size()) == |
344 static_cast<int>(content.size()); | 344 static_cast<int>(content.size()); |
345 } | 345 } |
346 | 346 |
347 bool HasGDocFileExtension(const base::FilePath& file_path) { | 347 bool HasGDocFileExtension(const base::FilePath& file_path) { |
348 return google_apis::ResourceEntry::ClassifyEntryKindByFileExtension( | 348 std::string extension = base::FilePath(file_path.Extension()).AsUTF8Unsafe(); |
349 file_path) & | 349 return IsHostedDocumentByExtension(extension); |
350 google_apis::ResourceEntry::KIND_OF_HOSTED_DOCUMENT; | |
351 } | 350 } |
352 | 351 |
353 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) { | 352 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) { |
354 return GURL(ReadStringFromGDocFile(file_path, "url")); | 353 return GURL(ReadStringFromGDocFile(file_path, "url")); |
355 } | 354 } |
356 | 355 |
357 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) { | 356 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) { |
358 return ReadStringFromGDocFile(file_path, "resource_id"); | 357 return ReadStringFromGDocFile(file_path, "resource_id"); |
359 } | 358 } |
360 | 359 |
(...skipping 28 matching lines...) Expand all Loading... |
389 const bool disable_sync_over_celluar = | 388 const bool disable_sync_over_celluar = |
390 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); | 389 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); |
391 | 390 |
392 if (is_connection_cellular && disable_sync_over_celluar) | 391 if (is_connection_cellular && disable_sync_over_celluar) |
393 return DRIVE_CONNECTED_METERED; | 392 return DRIVE_CONNECTED_METERED; |
394 return DRIVE_CONNECTED; | 393 return DRIVE_CONNECTED; |
395 } | 394 } |
396 | 395 |
397 } // namespace util | 396 } // namespace util |
398 } // namespace drive | 397 } // namespace drive |
OLD | NEW |