OLD | NEW |
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/component_updater/sw_reporter_installer_win.h" | 5 #include "chrome/browser/component_updater/sw_reporter_installer_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 if (exit_code == kPostRebootCleanupNeeded || exit_code == kCleanupNeeded) { | 128 if (exit_code == kPostRebootCleanupNeeded || exit_code == kCleanupNeeded) { |
129 // Find the last active browser, which may be NULL, in which case we won't | 129 // Find the last active browser, which may be NULL, in which case we won't |
130 // show the prompt this time and will wait until the next run of the | 130 // show the prompt this time and will wait until the next run of the |
131 // reporter. We can't use other ways of finding a browser because we don't | 131 // reporter. We can't use other ways of finding a browser because we don't |
132 // have a profile. | 132 // have a profile. |
133 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 133 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
134 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 134 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
135 if (browser) { | 135 if (browser) { |
136 Profile* profile = browser->profile(); | 136 Profile* profile = browser->profile(); |
| 137 // Don't show the prompt again if it's been shown before for this profile. |
137 DCHECK(profile); | 138 DCHECK(profile); |
138 // Now that we have a profile, make sure we have a tabbed browser since we | |
139 // need to anchor the bubble to the toolbar's wrench menu. Create one if | |
140 // none exist already. | |
141 if (browser->type() != Browser::TYPE_TABBED) { | |
142 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | |
143 if (!browser) | |
144 browser = new Browser(Browser::CreateParams(profile, desktop_type)); | |
145 } | |
146 const std::string prompt_version = | 139 const std::string prompt_version = |
147 profile->GetPrefs()->GetString(prefs::kSwReporterPromptVersion); | 140 profile->GetPrefs()->GetString(prefs::kSwReporterPromptVersion); |
148 // Don't show the prompt again if it's been shown before. | |
149 if (prompt_version.empty()) { | 141 if (prompt_version.empty()) { |
150 profile->GetPrefs()->SetString(prefs::kSwReporterPromptVersion, | 142 profile->GetPrefs()->SetString(prefs::kSwReporterPromptVersion, |
151 version); | 143 version); |
152 profile->GetPrefs()->SetInteger(prefs::kSwReporterPromptReason, | 144 profile->GetPrefs()->SetInteger(prefs::kSwReporterPromptReason, |
153 exit_code); | 145 exit_code); |
| 146 // Now that we have a profile, make sure we have a tabbed browser since |
| 147 // we need to anchor the bubble to the toolbar's wrench menu. Create one |
| 148 // if none exist already. |
| 149 if (browser->type() != Browser::TYPE_TABBED) { |
| 150 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
| 151 if (!browser) |
| 152 browser = new Browser(Browser::CreateParams(profile, desktop_type)); |
| 153 } |
154 GlobalErrorService* global_error_service = | 154 GlobalErrorService* global_error_service = |
155 GlobalErrorServiceFactory::GetForProfile(profile); | 155 GlobalErrorServiceFactory::GetForProfile(profile); |
156 SRTGlobalError* global_error = new SRTGlobalError(global_error_service); | 156 SRTGlobalError* global_error = new SRTGlobalError(global_error_service); |
157 // |global_error_service| takes ownership of |global_error| and keeps it | 157 // |global_error_service| takes ownership of |global_error| and keeps it |
158 // alive until RemoveGlobalError() is called, and even then, the object | 158 // alive until RemoveGlobalError() is called, and even then, the object |
159 // is not destroyed, the caller of RemoveGlobalError is responsible to | 159 // is not destroyed, the caller of RemoveGlobalError is responsible to |
160 // destroy it, and in the case of the SRTGlobalError, it deletes itself | 160 // destroy it, and in the case of the SRTGlobalError, it deletes itself |
161 // but only after the bubble has been interacted with. | 161 // but only after the bubble has been interacted with. |
162 global_error_service->AddGlobalError(global_error); | 162 global_error_service->AddGlobalError(global_error); |
163 | 163 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 -1, | 335 -1, |
336 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 336 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
337 | 337 |
338 registry->RegisterStringPref( | 338 registry->RegisterStringPref( |
339 prefs::kSwReporterPromptVersion, | 339 prefs::kSwReporterPromptVersion, |
340 "", | 340 "", |
341 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 341 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
342 } | 342 } |
343 | 343 |
344 } // namespace component_updater | 344 } // namespace component_updater |
OLD | NEW |