| OLD | NEW |
| 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/extensions/file_manager/file_browser_handlers.
h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handlers.
h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 (action_id == "view-pdf" || | 472 (action_id == "view-pdf" || |
| 473 action_id == "view-swf" || | 473 action_id == "view-swf" || |
| 474 action_id == "view-in-browser" || | 474 action_id == "view-in-browser" || |
| 475 action_id == "install-crx" || | 475 action_id == "install-crx" || |
| 476 action_id == "open-hosted-generic" || | 476 action_id == "open-hosted-generic" || |
| 477 action_id == "open-hosted-gdoc" || | 477 action_id == "open-hosted-gdoc" || |
| 478 action_id == "open-hosted-gsheet" || | 478 action_id == "open-hosted-gsheet" || |
| 479 action_id == "open-hosted-gslides")); | 479 action_id == "open-hosted-gslides")); |
| 480 } | 480 } |
| 481 | 481 |
| 482 // Opens the files specified by |file_urls| with the browser. |profile| is | 482 // Opens the files specified by |file_urls| with the browser for |profile|. |
| 483 // used for finding an active browser. Returns true on success. It's a | 483 // Returns true on success. It's a failure if no files are opened. |
| 484 // failure if no files are opened. | |
| 485 bool OpenFilesWithBrowser(Profile* profile, | 484 bool OpenFilesWithBrowser(Profile* profile, |
| 486 const std::vector<FileSystemURL>& file_urls) { | 485 const std::vector<FileSystemURL>& file_urls) { |
| 487 Browser* browser = chrome::FindLastActiveWithProfile( | |
| 488 profile, | |
| 489 chrome::HOST_DESKTOP_TYPE_ASH); | |
| 490 if (!browser) | |
| 491 return false; | |
| 492 | |
| 493 int num_opened = 0; | 486 int num_opened = 0; |
| 494 for (size_t i = 0; i < file_urls.size(); ++i) { | 487 for (size_t i = 0; i < file_urls.size(); ++i) { |
| 495 const FileSystemURL& file_url = file_urls[i]; | 488 const FileSystemURL& file_url = file_urls[i]; |
| 496 if (chromeos::FileSystemBackend::CanHandleURL(file_url)) { | 489 if (chromeos::FileSystemBackend::CanHandleURL(file_url)) { |
| 497 const base::FilePath& file_path = file_url.path(); | 490 const base::FilePath& file_path = file_url.path(); |
| 498 num_opened += util::OpenFileWithBrowser(browser, file_path); | 491 num_opened += util::OpenFileWithBrowser(profile, file_path); |
| 499 } | 492 } |
| 500 } | 493 } |
| 501 return num_opened > 0; | 494 return num_opened > 0; |
| 502 } | 495 } |
| 503 | 496 |
| 504 } // namespace | 497 } // namespace |
| 505 | 498 |
| 506 bool ExecuteFileBrowserHandler( | 499 bool ExecuteFileBrowserHandler( |
| 507 Profile* profile, | 500 Profile* profile, |
| 508 const Extension* extension, | 501 const Extension* extension, |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 } | 649 } |
| 657 | 650 |
| 658 // If there are no default handlers, use first handler in the list (file | 651 // If there are no default handlers, use first handler in the list (file |
| 659 // manager does the same in this situation). TODO(tbarzic): This is not so | 652 // manager does the same in this situation). TODO(tbarzic): This is not so |
| 660 // optimal behaviour. | 653 // optimal behaviour. |
| 661 return *common_handlers.begin(); | 654 return *common_handlers.begin(); |
| 662 } | 655 } |
| 663 | 656 |
| 664 } // namespace file_browser_handlers | 657 } // namespace file_browser_handlers |
| 665 } // namespace file_manager | 658 } // namespace file_manager |
| OLD | NEW |