OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_resetter/automatic_profile_resetter_delegate.h" | 5 #include "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 TemplateURL template_url(**it); | 261 TemplateURL template_url(**it); |
262 engines_details_list->Append( | 262 engines_details_list->Append( |
263 BuildSubTreeFromTemplateURL(&template_url).release()); | 263 BuildSubTreeFromTemplateURL(&template_url).release()); |
264 } | 264 } |
265 return engines_details_list.Pass(); | 265 return engines_details_list.Pass(); |
266 } | 266 } |
267 | 267 |
268 bool AutomaticProfileResetterDelegateImpl::TriggerPrompt() { | 268 bool AutomaticProfileResetterDelegateImpl::TriggerPrompt() { |
269 DCHECK(global_error_service_); | 269 DCHECK(global_error_service_); |
270 | 270 |
271 if (!ProfileResetGlobalError::IsSupportedOnPlatform()) | 271 Browser* browser = chrome::FindTabbedBrowser( |
| 272 profile_, false /*match_original_profiles*/, chrome::GetActiveDesktop()); |
| 273 if (!browser || !ProfileResetGlobalError::IsSupportedOnPlatform(browser)) |
272 return false; | 274 return false; |
273 | 275 |
274 ProfileResetGlobalError* global_error = new ProfileResetGlobalError(profile_); | 276 ProfileResetGlobalError* global_error = new ProfileResetGlobalError(profile_); |
275 global_error_service_->AddGlobalError(global_error); | 277 global_error_service_->AddGlobalError(global_error); |
276 | 278 |
277 // Do not try to show bubble if another GlobalError is already showing one. | 279 // Do not try to show bubble if another GlobalError is already showing one. |
278 const GlobalErrorService::GlobalErrorList& global_errors( | 280 const GlobalErrorService::GlobalErrorList& global_errors( |
279 global_error_service_->errors()); | 281 global_error_service_->errors()); |
280 GlobalErrorService::GlobalErrorList::const_iterator it; | 282 GlobalErrorService::GlobalErrorList::const_iterator it; |
281 for (it = global_errors.begin(); it != global_errors.end(); ++it) { | 283 for (it = global_errors.begin(); it != global_errors.end(); ++it) { |
282 if ((*it)->GetBubbleView()) | 284 if ((*it)->GetBubbleView()) |
283 break; | 285 break; |
284 } | 286 } |
285 if (it == global_errors.end()) { | 287 if (it == global_errors.end()) |
286 Browser* browser = chrome::FindTabbedBrowser( | 288 global_error->ShowBubbleView(browser); |
287 profile_, | |
288 false /*match_original_profiles*/, | |
289 chrome::GetActiveDesktop()); | |
290 if (browser) | |
291 global_error->ShowBubbleView(browser); | |
292 } | |
293 return true; | 289 return true; |
294 } | 290 } |
295 | 291 |
296 void AutomaticProfileResetterDelegateImpl::TriggerProfileSettingsReset( | 292 void AutomaticProfileResetterDelegateImpl::TriggerProfileSettingsReset( |
297 bool send_feedback, | 293 bool send_feedback, |
298 const base::Closure& completion) { | 294 const base::Closure& completion) { |
299 DCHECK(!profile_resetter_); | 295 DCHECK(!profile_resetter_); |
300 DCHECK(!completion.is_null()); | 296 DCHECK(!completion.is_null()); |
301 | 297 |
302 profile_resetter_.reset(new ProfileResetter(profile_)); | 298 profile_resetter_.reset(new ProfileResetter(profile_)); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (difference) { | 384 if (difference) { |
389 old_settings_snapshot->Subtract(new_settings_snapshot); | 385 old_settings_snapshot->Subtract(new_settings_snapshot); |
390 std::string report = | 386 std::string report = |
391 SerializeSettingsReport(*old_settings_snapshot, difference); | 387 SerializeSettingsReport(*old_settings_snapshot, difference); |
392 SendFeedback(report); | 388 SendFeedback(report); |
393 } | 389 } |
394 } | 390 } |
395 content::BrowserThread::PostTask( | 391 content::BrowserThread::PostTask( |
396 content::BrowserThread::UI, FROM_HERE, user_callback); | 392 content::BrowserThread::UI, FROM_HERE, user_callback); |
397 } | 393 } |
OLD | NEW |