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

Side by Side Diff: chrome/browser/safe_browsing/srt_fetcher_win.cc

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: commentary Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_browsing/srt_fetcher_win.h" 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/callback_helpers.h" 16 #include "base/callback_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/debug/leak_annotations.h" 18 #include "base/debug/leak_annotations.h"
19 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/memory/ptr_util.h"
21 #include "base/metrics/field_trial.h" 22 #include "base/metrics/field_trial.h"
22 #include "base/metrics/histogram_macros.h" 23 #include "base/metrics/histogram_macros.h"
23 #include "base/metrics/sparse_histogram.h" 24 #include "base/metrics/sparse_histogram.h"
24 #include "base/process/launch.h" 25 #include "base/process/launch.h"
25 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
28 #include "base/task_runner_util.h" 29 #include "base/task_runner_util.h"
29 #include "base/time/time.h" 30 #include "base/time/time.h"
30 #include "base/win/registry.h" 31 #include "base/win/registry.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (!browser) 538 if (!browser)
538 browser = new Browser(Browser::CreateParams(profile)); 539 browser = new Browser(Browser::CreateParams(profile));
539 } 540 }
540 GlobalErrorService* global_error_service = 541 GlobalErrorService* global_error_service =
541 GlobalErrorServiceFactory::GetForProfile(profile); 542 GlobalErrorServiceFactory::GetForProfile(profile);
542 SRTGlobalError* global_error = 543 SRTGlobalError* global_error =
543 new SRTGlobalError(global_error_service, download_path); 544 new SRTGlobalError(global_error_service, download_path);
544 545
545 // Ownership of |global_error| is passed to the service. The error removes 546 // Ownership of |global_error| is passed to the service. The error removes
546 // itself from the service and self-destructs when done. 547 // itself from the service and self-destructs when done.
547 global_error_service->AddGlobalError(global_error); 548 global_error_service->AddGlobalError(base::WrapUnique(global_error));
548 549
549 bool show_bubble = true; 550 bool show_bubble = true;
550 PrefService* local_state = g_browser_process->local_state(); 551 PrefService* local_state = g_browser_process->local_state();
551 if (local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt)) { 552 if (local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt)) {
552 // Don't show the bubble if there's already a pending prompt to only be 553 // Don't show the bubble if there's already a pending prompt to only be
553 // sown in the Chrome menu. 554 // sown in the Chrome menu.
554 RecordReporterStepHistogram(SW_REPORTER_ADDED_TO_MENU); 555 RecordReporterStepHistogram(SW_REPORTER_ADDED_TO_MENU);
555 show_bubble = false; 556 show_bubble = false;
556 } else { 557 } else {
557 // Do not try to show bubble if another GlobalError is already showing 558 // Do not try to show bubble if another GlobalError is already showing
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), 1097 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(),
1097 KEY_QUERY_VALUE) == ERROR_SUCCESS && 1098 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
1098 srt_cleaner_key.GetValueCount() > 0; 1099 srt_cleaner_key.GetValueCount() > 0;
1099 } 1100 }
1100 1101
1101 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { 1102 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) {
1102 g_testing_delegate_ = delegate; 1103 g_testing_delegate_ = delegate;
1103 } 1104 }
1104 1105
1105 } // namespace safe_browsing 1106 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/recovery/recovery_install_global_error.cc ('k') | chrome/browser/safe_browsing/srt_global_error_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698