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

Side by Side Diff: chrome/browser/recovery/recovery_install_global_error.cc

Issue 2576643002: Remove last vestigial uses of "update needed" png assets. (Closed)
Patch Set: rebase 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"
18 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
19 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/gfx/paint_vector_icon.h"
20 #include "ui/gfx/vector_icons_public.h"
21 #include "ui/native_theme/native_theme.h"
21 22
22 RecoveryInstallGlobalError::RecoveryInstallGlobalError(Profile* profile) 23 RecoveryInstallGlobalError::RecoveryInstallGlobalError(Profile* profile)
23 : elevation_needed_(false), 24 : elevation_needed_(false),
24 profile_(profile), 25 profile_(profile),
25 has_shown_bubble_view_(false) { 26 has_shown_bubble_view_(false) {
26 GlobalErrorServiceFactory::GetForProfile(profile_)->AddUnownedGlobalError( 27 GlobalErrorServiceFactory::GetForProfile(profile_)->AddUnownedGlobalError(
27 this); 28 this);
28 29
29 PrefService* pref = g_browser_process->local_state(); 30 PrefService* pref = g_browser_process->local_state();
30 if (pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)) { 31 if (pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)) {
31 elevation_needed_ = 32 elevation_needed_ =
32 pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation); 33 pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation);
33 } 34 }
34 if (elevation_needed_) { 35 if (elevation_needed_) {
35 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged( 36 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(
36 this); 37 this);
37 } 38 }
38 39
39 pref_registrar_.Init(pref); 40 pref_registrar_.Init(pref);
40 pref_registrar_.Add( 41 pref_registrar_.Add(
41 prefs::kRecoveryComponentNeedsElevation, 42 prefs::kRecoveryComponentNeedsElevation,
42 base::Bind(&RecoveryInstallGlobalError::OnElevationRequirementChanged, 43 base::Bind(&RecoveryInstallGlobalError::OnElevationRequirementChanged,
43 base::Unretained(this))); 44 base::Unretained(this)));
44 } 45 }
45 46
46 RecoveryInstallGlobalError::~RecoveryInstallGlobalError() { 47 RecoveryInstallGlobalError::~RecoveryInstallGlobalError() {}
47 }
48 48
49 void RecoveryInstallGlobalError::Shutdown() { 49 void RecoveryInstallGlobalError::Shutdown() {
50 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveUnownedGlobalError( 50 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveUnownedGlobalError(
51 this); 51 this);
52 } 52 }
53 53
54 GlobalError::Severity RecoveryInstallGlobalError::GetSeverity() { 54 GlobalError::Severity RecoveryInstallGlobalError::GetSeverity() {
55 return GlobalError::SEVERITY_HIGH; 55 return GlobalError::SEVERITY_HIGH;
56 } 56 }
57 57
58 bool RecoveryInstallGlobalError::HasMenuItem() { 58 bool RecoveryInstallGlobalError::HasMenuItem() {
59 return HasElevationNotification(); 59 return HasElevationNotification();
60 } 60 }
61 61
62 int RecoveryInstallGlobalError::MenuItemCommandID() { 62 int RecoveryInstallGlobalError::MenuItemCommandID() {
63 return IDC_ELEVATED_RECOVERY_DIALOG; 63 return IDC_ELEVATED_RECOVERY_DIALOG;
64 } 64 }
65 65
66 base::string16 RecoveryInstallGlobalError::MenuItemLabel() { 66 base::string16 RecoveryInstallGlobalError::MenuItemLabel() {
67 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); 67 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW);
68 } 68 }
69 69
70 gfx::Image RecoveryInstallGlobalError::MenuItemIcon() { 70 gfx::Image RecoveryInstallGlobalError::MenuItemIcon() {
71 return ResourceBundle::GetSharedInstance().GetNativeImageNamed( 71 return gfx::Image(gfx::CreateVectorIcon(
72 IDR_UPDATE_MENU_SEVERITY_HIGH); 72 gfx::VectorIconId::BROWSER_TOOLS_UPDATE,
73 ui::NativeTheme::GetInstanceForNativeUi()->GetSystemColor(
74 ui::NativeTheme::kColorId_AlertSeverityHigh)));
73 } 75 }
74 76
75 void RecoveryInstallGlobalError::ExecuteMenuItem(Browser* browser) { 77 void RecoveryInstallGlobalError::ExecuteMenuItem(Browser* browser) {
76 ShowBubbleView(browser); 78 ShowBubbleView(browser);
77 } 79 }
78 80
79 bool RecoveryInstallGlobalError::HasBubbleView() { 81 bool RecoveryInstallGlobalError::HasBubbleView() {
80 return HasElevationNotification(); 82 return HasElevationNotification();
81 } 83 }
82 84
83 bool RecoveryInstallGlobalError::HasShownBubbleView() { 85 bool RecoveryInstallGlobalError::HasShownBubbleView() {
84 return has_shown_bubble_view_; 86 return has_shown_bubble_view_;
85 } 87 }
86 88
87 void RecoveryInstallGlobalError::ShowBubbleView(Browser* browser) { 89 void RecoveryInstallGlobalError::ShowBubbleView(Browser* browser) {
88 GlobalErrorWithStandardBubble::ShowBubbleView(browser); 90 GlobalErrorWithStandardBubble::ShowBubbleView(browser);
89 has_shown_bubble_view_ = true; 91 has_shown_bubble_view_ = true;
90 } 92 }
91 93
92 bool RecoveryInstallGlobalError::ShouldCloseOnDeactivate() const { 94 bool RecoveryInstallGlobalError::ShouldCloseOnDeactivate() const {
93 return false; 95 return false;
94 } 96 }
95 97
96 gfx::Image RecoveryInstallGlobalError::GetBubbleViewIcon() { 98 gfx::Image RecoveryInstallGlobalError::GetBubbleViewIcon() {
97 return ResourceBundle::GetSharedInstance().GetNativeImageNamed( 99 // TODO(estade): there shouldn't be an icon in the bubble, but
98 IDR_UPDATE_MENU_SEVERITY_HIGH); 100 // GlobalErrorBubbleView currently requires it. See crbug.com/673995
101 return MenuItemIcon();
99 } 102 }
100 103
101 base::string16 RecoveryInstallGlobalError::GetBubbleViewTitle() { 104 base::string16 RecoveryInstallGlobalError::GetBubbleViewTitle() {
102 return l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TITLE); 105 return l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TITLE);
103 } 106 }
104 107
105 std::vector<base::string16> 108 std::vector<base::string16>
106 RecoveryInstallGlobalError::GetBubbleViewMessages() { 109 RecoveryInstallGlobalError::GetBubbleViewMessages() {
107 return std::vector<base::string16>(1, 110 return std::vector<base::string16>(1,
108 l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TEXT)); 111 l10n_util::GetStringUTF16(IDS_RECOVERY_BUBBLE_TEXT));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 DCHECK(pref->FindPreference(prefs::kRecoveryComponentNeedsElevation)); 150 DCHECK(pref->FindPreference(prefs::kRecoveryComponentNeedsElevation));
148 elevation_needed_ = pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation); 151 elevation_needed_ = pref->GetBoolean(prefs::kRecoveryComponentNeedsElevation);
149 152
150 // Got a new elevation request, resets |has_shown_bubble_view_| so the 153 // Got a new elevation request, resets |has_shown_bubble_view_| so the
151 // bubble has a higher priority to show. 154 // bubble has a higher priority to show.
152 if (elevation_needed_) 155 if (elevation_needed_)
153 has_shown_bubble_view_ = false; 156 has_shown_bubble_view_ = false;
154 157
155 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this); 158 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this);
156 } 159 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/ui/views/critical_notification_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698