| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/win/settings_app_monitor.h" | 5 #include "chrome/browser/win/settings_app_monitor.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <objbase.h> |
| 9 #include <oleauto.h> | 10 #include <oleauto.h> |
| 10 #include <stdint.h> | 11 #include <stdint.h> |
| 11 #include <uiautomation.h> | 12 #include <uiautomation.h> |
| 12 | 13 |
| 13 #include <algorithm> | 14 #include <algorithm> |
| 14 #include <iterator> | 15 #include <iterator> |
| 15 #include <string> | 16 #include <string> |
| 16 #include <utility> | 17 #include <utility> |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 scoped_refptr<base::SequencedTaskRunner> monitor_runner, | 643 scoped_refptr<base::SequencedTaskRunner> monitor_runner, |
| 643 const base::WeakPtr<SettingsAppMonitor>& monitor) { | 644 const base::WeakPtr<SettingsAppMonitor>& monitor) { |
| 644 // This and all other methods must be called on the automation thread. | 645 // This and all other methods must be called on the automation thread. |
| 645 DCHECK(task_runner->BelongsToCurrentThread()); | 646 DCHECK(task_runner->BelongsToCurrentThread()); |
| 646 DCHECK(!monitor_runner->RunsTasksInCurrentSequence()); | 647 DCHECK(!monitor_runner->RunsTasksInCurrentSequence()); |
| 647 | 648 |
| 648 task_runner_ = task_runner; | 649 task_runner_ = task_runner; |
| 649 monitor_runner_ = monitor_runner; | 650 monitor_runner_ = monitor_runner; |
| 650 monitor_ = monitor; | 651 monitor_ = monitor; |
| 651 | 652 |
| 652 HRESULT result = automation_.CreateInstance(CLSID_CUIAutomation, nullptr, | 653 HRESULT result = |
| 653 CLSCTX_INPROC_SERVER); | 654 ::CoCreateInstance(CLSID_CUIAutomation, nullptr, CLSCTX_INPROC_SERVER, |
| 655 IID_PPV_ARGS(&automation_)); |
| 654 if (SUCCEEDED(result)) | 656 if (SUCCEEDED(result)) |
| 655 result = automation_ ? InstallObservers() : E_FAIL; | 657 result = automation_ ? InstallObservers() : E_FAIL; |
| 656 | 658 |
| 657 // Tell the monitor that initialization is complete one way or the other. | 659 // Tell the monitor that initialization is complete one way or the other. |
| 658 monitor_runner_->PostTask( | 660 monitor_runner_->PostTask( |
| 659 FROM_HERE, | 661 FROM_HERE, |
| 660 base::Bind(&SettingsAppMonitor::OnInitialized, monitor_, result)); | 662 base::Bind(&SettingsAppMonitor::OnInitialized, monitor_, result)); |
| 661 | 663 |
| 662 // Self-destruct immediately if initialization failed to reduce overhead. | 664 // Self-destruct immediately if initialization failed to reduce overhead. |
| 663 if (FAILED(result)) | 665 if (FAILED(result)) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 delegate_->OnPromoFocused(); | 837 delegate_->OnPromoFocused(); |
| 836 } | 838 } |
| 837 | 839 |
| 838 void SettingsAppMonitor::OnPromoChoiceMade(bool accept_promo) { | 840 void SettingsAppMonitor::OnPromoChoiceMade(bool accept_promo) { |
| 839 DCHECK(thread_checker_.CalledOnValidThread()); | 841 DCHECK(thread_checker_.CalledOnValidThread()); |
| 840 delegate_->OnPromoChoiceMade(accept_promo); | 842 delegate_->OnPromoChoiceMade(accept_promo); |
| 841 } | 843 } |
| 842 | 844 |
| 843 } // namespace win | 845 } // namespace win |
| 844 } // namespace shell_integration | 846 } // namespace shell_integration |
| OLD | NEW |