Commit 0a98cc85 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove ash::ShellContentState

Update the last few tests that used it to pass the browser context
around in other ways.

TBR=sky@chromium.org

Bug: 826374
Change-Id: Ic6de0e33b8ccc20ab84a0dcf8309cc103595f5f5
Reviewed-on: https://chromium-review.googlesource.com/1112666
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569902}
parent cf69822f
...@@ -1456,8 +1456,6 @@ component("ash_with_content") { ...@@ -1456,8 +1456,6 @@ component("ash_with_content") {
"content/keyboard_overlay/keyboard_overlay_view.h", "content/keyboard_overlay/keyboard_overlay_view.h",
"content/screen_orientation_delegate_chromeos.cc", "content/screen_orientation_delegate_chromeos.cc",
"content/screen_orientation_delegate_chromeos.h", "content/screen_orientation_delegate_chromeos.h",
"content/shell_content_state.cc",
"content/shell_content_state.h",
] ]
defines = [ "ASH_WITH_CONTENT_IMPLEMENTATION" ] defines = [ "ASH_WITH_CONTENT_IMPLEMENTATION" ]
...@@ -1555,8 +1553,6 @@ static_library("ash_shell_lib_with_content") { ...@@ -1555,8 +1553,6 @@ static_library("ash_shell_lib_with_content") {
"shell/content/client/shell_content_browser_client.h", "shell/content/client/shell_content_browser_client.h",
"shell/content/client/shell_main_delegate.cc", "shell/content/client/shell_main_delegate.cc",
"shell/content/client/shell_main_delegate.h", "shell/content/client/shell_main_delegate.h",
"shell/content/shell_content_state_impl.cc",
"shell/content/shell_content_state_impl.h",
] ]
deps = [ deps = [
...@@ -2121,8 +2117,6 @@ static_library("test_support_with_content") { ...@@ -2121,8 +2117,6 @@ static_library("test_support_with_content") {
sources = [ sources = [
"test/ash_test_environment_content.cc", "test/ash_test_environment_content.cc",
"test/ash_test_environment_content.h", "test/ash_test_environment_content.h",
"test/content/test_shell_content_state.cc",
"test/content/test_shell_content_state.h",
] ]
configs += [ "//build/config:precompiled_headers" ] configs += [ "//build/config:precompiled_headers" ]
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <vector> #include <vector>
#include "ash/content/screen_orientation_delegate_chromeos.h" #include "ash/content/screen_orientation_delegate_chromeos.h"
#include "ash/content/shell_content_state.h"
#include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h" #include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_environment_content.h" #include "ash/test/ash_test_environment_content.h"
#include "ash/test/ash_test_helper.h" #include "ash/test/ash_test_helper.h"
#include "ash/test/content/test_shell_content_state.h"
#include "ash/test_shell_delegate.h" #include "ash/test_shell_delegate.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
...@@ -153,6 +151,8 @@ class ScreenOrientationControllerTest : public AshTestBase { ...@@ -153,6 +151,8 @@ class ScreenOrientationControllerTest : public AshTestBase {
private: private:
ScreenOrientationDelegateChromeos delegate_; ScreenOrientationDelegateChromeos delegate_;
content::TestBrowserContext browser_context_;
// Optional content::BrowserContext used for two window tests. // Optional content::BrowserContext used for two window tests.
std::unique_ptr<content::BrowserContext> secondary_browser_context_; std::unique_ptr<content::BrowserContext> secondary_browser_context_;
...@@ -171,8 +171,8 @@ ScreenOrientationControllerTest::~ScreenOrientationControllerTest() = default; ...@@ -171,8 +171,8 @@ ScreenOrientationControllerTest::~ScreenOrientationControllerTest() = default;
std::unique_ptr<content::WebContents> std::unique_ptr<content::WebContents>
ScreenOrientationControllerTest::CreateWebContents() { ScreenOrientationControllerTest::CreateWebContents() {
return content::WebContentsTester::CreateTestWebContents( return content::WebContentsTester::CreateTestWebContents(&browser_context_,
ShellContentState::GetInstance()->GetActiveBrowserContext(), nullptr); nullptr);
} }
std::unique_ptr<content::WebContents> std::unique_ptr<content::WebContents>
......
include_rules = [ include_rules = [
"+content/public/browser", "+content/public/browser",
] ]
specific_include_rules = {
".*test\.cc": [
"+content/public/test/test_browser_context.h",
],
}
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
#include <algorithm> #include <algorithm>
#include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h" #include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h"
#include "ash/content/shell_content_state.h"
#include "ash/public/cpp/accelerators.h" #include "ash/public/cpp/accelerators.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "content/public/test/test_browser_context.h"
#include "ui/web_dialogs/test/test_web_contents_handler.h" #include "ui/web_dialogs/test/test_web_contents_handler.h"
#include "ui/web_dialogs/test/test_web_dialog_delegate.h" #include "ui/web_dialogs/test/test_web_dialog_delegate.h"
...@@ -26,9 +26,9 @@ bool operator==(const KeyboardOverlayView::KeyEventData& lhs, ...@@ -26,9 +26,9 @@ bool operator==(const KeyboardOverlayView::KeyEventData& lhs,
// Verifies that the accelerators that open the keyboard overlay close it. // Verifies that the accelerators that open the keyboard overlay close it.
TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) { TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) {
ui::test::TestWebDialogDelegate delegate(GURL("chrome://keyboardoverlay")); ui::test::TestWebDialogDelegate delegate(GURL("chrome://keyboardoverlay"));
KeyboardOverlayView view( content::TestBrowserContext browser_context;
ShellContentState::GetInstance()->GetActiveBrowserContext(), &delegate, KeyboardOverlayView view(&browser_context, &delegate,
new ui::test::TestWebContentsHandler); new ui::test::TestWebContentsHandler);
for (size_t i = 0; i < kAcceleratorDataLength; ++i) { for (size_t i = 0; i < kAcceleratorDataLength; ++i) {
if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY)
continue; continue;
...@@ -45,9 +45,9 @@ TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) { ...@@ -45,9 +45,9 @@ TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) {
// canceling key. // canceling key.
TEST_F(KeyboardOverlayViewTest, TestCancelingKeysWithNonModifierFlags) { TEST_F(KeyboardOverlayViewTest, TestCancelingKeysWithNonModifierFlags) {
ui::test::TestWebDialogDelegate delegate(GURL("chrome://keyboardoverlay")); ui::test::TestWebDialogDelegate delegate(GURL("chrome://keyboardoverlay"));
KeyboardOverlayView view( content::TestBrowserContext browser_context;
ShellContentState::GetInstance()->GetActiveBrowserContext(), &delegate, KeyboardOverlayView view(&browser_context, &delegate,
new ui::test::TestWebContentsHandler); new ui::test::TestWebContentsHandler);
const int kNonModifierFlags = ui::EF_IS_SYNTHESIZED | ui::EF_NUM_LOCK_ON | const int kNonModifierFlags = ui::EF_IS_SYNTHESIZED | ui::EF_NUM_LOCK_ON |
ui::EF_IME_FABRICATED_KEY | ui::EF_IS_REPEAT; ui::EF_IME_FABRICATED_KEY | ui::EF_IS_REPEAT;
......
// Copyright 2015 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 "ash/content/shell_content_state.h"
#include "base/logging.h"
#include "ui/keyboard/keyboard_resource_util.h"
namespace ash {
// static
ShellContentState* ShellContentState::instance_ = nullptr;
// static
void ShellContentState::SetInstance(ShellContentState* instance) {
DCHECK(!instance_);
instance_ = instance;
}
// static
ShellContentState* ShellContentState::GetInstance() {
DCHECK(instance_);
return instance_;
}
// static
void ShellContentState::DestroyInstance() {
DCHECK(instance_);
delete instance_;
instance_ = nullptr;
}
ShellContentState::ShellContentState() {
// The keyboard system must be initialized before the RootWindowController is
// created.
keyboard::InitializeKeyboardResources();
}
ShellContentState::~ShellContentState() = default;
} // namespace ash
// Copyright 2015 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 ASH_CONTENT_SHELL_CONTENT_STATE_H_
#define ASH_CONTENT_SHELL_CONTENT_STATE_H_
#include "ash/content/ash_with_content_export.h"
#include "ash/public/cpp/session_types.h"
#include "base/macros.h"
namespace aura {
class Window;
}
namespace content {
class BrowserContext;
}
namespace ash {
class ASH_WITH_CONTENT_EXPORT ShellContentState {
public:
static void SetInstance(ShellContentState* state);
static ShellContentState* GetInstance();
static void DestroyInstance();
// Provides the embedder a way to return an active browser context for the
// current user scenario. Default implementation here returns nullptr.
virtual content::BrowserContext* GetActiveBrowserContext() = 0;
protected:
ShellContentState();
virtual ~ShellContentState();
private:
static ShellContentState* instance_;
DISALLOW_COPY_AND_ASSIGN(ShellContentState);
};
} // namespace ash
#endif // ASH_CONTENT_SHELL_CONTENT_STATE_H_
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
#include "ash/components/shortcut_viewer/public/mojom/shortcut_viewer.mojom.h" #include "ash/components/shortcut_viewer/public/mojom/shortcut_viewer.mojom.h"
#include "ash/components/tap_visualizer/public/mojom/constants.mojom.h" #include "ash/components/tap_visualizer/public/mojom/constants.mojom.h"
#include "ash/content/content_gpu_interface_provider.h" #include "ash/content/content_gpu_interface_provider.h"
#include "ash/content/shell_content_state.h"
#include "ash/login_status.h" #include "ash/login_status.h"
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell/content/shell_content_state_impl.h"
#include "ash/shell/example_session_controller_client.h" #include "ash/shell/example_session_controller_client.h"
#include "ash/shell/shell_delegate_impl.h" #include "ash/shell/shell_delegate_impl.h"
#include "ash/shell/shell_views_delegate.h" #include "ash/shell/shell_views_delegate.h"
...@@ -89,8 +87,6 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ...@@ -89,8 +87,6 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
chromeos::PowerPolicyController::Initialize( chromeos::PowerPolicyController::Initialize(
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()); chromeos::DBusThreadManager::Get()->GetPowerManagerClient());
ShellContentState::SetInstance(
new ShellContentStateImpl(browser_context_.get()));
ui::MaterialDesignController::Initialize(); ui::MaterialDesignController::Initialize();
ash::ShellInitParams init_params; ash::ShellInitParams init_params;
init_params.shell_port = std::make_unique<ash::ShellPortClassic>(); init_params.shell_port = std::make_unique<ash::ShellPortClassic>();
...@@ -112,8 +108,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ...@@ -112,8 +108,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
ash::shell::InitWindowTypeLauncher(base::Bind( ash::shell::InitWindowTypeLauncher(base::Bind(
&views::examples::ShowExamplesWindowWithContent, &views::examples::ShowExamplesWindowWithContent,
views::examples::DO_NOTHING_ON_CLOSE, views::examples::DO_NOTHING_ON_CLOSE, browser_context_.get(), nullptr));
ShellContentState::GetInstance()->GetActiveBrowserContext(), nullptr));
ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
...@@ -139,7 +134,6 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() { ...@@ -139,7 +134,6 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
void ShellBrowserMainParts::PostMainMessageLoopRun() { void ShellBrowserMainParts::PostMainMessageLoopRun() {
window_watcher_.reset(); window_watcher_.reset();
ash::Shell::DeleteInstance(); ash::Shell::DeleteInstance();
ShellContentState::DestroyInstance();
chromeos::CrasAudioHandler::Shutdown(); chromeos::CrasAudioHandler::Shutdown();
......
// Copyright 2015 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 "ash/shell/content/shell_content_state_impl.h"
#include "content/public/browser/browser_context.h"
namespace ash {
ShellContentStateImpl::ShellContentStateImpl(content::BrowserContext* context)
: browser_context_(context) {}
ShellContentStateImpl::~ShellContentStateImpl() = default;
content::BrowserContext* ShellContentStateImpl::GetActiveBrowserContext() {
return browser_context_;
}
} // namespace ash
// Copyright 2015 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 ASH_SHELL_CONTENT_SHELL_CONTENT_STATE_IMPL_H_
#define ASH_SHELL_CONTENT_SHELL_CONTENT_STATE_IMPL_H_
#include "ash/content/shell_content_state.h"
#include "base/macros.h"
namespace ash {
class ShellContentStateImpl : public ShellContentState {
public:
explicit ShellContentStateImpl(content::BrowserContext* context);
private:
~ShellContentStateImpl() override;
// Overridden from ShellContentState:
content::BrowserContext* GetActiveBrowserContext() override;
content::BrowserContext* browser_context_;
DISALLOW_COPY_AND_ASSIGN(ShellContentStateImpl);
};
} // namespace ash
#endif // ASH_SHELL_CONTENT_SHELL_CONTENT_STATE_IMPL_H_
...@@ -11,7 +11,6 @@ specific_include_rules = { ...@@ -11,7 +11,6 @@ specific_include_rules = {
"+content/public/browser/browser_thread.h", "+content/public/browser/browser_thread.h",
"+content/public/test/web_contents_tester.h", "+content/public/test/web_contents_tester.h",
"+content/public/test/test_browser_thread_bundle.h", "+content/public/test/test_browser_thread_bundle.h",
"+content/public/test/test_browser_context.h",
], ],
"ash_test_helper\.cc": [ "ash_test_helper\.cc": [
"+ash/host", "+ash/host",
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <memory> #include <memory>
#include "ash/test/ash_test_views_delegate.h" #include "ash/test/ash_test_views_delegate.h"
#include "ash/test/content/test_shell_content_state.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/web_contents_tester.h" #include "content/public/test/web_contents_tester.h"
...@@ -38,20 +37,13 @@ AshTestEnvironmentContent::AshTestEnvironmentContent() ...@@ -38,20 +37,13 @@ AshTestEnvironmentContent::AshTestEnvironmentContent()
AshTestEnvironmentContent::~AshTestEnvironmentContent() = default; AshTestEnvironmentContent::~AshTestEnvironmentContent() = default;
void AshTestEnvironmentContent::SetUp() { void AshTestEnvironmentContent::SetUp() {
ShellContentState* content_state = content_state_;
if (!content_state) {
test_shell_content_state_ = new TestShellContentState;
content_state = test_shell_content_state_;
}
scoped_web_contents_creator_ = scoped_web_contents_creator_ =
std::make_unique<views::WebView::ScopedWebContentsCreatorForTesting>( std::make_unique<views::WebView::ScopedWebContentsCreatorForTesting>(
base::BindRepeating(&CreateWebContents)); base::BindRepeating(&CreateWebContents));
ShellContentState::SetInstance(content_state);
} }
void AshTestEnvironmentContent::TearDown() { void AshTestEnvironmentContent::TearDown() {
scoped_web_contents_creator_.reset(); scoped_web_contents_creator_.reset();
ShellContentState::DestroyInstance();
} }
std::unique_ptr<AshTestViewsDelegate> std::unique_ptr<AshTestViewsDelegate>
......
...@@ -15,8 +15,6 @@ class TestBrowserThreadBundle; ...@@ -15,8 +15,6 @@ class TestBrowserThreadBundle;
namespace ash { namespace ash {
class ShellContentState;
class TestShellContentState;
// AshTestEnvironment implementation for tests that use content. // AshTestEnvironment implementation for tests that use content.
class AshTestEnvironmentContent : public AshTestEnvironment { class AshTestEnvironmentContent : public AshTestEnvironment {
...@@ -24,13 +22,6 @@ class AshTestEnvironmentContent : public AshTestEnvironment { ...@@ -24,13 +22,6 @@ class AshTestEnvironmentContent : public AshTestEnvironment {
AshTestEnvironmentContent(); AshTestEnvironmentContent();
~AshTestEnvironmentContent() override; ~AshTestEnvironmentContent() override;
TestShellContentState* test_shell_content_state() {
return test_shell_content_state_;
}
void set_content_state(ShellContentState* content_state) {
content_state_ = content_state;
}
// AshTestEnvironment: // AshTestEnvironment:
void SetUp() override; void SetUp() override;
void TearDown() override; void TearDown() override;
...@@ -41,15 +32,6 @@ class AshTestEnvironmentContent : public AshTestEnvironment { ...@@ -41,15 +32,6 @@ class AshTestEnvironmentContent : public AshTestEnvironment {
std::unique_ptr<views::WebView::ScopedWebContentsCreatorForTesting> std::unique_ptr<views::WebView::ScopedWebContentsCreatorForTesting>
scoped_web_contents_creator_; scoped_web_contents_creator_;
// An implementation of ShellContentState supplied by the user prior to
// SetUp().
ShellContentState* content_state_ = nullptr;
// If |content_state_| is not set prior to SetUp(), this value will be
// set to an instance of TestShellContentState created by this class. If
// |content_state_| is non-null, this will be nullptr.
TestShellContentState* test_shell_content_state_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(AshTestEnvironmentContent); DISALLOW_COPY_AND_ASSIGN(AshTestEnvironmentContent);
}; };
......
// Copyright 2015 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 "ash/test/content/test_shell_content_state.h"
#include "content/public/test/test_browser_context.h"
namespace ash {
TestShellContentState::TestShellContentState() = default;
TestShellContentState::~TestShellContentState() = default;
content::BrowserContext* TestShellContentState::GetActiveBrowserContext() {
active_browser_context_.reset(new content::TestBrowserContext());
return active_browser_context_.get();
}
} // namespace ash
// Copyright 2015 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 ASH_TEST_CONTENT_TEST_SHELL_CONTENT_STATE_H_
#define ASH_TEST_CONTENT_TEST_SHELL_CONTENT_STATE_H_
#include <memory>
#include "ash/content/shell_content_state.h"
#include "base/macros.h"
namespace content {
class BrowserContext;
}
namespace ash {
class TestShellContentState : public ShellContentState {
public:
TestShellContentState();
private:
~TestShellContentState() override;
// Overridden from ShellContentState:
content::BrowserContext* GetActiveBrowserContext() override;
std::unique_ptr<content::BrowserContext> active_browser_context_;
DISALLOW_COPY_AND_ASSIGN(TestShellContentState);
};
} // namespace ash
#endif // ASH_TEST_CONTENT_TEST_SHELL_CONTENT_STATE_H_
...@@ -1787,8 +1787,6 @@ split_static_library("ui") { ...@@ -1787,8 +1787,6 @@ split_static_library("ui") {
"ash/chrome_screenshot_grabber.cc", "ash/chrome_screenshot_grabber.cc",
"ash/chrome_screenshot_grabber.h", "ash/chrome_screenshot_grabber.h",
"ash/chrome_screenshot_grabber_test_observer.h", "ash/chrome_screenshot_grabber_test_observer.h",
"ash/chrome_shell_content_state.cc",
"ash/chrome_shell_content_state.h",
"ash/chrome_shell_delegate.cc", "ash/chrome_shell_delegate.cc",
"ash/chrome_shell_delegate.h", "ash/chrome_shell_delegate.h",
"ash/ime_controller_client.cc", "ash/ime_controller_client.cc",
......
...@@ -51,10 +51,6 @@ specific_include_rules = { ...@@ -51,10 +51,6 @@ specific_include_rules = {
"+ash/screenshot_delegate.h", "+ash/screenshot_delegate.h",
"+ash/shell.h", "+ash/shell.h",
], ],
# https://crbug.com/672277
"chrome_shell_content_state\.h": [
"+ash/content/shell_content_state.h",
],
# https://crbug.com/665064 # https://crbug.com/665064
"chrome_shell_delegate.*": [ "chrome_shell_delegate.*": [
# https://crbug.com/756054 # https://crbug.com/756054
...@@ -63,10 +59,6 @@ specific_include_rules = { ...@@ -63,10 +59,6 @@ specific_include_rules = {
"+ash/screenshot_delegate.h", "+ash/screenshot_delegate.h",
"+ash/shell_delegate.h", "+ash/shell_delegate.h",
], ],
# https://crbug.com/672277
"session_util\.cc": [
"+ash/content/shell_content_state.h",
],
# For ash::Shell::GetContainer (!mash) # For ash::Shell::GetContainer (!mash)
"system_tray_client\.cc": [ "system_tray_client\.cc": [
"+ash/shell.h", "+ash/shell.h",
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "ash/shell_port_classic.h" #include "ash/shell_port_classic.h"
#include "ash/window_manager.h" #include "ash/window_manager.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/ash/chrome_shell_content_state.h"
#include "chrome/browser/ui/ash/chrome_shell_delegate.h" #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
#include "content/public/browser/context_factory.h" #include "content/public/browser/context_factory.h"
...@@ -49,13 +48,10 @@ void AshShellInit::RegisterDisplayPrefs(PrefRegistrySimple* registry) { ...@@ -49,13 +48,10 @@ void AshShellInit::RegisterDisplayPrefs(PrefRegistrySimple* registry) {
} }
AshShellInit::AshShellInit() { AshShellInit::AshShellInit() {
// Balanced by a call to DestroyInstance() below.
ash::ShellContentState::SetInstance(new ChromeShellContentState);
CreateClassicShell(); CreateClassicShell();
ash::Shell::GetPrimaryRootWindow()->GetHost()->Show(); ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
} }
AshShellInit::~AshShellInit() { AshShellInit::~AshShellInit() {
ash::Shell::DeleteInstance(); ash::Shell::DeleteInstance();
ash::ShellContentState::DestroyInstance();
} }
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "chrome/browser/ui/ash/ash_shell_init.h" #include "chrome/browser/ui/ash/ash_shell_init.h"
#include "chrome/browser/ui/ash/cast_config_client_media_router.h" #include "chrome/browser/ui/ash/cast_config_client_media_router.h"
#include "chrome/browser/ui/ash/chrome_new_window_client.h" #include "chrome/browser/ui/ash/chrome_new_window_client.h"
#include "chrome/browser/ui/ash/chrome_shell_content_state.h"
#include "chrome/browser/ui/ash/ime_controller_client.h" #include "chrome/browser/ui/ash/ime_controller_client.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/login_screen_client.h"
...@@ -237,9 +236,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { ...@@ -237,9 +236,6 @@ void ChromeBrowserMainExtraPartsAsh::PreProfileInit() {
} }
void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
if (!features::IsAshInBrowserProcess())
chrome_shell_content_state_ = std::make_unique<ChromeShellContentState>();
cast_config_client_media_router_ = cast_config_client_media_router_ =
std::make_unique<CastConfigClientMediaRouter>(); std::make_unique<CastConfigClientMediaRouter>();
login_screen_client_ = std::make_unique<LoginScreenClient>(); login_screen_client_ = std::make_unique<LoginScreenClient>();
......
...@@ -29,7 +29,6 @@ class AppListClientImpl; ...@@ -29,7 +29,6 @@ class AppListClientImpl;
class AshShellInit; class AshShellInit;
class CastConfigClientMediaRouter; class CastConfigClientMediaRouter;
class ChromeNewWindowClient; class ChromeNewWindowClient;
class ChromeShellContentState;
class DataPromoNotification; class DataPromoNotification;
class ImeControllerClient; class ImeControllerClient;
class ImmersiveContextMus; class ImmersiveContextMus;
...@@ -119,9 +118,6 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts { ...@@ -119,9 +118,6 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
std::unique_ptr<AssistantClient> assistant_client_; std::unique_ptr<AssistantClient> assistant_client_;
#endif #endif
// Initialized in PostProfileInit if ash config == MASH:
std::unique_ptr<ChromeShellContentState> chrome_shell_content_state_;
// Initialized in PostProfileInit in all configs: // Initialized in PostProfileInit in all configs:
std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_; std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_;
std::unique_ptr<LoginScreenClient> login_screen_client_; std::unique_ptr<LoginScreenClient> login_screen_client_;
......
// Copyright 2015 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/ui/ash/chrome_shell_content_state.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/browser_context.h"
namespace {
ChromeShellContentState* g_chrome_shell_content_state_instance = nullptr;
} // namespace
// static
ChromeShellContentState* ChromeShellContentState::GetInstance() {
DCHECK(g_chrome_shell_content_state_instance);
return g_chrome_shell_content_state_instance;
}
ChromeShellContentState::ChromeShellContentState() {
DCHECK(!g_chrome_shell_content_state_instance);
g_chrome_shell_content_state_instance = this;
}
ChromeShellContentState::~ChromeShellContentState() {
DCHECK_EQ(this, g_chrome_shell_content_state_instance);
g_chrome_shell_content_state_instance = nullptr;
}
content::BrowserContext* ChromeShellContentState::GetActiveBrowserContext() {
return ProfileManager::GetActiveUserProfile();
}
// Copyright 2015 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_UI_ASH_CHROME_SHELL_CONTENT_STATE_H_
#define CHROME_BROWSER_UI_ASH_CHROME_SHELL_CONTENT_STATE_H_
#include "ash/content/shell_content_state.h"
#include "base/macros.h"
class ChromeShellContentState : public ash::ShellContentState {
public:
ChromeShellContentState();
~ChromeShellContentState() override;
static ChromeShellContentState* GetInstance();
// Overridden from ash::ShellContentState:
content::BrowserContext* GetActiveBrowserContext() override;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeShellContentState);
};
#endif // CHROME_BROWSER_UI_ASH_CHROME_SHELL_CONTENT_STATE_H_
...@@ -99,7 +99,8 @@ service_manager::Connector* ChromeShellDelegate::GetShellConnector() const { ...@@ -99,7 +99,8 @@ service_manager::Connector* ChromeShellDelegate::GetShellConnector() const {
} }
bool ChromeShellDelegate::CanShowWindowForUser(aura::Window* window) const { bool ChromeShellDelegate::CanShowWindowForUser(aura::Window* window) const {
return ::CanShowWindowForUser(window, base::Bind(&GetActiveBrowserContext)); return ::CanShowWindowForUser(window,
base::BindRepeating(&GetActiveBrowserContext));
} }
void ChromeShellDelegate::PreInit() { void ChromeShellDelegate::PreInit() {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "ash/content/shell_content_state.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -70,36 +69,22 @@ const char kBAccountIdString[] = ...@@ -70,36 +69,22 @@ const char kBAccountIdString[] =
const char kArrowBAccountIdString[] = const char kArrowBAccountIdString[] =
"->{\"account_type\":\"unknown\",\"email\":\"B\"}"; "->{\"account_type\":\"unknown\",\"email\":\"B\"}";
// TODO(beng): This implementation seems only superficially different to the const content::BrowserContext* GetActiveContext() {
// production impl. Evaluate whether or not we can just use that const user_manager::UserManager* user_manager =
// one. user_manager::UserManager::Get();
class TestShellContentState : public ash::ShellContentState { const user_manager::User* active_user = user_manager->GetActiveUser();
public: return active_user ? multi_user_util::GetProfileFromAccountId(
TestShellContentState() {} active_user->GetAccountId())
~TestShellContentState() override {} : nullptr;
}
private:
content::BrowserContext* GetActiveBrowserContext() override {
const user_manager::UserManager* user_manager =
user_manager::UserManager::Get();
const user_manager::User* active_user = user_manager->GetActiveUser();
return active_user ? multi_user_util::GetProfileFromAccountId(
active_user->GetAccountId())
: NULL;
}
DISALLOW_COPY_AND_ASSIGN(TestShellContentState);
};
class TestShellDelegateChromeOS : public ash::TestShellDelegate { class TestShellDelegateChromeOS : public ash::TestShellDelegate {
public: public:
TestShellDelegateChromeOS() {} TestShellDelegateChromeOS() {}
bool CanShowWindowForUser(aura::Window* window) const override { bool CanShowWindowForUser(aura::Window* window) const override {
return ::CanShowWindowForUser( return ::CanShowWindowForUser(window,
window, base::BindRepeating(&GetActiveContext));
base::Bind(&ash::ShellContentState::GetActiveBrowserContext,
base::Unretained(ash::ShellContentState::GetInstance())));
} }
private: private:
...@@ -289,10 +274,6 @@ void MultiUserWindowManagerChromeOSTest::SetUp() { ...@@ -289,10 +274,6 @@ void MultiUserWindowManagerChromeOSTest::SetUp() {
chromeos::DeviceSettingsService::Initialize(); chromeos::DeviceSettingsService::Initialize();
chromeos::CrosSettings::Initialize(); chromeos::CrosSettings::Initialize();
ash_test_helper()->set_test_shell_delegate(new TestShellDelegateChromeOS); ash_test_helper()->set_test_shell_delegate(new TestShellDelegateChromeOS);
ash::AshTestEnvironmentContent* test_environment =
static_cast<ash::AshTestEnvironmentContent*>(
ash_test_helper()->ash_test_environment());
test_environment->set_content_state(new ::TestShellContentState);
AshTestBase::SetUp(); AshTestBase::SetUp();
profile_manager_.reset( profile_manager_.reset(
new TestingProfileManager(TestingBrowserProcess::GetGlobal())); new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
......
...@@ -42,7 +42,7 @@ content::BrowserContext* GetBrowserContextForWindow(aura::Window* window, ...@@ -42,7 +42,7 @@ content::BrowserContext* GetBrowserContextForWindow(aura::Window* window,
} // namespace } // namespace
content::BrowserContext* GetActiveBrowserContext() { const content::BrowserContext* GetActiveBrowserContext() {
DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size()); DCHECK(user_manager::UserManager::Get()->GetLoggedInUsers().size());
return ProfileManager::GetActiveUserProfile(); return ProfileManager::GetActiveUserProfile();
} }
...@@ -52,11 +52,11 @@ bool CanShowWindowForUser( ...@@ -52,11 +52,11 @@ bool CanShowWindowForUser(
const GetActiveBrowserContextCallback& get_context_callback) { const GetActiveBrowserContextCallback& get_context_callback) {
DCHECK(window); DCHECK(window);
if (user_manager::UserManager::Get()->GetLoggedInUsers().size() > 1u) { if (user_manager::UserManager::Get()->GetLoggedInUsers().size() > 1u) {
content::BrowserContext* active_browser_context = const content::BrowserContext* active_browser_context =
get_context_callback.Run(); get_context_callback.Run();
content::BrowserContext* owner_browser_context = const content::BrowserContext* owner_browser_context =
GetBrowserContextForWindow(window, false); GetBrowserContextForWindow(window, false);
content::BrowserContext* shown_browser_context = const content::BrowserContext* shown_browser_context =
GetBrowserContextForWindow(window, true); GetBrowserContextForWindow(window, true);
if (owner_browser_context && active_browser_context && if (owner_browser_context && active_browser_context &&
......
...@@ -20,10 +20,10 @@ namespace user_manager { ...@@ -20,10 +20,10 @@ namespace user_manager {
class User; class User;
} }
content::BrowserContext* GetActiveBrowserContext(); const content::BrowserContext* GetActiveBrowserContext();
using GetActiveBrowserContextCallback = using GetActiveBrowserContextCallback =
base::Callback<content::BrowserContext*(void)>; base::RepeatingCallback<const content::BrowserContext*(void)>;
// See documentation in ash::ShellDelegate for the method of the same name. // See documentation in ash::ShellDelegate for the method of the same name.
// |context| is the content::BrowserContext deemed active for the current // |context| is the content::BrowserContext deemed active for the current
......
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