Commit eed73257 authored by motek@chromium.org's avatar motek@chromium.org

Adds browser preferences to configure first-run flow on Windows 8.

- master_prefefrencs/installerdata file may now contain
  { "distribution": {
      "suppress_first_run_default_browser_prompt": true
    } } 
  to suppress the Win8+ first-run dialog that walks the
  user through making Chrome the default browser. 
  If the dialog is suppressed, the default browser
  butterbar/prompt appears on first run instead.

- master_preferences/installerdata file may now contain
  { "browser": {
    "suppress_switch_to_metro_mode_on_set_default": true
  } }
  to suppress switching to metro mode on Win8+ immediately
  after Chrome is made the default browser via the first-run
  dialog.

This CL also removes the non-dialog mode of 
SetAsDefaultBrowserUI and fixes a problem where the dialog 
would be shown only when master preferences were not given.


BUG=135255,135256,135257
TEST=Verify that modifiers described above act as 
advertised in setup procedure on Win8. If both prefs are 
absent, the program should show a modal set-default dialog
and upon successful change restart Chrome *into the
normal first-run flow* in Metro. Note that butter-bar set
default is not expected to restart into metro.

Review URL: https://chromiumcodereview.appspot.com/10702097

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149881 0039d316-1c4b-4281-b951-d872f2087c98
parent bf9975d1
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_ui_prefs.h" #include "chrome/browser/ui/browser_ui_prefs.h"
#include "chrome/browser/ui/startup/default_browser_prompt.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/uma_browsing_activity_observer.h" #include "chrome/browser/ui/uma_browsing_activity_observer.h"
#include "chrome/browser/ui/user_data_dir_dialog.h" #include "chrome/browser/ui/user_data_dir_dialog.h"
...@@ -1122,6 +1123,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ...@@ -1122,6 +1123,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
chrome::SetNewHomePagePrefs(profile_->GetPrefs()); chrome::SetNewHomePagePrefs(profile_->GetPrefs());
browser_process_->profile_manager()->OnImportFinished(profile_); browser_process_->profile_manager()->OnImportFinished(profile_);
if (!master_prefs_->suppress_first_run_default_browser_prompt)
chrome::ShowFirstRunDefaultBrowserPrompt(profile_);
else
browser_creator_->set_is_default_browser_dialog_suppressed(true);
} // if (is_first_run_) } // if (is_first_run_)
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -235,6 +235,12 @@ void SetupMasterPrefsFromInstallPrefs( ...@@ -235,6 +235,12 @@ void SetupMasterPrefsFromInstallPrefs(
&value) && value) { &value) && value) {
out_prefs->make_chrome_default = true; out_prefs->make_chrome_default = true;
} }
if (install_prefs->GetBool(
installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt,
&value) && value) {
out_prefs->suppress_first_run_default_browser_prompt = true;
}
} }
void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ void SetDefaultBrowser(installer::MasterPreferences* install_prefs){
...@@ -409,7 +415,8 @@ MasterPrefs::MasterPrefs() ...@@ -409,7 +415,8 @@ MasterPrefs::MasterPrefs()
homepage_defined(false), homepage_defined(false),
do_import_items(0), do_import_items(0),
dont_import_items(0), dont_import_items(0),
make_chrome_default(false) { make_chrome_default(false),
suppress_first_run_default_browser_prompt(false) {
} }
MasterPrefs::~MasterPrefs() {} MasterPrefs::~MasterPrefs() {}
......
...@@ -48,6 +48,7 @@ struct MasterPrefs { ...@@ -48,6 +48,7 @@ struct MasterPrefs {
int do_import_items; int do_import_items;
int dont_import_items; int dont_import_items;
bool make_chrome_default; bool make_chrome_default;
bool suppress_first_run_default_browser_prompt;
std::vector<GURL> new_tabs; std::vector<GURL> new_tabs;
std::vector<GURL> bookmarks; std::vector<GURL> bookmarks;
}; };
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "chrome/browser/process_singleton.h" #include "chrome/browser/process_singleton.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/startup/default_browser_prompt.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h" #include "chrome/common/chrome_result_codes.h"
...@@ -554,7 +553,6 @@ void AutoImport( ...@@ -554,7 +553,6 @@ void AutoImport(
process_singleton->Unlock(); process_singleton->Unlock();
CreateSentinel(); CreateSentinel();
#endif // !defined(USE_AURA) #endif // !defined(USE_AURA)
chrome::ShowFirstRunDefaultBrowserPrompt(profile);
} }
int ImportNow(Profile* profile, const CommandLine& cmdline) { int ImportNow(Profile* profile, const CommandLine& cmdline) {
......
...@@ -82,9 +82,13 @@ void RegisterBrowserUserPrefs(PrefService* prefs) { ...@@ -82,9 +82,13 @@ void RegisterBrowserUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser,
true, true,
PrefService::UNSYNCABLE_PREF); PrefService::UNSYNCABLE_PREF);
prefs->RegisterBooleanPref(prefs::kDefaultBrowserFlowDialog, #if defined(OS_WIN)
true, // As with Mac-spacific code above, it should be in a platform-specific
// section somewhere, but there is no good place for it.
prefs->RegisterBooleanPref(prefs::kSuppressSwitchToMetroModeOnSetDefault,
false,
PrefService::UNSYNCABLE_PREF); PrefService::UNSYNCABLE_PREF);
#endif
prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint,
true, true,
PrefService::UNSYNCABLE_PREF); PrefService::UNSYNCABLE_PREF);
......
...@@ -181,12 +181,10 @@ namespace chrome { ...@@ -181,12 +181,10 @@ namespace chrome {
void ShowDefaultBrowserPrompt(Profile* profile) { void ShowDefaultBrowserPrompt(Profile* profile) {
// We do not check if we are the default browser if: // We do not check if we are the default browser if:
// - the user said "don't ask me again" on the infobar earlier. // - the user said "don't ask me again" on the infobar earlier.
// - this is the first launch after the first run flow.
// - There is a policy in control of this setting. // - There is a policy in control of this setting.
if (!profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser) || if (!profile->GetPrefs()->GetBoolean(prefs::kCheckDefaultBrowser))
first_run::IsChromeFirstRun()) {
return; return;
}
if (g_browser_process->local_state()->IsManagedPreference( if (g_browser_process->local_state()->IsManagedPreference(
prefs::kDefaultBrowserSettingEnabled)) { prefs::kDefaultBrowserSettingEnabled)) {
if (g_browser_process->local_state()->GetBoolean( if (g_browser_process->local_state()->GetBoolean(
......
...@@ -61,10 +61,7 @@ void SetMetroBrowserFlowLauncher::Observe( ...@@ -61,10 +61,7 @@ void SetMetroBrowserFlowLauncher::Observe(
// Unregister and delete. // Unregister and delete.
registrar_.RemoveAll(); registrar_.RemoveAll();
bool as_dialog = SetAsDefaultBrowserUI::Show(profile_, browser);
profile_->GetPrefs()->GetBoolean(prefs::kDefaultBrowserFlowDialog);
SetAsDefaultBrowserUI::Show(profile_, browser, as_dialog);
delete this; delete this;
} }
......
...@@ -154,7 +154,9 @@ base::LazyInstance<ProfileLaunchObserver> profile_launch_observer = ...@@ -154,7 +154,9 @@ base::LazyInstance<ProfileLaunchObserver> profile_launch_observer =
} // namespace } // namespace
StartupBrowserCreator::StartupBrowserCreator() {} StartupBrowserCreator::StartupBrowserCreator()
: is_default_browser_dialog_suppressed_(false) {
}
StartupBrowserCreator::~StartupBrowserCreator() {} StartupBrowserCreator::~StartupBrowserCreator() {}
......
...@@ -83,6 +83,14 @@ class StartupBrowserCreator { ...@@ -83,6 +83,14 @@ class StartupBrowserCreator {
const CommandLine& command_line, const CommandLine& command_line,
Profile* profile); Profile* profile);
void set_is_default_browser_dialog_suppressed(bool new_value) {
is_default_browser_dialog_suppressed_ = new_value;
}
bool is_default_browser_dialog_suppressed() const {
return is_default_browser_dialog_suppressed_;
}
private: private:
friend class CloudPrintProxyPolicyTest; friend class CloudPrintProxyPolicyTest;
friend class CloudPrintProxyPolicyStartupTest; friend class CloudPrintProxyPolicyStartupTest;
...@@ -118,6 +126,11 @@ class StartupBrowserCreator { ...@@ -118,6 +126,11 @@ class StartupBrowserCreator {
// Additional tabs to open during first run. // Additional tabs to open during first run.
std::vector<GURL> first_run_tabs_; std::vector<GURL> first_run_tabs_;
// True if the set-as-default dialog has been explicitly supressed.
// This information is used to allow the default browser prompt to show on
// first-run when the dialog has been suppressed.
bool is_default_browser_dialog_suppressed_;
// True if we have already read and reset the preference kWasRestarted. (A // True if we have already read and reset the preference kWasRestarted. (A
// member variable instead of a static variable inside WasRestarted because // member variable instead of a static variable inside WasRestarted because
// of testing.) // of testing.)
......
...@@ -362,8 +362,15 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile, ...@@ -362,8 +362,15 @@ bool StartupBrowserCreatorImpl::Launch(Profile* profile,
if (process_startup) { if (process_startup) {
if (browser_defaults::kOSSupportsOtherBrowsers && if (browser_defaults::kOSSupportsOtherBrowsers &&
!command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) { !command_line_.HasSwitch(switches::kNoDefaultBrowserCheck)) {
if (!chrome::ShowAutolaunchPrompt(profile)) // Generally, the default browser prompt should not be shown on first
// run. However, when the set-as-default dialog has been suppressed, we
// need to allow it.
if ((!is_first_run_ ||
(browser_creator_ &&
browser_creator_->is_default_browser_dialog_suppressed())) &&
!chrome::ShowAutolaunchPrompt(profile)) {
chrome::ShowDefaultBrowserPrompt(profile); chrome::ShowDefaultBrowserPrompt(profile);
}
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Check whether the auto-update system needs to be promoted from user // Check whether the auto-update system needs to be promoted from user
......
...@@ -135,10 +135,15 @@ void SetAsDefaultBrowserHandler::SetDefaultWebClientUIState( ...@@ -135,10 +135,15 @@ void SetAsDefaultBrowserHandler::SetDefaultWebClientUIState(
// chrome the default. We fold this UI and move on. // chrome the default. We fold this UI and move on.
ConcludeInteraction(); ConcludeInteraction();
} else if (state == ShellIntegration::STATE_IS_DEFAULT) { } else if (state == ShellIntegration::STATE_IS_DEFAULT) {
BrowserThread::PostTask( if (!Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean(
BrowserThread::FILE, FROM_HERE, prefs::kSuppressSwitchToMetroModeOnSetDefault)) {
base::Bind(&SetAsDefaultBrowserHandler::ActivateMetroChrome, BrowserThread::PostTask(
base::Unretained(this))); BrowserThread::FILE, FROM_HERE,
base::Bind(&SetAsDefaultBrowserHandler::ActivateMetroChrome,
base::Unretained(this)));
} else {
ConcludeInteraction();
}
} }
} }
...@@ -167,20 +172,13 @@ void SetAsDefaultBrowserHandler::ConcludeInteraction() { ...@@ -167,20 +172,13 @@ void SetAsDefaultBrowserHandler::ConcludeInteraction() {
WebContents* contents = web_ui()->GetWebContents(); WebContents* contents = web_ui()->GetWebContents();
if (contents) { if (contents) {
content::WebContentsDelegate* delegate = contents->GetDelegate(); content::WebContentsDelegate* delegate = contents->GetDelegate();
if (delegate) { if (delegate)
if (!delegate->IsPopupOrPanel(contents)) {
Browser* browser = browser::FindBrowserWithWebContents(contents);
if (browser)
chrome::ShowSyncSetup(browser, SyncPromoUI::SOURCE_START_PAGE);
}
delegate->CloseContents(contents); delegate->CloseContents(contents);
}
} }
} }
void SetAsDefaultBrowserHandler::ActivateMetroChrome() { void SetAsDefaultBrowserHandler::ActivateMetroChrome() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
FilePath cur_chrome_exe; FilePath cur_chrome_exe;
bool sentinel_removed = false; bool sentinel_removed = false;
if (PathService::Get(base::FILE_EXE, &cur_chrome_exe) && if (PathService::Get(base::FILE_EXE, &cur_chrome_exe) &&
...@@ -313,19 +311,9 @@ SetAsDefaultBrowserUI::SetAsDefaultBrowserUI(content::WebUI* web_ui) ...@@ -313,19 +311,9 @@ SetAsDefaultBrowserUI::SetAsDefaultBrowserUI(content::WebUI* web_ui)
} }
// static // static
void SetAsDefaultBrowserUI::Show(Profile* profile, void SetAsDefaultBrowserUI::Show(Profile* profile, Browser* browser) {
Browser* browser,
bool dialog) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (dialog) { SetAsDefaultBrowserDialogImpl* dialog =
SetAsDefaultBrowserDialogImpl* dialog = new SetAsDefaultBrowserDialogImpl(profile, browser);
new SetAsDefaultBrowserDialogImpl(profile, browser); dialog->ShowDialog();
dialog->ShowDialog();
} else {
GURL url(chrome::kChromeUIMetroFlowURL);
chrome::NavigateParams params(
chrome::GetSingletonTabNavigateParams(browser, url));
params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
chrome::ShowSingletonTabOverwritingNTP(browser, params);
}
} }
...@@ -18,7 +18,7 @@ class SetAsDefaultBrowserUI : public content::WebUIController { ...@@ -18,7 +18,7 @@ class SetAsDefaultBrowserUI : public content::WebUIController {
explicit SetAsDefaultBrowserUI(content::WebUI* web_ui); explicit SetAsDefaultBrowserUI(content::WebUI* web_ui);
// Present metroizer UI either in a new singleton tab or in a dialog window. // Present metroizer UI either in a new singleton tab or in a dialog window.
static void Show(Profile* profile, Browser* browser, bool dialog); static void Show(Profile* profile, Browser* browser);
private: private:
DISALLOW_COPY_AND_ASSIGN(SetAsDefaultBrowserUI); DISALLOW_COPY_AND_ASSIGN(SetAsDefaultBrowserUI);
......
...@@ -855,9 +855,13 @@ const char kPluginsAlwaysAuthorize[] = "plugins.always_authorize"; ...@@ -855,9 +855,13 @@ const char kPluginsAlwaysAuthorize[] = "plugins.always_authorize";
// on start-up. // on start-up.
const char kCheckDefaultBrowser[] = "browser.check_default_browser"; const char kCheckDefaultBrowser[] = "browser.check_default_browser";
// TODO(motek): Remove this once a firm decision is made regarding how the UI #if defined(OS_WIN)
// should be presented. // By default, setting Chrome as default during first run on Windows 8 will
const char kDefaultBrowserFlowDialog[] = "browser.set_default_flow_dialog"; // trigger shutting down the current instance and spawning a new (Metro)
// Chrome. This boolean preference supresses this behaviour.
const char kSuppressSwitchToMetroModeOnSetDefault[] =
"browser.suppress_switch_to_metro_mode_on_set_default";
#endif
// Policy setting whether default browser check should be disabled and default // Policy setting whether default browser check should be disabled and default
// browser registration should take place. // browser registration should take place.
......
...@@ -310,7 +310,9 @@ extern const char kPluginsShowDetails[]; ...@@ -310,7 +310,9 @@ extern const char kPluginsShowDetails[];
extern const char kPluginsAllowOutdated[]; extern const char kPluginsAllowOutdated[];
extern const char kPluginsAlwaysAuthorize[]; extern const char kPluginsAlwaysAuthorize[];
extern const char kCheckDefaultBrowser[]; extern const char kCheckDefaultBrowser[];
extern const char kDefaultBrowserFlowDialog[]; #if defined(OS_WIN)
extern const char kSuppressSwitchToMetroModeOnSetDefault[];
#endif
extern const char kDefaultBrowserSettingEnabled[]; extern const char kDefaultBrowserSettingEnabled[];
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
extern const char kShowUpdatePromotionInfoBar[]; extern const char kShowUpdatePromotionInfoBar[];
......
...@@ -31,6 +31,8 @@ namespace master_preferences { ...@@ -31,6 +31,8 @@ namespace master_preferences {
const char kLogFile[] = "log_file"; const char kLogFile[] = "log_file";
const char kMakeChromeDefault[] = "make_chrome_default"; const char kMakeChromeDefault[] = "make_chrome_default";
const char kMakeChromeDefaultForUser[] = "make_chrome_default_for_user"; const char kMakeChromeDefaultForUser[] = "make_chrome_default_for_user";
const char kSuppressFirstRunDefaultBrowserPrompt[] =
"suppress_first_run_default_browser_prompt";
const char kMsi[] = "msi"; const char kMsi[] = "msi";
const char kMultiInstall[] = "multi_install"; const char kMultiInstall[] = "multi_install";
const char kRequireEula[] = "require_eula"; const char kRequireEula[] = "require_eula";
......
...@@ -70,6 +70,11 @@ extern const char kMsi[]; ...@@ -70,6 +70,11 @@ extern const char kMsi[];
extern const char kMultiInstall[]; extern const char kMultiInstall[];
// Boolean. Show EULA dialog before install. // Boolean. Show EULA dialog before install.
extern const char kRequireEula[]; extern const char kRequireEula[];
// Boolean. Indicates that the first-run 'set-as-default' dialog should not be
// shown. Relevant in Windows 8+ context only. If this is true, the standard
// 'set default browser' prompt on the butter-bar will appear during the first
// run.
extern const char kSuppressFirstRunDefaultBrowserPrompt[];
// Boolean. Install Chrome to system wise location. Cmd line override present. // Boolean. Install Chrome to system wise location. Cmd line override present.
extern const char kSystemLevel[]; extern const char kSystemLevel[];
// Boolean. Run installer in verbose mode. Cmd line override present. // Boolean. Run installer in verbose mode. Cmd line override present.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment