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

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 (5) 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;
sky 2012/07/17 22:05:57 This is going to result in a LOG(ERROR) on line 18
qfel 2012/07/18 09:24:27 In any case, I think we should leave GrabWindowSna
122
116 // We use XGetImage() for Linux/ChromeOS for performance reasons. 123 // We use XGetImage() for Linux/ChromeOS for performance reasons.
117 // See crbug.com/119492 124 // See crbug.com/119492
118 // TODO(mukai): remove this when the performance issue has been fixed. 125 // TODO(mukai): remove this when the performance issue has been fixed.
119 if (window->GetRootWindow()->GrabSnapshot(snapshot_bounds, png_data)) 126 if (window->GetRootWindow()->GrabSnapshot(snapshot_bounds, png_data))
120 return true; 127 return true;
121 #endif // OS_LINUX 128 #endif // OS_LINUX
122 129
123 return browser::GrabWindowSnapshot(window, png_data, snapshot_bounds); 130 return browser::GrabWindowSnapshot(window, png_data, snapshot_bounds);
124 } 131 }
125 132
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 ash::internal::kShellWindowId_OverlayContainer)->layer(); 200 ash::internal::kShellWindowId_OverlayContainer)->layer();
194 parent->Add(visual_feedback_layer_.get()); 201 parent->Add(visual_feedback_layer_.get());
195 visual_feedback_layer_->SetVisible(true); 202 visual_feedback_layer_->SetVisible(true);
196 203
197 MessageLoopForUI::current()->PostDelayedTask( 204 MessageLoopForUI::current()->PostDelayedTask(
198 FROM_HERE, 205 FROM_HERE,
199 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer, 206 base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
200 base::Unretained(this)), 207 base::Unretained(this)),
201 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs)); 208 base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
202 } 209 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698