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

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

Issue 14670023: ChromeOS: Support opening files with apps from the downloads page. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: prioritize fallback handlers over non-default app handlers Created 7 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/file_manager_util.h ('k') | no next file » | 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/file_manager_util.h" 4 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
5 5
6 #include "ash/shell.h" 6 #include "ash/shell.h"
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/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/drive/drive.pb.h" 16 #include "chrome/browser/chromeos/drive/drive.pb.h"
17 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 17 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
18 #include "chrome/browser/chromeos/drive/file_system.h" 18 #include "chrome/browser/chromeos/drive/file_system.h"
19 #include "chrome/browser/chromeos/drive/file_system_util.h" 19 #include "chrome/browser/chromeos/drive/file_system_util.h"
20 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler.h " 20 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler.h "
21 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h" 21 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h"
22 #include "chrome/browser/chromeos/media/media_player.h" 22 #include "chrome/browser/chromeos/media/media_player.h"
23 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
23 #include "chrome/browser/extensions/crx_installer.h" 24 #include "chrome/browser/extensions/crx_installer.h"
24 #include "chrome/browser/extensions/extension_install_prompt.h" 25 #include "chrome/browser/extensions/extension_install_prompt.h"
25 #include "chrome/browser/extensions/extension_service.h" 26 #include "chrome/browser/extensions/extension_service.h"
26 #include "chrome/browser/extensions/extension_system.h" 27 #include "chrome/browser/extensions/extension_system.h"
27 #include "chrome/browser/google_apis/task_util.h" 28 #include "chrome/browser/google_apis/task_util.h"
28 #include "chrome/browser/plugins/plugin_prefs.h" 29 #include "chrome/browser/plugins/plugin_prefs.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/profiles/profile_manager.h" 31 #include "chrome/browser/profiles/profile_manager.h"
31 #include "chrome/browser/ui/browser.h" 32 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
33 #include "chrome/browser/ui/browser_iterator.h" 34 #include "chrome/browser/ui/browser_iterator.h"
34 #include "chrome/browser/ui/browser_tabstrip.h" 35 #include "chrome/browser/ui/browser_tabstrip.h"
35 #include "chrome/browser/ui/browser_window.h" 36 #include "chrome/browser/ui/browser_window.h"
36 #include "chrome/browser/ui/extensions/application_launch.h" 37 #include "chrome/browser/ui/extensions/application_launch.h"
37 #include "chrome/browser/ui/host_desktop.h" 38 #include "chrome/browser/ui/host_desktop.h"
38 #include "chrome/browser/ui/simple_message_box.h" 39 #include "chrome/browser/ui/simple_message_box.h"
39 #include "chrome/browser/ui/tabs/tab_strip_model.h" 40 #include "chrome/browser/ui/tabs/tab_strip_model.h"
40 #include "chrome/common/chrome_paths.h" 41 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/url_constants.h" 43 #include "chrome/common/url_constants.h"
43 #include "chromeos/chromeos_switches.h" 44 #include "chromeos/chromeos_switches.h"
44 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/plugin_service.h" 46 #include "content/public/browser/plugin_service.h"
46 #include "content/public/browser/storage_partition.h" 47 #include "content/public/browser/storage_partition.h"
47 #include "content/public/browser/user_metrics.h" 48 #include "content/public/browser/user_metrics.h"
48 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
49 #include "content/public/common/pepper_plugin_info.h" 50 #include "content/public/common/pepper_plugin_info.h"
50 #include "grit/generated_resources.h" 51 #include "grit/generated_resources.h"
51 #include "net/base/escape.h" 52 #include "net/base/escape.h"
53 #include "net/base/mime_util.h"
52 #include "net/base/net_util.h" 54 #include "net/base/net_util.h"
53 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
54 #include "ui/gfx/screen.h" 56 #include "ui/gfx/screen.h"
55 #include "webkit/browser/fileapi/file_system_context.h" 57 #include "webkit/browser/fileapi/file_system_context.h"
56 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" 58 #include "webkit/browser/fileapi/file_system_mount_point_provider.h"
57 #include "webkit/browser/fileapi/file_system_operation.h" 59 #include "webkit/browser/fileapi/file_system_operation.h"
58 #include "webkit/browser/fileapi/file_system_url.h" 60 #include "webkit/browser/fileapi/file_system_url.h"
59 #include "webkit/common/fileapi/file_system_util.h" 61 #include "webkit/common/fileapi/file_system_util.h"
60 #include "webkit/plugins/webplugininfo.h" 62 #include "webkit/plugins/webplugininfo.h"
61 63
62 using base::DictionaryValue; 64 using base::DictionaryValue;
63 using base::ListValue; 65 using base::ListValue;
64 using content::BrowserContext; 66 using content::BrowserContext;
65 using content::BrowserThread; 67 using content::BrowserThread;
66 using content::PluginService; 68 using content::PluginService;
67 using content::UserMetricsAction; 69 using content::UserMetricsAction;
70 using extensions::app_file_handler_util::FindFileHandlersForFiles;
71 using extensions::app_file_handler_util::PathAndMimeTypeSet;
68 using extensions::Extension; 72 using extensions::Extension;
69 using file_handler_util::FileTaskExecutor; 73 using file_handler_util::FileTaskExecutor;
70 using fileapi::FileSystemURL; 74 using fileapi::FileSystemURL;
71 75
72 const char kFileBrowserDomain[] = "hhaomjibdihmijegdhdafkllkbggdgoj"; 76 const char kFileBrowserDomain[] = "hhaomjibdihmijegdhdafkllkbggdgoj";
73 77
74 const char kFileBrowserGalleryTaskId[] = "gallery"; 78 const char kFileBrowserGalleryTaskId[] = "gallery";
75 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; 79 const char kFileBrowserMountArchiveTaskId[] = "mount-archive";
76 const char kFileBrowserWatchTaskId[] = "watch"; 80 const char kFileBrowserWatchTaskId[] = "watch";
77 const char kFileBrowserPlayTaskId[] = "play"; 81 const char kFileBrowserPlayTaskId[] = "play";
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (!external_provider) 311 if (!external_provider)
308 return false; 312 return false;
309 external_provider->GrantFullAccessToExtension(GetFileBrowserUrl().host()); 313 external_provider->GrantFullAccessToExtension(GetFileBrowserUrl().host());
310 return true; 314 return true;
311 } 315 }
312 316
313 // Executes handler specifed with |extension_id| and |action_id| for |url|. 317 // Executes handler specifed with |extension_id| and |action_id| for |url|.
314 void ExecuteHandler(Profile* profile, 318 void ExecuteHandler(Profile* profile,
315 std::string extension_id, 319 std::string extension_id,
316 std::string action_id, 320 std::string action_id,
317 const GURL& url) { 321 const GURL& url,
322 const std::string& task_type) {
318 // If File Browser has not been open yet then it did not request access 323 // If File Browser has not been open yet then it did not request access
319 // to the file system. Do it now. 324 // to the file system. Do it now.
320 if (!GrantFileSystemAccessToFileBrowser(profile)) 325 if (!GrantFileSystemAccessToFileBrowser(profile))
321 return; 326 return;
322 327
323 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()-> 328 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()->
324 GetSiteForExtensionId(kFileBrowserDomain); 329 GetSiteForExtensionId(kFileBrowserDomain);
325 fileapi::FileSystemContext* file_system_context = 330 fileapi::FileSystemContext* file_system_context =
326 BrowserContext::GetStoragePartitionForSite(profile, site)-> 331 BrowserContext::GetStoragePartitionForSite(profile, site)->
327 GetFileSystemContext(); 332 GetFileSystemContext();
328 333
329 // We are executing the task on behalf of File Browser extension. 334 // We are executing the task on behalf of File Browser extension.
330 const GURL source_url = GetFileBrowserUrl(); 335 const GURL source_url = GetFileBrowserUrl();
331 std::vector<FileSystemURL> urls; 336 std::vector<FileSystemURL> urls;
332 urls.push_back(file_system_context->CrackURL(url)); 337 urls.push_back(file_system_context->CrackURL(url));
333 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create(profile, 338 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create(profile,
334 source_url, kFileBrowserDomain, 0 /* no tab id */, extension_id, 339 source_url, kFileBrowserDomain, 0 /* no tab id */, extension_id,
335 file_handler_util::kTaskFile, action_id); 340 task_type, action_id);
336 executor->Execute(urls); 341 executor->Execute(urls);
337 } 342 }
338 343
339 // The |mode| argument is only for legacy Files.app. Files.app V2 has the 344 // The |mode| argument is only for legacy Files.app. Files.app V2 has the
340 // reusing logic in background.js. 345 // reusing logic in background.js.
341 void OpenFileBrowserImpl(const base::FilePath& path, 346 void OpenFileBrowserImpl(const base::FilePath& path,
342 TAB_REUSE_MODE mode, 347 TAB_REUSE_MODE mode,
343 const std::string& action_id) { 348 const std::string& action_id) {
344 content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); 349 content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab"));
345 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 350 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
346 351
347 if (IsFileManagerPackaged() && !path.value().empty()) { 352 if (IsFileManagerPackaged() && !path.value().empty()) {
348 GURL url; 353 GURL url;
349 if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) 354 if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url))
350 return; 355 return;
351 356
352 // Some values of |action_id| are not listed in the manifest and are used 357 // Some values of |action_id| are not listed in the manifest and are used
353 // to parametrize the behavior when opening the Files app window. 358 // to parametrize the behavior when opening the Files app window.
354 ExecuteHandler(profile, kFileBrowserDomain, action_id, url); 359 ExecuteHandler(profile, kFileBrowserDomain, action_id, url,
360 file_handler_util::kTaskFile);
355 return; 361 return;
356 } 362 }
357 363
358 if (FileManagerTabExists(path, mode)) 364 if (FileManagerTabExists(path, mode))
359 return; 365 return;
360 366
361 std::string url = chrome::kChromeUIFileManagerURL; 367 std::string url = chrome::kChromeUIFileManagerURL;
362 if (action_id.size()) { 368 if (action_id.size()) {
363 DictionaryValue arg_value; 369 DictionaryValue arg_value;
364 arg_value.SetString("action", action_id); 370 arg_value.SetString("action", action_id);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 for (int idx = 0; idx < tab_strip->count(); idx++) { 408 for (int idx = 0; idx < tab_strip->count(); idx++) {
403 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); 409 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx);
404 const GURL& url = web_contents->GetURL(); 410 const GURL& url = web_contents->GetURL();
405 if (url == target_url) 411 if (url == target_url)
406 return browser; 412 return browser;
407 } 413 }
408 } 414 }
409 return NULL; 415 return NULL;
410 } 416 }
411 417
412 bool ExecuteDefaultHandler(Profile* profile, const base::FilePath& path) { 418 bool ExecuteDefaultAppHandler(Profile* profile,
413 GURL url; 419 const base::FilePath& path,
414 if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url)) 420 const GURL& url,
421 const std::string& mime_type,
422 const std::string& default_task_id) {
423 ExtensionService* service = profile->GetExtensionService();
424 if (!service)
415 return false; 425 return false;
416 426
417 const FileBrowserHandler* handler; 427 PathAndMimeTypeSet files;
418 if (!file_handler_util::GetTaskForURLAndPath(profile, url, path, &handler)) 428 files.insert(std::make_pair(path, mime_type));
419 return false; 429 const extensions::FileHandlerInfo* first_handler = NULL;
430 const extensions::Extension* extension_for_first_handler = NULL;
420 431
421 std::string extension_id = handler->extension_id(); 432 // If we find the default handler, we execute it immediately, but otherwise,
422 std::string action_id = handler->id(); 433 // we remember the first handler, and if there was no default handler, simply
434 // execute the first one.
435 for (ExtensionSet::const_iterator iter = service->extensions()->begin();
436 iter != service->extensions()->end();
437 ++iter) {
438 const Extension* extension = *iter;
439
440 // We don't support using hosted apps to open files.
mtomasz 2013/06/07 02:36:00 This comment is misleading. is_platform_app disall
Sam McNally 2013/06/07 05:29:13 This is copied from the check in file_manager_priv
441 if (!extension->is_platform_app())
442 continue;
443
444 // We only support apps that specify "incognito: split" if in incognito
mtomasz 2013/06/07 02:36:00 I'm wondering if this behavior is documented somew
Sam McNally 2013/06/07 05:29:13 Same as above. This check may be unnecessary thoug
445 // mode.
446 if (profile->IsOffTheRecord() &&
447 !service->IsIncognitoEnabled(extension->id()))
448 continue;
449
450 typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList;
451 FileHandlerList file_handlers = FindFileHandlersForFiles(*extension, files);
452 for (FileHandlerList::iterator i = file_handlers.begin();
453 i != file_handlers.end(); ++i) {
454 const extensions::FileHandlerInfo* handler = *i;
455 std::string task_id = file_handler_util::MakeTaskID(extension->id(),
456 file_handler_util::kTaskApp, handler->id);
457 if (task_id == default_task_id) {
458 ExecuteHandler(profile, extension->id(), handler->id, url,
459 file_handler_util::kTaskApp);
460 return true;
461
462 } else if (!first_handler) {
463 first_handler = handler;
464 extension_for_first_handler = extension;
465 }
466 }
467 }
468 if (first_handler) {
469 ExecuteHandler(profile, extension_for_first_handler->id(),
470 first_handler->id, url, file_handler_util::kTaskApp);
471 return true;
472 }
473 return false;
474 }
475
476 bool ExecuteExtensionHandler(Profile* profile,
477 const base::FilePath& path,
478 const FileBrowserHandler& handler,
479 const GURL& url) {
480 std::string extension_id = handler.extension_id();
481 std::string action_id = handler.id();
423 Browser* browser = chrome::FindLastActiveWithProfile(profile, 482 Browser* browser = chrome::FindLastActiveWithProfile(profile,
424 chrome::HOST_DESKTOP_TYPE_ASH); 483 chrome::HOST_DESKTOP_TYPE_ASH);
425 484
426 // If there is no browsers for the profile, bail out. Return true so warning 485 // If there is no browsers for the profile, bail out. Return true so warning
427 // about file type not being supported is not displayed. 486 // about file type not being supported is not displayed.
428 if (!browser) 487 if (!browser)
429 return true; 488 return true;
430 489
431 if (extension_id == kFileBrowserDomain) { 490 if (extension_id == kFileBrowserDomain) {
432 if (IsFileManagerPackaged()) { 491 if (IsFileManagerPackaged()) {
433 if (action_id == kFileBrowserGalleryTaskId || 492 if (action_id == kFileBrowserGalleryTaskId ||
434 action_id == kFileBrowserMountArchiveTaskId || 493 action_id == kFileBrowserMountArchiveTaskId ||
435 action_id == kFileBrowserPlayTaskId || 494 action_id == kFileBrowserPlayTaskId ||
436 action_id == kFileBrowserWatchTaskId) { 495 action_id == kFileBrowserWatchTaskId) {
437 ExecuteHandler(profile, extension_id, action_id, url); 496 ExecuteHandler(profile, extension_id, action_id, url,
497 file_handler_util::kTaskFile);
438 return true; 498 return true;
439 } 499 }
440 return ExecuteBuiltinHandler(browser, path, action_id); 500 return ExecuteBuiltinHandler(browser, path, action_id);
441 } 501 }
442 502
443 // Only two of the built-in File Browser tasks require opening the File 503 // Only two of the built-in File Browser tasks require opening the File
444 // Browser tab. 504 // Browser tab.
445 if (action_id == kFileBrowserGalleryTaskId || 505 if (action_id == kFileBrowserGalleryTaskId ||
446 action_id == kFileBrowserMountArchiveTaskId) { 506 action_id == kFileBrowserMountArchiveTaskId) {
447 // Tab reuse currently does not work for these two tasks. 507 // Tab reuse currently does not work for these two tasks.
448 // |gallery| tries to put the file url into the tab url but it does not 508 // |gallery| tries to put the file url into the tab url but it does not
449 // work on Chrome OS. 509 // work on Chrome OS.
450 // |mount-archive| does not even try. 510 // |mount-archive| does not even try.
451 OpenFileBrowserImpl(path, REUSE_SAME_PATH, ""); 511 OpenFileBrowserImpl(path, REUSE_SAME_PATH, "");
452 return true; 512 return true;
453 } 513 }
454 return ExecuteBuiltinHandler(browser, path, action_id); 514 return ExecuteBuiltinHandler(browser, path, action_id);
455 } 515 }
456 516
457 ExecuteHandler(profile, extension_id, action_id, url); 517 ExecuteHandler(profile, extension_id, action_id, url,
518 file_handler_util::kTaskFile);
458 return true; 519 return true;
459 } 520 }
460 521
522 bool ExecuteDefaultHandler(Profile* profile, const base::FilePath& path) {
523 GURL url;
524 if (!ConvertFileToFileSystemUrl(profile, path, kFileBrowserDomain, &url))
525 return false;
526
527 std::string mime_type = GetMimeTypeForPath(path);
528 std::string default_task_id = file_handler_util::GetDefaultTaskIdFromPrefs(
529 profile, mime_type, path.Extension());
530 const FileBrowserHandler* handler;
531
532 // We choose the file handler from the following in decreasing priority or
533 // fail if none support the file type:
534 // 1. default extension
mtomasz 2013/06/07 02:36:00 default extensions before apps, but non-default ap
Sam McNally 2013/06/07 05:29:13 Yes, but there can be at most one default handler.
535 // 2. default app
536 // 3. a fallback handler (e.g. opening in the browser)
537 // 4. non-default app
538 // 5. non-default extension
539 // Note that there can be at most one of default extension and default app.
540 if (!file_handler_util::GetTaskForURLAndPath(profile, url, path, &handler)) {
541 return ExecuteDefaultAppHandler(
542 profile, path, url, mime_type, default_task_id);
543 }
544
545 std::string handler_task_id = file_handler_util::MakeTaskID(
546 handler->extension_id(), file_handler_util::kTaskFile, handler->id());
547 if (handler_task_id != default_task_id &&
548 !file_handler_util::IsFallbackTask(handler) &&
549 ExecuteDefaultAppHandler(
550 profile, path, url, mime_type, default_task_id)) {
551 return true;
552 }
553 return ExecuteExtensionHandler(profile, path, *handler, url);
554 }
555
461 // Reads the alternate URL from a GDoc file. When it fails, returns a file URL 556 // Reads the alternate URL from a GDoc file. When it fails, returns a file URL
462 // for |file_path| as fallback. 557 // for |file_path| as fallback.
463 // Note that an alternate url is a URL to open a hosted document. 558 // Note that an alternate url is a URL to open a hosted document.
464 GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) { 559 GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) {
465 GURL url = drive::util::ReadUrlFromGDocFile(file_path); 560 GURL url = drive::util::ReadUrlFromGDocFile(file_path);
466 if (url.is_empty()) 561 if (url.is_empty())
467 url = net::FilePathToFileURL(file_path); 562 url = net::FilePathToFileURL(file_path);
468 return url; 563 return url;
469 } 564 }
470 565
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 977
883 // If a bundled plugin is enabled, we should open pdf/swf files in a tab. 978 // If a bundled plugin is enabled, we should open pdf/swf files in a tab.
884 bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension) { 979 bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension) {
885 if (LowerCaseEqualsASCII(file_extension, kPdfExtension)) 980 if (LowerCaseEqualsASCII(file_extension, kPdfExtension))
886 return IsPdfPluginEnabled(profile); 981 return IsPdfPluginEnabled(profile);
887 if (LowerCaseEqualsASCII(file_extension, kSwfExtension)) 982 if (LowerCaseEqualsASCII(file_extension, kSwfExtension))
888 return IsFlashPluginEnabled(profile); 983 return IsFlashPluginEnabled(profile);
889 return false; 984 return false;
890 } 985 }
891 986
987 std::string GetMimeTypeForPath(const base::FilePath& file_path) {
988 const base::FilePath::StringType file_extension =
989 StringToLowerASCII(file_path.Extension());
990
991 // TODO(thorogood): Rearchitect this call so it can run on the File thread;
992 // GetMimeTypeFromFile requires this on Linux. Right now, we use
993 // Chrome-level knowledge only.
994 std::string mime_type;
995 if (file_extension.empty() ||
996 !net::GetWellKnownMimeTypeFromExtension(file_extension.substr(1),
997 &mime_type)) {
998 // If the file doesn't have an extension or its mime-type cannot be
999 // determined, then indicate that it has the empty mime-type. This will
1000 // only be matched if the Web Intents accepts "*" or "*/*".
1001 return "";
1002 } else {
1003 return mime_type;
1004 }
1005 }
1006
892 } // namespace file_manager_util 1007 } // namespace file_manager_util
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_manager/file_manager_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698