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

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

Issue 416223003: Unify HasGDocFileExtension and IsHostedDocumentByExtentoin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/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
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"
33 #include "chrome/browser/profiles/profile.h" 32 #include "chrome/browser/profiles/profile.h"
34 #include "chrome/browser/profiles/profile_manager.h" 33 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/common/chrome_constants.h" 34 #include "chrome/common/chrome_constants.h"
36 #include "chrome/common/chrome_paths_internal.h" 35 #include "chrome/common/chrome_paths_internal.h"
37 #include "chrome/common/pref_names.h" 36 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
39 #include "chromeos/chromeos_constants.h" 38 #include "chromeos/chromeos_constants.h"
40 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
41 #include "net/base/escape.h" 40 #include "net/base/escape.h"
42 #include "webkit/browser/fileapi/file_system_url.h" 41 #include "webkit/browser/fileapi/file_system_url.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 bool CreateGDocFile(const base::FilePath& file_path, 336 bool CreateGDocFile(const base::FilePath& file_path,
338 const GURL& url, 337 const GURL& url,
339 const std::string& resource_id) { 338 const std::string& resource_id) {
340 std::string content = base::StringPrintf( 339 std::string content = base::StringPrintf(
341 "{\"url\": \"%s\", \"resource_id\": \"%s\"}", 340 "{\"url\": \"%s\", \"resource_id\": \"%s\"}",
342 url.spec().c_str(), resource_id.c_str()); 341 url.spec().c_str(), resource_id.c_str());
343 return base::WriteFile(file_path, content.data(), content.size()) == 342 return base::WriteFile(file_path, content.data(), content.size()) ==
344 static_cast<int>(content.size()); 343 static_cast<int>(content.size());
345 } 344 }
346 345
347 bool HasGDocFileExtension(const base::FilePath& file_path) {
348 std::string extension = base::FilePath(file_path.Extension()).AsUTF8Unsafe();
349 return IsHostedDocumentByExtension(extension);
350 }
351
352 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) { 346 GURL ReadUrlFromGDocFile(const base::FilePath& file_path) {
353 return GURL(ReadStringFromGDocFile(file_path, "url")); 347 return GURL(ReadStringFromGDocFile(file_path, "url"));
354 } 348 }
355 349
356 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) { 350 std::string ReadResourceIdFromGDocFile(const base::FilePath& file_path) {
357 return ReadStringFromGDocFile(file_path, "resource_id"); 351 return ReadStringFromGDocFile(file_path, "resource_id");
358 } 352 }
359 353
360 bool IsDriveEnabledForProfile(Profile* profile) { 354 bool IsDriveEnabledForProfile(Profile* profile) {
361 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 26 matching lines...) Expand all
388 const bool disable_sync_over_celluar = 382 const bool disable_sync_over_celluar =
389 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular); 383 profile->GetPrefs()->GetBoolean(prefs::kDisableDriveOverCellular);
390 384
391 if (is_connection_cellular && disable_sync_over_celluar) 385 if (is_connection_cellular && disable_sync_over_celluar)
392 return DRIVE_CONNECTED_METERED; 386 return DRIVE_CONNECTED_METERED;
393 return DRIVE_CONNECTED; 387 return DRIVE_CONNECTED;
394 } 388 }
395 389
396 } // namespace util 390 } // namespace util
397 } // namespace drive 391 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_util.h ('k') | chrome/browser/chromeos/drive/file_system_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698