| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/common/system/system_notifier.h" | 9 #include "ash/common/system/system_notifier.h" |
| 10 #include "ash/common/system/tray/system_tray_notifier.h" |
| 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/common/wm_shell.h" |
| 10 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 11 #include "base/base64.h" | 14 #include "base/base64.h" |
| 12 #include "base/bind.h" | 15 #include "base/bind.h" |
| 13 #include "base/callback.h" | 16 #include "base/callback.h" |
| 14 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 15 #include "base/i18n/time_formatting.h" | 18 #include "base/i18n/time_formatting.h" |
| 16 #include "base/macros.h" | 19 #include "base/macros.h" |
| 17 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 19 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 NotifierStateTracker* const notifier_state_tracker = | 390 NotifierStateTracker* const notifier_state_tracker = |
| 388 NotifierStateTrackerFactory::GetForProfile(GetProfile()); | 391 NotifierStateTrackerFactory::GetForProfile(GetProfile()); |
| 389 if (notifier_state_tracker->IsNotifierEnabled(message_center::NotifierId( | 392 if (notifier_state_tracker->IsNotifierEnabled(message_center::NotifierId( |
| 390 message_center::NotifierId::SYSTEM_COMPONENT, | 393 message_center::NotifierId::SYSTEM_COMPONENT, |
| 391 ash::system_notifier::kNotifierScreenshot))) { | 394 ash::system_notifier::kNotifierScreenshot))) { |
| 392 std::unique_ptr<Notification> notification( | 395 std::unique_ptr<Notification> notification( |
| 393 CreateNotification(result, screenshot_path)); | 396 CreateNotification(result, screenshot_path)); |
| 394 g_browser_process->notification_ui_manager()->Add(*notification, | 397 g_browser_process->notification_ui_manager()->Add(*notification, |
| 395 GetProfile()); | 398 GetProfile()); |
| 396 } | 399 } |
| 400 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 401 if (wm_shell->maximize_mode_controller() |
| 402 ->IsMaximizeModeWindowManagerEnabled()) |
| 403 wm_shell->system_tray_notifier()->NotifyDidTakeScreenshot(); |
| 397 } | 404 } |
| 398 | 405 |
| 399 Notification* ChromeScreenshotGrabber::CreateNotification( | 406 Notification* ChromeScreenshotGrabber::CreateNotification( |
| 400 ui::ScreenshotGrabberObserver::Result screenshot_result, | 407 ui::ScreenshotGrabberObserver::Result screenshot_result, |
| 401 const base::FilePath& screenshot_path) { | 408 const base::FilePath& screenshot_path) { |
| 402 const std::string notification_id(kNotificationId); | 409 const std::string notification_id(kNotificationId); |
| 403 // We cancel a previous screenshot notification, if any, to ensure we get | 410 // We cancel a previous screenshot notification, if any, to ensure we get |
| 404 // a fresh notification pop-up. | 411 // a fresh notification pop-up. |
| 405 g_browser_process->notification_ui_manager()->CancelById( | 412 g_browser_process->notification_ui_manager()->CancelById( |
| 406 notification_id, NotificationUIManager::GetProfileID(GetProfile())); | 413 notification_id, NotificationUIManager::GetProfileID(GetProfile())); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 429 } | 436 } |
| 430 | 437 |
| 431 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { | 438 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { |
| 432 profile_for_test_ = profile; | 439 profile_for_test_ = profile; |
| 433 } | 440 } |
| 434 | 441 |
| 435 Profile* ChromeScreenshotGrabber::GetProfile() { | 442 Profile* ChromeScreenshotGrabber::GetProfile() { |
| 436 return profile_for_test_ ? profile_for_test_ | 443 return profile_for_test_ ? profile_for_test_ |
| 437 : ProfileManager::GetActiveUserProfile(); | 444 : ProfileManager::GetActiveUserProfile(); |
| 438 } | 445 } |
| OLD | NEW |