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

Side by Side Diff: chrome/browser/shell_integration.cc

Issue 10539169: Prototype version of the first-run dialog for Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed remarks from the review. Created 8 years, 6 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 "chrome/browser/shell_integration.h" 5 #include "chrome/browser/shell_integration.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 if (observer_) { 113 if (observer_) {
114 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); 114 observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
115 BrowserThread::PostTask( 115 BrowserThread::PostTask(
116 BrowserThread::FILE, FROM_HERE, 116 BrowserThread::FILE, FROM_HERE,
117 base::Bind( 117 base::Bind(
118 &DefaultWebClientWorker::ExecuteCheckIsDefault, this)); 118 &DefaultWebClientWorker::ExecuteCheckIsDefault, this));
119 } 119 }
120 } 120 }
121 121
122 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() { 122 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
123 bool interactive_permitted = false;
123 if (observer_) { 124 if (observer_) {
124 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); 125 observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
126 interactive_permitted = observer_->IsInteractiveSetDefaultPermitted();
125 } 127 }
126 BrowserThread::PostTask( 128 BrowserThread::PostTask(
127 BrowserThread::FILE, FROM_HERE, 129 BrowserThread::FILE, FROM_HERE,
128 base::Bind( 130 base::Bind(&DefaultWebClientWorker::ExecuteSetAsDefault, this,
129 &DefaultWebClientWorker::ExecuteSetAsDefault, this)); 131 interactive_permitted));
130 } 132 }
131 133
132 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() { 134 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() {
133 // Our associated view has gone away, so we shouldn't call back to it if 135 // Our associated view has gone away, so we shouldn't call back to it if
134 // our worker thread returns after the view is dead. 136 // our worker thread returns after the view is dead.
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
136 observer_ = NULL; 138 observer_ = NULL;
137 } 139 }
138 140
139 /////////////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////////////
(...skipping 13 matching lines...) Expand all
153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
154 UpdateUI(state); 156 UpdateUI(state);
155 // The worker has finished everything it needs to do, so free the observer 157 // The worker has finished everything it needs to do, so free the observer
156 // if we own it. 158 // if we own it.
157 if (observer_ && observer_->IsOwnedByWorker()) { 159 if (observer_ && observer_->IsOwnedByWorker()) {
158 delete observer_; 160 delete observer_;
159 observer_ = NULL; 161 observer_ = NULL;
160 } 162 }
161 } 163 }
162 164
163 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { 165 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault(
166 bool interactive_permitted) {
164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
165 SetAsDefault(observer_ && observer_->IsInteractiveSetDefaultPermitted()); 168
169 bool result = SetAsDefault(interactive_permitted);
166 BrowserThread::PostTask( 170 BrowserThread::PostTask(
167 BrowserThread::UI, FROM_HERE, 171 BrowserThread::UI, FROM_HERE,
168 base::Bind( 172 base::Bind(&DefaultWebClientWorker::CompleteSetAsDefault, this, result));
169 &DefaultWebClientWorker::CompleteSetAsDefault, this));
170 } 173 }
171 174
172 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { 175 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault(
176 bool call_result) {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
178 // First tell the observer what the SetAsDefault call has returned.
179 if (observer_)
180 observer_->OnSetAsDefaultConcluded(call_result);
174 // Set as default completed, check again to make sure it stuck... 181 // Set as default completed, check again to make sure it stuck...
175 StartCheckIsDefault(); 182 StartCheckIsDefault();
176 } 183 }
177 184
178 void ShellIntegration::DefaultWebClientWorker::UpdateUI( 185 void ShellIntegration::DefaultWebClientWorker::UpdateUI(
179 DefaultWebClientState state) { 186 DefaultWebClientState state) {
180 if (observer_) { 187 if (observer_) {
181 switch (state) { 188 switch (state) {
182 case NOT_DEFAULT_WEB_CLIENT: 189 case NOT_DEFAULT_WEB_CLIENT:
183 observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT); 190 observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT);
(...skipping 20 matching lines...) Expand all
204 } 211 }
205 212
206 /////////////////////////////////////////////////////////////////////////////// 213 ///////////////////////////////////////////////////////////////////////////////
207 // DefaultBrowserWorker, private: 214 // DefaultBrowserWorker, private:
208 215
209 ShellIntegration::DefaultWebClientState 216 ShellIntegration::DefaultWebClientState
210 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() { 217 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() {
211 return ShellIntegration::IsDefaultBrowser(); 218 return ShellIntegration::IsDefaultBrowser();
212 } 219 }
213 220
214 void ShellIntegration::DefaultBrowserWorker::SetAsDefault( 221 bool ShellIntegration::DefaultBrowserWorker::SetAsDefault(
215 bool interactive_permitted) { 222 bool interactive_permitted) {
223 bool result = false;
216 switch (ShellIntegration::CanSetAsDefaultBrowser()) { 224 switch (ShellIntegration::CanSetAsDefaultBrowser()) {
217 case ShellIntegration::SET_DEFAULT_UNATTENDED: 225 case ShellIntegration::SET_DEFAULT_UNATTENDED:
218 ShellIntegration::SetAsDefaultBrowser(); 226 result = ShellIntegration::SetAsDefaultBrowser();
219 break; 227 break;
220 case ShellIntegration::SET_DEFAULT_INTERACTIVE: 228 case ShellIntegration::SET_DEFAULT_INTERACTIVE:
221 if (interactive_permitted) 229 if (interactive_permitted)
222 ShellIntegration::SetAsDefaultBrowserInteractive(); 230 result = ShellIntegration::SetAsDefaultBrowserInteractive();
223 break; 231 break;
224 default: 232 default:
225 NOTREACHED(); 233 NOTREACHED();
226 } 234 }
235
236 return result;
227 } 237 }
228 238
229 /////////////////////////////////////////////////////////////////////////////// 239 ///////////////////////////////////////////////////////////////////////////////
230 // ShellIntegration::DefaultProtocolClientWorker 240 // ShellIntegration::DefaultProtocolClientWorker
231 // 241 //
232 242
233 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker( 243 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker(
234 DefaultWebClientObserver* observer, const std::string& protocol) 244 DefaultWebClientObserver* observer, const std::string& protocol)
235 : DefaultWebClientWorker(observer), 245 : DefaultWebClientWorker(observer),
236 protocol_(protocol) { 246 protocol_(protocol) {
237 } 247 }
238 248
239 /////////////////////////////////////////////////////////////////////////////// 249 ///////////////////////////////////////////////////////////////////////////////
240 // DefaultProtocolClientWorker, private: 250 // DefaultProtocolClientWorker, private:
241 251
242 ShellIntegration::DefaultWebClientState 252 ShellIntegration::DefaultWebClientState
243 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { 253 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
244 return ShellIntegration::IsDefaultProtocolClient(protocol_); 254 return ShellIntegration::IsDefaultProtocolClient(protocol_);
245 } 255 }
246 256
247 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( 257 bool ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
248 bool interactive_permitted) { 258 bool interactive_permitted) {
249 ShellIntegration::SetAsDefaultProtocolClient(protocol_); 259 return ShellIntegration::SetAsDefaultProtocolClient(protocol_);
250 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698