OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/startup/default_browser_prompt.h" | 5 #include "chrome/browser/ui/startup/default_browser_prompt.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } // namespace | 237 } // namespace |
238 | 238 |
239 namespace chrome { | 239 namespace chrome { |
240 | 240 |
241 void RegisterDefaultBrowserPromptPrefs(PrefRegistrySimple* registry) { | 241 void RegisterDefaultBrowserPromptPrefs(PrefRegistrySimple* registry) { |
242 registry->RegisterStringPref( | 242 registry->RegisterStringPref( |
243 prefs::kBrowserSuppressDefaultBrowserPrompt, std::string()); | 243 prefs::kBrowserSuppressDefaultBrowserPrompt, std::string()); |
244 } | 244 } |
245 | 245 |
246 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { | 246 void ShowDefaultBrowserPrompt(Profile* profile, HostDesktopType desktop_type) { |
247 // We do not check if we are the default browser if: | 247 // Do not check if Chrome is the default browser if there is a policy in |
248 // - There is a policy in control of this setting. | 248 // control of this setting. |
249 // We check if we are the default browser but do not prompt if: | 249 if (g_browser_process->local_state()->IsManagedPreference( |
| 250 prefs::kDefaultBrowserSettingEnabled)) { |
| 251 // Handling of the browser.default_browser_setting_enabled policy setting is |
| 252 // taken care of in BrowserProcessImpl. |
| 253 return; |
| 254 } |
| 255 |
| 256 // Check if Chrome is the default browser but do not prompt if: |
250 // - The user said "don't ask me again" on the infobar earlier. | 257 // - The user said "don't ask me again" on the infobar earlier. |
251 // - The "suppress_default_browser_prompt_for_version" master preference is | 258 // - The "suppress_default_browser_prompt_for_version" master preference is |
252 // set to the current version. | 259 // set to the current version. |
253 bool show_prompt = | 260 bool show_prompt = |
254 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser); | 261 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser); |
255 | |
256 if (g_browser_process->local_state()->IsManagedPreference( | |
257 prefs::kDefaultBrowserSettingEnabled)) { | |
258 if (g_browser_process->local_state()->GetBoolean( | |
259 prefs::kDefaultBrowserSettingEnabled)) { | |
260 content::BrowserThread::PostTask( | |
261 content::BrowserThread::FILE, FROM_HERE, | |
262 base::Bind( | |
263 base::IgnoreResult(&ShellIntegration::SetAsDefaultBrowser))); | |
264 } else { | |
265 // TODO(pastarmovj): We can't really do anything meaningful here yet but | |
266 // just prevent showing the infobar. | |
267 } | |
268 return; | |
269 } | |
270 | |
271 if (show_prompt) { | 262 if (show_prompt) { |
272 const std::string disable_version_string = | 263 const std::string disable_version_string = |
273 g_browser_process->local_state()->GetString( | 264 g_browser_process->local_state()->GetString( |
274 prefs::kBrowserSuppressDefaultBrowserPrompt); | 265 prefs::kBrowserSuppressDefaultBrowserPrompt); |
275 const Version disable_version(disable_version_string); | 266 const Version disable_version(disable_version_string); |
276 DCHECK(disable_version_string.empty() || disable_version.IsValid()); | 267 DCHECK(disable_version_string.empty() || disable_version.IsValid()); |
277 if (disable_version.IsValid()) { | 268 if (disable_version.IsValid()) { |
278 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) | 269 if (disable_version.Equals(Version(version_info::GetVersionNumber()))) |
279 show_prompt = false; | 270 show_prompt = false; |
280 } | 271 } |
281 } | 272 } |
282 | 273 |
283 content::BrowserThread::PostTask( | 274 content::BrowserThread::PostTask( |
284 content::BrowserThread::FILE, FROM_HERE, | 275 content::BrowserThread::FILE, FROM_HERE, |
285 base::Bind(&CheckDefaultBrowserOnFileThread, profile->GetPath(), | 276 base::Bind(&CheckDefaultBrowserOnFileThread, profile->GetPath(), |
286 show_prompt, desktop_type)); | 277 show_prompt, desktop_type)); |
287 } | 278 } |
288 | 279 |
289 #if !defined(OS_WIN) | 280 #if !defined(OS_WIN) |
290 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { | 281 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { |
291 return false; | 282 return false; |
292 } | 283 } |
293 #endif | 284 #endif |
294 | 285 |
295 } // namespace chrome | 286 } // namespace chrome |
OLD | NEW |