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

Side by Side Diff: chrome/browser/ui/webui/set_as_default_browser_ui.cc

Issue 1748773002: Simplify the default browser infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/webui/set_as_default_browser_ui.h" 5 #include "chrome/browser/ui/webui/set_as_default_browser_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/shell_integration.h" 13 #include "chrome/browser/shell_integration.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_dialogs.h" 15 #include "chrome/browser/ui/browser_dialogs.h"
16 #include "chrome/browser/ui/browser_finder.h" 16 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
18 #include "chrome/browser/ui/browser_list_observer.h" 18 #include "chrome/browser/ui/browser_list_observer.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/chrome_pages.h" 20 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chrome/browser/ui/singleton_tabs.h" 21 #include "chrome/browser/ui/singleton_tabs.h"
22 #include "chrome/browser/ui/startup/default_browser_prompt.h"
22 #include "chrome/browser/ui/sync/sync_promo_ui.h" 23 #include "chrome/browser/ui/sync/sync_promo_ui.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/chromium_strings.h" 27 #include "chrome/grit/chromium_strings.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "chrome/grit/locale_settings.h" 29 #include "chrome/grit/locale_settings.h"
29 #include "chrome/installer/util/install_util.h" 30 #include "chrome/installer/util/install_util.h"
30 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return "[]"; 287 return "[]";
287 } 288 }
288 289
289 void SetAsDefaultBrowserDialogImpl::OnDialogClosed( 290 void SetAsDefaultBrowserDialogImpl::OnDialogClosed(
290 const std::string& json_retval) { 291 const std::string& json_retval) {
291 // Register the user's response in UMA. 292 // Register the user's response in UMA.
292 UMA_HISTOGRAM_ENUMERATION(kSetAsDefaultBrowserHistogram, 293 UMA_HISTOGRAM_ENUMERATION(kSetAsDefaultBrowserHistogram,
293 dialog_interaction_result_, 294 dialog_interaction_result_,
294 MAKE_CHROME_DEFAULT_MAX); 295 MAKE_CHROME_DEFAULT_MAX);
295 296
296 // If the user explicitly elected *not to* make Chrome default, we won't 297 // Suppress showing the default browser infobar if the user explicitly elected
297 // ask again. 298 // *not to* make Chrome default.
298 if (dialog_interaction_result_ == MAKE_CHROME_DEFAULT_REGRETTED) { 299 if (dialog_interaction_result_ == MAKE_CHROME_DEFAULT_REGRETTED)
299 PrefService* prefs = profile_->GetPrefs(); 300 chrome::MarkDefaultBrowserPromptAsDismissed(profile_);
300 prefs->SetBoolean(prefs::kCheckDefaultBrowser, false);
301 }
302 301
303 // Carry on with a normal chrome session. For the purpose of surfacing this 302 // Carry on with a normal chrome session. For the purpose of surfacing this
304 // dialog the actual browser window had to remain hidden. Now it's time to 303 // dialog the actual browser window had to remain hidden. Now it's time to
305 // show it. 304 // show it.
306 if (browser_) { 305 if (browser_) {
307 BrowserWindow* window = browser_->window(); 306 BrowserWindow* window = browser_->window();
308 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); 307 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
309 window->Show(); 308 window->Show();
310 if (contents) 309 if (contents)
311 contents->SetInitialFocus(); 310 contents->SetInitialFocus();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 Profile::FromWebUI(web_ui), CreateSetAsDefaultBrowserUIHTMLSource()); 347 Profile::FromWebUI(web_ui), CreateSetAsDefaultBrowserUIHTMLSource());
349 } 348 }
350 349
351 // static 350 // static
352 void SetAsDefaultBrowserUI::Show(Profile* profile, Browser* browser) { 351 void SetAsDefaultBrowserUI::Show(Profile* profile, Browser* browser) {
353 DCHECK_CURRENTLY_ON(BrowserThread::UI); 352 DCHECK_CURRENTLY_ON(BrowserThread::UI);
354 SetAsDefaultBrowserDialogImpl* dialog = 353 SetAsDefaultBrowserDialogImpl* dialog =
355 new SetAsDefaultBrowserDialogImpl(profile, browser); 354 new SetAsDefaultBrowserDialogImpl(profile, browser);
356 dialog->ShowDialog(); 355 dialog->ShowDialog();
357 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698