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 #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/drive.pb.h" | 17 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" | 18 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
19 #include "chrome/browser/chromeos/gdata/drive_files.h" | 19 #include "chrome/browser/chromeos/gdata/drive_files.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 20 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
21 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
22 #include "chrome/browser/chromeos/gdata/operation_registry.h" | 22 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
23 #include "chrome/browser/chromeos/media/media_player.h" | 23 #include "chrome/browser/chromeos/media/media_player.h" |
24 #include "chrome/browser/extensions/crx_installer.h" | 24 #include "chrome/browser/extensions/crx_installer.h" |
25 #include "chrome/browser/extensions/extension_install_prompt.h" | 25 #include "chrome/browser/extensions/extension_install_prompt.h" |
26 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
27 #include "chrome/browser/plugin_prefs.h" | 27 #include "chrome/browser/plugin_prefs.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 Profile* profile = browser->profile(); | 618 Profile* profile = browser->profile(); |
619 std::string file_extension = path.Extension(); | 619 std::string file_extension = path.Extension(); |
620 // For things supported natively by the browser, we should open it | 620 // For things supported natively by the browser, we should open it |
621 // in a tab. | 621 // in a tab. |
622 if (IsSupportedBrowserExtension(file_extension.data()) || | 622 if (IsSupportedBrowserExtension(file_extension.data()) || |
623 ShouldBeOpenedWithPdfPlugin(profile, file_extension.data())) { | 623 ShouldBeOpenedWithPdfPlugin(profile, file_extension.data())) { |
624 GURL page_url = net::FilePathToFileURL(path); | 624 GURL page_url = net::FilePathToFileURL(path); |
625 // Override gdata resource to point to internal handler instead of file: | 625 // Override gdata resource to point to internal handler instead of file: |
626 // URL. | 626 // URL. |
627 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { | 627 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { |
628 gdata::GDataSystemService* system_service = | 628 gdata::DriveSystemService* system_service = |
629 gdata::GDataSystemServiceFactory::GetForProfile(profile); | 629 gdata::DriveSystemServiceFactory::GetForProfile(profile); |
630 if (!system_service) | 630 if (!system_service) |
631 return false; | 631 return false; |
632 | 632 |
633 // Open the file once the file is found. | 633 // Open the file once the file is found. |
634 system_service->file_system()->GetEntryInfoByPath( | 634 system_service->file_system()->GetEntryInfoByPath( |
635 gdata::util::ExtractGDataPath(path), | 635 gdata::util::ExtractGDataPath(path), |
636 base::Bind(&OnGDataFileFound, profile, path, gdata::REGULAR_FILE)); | 636 base::Bind(&OnGDataFileFound, profile, path, gdata::REGULAR_FILE)); |
637 return true; | 637 return true; |
638 } | 638 } |
639 OpenNewTab(page_url, NULL); | 639 OpenNewTab(page_url, NULL); |
640 return true; | 640 return true; |
641 } | 641 } |
642 | 642 |
643 if (IsSupportedGDocsExtension(file_extension.data())) { | 643 if (IsSupportedGDocsExtension(file_extension.data())) { |
644 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { | 644 if (gdata::util::GetSpecialRemoteRootPath().IsParent(path)) { |
645 // The file is on Google Docs. Get the Docs from the GData service. | 645 // The file is on Google Docs. Get the Docs from the GData service. |
646 gdata::GDataSystemService* system_service = | 646 gdata::DriveSystemService* system_service = |
647 gdata::GDataSystemServiceFactory::GetForProfile(profile); | 647 gdata::DriveSystemServiceFactory::GetForProfile(profile); |
648 if (!system_service) | 648 if (!system_service) |
649 return false; | 649 return false; |
650 | 650 |
651 system_service->file_system()->GetEntryInfoByPath( | 651 system_service->file_system()->GetEntryInfoByPath( |
652 gdata::util::ExtractGDataPath(path), | 652 gdata::util::ExtractGDataPath(path), |
653 base::Bind(&OnGDataFileFound, profile, path, | 653 base::Bind(&OnGDataFileFound, profile, path, |
654 gdata::HOSTED_DOCUMENT)); | 654 gdata::HOSTED_DOCUMENT)); |
655 } else { | 655 } else { |
656 // The file is local (downloaded from an attachment or otherwise copied). | 656 // The file is local (downloaded from an attachment or otherwise copied). |
657 // Parse the file to extract the Docs url and open this url. | 657 // Parse the file to extract the Docs url and open this url. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 OperationRegistry::ProgressStatus>::const_iterator iter = | 749 OperationRegistry::ProgressStatus>::const_iterator iter = |
750 list.begin(); | 750 list.begin(); |
751 iter != list.end(); ++iter) { | 751 iter != list.end(); ++iter) { |
752 result_list->Append( | 752 result_list->Append( |
753 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 753 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
754 } | 754 } |
755 return result_list.release(); | 755 return result_list.release(); |
756 } | 756 } |
757 | 757 |
758 } // namespace file_manager_util | 758 } // namespace file_manager_util |
OLD | NEW |