OLD | NEW |
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 "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
| 7 #include "base/bind.h" |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( | 74 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( |
74 DefaultWebClientObserver* observer) | 75 DefaultWebClientObserver* observer) |
75 : observer_(observer) { | 76 : observer_(observer) { |
76 } | 77 } |
77 | 78 |
78 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { | 79 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { |
79 if (observer_) { | 80 if (observer_) { |
80 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); | 81 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); |
81 BrowserThread::PostTask( | 82 BrowserThread::PostTask( |
82 BrowserThread::FILE, FROM_HERE, | 83 BrowserThread::FILE, FROM_HERE, |
83 NewRunnableMethod( | 84 base::Bind( |
84 this, &DefaultWebClientWorker::ExecuteCheckIsDefault)); | 85 &DefaultWebClientWorker::ExecuteCheckIsDefault, this)); |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() { | 89 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() { |
89 if (observer_) { | 90 if (observer_) { |
90 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); | 91 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); |
91 } | 92 } |
92 BrowserThread::PostTask( | 93 BrowserThread::PostTask( |
93 BrowserThread::FILE, FROM_HERE, | 94 BrowserThread::FILE, FROM_HERE, |
94 NewRunnableMethod( | 95 base::Bind( |
95 this, &DefaultWebClientWorker::ExecuteSetAsDefault)); | 96 &DefaultWebClientWorker::ExecuteSetAsDefault, this)); |
96 } | 97 } |
97 | 98 |
98 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() { | 99 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() { |
99 // Our associated view has gone away, so we shouldn't call back to it if | 100 // Our associated view has gone away, so we shouldn't call back to it if |
100 // our worker thread returns after the view is dead. | 101 // our worker thread returns after the view is dead. |
101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
102 observer_ = NULL; | 103 observer_ = NULL; |
103 } | 104 } |
104 | 105 |
105 /////////////////////////////////////////////////////////////////////////////// | 106 /////////////////////////////////////////////////////////////////////////////// |
106 // DefaultWebClientWorker, private: | 107 // DefaultWebClientWorker, private: |
107 | 108 |
108 void ShellIntegration::DefaultWebClientWorker::ExecuteCheckIsDefault() { | 109 void ShellIntegration::DefaultWebClientWorker::ExecuteCheckIsDefault() { |
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
110 DefaultWebClientState state = CheckIsDefault(); | 111 DefaultWebClientState state = CheckIsDefault(); |
111 BrowserThread::PostTask( | 112 BrowserThread::PostTask( |
112 BrowserThread::UI, FROM_HERE, | 113 BrowserThread::UI, FROM_HERE, |
113 NewRunnableMethod( | 114 base::Bind( |
114 this, &DefaultWebClientWorker::CompleteCheckIsDefault, state)); | 115 &DefaultWebClientWorker::CompleteCheckIsDefault, this, state)); |
115 } | 116 } |
116 | 117 |
117 void ShellIntegration::DefaultWebClientWorker::CompleteCheckIsDefault( | 118 void ShellIntegration::DefaultWebClientWorker::CompleteCheckIsDefault( |
118 DefaultWebClientState state) { | 119 DefaultWebClientState state) { |
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
120 UpdateUI(state); | 121 UpdateUI(state); |
121 // The worker has finished everything it needs to do, so free the observer | 122 // The worker has finished everything it needs to do, so free the observer |
122 // if we own it. | 123 // if we own it. |
123 if (observer_ && observer_->IsOwnedByWorker()) { | 124 if (observer_ && observer_->IsOwnedByWorker()) { |
124 delete observer_; | 125 delete observer_; |
125 observer_ = NULL; | 126 observer_ = NULL; |
126 } | 127 } |
127 } | 128 } |
128 | 129 |
129 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { | 130 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { |
130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 131 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
131 SetAsDefault(); | 132 SetAsDefault(); |
132 BrowserThread::PostTask( | 133 BrowserThread::PostTask( |
133 BrowserThread::UI, FROM_HERE, | 134 BrowserThread::UI, FROM_HERE, |
134 NewRunnableMethod( | 135 base::Bind( |
135 this, &DefaultWebClientWorker::CompleteSetAsDefault)); | 136 &DefaultWebClientWorker::CompleteSetAsDefault, this)); |
136 } | 137 } |
137 | 138 |
138 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { | 139 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { |
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
140 // Set as default completed, check again to make sure it stuck... | 141 // Set as default completed, check again to make sure it stuck... |
141 StartCheckIsDefault(); | 142 StartCheckIsDefault(); |
142 } | 143 } |
143 | 144 |
144 void ShellIntegration::DefaultWebClientWorker::UpdateUI( | 145 void ShellIntegration::DefaultWebClientWorker::UpdateUI( |
145 DefaultWebClientState state) { | 146 DefaultWebClientState state) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // DefaultProtocolClientWorker, private: | 196 // DefaultProtocolClientWorker, private: |
196 | 197 |
197 ShellIntegration::DefaultWebClientState | 198 ShellIntegration::DefaultWebClientState |
198 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { | 199 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { |
199 return ShellIntegration::IsDefaultProtocolClient(protocol_); | 200 return ShellIntegration::IsDefaultProtocolClient(protocol_); |
200 } | 201 } |
201 | 202 |
202 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault() { | 203 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault() { |
203 ShellIntegration::SetAsDefaultProtocolClient(protocol_); | 204 ShellIntegration::SetAsDefaultProtocolClient(protocol_); |
204 } | 205 } |
OLD | NEW |