Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
| 35 | 35 |
| 36 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/chromeos/drive/file_system_util.h" | 37 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 38 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" | 38 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" |
| 39 #include "chrome/browser/chromeos/login/user_manager.h" | 39 #include "chrome/browser/chromeos/login/user_manager.h" |
| 40 #include "chrome/browser/notifications/desktop_notification_service.h" | 40 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 41 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 41 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 42 #include "chromeos/login/login_state.h" | |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 // The minimum interval between two screenshot commands. It has to be | 46 // The minimum interval between two screenshot commands. It has to be |
| 46 // more than 1000 to prevent the conflict of filenames. | 47 // more than 1000 to prevent the conflict of filenames. |
| 47 const int kScreenshotMinimumIntervalInMS = 1000; | 48 const int kScreenshotMinimumIntervalInMS = 1000; |
| 48 | 49 |
| 49 const char kNotificationId[] = "screenshot"; | 50 const char kNotificationId[] = "screenshot"; |
| 50 | 51 |
| 51 const char kNotificationOriginUrl[] = "chrome://screenshot"; | 52 const char kNotificationOriginUrl[] = "chrome://screenshot"; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME), | 346 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NOTIFIER_SCREENSHOT_NAME), |
| 346 replace_id, | 347 replace_id, |
| 347 new ScreenshotTakerNotificationDelegate(success, screenshot_path)); | 348 new ScreenshotTakerNotificationDelegate(success, screenshot_path)); |
| 348 } | 349 } |
| 349 | 350 |
| 350 void ScreenshotTaker::ShowNotification( | 351 void ScreenshotTaker::ShowNotification( |
| 351 ScreenshotTakerObserver::Result screenshot_result, | 352 ScreenshotTakerObserver::Result screenshot_result, |
| 352 const base::FilePath& screenshot_path) { | 353 const base::FilePath& screenshot_path) { |
| 353 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 354 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 354 #if defined(OS_CHROMEOS) | 355 #if defined(OS_CHROMEOS) |
| 356 // Do not show a notification that a screenshot was taken when it was done | |
| 357 // while no user the login screen. | |
|
James Cook
2013/08/09 20:09:16
nit: Maybe add the "why" here -- because it's conf
Mr4D (OOO till 08-26)
2013/08/09 20:35:45
Done.
| |
| 358 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) | |
| 359 return; | |
| 360 | |
| 355 // TODO(sschmitz): make this work for Windows. | 361 // TODO(sschmitz): make this work for Windows. |
| 356 DesktopNotificationService* const service = | 362 DesktopNotificationService* const service = |
| 357 DesktopNotificationServiceFactory::GetForProfile(GetProfile()); | 363 DesktopNotificationServiceFactory::GetForProfile(GetProfile()); |
| 358 if (service->IsNotifierEnabled( | 364 if (service->IsNotifierEnabled( |
| 359 message_center::NotifierId(message_center::NotifierId::SCREENSHOT))) { | 365 message_center::NotifierId(message_center::NotifierId::SCREENSHOT))) { |
| 360 scoped_ptr<Notification> notification( | 366 scoped_ptr<Notification> notification( |
| 361 CreateNotification(screenshot_result, screenshot_path)); | 367 CreateNotification(screenshot_result, screenshot_path)); |
| 362 g_browser_process->notification_ui_manager()->Add(*notification, | 368 g_browser_process->notification_ui_manager()->Add(*notification, |
| 363 GetProfile()); | 369 GetProfile()); |
| 364 } | 370 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 391 } | 397 } |
| 392 | 398 |
| 393 void ScreenshotTaker::SetScreenshotBasenameForTest( | 399 void ScreenshotTaker::SetScreenshotBasenameForTest( |
| 394 const std::string& basename) { | 400 const std::string& basename) { |
| 395 screenshot_basename_for_test_ = basename; | 401 screenshot_basename_for_test_ = basename; |
| 396 } | 402 } |
| 397 | 403 |
| 398 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 404 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
| 399 profile_for_test_ = profile; | 405 profile_for_test_ = profile; |
| 400 } | 406 } |
| OLD | NEW |