| OLD | NEW |
| 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 "chrome/browser/ui/views/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 | 10 |
| 11 namespace { |
| 12 |
| 11 // Helpers to show certain types of Windows shell dialogs in a way that doesn't | 13 // Helpers to show certain types of Windows shell dialogs in a way that doesn't |
| 12 // block the UI of the entire app. | 14 // block the UI of the entire app. |
| 13 | |
| 14 class ShellDialogThread : public base::Thread { | 15 class ShellDialogThread : public base::Thread { |
| 15 public: | 16 public: |
| 16 ShellDialogThread() : base::Thread("Chrome_ShellDialogThread") { } | 17 ShellDialogThread() : base::Thread("Chrome_ShellDialogThread") { } |
| 17 ~ShellDialogThread(); | 18 ~ShellDialogThread(); |
| 18 | 19 |
| 19 protected: | 20 protected: |
| 20 void Init(); | 21 void Init(); |
| 21 | 22 |
| 22 void CleanUp(); | 23 void CleanUp(); |
| 23 | 24 |
| 24 private: | 25 private: |
| 25 DISALLOW_COPY_AND_ASSIGN(ShellDialogThread); | 26 DISALLOW_COPY_AND_ASSIGN(ShellDialogThread); |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 ShellDialogThread::~ShellDialogThread() { | 29 ShellDialogThread::~ShellDialogThread() { |
| 29 Stop(); | 30 Stop(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 void ShellDialogThread::Init() { | 33 void ShellDialogThread::Init() { |
| 33 // Initializes the COM library on the current thread. | 34 // Initializes the COM library on the current thread. |
| 34 CoInitialize(NULL); | 35 CoInitialize(NULL); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void ShellDialogThread::CleanUp() { | 38 void ShellDialogThread::CleanUp() { |
| 38 // Closes the COM library on the current thread. CoInitialize must | 39 // Closes the COM library on the current thread. CoInitialize must |
| 39 // be balanced by a corresponding call to CoUninitialize. | 40 // be balanced by a corresponding call to CoUninitialize. |
| 40 CoUninitialize(); | 41 CoUninitialize(); |
| 41 } | 42 } |
| 42 | 43 |
| 44 } // namespace |
| 45 |
| 46 namespace ui { |
| 47 |
| 43 // static | 48 // static |
| 44 BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_; | 49 BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_; |
| 45 int BaseShellDialogImpl::instance_count_ = 0; | 50 int BaseShellDialogImpl::instance_count_ = 0; |
| 46 | 51 |
| 47 BaseShellDialogImpl::BaseShellDialogImpl() { | 52 BaseShellDialogImpl::BaseShellDialogImpl() { |
| 48 ++instance_count_; | 53 ++instance_count_; |
| 49 } | 54 } |
| 50 | 55 |
| 51 BaseShellDialogImpl::~BaseShellDialogImpl() { | 56 BaseShellDialogImpl::~BaseShellDialogImpl() { |
| 52 // All runs should be complete by the time this is called! | 57 // All runs should be complete by the time this is called! |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 base::Thread* thread = new ShellDialogThread; | 100 base::Thread* thread = new ShellDialogThread; |
| 96 bool started = thread->Start(); | 101 bool started = thread->Start(); |
| 97 DCHECK(started); | 102 DCHECK(started); |
| 98 return thread; | 103 return thread; |
| 99 } | 104 } |
| 100 | 105 |
| 101 void BaseShellDialogImpl::EnableOwner(HWND owner) { | 106 void BaseShellDialogImpl::EnableOwner(HWND owner) { |
| 102 if (IsWindow(owner)) | 107 if (IsWindow(owner)) |
| 103 EnableWindow(owner, TRUE); | 108 EnableWindow(owner, TRUE); |
| 104 } | 109 } |
| 110 |
| 111 } // namespace ui |
| OLD | NEW |