diff options
-rw-r--r-- | chrome/browser/devtools/OWNERS | 11 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_embedder_message_dispatcher.cc | 204 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_embedder_message_dispatcher.h | 64 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_window.cc | 11 | ||||
-rw-r--r-- | chrome/browser/devtools/devtools_window.h | 11 | ||||
-rw-r--r-- | chrome/chrome.gyp | 2 | ||||
-rw-r--r-- | content/browser/devtools/devtools_frontend_host.cc | 86 | ||||
-rw-r--r-- | content/browser/devtools/devtools_frontend_host.h | 17 | ||||
-rw-r--r-- | content/common/devtools_messages.h | 62 | ||||
-rw-r--r-- | content/public/browser/devtools_frontend_host_delegate.h | 52 | ||||
-rw-r--r-- | content/renderer/devtools/devtools_client.cc | 72 | ||||
-rw-r--r-- | content/renderer/devtools/devtools_client.h | 24 | ||||
-rw-r--r-- | content/shell/browser/shell_devtools_frontend.h | 21 |
13 files changed, 312 insertions, 325 deletions
diff --git a/chrome/browser/devtools/OWNERS b/chrome/browser/devtools/OWNERS index bb6028e..676e6d8 100644 --- a/chrome/browser/devtools/OWNERS +++ b/chrome/browser/devtools/OWNERS @@ -1,2 +1,13 @@ pfeldman@chromium.org yurys@chromium.org + +# Changes to embedder messages require a security review. +# The list of reviewers is copied from content/common/OWNERS +per-file devtools_embedder_message_dispatcher.*=set noparent +per-file devtools_embedder_message_dispatcher.*=cdn@chromium.org +per-file devtools_embedder_message_dispatcher.*=cevans@chromium.org +per-file devtools_embedder_message_dispatcher.*=jln@chromium.org +per-file devtools_embedder_message_dispatcher.*=jschuh@chromium.org +per-file devtools_embedder_message_dispatcher.*=palmer@chromium.org +per-file devtools_embedder_message_dispatcher.*=tsepez@chromium.org +per-file devtools_embedder_message_dispatcher.*=kenrb@chromium.org diff --git a/chrome/browser/devtools/devtools_embedder_message_dispatcher.cc b/chrome/browser/devtools/devtools_embedder_message_dispatcher.cc new file mode 100644 index 0000000..6071fb8 --- /dev/null +++ b/chrome/browser/devtools/devtools_embedder_message_dispatcher.cc @@ -0,0 +1,204 @@ +// Copyright 2013 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/devtools/devtools_embedder_message_dispatcher.h" + +#include "base/bind.h" +#include "base/json/json_reader.h" +#include "base/values.h" + +namespace { + +static const char kFrontendHostMethod[] = "method"; +static const char kFrontendHostParams[] = "params"; + +bool GetValue(const base::ListValue& list, int pos, std::string& value) { + return list.GetString(pos, &value); +} + +bool GetValue(const base::ListValue& list, int pos, int& value) { + return list.GetInteger(pos, &value); +} + +bool GetValue(const base::ListValue& list, int pos, bool& value) { + return list.GetBoolean(pos, &value); +} + +template <typename T> +struct StorageTraits { + typedef T StorageType; +}; + +template <typename T> +struct StorageTraits<const T&> { + typedef T StorageType; +}; + +template <class A> +class Argument { + public: + typedef typename StorageTraits<A>::StorageType ValueType; + + Argument(const base::ListValue& list, int pos) { + valid_ = GetValue(list, pos, value_); + } + + ValueType value() const { return value_; } + bool valid() const { return valid_; } + + private: + ValueType value_; + bool valid_; +}; + +bool ParseAndHandle0(const base::Callback<void(void)>& handler, + const base::ListValue& list) { + handler.Run(); + return true; +} + +template <class A1> +bool ParseAndHandle1(const base::Callback<void(A1)>& handler, + const base::ListValue& list) { + if (list.GetSize() != 1) + return false; + Argument<A1> arg1(list, 0); + if (!arg1.valid()) + return false; + handler.Run(arg1.value()); + return true; +} + +template <class A1, class A2> +bool ParseAndHandle2(const base::Callback<void(A1, A2)>& handler, + const base::ListValue& list) { + if (list.GetSize() != 2) + return false; + Argument<A1> arg1(list, 0); + if (!arg1.valid()) + return false; + Argument<A2> arg2(list, 1); + if (!arg2.valid()) + return false; + handler.Run(arg1.value(), arg2.value()); + return true; +} + +template <class A1, class A2, class A3> +bool ParseAndHandle3(const base::Callback<void(A1, A2, A3)>& handler, + const base::ListValue& list) { + if (list.GetSize() != 3) + return false; + Argument<A1> arg1(list, 0); + if (!arg1.valid()) + return false; + Argument<A2> arg2(list, 1); + if (!arg2.valid()) + return false; + Argument<A3> arg3(list, 2); + if (!arg3.valid()) + return false; + handler.Run(arg1.value(), arg2.value(), arg3.value()); + return true; +} + +typedef base::Callback<bool(const base::ListValue&)> ListValueParser; + +ListValueParser BindToListParser(const base::Callback<void()>& handler) { + return base::Bind(&ParseAndHandle0, handler); +} + +template <class A1> +ListValueParser BindToListParser(const base::Callback<void(A1)>& handler) { + return base::Bind(&ParseAndHandle1<A1>, handler); +} + +template <class A1, class A2> +ListValueParser BindToListParser(const base::Callback<void(A1,A2)>& handler) { + return base::Bind(&ParseAndHandle2<A1, A2>, handler); +} + +template <class A1, class A2, class A3> +ListValueParser BindToListParser( + const base::Callback<void(A1,A2,A3)>& handler) { + return base::Bind(&ParseAndHandle3<A1, A2, A3>, handler); +} + +} // namespace + +DevToolsEmbedderMessageDispatcher::DevToolsEmbedderMessageDispatcher( + Delegate* delegate) { + RegisterHandler("bringToFront", + BindToListParser(base::Bind(&Delegate::ActivateWindow, + base::Unretained(delegate)))); + RegisterHandler("closeWindow", + BindToListParser(base::Bind(&Delegate::CloseWindow, + base::Unretained(delegate)))); + RegisterHandler("moveWindowBy", + BindToListParser(base::Bind(&Delegate::MoveWindow, + base::Unretained(delegate)))); + RegisterHandler("requestSetDockSide", + BindToListParser(base::Bind(&Delegate::SetDockSide, + base::Unretained(delegate)))); + RegisterHandler("openInNewTab", + BindToListParser(base::Bind(&Delegate::OpenInNewTab, + base::Unretained(delegate)))); + RegisterHandler("save", + BindToListParser(base::Bind(&Delegate::SaveToFile, + base::Unretained(delegate)))); + RegisterHandler("append", + BindToListParser(base::Bind(&Delegate::AppendToFile, + base::Unretained(delegate)))); + RegisterHandler("requestFileSystems", + BindToListParser(base::Bind(&Delegate::RequestFileSystems, + base::Unretained(delegate)))); + RegisterHandler("addFileSystem", + BindToListParser(base::Bind(&Delegate::AddFileSystem, + base::Unretained(delegate)))); + RegisterHandler("removeFileSystem", + BindToListParser(base::Bind(&Delegate::RemoveFileSystem, + base::Unretained(delegate)))); + RegisterHandler("indexPath", + BindToListParser(base::Bind(&Delegate::IndexPath, + base::Unretained(delegate)))); + RegisterHandler("stopIndexing", + BindToListParser(base::Bind(&Delegate::StopIndexing, + base::Unretained(delegate)))); + RegisterHandler("searchInPath", + BindToListParser(base::Bind(&Delegate::SearchInPath, + base::Unretained(delegate)))); +} + +DevToolsEmbedderMessageDispatcher::~DevToolsEmbedderMessageDispatcher() {} + +void DevToolsEmbedderMessageDispatcher::Dispatch(const std::string& message) { + std::string method; + base::ListValue empty_params; + base::ListValue* params = &empty_params; + + base::DictionaryValue* dict; + scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message)); + if (!parsed_message || + !parsed_message->GetAsDictionary(&dict) || + !dict->GetString(kFrontendHostMethod, &method) || + (dict->HasKey(kFrontendHostParams) && + !dict->GetList(kFrontendHostParams, ¶ms))) { + LOG(ERROR) << "Cannot parse frontend host message: " << message; + return; + } + + HandlerMap::iterator it = handlers_.find(method); + if (it == handlers_.end()) { + LOG(ERROR) << "Unsupported frontend host method: " << message; + return; + } + + if (!it->second.Run(*params)) + LOG(ERROR) << "Invalid frontend host message parameters: " << message; +} + +void DevToolsEmbedderMessageDispatcher::RegisterHandler( + const std::string& method, const Handler& handler) { + handlers_[method] = handler; +} diff --git a/chrome/browser/devtools/devtools_embedder_message_dispatcher.h b/chrome/browser/devtools/devtools_embedder_message_dispatcher.h new file mode 100644 index 0000000..ae325fc --- /dev/null +++ b/chrome/browser/devtools/devtools_embedder_message_dispatcher.h @@ -0,0 +1,64 @@ +// Copyright 2013 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_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_ +#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_ + +#include <map> +#include <string> + +#include "base/callback.h" + +namespace base { +class ListValue; +} + +/** + * Dispatcher for messages sent from the DevTools frontend running in an + * isolated renderer (on chrome-devtools://) to the embedder in the browser. + * + * The messages are sent via InspectorFrontendHost.sendMessageToEmbedder method. + */ +class DevToolsEmbedderMessageDispatcher { + public: + class Delegate { + public: + virtual ~Delegate() {} + + virtual void ActivateWindow() = 0; + virtual void CloseWindow() = 0; + virtual void MoveWindow(int x, int y) = 0; + virtual void SetDockSide(const std::string& side) = 0; + virtual void OpenInNewTab(const std::string& url) = 0; + virtual void SaveToFile(const std::string& url, + const std::string& content, + bool save_as) = 0; + virtual void AppendToFile(const std::string& url, + const std::string& content) = 0; + virtual void RequestFileSystems() = 0; + virtual void AddFileSystem() = 0; + virtual void RemoveFileSystem(const std::string& file_system_path) = 0; + virtual void IndexPath(int request_id, + const std::string& file_system_path) = 0; + virtual void StopIndexing(int request_id) = 0; + virtual void SearchInPath(int request_id, + const std::string& file_system_path, + const std::string& query) = 0; + }; + + explicit DevToolsEmbedderMessageDispatcher(Delegate* delegate); + + ~DevToolsEmbedderMessageDispatcher(); + + void Dispatch(const std::string& message); + + private: + typedef base::Callback<bool(const base::ListValue&)> Handler; + void RegisterHandler(const std::string& method, const Handler& handler); + + typedef std::map<std::string, Handler> HandlerMap; + HandlerMap handlers_; +}; + +#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_EMBEDDER_MESSAGE_DISPATCHER_H_ diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index d052d14..f8e1b6a 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -587,6 +587,9 @@ DevToolsWindow::DevToolsWindow(Profile* profile, if (inspected_rvh) inspected_contents_observer_.reset(new InspectedWebContentsObserver( content::WebContents::FromRenderViewHost(inspected_rvh))); + + embedder_message_dispatcher_.reset( + new DevToolsEmbedderMessageDispatcher(this)); } // static @@ -832,6 +835,10 @@ void DevToolsWindow::WebContentsFocused(content::WebContents* contents) { inspected_browser->window()->WebContentsFocused(contents); } +void DevToolsWindow::DispatchOnEmbedder(const std::string& message) { + embedder_message_dispatcher_->Dispatch(message); +} + void DevToolsWindow::ActivateWindow() { if (IsDocked() && GetInspectedBrowserWindow()) web_contents_->GetView()->Focus(); @@ -839,10 +846,6 @@ void DevToolsWindow::ActivateWindow() { browser_->window()->Activate(); } -void DevToolsWindow::ChangeAttachedWindowHeight(unsigned height) { - NOTREACHED(); // TODO(dgozman): This is not used anymore, remove. -} - void DevToolsWindow::CloseWindow() { DCHECK(IsDocked()); content::DevToolsManager::GetInstance()->ClientHostClosing( diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h index cd556be..e3b2e90 100644 --- a/chrome/browser/devtools/devtools_window.h +++ b/chrome/browser/devtools/devtools_window.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" +#include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" #include "chrome/browser/devtools/devtools_file_helper.h" #include "chrome/browser/devtools/devtools_file_system_indexer.h" #include "chrome/browser/devtools/devtools_toggle_action.h" @@ -55,7 +56,8 @@ enum DevToolsDockSide { class DevToolsWindow : private content::NotificationObserver, private content::WebContentsDelegate, - private content::DevToolsFrontendHostDelegate { + private content::DevToolsFrontendHostDelegate, + private DevToolsEmbedderMessageDispatcher::Delegate { public: typedef base::Callback<void(bool)> InfoBarCallback; @@ -181,9 +183,11 @@ class DevToolsWindow : private content::NotificationObserver, const content::FileChooserParams& params) OVERRIDE; virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; - // content::DevToolsFrontendHostDelegate: + // content::DevToolsFrontendHostDelegate override: + virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; + + // DevToolsEmbedderMessageDispatcher::Delegate overrides: virtual void ActivateWindow() OVERRIDE; - virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE; virtual void CloseWindow() OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE; virtual void SetDockSide(const std::string& side) OVERRIDE; @@ -266,6 +270,7 @@ class DevToolsWindow : private content::NotificationObserver, int height_; DevToolsDockSide dock_side_before_minimized_; + scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); }; diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 2154a14..0d556b7 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -177,6 +177,8 @@ 'browser/devtools/browser_list_tabcontents_provider.h', 'browser/devtools/devtools_adb_bridge.cc', 'browser/devtools/devtools_adb_bridge.h', + 'browser/devtools/devtools_embedder_message_dispatcher.cc', + 'browser/devtools/devtools_embedder_message_dispatcher.h', 'browser/devtools/devtools_file_helper.cc', 'browser/devtools/devtools_file_helper.h', 'browser/devtools/devtools_file_system_indexer.cc', diff --git a/content/browser/devtools/devtools_frontend_host.cc b/content/browser/devtools/devtools_frontend_host.cc index 8f177b6..bfa623a 100644 --- a/content/browser/devtools/devtools_frontend_host.cc +++ b/content/browser/devtools/devtools_frontend_host.cc @@ -63,23 +63,8 @@ bool DevToolsFrontendHost::OnMessageReceived( IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, OnDispatchOnInspectorBackend) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_ChangeAttachedWindowHeight, - OnChangeAttachedWindowHeight) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_MoveWindow, OnMoveWindow) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestSetDockSide, - OnRequestSetDockSide) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_OpenInNewTab, OnOpenInNewTab) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_Save, OnSave) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_Append, OnAppend) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestFileSystems, - OnRequestFileSystems) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_AddFileSystem, OnAddFileSystem) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_RemoveFileSystem, OnRemoveFileSystem) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_IndexPath, OnIndexPath) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_StopIndexing, OnStopIndexing) - IPC_MESSAGE_HANDLER(DevToolsHostMsg_SearchInPath, OnSearchInPath) + IPC_MESSAGE_HANDLER(DevToolsHostMsg_DispatchOnEmbedder, + OnDispatchOnEmbedder) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -101,72 +86,11 @@ void DevToolsFrontendHost::RenderProcessGone( void DevToolsFrontendHost::OnDispatchOnInspectorBackend( const std::string& message) { DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message); -// delegate_->DispatchOnInspectorBackend(message); } -void DevToolsFrontendHost::OnActivateWindow() { - delegate_->ActivateWindow(); -} - -void DevToolsFrontendHost::OnChangeAttachedWindowHeight(unsigned height) { - delegate_->ChangeAttachedWindowHeight(height); -} - -void DevToolsFrontendHost::OnCloseWindow() { - delegate_->CloseWindow(); -} - -void DevToolsFrontendHost::OnMoveWindow(int x, int y) { - delegate_->MoveWindow(x, y); -} - -void DevToolsFrontendHost::OnOpenInNewTab(const std::string& url) { - delegate_->OpenInNewTab(url); -} - -void DevToolsFrontendHost::OnSave( - const std::string& url, - const std::string& content, - bool save_as) { - delegate_->SaveToFile(url, content, save_as); -} - -void DevToolsFrontendHost::OnAppend( - const std::string& url, - const std::string& content) { - delegate_->AppendToFile(url, content); -} - -void DevToolsFrontendHost::OnRequestFileSystems() { - delegate_->RequestFileSystems(); -} - -void DevToolsFrontendHost::OnAddFileSystem() { - delegate_->AddFileSystem(); -} - -void DevToolsFrontendHost::OnRemoveFileSystem( - const std::string& file_system_path) { - delegate_->RemoveFileSystem(file_system_path); -} - -void DevToolsFrontendHost::OnIndexPath(int request_id, - const std::string& file_system_path) { - delegate_->IndexPath(request_id, file_system_path); -} - -void DevToolsFrontendHost::OnStopIndexing(int request_id) { - delegate_->StopIndexing(request_id); -} - -void DevToolsFrontendHost::OnSearchInPath(int request_id, - const std::string& file_system_path, - const std::string& query) { - delegate_->SearchInPath(request_id, file_system_path, query); -} - -void DevToolsFrontendHost::OnRequestSetDockSide(const std::string& side) { - delegate_->SetDockSide(side); +void DevToolsFrontendHost::OnDispatchOnEmbedder( + const std::string& message) { + delegate_->DispatchOnEmbedder(message); } } // namespace content diff --git a/content/browser/devtools/devtools_frontend_host.h b/content/browser/devtools/devtools_frontend_host.h index 646ea4b..469d162 100644 --- a/content/browser/devtools/devtools_frontend_host.h +++ b/content/browser/devtools/devtools_frontend_host.h @@ -40,22 +40,7 @@ class DevToolsFrontendHost : public DevToolsClientHost, virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; void OnDispatchOnInspectorBackend(const std::string& message); - void OnActivateWindow(); - void OnChangeAttachedWindowHeight(unsigned height); - void OnCloseWindow(); - void OnMoveWindow(int x, int y); - void OnRequestSetDockSide(const std::string& side); - void OnOpenInNewTab(const std::string& url); - void OnSave(const std::string& url, const std::string& content, bool save_as); - void OnAppend(const std::string& url, const std::string& content); - void OnRequestFileSystems(); - void OnAddFileSystem(); - void OnRemoveFileSystem(const std::string& file_system_path); - void OnIndexPath(int request_id, const std::string& file_system_path); - void OnStopIndexing(int request_id); - void OnSearchInPath(int request_id, - const std::string& file_system_path, - const std::string& query); + void OnDispatchOnEmbedder(const std::string& message); DevToolsFrontendHostDelegate* delegate_; DISALLOW_COPY_AND_ASSIGN(DevToolsFrontendHost); diff --git a/content/common/devtools_messages.h b/content/common/devtools_messages.h index 996c0cf..b8d4c7e 100644 --- a/content/common/devtools_messages.h +++ b/content/common/devtools_messages.h @@ -107,65 +107,9 @@ IPC_MESSAGE_ROUTED0(DevToolsMsg_SetupDevToolsClient) //----------------------------------------------------------------------------- // These are messages sent from the renderer to the browser. -// Activates (brings to the front) corresponding dev tools window. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_ActivateWindow) - -// Sets the height of corresponding dev tools window. -IPC_MESSAGE_ROUTED1(DevToolsHostMsg_ChangeAttachedWindowHeight, - unsigned /* height */) - -// Closes dev tools window that is inspecting current render_view_host. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_CloseWindow) - -// Moves the corresponding dev tools window by the specified offset. -IPC_MESSAGE_ROUTED2(DevToolsHostMsg_MoveWindow, - int /* x */, - int /* y */) - -// Specifies side for devtools to dock to. -IPC_MESSAGE_ROUTED1(DevToolsHostMsg_RequestSetDockSide, - std::string /* side */) - -// Opens given URL in the new tab. -IPC_MESSAGE_ROUTED1(DevToolsHostMsg_OpenInNewTab, - std::string /* url */) - -// Shows Save As dialog for content. -IPC_MESSAGE_ROUTED3(DevToolsHostMsg_Save, - std::string /* url */, - std::string /* content */, - bool /* save_as */) - -// Appends given |content| to the file that has been associated with the -// given |url| by Save message handler. -IPC_MESSAGE_ROUTED2(DevToolsHostMsg_Append, - std::string /* url */, - std::string /* content */) - -// Requests the list of filesystems previously added for devtools. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_RequestFileSystems) - -// Shows a dialog to select a folder to which an isolated filesystem is added. -IPC_MESSAGE_ROUTED0(DevToolsHostMsg_AddFileSystem) - -// Removes a previously added devtools filesystem given by |file_system_path|. -IPC_MESSAGE_ROUTED1(DevToolsHostMsg_RemoveFileSystem, - std::string /* file_system_path */) - -// Performs file system indexing for given |file_system_path| and sends progress -// callbacks. -IPC_MESSAGE_ROUTED2(DevToolsHostMsg_IndexPath, - int /* request_id */, - std::string /* file_system_path */) - -// Stops file system indexing. -IPC_MESSAGE_ROUTED1(DevToolsHostMsg_StopIndexing, int /* request_id */) - -// Performs trigram search for given |query| in |file_system_path|. -IPC_MESSAGE_ROUTED3(DevToolsHostMsg_SearchInPath, - int /* request_id */, - std::string /* file_system_path */, - std::string /* query */) +// Transport from Inspector frontend to frontend host. +IPC_MESSAGE_ROUTED1(DevToolsHostMsg_DispatchOnEmbedder, + std::string /* message */) // Updates agent runtime state stored in devtools manager in order to support // cross-navigation instrumentation. diff --git a/content/public/browser/devtools_frontend_host_delegate.h b/content/public/browser/devtools_frontend_host_delegate.h index 2aa8826..1d41bef 100644 --- a/content/public/browser/devtools_frontend_host_delegate.h +++ b/content/public/browser/devtools_frontend_host_delegate.h @@ -16,56 +16,8 @@ class DevToolsFrontendHostDelegate { public: virtual ~DevToolsFrontendHostDelegate() {} - // Should bring DevTools window to front. - virtual void ActivateWindow() = 0; - - // Changes the height of attached DevTools window. - virtual void ChangeAttachedWindowHeight(unsigned height) = 0; - - // Closes DevTools front-end window. - virtual void CloseWindow() = 0; - - // Moves DevTools front-end window. - virtual void MoveWindow(int x, int y) = 0; - - // Specifies side for devtools to dock to. - virtual void SetDockSide(const std::string& side) = 0; - - // Opens given |url| in a new contents. - virtual void OpenInNewTab(const std::string& url) = 0; - - // Saves given |content| associated with the given |url|. Optionally showing - // Save As dialog. - virtual void SaveToFile(const std::string& url, - const std::string& content, - bool save_as) = 0; - - // Appends given |content| to the file that has been associated with the - // given |url| by SaveToFile method. - virtual void AppendToFile(const std::string& url, - const std::string& content) = 0; - - // Requests the list of filesystems previously added for devtools. - virtual void RequestFileSystems() = 0; - - // Shows a dialog to select a folder to which an isolated filesystem is added. - virtual void AddFileSystem() = 0; - - // Removes a previously added devtools filesystem given by |file_system_path|. - virtual void RemoveFileSystem(const std::string& file_system_path) = 0; - - // Performs file system indexing for given |file_system_path| and sends - // progress callbacks. - virtual void IndexPath(int request_id, - const std::string& file_system_path) = 0; - - // Stops file system indexing. - virtual void StopIndexing(int request_id) = 0; - - // Performs trigram search for given |query| in |file_system_path|. - virtual void SearchInPath(int request_id, - const std::string& file_system_path, - const std::string& query) = 0; + // Dispatch the message from the frontend to the frontend host. + virtual void DispatchOnEmbedder(const std::string& message) = 0; // This method is called when the contents inspected by this devtools frontend // is closing. diff --git a/content/renderer/devtools/devtools_client.cc b/content/renderer/devtools/devtools_client.cc index 3530081a..5793d2c 100644 --- a/content/renderer/devtools/devtools_client.cc +++ b/content/renderer/devtools/devtools_client.cc @@ -55,75 +55,9 @@ void DevToolsClient::sendMessageToBackend(const WebString& message) { message.utf8())); } -void DevToolsClient::activateWindow() { - Send(new DevToolsHostMsg_ActivateWindow(routing_id())); -} - -void DevToolsClient::changeAttachedWindowHeight(unsigned height) { - Send(new DevToolsHostMsg_ChangeAttachedWindowHeight(routing_id(), height)); -} - -void DevToolsClient::closeWindow() { - Send(new DevToolsHostMsg_CloseWindow(routing_id())); -} - -void DevToolsClient::moveWindowBy(const WebKit::WebFloatPoint& offset) { - Send(new DevToolsHostMsg_MoveWindow(routing_id(), offset.x, offset.y)); -} - -void DevToolsClient::requestSetDockSide(const WebKit::WebString& side) { - Send(new DevToolsHostMsg_RequestSetDockSide(routing_id(), side.utf8())); -} - -void DevToolsClient::openInNewTab(const WebKit::WebString& url) { - Send(new DevToolsHostMsg_OpenInNewTab(routing_id(), - url.utf8())); -} - -void DevToolsClient::save(const WebKit::WebString& url, - const WebKit::WebString& content, - bool save_as) { - Send(new DevToolsHostMsg_Save(routing_id(), - url.utf8(), - content.utf8(), - save_as)); -} - -void DevToolsClient::append(const WebKit::WebString& url, - const WebKit::WebString& content) { - Send(new DevToolsHostMsg_Append(routing_id(), - url.utf8(), - content.utf8())); -} - -void DevToolsClient::requestFileSystems() { - Send(new DevToolsHostMsg_RequestFileSystems(routing_id())); -} - -void DevToolsClient::addFileSystem() { - Send(new DevToolsHostMsg_AddFileSystem(routing_id())); -} - -void DevToolsClient::removeFileSystem(const WebString& file_system_path) { - Send(new DevToolsHostMsg_RemoveFileSystem(routing_id(), - file_system_path.utf8())); -} - -void DevToolsClient::indexPath(int request_id, - const WebKit::WebString& file_system_path) { - Send(new DevToolsHostMsg_IndexPath( - routing_id(), request_id, file_system_path.utf8())); -} - -void DevToolsClient::stopIndexing(int request_id) { - Send(new DevToolsHostMsg_StopIndexing(routing_id(), request_id)); -} - -void DevToolsClient::searchInPath(int request_id, - const WebKit::WebString& file_system_path, - const WebKit::WebString& query) { - Send(new DevToolsHostMsg_SearchInPath( - routing_id(), request_id, file_system_path.utf8(), query.utf8())); +void DevToolsClient::sendMessageToEmbedder(const WebString& message) { + Send(new DevToolsHostMsg_DispatchOnEmbedder(routing_id(), + message.utf8())); } bool DevToolsClient::isUnderTest() { diff --git a/content/renderer/devtools/devtools_client.h b/content/renderer/devtools/devtools_client.h index 768253d..1c9d3f8 100644 --- a/content/renderer/devtools/devtools_client.h +++ b/content/renderer/devtools/devtools_client.h @@ -40,29 +40,7 @@ class CONTENT_EXPORT DevToolsClient // WebDevToolsFrontendClient implementation. virtual void sendMessageToBackend(const WebKit::WebString&) OVERRIDE; - - virtual void activateWindow() OVERRIDE; - virtual void changeAttachedWindowHeight(unsigned height) OVERRIDE; - virtual void closeWindow() OVERRIDE; - virtual void moveWindowBy(const WebKit::WebFloatPoint& offset) OVERRIDE; - virtual void requestSetDockSide(const WebKit::WebString& side) OVERRIDE; - virtual void openInNewTab(const WebKit::WebString& side) OVERRIDE; - virtual void save(const WebKit::WebString& url, - const WebKit::WebString& content, - bool save_as) OVERRIDE; - virtual void append(const WebKit::WebString& url, - const WebKit::WebString& content) OVERRIDE; - - virtual void requestFileSystems() OVERRIDE; - virtual void addFileSystem() OVERRIDE; - virtual void removeFileSystem( - const WebKit::WebString& file_system_path) OVERRIDE; - virtual void indexPath(int request_id, - const WebKit::WebString& file_system_path) OVERRIDE; - virtual void stopIndexing(int request_id) OVERRIDE; - virtual void searchInPath(int request_id, - const WebKit::WebString& file_system_path, - const WebKit::WebString& query) OVERRIDE; + virtual void sendMessageToEmbedder(const WebKit::WebString&) OVERRIDE; virtual bool isUnderTest() OVERRIDE; diff --git a/content/shell/browser/shell_devtools_frontend.h b/content/shell/browser/shell_devtools_frontend.h index b6a617f..4d30666 100644 --- a/content/shell/browser/shell_devtools_frontend.h +++ b/content/shell/browser/shell_devtools_frontend.h @@ -38,26 +38,7 @@ class ShellDevToolsFrontend : public WebContentsObserver, virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; // DevToolsFrontendHostDelegate implementation - virtual void ActivateWindow() OVERRIDE {} - virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE {} - virtual void CloseWindow() OVERRIDE {} - virtual void MoveWindow(int x, int y) OVERRIDE {} - virtual void SetDockSide(const std::string& side) OVERRIDE {} - virtual void OpenInNewTab(const std::string& url) OVERRIDE {} - virtual void SaveToFile(const std::string& url, - const std::string& content, - bool save_as) OVERRIDE {} - virtual void AppendToFile(const std::string& url, - const std::string& content) OVERRIDE {} - virtual void RequestFileSystems() OVERRIDE {} - virtual void AddFileSystem() OVERRIDE {} - virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE {} - virtual void IndexPath(int request_id, - const std::string& file_system_path) OVERRIDE {} - virtual void StopIndexing(int request_id) OVERRIDE {} - virtual void SearchInPath(int request_id, - const std::string& file_system_path, - const std::string& query) OVERRIDE {} + virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE {} virtual void InspectedContentsClosing() OVERRIDE; |