| 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/ash/screenshot_taker.h" | 5 #include "chrome/browser/ui/ash/screenshot_taker.h" |
| 6 | 6 |
| 7 #include <climits> | 7 #include <climits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 public: | 120 public: |
| 121 ScreenshotTakerNotificationDelegate(bool success, | 121 ScreenshotTakerNotificationDelegate(bool success, |
| 122 Profile* profile, | 122 Profile* profile, |
| 123 const base::FilePath& screenshot_path) | 123 const base::FilePath& screenshot_path) |
| 124 : success_(success), | 124 : success_(success), |
| 125 profile_(profile), | 125 profile_(profile), |
| 126 screenshot_path_(screenshot_path) { | 126 screenshot_path_(screenshot_path) { |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Overridden from NotificationDelegate: | 129 // Overridden from NotificationDelegate: |
| 130 virtual void Display() override {} | 130 void Display() override {} |
| 131 virtual void Error() override {} | 131 void Error() override {} |
| 132 virtual void Close(bool by_user) override {} | 132 void Close(bool by_user) override {} |
| 133 virtual void Click() override { | 133 void Click() override { |
| 134 if (!success_) | 134 if (!success_) |
| 135 return; | 135 return; |
| 136 #if defined(OS_CHROMEOS) | 136 #if defined(OS_CHROMEOS) |
| 137 file_manager::util::ShowItemInFolder(profile_, screenshot_path_); | 137 file_manager::util::ShowItemInFolder(profile_, screenshot_path_); |
| 138 #else | 138 #else |
| 139 // TODO(sschmitz): perhaps add similar action for Windows. | 139 // TODO(sschmitz): perhaps add similar action for Windows. |
| 140 #endif | 140 #endif |
| 141 } | 141 } |
| 142 virtual void ButtonClick(int button_index) override { | 142 void ButtonClick(int button_index) override { |
| 143 DCHECK(success_ && button_index == 0); | 143 DCHECK(success_ && button_index == 0); |
| 144 | 144 |
| 145 // To avoid keeping the screenshot image on memory, it will re-read the | 145 // To avoid keeping the screenshot image on memory, it will re-read the |
| 146 // screenshot file and copy it to the clipboard. | 146 // screenshot file and copy it to the clipboard. |
| 147 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
| 148 if (drive::util::IsUnderDriveMountPoint(screenshot_path_)) { | 148 if (drive::util::IsUnderDriveMountPoint(screenshot_path_)) { |
| 149 drive::FileSystemInterface* file_system = | 149 drive::FileSystemInterface* file_system = |
| 150 drive::util::GetFileSystemByProfile(profile_); | 150 drive::util::GetFileSystemByProfile(profile_); |
| 151 file_system->GetFile( | 151 file_system->GetFile( |
| 152 drive::util::ExtractDrivePath(screenshot_path_), | 152 drive::util::ExtractDrivePath(screenshot_path_), |
| 153 base::Bind(&ReadFileAndCopyToClipboardDrive)); | 153 base::Bind(&ReadFileAndCopyToClipboardDrive)); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 #endif | 156 #endif |
| 157 content::BrowserThread::GetBlockingPool()->PostTask( | 157 content::BrowserThread::GetBlockingPool()->PostTask( |
| 158 FROM_HERE, base::Bind( | 158 FROM_HERE, base::Bind( |
| 159 &ReadFileAndCopyToClipboardLocal, screenshot_path_)); | 159 &ReadFileAndCopyToClipboardLocal, screenshot_path_)); |
| 160 } | 160 } |
| 161 virtual bool HasClickedListener() override { return success_; } | 161 bool HasClickedListener() override { return success_; } |
| 162 virtual std::string id() const override { | 162 std::string id() const override { return std::string(kNotificationId); } |
| 163 return std::string(kNotificationId); | |
| 164 } | |
| 165 | 163 |
| 166 private: | 164 private: |
| 167 virtual ~ScreenshotTakerNotificationDelegate() {} | 165 ~ScreenshotTakerNotificationDelegate() override {} |
| 168 | 166 |
| 169 const bool success_; | 167 const bool success_; |
| 170 Profile* profile_; | 168 Profile* profile_; |
| 171 const base::FilePath screenshot_path_; | 169 const base::FilePath screenshot_path_; |
| 172 | 170 |
| 173 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerNotificationDelegate); | 171 DISALLOW_COPY_AND_ASSIGN(ScreenshotTakerNotificationDelegate); |
| 174 }; | 172 }; |
| 175 | 173 |
| 176 typedef base::Callback< | 174 typedef base::Callback< |
| 177 void(ScreenshotTakerObserver::Result screenshot_result, | 175 void(ScreenshotTakerObserver::Result screenshot_result, |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 621 } |
| 624 | 622 |
| 625 void ScreenshotTaker::SetScreenshotBasenameForTest( | 623 void ScreenshotTaker::SetScreenshotBasenameForTest( |
| 626 const std::string& basename) { | 624 const std::string& basename) { |
| 627 screenshot_basename_for_test_ = basename; | 625 screenshot_basename_for_test_ = basename; |
| 628 } | 626 } |
| 629 | 627 |
| 630 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 628 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
| 631 profile_for_test_ = profile; | 629 profile_for_test_ = profile; |
| 632 } | 630 } |
| OLD | NEW |