Commit 65669a93 authored by Jason Lin's avatar Jason Lin Committed by Commit Bot

crostini: place and size terminal settings window better

Bug: 1048451
Change-Id: Ic8e0eadc059a1648c484ad592f9a85bbfec979fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2045619Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Jason Lin <lxj@google.com>
Auto-Submit: Jason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#744179}
parent 845d0cd8
......@@ -19,6 +19,12 @@
#include "chrome/grit/chrome_unscaled_resources.h"
#include "net/base/escape.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
namespace {
constexpr gfx::Size TERMINAL_SETTINGS_SIZE(768, 512);
} // namespace
namespace crostini {
......@@ -104,12 +110,14 @@ void LaunchContainerTerminal(Profile* profile,
ShowContainerTerminal(profile, launch_params, vsh_in_crosh_url, browser);
}
void LaunchTerminalSettings(Profile* profile) {
void LaunchTerminalSettings(Profile* profile, gfx::Point window_origin) {
DCHECK(base::FeatureList::IsEnabled(features::kTerminalSystemApp));
auto params = web_app::CreateSystemWebAppLaunchParams(
profile, web_app::SystemAppType::TERMINAL);
// Use an app pop window to host the settings page.
params->disposition = WindowOpenDisposition::NEW_POPUP;
params->override_bounds.set_origin(window_origin);
params->override_bounds.set_size(TERMINAL_SETTINGS_SIZE);
web_app::LaunchSystemWebApp(profile, web_app::SystemAppType::TERMINAL,
GURL(std::string(chrome::kChromeUITerminalURL) +
"html/terminal_settings.html"),
......
......@@ -8,6 +8,7 @@
#include <vector>
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "ui/gfx/geometry/point.h"
class GURL;
class Browser;
......@@ -45,7 +46,7 @@ void LaunchContainerTerminal(Profile* profile,
const std::vector<std::string>& terminal_args);
// Launches the terminal settings popup window.
void LaunchTerminalSettings(Profile* profile);
void LaunchTerminalSettings(Profile* profile, gfx::Point window_origin);
} // namespace crostini
......
......@@ -15,14 +15,22 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h"
#include "components/strings/grit/components_strings.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
#include "url/third_party/mozilla/url_parse.h"
#include "url/url_canon.h"
namespace {
// The dialog is shifted by the height of the title bar plus a few more pixels.
constexpr int SHIFT_DISTANCE = 47;
} // namespace
TerminalSystemAppMenuModel::TerminalSystemAppMenuModel(
ui::AcceleratorProvider* provider,
Browser* browser)
......@@ -47,7 +55,10 @@ bool TerminalSystemAppMenuModel::IsCommandIdEnabled(int command_id) const {
void TerminalSystemAppMenuModel::ExecuteCommand(int command_id,
int event_flags) {
if (command_id == IDC_OPTIONS) {
crostini::LaunchTerminalSettings(browser()->profile());
const gfx::Rect& bounds = browser()->window()->GetBounds();
crostini::LaunchTerminalSettings(
browser()->profile(),
gfx::Point(bounds.x() + SHIFT_DISTANCE, bounds.y() + SHIFT_DISTANCE));
return;
}
......
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