Skip to content

Commit

Permalink
Add skeleton for chrome://parallels-internal
Browse files Browse the repository at this point in the history
Bug: b/173653141
Test: visit chrome://parallels-internal manually
Change-Id: I86ae119c9e102808183995c1eb60b9395ee3b885
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2719248
Commit-Queue: Jason Lin <lxj@google.com>
Reviewed-by: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#858479}
  • Loading branch information
Jason Lin authored and Chromium LUCI CQ committed Mar 1, 2021
1 parent 17904b1 commit 36bfd11
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/ui/BUILD.gn
Expand Up @@ -2424,6 +2424,8 @@ static_library("ui") {
"webui/chromeos/network_ui.h",
"webui/chromeos/onc_import_message_handler.cc",
"webui/chromeos/onc_import_message_handler.h",
"webui/chromeos/plugin_vm_internal/plugin_vm_internal_ui.cc",
"webui/chromeos/plugin_vm_internal/plugin_vm_internal_ui.h",
"webui/chromeos/power_ui.cc",
"webui/chromeos/power_ui.h",
"webui/chromeos/set_time_ui.cc",
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
Expand Up @@ -195,6 +195,7 @@
#include "chrome/browser/ui/webui/chromeos/multidevice_internals/multidevice_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
#include "chrome/browser/ui/webui/chromeos/network_ui.h"
#include "chrome/browser/ui/webui/chromeos/plugin_vm_internal/plugin_vm_internal_ui.h"
#include "chrome/browser/ui/webui/chromeos/power_ui.h"
#include "chrome/browser/ui/webui/chromeos/set_time_ui.h"
#include "chrome/browser/ui/webui/chromeos/slow_trace_ui.h"
Expand Down Expand Up @@ -812,6 +813,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
base::FeatureList::IsEnabled(chromeos::features::kEcheSWA)) {
return &NewWebUI<chromeos::eche_app::EcheAppUI>;
}
if (url.host_piece() == chrome::kChromeUIPluginVmInternalHost) {
return &NewWebUI<chromeos::PluginVmInternalUI>;
}

#if !defined(OFFICIAL_BUILD)
#if !defined(USE_REAL_DBUS_CLIENTS)
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/webui/chromeos/plugin_vm_internal/OWNERS
@@ -0,0 +1 @@
file://chrome/browser/chromeos/guest_os/OWNERS
@@ -0,0 +1,51 @@
// Copyright 2021 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/webui/chromeos/plugin_vm_internal/plugin_vm_internal_ui.h"

#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
#include "content/public/browser/url_data_source.h"

// TODO(b/173653141) We need to port this to lacros eventually.

namespace chromeos {

namespace {

class DataSource : public content::URLDataSource {
std::string GetSource() override {
return chrome::kChromeUIPluginVmInternalHost;
}

void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
GotDataCallback callback) override {
// TODO(b/173653141) Send actual diagnosis.
std::string rv = "parallels diagnosis";
std::move(callback).Run(base::RefCountedString::TakeString(&rv));
}

std::string GetMimeType(const std::string& path) override {
return "text/plain";
}

bool AllowCaching() override {
// We need to generate new diagnosis every time.
return false;
}
};

} // namespace

PluginVmInternalUI::PluginVmInternalUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
auto* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile, std::make_unique<DataSource>());
}

PluginVmInternalUI::~PluginVmInternalUI() = default;

} // namespace chromeos
@@ -0,0 +1,23 @@
// Copyright 2021 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_WEBUI_CHROMEOS_PLUGIN_VM_INTERNAL_PLUGIN_VM_INTERNAL_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_PLUGIN_VM_INTERNAL_PLUGIN_VM_INTERNAL_UI_H_

#include "content/public/browser/web_ui_controller.h"

namespace chromeos {

// The WebUI for chrome://parallels-internal
class PluginVmInternalUI : public content::WebUIController {
public:
explicit PluginVmInternalUI(content::WebUI* web_ui);
PluginVmInternalUI(const PluginVmInternalUI&) = delete;
PluginVmInternalUI& operator=(const PluginVmInternalUI&) = delete;
~PluginVmInternalUI() override;
};

} // namespace chromeos

#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_PLUGIN_VM_INTERNAL_PLUGIN_VM_INTERNAL_UI_H_
1 change: 1 addition & 0 deletions chrome/common/webui_url_constants.cc
Expand Up @@ -276,6 +276,7 @@ const char kChromeUIOobeHost[] = "oobe";
const char kChromeUIOobeURL[] = "chrome://oobe/";
const char kChromeUIPasswordChangeHost[] = "password-change";
const char kChromeUIPasswordChangeUrl[] = "chrome://password-change";
const char kChromeUIPluginVmInternalHost[] = "parallels-internal";
const char kChromeUIPrintManagementUrl[] = "chrome://print-management";
const char kChromeUIPowerHost[] = "power";
const char kChromeUIScanningAppURL[] = "chrome://scanning";
Expand Down
1 change: 1 addition & 0 deletions chrome/common/webui_url_constants.h
Expand Up @@ -267,6 +267,7 @@ extern const char kChromeUIOobeHost[];
extern const char kChromeUIOobeURL[];
extern const char kChromeUIPasswordChangeHost[];
extern const char kChromeUIPasswordChangeUrl[];
extern const char kChromeUIPluginVmInternalHost[];
extern const char kChromeUIPrintManagementUrl[];
extern const char kChromeUIPowerHost[];
extern const char kChromeUIScanningAppURL[];
Expand Down

0 comments on commit 36bfd11

Please sign in to comment.