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

Side by Side Diff: chrome/browser/ui/views/html_dialog_view_browsertest.cc

Issue 8021009: Consolidate message observer API for win and aura (and touch). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months 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) 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 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/views/html_dialog_view.h" 10 #include "chrome/browser/ui/views/html_dialog_view.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #if defined(OS_WIN) 70 #if defined(OS_WIN)
71 class WindowChangedObserver : public MessageLoopForUI::Observer { 71 class WindowChangedObserver : public MessageLoopForUI::Observer {
72 public: 72 public:
73 WindowChangedObserver() {} 73 WindowChangedObserver() {}
74 74
75 static WindowChangedObserver* GetInstance() { 75 static WindowChangedObserver* GetInstance() {
76 return Singleton<WindowChangedObserver>::get(); 76 return Singleton<WindowChangedObserver>::get();
77 } 77 }
78 78
79 // This method is called before processing a message. 79 // This method is called before processing a message.
80 virtual void WillProcessMessage(const MSG& msg) {} 80 virtual base::EventStatus WillProcessEvent(
81 const MSG& msg) OVERRIDE {
82 return base::EVENT_CONTINUE;
83 }
81 84
82 // This method is called after processing a message. 85 // This method is called after processing a message.
83 virtual void DidProcessMessage(const MSG& msg) { 86 virtual void DidProcessEvent(const MSG& msg) OVERRIDE {
84 // Either WM_PAINT or WM_TIMER indicates the actual work of 87 // Either WM_PAINT or WM_TIMER indicates the actual work of
85 // pushing through the window resizing messages is done since 88 // pushing through the window resizing messages is done since
86 // they are lower priority (we don't get to see the 89 // they are lower priority (we don't get to see the
87 // WM_WINDOWPOSCHANGED message here). 90 // WM_WINDOWPOSCHANGED message here).
88 if (msg.message == WM_PAINT || msg.message == WM_TIMER) 91 if (msg.message == WM_PAINT || msg.message == WM_TIMER)
89 MessageLoop::current()->Quit(); 92 MessageLoop::current()->Quit();
90 } 93 }
91 }; 94 };
92 #elif !defined(OS_MACOSX) 95 #elif defined(TOUCH_UI) || defined(USE_AURA)
93 class WindowChangedObserver : public MessageLoopForUI::Observer { 96 class WindowChangedObserver : public MessageLoopForUI::Observer {
94 public: 97 public:
95 WindowChangedObserver() {} 98 WindowChangedObserver() {}
99
100 static WindowChangedObserver* GetInstance() {
101 return Singleton<WindowChangedObserver>::get();
102 }
103
104 // This method is called before processing a message.
105 virtual base::EventStatus WillProcessEvent(XEvent* event) {
106 return base::EVENT_CONTINUE;
107 }
108
109 // This method is called after processing a message.
110 virtual void DidProcessEvent(XEvent* event) {
111 // Quit once the ConfigureNotify event has been processed - seeing
112 // this means the window sizing request that was made actually
113 // happened.
114 if (event->type == ConfigureNotify)
115 MessageLoop::current()->Quit();
116 }
117 };
118 #elif defined(TOOLKIT_USES_GTK)
119 class WindowChangedObserver : public MessageLoopForUI::Observer {
120 public:
121 WindowChangedObserver() {}
96 122
97 static WindowChangedObserver* GetInstance() { 123 static WindowChangedObserver* GetInstance() {
98 return Singleton<WindowChangedObserver>::get(); 124 return Singleton<WindowChangedObserver>::get();
99 } 125 }
100 126
101 // This method is called before processing a message. 127 // This method is called before processing a message.
102 virtual void WillProcessEvent(GdkEvent* event) {} 128 virtual void WillProcessEvent(GdkEvent* event) {}
103 129
104 // This method is called after processing a message. 130 // This method is called after processing a message.
105 virtual void DidProcessEvent(GdkEvent* event) { 131 virtual void DidProcessEvent(GdkEvent* event) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 WindowChangedObserver::GetInstance()); 252 WindowChangedObserver::GetInstance());
227 // We use busy loop because the state is updated in notifications. 253 // We use busy loop because the state is updated in notifications.
228 while (html_view->state_ != HtmlDialogView::PAINTED) 254 while (html_view->state_ != HtmlDialogView::PAINTED)
229 MessageLoop::current()->RunAllPending(); 255 MessageLoop::current()->RunAllPending();
230 256
231 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); 257 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_);
232 258
233 MessageLoopForUI::current()->RemoveObserver( 259 MessageLoopForUI::current()->RemoveObserver(
234 WindowChangedObserver::GetInstance()); 260 WindowChangedObserver::GetInstance());
235 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698