Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: chrome/browser/ui/ash/chrome_screenshot_grabber.cc

Issue 1827323002: Take screenshot of active window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/system_notifier.h" 10 #include "ash/system/system_notifier.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 base::FilePath()); 344 base::FilePath());
345 return; 345 return;
346 } 346 }
347 347
348 base::FilePath screenshot_path = 348 base::FilePath screenshot_path =
349 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png"); 349 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png");
350 screenshot_grabber_->TakeScreenshot(window, rect, screenshot_path); 350 screenshot_grabber_->TakeScreenshot(window, rect, screenshot_path);
351 content::RecordAction(base::UserMetricsAction("Screenshot_TakePartial")); 351 content::RecordAction(base::UserMetricsAction("Screenshot_TakePartial"));
352 } 352 }
353 353
354 void ChromeScreenshotGrabber::HandleTakeWindowScreenshot(aura::Window* window) {
355 if (ScreenshotsDisabled()) {
356 screenshot_grabber_->NotifyScreenshotCompleted(
357 ui::ScreenshotGrabberObserver::SCREENSHOTS_DISABLED, base::FilePath());
358 return;
359 }
360
361 base::FilePath screenshot_directory;
362 if (!GetScreenshotDirectory(&screenshot_directory)) {
363 screenshot_grabber_->NotifyScreenshotCompleted(
364 ui::ScreenshotGrabberObserver::SCREENSHOT_GET_DIR_FAILED,
365 base::FilePath());
366 return;
367 }
368
369 base::FilePath screenshot_path =
370 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png");
371 screenshot_grabber_->TakeScreenshot(window,
372 gfx::Rect(window->bounds().size()),
373 screenshot_path);
374 content::RecordAction(base::UserMetricsAction("Screenshot_TakeWindow"));
375 }
376
354 bool ChromeScreenshotGrabber::CanTakeScreenshot() { 377 bool ChromeScreenshotGrabber::CanTakeScreenshot() {
355 return screenshot_grabber_->CanTakeScreenshot(); 378 return screenshot_grabber_->CanTakeScreenshot();
356 } 379 }
357 380
358 void ChromeScreenshotGrabber::PrepareFileAndRunOnBlockingPool( 381 void ChromeScreenshotGrabber::PrepareFileAndRunOnBlockingPool(
359 const base::FilePath& path, 382 const base::FilePath& path,
360 scoped_refptr<base::TaskRunner> blocking_task_runner, 383 scoped_refptr<base::TaskRunner> blocking_task_runner,
361 const FileCallback& callback) { 384 const FileCallback& callback) {
362 #if defined(OS_CHROMEOS) 385 #if defined(OS_CHROMEOS)
363 Profile* profile = ProfileManager::GetActiveUserProfile(); 386 Profile* profile = ProfileManager::GetActiveUserProfile();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 #endif 454 #endif
432 455
433 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { 456 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) {
434 profile_for_test_ = profile; 457 profile_for_test_ = profile;
435 } 458 }
436 459
437 Profile* ChromeScreenshotGrabber::GetProfile() { 460 Profile* ChromeScreenshotGrabber::GetProfile() {
438 return profile_for_test_ ? profile_for_test_ 461 return profile_for_test_ ? profile_for_test_
439 : ProfileManager::GetActiveUserProfile(); 462 : ProfileManager::GetActiveUserProfile();
440 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698