Commit c9af1726 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Add display::Screen implementation for WebRunner

Aura requires that display::Screen::GetScreen() returns a valid object.
1. Added WebRunnerContentBrowserClient,
2. Added WebRunnerBrowserMainParts,
3. Added display::Screen, created by WebRunnerBrowserMainParts.

Bug: 822474
Change-Id: Id22a6a369b89ed0f911513adb17f33ed8b503f26
Reviewed-on: https://chromium-review.googlesource.com/988841
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547481}
parent 849fc67a
......@@ -18,6 +18,7 @@ executable("webrunner") {
"//content/public/child",
"//content/public/common",
"//content/public/renderer",
"//ui/display",
]
data_deps = [
......@@ -33,6 +34,12 @@ executable("webrunner") {
"app/webrunner_main_delegate.h",
"browser/webrunner_browser_main.cc",
"browser/webrunner_browser_main.h",
"browser/webrunner_browser_main_parts.cc",
"browser/webrunner_browser_main_parts.h",
"browser/webrunner_content_browser_client.cc",
"browser/webrunner_content_browser_client.h",
"browser/webrunner_screen.cc",
"browser/webrunner_screen.h",
"common/webrunner_content_client.cc",
"common/webrunner_content_client.h",
]
......
......@@ -10,6 +10,7 @@
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
#include "webrunner/browser/webrunner_browser_main.h"
#include "webrunner/browser/webrunner_content_browser_client.h"
#include "webrunner/common/webrunner_content_client.h"
namespace webrunner {
......@@ -69,4 +70,11 @@ int WebRunnerMainDelegate::RunProcess(
return WebRunnerBrowserMain(main_function_params);
}
content::ContentBrowserClient*
WebRunnerMainDelegate::CreateContentBrowserClient() {
DCHECK(!browser_client_);
browser_client_ = std::make_unique<WebRunnerContentBrowserClient>();
return browser_client_.get();
}
} // namespace webrunner
......@@ -27,9 +27,11 @@ class WebRunnerMainDelegate : public content::ContentMainDelegate {
int RunProcess(
const std::string& process_type,
const content::MainFunctionParams& main_function_params) override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
private:
std::unique_ptr<content::ContentClient> content_client_;
std::unique_ptr<content::ContentBrowserClient> browser_client_;
DISALLOW_COPY_AND_ASSIGN(WebRunnerMainDelegate);
};
......
include_rules = [
"+content/public/browser",
"+ui/aura",
"+ui/display",
]
\ No newline at end of file
// Copyright 2018 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 "webrunner/browser/webrunner_browser_main_parts.h"
#include "webrunner/browser/webrunner_screen.h"
namespace webrunner {
WebRunnerBrowserMainParts::WebRunnerBrowserMainParts() = default;
WebRunnerBrowserMainParts::~WebRunnerBrowserMainParts() = default;
void WebRunnerBrowserMainParts::PreMainMessageLoopRun() {
DCHECK(!screen_);
screen_ = std::make_unique<WebRunnerScreen>();
display::Screen::SetScreenInstance(screen_.get());
}
} // namespace webrunner
// Copyright 2018 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 WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_PARTS_H_
#define WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_PARTS_H_
#include <memory>
#include "base/macros.h"
#include "content/public/browser/browser_main_parts.h"
namespace webrunner {
class WebRunnerScreen;
class WebRunnerBrowserMainParts : public content::BrowserMainParts {
public:
WebRunnerBrowserMainParts();
~WebRunnerBrowserMainParts() override;
// content::BrowserMainParts overrides.
void PreMainMessageLoopRun() override;
private:
std::unique_ptr<WebRunnerScreen> screen_;
DISALLOW_COPY_AND_ASSIGN(WebRunnerBrowserMainParts);
};
} // namespace webrunner
#endif // WEBRUNNER_BROWSER_WEBRUNNER_BROWSER_MAIN_PARTS_H_
\ No newline at end of file
// Copyright 2018 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 "webrunner/browser/webrunner_content_browser_client.h"
#include "webrunner/browser/webrunner_browser_main_parts.h"
namespace webrunner {
WebRunnerContentBrowserClient::WebRunnerContentBrowserClient() = default;
WebRunnerContentBrowserClient::~WebRunnerContentBrowserClient() = default;
content::BrowserMainParts*
WebRunnerContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
return new WebRunnerBrowserMainParts();
}
} // namespace webrunner
\ No newline at end of file
// Copyright 2018 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 WEBRUNNER_BROWSER_WEBRUNNER_CONTENT_BROWSER_CLIENT_H_
#define WEBRUNNER_BROWSER_WEBRUNNER_CONTENT_BROWSER_CLIENT_H_
#include "base/macros.h"
#include "content/public/browser/content_browser_client.h"
namespace webrunner {
class WebRunnerContentBrowserClient : public content::ContentBrowserClient {
public:
WebRunnerContentBrowserClient();
~WebRunnerContentBrowserClient() override;
// ContentBrowserClient overrides.
content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;
private:
DISALLOW_COPY_AND_ASSIGN(WebRunnerContentBrowserClient);
};
} // namespace webrunner
#endif // WEBRUNNER_BROWSER_WEBRUNNER_CONTENT_BROWSER_CLIENT_H_
// Copyright 2018 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 "webrunner/browser/webrunner_screen.h"
#include "ui/display/display.h"
namespace webrunner {
WebRunnerScreen::WebRunnerScreen() {
const int64_t kDefaultDisplayId = 1;
display::Display display(kDefaultDisplayId);
ProcessDisplayChanged(display, /*is_primary=*/true);
}
WebRunnerScreen::~WebRunnerScreen() = default;
} // namespace webrunner
// Copyright 2018 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 WEBRUNNER_BROWSER_WEBRUNNER_SCREEN_H_
#define WEBRUNNER_BROWSER_WEBRUNNER_SCREEN_H_
#include "base/macros.h"
#include "ui/display/screen_base.h"
namespace webrunner {
// display::Screen implementation for WebRunner on Fuchsia.
class DISPLAY_EXPORT WebRunnerScreen : public display::ScreenBase {
public:
WebRunnerScreen();
~WebRunnerScreen() override;
private:
DISALLOW_COPY_AND_ASSIGN(WebRunnerScreen);
};
} // namespace webrunner
#endif // WEBRUNNER_BROWSER_WEBRUNNER_SCREEN_H_
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