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

Side by Side Diff: chrome/browser/ui/views/ash/screenshot_taker.cc

Issue 10692110: screenshot disabling policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments (2), hooking into GrabWindowSnapshot instead of ChromeShellDelegate, rebased on … Created 8 years, 5 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 (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/views/ash/screenshot_taker.h" 5 #include "chrome/browser/ui/views/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"
11 #include "ash/shell_delegate.h" 11 #include "ash/shell_delegate.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/i18n/time_formatting.h" 16 #include "base/i18n/time_formatting.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/ref_counted_memory.h" 18 #include "base/memory/ref_counted_memory.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/download/download_prefs.h" 22 #include "chrome/browser/download/download_prefs.h"
22 #include "chrome/browser/prefs/pref_service.h" 23 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" 26 #include "chrome/browser/ui/window_snapshot/window_snapshot.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "ui/aura/root_window.h" 29 #include "ui/aura/root_window.h"
29 #include "ui/aura/window.h" 30 #include "ui/aura/window.h"
30 31
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 reinterpret_cast<char*>(&(png_data->data()[0])), 107 reinterpret_cast<char*>(&(png_data->data()[0])),
107 png_data->size())) != png_data->size()) { 108 png_data->size())) != png_data->size()) {
108 LOG(ERROR) << "Failed to save to " << screenshot_path.value(); 109 LOG(ERROR) << "Failed to save to " << screenshot_path.value();
109 } 110 }
110 } 111 }
111 112
112 bool GrabWindowSnapshot(aura::Window* window, 113 bool GrabWindowSnapshot(aura::Window* window,
113 const gfx::Rect& snapshot_bounds, 114 const gfx::Rect& snapshot_bounds,
114 std::vector<unsigned char>* png_data) { 115 std::vector<unsigned char>* png_data) {
115 #if defined(OS_LINUX) 116 #if defined(OS_LINUX)
117 // browser::GrabWindowSnapshot checks this too, but RootWindow::GrabSnapshot
118 // does not. The statement below is only to support linux-specific XGetImage
119 // optimization.
120 if (g_browser_process->local_state()->GetBoolean(prefs::kDisableScreenshots))
121 return false;
Mattias Nissler (ping if slow) 2012/07/12 08:59:32 add blank line before comment
qfel 2012/07/12 14:48:06 Done.
116 // We use XGetImage() for Linux/ChromeOS for performance reasons. 122 // We use XGetImage() for Linux/ChromeOS for performance reasons.
117 // See crbug.com/119492 123 // See crbug.com/119492
118 // TODO(mukai): remove this when the performance issue has been fixed. 124 // TODO(mukai): remove this when the performance issue has been fixed.
119 if (window->GetRootWindow()->GrabSnapshot(snapshot_bounds, png_data)) 125 if (window->GetRootWindow()->GrabSnapshot(snapshot_bounds, png_data))
120 return true; 126 return true;
121 #endif // OS_LINUX 127 #endif // OS_LINUX
122 128
123 return browser::GrabWindowSnapshot(window, png_data, snapshot_bounds); 129 return browser::GrabWindowSnapshot(window, png_data, snapshot_bounds);
124 } 130 }
125 131
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 ash::internal::kShellWindowId_OverlayContainer)->layer(); 199 ash::internal::kShellWindowId_OverlayContainer)->layer();
194 parent->Add(visual_feedback_layer_.get()); 200 parent->Add(visual_feedback_layer_.get());
195 visual_feedback_layer_->SetVisible(true); 201 visual_feedback_layer_->SetVisible(true);
196 202
197 MessageLoopForUI::current()->PostDelayedTask( 203 MessageLoopForUI::current()->PostDelayedTask(
198 FROM_HERE, 204 FROM_HERE,
199 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, 205 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
200 base::Unretained(this)), 206 base::Unretained(this)),
201 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); 207 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
202 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698