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

Unified Diff: chrome/browser/ui/views/aura/screenshot_taker.cc

Issue 9570044: Rename chrome/browser/ui/views/{aura => ash}/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/aura/screenshot_taker.cc
diff --git a/chrome/browser/ui/views/aura/screenshot_taker.cc b/chrome/browser/ui/views/aura/screenshot_taker.cc
deleted file mode 100644
index c004e9c736fb66c4022d03da8cd7c0549332872e..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/views/aura/screenshot_taker.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/views/aura/screenshot_taker.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted_memory.h"
-#include "base/stringprintf.h"
-#include "base/time.h"
-#include "chrome/browser/download/download_util.h"
-#include "chrome/browser/ui/window_snapshot/window_snapshot.h"
-#include "content/public/browser/browser_thread.h"
-#include "ui/aura/window.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/login/user_manager.h"
-#endif
-
-namespace {
-std::string GetScreenshotFileName() {
- base::Time::Exploded now;
- base::Time::Now().LocalExplode(&now);
-
- return base::StringPrintf("screenshot-%d%02d%02d-%02d%02d%02d.png",
- now.year, now.month, now.day_of_month,
- now.hour, now.minute, now.second);
-}
-
-// |is_logged_in| is used only for ChromeOS. Otherwise it is always true.
-void SaveScreenshot(bool is_logged_in,
- scoped_refptr<RefCountedBytes> png_data) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
-
- std::string screenshot_filename = GetScreenshotFileName();
- FilePath screenshot_path;
- if (is_logged_in) {
- screenshot_path = download_util::GetDefaultDownloadDirectory().AppendASCII(
- screenshot_filename);
- } else {
- file_util::CreateTemporaryFile(&screenshot_path);
- }
-
- if (static_cast<size_t>(file_util::WriteFile(
- screenshot_path,
- reinterpret_cast<char*>(&(png_data->data()[0])),
- png_data->size())) == png_data->size()) {
- if (!is_logged_in) {
- // We created a temporary file without .png suffix. Rename it
- // here.
- FilePath real_path = screenshot_path.DirName().AppendASCII(
- screenshot_filename);
- if (!file_util::ReplaceFile(screenshot_path, real_path)) {
- LOG(ERROR) << "Failed to rename the file to " << real_path.value();
- }
- }
- } else {
- LOG(ERROR) << "Failed to save to " << screenshot_path.value();
- }
-}
-
-} // namespace
-
-ScreenshotTaker::ScreenshotTaker() {
-}
-
-void ScreenshotTaker::HandleTakePartialScreenshot(
- aura::Window* window, const gfx::Rect& rect) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- scoped_refptr<RefCountedBytes> png_data(new RefCountedBytes);
-
- bool is_logged_in = true;
-#if defined(OS_CHROMEOS)
- is_logged_in = chromeos::UserManager::Get()->user_is_logged_in();
-#endif
-
- if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) {
- content::BrowserThread::PostTask(
- content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&SaveScreenshot, is_logged_in, png_data));
- } else {
- LOG(ERROR) << "Failed to grab the window screenshot";
- }
-}
-
-void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) {
- HandleTakePartialScreenshot(window, window->bounds());
-}
« no previous file with comments | « chrome/browser/ui/views/aura/screenshot_taker.h ('k') | chrome/browser/ui/views/aura/status_area_host_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698