Permalink
Browse files

Add DevTools support

  • Loading branch information...
dati91 committed Jul 27, 2015
1 parent 4f5f4da commit f16f58589d13b087f5befa2b37b48f4d3c2f0826
View
@@ -2,9 +2,10 @@
========
The browser is based on Chromium's Content API.
Supported platforms: Linux, Android.
-Currently we have two branches: master and core.
+Currently we have three branches: master, testing and core.
Core branch contains the relevant code to a minimal browser which can be easily extended with new features.
Master branch contains extra features, for example toolbar, dialogs, tab support.
+Testing branch contains test specific features, for example devtools.
Build steps
-------------
#### Getting the Chromium source code
@@ -27,6 +28,9 @@ git clone https://github.com/szeged/sprocket.git sprocket
cd sprocket && git checkout core && cd ..
# use the latest working Chromium release revision
git reset --hard "$(< sprocket/LKGR)" && gclient sync --nohooks --with_branch_heads --jobs 16
+# apply patches
+git apply sprocket/patch/gritsettings.patch
+git apply sprocket/patch/chromedriver.patch
```
Next, run the selected platform's commands.
##### Linux/PC
@@ -73,6 +77,14 @@ export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox
# run sprocket with sandbox
./out/Release/sprocket --use-sandbox
```
+##### Chromedriver
+[Official site](https://sites.google.com/a/chromium.org/chromedriver/ "ChromeDriver")
+```shell
+# build the chromedirver
+ninja -C out/Release chromedriver
+# run the server
+./out/Release/chromedriver
+```
Additional info
---------------
[How to build a Web Browser](https://docs.google.com/document/d/1Uwvjy5Mj_CMIoLPbKo_kcdVVyrF9waocZQ1vJMuIj54 "How to build a Web Browser")
@@ -13,9 +13,11 @@
#include "base/message_loop/message_loop.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/url_constants.h"
-#include "sprocket/browser/web_contents.h"
-#include "sprocket/browser/ui/window.h"
+#include "components/devtools_http_handler/devtools_http_handler.h"
#include "sprocket/browser/browser_context.h"
+#include "sprocket/browser/devtools/devtools_manager_delegate.h"
+#include "sprocket/browser/ui/window.h"
+#include "sprocket/browser/web_contents.h"
#include "net/base/filename_util.h"
#include "net/base/net_module.h"
#include "net/grit/net_resources.h"
@@ -68,10 +70,12 @@ base::StringPiece NetResourceProvider(int key) {
SprocketBrowserMainParts::SprocketBrowserMainParts(
const content::MainFunctionParams& parameters)
: parameters_(parameters),
- run_message_loop_(true) {
+ run_message_loop_(true),
+ devtools_http_handler_(nullptr) {
}
SprocketBrowserMainParts::~SprocketBrowserMainParts() {
+ DCHECK(!devtools_http_handler_);
}
void SprocketBrowserMainParts::PreEarlyInitialization() {
@@ -110,6 +114,9 @@ void SprocketBrowserMainParts::PreMainMessageLoopRun() {
net::NetModule::SetResourceProvider(NetResourceProvider);
+ devtools_http_handler_.reset(
+ SprocketDevToolsManagerDelegate::CreateHttpHandler(browser_context_.get()));
+
InitializeMessageLoopContext();
}
@@ -119,6 +126,7 @@ bool SprocketBrowserMainParts::MainMessageLoopRun(int* result_code) {
void SprocketBrowserMainParts::PostMainMessageLoopRun() {
SprocketWindow::Deinitialize();
+ devtools_http_handler_.reset();
browser_context_.reset();
off_the_record_browser_context_.reset();
}
@@ -13,6 +13,10 @@
#include "content/public/common/main_function_params.h"
#include "sprocket/browser/browser_context.h"
+namespace devtools_http_handler {
+class DevToolsHttpHandler;
+}
+
// This class contains different "stages" to be executed by |BrowserMain()|,
// Each stage is represented by a single BrowserMainParts method, called from
// the corresponding method in |BrowserMainLoop| (e.g., EarlyInitialization())
@@ -65,6 +69,10 @@ class SprocketBrowserMainParts : public content::BrowserMainParts {
// threads are stopped.
void PostMainMessageLoopRun() override;
+ devtools_http_handler::DevToolsHttpHandler* devtools_http_handler() {
+ return devtools_http_handler_.get();
+ }
+
protected:
virtual void InitializeBrowserContexts();
virtual void InitializeMessageLoopContext();
@@ -83,6 +91,8 @@ class SprocketBrowserMainParts : public content::BrowserMainParts {
const content::MainFunctionParams parameters_;
bool run_message_loop_;
+ scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
+
DISALLOW_COPY_AND_ASSIGN(SprocketBrowserMainParts);
};
@@ -16,6 +16,8 @@
#include "content/public/common/url_constants.h"
#include "sprocket/browser/browser_context.h"
#include "sprocket/browser/browser_main_parts.h"
+#include "sprocket/browser/devtools/devtools_manager_delegate.h"
+
#include "net/url_request/url_request_context_getter.h"
#include "url/gurl.h"
@@ -83,6 +85,7 @@ bool SprocketContentBrowserClient::IsHandledURL(const GURL& url) {
url::kFileSystemScheme,
url::kDataScheme,
url::kFileScheme,
+ content::kChromeDevToolsScheme,
};
for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
if (url.scheme() == kProtocolList[i])
@@ -95,6 +98,11 @@ std::string SprocketContentBrowserClient::GetDefaultDownloadName() {
return "download";
}
+content::DevToolsManagerDelegate*
+SprocketContentBrowserClient::GetDevToolsManagerDelegate() {
+ return new SprocketDevToolsManagerDelegate(BrowserContext());
+}
+
#if defined(OS_ANDROID)
void SprocketContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
const base::CommandLine& command_line,
@@ -48,6 +48,8 @@ class SprocketContentBrowserClient : public content::ContentBrowserClient {
// else we should do with the file.
std::string GetDefaultDownloadName() override;
+ content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
+
// Populates |mappings| with all files that need to be mapped before launching
// a child process.
#if defined(OS_ANDROID)
Oops, something went wrong.

0 comments on commit f16f585

Please sign in to comment.