| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // drive's web interface. Otherwise (e.g. MTP, FSP), the file is just | 163 // drive's web interface. Otherwise (e.g. MTP, FSP), the file is just |
| 164 // downloaded in a browser tab. | 164 // downloaded in a browser tab. |
| 165 const GURL url = | 165 const GURL url = |
| 166 chromeos::FileSystemURLToExternalFileURL(file_system_url); | 166 chromeos::FileSystemURLToExternalFileURL(file_system_url); |
| 167 DCHECK(!url.is_empty()); | 167 DCHECK(!url.is_empty()); |
| 168 OpenNewTab(profile, url); | 168 OpenNewTab(profile, url); |
| 169 } else { | 169 } else { |
| 170 // The file is local (downloaded from an attachment or otherwise copied). | 170 // The file is local (downloaded from an attachment or otherwise copied). |
| 171 // Parse the file to extract the Docs url and open this url. | 171 // Parse the file to extract the Docs url and open this url. |
| 172 base::PostTaskWithTraitsAndReplyWithResult( | 172 base::PostTaskWithTraitsAndReplyWithResult( |
| 173 FROM_HERE, base::TaskTraits().MayBlock(), | 173 FROM_HERE, {base::MayBlock()}, |
| 174 base::Bind(&ReadUrlFromGDocAsync, file_path), | 174 base::Bind(&ReadUrlFromGDocAsync, file_path), |
| 175 base::Bind(&OpenNewTab, profile)); | 175 base::Bind(&OpenNewTab, profile)); |
| 176 } | 176 } |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Failed to open the file of unknown type. | 180 // Failed to open the file of unknown type. |
| 181 LOG(WARNING) << "Unknown file type: " << file_path.value(); | 181 LOG(WARNING) << "Unknown file type: " << file_path.value(); |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // If a bundled plugin is enabled, we should open pdf/swf files in a tab. | 185 // If a bundled plugin is enabled, we should open pdf/swf files in a tab. |
| 186 bool ShouldBeOpenedWithPlugin( | 186 bool ShouldBeOpenedWithPlugin( |
| 187 Profile* profile, | 187 Profile* profile, |
| 188 const base::FilePath::StringType& file_extension) { | 188 const base::FilePath::StringType& file_extension) { |
| 189 DCHECK(profile); | 189 DCHECK(profile); |
| 190 | 190 |
| 191 const base::FilePath file_path = | 191 const base::FilePath file_path = |
| 192 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension); | 192 base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension); |
| 193 if (file_path.MatchesExtension(kPdfExtension)) | 193 if (file_path.MatchesExtension(kPdfExtension)) |
| 194 return IsPdfPluginEnabled(profile); | 194 return IsPdfPluginEnabled(profile); |
| 195 if (file_path.MatchesExtension(kSwfExtension)) | 195 if (file_path.MatchesExtension(kSwfExtension)) |
| 196 return IsFlashPluginEnabled(profile); | 196 return IsFlashPluginEnabled(profile); |
| 197 return false; | 197 return false; |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace util | 200 } // namespace util |
| 201 } // namespace file_manager | 201 } // namespace file_manager |
| OLD | NEW |