Commit 0713fb9e authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

ksv: Move interface to ash/public, remove chrome util files

Also perform some simple cleanup.

Bug: 958073
Change-Id: Idf9e0abbd734af3f60928fd4d26dd9e74da26431
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1591666
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656473}
parent 7ef5d0fe
......@@ -47,9 +47,6 @@ include_rules = [
# header required to launch the app.
"-ash/components",
# Ash can talk to public interfaces for mini-apps.
"+ash/components/shortcut_viewer/public",
# Ash sits above content. Exceptions live in //ash/content.
"-content",
......
......@@ -10,8 +10,6 @@ source_set("shortcut_viewer") {
"keyboard_shortcut_viewer_metadata.cc",
"keyboard_shortcut_viewer_metadata.h",
"ksv_export.h",
"shortcut_viewer.cc",
"shortcut_viewer.h",
"views/bubble_view.cc",
"views/bubble_view.h",
"views/keyboard_shortcut_item_list_view.cc",
......
// Copyright 2019 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/components/shortcut_viewer/shortcut_viewer.h"
#include "ash/components/shortcut_viewer/views/keyboard_shortcut_view.h"
namespace keyboard_shortcut_viewer {
void Toggle(base::TimeTicks user_gesture_time) {
KeyboardShortcutView::Toggle(user_gesture_time, nullptr);
}
} // namespace keyboard_shortcut_viewer
// Copyright 2019 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_COMPONENTS_SHORTCUT_VIEWER_SHORTCUT_VIEWER_H_
#define ASH_COMPONENTS_SHORTCUT_VIEWER_SHORTCUT_VIEWER_H_
#include "base/time/time.h"
namespace keyboard_shortcut_viewer {
// Toggle the Keyboard Shortcut Viewer window. |user_gesture_time| is the time
// of the user gesture that caused the window to show. Used for metrics.
void Toggle(base::TimeTicks user_gesture_time);
} // namespace keyboard_shortcut_viewer
#endif // ASH_COMPONENTS_SHORTCUT_VIEWER_SHORTCUT_VIEWER_H_
......@@ -138,14 +138,14 @@ KeyboardShortcutView::~KeyboardShortcutView() {
}
// static
views::Widget* KeyboardShortcutView::Toggle(base::TimeTicks start_time,
aura::Window* context) {
views::Widget* KeyboardShortcutView::Toggle(aura::Window* context) {
if (g_ksv_view) {
if (g_ksv_view->GetWidget()->IsActive())
g_ksv_view->GetWidget()->Close();
else
g_ksv_view->GetWidget()->Activate();
} else {
const base::TimeTicks start_time = base::TimeTicks::Now();
TRACE_EVENT0("shortcut_viewer", "CreateWidget");
base::RecordAction(
base::UserMetricsAction("KeyboardShortcutViewer.CreateWindow"));
......@@ -608,3 +608,11 @@ KSVSearchBoxView* KeyboardShortcutView::GetSearchBoxViewForTesting() {
}
} // namespace keyboard_shortcut_viewer
namespace ash {
void ToggleKeyboardShortcutViewer() {
keyboard_shortcut_viewer::KeyboardShortcutView::Toggle(nullptr);
}
} // namespace ash
......@@ -19,10 +19,6 @@ namespace aura {
class Window;
}
namespace base {
class TimeTicks;
}
namespace views {
class TabbedPane;
class Widget;
......@@ -44,14 +40,8 @@ class KeyboardShortcutView : public views::WidgetDelegateView,
// 1. Show the window if it is not open.
// 2. Activate the window if it is open but not active.
// 3. Close the window if it is open and active.
// |start_time| is the time of the user gesture that caused the window to
// show. Used for metrics.
// |context| is used to determine which display to place the Window on.
// |context| is only necessary when called from within Chrome.
// TODO: remove |context|, it's not needed once KeyboardShortcutView is only
// launched as an app.
static views::Widget* Toggle(base::TimeTicks start_time,
aura::Window* context);
static views::Widget* Toggle(aura::Window* context);
// views::View:
const char* GetClassName() const override;
......
......@@ -30,7 +30,7 @@ class KeyboardShortcutViewTest : public ash::AshTestBase {
~KeyboardShortcutViewTest() override = default;
views::Widget* Toggle() {
return KeyboardShortcutView::Toggle(base::TimeTicks(), CurrentContext());
return KeyboardShortcutView::Toggle(CurrentContext());
}
// ash::AshTestBase:
......
......@@ -76,6 +76,7 @@ component("cpp") {
"immersive/immersive_fullscreen_controller_delegate.h",
"immersive/immersive_revealed_lock.cc",
"immersive/immersive_revealed_lock.h",
"keyboard_shortcut_viewer.h",
"lock_screen_widget_factory.cc",
"lock_screen_widget_factory.h",
"login_constants.h",
......
// Copyright 2019 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_PUBLIC_CPP_KEYBOARD_SHORTCUT_VIEWER_H_
#define ASH_PUBLIC_CPP_KEYBOARD_SHORTCUT_VIEWER_H_
#include "ash/public/cpp/ash_public_export.h"
namespace ash {
// Toggle the Keyboard Shortcut Viewer window.
// 1. Show the window if it is not open.
// 2. Activate the window if it is open but not active.
// 3. Close the window if it is open and active.
void ASH_PUBLIC_EXPORT ToggleKeyboardShortcutViewer();
} // namespace ash
#endif // ASH_PUBLIC_CPP_KEYBOARD_SHORTCUT_VIEWER_H_
......@@ -44,7 +44,6 @@ include_rules = [
specific_include_rules = {
"chrome_content_browser_overlay_manifest\.cc": [
"+ash/components/shortcut_viewer/public",
"+chrome/services/app_service",
"+chromeos/assistant",
"+chromeos/services/assistant",
......@@ -83,7 +82,6 @@ specific_include_rules = {
"+third_party/blink/public/mojom",
],
"chrome_packaged_service_manifests\.cc": [
"+ash/components/shortcut_viewer/public",
"+chrome/services/cups_ipp_parser/public",
"+chrome/services/cups_proxy/public",
"+chrome/services/file_util/public",
......
......@@ -1406,8 +1406,6 @@ jumbo_split_static_library("ui") {
"ash/keyboard/chrome_keyboard_web_contents.h",
"ash/kiosk_next_shell_client.cc",
"ash/kiosk_next_shell_client.h",
"ash/ksv/keyboard_shortcut_viewer_util.cc",
"ash/ksv/keyboard_shortcut_viewer_util.h",
"ash/launcher/app_shortcut_launcher_item_controller.cc",
"ash/launcher/app_shortcut_launcher_item_controller.h",
"ash/launcher/app_window_launcher_controller.cc",
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "ash/public/cpp/keyboard_shortcut_viewer.h"
#include "ash/public/cpp/resources/grit/ash_public_unscaled_resources.h"
#include "ash/public/cpp/shelf_model.h"
#include "base/bind.h"
......@@ -25,7 +26,6 @@
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/app_list/extension_app_utils.h"
#include "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h"
#include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
......@@ -281,7 +281,7 @@ void OpenInternalApp(const std::string& app_id,
Profile* profile,
int event_flags) {
if (app_id == kInternalAppIdKeyboardShortcutViewer) {
keyboard_shortcut_viewer_util::ToggleKeyboardShortcutViewer();
ash::ToggleKeyboardShortcutViewer();
} else if (app_id == kInternalAppIdSettings) {
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(profile);
} else if (app_id == kInternalAppIdCamera) {
......
......@@ -8,7 +8,7 @@ include_rules = [
specific_include_rules = {
".*test.*": [
"!ash",
"+ash/components/shortcut_viewer/public",
"+ash/components/shortcut_viewer",
"+ash/public",
],
# AshShellInit supports classic (non-mash) mode so allow ash/ includes.
......
......@@ -8,6 +8,7 @@
#include <utility>
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/keyboard_shortcut_viewer.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
......@@ -23,7 +24,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
......@@ -388,7 +388,7 @@ void ChromeNewWindowClient::RestoreTab() {
}
void ChromeNewWindowClient::ShowKeyboardShortcutViewer() {
keyboard_shortcut_viewer_util::ToggleKeyboardShortcutViewer();
ash::ToggleKeyboardShortcutViewer();
}
void ChromeNewWindowClient::ShowTaskManager() {
......
include_rules = [
"-chrome",
"+ash/components/shortcut_viewer/public",
"+chrome/browser/ui/ash/ksv",
]
specific_include_rules = {
# Tests.
"keyboard_shortcut_viewer_metadata_unittest\.cc": [
"+ash/components/shortcut_viewer",
"+chrome/browser/ui/views",
],
}
// 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 "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h"
#include "ash/components/shortcut_viewer/shortcut_viewer.h"
#include "base/time/time.h"
namespace keyboard_shortcut_viewer_util {
void ToggleKeyboardShortcutViewer() {
keyboard_shortcut_viewer::Toggle(base::TimeTicks::Now());
}
} // namespace keyboard_shortcut_viewer_util
// 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 CHROME_BROWSER_UI_ASH_KSV_KEYBOARD_SHORTCUT_VIEWER_UTIL_H_
#define CHROME_BROWSER_UI_ASH_KSV_KEYBOARD_SHORTCUT_VIEWER_UTIL_H_
namespace keyboard_shortcut_viewer_util {
// Opens or closes the keyboard shortcut viewer.
void ToggleKeyboardShortcutViewer();
} // namespace keyboard_shortcut_viewer_util
#endif // CHROME_BROWSER_UI_ASH_KSV_KEYBOARD_SHORTCUT_VIEWER_UTIL_H_
......@@ -4,12 +4,12 @@
#include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
#include "ash/public/cpp/keyboard_shortcut_viewer.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/new_window.mojom.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/ui/ash/ksv/keyboard_shortcut_viewer_util.h"
#include "chrome/browser/ui/ash/tablet_mode_client.h"
#include "chromeos/constants/chromeos_switches.h"
#include "chromeos/services/assistant/public/features.h"
......@@ -105,7 +105,7 @@ void KeyboardHandler::HandleInitialize(const base::ListValue* args) {
void KeyboardHandler::HandleShowKeyboardShortcutViewer(
const base::ListValue* args) const {
keyboard_shortcut_viewer_util::ToggleKeyboardShortcutViewer();
ash::ToggleKeyboardShortcutViewer();
}
void KeyboardHandler::HandleKeyboardChange(const base::ListValue* args) {
......
......@@ -3748,7 +3748,7 @@ test("unit_tests") {
"../browser/ui/ash/ime_controller_client_unittest.cc",
"../browser/ui/ash/keyboard/chrome_keyboard_ui_unittest.cc",
"../browser/ui/ash/keyboard/chrome_keyboard_web_contents_unittest.cc",
"../browser/ui/ash/ksv/keyboard_shortcut_viewer_metadata_unittest.cc",
"../browser/ui/ash/keyboard_shortcut_viewer_metadata_unittest.cc",
"../browser/ui/ash/launcher/arc_app_shelf_id_unittest.cc",
"../browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc",
"../browser/ui/ash/launcher/launcher_context_menu_unittest.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