OLD | NEW |
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 // Implementation of the manager for infobar windows. | 5 // Implementation of the manager for infobar windows. |
6 | 6 |
7 #include "ceee/ie/plugin/bho/infobar_window.h" | 7 #include "ceee/ie/plugin/bho/infobar_window.h" |
8 | 8 |
9 #include <atlapp.h> | 9 #include <atlapp.h> |
10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
(...skipping 23 matching lines...) Expand all Loading... |
34 DCHECK(delegate); | 34 DCHECK(delegate); |
35 return NULL == delegate ? NULL : new InfobarWindow(type, delegate); | 35 return NULL == delegate ? NULL : new InfobarWindow(type, delegate); |
36 } | 36 } |
37 | 37 |
38 InfobarWindow::InfobarWindow(InfobarType type, Delegate* delegate) | 38 InfobarWindow::InfobarWindow(InfobarType type, Delegate* delegate) |
39 : type_(type), | 39 : type_(type), |
40 delegate_(delegate), | 40 delegate_(delegate), |
41 show_(false), | 41 show_(false), |
42 target_height_(1), | 42 target_height_(1), |
43 current_height_(1), | 43 current_height_(1), |
44 sliding_infobar_(false) { | 44 sliding_infobar_(false), |
| 45 timer_id_(0) { |
45 DCHECK(delegate); | 46 DCHECK(delegate); |
46 } | 47 } |
47 | 48 |
48 InfobarWindow::~InfobarWindow() { | 49 InfobarWindow::~InfobarWindow() { |
49 Reset(); | 50 Reset(); |
50 | 51 |
51 if (IsWindow()) { | 52 if (IsWindow()) { |
52 DestroyWindow(); | 53 DestroyWindow(); |
53 } else { | 54 } else { |
54 NOTREACHED() << "Infobar window was not successfully created."; | 55 NOTREACHED() << "Infobar window was not successfully created."; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 target_height_ = 1; | 159 target_height_ = 1; |
159 } | 160 } |
160 } else { | 161 } else { |
161 target_height_ = 1; | 162 target_height_ = 1; |
162 } | 163 } |
163 | 164 |
164 if (!slide || !show) { | 165 if (!slide || !show) { |
165 current_height_ = target_height_; | 166 current_height_ = target_height_; |
166 | 167 |
167 if (sliding_infobar_) { | 168 if (sliding_infobar_) { |
168 KillTimer(kInfobarSlidingTimerId); | 169 KillTimer(timer_id_); |
169 sliding_infobar_ = false; | 170 sliding_infobar_ = false; |
170 } | 171 } |
171 } else { | 172 } else { |
172 // If the infobar is visible and sliding effect is requested, we need to | 173 // If the infobar is visible and sliding effect is requested, we need to |
173 // start expanding/shrinking the infobar according to its current height. | 174 // start expanding/shrinking the infobar according to its current height. |
174 current_height_ = CalculateNextHeight(); | 175 current_height_ = CalculateNextHeight(); |
175 | 176 |
176 if (!sliding_infobar_) { | 177 if (!sliding_infobar_) { |
177 SetTimer(kInfobarSlidingTimerId, kInfobarSlidingTimerIntervalMs, NULL); | 178 // Set timer and store its id (it could be different from the passed one). |
| 179 timer_id_ = SetTimer(kInfobarSlidingTimerId, |
| 180 kInfobarSlidingTimerIntervalMs, NULL); |
178 sliding_infobar_ = true; | 181 sliding_infobar_ = true; |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
182 UpdateLayout(); | 185 UpdateLayout(); |
183 } | 186 } |
184 | 187 |
185 int InfobarWindow::CalculateNextHeight() { | 188 int InfobarWindow::CalculateNextHeight() { |
186 if (current_height_ < target_height_) { | 189 if (current_height_ < target_height_) { |
187 return std::min(current_height_ + kInfobarSlidingStep, target_height_); | 190 return std::min(current_height_ + kInfobarSlidingStep, target_height_); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 return E_POINTER; | 254 return E_POINTER; |
252 | 255 |
253 // Set the size to 0 that means we do not know it. | 256 // Set the size to 0 that means we do not know it. |
254 // TODO(vadimb@google.com): Find how to get the content size from the CF. | 257 // TODO(vadimb@google.com): Find how to get the content size from the CF. |
255 size->cx = 0; | 258 size->cx = 0; |
256 size->cy = 0; | 259 size->cy = 0; |
257 return S_OK; | 260 return S_OK; |
258 } | 261 } |
259 | 262 |
260 LRESULT InfobarWindow::OnTimer(UINT_PTR nIDEvent) { | 263 LRESULT InfobarWindow::OnTimer(UINT_PTR nIDEvent) { |
261 DCHECK(nIDEvent == kInfobarSlidingTimerId); | 264 DCHECK(nIDEvent == timer_id_); |
262 if (show_ && sliding_infobar_ && current_height_ != target_height_) { | 265 if (show_ && sliding_infobar_ && current_height_ != target_height_) { |
263 current_height_ = CalculateNextHeight(); | 266 current_height_ = CalculateNextHeight(); |
264 UpdateLayout(); | 267 UpdateLayout(); |
265 } else if (sliding_infobar_) { | 268 } else if (sliding_infobar_) { |
266 KillTimer(kInfobarSlidingTimerId); | 269 KillTimer(timer_id_); |
267 sliding_infobar_ = false; | 270 sliding_infobar_ = false; |
268 } | 271 } |
269 | 272 |
270 return S_OK; | 273 return S_OK; |
271 } | 274 } |
272 | 275 |
273 LRESULT InfobarWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { | 276 LRESULT InfobarWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { |
274 InitializingCoClass<InfobarBrowserWindow>::CreateInitialized( | 277 InitializingCoClass<InfobarBrowserWindow>::CreateInitialized( |
275 CComBSTR(url_.c_str()), this, &chrome_frame_host_); | 278 CComBSTR(url_.c_str()), this, &chrome_frame_host_); |
276 | 279 |
(...skipping 26 matching lines...) Expand all Loading... |
303 | 306 |
304 void InfobarWindow::AdjustSize() { | 307 void InfobarWindow::AdjustSize() { |
305 if (NULL != chrome_frame_host_) { | 308 if (NULL != chrome_frame_host_) { |
306 CRect rect; | 309 CRect rect; |
307 GetClientRect(&rect); | 310 GetClientRect(&rect); |
308 chrome_frame_host_->SetWindowSize(rect.Width(), rect.Height()); | 311 chrome_frame_host_->SetWindowSize(rect.Width(), rect.Height()); |
309 } | 312 } |
310 } | 313 } |
311 | 314 |
312 } // namespace infobar_api | 315 } // namespace infobar_api |
OLD | NEW |