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

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

Issue 10836354: Rename GData* to Drive* in gdata.proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for comments. Created 8 years, 4 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/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/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.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/cros/cros_library.h" 18 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/network_library.h" 19 #include "chrome/browser/chromeos/cros/network_library.h"
20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" 20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h"
21 #include "chrome/browser/chromeos/extensions/file_handler_util.h" 21 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
22 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 22 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
23 #include "chrome/browser/chromeos/gdata/drive.pb.h"
23 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" 24 #include "chrome/browser/chromeos/gdata/drive_service_interface.h"
24 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 25 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
25 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
27 #include "chrome/browser/chromeos/gdata/gdata_util.h" 27 #include "chrome/browser/chromeos/gdata/gdata_util.h"
28 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" 28 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
29 #include "chrome/browser/chromeos/gdata/operation_registry.h" 29 #include "chrome/browser/chromeos/gdata/operation_registry.h"
30 #include "chrome/browser/chromeos/system/statistics_provider.h" 30 #include "chrome/browser/chromeos/system/statistics_provider.h"
31 #include "chrome/browser/extensions/extension_function_dispatcher.h" 31 #include "chrome/browser/extensions/extension_function_dispatcher.h"
32 #include "chrome/browser/extensions/extension_process_manager.h" 32 #include "chrome/browser/extensions/extension_process_manager.h"
33 #include "chrome/browser/extensions/extension_service.h" 33 #include "chrome/browser/extensions/extension_service.h"
34 #include "chrome/browser/extensions/extension_tab_util.h" 34 #include "chrome/browser/extensions/extension_tab_util.h"
35 #include "chrome/browser/extensions/process_map.h" 35 #include "chrome/browser/extensions/process_map.h"
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 1739
1740 GetGDataFilePropertiesFunction::GetGDataFilePropertiesFunction() { 1740 GetGDataFilePropertiesFunction::GetGDataFilePropertiesFunction() {
1741 } 1741 }
1742 1742
1743 GetGDataFilePropertiesFunction::~GetGDataFilePropertiesFunction() { 1743 GetGDataFilePropertiesFunction::~GetGDataFilePropertiesFunction() {
1744 } 1744 }
1745 1745
1746 void GetGDataFilePropertiesFunction::DoOperation( 1746 void GetGDataFilePropertiesFunction::DoOperation(
1747 const FilePath& file_path, 1747 const FilePath& file_path,
1748 base::DictionaryValue* property_dict, 1748 base::DictionaryValue* property_dict,
1749 scoped_ptr<gdata::GDataEntryProto> entry_proto) { 1749 scoped_ptr<gdata::DriveEntryProto> entry_proto) {
1750 DCHECK(property_dict); 1750 DCHECK(property_dict);
1751 1751
1752 // Nothing to do here so simply call OnOperationComplete(). 1752 // Nothing to do here so simply call OnOperationComplete().
1753 OnOperationComplete(file_path, 1753 OnOperationComplete(file_path,
1754 property_dict, 1754 property_dict,
1755 gdata::GDATA_FILE_OK, 1755 gdata::GDATA_FILE_OK,
1756 entry_proto.Pass()); 1756 entry_proto.Pass());
1757 } 1757 }
1758 1758
1759 bool GetGDataFilePropertiesFunction::RunImpl() { 1759 bool GetGDataFilePropertiesFunction::RunImpl() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 1808
1809 // Could be called from callback. Let finish operation. 1809 // Could be called from callback. Let finish operation.
1810 MessageLoop::current()->PostTask(FROM_HERE, 1810 MessageLoop::current()->PostTask(FROM_HERE,
1811 Bind(&GetGDataFilePropertiesFunction::GetNextFileProperties, this)); 1811 Bind(&GetGDataFilePropertiesFunction::GetNextFileProperties, this));
1812 } 1812 }
1813 1813
1814 void GetGDataFilePropertiesFunction::OnGetFileInfo( 1814 void GetGDataFilePropertiesFunction::OnGetFileInfo(
1815 const FilePath& file_path, 1815 const FilePath& file_path,
1816 base::DictionaryValue* property_dict, 1816 base::DictionaryValue* property_dict,
1817 gdata::GDataFileError error, 1817 gdata::GDataFileError error,
1818 scoped_ptr<gdata::GDataEntryProto> entry_proto) { 1818 scoped_ptr<gdata::DriveEntryProto> entry_proto) {
1819 DCHECK(property_dict); 1819 DCHECK(property_dict);
1820 1820
1821 if (entry_proto.get() && !entry_proto->has_file_specific_info()) 1821 if (entry_proto.get() && !entry_proto->has_file_specific_info())
1822 error = gdata::GDATA_FILE_ERROR_NOT_FOUND; 1822 error = gdata::GDATA_FILE_ERROR_NOT_FOUND;
1823 1823
1824 if (error == gdata::GDATA_FILE_OK) 1824 if (error == gdata::GDATA_FILE_OK)
1825 DoOperation(file_path, property_dict, entry_proto.Pass()); 1825 DoOperation(file_path, property_dict, entry_proto.Pass());
1826 else 1826 else
1827 OnOperationComplete(file_path, property_dict, error, entry_proto.Pass()); 1827 OnOperationComplete(file_path, property_dict, error, entry_proto.Pass());
1828 } 1828 }
1829 1829
1830 void GetGDataFilePropertiesFunction::OnOperationComplete( 1830 void GetGDataFilePropertiesFunction::OnOperationComplete(
1831 const FilePath& file_path, 1831 const FilePath& file_path,
1832 base::DictionaryValue* property_dict, 1832 base::DictionaryValue* property_dict,
1833 gdata::GDataFileError error, 1833 gdata::GDataFileError error,
1834 scoped_ptr<gdata::GDataEntryProto> entry_proto) { 1834 scoped_ptr<gdata::DriveEntryProto> entry_proto) {
1835 if (entry_proto.get() && !entry_proto->has_file_specific_info()) 1835 if (entry_proto.get() && !entry_proto->has_file_specific_info())
1836 error = gdata::GDATA_FILE_ERROR_NOT_FOUND; 1836 error = gdata::GDATA_FILE_ERROR_NOT_FOUND;
1837 1837
1838 if (error != gdata::GDATA_FILE_OK) { 1838 if (error != gdata::GDATA_FILE_OK) {
1839 property_dict->SetInteger("errorCode", error); 1839 property_dict->SetInteger("errorCode", error);
1840 CompleteGetFileProperties(); 1840 CompleteGetFileProperties();
1841 return; 1841 return;
1842 } 1842 }
1843 DCHECK(entry_proto.get()); 1843 DCHECK(entry_proto.get());
1844 1844
1845 const gdata::GDataFileSpecificInfo& file_specific_info = 1845 const gdata::DriveFileSpecificInfo& file_specific_info =
1846 entry_proto->file_specific_info(); 1846 entry_proto->file_specific_info();
1847 property_dict->SetString("thumbnailUrl", file_specific_info.thumbnail_url()); 1847 property_dict->SetString("thumbnailUrl", file_specific_info.thumbnail_url());
1848 if (!file_specific_info.alternate_url().empty()) 1848 if (!file_specific_info.alternate_url().empty())
1849 property_dict->SetString("editUrl", file_specific_info.alternate_url()); 1849 property_dict->SetString("editUrl", file_specific_info.alternate_url());
1850 1850
1851 if (!entry_proto->content_url().empty()) { 1851 if (!entry_proto->content_url().empty()) {
1852 property_dict->SetString("contentUrl", entry_proto->content_url()); 1852 property_dict->SetString("contentUrl", entry_proto->content_url());
1853 } 1853 }
1854 1854
1855 property_dict->SetBoolean("isHosted", 1855 property_dict->SetBoolean("isHosted",
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 entry_proto->resource_id(), 1890 entry_proto->resource_id(),
1891 file_specific_info.file_md5(), 1891 file_specific_info.file_md5(),
1892 base::Bind( 1892 base::Bind(
1893 &GetGDataFilePropertiesFunction::CacheStateReceived, 1893 &GetGDataFilePropertiesFunction::CacheStateReceived,
1894 this, property_dict)); 1894 this, property_dict));
1895 } 1895 }
1896 1896
1897 void GetGDataFilePropertiesFunction::CacheStateReceived( 1897 void GetGDataFilePropertiesFunction::CacheStateReceived(
1898 base::DictionaryValue* property_dict, 1898 base::DictionaryValue* property_dict,
1899 bool /* success */, 1899 bool /* success */,
1900 const gdata::GDataCacheEntry& cache_entry) { 1900 const gdata::DriveCacheEntry& cache_entry) {
1901 // In case of an error (i.e. success is false), cache_entry.is_*() all 1901 // In case of an error (i.e. success is false), cache_entry.is_*() all
1902 // returns false. 1902 // returns false.
1903 property_dict->SetBoolean("isPinned", cache_entry.is_pinned()); 1903 property_dict->SetBoolean("isPinned", cache_entry.is_pinned());
1904 property_dict->SetBoolean("isPresent", cache_entry.is_present()); 1904 property_dict->SetBoolean("isPresent", cache_entry.is_present());
1905 property_dict->SetBoolean("isDirty", cache_entry.is_dirty()); 1905 property_dict->SetBoolean("isDirty", cache_entry.is_dirty());
1906 1906
1907 CompleteGetFileProperties(); 1907 CompleteGetFileProperties();
1908 } 1908 }
1909 1909
1910 PinGDataFileFunction::PinGDataFileFunction() { 1910 PinGDataFileFunction::PinGDataFileFunction() {
1911 } 1911 }
1912 1912
1913 PinGDataFileFunction::~PinGDataFileFunction() { 1913 PinGDataFileFunction::~PinGDataFileFunction() {
1914 } 1914 }
1915 1915
1916 bool PinGDataFileFunction::RunImpl() { 1916 bool PinGDataFileFunction::RunImpl() {
1917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1917 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1918 if (args_->GetSize() != 2 || !args_->GetBoolean(1, &set_pin_)) 1918 if (args_->GetSize() != 2 || !args_->GetBoolean(1, &set_pin_))
1919 return false; 1919 return false;
1920 1920
1921 PrepareResults(); 1921 PrepareResults();
1922 1922
1923 return true; 1923 return true;
1924 } 1924 }
1925 1925
1926 void PinGDataFileFunction::DoOperation( 1926 void PinGDataFileFunction::DoOperation(
1927 const FilePath& file_path, 1927 const FilePath& file_path,
1928 base::DictionaryValue* properties, 1928 base::DictionaryValue* properties,
1929 scoped_ptr<gdata::GDataEntryProto> entry_proto) { 1929 scoped_ptr<gdata::DriveEntryProto> entry_proto) {
1930 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1930 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1931 1931
1932 gdata::GDataSystemService* system_service = 1932 gdata::GDataSystemService* system_service =
1933 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 1933 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
1934 // This is subtle but we should take references of resource_id and md5 1934 // This is subtle but we should take references of resource_id and md5
1935 // before |file_info| is passed to |callback| by base::Passed(). Otherwise, 1935 // before |file_info| is passed to |callback| by base::Passed(). Otherwise,
1936 // file_info->whatever() crashes. 1936 // file_info->whatever() crashes.
1937 const std::string& resource_id = entry_proto->resource_id(); 1937 const std::string& resource_id = entry_proto->resource_id();
1938 const std::string& md5 = entry_proto->file_specific_info().file_md5(); 1938 const std::string& md5 = entry_proto->file_specific_info().file_md5();
1939 const gdata::CacheOperationCallback callback = 1939 const gdata::CacheOperationCallback callback =
1940 base::Bind(&PinGDataFileFunction::OnPinStateSet, 1940 base::Bind(&PinGDataFileFunction::OnPinStateSet,
1941 this, 1941 this,
1942 file_path, 1942 file_path,
1943 properties, 1943 properties,
1944 base::Passed(&entry_proto)); 1944 base::Passed(&entry_proto));
1945 1945
1946 if (set_pin_) 1946 if (set_pin_)
1947 system_service->cache()->PinOnUIThread(resource_id, md5, callback); 1947 system_service->cache()->PinOnUIThread(resource_id, md5, callback);
1948 else 1948 else
1949 system_service->cache()->UnpinOnUIThread(resource_id, md5, callback); 1949 system_service->cache()->UnpinOnUIThread(resource_id, md5, callback);
1950 } 1950 }
1951 1951
1952 void PinGDataFileFunction::OnPinStateSet( 1952 void PinGDataFileFunction::OnPinStateSet(
1953 const FilePath& path, 1953 const FilePath& path,
1954 base::DictionaryValue* properties, 1954 base::DictionaryValue* properties,
1955 scoped_ptr<gdata::GDataEntryProto> entry_proto, 1955 scoped_ptr<gdata::DriveEntryProto> entry_proto,
1956 gdata::GDataFileError error, 1956 gdata::GDataFileError error,
1957 const std::string& /* resource_id */, 1957 const std::string& /* resource_id */,
1958 const std::string& /* md5 */) { 1958 const std::string& /* md5 */) {
1959 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1959 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1960 1960
1961 OnOperationComplete(path, properties, error, entry_proto.Pass()); 1961 OnOperationComplete(path, properties, error, entry_proto.Pass());
1962 } 1962 }
1963 1963
1964 GetFileLocationsFunction::GetFileLocationsFunction() { 1964 GetFileLocationsFunction::GetFileLocationsFunction() {
1965 } 1965 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 gdata::GDataSystemService* system_service = 2432 gdata::GDataSystemService* system_service =
2433 gdata::GDataSystemServiceFactory::GetForProfile(profile_); 2433 gdata::GDataSystemServiceFactory::GetForProfile(profile_);
2434 if (!system_service || !system_service->file_system()) 2434 if (!system_service || !system_service->file_system())
2435 return false; 2435 return false;
2436 2436
2437 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); 2437 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string));
2438 system_service->file_system()->RequestDirectoryRefresh(directory_path); 2438 system_service->file_system()->RequestDirectoryRefresh(directory_path);
2439 2439
2440 return true; 2440 return true;
2441 } 2441 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.h ('k') | chrome/browser/chromeos/extensions/file_manager_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698