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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_private_api.cc

Issue 10271016: gdata: Remove use of FindEntryByPathAsync() from file_browser_private_api.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 7 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.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/chromeos/extensions/file_browser_private_api.h" 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/string_split.h" 14 #include "base/string_split.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/chromeos/extensions/file_handler_util.h" 18 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
19 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 19 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
20 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
20 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" 21 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
21 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" 22 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
22 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 23 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
23 #include "chrome/browser/chromeos/gdata/gdata_util.h" 24 #include "chrome/browser/chromeos/gdata/gdata_util.h"
24 #include "chrome/browser/extensions/extension_function_dispatcher.h" 25 #include "chrome/browser/extensions/extension_function_dispatcher.h"
25 #include "chrome/browser/extensions/extension_process_manager.h" 26 #include "chrome/browser/extensions/extension_process_manager.h"
26 #include "chrome/browser/extensions/extension_service.h" 27 #include "chrome/browser/extensions/extension_service.h"
27 #include "chrome/browser/extensions/extension_tab_util.h" 28 #include "chrome/browser/extensions/extension_tab_util.h"
28 #include "chrome/browser/extensions/process_map.h" 29 #include "chrome/browser/extensions/process_map.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 base::DictionaryValue* property_dict, 1578 base::DictionaryValue* property_dict,
1578 base::PlatformFileError error) { 1579 base::PlatformFileError error) {
1579 if (error != base::PLATFORM_FILE_OK) { 1580 if (error != base::PLATFORM_FILE_OK) {
1580 property_dict->SetInteger("errorCode", error); 1581 property_dict->SetInteger("errorCode", error);
1581 CompleteGetFileProperties(); 1582 CompleteGetFileProperties();
1582 return; 1583 return;
1583 } 1584 }
1584 1585
1585 gdata::GDataSystemService* system_service = 1586 gdata::GDataSystemService* system_service =
1586 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1587 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1587 system_service->file_system()->FindEntryByPathAsync( 1588 system_service->file_system()->GetFileInfoByPathAsync(
1588 path, 1589 path,
1589 base::Bind(&GetGDataFilePropertiesFunction::OnFileProperties, 1590 base::Bind(&GetGDataFilePropertiesFunction::OnGetFileInfo,
1590 this, 1591 this,
1591 property_dict, 1592 property_dict,
1592 path)); 1593 path));
1593 } 1594 }
1594 1595
1595 void GetGDataFilePropertiesFunction::OnFileProperties( 1596 void GetGDataFilePropertiesFunction::OnGetFileInfo(
1596 base::DictionaryValue* property_dict, 1597 base::DictionaryValue* property_dict,
1597 const FilePath& file_path, 1598 const FilePath& file_path,
1598 base::PlatformFileError error, 1599 base::PlatformFileError error,
1599 const FilePath& /* directory_path */, 1600 scoped_ptr<gdata::GDataFileProto> file_proto) {
1600 gdata::GDataEntry* entry) { 1601 DCHECK(property_dict);
1602
1601 if (error != base::PLATFORM_FILE_OK) { 1603 if (error != base::PLATFORM_FILE_OK) {
1602 property_dict->SetInteger("errorCode", error); 1604 property_dict->SetInteger("errorCode", error);
1603 CompleteGetFileProperties(); 1605 CompleteGetFileProperties();
1604 return; 1606 return;
1605 } 1607 }
1608 DCHECK(file_proto.get());
1606 1609
1607 gdata::GDataFile* file = entry->AsGDataFile(); 1610 property_dict->SetString("thumbnailUrl", file_proto->thumbnail_url());
1608 if (!file) { 1611 if (!file_proto->alternate_url().empty())
1609 LOG(WARNING) << "Reading properties of a non-file at " 1612 property_dict->SetString("editUrl", file_proto->alternate_url());
1610 << file_path.value(); 1613
1611 CompleteGetFileProperties(); 1614 if (!file_proto->gdata_entry().content_url().empty()) {
1612 return; 1615 property_dict->SetString("contentUrl",
1616 file_proto->gdata_entry().content_url());
1613 } 1617 }
1614 1618
1615 property_dict->SetString("thumbnailUrl", file->thumbnail_url().spec()); 1619 property_dict->SetBoolean("isHosted", file_proto->is_hosted_document());
1616 if (!file->alternate_url().is_empty())
1617 property_dict->SetString("editUrl", file->alternate_url().spec());
1618
1619 if (!file->content_url().is_empty())
1620 property_dict->SetString("contentUrl", file->content_url().spec());
1621
1622 property_dict->SetBoolean("isHosted", file->is_hosted_document());
1623 1620
1624 gdata::GDataSystemService* system_service = 1621 gdata::GDataSystemService* system_service =
1625 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1622 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1626 system_service->file_system()->GetCacheState( 1623 system_service->file_system()->GetCacheState(
1627 file->resource_id(), 1624 file_proto->gdata_entry().resource_id(),
1628 file->file_md5(), 1625 file_proto->file_md5(),
1629 base::Bind( 1626 base::Bind(
1630 &GetGDataFilePropertiesFunction::CacheStateReceived, 1627 &GetGDataFilePropertiesFunction::CacheStateReceived,
1631 this, property_dict)); 1628 this, property_dict));
1632 } 1629 }
1633 1630
1634 void GetGDataFilePropertiesFunction::CacheStateReceived( 1631 void GetGDataFilePropertiesFunction::CacheStateReceived(
1635 base::DictionaryValue* property_dict, 1632 base::DictionaryValue* property_dict,
1636 base::PlatformFileError error, 1633 base::PlatformFileError error,
1637 int cache_state) { 1634 int cache_state) {
1638 property_dict->SetBoolean( 1635 property_dict->SetBoolean(
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 if (value->GetBoolean("cellularDisabled", &tmp)) { 2003 if (value->GetBoolean("cellularDisabled", &tmp)) {
2007 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); 2004 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp);
2008 } 2005 }
2009 2006
2010 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { 2007 if (value->GetBoolean("hostedFilesDisabled", &tmp)) {
2011 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); 2008 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp);
2012 } 2009 }
2013 2010
2014 return true; 2011 return true;
2015 } 2012 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698