Commit 9017a43d authored by scottmg's avatar scottmg Committed by Commit bot

Remove PerAppSettingsService

Was only required for different |HostDesktopType|s which are being
removed.

R=benwells@chromium.org
BUG=558054

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

Cr-Commit-Position: refs/heads/master@{#374789}
parent ffaec538
// Copyright 2014 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/per_app_settings_service.h"
PerAppSettingsService::PerAppSettingsService() {
}
PerAppSettingsService::~PerAppSettingsService() {
}
void PerAppSettingsService::SetDesktopLastLaunchedFrom(
const std::string& app_id, chrome::HostDesktopType host_desktop) {
default_desktops_[app_id] = host_desktop;
}
chrome::HostDesktopType PerAppSettingsService::GetDesktopLastLaunchedFrom(
const std::string& app_id) const {
DesktopMap::const_iterator it = default_desktops_.find(app_id);
if (it == default_desktops_.end())
NOTREACHED();
return it->second;
}
bool PerAppSettingsService::HasDesktopLastLaunchedFrom(
const std::string& app_id) const {
return default_desktops_.find(app_id) != default_desktops_.end();
}
// Copyright 2014 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_PER_APP_SETTINGS_SERVICE_H_
#define CHROME_BROWSER_APPS_PER_APP_SETTINGS_SERVICE_H_
#include <map>
#include <string>
#include "base/macros.h"
#include "chrome/browser/ui/host_desktop.h"
#include "components/keyed_service/core/keyed_service.h"
// Stores settings for apps that only persist until the browser context is
// destroyed.
class PerAppSettingsService : public KeyedService {
public:
PerAppSettingsService();
~PerAppSettingsService() override;
// Sets/gets the desktop that |app_id| was last launched from.
void SetDesktopLastLaunchedFrom(
const std::string& app_id, chrome::HostDesktopType host);
chrome::HostDesktopType GetDesktopLastLaunchedFrom(
const std::string& app_id) const;
bool HasDesktopLastLaunchedFrom(const std::string& app_id) const;
private:
typedef std::map<std::string, chrome::HostDesktopType> DesktopMap;
DesktopMap default_desktops_;
DISALLOW_COPY_AND_ASSIGN(PerAppSettingsService);
};
#endif // CHROME_BROWSER_APPS_PER_APP_SETTINGS_SERVICE_H_
// Copyright 2014 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/per_app_settings_service_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/apps/per_app_settings_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extensions_browser_client.h"
// static
PerAppSettingsServiceFactory* PerAppSettingsServiceFactory::GetInstance() {
return base::Singleton<PerAppSettingsServiceFactory>::get();
}
// static
PerAppSettingsService* PerAppSettingsServiceFactory::GetForBrowserContext(
content::BrowserContext* browser_context) {
return static_cast<PerAppSettingsService*>(
GetInstance()->GetServiceForBrowserContext(
browser_context, true /* create */));
}
PerAppSettingsServiceFactory::PerAppSettingsServiceFactory()
: BrowserContextKeyedServiceFactory(
"PerAppSettingsServiceFactory",
BrowserContextDependencyManager::GetInstance()) {
}
PerAppSettingsServiceFactory::~PerAppSettingsServiceFactory() {}
KeyedService* PerAppSettingsServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
return new PerAppSettingsService;
}
bool PerAppSettingsServiceFactory::ServiceIsCreatedWithBrowserContext() const {
return false;
}
content::BrowserContext* PerAppSettingsServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return extensions::ExtensionsBrowserClient::Get()->
GetOriginalContext(context);
}
// Copyright 2014 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_PER_APP_SETTINGS_SERVICE_FACTORY_H_
#define CHROME_BROWSER_APPS_PER_APP_SETTINGS_SERVICE_FACTORY_H_
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
namespace content {
class BrowserContext;
}
class PerAppSettingsService;
namespace base {
template <typename T> struct DefaultSingletonTraits;
}
class PerAppSettingsServiceFactory : public BrowserContextKeyedServiceFactory {
public:
static PerAppSettingsServiceFactory* GetInstance();
static PerAppSettingsService* GetForBrowserContext(
content::BrowserContext* browser_context);
private:
friend struct base::DefaultSingletonTraits<PerAppSettingsServiceFactory>;
PerAppSettingsServiceFactory();
~PerAppSettingsServiceFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
};
#endif // CHROME_BROWSER_APPS_PER_APP_SETTINGS_SERVICE_FACTORY_H_
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/apps/per_app_settings_service.h"
#include "chrome/browser/apps/per_app_settings_service_factory.h"
#include "chrome/browser/engagement/site_engagement_service.h" #include "chrome/browser/engagement/site_engagement_service.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h" #include "chrome/browser/extensions/launch_util.h"
...@@ -316,11 +314,6 @@ WebContents* OpenEnabledApplication(const AppLaunchParams& params) { ...@@ -316,11 +314,6 @@ WebContents* OpenEnabledApplication(const AppLaunchParams& params) {
prefs->SetActiveBit(extension->id(), true); prefs->SetActiveBit(extension->id(), true);
if (CanLaunchViaEvent(extension)) { if (CanLaunchViaEvent(extension)) {
// Remember what desktop the launch happened on so that when the app opens a
// window we can open them on the right desktop.
PerAppSettingsServiceFactory::GetForBrowserContext(profile)->
SetDesktopLastLaunchedFrom(extension->id(), params.desktop_type);
apps::LaunchPlatformAppWithCommandLine(profile, apps::LaunchPlatformAppWithCommandLine(profile,
extension, extension,
params.command_line, params.command_line,
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/apps/per_app_settings_service.h"
#include "chrome/browser/apps/per_app_settings_service_factory.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/views/apps/app_window_desktop_native_widget_aura_win.h" #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win.h"
...@@ -55,29 +53,6 @@ void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( ...@@ -55,29 +53,6 @@ void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit(
views::Widget* widget) { views::Widget* widget) {
ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params, ChromeNativeAppWindowViewsAura::OnBeforeWidgetInit(create_params, init_params,
widget); widget);
content::BrowserContext* browser_context = app_window()->browser_context();
std::string extension_id = app_window()->extension_id();
// If an app has any existing windows, ensure new ones are created on the
// same desktop.
extensions::AppWindow* any_existing_window =
extensions::AppWindowRegistry::Get(browser_context)
->GetCurrentAppWindowForApp(extension_id);
chrome::HostDesktopType desktop_type;
if (any_existing_window) {
desktop_type = chrome::GetHostDesktopTypeForNativeWindow(
any_existing_window->GetNativeWindow());
} else {
PerAppSettingsService* settings =
PerAppSettingsServiceFactory::GetForBrowserContext(browser_context);
if (settings->HasDesktopLastLaunchedFrom(extension_id)) {
desktop_type = settings->GetDesktopLastLaunchedFrom(extension_id);
} else {
// We don't know what desktop this app was last launched from, so take our
// best guess as to what desktop the user is on.
desktop_type = chrome::GetActiveDesktop();
}
}
init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this);
is_translucent_ = is_translucent_ =
......
...@@ -96,10 +96,6 @@ ...@@ -96,10 +96,6 @@
'browser/apps/app_window_registry_util.h', 'browser/apps/app_window_registry_util.h',
'browser/apps/install_chrome_app.cc', 'browser/apps/install_chrome_app.cc',
'browser/apps/install_chrome_app.h', 'browser/apps/install_chrome_app.h',
'browser/apps/per_app_settings_service.cc',
'browser/apps/per_app_settings_service.h',
'browser/apps/per_app_settings_service_factory.cc',
'browser/apps/per_app_settings_service_factory.h',
'browser/apps/scoped_keep_alive.cc', 'browser/apps/scoped_keep_alive.cc',
'browser/apps/scoped_keep_alive.h', 'browser/apps/scoped_keep_alive.h',
'browser/apps/shortcut_manager.cc', 'browser/apps/shortcut_manager.cc',
......
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