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