Skip to content

Commit

Permalink
Remove logic for unused foreground auto-launch mode on Windows.
Browse files Browse the repository at this point in the history
And distill auto_launch_util.cc to essentially the very simple thing it is
doing once all the if(in_foreground) code is out of the way..!

TBR=atwilson (metrics change in chrome/browser/background/background_mode_manager.cc already reviewed by metrics OWNER rkaplow@)
TBR=pkasting (side-effect of switch removal on chrome/browser/ui/startup/startup_browser_creator_impl.cc already reviewed by grt@)
TBR=gene (side-effect of switch removal on cloud_print -- that switch was a no-op for cloud_print anyways)
BUG=553790
TEST=Install pre-CL chrome, enable bg auto-launch, install new Chrome, confirm it uses the same key for bg auto-launch and works with it.

Review URL: https://codereview.chromium.org/1439803002

Cr-Commit-Position: refs/heads/master@{#359561}
  • Loading branch information
gab authored and Commit bot committed Nov 13, 2015
1 parent 264c1a2 commit a17c5d4
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 351 deletions.
38 changes: 2 additions & 36 deletions chrome/browser/background/background_mode_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,6 @@ using extensions::Extension;

namespace {

// Records histogram about which auto-launch pattern (if any) was used to launch
// the current process based on |command_line|.
void RecordAutoLaunchState(const base::CommandLine& command_line) {
enum AutoLaunchState {
AUTO_LAUNCH_NONE = 0,
AUTO_LAUNCH_BACKGROUND = 1,
AUTO_LAUNCH_FOREGROUND = 2,
AUTO_LAUNCH_FOREGROUND_USELESS = 3,
AUTO_LAUNCH_NUM_STATES
} auto_launch_state = AUTO_LAUNCH_NONE;

if (command_line.HasSwitch(switches::kNoStartupWindow))
auto_launch_state = AUTO_LAUNCH_BACKGROUND;

if (command_line.HasSwitch(switches::kAutoLaunchAtStartup)) {
// The only purpose of kAutoLaunchAtStartup is to override a background
// auto-launch from kNoStartupWindow into a foreground auto-launch. It's a
// meaningless switch on its own.
if (auto_launch_state == AUTO_LAUNCH_BACKGROUND) {
auto_launch_state = AUTO_LAUNCH_FOREGROUND;
} else {
auto_launch_state = AUTO_LAUNCH_FOREGROUND_USELESS;
}
}

// Observe the AutoLaunchStates in the wild. According to the platform-
// specific implementations of EnableLaunchOnStartup(), we'd expect only Mac
// and Windows to have any sort of AutoLaunchState and only Windows should use
// FOREGROUND if at all (it was only used by a deprecated experiment and a
// master pref which may not be used much). Tighten up auto-launch settings
// based on the result of usage in the wild.
UMA_HISTOGRAM_ENUMERATION("BackgroundMode.OnStartup.AutoLaunchState",
auto_launch_state, AUTO_LAUNCH_NUM_STATES);
}

// Enum for recording menu item clicks in UMA.
// NOTE: Do not renumber these as that would confuse interpretation of
// previously logged data. When making changes, also update histograms.xml.
Expand Down Expand Up @@ -320,7 +285,8 @@ BackgroundModeManager::BackgroundModeManager(
// are deleted and their names change.
profile_cache_->AddObserver(this);

RecordAutoLaunchState(command_line);
UMA_HISTOGRAM_BOOLEAN("BackgroundMode.OnStartup.AutoLaunchState",
command_line.HasSwitch(switches::kNoStartupWindow));
UMA_HISTOGRAM_BOOLEAN("BackgroundMode.OnStartup.IsBackgroundModePrefEnabled",
IsBackgroundModePrefEnabled());

Expand Down
9 changes: 2 additions & 7 deletions chrome/browser/ui/startup/startup_browser_creator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,9 @@ void StartupBrowserCreatorImpl::ProcessLaunchURLs(
bool process_startup,
const std::vector<GURL>& urls_to_open,
chrome::HostDesktopType desktop_type) {
// If we're starting up in "background mode" (no open browser window) then
// don't open any browser windows, unless kAutoLaunchAtStartup is also
// specified.
if (process_startup &&
command_line_.HasSwitch(switches::kNoStartupWindow) &&
!command_line_.HasSwitch(switches::kAutoLaunchAtStartup)) {
// Don't open any browser windows if we're starting up in "background mode".
if (process_startup && command_line_.HasSwitch(switches::kNoStartupWindow))
return;
}

// Determine whether or not this launch must include the welcome page.
InitializeWelcomeRunType(urls_to_open);
Expand Down
4 changes: 0 additions & 4 deletions chrome/common/chrome_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ const char kAuthExtensionPath[] = "auth-ext-path";
// Whitelist for Negotiate Auth servers
const char kAuthServerWhitelist[] = "auth-server-whitelist";

// A flag that is used to tell Chrome that it was launched automatically at
// computer startup and not by some user action.
const char kAutoLaunchAtStartup[] = "auto-launch-at-startup";

// This flag makes Chrome auto-select the provided choice when an extension asks
// permission to start desktop capture. Should only be used for tests. For
// instance, --auto-select-desktop-capture-source="Entire screen" will
Expand Down
1 change: 0 additions & 1 deletion chrome/common/chrome_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ extern const char kAppModeAuthCode[];
extern const char kAppModeOAuth2Token[];
extern const char kAuthExtensionPath[];
extern const char kAuthServerWhitelist[];
extern const char kAutoLaunchAtStartup[];
extern const char kAutoSelectDesktopCaptureSource[];
extern const char kBypassAppBannerEngagementChecks[];
extern const char kCertificateTransparencyLog[];
Expand Down
17 changes: 0 additions & 17 deletions chrome/installer/setup/install.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/setup/setup_util.h"
#include "chrome/installer/setup/update_active_setup_version_work_item.h"
#include "chrome/installer/util/auto_launch_util.h"
#include "chrome/installer/util/beacons.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
Expand Down Expand Up @@ -551,22 +550,6 @@ InstallStatus InstallOrUpdateProduct(
RegisterChromeOnMachine(installer_state, *chrome_product,
make_chrome_default || force_chrome_default_for_user);

// Configure auto-launch.
if (result == FIRST_INSTALL_SUCCESS) {
installer_state.UpdateStage(installer::CONFIGURE_AUTO_LAUNCH);

// Add auto-launch key if specified in master_preferences.
bool auto_launch_chrome = false;
prefs.GetBool(
installer::master_preferences::kAutoLaunchChrome,
&auto_launch_chrome);
if (auto_launch_chrome) {
auto_launch_util::EnableForegroundStartAtLogin(
base::ASCIIToUTF16(chrome::kInitialProfile),
installer_state.target_path());
}
}

if (!installer_state.system_install()) {
DCHECK_EQ(chrome_product->distribution(),
BrowserDistribution::GetDistribution());
Expand Down
3 changes: 1 addition & 2 deletions chrome/installer/setup/uninstall.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1151,8 +1151,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
WorkItem::kWow64Default);
}

auto_launch_util::DisableAllAutoStartFeatures(
base::ASCIIToUTF16(chrome::kInitialProfile));
auto_launch_util::DisableBackgroundStartAtLogin();

// If user-level chrome is self-destructing as a result of encountering a
// system-level chrome, retarget owned non-default shortcuts (app shortcuts,
Expand Down
Loading

0 comments on commit a17c5d4

Please sign in to comment.