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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 base::FieldTrialList::FindFullName(kSRTPromptTrialName) == | 134 base::FieldTrialList::FindFullName(kSRTPromptTrialName) == |
135 kSRTPromptOnGroup) { | 135 kSRTPromptOnGroup) { |
136 // Find the last active browser, which may be NULL, in which case we won't | 136 // Find the last active browser, which may be NULL, in which case we won't |
137 // show the prompt this time and will wait until the next run of the | 137 // show the prompt this time and will wait until the next run of the |
138 // reporter. We can't use other ways of finding a browser because we don't | 138 // reporter. We can't use other ways of finding a browser because we don't |
139 // have a profile. | 139 // have a profile. |
140 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 140 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
141 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 141 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
142 if (browser) { | 142 if (browser) { |
143 Profile* profile = browser->profile(); | 143 Profile* profile = browser->profile(); |
| 144 // Don't show the prompt again if it's been shown before for this profile. |
144 DCHECK(profile); | 145 DCHECK(profile); |
145 // Now that we have a profile, make sure we have a tabbed browser since we | |
146 // need to anchor the bubble to the toolbar's wrench menu. Create one if | |
147 // none exist already. | |
148 if (browser->type() != Browser::TYPE_TABBED) { | |
149 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | |
150 if (!browser) | |
151 browser = new Browser(Browser::CreateParams(profile, desktop_type)); | |
152 } | |
153 const std::string prompt_version = | 146 const std::string prompt_version = |
154 profile->GetPrefs()->GetString(prefs::kSwReporterPromptVersion); | 147 profile->GetPrefs()->GetString(prefs::kSwReporterPromptVersion); |
155 // Don't show the prompt again if it's been shown before. | |
156 if (prompt_version.empty()) { | 148 if (prompt_version.empty()) { |
157 profile->GetPrefs()->SetString(prefs::kSwReporterPromptVersion, | 149 profile->GetPrefs()->SetString(prefs::kSwReporterPromptVersion, |
158 version); | 150 version); |
159 profile->GetPrefs()->SetInteger(prefs::kSwReporterPromptReason, | 151 profile->GetPrefs()->SetInteger(prefs::kSwReporterPromptReason, |
160 exit_code); | 152 exit_code); |
| 153 // Now that we have a profile, make sure we have a tabbed browser since |
| 154 // we need to anchor the bubble to the toolbar's wrench menu. Create one |
| 155 // if none exist already. |
| 156 if (browser->type() != Browser::TYPE_TABBED) { |
| 157 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
| 158 if (!browser) |
| 159 browser = new Browser(Browser::CreateParams(profile, desktop_type)); |
| 160 } |
161 GlobalErrorService* global_error_service = | 161 GlobalErrorService* global_error_service = |
162 GlobalErrorServiceFactory::GetForProfile(profile); | 162 GlobalErrorServiceFactory::GetForProfile(profile); |
163 SRTGlobalError* global_error = new SRTGlobalError(global_error_service); | 163 SRTGlobalError* global_error = new SRTGlobalError(global_error_service); |
164 // |global_error_service| takes ownership of |global_error| and keeps it | 164 // |global_error_service| takes ownership of |global_error| and keeps it |
165 // alive until RemoveGlobalError() is called, and even then, the object | 165 // alive until RemoveGlobalError() is called, and even then, the object |
166 // is not destroyed, the caller of RemoveGlobalError is responsible to | 166 // is not destroyed, the caller of RemoveGlobalError is responsible to |
167 // destroy it, and in the case of the SRTGlobalError, it deletes itself | 167 // destroy it, and in the case of the SRTGlobalError, it deletes itself |
168 // but only after the bubble has been interacted with. | 168 // but only after the bubble has been interacted with. |
169 global_error_service->AddGlobalError(global_error); | 169 global_error_service->AddGlobalError(global_error); |
170 | 170 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 -1, | 350 -1, |
351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 351 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
352 | 352 |
353 registry->RegisterStringPref( | 353 registry->RegisterStringPref( |
354 prefs::kSwReporterPromptVersion, | 354 prefs::kSwReporterPromptVersion, |
355 "", | 355 "", |
356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
357 } | 357 } |
358 | 358 |
359 } // namespace component_updater | 359 } // namespace component_updater |
OLD | NEW |