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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_browser_handlers.cc

Issue 589473002: Files.app: Enable externalfile: protocol for MTP volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 6 years, 2 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
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 4
5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h"
6 6
7 #include <algorithm>
8 #include <set>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
9 #include "base/i18n/case_conversion.h" 12 #include "base/i18n/case_conversion.h"
10 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/drive/file_system_util.h" 14 #include "chrome/browser/chromeos/drive/file_system_util.h"
12 #include "chrome/browser/chromeos/file_manager/app_id.h" 15 #include "chrome/browser/chromeos/file_manager/app_id.h"
13 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 16 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
14 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" 17 #include "chrome/browser/chromeos/file_manager/open_with_browser.h"
15 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" 18 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
16 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 GrantCreateReadWriteFile(handler_pid, iter->absolute_path); 426 GrantCreateReadWriteFile(handler_pid, iter->absolute_path);
424 } 427 }
425 } 428 }
426 } 429 }
427 430
428 // Returns true if |extension_id| and |action_id| indicate that the file 431 // Returns true if |extension_id| and |action_id| indicate that the file
429 // currently being handled should be opened with the browser. This function 432 // currently being handled should be opened with the browser. This function
430 // is used to handle certain action IDs of the file manager. 433 // is used to handle certain action IDs of the file manager.
431 bool ShouldBeOpenedWithBrowser(const std::string& extension_id, 434 bool ShouldBeOpenedWithBrowser(const std::string& extension_id,
432 const std::string& action_id) { 435 const std::string& action_id) {
433
434 return (extension_id == kFileManagerAppId && 436 return (extension_id == kFileManagerAppId &&
435 (action_id == "view-pdf" || 437 (action_id == "view-pdf" ||
436 action_id == "view-swf" || 438 action_id == "view-swf" ||
437 action_id == "view-in-browser" || 439 action_id == "view-in-browser" ||
438 action_id == "open-hosted-generic" || 440 action_id == "open-hosted-generic" ||
439 action_id == "open-hosted-gdoc" || 441 action_id == "open-hosted-gdoc" ||
440 action_id == "open-hosted-gsheet" || 442 action_id == "open-hosted-gsheet" ||
441 action_id == "open-hosted-gslides")); 443 action_id == "open-hosted-gslides"));
442 } 444 }
443 445
444 // Opens the files specified by |file_urls| with the browser for |profile|. 446 // Opens the files specified by |file_urls| with the browser for |profile|.
445 // Returns true on success. It's a failure if no files are opened. 447 // Returns true on success. It's a failure if no files are opened.
446 bool OpenFilesWithBrowser(Profile* profile, 448 bool OpenFilesWithBrowser(Profile* profile,
447 const std::vector<FileSystemURL>& file_urls) { 449 const std::vector<FileSystemURL>& file_urls) {
448 int num_opened = 0; 450 int num_opened = 0;
449 for (size_t i = 0; i < file_urls.size(); ++i) { 451 for (size_t i = 0; i < file_urls.size(); ++i) {
450 const FileSystemURL& file_url = file_urls[i]; 452 const FileSystemURL& file_url = file_urls[i];
451 if (chromeos::FileSystemBackend::CanHandleURL(file_url)) { 453 if (chromeos::FileSystemBackend::CanHandleURL(file_url)) {
452 const base::FilePath& file_path = file_url.path(); 454 num_opened += util::OpenFileWithBrowser(profile, file_url) ? 1 : 0;
453 num_opened += util::OpenFileWithBrowser(profile, file_path);
454 } 455 }
455 } 456 }
456 return num_opened > 0; 457 return num_opened > 0;
457 } 458 }
458 459
459 } // namespace 460 } // namespace
460 461
461 bool ExecuteFileBrowserHandler( 462 bool ExecuteFileBrowserHandler(
462 Profile* profile, 463 Profile* profile,
463 const Extension* extension, 464 const Extension* extension,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 if (common_handlers.empty()) 517 if (common_handlers.empty())
517 return FileBrowserHandlerList(); 518 return FileBrowserHandlerList();
518 } 519 }
519 } 520 }
520 521
521 return common_handlers; 522 return common_handlers;
522 } 523 }
523 524
524 } // namespace file_browser_handlers 525 } // namespace file_browser_handlers
525 } // namespace file_manager 526 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698