Commit 3ff66ccb authored by fukino@chromium.org's avatar fukino@chromium.org

Add keyboard shortcuts in Files.app to open inspector.

This CL adds following keyboard shortcuts for debugging Files.app.

* Ctrl+Shift+I: Open inspector
* Ctrl+Shift+J: Open inspector and focus to console.
* Ctrl+Shift+C: Open inspector and start element inspection.
* Ctrl+Shift+B: Open inspector for the background page.

BUG=280551

Review URL: https://codereview.chromium.org/299443009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272931 0039d316-1c4b-4281-b951-d872f2087c98
parent be116c5b
......@@ -9,6 +9,7 @@
#include "ash/frame/frame_util.h"
#include "base/files/file_path.h"
#include "base/prefs/pref_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
......@@ -19,7 +20,9 @@
#include "chrome/browser/chromeos/file_manager/zip_file_creator.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/drive/event_logger.h"
#include "chrome/browser/extensions/devtools_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -437,4 +440,39 @@ bool FileBrowserPrivateVisitDesktopFunction::RunSync() {
return true;
}
bool FileBrowserPrivateOpenInspectorFunction::RunSync() {
using extensions::api::file_browser_private::OpenInspector::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
switch (params->type) {
case extensions::api::file_browser_private::INSPECTION_TYPE_NORMAL:
// Open inspector for foreground page.
DevToolsWindow::OpenDevToolsWindow(render_view_host());
break;
case extensions::api::file_browser_private::INSPECTION_TYPE_CONSOLE:
// Open inspector for foreground page and bring focus to the console.
DevToolsWindow::OpenDevToolsWindow(render_view_host(),
DevToolsToggleAction::ShowConsole());
break;
case extensions::api::file_browser_private::INSPECTION_TYPE_ELEMENT:
// Open inspector for foreground page in inspect element mode.
DevToolsWindow::OpenDevToolsWindow(render_view_host(),
DevToolsToggleAction::Inspect());
break;
case extensions::api::file_browser_private::INSPECTION_TYPE_BACKGROUND:
// Open inspector for background page.
extensions::devtools_util::InspectBackgroundPage(GetExtension(),
GetProfile());
break;
default:
NOTREACHED();
SetError(
base::StringPrintf("Unexpected inspection type(%d) is specified.",
static_cast<int>(params->type)));
return false;
}
return true;
}
} // namespace extensions
......@@ -160,6 +160,19 @@ class FileBrowserPrivateVisitDesktopFunction
virtual bool RunSync() OVERRIDE;
};
// Implements the chrome.fileBrowserPrivate.openInspector method.
class FileBrowserPrivateOpenInspectorFunction
: public ChromeSyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.openInspector",
FILEBROWSERPRIVATE_OPENINSPECTOR);
protected:
virtual ~FileBrowserPrivateOpenInspectorFunction() {}
virtual bool RunSync() OVERRIDE;
};
} // namespace extensions
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_MISC_H_
......@@ -81,6 +81,18 @@ enum SearchType { EXCLUDE_DIRECTORIES, SHARED_WITH_ME, OFFLINE, ALL };
// Zooming mode.
enum ZoomOperationType { in, out, reset };
// Specifies how to open inspector.
enum InspectionType {
// Open inspector for foreground page.
normal,
// Open inspector for foreground page and bring focus to the console.
console,
// Open inspector for foreground page in inspect element mode.
element,
// Open inspector for background page.
background
};
// Device event type.
enum DeviceEventType {
// Device is added.
......@@ -761,6 +773,10 @@ interface Functions {
// Moves the window to other user's desktop.
static void visitDesktop(DOMString profileId,
optional SimpleCallback callback);
// Opens inspector window.
// |type| InspectionType which specifies how to open inspector.
static void openInspector(InspectionType type);
};
interface Events {
......
......@@ -840,6 +840,7 @@ enum HistogramValue {
ENTERPRISE_PLATFORMKEYS_GETCERTIFICATES,
ENTERPRISE_PLATFORMKEYS_IMPORTCERTIFICATE,
ENTERPRISE_PLATFORMKEYS_REMOVECERTIFICATE,
FILEBROWSERPRIVATE_OPENINSPECTOR,
// Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms/histograms.xml.
ENUM_BOUNDARY
......
......@@ -34952,6 +34952,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="779" label="ENTERPRISE_PLATFORMKEYS_GETCERTIFICATES"/>
<int value="780" label="ENTERPRISE_PLATFORMKEYS_IMPORTCERTIFICATE"/>
<int value="781" label="ENTERPRISE_PLATFORMKEYS_REMOVECERTIFICATE"/>
<int value="782" label="FILEBROWSERPRIVATE_OPENINSPECTOR"/>
</enum>
<enum name="ExtensionInstallCause" type="int">
......@@ -905,3 +905,48 @@ CommandHandler.COMMANDS_['zoom-reset'] = {
},
canExecute: CommandUtil.canExecuteAlways
};
/**
* Open inspector for foreground page.
* @type {Command}
*/
CommandHandler.COMMANDS_['inspect-normal'] = {
execute: function(event, fileManager) {
chrome.fileBrowserPrivate.openInspector('normal');
},
canExecute: CommandUtil.canExecuteAlways
};
/**
* Open inspector for foreground page and bring focus to the console.
* @type {Command}
*/
CommandHandler.COMMANDS_['inspect-console'] = {
execute: function(event, fileManager) {
chrome.fileBrowserPrivate.openInspector('console');
},
canExecute: CommandUtil.canExecuteAlways
};
/**
* Open inspector for foreground page in inspect element mode.
* @type {Command}
*/
CommandHandler.COMMANDS_['inspect-element'] = {
execute: function(event, fileManager) {
chrome.fileBrowserPrivate.openInspector('element');
},
canExecute: CommandUtil.canExecuteAlways
};
/**
* Open inspector for background page.
* @type {Command}
*/
CommandHandler.COMMANDS_['inspect-background'] = {
execute: function(event, fileManager) {
chrome.fileBrowserPrivate.openInspector('background');
},
canExecute: CommandUtil.canExecuteAlways
};
......@@ -198,6 +198,12 @@
<command id="zoom-in" shortcut="U+00BB-Ctrl">
<command id="zoom-out" shortcut="U+00BD-Ctrl">
<command id="zoom-reset" shortcut="U+0030-Ctrl">
<!-- Shortcuts to open inspector. (Ctrl+Shift+I/J/C/B) -->
<command id="inspect-normal" shortcut="U+0049-Shift-Ctrl">
<command id="inspect-console" shortcut="U+004A-Shift-Ctrl">
<command id="inspect-element" shortcut="U+0043-Shift-Ctrl">
<command id="inspect-background" shortcut="U+0042-Shift-Ctrl">
</commands>
<menu id="file-context-menu" class="chrome-menu" showShortcuts>
......
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