Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome_frame/infobars/internal/displaced_window.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome_frame/utils.h" | |
| 9 | |
| 10 DISABLE_RUNNABLE_METHOD_REFCOUNT(DisplacedWindowManager); | |
| 11 | |
| 12 DisplacedWindowManager::DisplacedWindowManager() { | |
| 13 } | |
| 14 | |
| 15 bool DisplacedWindowManager::Initialize(HWND displaced_hwnd, | |
| 16 Delegate* delegate) { | |
| 17 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
| |
| 18 DCHECK(delegate_ == NULL); | |
| 19 delegate_.reset(delegate); | |
| 20 | |
| 21 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
| |
| 22 if (!SubclassWindow(displaced_hwnd)) { | |
| 23 LOG(DFATAL) << "Failed to subclass IE Renderer HWND for infobar " | |
| 24 << "installation."; | |
| 25 return false; | |
| 26 } | |
| 27 | |
| 28 return true; | |
| 29 } | |
| 30 | |
| 31 void DisplacedWindowManager::UpdateLayout() { | |
| 32 PushTask( | |
| 33 NewRunnableMethod(this, &DisplacedWindowManager::DoUpdateLayout)); | |
| 34 } | |
| 35 | |
| 36 void DisplacedWindowManager::PushTask(Task* task) { | |
| 37 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
| |
| 38 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
| |
| 39 PostMessage(TM_RUN_TASK_QUEUE, 0, 0); | |
| 40 } | |
| 41 | |
| 42 LRESULT DisplacedWindowManager::OnRunTaskQueue(UINT message, | |
| 43 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.
| |
| 44 LPARAM lparam, | |
| 45 BOOL& handled) { | |
| 46 task_queue_.Run(); | |
| 47 handled = TRUE; | |
| 48 return 0; | |
| 49 } | |
| 50 | |
| 51 void DisplacedWindowManager::DoUpdateLayout() { | |
| 52 // Call SetWindowPos with SWP_FRAMECHANGED for IE window, then IE | |
| 53 // window would receive WM_NCCALCSIZE to recalculate its client size. | |
| 54 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.
| |
| 55 ::SetWindowPos(m_hWnd, | |
| 56 NULL, 0, 0, 0, 0, | |
| 57 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | | |
| 58 SWP_FRAMECHANGED); | |
| 59 } | |
| 60 | |
| 61 LRESULT DisplacedWindowManager::OnNcCalcSize(BOOL calc_valid_rects, | |
| 62 LPARAM lparam) { | |
| 63 // Ask the original window proc to calculate the 'natural' size of the window. | |
| 64 LRESULT ret = DefWindowProc(WM_NCCALCSIZE, | |
| 65 static_cast<WPARAM>(calc_valid_rects), lparam); | |
| 66 // 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
| |
| 67 // lparam as a RECT object. | |
| 68 RECT* rect = reinterpret_cast<RECT*>(lparam); | |
| 69 if (delegate_ != NULL) | |
| 70 delegate_->AdjustDisplacedWindowDimensions(rect); | |
| 71 | |
| 72 return ret; | |
| 73 } | |
| 74 | |
| 75 // The displaced window has been destroyed. Inform the InfobarManagerImpl, who | |
| 76 // will orphan this instance. We will delete ourselves in OnFinalMessage. | |
| 77 void DisplacedWindowManager::OnDestroy() { | |
| 78 if (delegate_ != NULL) | |
| 79 delegate_->OnDisplacedWindowDestroyed(); | |
| 80 delegate_.reset(); | |
| 81 } | |
| 82 | |
| 83 void DisplacedWindowManager::OnFinalMessage(HWND) { | |
| 84 delete this; | |
| 85 } | |
| OLD | NEW |