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

Side by Side Diff: chrome/browser/recovery/recovery_install_global_error.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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/recovery/recovery_install_global_error.h" 5 #include "chrome/browser/recovery/recovery_install_global_error.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/component_updater/recovery_component_installer.h" 9 #include "chrome/browser/component_updater/recovery_component_installer.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/global_error/global_error_service.h" 11 #include "chrome/browser/ui/global_error/global_error_service.h"
12 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 12 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
13 #include "chrome/browser/upgrade_detector.h" 13 #include "chrome/browser/upgrade_detector.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/grit/chromium_strings.h" 16 #include "chrome/grit/chromium_strings.h"
17 #include "chrome/grit/theme_resources.h" 17 #include "chrome/grit/theme_resources.h"
18 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 21
22 RecoveryInstallGlobalError::RecoveryInstallGlobalError(Profile* profile) 22 RecoveryInstallGlobalError::RecoveryInstallGlobalError(Profile* profile)
23 : elevation_needed_(false), 23 : elevation_needed_(false),
24 profile_(profile), 24 profile_(profile),
25 has_shown_bubble_view_(false) { 25 has_shown_bubble_view_(false) {
26 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(this); 26 GlobalErrorServiceFactory::GetForProfile(profile_)->AddUnownedGlobalError(
27 this);
27 28
28 PrefService* pref = g_browser_process->local_state(); 29 PrefService* pref = g_browser_process->local_state();
29 if (pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)) { 30 if (pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)) {
30 elevation_needed_ = 31 elevation_needed_ =
31 pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation); 32 pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation);
32 } 33 }
33 if (elevation_needed_) { 34 if (elevation_needed_) {
34 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged( 35 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(
35 this); 36 this);
36 } 37 }
37 38
38 pref_registrar_.Init(pref); 39 pref_registrar_.Init(pref);
39 pref_registrar_.Add( 40 pref_registrar_.Add(
40 prefs::kRecoveryComponentNeedsElevation, 41 prefs::kRecoveryComponentNeedsElevation,
41 base::Bind(&RecoveryInstallGlobalError::OnElevationRequirementChanged, 42 base::Bind(&RecoveryInstallGlobalError::OnElevationRequirementChanged,
42 base::Unretained(this))); 43 base::Unretained(this)));
43 } 44 }
44 45
45 RecoveryInstallGlobalError::~RecoveryInstallGlobalError() { 46 RecoveryInstallGlobalError::~RecoveryInstallGlobalError() {
46 } 47 }
47 48
48 void RecoveryInstallGlobalError::Shutdown() { 49 void RecoveryInstallGlobalError::Shutdown() {
49 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); 50 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveUnownedGlobalError(
51 this);
50 } 52 }
51 53
52 GlobalError::Severity RecoveryInstallGlobalError::GetSeverity() { 54 GlobalError::Severity RecoveryInstallGlobalError::GetSeverity() {
53 return GlobalError::SEVERITY_HIGH; 55 return GlobalError::SEVERITY_HIGH;
54 } 56 }
55 57
56 bool RecoveryInstallGlobalError::HasMenuItem() { 58 bool RecoveryInstallGlobalError::HasMenuItem() {
57 return HasElevationNotification(); 59 return HasElevationNotification();
58 } 60 }
59 61
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 DCHECK(pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)); 147 DCHECK(pref->FindPreference(prefs::kRecoveryComponentNeedsElevation));
146 elevation_needed_ = pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation); 148 elevation_needed_ = pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation);
147 149
148 // Got a new elevation request, resets |has_shown_bubble_view_| so the 150 // Got a new elevation request, resets |has_shown_bubble_view_| so the
149 // bubble has a higher priority to show. 151 // bubble has a higher priority to show.
150 if (elevation_needed_) 152 if (elevation_needed_)
151 has_shown_bubble_view_ = false; 153 has_shown_bubble_view_ = false;
152 154
153 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this); 155 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this);
154 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/warning_badge_service.cc ('k') | chrome/browser/safe_browsing/srt_fetcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698