| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/file_manager_util.h" | 4 #include "chrome/browser/extensions/file_manager_util.h" |
| 5 | 5 |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #define FILEBROWSER_URL(PATH) \ | 43 #define FILEBROWSER_URL(PATH) \ |
| 44 ("chrome-extension://" FILEBROWSER_DOMAIN "/" PATH) | 44 ("chrome-extension://" FILEBROWSER_DOMAIN "/" PATH) |
| 45 // This is the "well known" url for the file manager extension from | 45 // This is the "well known" url for the file manager extension from |
| 46 // browser/resources/file_manager. In the future we may provide a way to swap | 46 // browser/resources/file_manager. In the future we may provide a way to swap |
| 47 // out this file manager for an aftermarket part, but not yet. | 47 // out this file manager for an aftermarket part, but not yet. |
| 48 const char kFileBrowserExtensionUrl[] = FILEBROWSER_URL(""); | 48 const char kFileBrowserExtensionUrl[] = FILEBROWSER_URL(""); |
| 49 const char kBaseFileBrowserUrl[] = FILEBROWSER_URL("main.html"); | 49 const char kBaseFileBrowserUrl[] = FILEBROWSER_URL("main.html"); |
| 50 const char kMediaPlayerUrl[] = FILEBROWSER_URL("mediaplayer.html"); | 50 const char kMediaPlayerUrl[] = FILEBROWSER_URL("mediaplayer.html"); |
| 51 const char kMediaPlayerPlaylistUrl[] = FILEBROWSER_URL("playlist.html"); | 51 const char kMediaPlayerPlaylistUrl[] = FILEBROWSER_URL("playlist.html"); |
| 52 #undef FILEBROWSER_URL | 52 #undef FILEBROWSER_URL |
| 53 #undef FILEBROWSER_DOMAIN |
| 54 |
| 55 namespace { |
| 53 | 56 |
| 54 const char kPdfExtension[] = ".pdf"; | 57 const char kPdfExtension[] = ".pdf"; |
| 55 // List of file extension we can open in tab. | 58 // List of file extension we can open in tab. |
| 56 const char* kBrowserSupportedExtensions[] = { | 59 const char* kBrowserSupportedExtensions[] = { |
| 57 #if defined(GOOGLE_CHROME_BUILD) | 60 #if defined(GOOGLE_CHROME_BUILD) |
| 58 ".pdf", | 61 ".pdf", |
| 59 #endif | 62 #endif |
| 60 ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".txt", ".html", ".htm" | 63 ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".txt", ".html", ".htm" |
| 61 }; | 64 }; |
| 62 // List of file extension that can be handled with the media player. | 65 // List of file extension that can be handled with the media player. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 232 } |
| 230 | 233 |
| 231 std::string json_args; | 234 std::string json_args; |
| 232 base::JSONWriter::Write(&arg_value, false, &json_args); | 235 base::JSONWriter::Write(&arg_value, false, &json_args); |
| 233 | 236 |
| 234 // kChromeUIFileManagerURL could not be used since query parameters are not | 237 // kChromeUIFileManagerURL could not be used since query parameters are not |
| 235 // supported for it. | 238 // supported for it. |
| 236 std::string url = FileManagerUtil::GetFileBrowserUrl().spec() + | 239 std::string url = FileManagerUtil::GetFileBrowserUrl().spec() + |
| 237 '?' + net::EscapeUrlEncodedData(json_args, false); | 240 '?' + net::EscapeUrlEncodedData(json_args, false); |
| 238 return GURL(url); | 241 return GURL(url); |
| 239 | |
| 240 } | 242 } |
| 241 | 243 |
| 242 // static | 244 // static |
| 243 void FileManagerUtil::ShowFullTabUrl(Profile*, | 245 void FileManagerUtil::ViewFolder(const FilePath& dir) { |
| 244 const FilePath& dir) { | |
| 245 Browser* browser = BrowserList::GetLastActive(); | 246 Browser* browser = BrowserList::GetLastActive(); |
| 246 if (!browser) | 247 if (!browser) |
| 247 return; | 248 return; |
| 248 | 249 |
| 249 FilePath virtual_path; | 250 FilePath virtual_path; |
| 250 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath(browser->profile(), | 251 if (!FileManagerUtil::ConvertFileToRelativeFileSystemPath(browser->profile(), |
| 251 dir, | 252 dir, |
| 252 &virtual_path)) { | 253 &virtual_path)) { |
| 253 return; | 254 return; |
| 254 } | 255 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 case SelectFileDialog::SELECT_OPEN_MULTI_FILE: | 347 case SelectFileDialog::SELECT_OPEN_MULTI_FILE: |
| 347 type_str = "open-multi-file"; | 348 type_str = "open-multi-file"; |
| 348 break; | 349 break; |
| 349 | 350 |
| 350 default: | 351 default: |
| 351 NOTREACHED(); | 352 NOTREACHED(); |
| 352 } | 353 } |
| 353 | 354 |
| 354 return type_str; | 355 return type_str; |
| 355 } | 356 } |
| OLD | NEW |