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 virtual void Display() override {} |
131 virtual void Error() OVERRIDE {} | 131 virtual void Error() override {} |
132 virtual void Close(bool by_user) OVERRIDE {} | 132 virtual void Close(bool by_user) override {} |
133 virtual void Click() OVERRIDE { | 133 virtual 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 virtual 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 virtual bool HasClickedListener() override { return success_; } |
162 virtual std::string id() const OVERRIDE { | 162 virtual std::string id() const override { |
163 return std::string(kNotificationId); | 163 return std::string(kNotificationId); |
164 } | 164 } |
165 virtual content::WebContents* GetWebContents() const OVERRIDE { | 165 virtual content::WebContents* GetWebContents() const override { |
166 return NULL; | 166 return NULL; |
167 } | 167 } |
168 | 168 |
169 private: | 169 private: |
170 virtual ~ScreenshotTakerNotificationDelegate() {} | 170 virtual ~ScreenshotTakerNotificationDelegate() {} |
171 | 171 |
172 const bool success_; | 172 const bool success_; |
173 Profile* profile_; | 173 Profile* profile_; |
174 const base::FilePath screenshot_path_; | 174 const base::FilePath screenshot_path_; |
175 | 175 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 } | 625 } |
626 | 626 |
627 void ScreenshotTaker::SetScreenshotBasenameForTest( | 627 void ScreenshotTaker::SetScreenshotBasenameForTest( |
628 const std::string& basename) { | 628 const std::string& basename) { |
629 screenshot_basename_for_test_ = basename; | 629 screenshot_basename_for_test_ = basename; |
630 } | 630 } |
631 | 631 |
632 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 632 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
633 profile_for_test_ = profile; | 633 profile_for_test_ = profile; |
634 } | 634 } |
OLD | NEW |