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

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, 9 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 base::FilePath()); 343 base::FilePath());
344 return; 344 return;
345 } 345 }
346 346
347 base::FilePath screenshot_path = 347 base::FilePath screenshot_path =
348 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png"); 348 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png");
349 screenshot_grabber_->TakeScreenshot(window, rect, screenshot_path); 349 screenshot_grabber_->TakeScreenshot(window, rect, screenshot_path);
350 content::RecordAction(base::UserMetricsAction("Screenshot_TakePartial")); 350 content::RecordAction(base::UserMetricsAction("Screenshot_TakePartial"));
351 } 351 }
352 352
353 void ChromeScreenshotGrabber::HandleTakeWindowScreenshot(aura::Window* window) {
354 if (ScreenshotsDisabled()) {
355 screenshot_grabber_->NotifyScreenshotCompleted(
356 ui::ScreenshotGrabberObserver::SCREENSHOTS_DISABLED, base::FilePath());
357 return;
358 }
359
360 base::FilePath screenshot_directory;
361 if (!GetScreenshotDirectory(&screenshot_directory)) {
362 screenshot_grabber_->NotifyScreenshotCompleted(
363 ui::ScreenshotGrabberObserver::SCREENSHOT_GET_DIR_FAILED,
364 base::FilePath());
365 return;
366 }
367
368 base::FilePath screenshot_path =
369 screenshot_directory.AppendASCII(GetScreenshotBaseFilename() + ".png");
370 aura::Window* root_window = window->GetRootWindow();
371 gfx::Rect root_rect = root_window->bounds();
sky 2016/03/25 15:27:53 This code assumes window is a direct child of root
Qiang(Joe) Xu 2016/03/25 19:09:40 GetRootWindow() will get root window, it is not pa
sky 2016/03/25 20:37:08 GetRootWindow() walks up the tree starting at wind
372 screenshot_grabber_->TakeScreenshot(window, root_rect, screenshot_path);
sky 2016/03/25 15:27:53 I'm confused by the coordinates here. You're passi
Qiang(Joe) Xu 2016/03/25 19:09:40 Here we should use the root window's coordinates a
sky 2016/03/25 20:37:08 This is the comment says for the function you're u
Qiang(Joe) Xu 2016/03/25 21:15:54 I get it: My original one is: passing active_windo
sky 2016/03/25 22:58:43 I don't think that's right either. The problem wit
373 content::RecordAction(base::UserMetricsAction("Screenshot_TakeWindow"));
374 }
375
353 bool ChromeScreenshotGrabber::CanTakeScreenshot() { 376 bool ChromeScreenshotGrabber::CanTakeScreenshot() {
354 return screenshot_grabber_->CanTakeScreenshot(); 377 return screenshot_grabber_->CanTakeScreenshot();
355 } 378 }
356 379
357 void ChromeScreenshotGrabber::PrepareFileAndRunOnBlockingPool( 380 void ChromeScreenshotGrabber::PrepareFileAndRunOnBlockingPool(
358 const base::FilePath& path, 381 const base::FilePath& path,
359 scoped_refptr<base::TaskRunner> blocking_task_runner, 382 scoped_refptr<base::TaskRunner> blocking_task_runner,
360 const FileCallback& callback) { 383 const FileCallback& callback) {
361 #if defined(OS_CHROMEOS) 384 #if defined(OS_CHROMEOS)
362 Profile* profile = ProfileManager::GetActiveUserProfile(); 385 Profile* profile = ProfileManager::GetActiveUserProfile();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 #endif 453 #endif
431 454
432 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) { 455 void ChromeScreenshotGrabber::SetProfileForTest(Profile* profile) {
433 profile_for_test_ = profile; 456 profile_for_test_ = profile;
434 } 457 }
435 458
436 Profile* ChromeScreenshotGrabber::GetProfile() { 459 Profile* ChromeScreenshotGrabber::GetProfile() {
437 return profile_for_test_ ? profile_for_test_ 460 return profile_for_test_ ? profile_for_test_
438 : ProfileManager::GetActiveUserProfile(); 461 : ProfileManager::GetActiveUserProfile();
439 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698