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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "chromeos/login/login_state.h" | 51 #include "chromeos/login/login_state.h" |
52 #endif | 52 #endif |
53 | 53 |
54 namespace { | 54 namespace { |
55 // The minimum interval between two screenshot commands. It has to be | 55 // The minimum interval between two screenshot commands. It has to be |
56 // more than 1000 to prevent the conflict of filenames. | 56 // more than 1000 to prevent the conflict of filenames. |
57 const int kScreenshotMinimumIntervalInMS = 1000; | 57 const int kScreenshotMinimumIntervalInMS = 1000; |
58 | 58 |
59 const char kNotificationId[] = "screenshot"; | 59 const char kNotificationId[] = "screenshot"; |
60 | 60 |
| 61 #if defined(OS_CHROMEOS) |
61 const char kNotificationOriginUrl[] = "chrome://screenshot"; | 62 const char kNotificationOriginUrl[] = "chrome://screenshot"; |
| 63 #endif |
62 | 64 |
63 const char kImageClipboardFormatPrefix[] = "<img src='data:image/png;base64,"; | 65 const char kImageClipboardFormatPrefix[] = "<img src='data:image/png;base64,"; |
64 const char kImageClipboardFormatSuffix[] = "'>"; | 66 const char kImageClipboardFormatSuffix[] = "'>"; |
65 | 67 |
66 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { | 68 void CopyScreenshotToClipboard(scoped_refptr<base::RefCountedString> png_data) { |
67 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 69 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
68 | 70 |
69 std::string encoded; | 71 std::string encoded; |
70 base::Base64Encode(png_data->data(), &encoded); | 72 base::Base64Encode(png_data->data(), &encoded); |
71 | 73 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 *directory = download_prefs->DownloadPath(); | 354 *directory = download_prefs->DownloadPath(); |
353 } else { | 355 } else { |
354 if (!base::GetTempDir(directory)) { | 356 if (!base::GetTempDir(directory)) { |
355 LOG(ERROR) << "Failed to find temporary directory."; | 357 LOG(ERROR) << "Failed to find temporary directory."; |
356 return false; | 358 return false; |
357 } | 359 } |
358 } | 360 } |
359 return true; | 361 return true; |
360 } | 362 } |
361 | 363 |
| 364 #if defined(OS_CHROMEOS) |
362 const int GetScreenshotNotificationTitle( | 365 const int GetScreenshotNotificationTitle( |
363 ScreenshotTakerObserver::Result screenshot_result) { | 366 ScreenshotTakerObserver::Result screenshot_result) { |
364 switch (screenshot_result) { | 367 switch (screenshot_result) { |
365 case ScreenshotTakerObserver::SCREENSHOTS_DISABLED: | 368 case ScreenshotTakerObserver::SCREENSHOTS_DISABLED: |
366 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_DISABLED; | 369 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_DISABLED; |
367 case ScreenshotTakerObserver::SCREENSHOT_SUCCESS: | 370 case ScreenshotTakerObserver::SCREENSHOT_SUCCESS: |
368 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_SUCCESS; | 371 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_SUCCESS; |
369 default: | 372 default: |
370 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_FAIL; | 373 return IDS_ASH_SCREENSHOT_NOTIFICATION_TITLE_FAIL; |
371 } | 374 } |
372 } | 375 } |
373 | 376 |
374 const int GetScreenshotNotificationText( | 377 const int GetScreenshotNotificationText( |
375 ScreenshotTakerObserver::Result screenshot_result) { | 378 ScreenshotTakerObserver::Result screenshot_result) { |
376 switch (screenshot_result) { | 379 switch (screenshot_result) { |
377 case ScreenshotTakerObserver::SCREENSHOTS_DISABLED: | 380 case ScreenshotTakerObserver::SCREENSHOTS_DISABLED: |
378 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_DISABLED; | 381 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_DISABLED; |
379 case ScreenshotTakerObserver::SCREENSHOT_SUCCESS: | 382 case ScreenshotTakerObserver::SCREENSHOT_SUCCESS: |
380 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_SUCCESS; | 383 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_SUCCESS; |
381 default: | 384 default: |
382 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_FAIL; | 385 return IDS_ASH_SCREENSHOT_NOTIFICATION_TEXT_FAIL; |
383 } | 386 } |
384 } | 387 } |
| 388 #endif |
385 | 389 |
386 } // namespace | 390 } // namespace |
387 | 391 |
388 ScreenshotTaker::ScreenshotTaker() | 392 ScreenshotTaker::ScreenshotTaker() |
389 : factory_(this), | 393 : factory_(this), |
390 profile_for_test_(NULL) { | 394 profile_for_test_(NULL) { |
391 } | 395 } |
392 | 396 |
393 ScreenshotTaker::~ScreenshotTaker() { | 397 ScreenshotTaker::~ScreenshotTaker() { |
394 } | 398 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } | 627 } |
624 | 628 |
625 void ScreenshotTaker::SetScreenshotBasenameForTest( | 629 void ScreenshotTaker::SetScreenshotBasenameForTest( |
626 const std::string& basename) { | 630 const std::string& basename) { |
627 screenshot_basename_for_test_ = basename; | 631 screenshot_basename_for_test_ = basename; |
628 } | 632 } |
629 | 633 |
630 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 634 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
631 profile_for_test_ = profile; | 635 profile_for_test_ = profile; |
632 } | 636 } |
OLD | NEW |