| 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/ui/webui/feedback_ui.h" | 5 #include "chrome/browser/ui/webui/feedback_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/files/file_enumerator.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/time.h" | 20 #include "base/time.h" |
| 20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 698 |
| 698 #if defined(OS_CHROMEOS) | 699 #if defined(OS_CHROMEOS) |
| 699 // static | 700 // static |
| 700 void FeedbackUI::GetMostRecentScreenshots( | 701 void FeedbackUI::GetMostRecentScreenshots( |
| 701 const base::FilePath& filepath, | 702 const base::FilePath& filepath, |
| 702 std::vector<std::string>* saved_screenshots, | 703 std::vector<std::string>* saved_screenshots, |
| 703 size_t max_saved) { | 704 size_t max_saved) { |
| 704 std::string pattern = | 705 std::string pattern = |
| 705 std::string(ScreenshotSource::kScreenshotPrefix) + "*" + | 706 std::string(ScreenshotSource::kScreenshotPrefix) + "*" + |
| 706 ScreenshotSource::kScreenshotSuffix; | 707 ScreenshotSource::kScreenshotSuffix; |
| 707 file_util::FileEnumerator screenshots(filepath, false, | 708 base::FileEnumerator screenshots(filepath, false, |
| 708 file_util::FileEnumerator::FILES, | 709 base::FileEnumerator::FILES, pattern); |
| 709 pattern); | |
| 710 base::FilePath screenshot = screenshots.Next(); | 710 base::FilePath screenshot = screenshots.Next(); |
| 711 | 711 |
| 712 std::vector<std::string> screenshot_filepaths; | 712 std::vector<std::string> screenshot_filepaths; |
| 713 while (!screenshot.empty()) { | 713 while (!screenshot.empty()) { |
| 714 screenshot_filepaths.push_back(screenshot.BaseName().value()); | 714 screenshot_filepaths.push_back(screenshot.BaseName().value()); |
| 715 screenshot = screenshots.Next(); | 715 screenshot = screenshots.Next(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); | 718 size_t sort_size = std::min(max_saved, screenshot_filepaths.size()); |
| 719 std::partial_sort(screenshot_filepaths.begin(), | 719 std::partial_sort(screenshot_filepaths.begin(), |
| 720 screenshot_filepaths.begin() + sort_size, | 720 screenshot_filepaths.begin() + sort_size, |
| 721 screenshot_filepaths.end(), | 721 screenshot_filepaths.end(), |
| 722 ScreenshotTimestampComp); | 722 ScreenshotTimestampComp); |
| 723 for (size_t i = 0; i < sort_size; ++i) | 723 for (size_t i = 0; i < sort_size; ++i) |
| 724 saved_screenshots->push_back( | 724 saved_screenshots->push_back( |
| 725 std::string(ScreenshotSource::kScreenshotUrlRoot) + | 725 std::string(ScreenshotSource::kScreenshotUrlRoot) + |
| 726 std::string(ScreenshotSource::kScreenshotSaved) + | 726 std::string(ScreenshotSource::kScreenshotSaved) + |
| 727 screenshot_filepaths[i]); | 727 screenshot_filepaths[i]); |
| 728 } | 728 } |
| 729 #endif | 729 #endif |
| OLD | NEW |