| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome_frame/infobars/internal/infobar_window.h" | 7 #include "chrome_frame/infobars/internal/infobar_window.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "chrome_frame/function_stub.h" | 13 #include "chrome_frame/function_stub.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // length of each step when opening or closing | 17 // length of each step when opening or closing |
| 18 const UINT kInfobarSlidingTimerIntervalMs = 50U; | 18 const UINT kInfobarSlidingTimerIntervalMs = 50U; |
| 19 // pixels per step, when opening or closing | 19 // pixels per step, when opening or closing |
| 20 const int kInfobarSlideOpenStep = 2; | 20 const int kInfobarSlideOpenStep = 2; |
| 21 const int kInfobarSlideCloseStep = 6; | 21 const int kInfobarSlideCloseStep = 6; |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 void OnSliderTimer(InfobarWindow::Host* host) { | 25 VOID CALLBACK OnSliderTimer(InfobarWindow::Host* host, |
| 26 HWND /*hwnd*/, UINT /*uMsg*/, |
| 27 UINT_PTR /*idEvent*/, DWORD /*dwTime*/) { |
| 26 if (host) | 28 if (host) |
| 27 host->UpdateLayout(); | 29 host->UpdateLayout(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 InfobarWindow::InfobarWindow(InfobarType type) | 32 InfobarWindow::InfobarWindow(InfobarType type) |
| 31 : type_(type), | 33 : type_(type), |
| 32 host_(NULL), | 34 host_(NULL), |
| 33 target_height_(0), | 35 target_height_(0), |
| 34 initial_height_(0), | 36 initial_height_(0), |
| 35 current_height_(0), | 37 current_height_(0), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (StartTimer()) | 134 if (StartTimer()) |
| 133 slide_start_ = base::Time::Now(); | 135 slide_start_ = base::Time::Now(); |
| 134 else | 136 else |
| 135 slide_start_ = base::Time(); // NULL time means don't slide, resize now | 137 slide_start_ = base::Time(); // NULL time means don't slide, resize now |
| 136 | 138 |
| 137 // Trigger an immediate re-laying out. The timer will handle remaining steps. | 139 // Trigger an immediate re-laying out. The timer will handle remaining steps. |
| 138 host_->UpdateLayout(); | 140 host_->UpdateLayout(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 bool InfobarWindow::StartTimer() { | 143 bool InfobarWindow::StartTimer() { |
| 142 return false; // TODO(erikwright): Diagnose and fix crashes on IE. | |
| 143 #if 0 | |
| 144 if (timer_id_ != 0) | 144 if (timer_id_ != 0) |
| 145 return true; | 145 return true; |
| 146 | 146 |
| 147 DCHECK(timer_stub_ != NULL); | 147 DCHECK(timer_stub_ != NULL); |
| 148 if (timer_stub_ == NULL) | 148 if (timer_stub_ == NULL) |
| 149 return false; | 149 return false; |
| 150 | 150 |
| 151 timer_id_ = ::SetTimer(NULL, | 151 timer_id_ = ::SetTimer(NULL, |
| 152 timer_id_, | 152 timer_id_, |
| 153 kInfobarSlidingTimerIntervalMs, | 153 kInfobarSlidingTimerIntervalMs, |
| 154 reinterpret_cast<TIMERPROC>(timer_stub_->code())); | 154 reinterpret_cast<TIMERPROC>(timer_stub_->code())); |
| 155 | 155 |
| 156 DPLOG_IF(ERROR, timer_id_ == 0) << "Failure in SetTimer."; | 156 DPLOG_IF(ERROR, timer_id_ == 0) << "Failure in SetTimer."; |
| 157 | 157 |
| 158 return timer_id_ != 0; | 158 return timer_id_ != 0; |
| 159 #endif | |
| 160 } | 159 } |
| 161 | 160 |
| 162 bool InfobarWindow::StopTimer() { | 161 bool InfobarWindow::StopTimer() { |
| 163 if (timer_id_ == 0) | 162 if (timer_id_ == 0) |
| 164 return true; | 163 return true; |
| 165 | 164 |
| 166 if (::KillTimer(NULL, timer_id_)) { | 165 if (::KillTimer(NULL, timer_id_)) { |
| 167 timer_id_ = 0; | 166 timer_id_ = 0; |
| 168 return true; | 167 return true; |
| 169 } | 168 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 195 : infobar_window_(infobar_window) { | 194 : infobar_window_(infobar_window) { |
| 196 } | 195 } |
| 197 | 196 |
| 198 HWND InfobarWindow::FrameImpl::GetFrameWindow() { | 197 HWND InfobarWindow::FrameImpl::GetFrameWindow() { |
| 199 return infobar_window_->host_->GetContainerWindow(); | 198 return infobar_window_->host_->GetContainerWindow(); |
| 200 } | 199 } |
| 201 | 200 |
| 202 void InfobarWindow::FrameImpl::CloseInfobar() { | 201 void InfobarWindow::FrameImpl::CloseInfobar() { |
| 203 infobar_window_->Hide(); | 202 infobar_window_->Hide(); |
| 204 } | 203 } |
| OLD | NEW |