OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ash/chrome_screenshot_grabber.h" | 5 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/system_notifier.h" | 8 #include "ash/system/system_notifier.h" |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/download/download_prefs.h" | 18 #include "chrome/browser/download/download_prefs.h" |
19 #include "chrome/browser/notifications/notification_ui_manager.h" | 19 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 20 #include "chrome/browser/platform_util.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
25 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
26 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
27 #include "ui/base/clipboard/clipboard.h" | 28 #include "ui/base/clipboard/clipboard.h" |
28 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 29 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 Profile* profile, | 108 Profile* profile, |
108 const base::FilePath& screenshot_path) | 109 const base::FilePath& screenshot_path) |
109 : success_(success), | 110 : success_(success), |
110 profile_(profile), | 111 profile_(profile), |
111 screenshot_path_(screenshot_path) {} | 112 screenshot_path_(screenshot_path) {} |
112 | 113 |
113 // Overridden from NotificationDelegate: | 114 // Overridden from NotificationDelegate: |
114 void Click() override { | 115 void Click() override { |
115 if (!success_) | 116 if (!success_) |
116 return; | 117 return; |
117 #if defined(OS_CHROMEOS) | 118 platform_util::ShowItemInFolder(profile_, screenshot_path_); |
118 file_manager::util::ShowItemInFolder(profile_, screenshot_path_); | |
119 #else | |
120 // TODO(sschmitz): perhaps add similar action for Windows. | |
121 #endif | |
122 } | 119 } |
123 void ButtonClick(int button_index) override { | 120 void ButtonClick(int button_index) override { |
124 DCHECK(success_ && button_index == 0); | 121 DCHECK(success_ && button_index == 0); |
125 | 122 |
126 // To avoid keeping the screenshot image on memory, it will re-read the | 123 // To avoid keeping the screenshot image on memory, it will re-read the |
127 // screenshot file and copy it to the clipboard. | 124 // screenshot file and copy it to the clipboard. |
128 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
129 if (drive::util::IsUnderDriveMountPoint(screenshot_path_)) { | 126 if (drive::util::IsUnderDriveMountPoint(screenshot_path_)) { |
130 drive::FileSystemInterface* file_system = | 127 drive::FileSystemInterface* file_system = |
131 drive::util::GetFileSystemByProfile(profile_); | 128 drive::util::GetFileSystemByProfile(profile_); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 #endif | 426 #endif |
430 | 427 |
431 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { | 428 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { |
432 profile_for_test_ = profile; | 429 profile_for_test_ = profile; |
433 } | 430 } |
434 | 431 |
435 Profile* ChromeScreenshotGrabber::GetProfile() { | 432 Profile* ChromeScreenshotGrabber::GetProfile() { |
436 return profile_for_test_ ? profile_for_test_ | 433 return profile_for_test_ ? profile_for_test_ |
437 : ProfileManager::GetActiveUserProfile(); | 434 : ProfileManager::GetActiveUserProfile(); |
438 } | 435 } |
OLD | NEW |