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

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: windows, ownership Created 4 years, 2 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
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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (!browser) 521 if (!browser)
521 browser = new Browser(Browser::CreateParams(profile)); 522 browser = new Browser(Browser::CreateParams(profile));
522 } 523 }
523 GlobalErrorService* global_error_service = 524 GlobalErrorService* global_error_service =
524 GlobalErrorServiceFactory::GetForProfile(profile); 525 GlobalErrorServiceFactory::GetForProfile(profile);
525 SRTGlobalError* global_error = 526 SRTGlobalError* global_error =
526 new SRTGlobalError(global_error_service, download_path); 527 new SRTGlobalError(global_error_service, download_path);
527 528
528 // Ownership of |global_error| is passed to the service. The error removes 529 // Ownership of |global_error| is passed to the service. The error removes
529 // itself from the service and self-destructs when done. 530 // itself from the service and self-destructs when done.
530 global_error_service->AddGlobalError(global_error); 531 global_error_service->AddOwnedGlobalError(base::WrapUnique(global_error));
531 532
532 bool show_bubble = true; 533 bool show_bubble = true;
533 PrefService* local_state = g_browser_process->local_state(); 534 PrefService* local_state = g_browser_process->local_state();
534 if (local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt)) { 535 if (local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt)) {
535 // Don't show the bubble if there's already a pending prompt to only be 536 // Don't show the bubble if there's already a pending prompt to only be
536 // sown in the Chrome menu. 537 // sown in the Chrome menu.
537 RecordReporterStepHistogram(SW_REPORTER_ADDED_TO_MENU); 538 RecordReporterStepHistogram(SW_REPORTER_ADDED_TO_MENU);
538 show_bubble = false; 539 show_bubble = false;
539 } else { 540 } else {
540 // Do not try to show bubble if another GlobalError is already showing 541 // Do not try to show bubble if another GlobalError is already showing
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), 1077 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(),
1077 KEY_QUERY_VALUE) == ERROR_SUCCESS && 1078 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
1078 srt_cleaner_key.GetValueCount() > 0; 1079 srt_cleaner_key.GetValueCount() > 0;
1079 } 1080 }
1080 1081
1081 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { 1082 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) {
1082 g_testing_delegate_ = delegate; 1083 g_testing_delegate_ = delegate;
1083 } 1084 }
1084 1085
1085 } // namespace safe_browsing 1086 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698