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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } else if (!GetScreenshotDirectory(&screenshot_directory)) { | 336 } else if (!GetScreenshotDirectory(&screenshot_directory)) { |
337 ShowNotification(ScreenshotTakerObserver::SCREENSHOT_GET_DIR_FAILED, | 337 ShowNotification(ScreenshotTakerObserver::SCREENSHOT_GET_DIR_FAILED, |
338 base::FilePath()); | 338 base::FilePath()); |
339 return; | 339 return; |
340 } | 340 } |
341 std::string screenshot_basename = !screenshot_basename_for_test_.empty() ? | 341 std::string screenshot_basename = !screenshot_basename_for_test_.empty() ? |
342 screenshot_basename_for_test_ : GetScreenshotBaseFilename(); | 342 screenshot_basename_for_test_ : GetScreenshotBaseFilename(); |
343 | 343 |
344 ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows(); | 344 ash::Shell::RootWindowList root_windows = ash::Shell::GetAllRootWindows(); |
345 // Reorder root_windows to take the primary root window's snapshot at first. | 345 // Reorder root_windows to take the primary root window's snapshot at first. |
346 aura::RootWindow* primary_root = ash::Shell::GetPrimaryRootWindow(); | 346 aura::Window* primary_root = ash::Shell::GetPrimaryRootWindow(); |
347 if (*(root_windows.begin()) != primary_root) { | 347 if (*(root_windows.begin()) != primary_root) { |
348 root_windows.erase(std::find( | 348 root_windows.erase(std::find( |
349 root_windows.begin(), root_windows.end(), primary_root)); | 349 root_windows.begin(), root_windows.end(), primary_root)); |
350 root_windows.insert(root_windows.begin(), primary_root); | 350 root_windows.insert(root_windows.begin(), primary_root->GetDispatcher()); |
351 } | 351 } |
352 for (size_t i = 0; i < root_windows.size(); ++i) { | 352 for (size_t i = 0; i < root_windows.size(); ++i) { |
353 aura::RootWindow* root_window = root_windows[i]; | 353 aura::RootWindow* root_window = root_windows[i]; |
354 scoped_refptr<base::RefCountedBytes> png_data(new base::RefCountedBytes); | 354 scoped_refptr<base::RefCountedBytes> png_data(new base::RefCountedBytes); |
355 std::string basename = screenshot_basename; | 355 std::string basename = screenshot_basename; |
356 gfx::Rect rect = root_window->bounds(); | 356 gfx::Rect rect = root_window->bounds(); |
357 if (root_windows.size() > 1) | 357 if (root_windows.size() > 1) |
358 basename += base::StringPrintf(" - Display %d", static_cast<int>(i + 1)); | 358 basename += base::StringPrintf(" - Display %d", static_cast<int>(i + 1)); |
359 base::FilePath screenshot_path = | 359 base::FilePath screenshot_path = |
360 screenshot_directory.AppendASCII(basename + ".png"); | 360 screenshot_directory.AppendASCII(basename + ".png"); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 498 } |
499 | 499 |
500 void ScreenshotTaker::SetScreenshotBasenameForTest( | 500 void ScreenshotTaker::SetScreenshotBasenameForTest( |
501 const std::string& basename) { | 501 const std::string& basename) { |
502 screenshot_basename_for_test_ = basename; | 502 screenshot_basename_for_test_ = basename; |
503 } | 503 } |
504 | 504 |
505 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { | 505 void ScreenshotTaker::SetScreenshotProfileForTest(Profile* profile) { |
506 profile_for_test_ = profile; | 506 profile_for_test_ = profile; |
507 } | 507 } |
OLD | NEW |