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

Side by Side Diff: chrome/browser/ui/startup/default_browser_prompt.cc

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 years, 3 months 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) 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 174 }
175 175
176 bool DefaultBrowserInfoBarDelegate::Cancel() { 176 bool DefaultBrowserInfoBarDelegate::Cancel() {
177 action_taken_ = true; 177 action_taken_ = true;
178 UMA_HISTOGRAM_BOOLEAN("DefaultBrowserWarning.DontSetAsDefault", true); 178 UMA_HISTOGRAM_BOOLEAN("DefaultBrowserWarning.DontSetAsDefault", true);
179 // User clicked "Don't ask me again", remember that. 179 // User clicked "Don't ask me again", remember that.
180 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false); 180 prefs_->SetBoolean(prefs::kCheckDefaultBrowser, false);
181 return true; 181 return true;
182 } 182 }
183 183
184 void NotifyNotDefaultBrowserCallback(chrome::HostDesktopType desktop_type) { 184 void NotifyNotDefaultBrowserCallback(ui::HostDesktopType desktop_type) {
185 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); 185 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type);
186 if (!browser) 186 if (!browser)
187 return; // Reached during ui tests. 187 return; // Reached during ui tests.
188 188
189 // In ChromeBot tests, there might be a race. This line appears to get 189 // In ChromeBot tests, there might be a race. This line appears to get
190 // called during shutdown and |tab| can be NULL. 190 // called during shutdown and |tab| can be NULL.
191 content::WebContents* web_contents = 191 content::WebContents* web_contents =
192 browser->tab_strip_model()->GetActiveWebContents(); 192 browser->tab_strip_model()->GetActiveWebContents();
193 if (!web_contents) 193 if (!web_contents)
194 return; 194 return;
(...skipping 10 matching lines...) Expand all
205 const base::FilePath& profile_path) { 205 const base::FilePath& profile_path) {
206 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 206 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
207 Profile* profile = 207 Profile* profile =
208 g_browser_process->profile_manager()->GetProfileByPath(profile_path); 208 g_browser_process->profile_manager()->GetProfileByPath(profile_path);
209 if (profile) 209 if (profile)
210 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); 210 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true);
211 } 211 }
212 212
213 void CheckDefaultBrowserOnFileThread(const base::FilePath& profile_path, 213 void CheckDefaultBrowserOnFileThread(const base::FilePath& profile_path,
214 bool show_prompt, 214 bool show_prompt,
215 chrome::HostDesktopType desktop_type) { 215 ui::HostDesktopType desktop_type) {
216 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 216 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
217 ShellIntegration::DefaultWebClientState state = 217 ShellIntegration::DefaultWebClientState state =
218 ShellIntegration::GetDefaultBrowser(); 218 ShellIntegration::GetDefaultBrowser();
219 if (state == ShellIntegration::IS_DEFAULT) { 219 if (state == ShellIntegration::IS_DEFAULT) {
220 // Notify the user in the future if Chrome ceases to be the user's chosen 220 // Notify the user in the future if Chrome ceases to be the user's chosen
221 // default browser. 221 // default browser.
222 content::BrowserThread::PostTask( 222 content::BrowserThread::PostTask(
223 content::BrowserThread::UI, FROM_HERE, 223 content::BrowserThread::UI, FROM_HERE,
224 base::Bind(&ResetCheckDefaultBrowserPrefOnUIThread, profile_path)); 224 base::Bind(&ResetCheckDefaultBrowserPrefOnUIThread, profile_path));
225 } else if (show_prompt && state == ShellIntegration::NOT_DEFAULT) { 225 } else if (show_prompt && state == ShellIntegration::NOT_DEFAULT) {
(...skipping 10 matching lines...) Expand all
236 236
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,
247 ui::HostDesktopType desktop_type) {
247 // We do not check if we are the default browser if: 248 // We do not check if we are the default browser if:
248 // - There is a policy in control of this setting. 249 // - There is a policy in control of this setting.
249 // We check if we are the default browser but do not prompt if: 250 // We check if we are the default browser but do not prompt if:
250 // - The user said "don't ask me again" on the infobar earlier. 251 // - The user said "don't ask me again" on the infobar earlier.
251 // - The "suppress_default_browser_prompt_for_version" master preference is 252 // - The "suppress_default_browser_prompt_for_version" master preference is
252 // set to the current version. 253 // set to the current version.
253 bool show_prompt = 254 bool show_prompt =
254 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser); 255 profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser);
255 256
256 if (g_browser_process->local_state()->IsManagedPreference( 257 if (g_browser_process->local_state()->IsManagedPreference(
(...skipping 29 matching lines...) Expand all
286 show_prompt, desktop_type)); 287 show_prompt, desktop_type));
287 } 288 }
288 289
289 #if !defined(OS_WIN) 290 #if !defined(OS_WIN)
290 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { 291 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
291 return false; 292 return false;
292 } 293 }
293 #endif 294 #endif
294 295
295 } // namespace chrome 296 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698