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

Side by Side Diff: chrome/test/base/ui_test_utils_win.cc

Issue 10692110: screenshot disabling policy (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comments (4) 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/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool succeeded = false; 117 bool succeeded = false;
118 FilePath out_path(GetSnapshotFileName(directory)); 118 FilePath out_path(GetSnapshotFileName(directory));
119 119
120 MONITORINFO monitor_info = {}; 120 MONITORINFO monitor_info = {};
121 monitor_info.cbSize = sizeof(monitor_info); 121 monitor_info.cbSize = sizeof(monitor_info);
122 HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY); 122 HMONITOR main_monitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
123 if (GetMonitorInfo(main_monitor, &monitor_info)) { 123 if (GetMonitorInfo(main_monitor, &monitor_info)) {
124 RECT& rect = monitor_info.rcMonitor; 124 RECT& rect = monitor_info.rcMonitor;
125 125
126 std::vector<unsigned char> png_data; 126 std::vector<unsigned char> png_data;
127 if (browser::GrabWindowSnapshot(NULL, &png_data, 127 if (browser::GrabWindowSnapshotIfPermitted(NULL, &png_data,
Mattias Nissler (ping if slow) 2012/07/16 10:47:38 nit: I think this would become a little more reada
qfel 2012/07/17 13:33:43 No longer applicable.
128 gfx::Rect(rect.right - rect.left, 128 gfx::Rect(
129 rect.bottom - rect.top)) && 129 rect.right - rect.left,
130 rect.bottom - rect.top)) &&
130 png_data.size() <= INT_MAX) { 131 png_data.size() <= INT_MAX) {
131 int bytes = static_cast<int>(png_data.size()); 132 int bytes = static_cast<int>(png_data.size());
132 int written = file_util::WriteFile( 133 int written = file_util::WriteFile(
133 out_path, reinterpret_cast<char*>(&png_data[0]), bytes); 134 out_path, reinterpret_cast<char*>(&png_data[0]), bytes);
134 succeeded = (written == bytes); 135 succeeded = (written == bytes);
135 } 136 }
136 } 137 }
137 138
138 if (succeeded && screenshot_path != NULL) 139 if (succeeded && screenshot_path != NULL)
139 *screenshot_path = out_path; 140 *screenshot_path = out_path;
140 141
141 return succeeded; 142 return succeeded;
142 } 143 }
143 144
144 bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) { 145 bool SaveScreenSnapshotToDesktop(FilePath* screenshot_path) {
145 FilePath desktop; 146 FilePath desktop;
146 147
147 return PathService::Get(chrome::DIR_USER_DESKTOP, &desktop) && 148 return PathService::Get(chrome::DIR_USER_DESKTOP, &desktop) &&
148 SaveScreenSnapshotToDirectory(desktop, screenshot_path); 149 SaveScreenSnapshotToDirectory(desktop, screenshot_path);
149 } 150 }
150 151
151 } // namespace ui_test_utils 152 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698