Chromium Code Reviews| Index: chrome_frame/infobars/internal/displaced_window.cc |
| =================================================================== |
| --- chrome_frame/infobars/internal/displaced_window.cc (revision 0) |
| +++ chrome_frame/infobars/internal/displaced_window.cc (revision 0) |
| @@ -0,0 +1,85 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome_frame/infobars/internal/displaced_window.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome_frame/utils.h" |
| + |
| +DISABLE_RUNNABLE_METHOD_REFCOUNT(DisplacedWindowManager); |
| + |
| +DisplacedWindowManager::DisplacedWindowManager() { |
| +} |
| + |
| +bool DisplacedWindowManager::Initialize(HWND displaced_hwnd, |
| + Delegate* delegate) { |
| + DCHECK(delegate != NULL); |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
fyi - when you run gcl lint on this change list, y
erikwright (departed)
2010/12/01 20:05:52
I did run lint. It didn't report this. Furthermore
|
| + DCHECK(delegate_ == NULL); |
| + delegate_.reset(delegate); |
| + |
| + PinModule(); |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
add a comment for why this class requires pinning
erikwright (departed)
2010/12/01 20:05:52
(NB this code moved to subclassing_window.h - I ad
|
| + if (!SubclassWindow(displaced_hwnd)) { |
| + LOG(DFATAL) << "Failed to subclass IE Renderer HWND for infobar " |
| + << "installation."; |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +void DisplacedWindowManager::UpdateLayout() { |
| + PushTask( |
| + NewRunnableMethod(this, &DisplacedWindowManager::DoUpdateLayout)); |
| +} |
| + |
| +void DisplacedWindowManager::PushTask(Task* task) { |
| + task_queue_.Push(task); |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
since there's no locking, can we DCHECK that this
erikwright (departed)
2010/12/01 20:05:52
This code no longer exists. But the comment is rel
|
| + if (IsWindow()) |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
Is there a chance that the window doesn't exist at
erikwright (departed)
2010/12/01 20:05:52
I'm uncertain about what happens when a window is
|
| + PostMessage(TM_RUN_TASK_QUEUE, 0, 0); |
| +} |
| + |
| +LRESULT DisplacedWindowManager::OnRunTaskQueue(UINT message, |
| + WPARAM wparam, |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
indent either 4 spaces or to the same indent as th
grt (UTC plus 2)
2010/11/25 18:00:13
indentation
erikwright (departed)
2010/12/01 20:05:52
Done.
erikwright (departed)
2010/12/01 20:05:52
Done.
|
| + LPARAM lparam, |
| + BOOL& handled) { |
| + task_queue_.Run(); |
| + handled = TRUE; |
| + return 0; |
| +} |
| + |
| +void DisplacedWindowManager::DoUpdateLayout() { |
| + // Call SetWindowPos with SWP_FRAMECHANGED for IE window, then IE |
| + // window would receive WM_NCCALCSIZE to recalculate its client size. |
| + if (IsWindow()) |
|
tommi (sloooow) - chröme
2010/11/24 16:08:24
I think the coding guidelines call for {} when the
erikwright (departed)
2010/12/01 20:05:52
Done.
|
| + ::SetWindowPos(m_hWnd, |
| + NULL, 0, 0, 0, 0, |
| + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | |
| + SWP_FRAMECHANGED); |
| +} |
| + |
| +LRESULT DisplacedWindowManager::OnNcCalcSize(BOOL calc_valid_rects, |
| + LPARAM lparam) { |
| + // Ask the original window proc to calculate the 'natural' size of the window. |
| + LRESULT ret = DefWindowProc(WM_NCCALCSIZE, |
| + static_cast<WPARAM>(calc_valid_rects), lparam); |
| + // Whether calc_valid_rects is true or false, we could treat beginning of |
|
amit
2010/11/24 14:21:35
This is somewhat unlikely but if calc_valid_rects
erikwright (departed)
2010/12/01 20:05:52
Great point. To be honest I didn't fully understan
|
| + // lparam as a RECT object. |
| + RECT* rect = reinterpret_cast<RECT*>(lparam); |
| + if (delegate_ != NULL) |
| + delegate_->AdjustDisplacedWindowDimensions(rect); |
| + |
| + return ret; |
| +} |
| + |
| +// The displaced window has been destroyed. Inform the InfobarManagerImpl, who |
| +// will orphan this instance. We will delete ourselves in OnFinalMessage. |
| +void DisplacedWindowManager::OnDestroy() { |
| + if (delegate_ != NULL) |
| + delegate_->OnDisplacedWindowDestroyed(); |
| + delegate_.reset(); |
| +} |
| + |
| +void DisplacedWindowManager::OnFinalMessage(HWND) { |
| + delete this; |
| +} |
| Property changes on: chrome_frame\infobars\internal\displaced_window.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |