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

Side by Side Diff: ui/gfx/win/singleton_hwnd.cc

Issue 23812010: Implement first part of supporting global extension commands. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No change, just reuploading (last attempt was incomplete) Created 7 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
« ui/gfx/win/singleton_hwnd.h ('K') | « ui/gfx/win/singleton_hwnd.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/win/singleton_hwnd.h" 5 #include "ui/gfx/win/singleton_hwnd.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 9
10 namespace gfx { 10 namespace gfx {
11 11
12 // static 12 // static
13 SingletonHwnd* SingletonHwnd::GetInstance() { 13 SingletonHwnd* SingletonHwnd::GetInstance() {
14 return Singleton<SingletonHwnd>::get(); 14 return Singleton<SingletonHwnd>::get();
15 } 15 }
16 16
17 void SingletonHwnd::Init() {
18 if (!base::MessageLoop::current() ||
19 base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) {
20 // Creating this window in (e.g.) a renderer inhibits shutdown on
21 // Windows. See http://crbug.com/230122 and http://crbug.com/236039.
22 DLOG(ERROR) << "Cannot create windows on non-UI thread!";
23 return;
24 }
25 WindowImpl::Init(NULL, Rect());
26 }
27
17 void SingletonHwnd::AddObserver(Observer* observer) { 28 void SingletonHwnd::AddObserver(Observer* observer) {
18 if (!hwnd()) { 29 if (!hwnd())
19 if (!base::MessageLoop::current() || 30 Init();
20 base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) {
21 // Creating this window in (e.g.) a renderer inhibits shutdown on
22 // Windows. See http://crbug.com/230122 and http://crbug.com/236039.
23 DLOG(ERROR) << "Cannot create windows on non-UI thread!";
24 return;
25 }
26 WindowImpl::Init(NULL, Rect());
27 }
28 observer_list_.AddObserver(observer); 31 observer_list_.AddObserver(observer);
29 } 32 }
30 33
31 void SingletonHwnd::RemoveObserver(Observer* observer) { 34 void SingletonHwnd::RemoveObserver(Observer* observer) {
32 if (!hwnd()) 35 if (!hwnd())
33 return; 36 return;
34 observer_list_.RemoveObserver(observer); 37 observer_list_.RemoveObserver(observer);
35 } 38 }
36 39
37 BOOL SingletonHwnd::ProcessWindowMessage(HWND window, 40 BOOL SingletonHwnd::ProcessWindowMessage(HWND window,
38 UINT message, 41 UINT message,
39 WPARAM wparam, 42 WPARAM wparam,
40 LPARAM lparam, 43 LPARAM lparam,
41 LRESULT& result, 44 LRESULT& result,
42 DWORD msg_map_id) { 45 DWORD msg_map_id) {
43 FOR_EACH_OBSERVER(Observer, 46 FOR_EACH_OBSERVER(Observer,
44 observer_list_, 47 observer_list_,
45 OnWndProc(window, message, wparam, lparam)); 48 OnWndProc(window, message, wparam, lparam));
46 return false; 49 return false;
47 } 50 }
48 51
49 SingletonHwnd::SingletonHwnd() { 52 SingletonHwnd::SingletonHwnd() {
50 } 53 }
51 54
52 SingletonHwnd::~SingletonHwnd() { 55 SingletonHwnd::~SingletonHwnd() {
53 } 56 }
54 57
55 } // namespace gfx 58 } // namespace gfx
OLDNEW
« ui/gfx/win/singleton_hwnd.h ('K') | « ui/gfx/win/singleton_hwnd.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698