From 85c9b6a983ddd8fdde9e1b4d24e497c7d14105e5 Mon Sep 17 00:00:00 2001 From: Trent Apted Date: Sun, 16 Sep 2018 12:24:44 +0000 Subject: [PATCH] Remove app_launch_for_metro_restart_win.cc (dead code). Bug: 558054 Change-Id: I51f838746263db44484f13c78d6a08d61a53f2a6 Reviewed-on: https://chromium-review.googlesource.com/1220966 Commit-Queue: Trent Apted Reviewed-by: Gabriel Charette Cr-Commit-Position: refs/heads/master@{#591601} --- chrome/browser/apps/platform_apps/BUILD.gn | 2 - .../app_launch_for_metro_restart_win.cc | 95 ------------------- .../app_launch_for_metro_restart_win.h | 28 ------ chrome/browser/prefs/browser_prefs.cc | 2 - .../prefs/pref_service_incognito_whitelist.cc | 4 - .../startup/startup_browser_creator_impl.cc | 3 - chrome/common/pref_names.cc | 11 --- chrome/common/pref_names.h | 4 - 8 files changed, 149 deletions(-) delete mode 100644 chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.cc delete mode 100644 chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h diff --git a/chrome/browser/apps/platform_apps/BUILD.gn b/chrome/browser/apps/platform_apps/BUILD.gn index e150decd18a848..8939ff7cefcaa6 100644 --- a/chrome/browser/apps/platform_apps/BUILD.gn +++ b/chrome/browser/apps/platform_apps/BUILD.gn @@ -8,8 +8,6 @@ assert(enable_extensions) source_set("platform_apps") { sources = [ - "app_launch_for_metro_restart_win.cc", - "app_launch_for_metro_restart_win.h", "app_load_service.cc", "app_load_service.h", "app_load_service_factory.cc", diff --git a/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.cc b/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.cc deleted file mode 100644 index 98a1a307c1f0ea..00000000000000 --- a/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h" - -#include "apps/launcher.h" -#include "base/bind.h" -#include "base/files/file_path.h" -#include "base/location.h" -#include "base/single_thread_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" -#include "base/time/time.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/common/pref_names.h" -#include "components/prefs/pref_registry_simple.h" -#include "components/prefs/pref_service.h" -#include "extensions/browser/api/app_runtime/app_runtime_api.h" -#include "extensions/browser/extension_system.h" -#include "extensions/common/api/app_runtime.h" -#include "extensions/common/constants.h" - -using extensions::AppRuntimeEventRouter; -using extensions::Extension; -using extensions::ExtensionSystem; - -namespace app_metro_launch { - -namespace { - -void LaunchAppWithId(Profile* profile, const std::string& extension_id) { - extensions::ExtensionService* extension_service = - ExtensionSystem::Get(profile)->extension_service(); - if (!extension_service) - return; - - const Extension* extension = - extension_service->GetExtensionById(extension_id, false); - if (!extension) - return; - - AppRuntimeEventRouter::DispatchOnLaunchedEvent( - profile, extension, extensions::SOURCE_RESTART, nullptr); -} - -} // namespace - -void HandleAppLaunchForMetroRestart(Profile* profile) { - PrefService* prefs = g_browser_process->local_state(); - if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestartProfile)) - return; - - // This will be called for each profile that had a browser window open before - // relaunch. After checking that the preference is set, check that the - // profile that is starting up matches the profile that initially wanted to - // launch the app. - base::FilePath profile_dir = base::FilePath::FromUTF8Unsafe( - prefs->GetString(prefs::kAppLaunchForMetroRestartProfile)); - if (profile_dir.empty() || profile->GetPath().BaseName() != profile_dir) - return; - - prefs->ClearPref(prefs::kAppLaunchForMetroRestartProfile); - - if (!prefs->HasPrefPath(prefs::kAppLaunchForMetroRestart)) - return; - - std::string extension_id = prefs->GetString(prefs::kAppLaunchForMetroRestart); - if (extension_id.empty()) - return; - - prefs->ClearPref(prefs::kAppLaunchForMetroRestart); - - const int kRestartAppLaunchDelayMs = 1000; - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, base::Bind(&LaunchAppWithId, profile, extension_id), - base::TimeDelta::FromMilliseconds(kRestartAppLaunchDelayMs)); -} - -void SetAppLaunchForMetroRestart(Profile* profile, - const std::string& extension_id) { - PrefService* prefs = g_browser_process->local_state(); - prefs->SetString(prefs::kAppLaunchForMetroRestartProfile, - profile->GetPath().BaseName().MaybeAsASCII()); - prefs->SetString(prefs::kAppLaunchForMetroRestart, extension_id); -} - -void RegisterPrefs(PrefRegistrySimple* registry) { - registry->RegisterStringPref(prefs::kAppLaunchForMetroRestart, ""); - registry->RegisterStringPref(prefs::kAppLaunchForMetroRestartProfile, ""); -} - -} // namespace app_metro_launch diff --git a/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h b/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h deleted file mode 100644 index ec9b0206a4ff6e..00000000000000 --- a/chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_APPS_PLATFORM_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_ -#define CHROME_BROWSER_APPS_PLATFORM_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_ - -#include - -class PrefRegistrySimple; -class Profile; - -namespace app_metro_launch { - -// Handles launching apps on browser startup due to an attempt to launch an app -// in Windows 8 Metro mode. -void HandleAppLaunchForMetroRestart(Profile* profile); - -// Set a local pref to launch an app before relaunching chrome in desktop mode. -void SetAppLaunchForMetroRestart(Profile* profile, - const std::string& extension_id); - -// Register preferences to do with launching apps in Metro. -void RegisterPrefs(PrefRegistrySimple* registry); - -} // namespace app_metro_launch - -#endif // CHROME_BROWSER_APPS_PLATFORM_APPS_APP_LAUNCH_FOR_METRO_RESTART_WIN_H_ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 38833ecafca08e..e210eedbb2f939 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -294,7 +294,6 @@ #endif #if defined(OS_WIN) -#include "chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h" #include "chrome/browser/browser_switcher/browser_switcher_prefs.h" #include "chrome/browser/component_updater/sw_reporter_installer_win.h" #if defined(GOOGLE_CHROME_BUILD) @@ -492,7 +491,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) { #endif #if defined(OS_WIN) - app_metro_launch::RegisterPrefs(registry); component_updater::RegisterPrefsForSwReporter(registry); desktop_ios_promotion::RegisterLocalPrefs(registry); #if defined(GOOGLE_CHROME_BUILD) diff --git a/chrome/browser/prefs/pref_service_incognito_whitelist.cc b/chrome/browser/prefs/pref_service_incognito_whitelist.cc index 44cdc3d7c6c0e6..2de253dad734cd 100644 --- a/chrome/browser/prefs/pref_service_incognito_whitelist.cc +++ b/chrome/browser/prefs/pref_service_incognito_whitelist.cc @@ -309,10 +309,6 @@ const char* const kTemporaryIncognitoWhitelist[] = { prefs::kAppListLocalState, #endif // BUILDFLAG(ENABLE_APP_LIST) -#if defined(OS_WIN) - prefs::kAppLaunchForMetroRestart, - prefs::kAppLaunchForMetroRestartProfile, -#endif prefs::kAppShortcutsVersion, prefs::kModuleConflictBubbleShown, diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 98280ffefa817e..9fbbbeb51aac85 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -76,13 +76,10 @@ #endif #if defined(OS_WIN) -#include "base/win/windows_version.h" -#include "chrome/browser/apps/platform_apps/app_launch_for_metro_restart_win.h" #if defined(GOOGLE_CHROME_BUILD) #include "chrome/browser/conflicts/incompatible_applications_updater_win.h" #endif // defined(GOOGLE_CHROME_BUILD) #include "chrome/browser/notifications/notification_platform_bridge_win.h" -#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/shell_integration_win.h" #endif // defined(OS_WIN) diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 5ef55545f244af..012d9a0f53e19f 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -2165,17 +2165,6 @@ const char kRLZDisabled[] = "rlz.disabled"; const char kAppListLocalState[] = "app_list.local_state"; #endif -#if defined(OS_WIN) -// If set, the user requested to launch the app with this extension id while -// in Metro mode, and then relaunched to Desktop mode to start it. -const char kAppLaunchForMetroRestart[] = "apps.app_launch_for_metro_restart"; - -// Set with |kAppLaunchForMetroRestart|, the profile whose loading triggers -// launch of the specified app when restarting Chrome in desktop mode. -const char kAppLaunchForMetroRestartProfile[] = - "apps.app_launch_for_metro_restart_profile"; -#endif - // An integer that is incremented whenever changes are made to app shortcuts. // Increasing this causes all app shortcuts to be recreated. const char kAppShortcutsVersion[] = "apps.shortcuts_version"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index ad4fea394be3da..feb9ce56c9b839 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -760,10 +760,6 @@ extern const char kRLZDisabled[]; extern const char kAppListLocalState[]; #endif // BUILDFLAG(ENABLE_APP_LIST) -#if defined(OS_WIN) -extern const char kAppLaunchForMetroRestart[]; -extern const char kAppLaunchForMetroRestartProfile[]; -#endif extern const char kAppShortcutsVersion[]; extern const char kModuleConflictBubbleShown[];