| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/file_manager/open_with_browser.h" | 5 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | 11 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system_util.h" | 13 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 14 #include "chrome/browser/chromeos/fileapi/external_file_url_util.h" |
| 14 #include "chrome/browser/drive/drive_api_util.h" | 15 #include "chrome/browser/drive/drive_api_util.h" |
| 15 #include "chrome/browser/plugins/plugin_prefs.h" | 16 #include "chrome/browser/plugins/plugin_prefs.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 18 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 20 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 22 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 133 DCHECK(profile); | 134 DCHECK(profile); |
| 134 | 135 |
| 135 // For things supported natively by the browser, we should open it | 136 // For things supported natively by the browser, we should open it |
| 136 // in a tab. | 137 // in a tab. |
| 137 if (IsViewableInBrowser(file_path) || | 138 if (IsViewableInBrowser(file_path) || |
| 138 ShouldBeOpenedWithPlugin(profile, file_path.Extension())) { | 139 ShouldBeOpenedWithPlugin(profile, file_path.Extension())) { |
| 139 GURL page_url = net::FilePathToFileURL(file_path); | 140 GURL page_url = net::FilePathToFileURL(file_path); |
| 140 // Override drive resource to point to internal handler instead of file URL. | 141 // Override drive resource to point to internal handler instead of file URL. |
| 141 if (drive::util::IsUnderDriveMountPoint(file_path)) { | 142 if (drive::util::IsUnderDriveMountPoint(file_path)) { |
| 142 page_url = drive::util::FilePathToDriveURL( | 143 page_url = chromeos::FilePathToExternalFileURL( |
| 143 drive::util::ExtractDrivePath(file_path)); | 144 drive::util::ExtractDrivePath(file_path)); |
| 144 } | 145 } |
| 145 OpenNewTab(profile, page_url); | 146 OpenNewTab(profile, page_url); |
| 146 return true; | 147 return true; |
| 147 } | 148 } |
| 148 | 149 |
| 149 if (drive::util::HasHostedDocumentExtension(file_path)) { | 150 if (drive::util::HasHostedDocumentExtension(file_path)) { |
| 150 if (drive::util::IsUnderDriveMountPoint(file_path)) { | 151 if (drive::util::IsUnderDriveMountPoint(file_path)) { |
| 151 // The file is on Google Docs. Open with drive URL. | 152 // The file is on Google Docs. Open with drive URL. |
| 152 GURL url = drive::util::FilePathToDriveURL( | 153 GURL url = chromeos::FilePathToExternalFileURL( |
| 153 drive::util::ExtractDrivePath(file_path)); | 154 drive::util::ExtractDrivePath(file_path)); |
| 154 OpenNewTab(profile, url); | 155 OpenNewTab(profile, url); |
| 155 } else { | 156 } else { |
| 156 // The file is local (downloaded from an attachment or otherwise copied). | 157 // The file is local (downloaded from an attachment or otherwise copied). |
| 157 // Parse the file to extract the Docs url and open this url. | 158 // Parse the file to extract the Docs url and open this url. |
| 158 base::PostTaskAndReplyWithResult( | 159 base::PostTaskAndReplyWithResult( |
| 159 BrowserThread::GetBlockingPool(), | 160 BrowserThread::GetBlockingPool(), |
| 160 FROM_HERE, | 161 FROM_HERE, |
| 161 base::Bind(&ReadUrlFromGDocOnBlockingPool, file_path), | 162 base::Bind(&ReadUrlFromGDocOnBlockingPool, file_path), |
| 162 base::Bind(&OpenNewTab, profile)); | 163 base::Bind(&OpenNewTab, profile)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 179 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension); | 180 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension); |
| 180 if (file_path.MatchesExtension(kPdfExtension)) | 181 if (file_path.MatchesExtension(kPdfExtension)) |
| 181 return IsPdfPluginEnabled(profile); | 182 return IsPdfPluginEnabled(profile); |
| 182 if (file_path.MatchesExtension(kSwfExtension)) | 183 if (file_path.MatchesExtension(kSwfExtension)) |
| 183 return IsFlashPluginEnabled(profile); | 184 return IsFlashPluginEnabled(profile); |
| 184 return false; | 185 return false; |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace util | 188 } // namespace util |
| 188 } // namespace file_manager | 189 } // namespace file_manager |
| OLD | NEW |