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

Side by Side Diff: ui/base/dialogs/base_shell_dialog_win.cc

Issue 11048029: Allow Thread to initialize COM for Windows consumers who need it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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) 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/base/dialogs/base_shell_dialog_win.h" 5 #include "ui/base/dialogs/base_shell_dialog_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "base/win/scoped_com_initializer.h" 10 #include "base/win/scoped_com_initializer.h"
11 11
12 namespace {
13
14 // Helpers to show certain types of Windows shell dialogs in a way that doesn't
15 // block the UI of the entire app.
16 class ShellDialogThread : public base::Thread {
17 public:
18 ShellDialogThread() : base::Thread("Chrome_ShellDialogThread") { }
19 ~ShellDialogThread();
20
21 private:
22 void Init();
23 void CleanUp();
24
25 scoped_ptr<base::win::ScopedCOMInitializer> com_initializer_;
26
27 DISALLOW_COPY_AND_ASSIGN(ShellDialogThread);
28 };
29
30 ShellDialogThread::~ShellDialogThread() {
31 Stop();
32 }
33
34 void ShellDialogThread::Init() {
35 com_initializer_.reset(new base::win::ScopedCOMInitializer());
36 }
37
38 void ShellDialogThread::CleanUp() {
39 com_initializer_.reset();
40 }
41
42 } // namespace
43
44 namespace ui { 12 namespace ui {
45 13
46 // static 14 // static
47 BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_; 15 BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_;
48 int BaseShellDialogImpl::instance_count_ = 0; 16 int BaseShellDialogImpl::instance_count_ = 0;
49 17
50 BaseShellDialogImpl::BaseShellDialogImpl() { 18 BaseShellDialogImpl::BaseShellDialogImpl() {
51 ++instance_count_; 19 ++instance_count_;
52 } 20 }
53 21
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return (owner && owners_.find(owner) != owners_.end()); 56 return (owner && owners_.find(owner) != owners_.end());
89 } 57 }
90 58
91 void BaseShellDialogImpl::DisableOwner(HWND owner) { 59 void BaseShellDialogImpl::DisableOwner(HWND owner) {
92 if (IsWindow(owner)) 60 if (IsWindow(owner))
93 EnableWindow(owner, FALSE); 61 EnableWindow(owner, FALSE);
94 } 62 }
95 63
96 // static 64 // static
97 base::Thread* BaseShellDialogImpl::CreateDialogThread() { 65 base::Thread* BaseShellDialogImpl::CreateDialogThread() {
98 base::Thread* thread = new ShellDialogThread; 66 base::Thread* thread = new base::Thread("Chrome_ShellDialogThread");
67 #if defined(OS_WIN)
grt (UTC plus 2) 2012/10/16 01:58:13 _win.cc here, too
68 thread->init_com_with_mta(false);
69 #endif
99 bool started = thread->Start(); 70 bool started = thread->Start();
100 DCHECK(started); 71 DCHECK(started);
101 return thread; 72 return thread;
102 } 73 }
103 74
104 void BaseShellDialogImpl::EnableOwner(HWND owner) { 75 void BaseShellDialogImpl::EnableOwner(HWND owner) {
105 if (IsWindow(owner)) 76 if (IsWindow(owner))
106 EnableWindow(owner, TRUE); 77 EnableWindow(owner, TRUE);
107 } 78 }
108 79
109 } // namespace ui 80 } // namespace ui
OLDNEW
« remoting/host/setup/daemon_controller_win.cc ('K') | « remoting/host/setup/daemon_controller_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698