Commit 5b0b74ae authored by zengster's avatar zengster Committed by Commit bot

Added in switches for the Mac Installer to send preferences to Chrome

BUG=

Review-Url: https://codereview.chromium.org/2270083002
Cr-Commit-Position: refs/heads/master@{#415525}
parent 7c1aeada
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "chrome/app/chrome_main_mac.h" #include "chrome/app/chrome_main_mac.h"
#include "chrome/browser/mac/relauncher.h" #include "chrome/browser/mac/relauncher.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/mac/cfbundle_blocker.h" #include "chrome/common/mac/cfbundle_blocker.h"
#include "components/crash/content/app/crashpad.h" #include "components/crash/content/app/crashpad.h"
#include "components/crash/core/common/objc_zombie.h" #include "components/crash/core/common/objc_zombie.h"
...@@ -695,6 +696,18 @@ void ChromeMainDelegate::InitMacCrashReporter( ...@@ -695,6 +696,18 @@ void ChromeMainDelegate::InitMacCrashReporter(
<< "Main application forbids --type, saw " << process_type; << "Main application forbids --type, saw " << process_type;
} }
} }
void ChromeMainDelegate::SetUpInstallerPreferences(
const base::CommandLine& command_line) {
const bool uma_setting = command_line.HasSwitch(switches::kEnableUserMetrics);
const bool default_browser_setting =
command_line.HasSwitch(switches::kMakeChromeDefault);
if (uma_setting)
crash_reporter::SetUploadConsent(uma_setting);
if (default_browser_setting)
shell_integration::SetAsDefaultBrowser();
}
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
void ChromeMainDelegate::PreSandboxStartup() { void ChromeMainDelegate::PreSandboxStartup() {
...@@ -715,6 +728,7 @@ void ChromeMainDelegate::PreSandboxStartup() { ...@@ -715,6 +728,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
Append(chrome::kHelperProcessExecutablePath)); Append(chrome::kHelperProcessExecutablePath));
InitMacCrashReporter(command_line, process_type); InitMacCrashReporter(command_line, process_type);
SetUpInstallerPreferences(command_line);
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -54,6 +54,7 @@ class ChromeMainDelegate : public content::ContentMainDelegate { ...@@ -54,6 +54,7 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void InitMacCrashReporter(const base::CommandLine& command_line, void InitMacCrashReporter(const base::CommandLine& command_line,
const std::string& process_type); const std::string& process_type);
void SetUpInstallerPreferences(const base::CommandLine& command_line);
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
ChromeContentClient chrome_content_client_; ChromeContentClient chrome_content_client_;
......
...@@ -1153,6 +1153,9 @@ const char kDisableMacViewsNativeAppWindows[] = ...@@ -1153,6 +1153,9 @@ const char kDisableMacViewsNativeAppWindows[] =
// Disables Translate experimental new UX which replaces the infobar. // Disables Translate experimental new UX which replaces the infobar.
const char kDisableTranslateNewUX[] = "disable-translate-new-ux"; const char kDisableTranslateNewUX[] = "disable-translate-new-ux";
// Enable user metrics from within the installer.
const char kEnableUserMetrics[] = "enable-user-metrics";
// Enable the toolkit-views App Info dialog for Mac. This is accessible from // Enable the toolkit-views App Info dialog for Mac. This is accessible from
// chrome://apps and chrome://extensions and is already enabled on non-mac. // chrome://apps and chrome://extensions and is already enabled on non-mac.
const char kEnableAppInfoDialogMac[] = "enable-app-info-dialog-mac"; const char kEnableAppInfoDialogMac[] = "enable-app-info-dialog-mac";
...@@ -1195,6 +1198,10 @@ const char kRelauncherProcess[] = "relauncher"; ...@@ -1195,6 +1198,10 @@ const char kRelauncherProcess[] = "relauncher";
// image and move its disk image file to the trash. The argument's value must // image and move its disk image file to the trash. The argument's value must
// be a BSD device name of the form "diskN" or "diskNsM". // be a BSD device name of the form "diskN" or "diskNsM".
const char kRelauncherProcessDMGDevice[] = "dmg-device"; const char kRelauncherProcessDMGDevice[] = "dmg-device";
// Indicates whether Chrome should be set as the default browser during
// installation.
const char kMakeChromeDefault[] = "make-chrome-default";
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -345,10 +345,12 @@ extern const char kEnableFullscreenToolbarReveal[]; ...@@ -345,10 +345,12 @@ extern const char kEnableFullscreenToolbarReveal[];
extern const char kEnableHostedAppsInWindows[]; extern const char kEnableHostedAppsInWindows[];
extern const char kEnableMacViewsNativeAppWindows[]; extern const char kEnableMacViewsNativeAppWindows[];
extern const char kEnableTranslateNewUX[]; extern const char kEnableTranslateNewUX[];
extern const char kEnableUserMetrics[];
extern const char kHostedAppQuitNotification[]; extern const char kHostedAppQuitNotification[];
extern const char kMetricsClientID[]; extern const char kMetricsClientID[];
extern const char kRelauncherProcess[]; extern const char kRelauncherProcess[];
extern const char kRelauncherProcessDMGDevice[]; extern const char kRelauncherProcessDMGDevice[];
extern const char kMakeChromeDefault[];
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <Security/Security.h> #include <Security/Security.h>
#include "chrome/common/chrome_switches.h"
#import "Downloader.h" #import "Downloader.h"
#import "InstallerWindowController.h" #import "InstallerWindowController.h"
#import "NSError+ChromeInstallerAdditions.h" #import "NSError+ChromeInstallerAdditions.h"
...@@ -162,12 +164,23 @@ ...@@ -162,12 +164,23 @@
NSString* chromeInApplicationsFolder = NSString* chromeInApplicationsFolder =
[authorizedInstall_ startInstall:tempAppPath]; [authorizedInstall_ startInstall:tempAppPath];
NSMutableArray* installerSettings = [[NSMutableArray alloc] init];
if ([installerWindowController_ isUserMetricsChecked])
[installerSettings
addObject:[NSString stringWithUTF8String:switches::kEnableUserMetrics]];
if ([installerWindowController_ isDefaultBrowserChecked])
[installerSettings
addObject:[NSString
stringWithUTF8String:switches::kMakeDefaultBrowser]];
NSError* error = nil; NSError* error = nil;
[[NSWorkspace sharedWorkspace] [[NSWorkspace sharedWorkspace]
launchApplicationAtURL:[NSURL fileURLWithPath:chromeInApplicationsFolder launchApplicationAtURL:[NSURL fileURLWithPath:chromeInApplicationsFolder
isDirectory:NO] isDirectory:NO]
options:NSWorkspaceLaunchDefault options:NSWorkspaceLaunchDefault
configuration:@{} configuration:@{
NSWorkspaceLaunchConfigurationArguments : installerSettings
}
error:&error]; error:&error];
if (error) { if (error) {
NSLog(@"Chrome failed to launch: %@", error); NSLog(@"Chrome failed to launch: %@", error);
......
...@@ -33,7 +33,7 @@ mac_app_bundle("mac_installer_app") { ...@@ -33,7 +33,7 @@ mac_app_bundle("mac_installer_app") {
extra_substitutions = [ "MACOSX_DEPLOYMENT_TARGET=10.9" ] extra_substitutions = [ "MACOSX_DEPLOYMENT_TARGET=10.9" ]
sources = [ sources = [
"AppDelegate.h", "AppDelegate.h",
"AppDelegate.m", "AppDelegate.mm",
"AuthorizedInstall.h", "AuthorizedInstall.h",
"AuthorizedInstall.m", "AuthorizedInstall.m",
"InstallerWindowController.h", "InstallerWindowController.h",
...@@ -45,6 +45,7 @@ mac_app_bundle("mac_installer_app") { ...@@ -45,6 +45,7 @@ mac_app_bundle("mac_installer_app") {
":mac_installer_base", ":mac_installer_base",
":mac_installer_resources", ":mac_installer_resources",
":mac_installer_xibs", ":mac_installer_xibs",
"//chrome/common:constants",
] ]
libs = [ libs = [
...@@ -79,6 +80,7 @@ test("mac_installer_unittests") { ...@@ -79,6 +80,7 @@ test("mac_installer_unittests") {
":mac_installer_base", ":mac_installer_base",
"//base:base", "//base:base",
"//base/test:run_all_unittests", "//base/test:run_all_unittests",
"//chrome/common:constants",
"//testing/gtest:gtest", "//testing/gtest:gtest",
] ]
libs = [ libs = [
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
- (void)updateStatusDescription:(NSString*)text; - (void)updateStatusDescription:(NSString*)text;
- (void)updateDownloadProgress:(double)progressPercent; - (void)updateDownloadProgress:(double)progressPercent;
- (void)enableLaunchButton; - (void)enableLaunchButton;
- (BOOL)isUserMetricsChecked;
- (BOOL)isDefaultBrowserChecked;
@end @end
#endif // CHROME_INSTALLER_MAC_APP_INSTALLERWINDOWCONTROLLER_H_ #endif // CHROME_INSTALLER_MAC_APP_INSTALLERWINDOWCONTROLLER_H_
...@@ -138,4 +138,12 @@ ...@@ -138,4 +138,12 @@
[NSApp terminate:nil]; [NSApp terminate:nil];
} }
- (BOOL)isUserMetricsChecked {
return optInButton_.state == NSOnState;
}
- (BOOL)isDefaultBrowserChecked {
return defaultBrowserButton_.state == NSOnState;
}
@end @end
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