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

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: Update after owners' 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
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return new_cmd_line; 95 return new_cmd_line;
96 } 96 }
97 97
98 #if !defined(OS_WIN) 98 #if !defined(OS_WIN)
99 // static 99 // static
100 bool ShellIntegration::SetAsDefaultBrowserInteractive() { 100 bool ShellIntegration::SetAsDefaultBrowserInteractive() {
101 return false; 101 return false;
102 } 102 }
103 #endif 103 #endif
104 104
105 bool ShellIntegration::DefaultWebClientObserver::IsOwnedByWorker() {
106 return false;
107 }
108
109 bool ShellIntegration::DefaultWebClientObserver::
110 IsInteractiveSetDefaultPermitted() {
111 return false;
112 }
113
105 /////////////////////////////////////////////////////////////////////////////// 114 ///////////////////////////////////////////////////////////////////////////////
106 // ShellIntegration::DefaultWebClientWorker 115 // ShellIntegration::DefaultWebClientWorker
107 // 116 //
108 117
109 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker( 118 ShellIntegration::DefaultWebClientWorker::DefaultWebClientWorker(
110 DefaultWebClientObserver* observer) 119 DefaultWebClientObserver* observer)
111 : observer_(observer) { 120 : observer_(observer) {
112 } 121 }
113 122
114 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() { 123 void ShellIntegration::DefaultWebClientWorker::StartCheckIsDefault() {
115 if (observer_) { 124 if (observer_) {
116 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); 125 observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
117 BrowserThread::PostTask( 126 BrowserThread::PostTask(
118 BrowserThread::FILE, FROM_HERE, 127 BrowserThread::FILE, FROM_HERE,
119 base::Bind( 128 base::Bind(
120 &DefaultWebClientWorker::ExecuteCheckIsDefault, this)); 129 &DefaultWebClientWorker::ExecuteCheckIsDefault, this));
121 } 130 }
122 } 131 }
123 132
124 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() { 133 void ShellIntegration::DefaultWebClientWorker::StartSetAsDefault() {
134 bool interactive_permitted = false;
125 if (observer_) { 135 if (observer_) {
126 observer_->SetDefaultWebClientUIState(STATE_PROCESSING); 136 observer_->SetDefaultWebClientUIState(STATE_PROCESSING);
137 interactive_permitted = observer_->IsInteractiveSetDefaultPermitted();
127 } 138 }
128 BrowserThread::PostTask( 139 BrowserThread::PostTask(
129 BrowserThread::FILE, FROM_HERE, 140 BrowserThread::FILE, FROM_HERE,
130 base::Bind( 141 base::Bind(&DefaultWebClientWorker::ExecuteSetAsDefault, this,
131 &DefaultWebClientWorker::ExecuteSetAsDefault, this)); 142 interactive_permitted));
132 } 143 }
133 144
134 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() { 145 void ShellIntegration::DefaultWebClientWorker::ObserverDestroyed() {
135 // Our associated view has gone away, so we shouldn't call back to it if 146 // Our associated view has gone away, so we shouldn't call back to it if
136 // our worker thread returns after the view is dead. 147 // our worker thread returns after the view is dead.
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
138 observer_ = NULL; 149 observer_ = NULL;
139 } 150 }
140 151
141 /////////////////////////////////////////////////////////////////////////////// 152 ///////////////////////////////////////////////////////////////////////////////
(...skipping 13 matching lines...) Expand all
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
156 UpdateUI(state); 167 UpdateUI(state);
157 // The worker has finished everything it needs to do, so free the observer 168 // The worker has finished everything it needs to do, so free the observer
158 // if we own it. 169 // if we own it.
159 if (observer_ && observer_->IsOwnedByWorker()) { 170 if (observer_ && observer_->IsOwnedByWorker()) {
160 delete observer_; 171 delete observer_;
161 observer_ = NULL; 172 observer_ = NULL;
162 } 173 }
163 } 174 }
164 175
165 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault() { 176 void ShellIntegration::DefaultWebClientWorker::ExecuteSetAsDefault(
177 bool interactive_permitted) {
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
167 SetAsDefault(observer_ && observer_->IsInteractiveSetDefaultPermitted()); 179
180 bool result = SetAsDefault(interactive_permitted);
168 BrowserThread::PostTask( 181 BrowserThread::PostTask(
169 BrowserThread::UI, FROM_HERE, 182 BrowserThread::UI, FROM_HERE,
170 base::Bind( 183 base::Bind(&DefaultWebClientWorker::CompleteSetAsDefault, this, result));
171 &DefaultWebClientWorker::CompleteSetAsDefault, this));
172 } 184 }
173 185
174 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault() { 186 void ShellIntegration::DefaultWebClientWorker::CompleteSetAsDefault(
187 bool succeeded) {
175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
189 // First tell the observer what the SetAsDefault call has returned.
190 if (observer_)
191 observer_->OnSetAsDefaultConcluded(succeeded);
176 // Set as default completed, check again to make sure it stuck... 192 // Set as default completed, check again to make sure it stuck...
177 StartCheckIsDefault(); 193 StartCheckIsDefault();
178 } 194 }
179 195
180 void ShellIntegration::DefaultWebClientWorker::UpdateUI( 196 void ShellIntegration::DefaultWebClientWorker::UpdateUI(
181 DefaultWebClientState state) { 197 DefaultWebClientState state) {
182 if (observer_) { 198 if (observer_) {
183 switch (state) { 199 switch (state) {
184 case NOT_DEFAULT_WEB_CLIENT: 200 case NOT_DEFAULT_WEB_CLIENT:
185 observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT); 201 observer_->SetDefaultWebClientUIState(STATE_NOT_DEFAULT);
(...skipping 20 matching lines...) Expand all
206 } 222 }
207 223
208 /////////////////////////////////////////////////////////////////////////////// 224 ///////////////////////////////////////////////////////////////////////////////
209 // DefaultBrowserWorker, private: 225 // DefaultBrowserWorker, private:
210 226
211 ShellIntegration::DefaultWebClientState 227 ShellIntegration::DefaultWebClientState
212 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() { 228 ShellIntegration::DefaultBrowserWorker::CheckIsDefault() {
213 return ShellIntegration::IsDefaultBrowser(); 229 return ShellIntegration::IsDefaultBrowser();
214 } 230 }
215 231
216 void ShellIntegration::DefaultBrowserWorker::SetAsDefault( 232 bool ShellIntegration::DefaultBrowserWorker::SetAsDefault(
217 bool interactive_permitted) { 233 bool interactive_permitted) {
234 bool result = false;
218 switch (ShellIntegration::CanSetAsDefaultBrowser()) { 235 switch (ShellIntegration::CanSetAsDefaultBrowser()) {
219 case ShellIntegration::SET_DEFAULT_UNATTENDED: 236 case ShellIntegration::SET_DEFAULT_UNATTENDED:
220 ShellIntegration::SetAsDefaultBrowser(); 237 result = ShellIntegration::SetAsDefaultBrowser();
221 break; 238 break;
222 case ShellIntegration::SET_DEFAULT_INTERACTIVE: 239 case ShellIntegration::SET_DEFAULT_INTERACTIVE:
223 if (interactive_permitted) 240 if (interactive_permitted)
224 ShellIntegration::SetAsDefaultBrowserInteractive(); 241 result = ShellIntegration::SetAsDefaultBrowserInteractive();
225 break; 242 break;
226 default: 243 default:
227 NOTREACHED(); 244 NOTREACHED();
228 } 245 }
246
247 return result;
229 } 248 }
230 249
231 /////////////////////////////////////////////////////////////////////////////// 250 ///////////////////////////////////////////////////////////////////////////////
232 // ShellIntegration::DefaultProtocolClientWorker 251 // ShellIntegration::DefaultProtocolClientWorker
233 // 252 //
234 253
235 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker( 254 ShellIntegration::DefaultProtocolClientWorker::DefaultProtocolClientWorker(
236 DefaultWebClientObserver* observer, const std::string& protocol) 255 DefaultWebClientObserver* observer, const std::string& protocol)
237 : DefaultWebClientWorker(observer), 256 : DefaultWebClientWorker(observer),
238 protocol_(protocol) { 257 protocol_(protocol) {
239 } 258 }
240 259
241 /////////////////////////////////////////////////////////////////////////////// 260 ///////////////////////////////////////////////////////////////////////////////
242 // DefaultProtocolClientWorker, private: 261 // DefaultProtocolClientWorker, private:
243 262
244 ShellIntegration::DefaultWebClientState 263 ShellIntegration::DefaultWebClientState
245 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() { 264 ShellIntegration::DefaultProtocolClientWorker::CheckIsDefault() {
246 return ShellIntegration::IsDefaultProtocolClient(protocol_); 265 return ShellIntegration::IsDefaultProtocolClient(protocol_);
247 } 266 }
248 267
249 void ShellIntegration::DefaultProtocolClientWorker::SetAsDefault( 268 bool ShellIntegration::DefaultProtocolClientWorker::SetAsDefault(
250 bool interactive_permitted) { 269 bool interactive_permitted) {
251 ShellIntegration::SetAsDefaultProtocolClient(protocol_); 270 return ShellIntegration::SetAsDefaultProtocolClient(protocol_);
252 } 271 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698