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

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

Issue 10270025: gdata: Remove use of FindEntryByPathAsync() from file_manager_util.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address 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 | « no previous file | chrome/browser/chromeos/gdata/gdata.proto » ('j') | 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 #include "chrome/browser/chromeos/extensions/file_manager_util.h" 4 #include "chrome/browser/chromeos/extensions/file_manager_util.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/chromeos/extensions/file_handler_util.h" 16 #include "chrome/browser/chromeos/extensions/file_handler_util.h"
17 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
17 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" 18 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h"
18 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
19 #include "chrome/browser/chromeos/gdata/gdata_util.h" 20 #include "chrome/browser/chromeos/gdata/gdata_util.h"
20 #include "chrome/browser/extensions/crx_installer.h" 21 #include "chrome/browser/extensions/crx_installer.h"
21 #include "chrome/browser/extensions/extension_install_ui.h" 22 #include "chrome/browser/extensions/extension_install_ui.h"
22 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/plugin_prefs.h" 24 #include "chrome/browser/plugin_prefs.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/simple_message_box.h" 27 #include "chrome/browser/simple_message_box.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 UTF8ToUTF16(path.BaseName().value())), 236 UTF8ToUTF16(path.BaseName().value())),
236 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE)); 237 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE));
237 } 238 }
238 239
239 // Called when a file on GData was found. Opens the file found at |file_path| 240 // Called when a file on GData was found. Opens the file found at |file_path|
240 // in a new tab with a URL computed based on the |file_type| 241 // in a new tab with a URL computed based on the |file_type|
241 void OnGDataFileFound(Profile* profile, 242 void OnGDataFileFound(Profile* profile,
242 const FilePath& file_path, 243 const FilePath& file_path,
243 gdata::GDataFileType file_type, 244 gdata::GDataFileType file_type,
244 base::PlatformFileError error, 245 base::PlatformFileError error,
245 const FilePath& /* directory_path */, 246 scoped_ptr<gdata::GDataFileProto> file_proto) {
246 gdata::GDataEntry* entry) {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
248 248
249 if (error == base::PLATFORM_FILE_OK && entry && entry->AsGDataFile()) { 249 if (error == base::PLATFORM_FILE_OK) {
250 gdata::GDataFile* file = entry->AsGDataFile();
251 GURL page_url; 250 GURL page_url;
252 if (file_type == gdata::REGULAR_FILE) { 251 if (file_type == gdata::REGULAR_FILE) {
253 page_url = gdata::util::GetFileResourceUrl(file->resource_id(), 252 page_url = gdata::util::GetFileResourceUrl(
254 file->file_name()); 253 file_proto->gdata_entry().resource_id(),
254 file_proto->gdata_entry().file_name());
255 } else if (file_type == gdata::HOSTED_DOCUMENT) { 255 } else if (file_type == gdata::HOSTED_DOCUMENT) {
256 page_url = file->alternate_url(); 256 page_url = GURL(file_proto->alternate_url());
257 } else { 257 } else {
258 NOTREACHED(); 258 NOTREACHED();
259 } 259 }
260 OpenNewTab(page_url, profile); 260 OpenNewTab(page_url, profile);
261 } else { 261 } else {
262 ShowWarningMessageBox(profile, file_path); 262 ShowWarningMessageBox(profile, file_path);
263 } 263 }
264 } 264 }
265 265
266 } // namespace 266 } // namespace
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 #if defined(OS_CHROMEOS) 614 #if defined(OS_CHROMEOS)
615 // Override gdata resource to point to internal handler instead of file: 615 // Override gdata resource to point to internal handler instead of file:
616 // URL. 616 // URL.
617 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { 617 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) {
618 gdata::GDataSystemService* system_service = 618 gdata::GDataSystemService* system_service =
619 gdata::GDataSystemServiceFactory::GetForProfile(profile); 619 gdata::GDataSystemServiceFactory::GetForProfile(profile);
620 if (!system_service) 620 if (!system_service)
621 return false; 621 return false;
622 622
623 // Open the file once the file is found. 623 // Open the file once the file is found.
624 system_service->file_system()->FindEntryByPathAsync( 624 system_service->file_system()->GetFileInfoByPathAsync(
625 gdata::util::ExtractGDataPath(path), 625 gdata::util::ExtractGDataPath(path),
626 base::Bind(&OnGDataFileFound, profile, path, gdata::REGULAR_FILE)); 626 base::Bind(&OnGDataFileFound, profile, path, gdata::REGULAR_FILE));
627 return true; 627 return true;
628 } 628 }
629 #endif 629 #endif
630 OpenNewTab(page_url, (Profile*)NULL); 630 OpenNewTab(page_url, (Profile*)NULL);
631 return true; 631 return true;
632 } 632 }
633 633
634 if (IsSupportedGDocsExtension(file_extension.data())) { 634 if (IsSupportedGDocsExtension(file_extension.data())) {
635 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { 635 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) {
636 // The file is on Google Docs. Get the Docs from the GData service. 636 // The file is on Google Docs. Get the Docs from the GData service.
637 gdata::GDataSystemService* system_service = 637 gdata::GDataSystemService* system_service =
638 gdata::GDataSystemServiceFactory::GetForProfile(profile); 638 gdata::GDataSystemServiceFactory::GetForProfile(profile);
639 if (!system_service) 639 if (!system_service)
640 return false; 640 return false;
641 641
642 system_service->file_system()->FindEntryByPathAsync( 642 system_service->file_system()->GetFileInfoByPathAsync(
643 gdata::util::ExtractGDataPath(path), 643 gdata::util::ExtractGDataPath(path),
644 base::Bind(&OnGDataFileFound, profile, path, 644 base::Bind(&OnGDataFileFound, profile, path,
645 gdata::HOSTED_DOCUMENT)); 645 gdata::HOSTED_DOCUMENT));
646 } else { 646 } else {
647 // The file is local (downloaded from an attachment or otherwise copied). 647 // The file is local (downloaded from an attachment or otherwise copied).
648 // Parse the file to extract the Docs url and open this url. 648 // Parse the file to extract the Docs url and open this url.
649 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 649 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
650 base::Bind(&ReadUrlFromGDocOnFileThread, path)); 650 base::Bind(&ReadUrlFromGDocOnFileThread, path));
651 } 651 }
652 return true; 652 return true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 GDataOperationRegistry::ProgressStatus>::const_iterator iter = 720 GDataOperationRegistry::ProgressStatus>::const_iterator iter =
721 list.begin(); 721 list.begin();
722 iter != list.end(); ++iter) { 722 iter != list.end(); ++iter) {
723 result_list->Append( 723 result_list->Append(
724 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); 724 ProgessStatusToDictionaryValue(profile, origin_url, *iter));
725 } 725 }
726 return result_list.release(); 726 return result_list.release();
727 } 727 }
728 728
729 } // namespace file_manager_util 729 } // namespace file_manager_util
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698