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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 profile_resetter_.reset(new ProfileResetter(profile_)); | 298 profile_resetter_.reset(new ProfileResetter(profile_)); |
299 FetchBrandcodedDefaultSettingsIfNeeded(); | 299 FetchBrandcodedDefaultSettingsIfNeeded(); |
300 RequestCallbackWhenBrandcodedDefaultsAreFetched(base::Bind( | 300 RequestCallbackWhenBrandcodedDefaultsAreFetched(base::Bind( |
301 &AutomaticProfileResetterDelegateImpl::RunProfileSettingsReset, | 301 &AutomaticProfileResetterDelegateImpl::RunProfileSettingsReset, |
302 AsWeakPtr(), | 302 AsWeakPtr(), |
303 send_feedback, | 303 send_feedback, |
304 completion)); | 304 completion)); |
305 } | 305 } |
306 | 306 |
307 void AutomaticProfileResetterDelegateImpl::OnTemplateURLServiceChanged() { | 307 void AutomaticProfileResetterDelegateImpl::OnTemplateURLServiceChanged() { |
308 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 308 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
309 DCHECK(template_url_service_); | 309 DCHECK(template_url_service_); |
310 if (template_url_service_->loaded() && | 310 if (template_url_service_->loaded() && |
311 !template_url_service_ready_event_.is_signaled()) | 311 !template_url_service_ready_event_.is_signaled()) |
312 template_url_service_ready_event_.Signal(); | 312 template_url_service_ready_event_.Signal(); |
313 } | 313 } |
314 | 314 |
315 void AutomaticProfileResetterDelegateImpl::DismissPrompt() { | 315 void AutomaticProfileResetterDelegateImpl::DismissPrompt() { |
316 DCHECK(global_error_service_); | 316 DCHECK(global_error_service_); |
317 GlobalError* global_error = | 317 GlobalError* global_error = |
318 global_error_service_->GetGlobalErrorByMenuItemCommandID( | 318 global_error_service_->GetGlobalErrorByMenuItemCommandID( |
319 IDC_SHOW_SETTINGS_RESET_BUBBLE); | 319 IDC_SHOW_SETTINGS_RESET_BUBBLE); |
320 if (global_error) { | 320 if (global_error) { |
321 // This will also close/destroy the Bubble UI if it is currently shown. | 321 // This will also close/destroy the Bubble UI if it is currently shown. |
322 global_error_service_->RemoveGlobalError(global_error); | 322 global_error_service_->RemoveGlobalError(global_error); |
323 delete global_error; | 323 delete global_error; |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 void AutomaticProfileResetterDelegateImpl::Observe( | 327 void AutomaticProfileResetterDelegateImpl::Observe( |
328 int type, | 328 int type, |
329 const content::NotificationSource& source, | 329 const content::NotificationSource& source, |
330 const content::NotificationDetails& details) { | 330 const content::NotificationDetails& details) { |
331 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 331 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
332 if (type == chrome::NOTIFICATION_MODULE_LIST_ENUMERATED && | 332 if (type == chrome::NOTIFICATION_MODULE_LIST_ENUMERATED && |
333 !modules_have_been_enumerated_event_.is_signaled()) { | 333 !modules_have_been_enumerated_event_.is_signaled()) { |
334 #if defined(OS_WIN) | 334 #if defined(OS_WIN) |
335 module_list_.reset(EnumerateModulesModel::GetInstance()->GetModuleList()); | 335 module_list_.reset(EnumerateModulesModel::GetInstance()->GetModuleList()); |
336 #endif | 336 #endif |
337 modules_have_been_enumerated_event_.Signal(); | 337 modules_have_been_enumerated_event_.Signal(); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 void AutomaticProfileResetterDelegateImpl::SendFeedback( | 341 void AutomaticProfileResetterDelegateImpl::SendFeedback( |
(...skipping 15 matching lines...) Expand all Loading... |
357 send_feedback, | 357 send_feedback, |
358 base::Bind(&AutomaticProfileResetterDelegateImpl:: | 358 base::Bind(&AutomaticProfileResetterDelegateImpl:: |
359 OnProfileSettingsResetCompleted, | 359 OnProfileSettingsResetCompleted, |
360 AsWeakPtr(), | 360 AsWeakPtr(), |
361 completion, | 361 completion, |
362 base::Passed(&old_settings_snapshot))); | 362 base::Passed(&old_settings_snapshot))); |
363 } | 363 } |
364 | 364 |
365 void AutomaticProfileResetterDelegateImpl:: | 365 void AutomaticProfileResetterDelegateImpl:: |
366 OnBrandcodedDefaultsFetched() { | 366 OnBrandcodedDefaultsFetched() { |
367 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 367 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
368 DCHECK(brandcoded_config_fetcher_); | 368 DCHECK(brandcoded_config_fetcher_); |
369 DCHECK(!brandcoded_config_fetcher_->IsActive()); | 369 DCHECK(!brandcoded_config_fetcher_->IsActive()); |
370 brandcoded_defaults_ = brandcoded_config_fetcher_->GetSettings(); | 370 brandcoded_defaults_ = brandcoded_config_fetcher_->GetSettings(); |
371 if (!brandcoded_defaults_) | 371 if (!brandcoded_defaults_) |
372 brandcoded_defaults_.reset(new BrandcodedDefaultSettings); | 372 brandcoded_defaults_.reset(new BrandcodedDefaultSettings); |
373 brandcoded_defaults_fetched_event_.Signal(); | 373 brandcoded_defaults_fetched_event_.Signal(); |
374 } | 374 } |
375 | 375 |
376 void AutomaticProfileResetterDelegateImpl::OnProfileSettingsResetCompleted( | 376 void AutomaticProfileResetterDelegateImpl::OnProfileSettingsResetCompleted( |
377 const base::Closure& user_callback, | 377 const base::Closure& user_callback, |
378 scoped_ptr<ResettableSettingsSnapshot> old_settings_snapshot) { | 378 scoped_ptr<ResettableSettingsSnapshot> old_settings_snapshot) { |
379 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 379 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
380 if (old_settings_snapshot) { | 380 if (old_settings_snapshot) { |
381 ResettableSettingsSnapshot new_settings_snapshot(profile_); | 381 ResettableSettingsSnapshot new_settings_snapshot(profile_); |
382 int difference = | 382 int difference = |
383 old_settings_snapshot->FindDifferentFields(new_settings_snapshot); | 383 old_settings_snapshot->FindDifferentFields(new_settings_snapshot); |
384 if (difference) { | 384 if (difference) { |
385 old_settings_snapshot->Subtract(new_settings_snapshot); | 385 old_settings_snapshot->Subtract(new_settings_snapshot); |
386 std::string report = | 386 std::string report = |
387 SerializeSettingsReport(*old_settings_snapshot, difference); | 387 SerializeSettingsReport(*old_settings_snapshot, difference); |
388 SendFeedback(report); | 388 SendFeedback(report); |
389 } | 389 } |
390 } | 390 } |
391 content::BrowserThread::PostTask( | 391 content::BrowserThread::PostTask( |
392 content::BrowserThread::UI, FROM_HERE, user_callback); | 392 content::BrowserThread::UI, FROM_HERE, user_callback); |
393 } | 393 } |
OLD | NEW |