| 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/gdata/gdata_util.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
| 17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 22 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 23 #include "base/time.h" | 23 #include "base/time.h" |
| 24 #include "base/tracked_objects.h" | 24 #include "base/tracked_objects.h" |
| 25 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 25 #include "chrome/browser/chromeos/gdata/file_write_helper.h" | 26 #include "chrome/browser/chromeos/gdata/file_write_helper.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | |
| 27 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 27 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 28 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 28 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 29 #include "chrome/browser/chromeos/login/user.h" | 29 #include "chrome/browser/chromeos/login/user.h" |
| 30 #include "chrome/browser/chromeos/login/user_manager.h" | 30 #include "chrome/browser/chromeos/login/user_manager.h" |
| 31 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
| 34 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
| 35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/chrome_version_info.h" | 36 #include "chrome/common/chrome_version_info.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 109 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 // Invoked upon completion of GetEntryInfoByResourceId initiated by | 113 // Invoked upon completion of GetEntryInfoByResourceId initiated by |
| 114 // ModifyGDataFileResourceUrl. | 114 // ModifyGDataFileResourceUrl. |
| 115 void OnGetEntryInfoByResourceId(Profile* profile, | 115 void OnGetEntryInfoByResourceId(Profile* profile, |
| 116 const std::string& resource_id, | 116 const std::string& resource_id, |
| 117 GDataFileError error, | 117 GDataFileError error, |
| 118 const FilePath& /* gdata_file_path */, | 118 const FilePath& /* gdata_file_path */, |
| 119 scoped_ptr<GDataEntryProto> entry_proto) { | 119 scoped_ptr<DriveEntryProto> entry_proto) { |
| 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 121 | 121 |
| 122 if (error != GDATA_FILE_OK) | 122 if (error != GDATA_FILE_OK) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 DCHECK(entry_proto.get()); | 125 DCHECK(entry_proto.get()); |
| 126 const std::string& base_name = entry_proto->base_name(); | 126 const std::string& base_name = entry_proto->base_name(); |
| 127 const GURL edit_url = GetFileResourceUrl(resource_id, base_name); | 127 const GURL edit_url = GetFileResourceUrl(resource_id, base_name); |
| 128 OpenEditURLUIThread(profile, &edit_url); | 128 OpenEditURLUIThread(profile, &edit_url); |
| 129 DVLOG(1) << "OnFindEntryByResourceId " << edit_url; | 129 DVLOG(1) << "OnFindEntryByResourceId " << edit_url; |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Invoked upon completion of GetEntryInfoByPath initiated by | 132 // Invoked upon completion of GetEntryInfoByPath initiated by |
| 133 // InsertGDataCachePathPermissions. | 133 // InsertGDataCachePathPermissions. |
| 134 void OnGetEntryInfoForInsertGDataCachePathsPermissions( | 134 void OnGetEntryInfoForInsertGDataCachePathsPermissions( |
| 135 Profile* profile, | 135 Profile* profile, |
| 136 std::vector<std::pair<FilePath, int> >* cache_paths, | 136 std::vector<std::pair<FilePath, int> >* cache_paths, |
| 137 const base::Closure& callback, | 137 const base::Closure& callback, |
| 138 GDataFileError error, | 138 GDataFileError error, |
| 139 scoped_ptr<GDataEntryProto> entry_proto) { | 139 scoped_ptr<DriveEntryProto> entry_proto) { |
| 140 DCHECK(profile); | 140 DCHECK(profile); |
| 141 DCHECK(cache_paths); | 141 DCHECK(cache_paths); |
| 142 DCHECK(!callback.is_null()); | 142 DCHECK(!callback.is_null()); |
| 143 | 143 |
| 144 if (entry_proto.get() && !entry_proto->has_file_specific_info()) | 144 if (entry_proto.get() && !entry_proto->has_file_specific_info()) |
| 145 error = GDATA_FILE_ERROR_NOT_FOUND; | 145 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 146 | 146 |
| 147 GDataCache* cache = GetGDataCache(profile); | 147 GDataCache* cache = GetGDataCache(profile); |
| 148 if (!cache || error != GDATA_FILE_OK) { | 148 if (!cache || error != GDATA_FILE_OK) { |
| 149 callback.Run(); | 149 callback.Run(); |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 const base::Closure& reply_task) { | 652 const base::Closure& reply_task) { |
| 653 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 653 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 654 | 654 |
| 655 const bool posted = blocking_task_runner->PostTaskAndReply( | 655 const bool posted = blocking_task_runner->PostTaskAndReply( |
| 656 from_here, request_task, reply_task); | 656 from_here, request_task, reply_task); |
| 657 DCHECK(posted); | 657 DCHECK(posted); |
| 658 } | 658 } |
| 659 | 659 |
| 660 } // namespace util | 660 } // namespace util |
| 661 } // namespace gdata | 661 } // namespace gdata |
| OLD | NEW |