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

Side by Side Diff: chrome_frame/test/win_event_receiver.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_frame/test/win_event_receiver.h" 5 #include "chrome_frame/test/win_event_receiver.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/win/object_watcher.h" 9 #include "base/win/object_watcher.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 i = (observer == i->observer) ? observers_.erase(i) : ++i; 162 i = (observer == i->observer) ? observers_.erase(i) : ++i;
163 } 163 }
164 164
165 if (observers_.empty()) 165 if (observers_.empty())
166 win_event_receiver_.StopReceivingEvents(); 166 win_event_receiver_.StopReceivingEvents();
167 } 167 }
168 168
169 std::string WindowWatchdog::GetWindowCaption(HWND hwnd) { 169 std::string WindowWatchdog::GetWindowCaption(HWND hwnd) {
170 std::string caption; 170 std::string caption;
171 int len = ::GetWindowTextLength(hwnd) + 1; 171 int len = ::GetWindowTextLength(hwnd) + 1;
172 ::GetWindowTextA(hwnd, WriteInto(&caption, len), len); 172 if (len > 1)
173 173 ::GetWindowTextA(hwnd, WriteInto(&caption, len), len);
174 return caption; 174 return caption;
175 } 175 }
176 176
177 bool WindowWatchdog::MatchingWindow(const ObserverEntry& entry, 177 bool WindowWatchdog::MatchingWindow(const ObserverEntry& entry,
178 const std::string& caption, 178 const std::string& caption,
179 const std::string& class_name) { 179 const std::string& class_name) {
180 bool should_match_caption = !entry.caption_pattern.empty(); 180 bool should_match_caption = !entry.caption_pattern.empty();
181 bool should_match_class = !entry.class_name_pattern.empty(); 181 bool should_match_class = !entry.class_name_pattern.empty();
182 182
183 if (should_match_caption && 183 if (should_match_caption &&
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 HandleOnOpen(hwnd); 266 HandleOnOpen(hwnd);
267 } else { 267 } else {
268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE); 268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE);
269 HandleOnClose(hwnd); 269 HandleOnClose(hwnd);
270 } 270 }
271 } 271 }
272 272
273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) { 273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) {
274 HandleOnClose(hwnd); 274 HandleOnClose(hwnd);
275 } 275 }
OLDNEW
« no previous file with comments | « chrome_frame/chrome_tab.cc ('k') | chrome_frame/utils.cc » ('j') | crypto/encryptor_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698