commit
0180eea8a9
26 changed files with 192 additions and 276 deletions
|
@ -82,8 +82,11 @@
|
||||||
['libchromiumcontent_component', {
|
['libchromiumcontent_component', {
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
# libgtk2ui is always linked statically.
|
# Following libraries are always linked statically.
|
||||||
'<(libchromiumcontent_dir)/libgtk2ui.a',
|
'<(libchromiumcontent_dir)/libgtk2ui.a',
|
||||||
|
'<(libchromiumcontent_dir)/libdevtools_discovery.a',
|
||||||
|
'<(libchromiumcontent_dir)/libdevtools_http_handler.a',
|
||||||
|
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
@ -112,10 +115,19 @@
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'conditions': [
|
'conditions': [
|
||||||
# Link with system frameworks.
|
['libchromiumcontent_component', {
|
||||||
['libchromiumcontent_component==0', {
|
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
|
# Following libraries are always linked statically.
|
||||||
|
'<(libchromiumcontent_dir)/libdevtools_discovery.a',
|
||||||
|
'<(libchromiumcontent_dir)/libdevtools_http_handler.a',
|
||||||
|
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'link_settings': {
|
||||||
|
'libraries': [
|
||||||
|
# Link with system frameworks.
|
||||||
# ui_base.gypi:
|
# ui_base.gypi:
|
||||||
'$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
|
'$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
|
||||||
# net.gypi:
|
# net.gypi:
|
||||||
|
@ -152,19 +164,21 @@
|
||||||
['OS=="win"', {
|
['OS=="win"', {
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['libchromiumcontent_component', {
|
['libchromiumcontent_component', {
|
||||||
# sandbox and base_static are always linked statically.
|
# sandbox, base_static, devtools_discovery, devtools_http_handler,
|
||||||
|
# http_server are always linked statically.
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
'<(libchromiumcontent_dir)/base_static.lib',
|
'<(libchromiumcontent_dir)/base_static.lib',
|
||||||
'<(libchromiumcontent_dir)/sandbox.lib',
|
'<(libchromiumcontent_dir)/sandbox.lib',
|
||||||
|
'<(libchromiumcontent_dir)/devtools_discovery.lib',
|
||||||
|
'<(libchromiumcontent_dir)/devtools_http_handler.lib',
|
||||||
|
'<(libchromiumcontent_dir)/http_server.lib',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# Link with system libraries.
|
# Link with system libraries.
|
||||||
'link_settings': {
|
'link_settings': {
|
||||||
'libraries': [
|
'libraries': [
|
||||||
# ffmpegsumo.lib is required for linking with ffmpegsumo.dll
|
|
||||||
'<(libchromiumcontent_dir)/ffmpegsumo.lib',
|
|
||||||
# content_browser.gypi:
|
# content_browser.gypi:
|
||||||
'-lsensorsapi.lib',
|
'-lsensorsapi.lib',
|
||||||
'-lportabledeviceguids.lib',
|
'-lportabledeviceguids.lib',
|
||||||
|
@ -184,6 +198,7 @@
|
||||||
'AdditionalDependencies': [
|
'AdditionalDependencies': [
|
||||||
'advapi32.lib',
|
'advapi32.lib',
|
||||||
'dbghelp.lib',
|
'dbghelp.lib',
|
||||||
|
'delayimp.lib',
|
||||||
'dwmapi.lib',
|
'dwmapi.lib',
|
||||||
'gdi32.lib',
|
'gdi32.lib',
|
||||||
'netapi32.lib',
|
'netapi32.lib',
|
||||||
|
@ -195,7 +210,6 @@
|
||||||
'winspool.lib',
|
'winspool.lib',
|
||||||
],
|
],
|
||||||
'DelayLoadDLLs': [
|
'DelayLoadDLLs': [
|
||||||
'ffmpegsumo.dll',
|
|
||||||
# content_common.gypi:
|
# content_common.gypi:
|
||||||
'd3d9.dll',
|
'd3d9.dll',
|
||||||
'dxva2.dll',
|
'dxva2.dll',
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
'-Wextra',
|
'-Wextra',
|
||||||
'-Wno-unused-parameter',
|
'-Wno-unused-parameter',
|
||||||
'-Wno-missing-field-initializers',
|
'-Wno-missing-field-initializers',
|
||||||
|
'-Wno-unneeded-internal-declaration',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'msvs_configuration_attributes': {
|
'msvs_configuration_attributes': {
|
||||||
|
|
|
@ -10,11 +10,8 @@
|
||||||
#include "browser/media/media_capture_devices_dispatcher.h"
|
#include "browser/media/media_capture_devices_dispatcher.h"
|
||||||
#include "browser/platform_notification_service_impl.h"
|
#include "browser/platform_notification_service_impl.h"
|
||||||
|
|
||||||
#include "base/base_paths.h"
|
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "content/public/common/content_descriptors.h"
|
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
#include "gin/public/isolate_holder.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
@ -32,11 +29,6 @@ BrowserClient::BrowserClient()
|
||||||
: browser_main_parts_(nullptr) {
|
: browser_main_parts_(nullptr) {
|
||||||
DCHECK(!g_browser_client);
|
DCHECK(!g_browser_client);
|
||||||
g_browser_client = this;
|
g_browser_client = this;
|
||||||
|
|
||||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
||||||
v8_natives_fd_.reset(-1);
|
|
||||||
v8_snapshot_fd_.reset(-1);
|
|
||||||
#endif // OS_POSIX && !OS_MACOSX
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserClient::~BrowserClient() {
|
BrowserClient::~BrowserClient() {
|
||||||
|
@ -63,7 +55,9 @@ net::URLRequestContextGetter* BrowserClient::CreateRequestContext(
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors) {
|
content::URLRequestInterceptorScopedVector protocol_interceptors) {
|
||||||
auto context = static_cast<BrowserContext*>(browser_context);
|
auto context = static_cast<BrowserContext*>(browser_context);
|
||||||
return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass());
|
return context->CreateRequestContext(static_cast<NetLog*>(GetNetLog()),
|
||||||
|
protocol_handlers,
|
||||||
|
protocol_interceptors.Pass());
|
||||||
}
|
}
|
||||||
|
|
||||||
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
||||||
|
@ -81,7 +75,7 @@ void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||||
}
|
}
|
||||||
|
|
||||||
net::NetLog* BrowserClient::GetNetLog() {
|
net::NetLog* BrowserClient::GetNetLog() {
|
||||||
return browser_context()->GetNetLog();
|
return &net_log_;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
|
base::FilePath BrowserClient::GetDefaultDownloadDirectory() {
|
||||||
|
@ -97,31 +91,4 @@ content::DevToolsManagerDelegate* BrowserClient::GetDevToolsManagerDelegate() {
|
||||||
return new DevToolsManagerDelegate;
|
return new DevToolsManagerDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
||||||
void BrowserClient::GetAdditionalMappedFilesForChildProcess(
|
|
||||||
const base::CommandLine& command_line,
|
|
||||||
int child_process_id,
|
|
||||||
content::FileDescriptorInfo* mappings) {
|
|
||||||
if (v8_snapshot_fd_.get() == -1 && v8_natives_fd_.get() == -1) {
|
|
||||||
base::FilePath v8_data_path;
|
|
||||||
PathService::Get(gin::IsolateHolder::kV8SnapshotBasePathKey, &v8_data_path);
|
|
||||||
DCHECK(!v8_data_path.empty());
|
|
||||||
|
|
||||||
int file_flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
|
|
||||||
base::FilePath v8_natives_data_path =
|
|
||||||
v8_data_path.AppendASCII(gin::IsolateHolder::kNativesFileName);
|
|
||||||
base::FilePath v8_snapshot_data_path =
|
|
||||||
v8_data_path.AppendASCII(gin::IsolateHolder::kSnapshotFileName);
|
|
||||||
base::File v8_natives_data_file(v8_natives_data_path, file_flags);
|
|
||||||
base::File v8_snapshot_data_file(v8_snapshot_data_path, file_flags);
|
|
||||||
DCHECK(v8_natives_data_file.IsValid());
|
|
||||||
DCHECK(v8_snapshot_data_file.IsValid());
|
|
||||||
v8_natives_fd_.reset(v8_natives_data_file.TakePlatformFile());
|
|
||||||
v8_snapshot_fd_.reset(v8_snapshot_data_file.TakePlatformFile());
|
|
||||||
}
|
|
||||||
mappings->Share(kV8NativesDataDescriptor, v8_natives_fd_.get());
|
|
||||||
mappings->Share(kV8SnapshotDataDescriptor, v8_snapshot_fd_.get());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
#ifndef BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
|
#ifndef BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
|
||||||
#define BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
|
#define BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
|
||||||
|
|
||||||
|
#include "browser/net_log.h"
|
||||||
#include "content/public/browser/content_browser_client.h"
|
#include "content/public/browser/content_browser_client.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class BrowserContext;
|
class BrowserContext;
|
||||||
class BrowserMainParts;
|
class BrowserMainParts;
|
||||||
|
class NetLog;
|
||||||
|
|
||||||
class BrowserClient : public content::ContentBrowserClient {
|
class BrowserClient : public content::ContentBrowserClient {
|
||||||
public:
|
public:
|
||||||
|
@ -35,8 +37,6 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors) override;
|
content::URLRequestInterceptorScopedVector protocol_interceptors) override;
|
||||||
|
|
||||||
private:
|
|
||||||
content::BrowserMainParts* CreateBrowserMainParts(
|
content::BrowserMainParts* CreateBrowserMainParts(
|
||||||
const content::MainFunctionParams&) override;
|
const content::MainFunctionParams&) override;
|
||||||
content::MediaObserver* GetMediaObserver() override;
|
content::MediaObserver* GetMediaObserver() override;
|
||||||
|
@ -47,19 +47,8 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
base::FilePath GetDefaultDownloadDirectory() override;
|
base::FilePath GetDefaultDownloadDirectory() override;
|
||||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||||
|
|
||||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
||||||
void GetAdditionalMappedFilesForChildProcess(
|
|
||||||
const base::CommandLine& command_line,
|
|
||||||
int child_process_id,
|
|
||||||
content::FileDescriptorInfo* mappings) override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BrowserMainParts* browser_main_parts_;
|
BrowserMainParts* browser_main_parts_;
|
||||||
|
NetLog net_log_;
|
||||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
||||||
base::ScopedFD v8_natives_fd_;
|
|
||||||
base::ScopedFD v8_snapshot_fd_;
|
|
||||||
#endif // OS_POSIX && !OS_MACOSX
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||||
};
|
};
|
||||||
|
|
|
@ -100,11 +100,13 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
||||||
|
NetLog* net_log,
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors) {
|
content::URLRequestInterceptorScopedVector protocol_interceptors) {
|
||||||
DCHECK(!url_request_getter_.get());
|
DCHECK(!url_request_getter_.get());
|
||||||
url_request_getter_ = new URLRequestContextGetter(
|
url_request_getter_ = new URLRequestContextGetter(
|
||||||
this,
|
this,
|
||||||
|
net_log,
|
||||||
GetPath(),
|
GetPath(),
|
||||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
||||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
||||||
|
@ -114,10 +116,6 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
||||||
return url_request_getter_.get();
|
return url_request_getter_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::NetLog* BrowserContext::GetNetLog() {
|
|
||||||
return url_request_getter_->net_log();
|
|
||||||
}
|
|
||||||
|
|
||||||
net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() {
|
net::NetworkDelegate* BrowserContext::CreateNetworkDelegate() {
|
||||||
return new NetworkDelegate;
|
return new NetworkDelegate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ class BrowserContext : public content::BrowserContext,
|
||||||
content::PermissionManager* GetPermissionManager() override;
|
content::PermissionManager* GetPermissionManager() override;
|
||||||
|
|
||||||
net::URLRequestContextGetter* CreateRequestContext(
|
net::URLRequestContextGetter* CreateRequestContext(
|
||||||
|
NetLog* net_log,
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors);
|
content::URLRequestInterceptorScopedVector protocol_interceptors);
|
||||||
net::NetLog* GetNetLog();
|
|
||||||
|
|
||||||
net::URLRequestContextGetter* url_request_context_getter() const {
|
net::URLRequestContextGetter* url_request_context_getter() const {
|
||||||
return url_request_getter_.get();
|
return url_request_getter_.get();
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "components/devtools_http_handler/devtools_http_handler.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
#include "net/proxy/proxy_resolver_v8.h"
|
#include "net/proxy/proxy_resolver_v8.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "content/public/browser/browser_main_parts.h"
|
#include "content/public/browser/browser_main_parts.h"
|
||||||
|
|
||||||
namespace content {
|
namespace devtools_http_handler {
|
||||||
class DevToolsHttpHandler;
|
class DevToolsHttpHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class BrowserMainParts : public content::BrowserMainParts {
|
||||||
|
|
||||||
scoped_ptr<BrowserContext> browser_context_;
|
scoped_ptr<BrowserContext> browser_context_;
|
||||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||||
scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler_;
|
scoped_ptr<devtools_http_handler::DevToolsHttpHandler> devtools_http_handler_;
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
scoped_ptr<ViewsDelegate> views_delegate_;
|
scoped_ptr<ViewsDelegate> views_delegate_;
|
||||||
|
|
|
@ -195,6 +195,11 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
|
||||||
d->RegisterHandler("recordActionUMA", &Delegate::RecordActionUMA, delegate);
|
d->RegisterHandler("recordActionUMA", &Delegate::RecordActionUMA, delegate);
|
||||||
d->RegisterHandlerWithCallback("sendJsonRequest",
|
d->RegisterHandlerWithCallback("sendJsonRequest",
|
||||||
&Delegate::SendJsonRequest, delegate);
|
&Delegate::SendJsonRequest, delegate);
|
||||||
|
d->RegisterHandlerWithCallback("getPreferences",
|
||||||
|
&Delegate::GetPreferences, delegate);
|
||||||
|
d->RegisterHandler("setPreference", &Delegate::SetPreference, delegate);
|
||||||
|
d->RegisterHandler("removePreference", &Delegate::RemovePreference, delegate);
|
||||||
|
d->RegisterHandler("clearPreferences", &Delegate::ClearPreferences, delegate);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,11 @@ class DevToolsEmbedderMessageDispatcher {
|
||||||
virtual void SendJsonRequest(const DispatchCallback& callback,
|
virtual void SendJsonRequest(const DispatchCallback& callback,
|
||||||
const std::string& browser_id,
|
const std::string& browser_id,
|
||||||
const std::string& url) = 0;
|
const std::string& url) = 0;
|
||||||
|
virtual void GetPreferences(const DispatchCallback& callback) = 0;
|
||||||
|
virtual void SetPreference(const std::string& name,
|
||||||
|
const std::string& value) = 0;
|
||||||
|
virtual void RemovePreference(const std::string& name) = 0;
|
||||||
|
virtual void ClearPreferences() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
using DispatchCallback = Delegate::DispatchCallback;
|
using DispatchCallback = Delegate::DispatchCallback;
|
||||||
|
|
|
@ -12,27 +12,22 @@
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "browser/browser_context.h"
|
#include "common/content_client.h"
|
||||||
|
#include "components/devtools_discovery/basic_target_descriptor.h"
|
||||||
|
#include "components/devtools_discovery/devtools_discovery_manager.h"
|
||||||
|
#include "components/devtools_http_handler/devtools_http_handler.h"
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
#include "content/public/browser/devtools_agent_host.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "content/public/browser/devtools_frontend_host.h"
|
||||||
#include "content/public/browser/devtools_target.h"
|
|
||||||
#include "content/public/browser/favicon_status.h"
|
#include "content/public/browser/favicon_status.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
#include "content/public/common/user_agent.h"
|
#include "content/public/common/user_agent.h"
|
||||||
|
#include "net/base/net_errors.h"
|
||||||
#include "net/socket/tcp_server_socket.h"
|
#include "net/socket/tcp_server_socket.h"
|
||||||
#include "net/socket/stream_socket.h"
|
#include "net/socket/stream_socket.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
#include "ui/base/resource/resource_bundle.h"
|
||||||
|
|
||||||
using content::DevToolsAgentHost;
|
|
||||||
using content::RenderViewHost;
|
|
||||||
using content::WebContents;
|
|
||||||
using content::BrowserContext;
|
|
||||||
using content::DevToolsTarget;
|
|
||||||
using content::DevToolsHttpHandler;
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
@ -43,12 +38,8 @@ namespace {
|
||||||
// since libcontentchromium doesn't expose content_shell resources.
|
// since libcontentchromium doesn't expose content_shell resources.
|
||||||
const int kIDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE = 25500;
|
const int kIDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE = 25500;
|
||||||
|
|
||||||
const char kTargetTypePage[] = "page";
|
|
||||||
const char kTargetTypeServiceWorker[] = "service_worker";
|
|
||||||
const char kTargetTypeOther[] = "other";
|
|
||||||
|
|
||||||
class TCPServerSocketFactory
|
class TCPServerSocketFactory
|
||||||
: public content::DevToolsHttpHandler::ServerSocketFactory {
|
: public devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory {
|
||||||
public:
|
public:
|
||||||
TCPServerSocketFactory(const std::string& address, int port)
|
TCPServerSocketFactory(const std::string& address, int port)
|
||||||
: address_(address), port_(port) {
|
: address_(address), port_(port) {
|
||||||
|
@ -71,7 +62,7 @@ class TCPServerSocketFactory
|
||||||
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
|
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
|
||||||
};
|
};
|
||||||
|
|
||||||
scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
|
scoped_ptr<devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory>
|
||||||
CreateSocketFactory() {
|
CreateSocketFactory() {
|
||||||
auto& command_line = *base::CommandLine::ForCurrentProcess();
|
auto& command_line = *base::CommandLine::ForCurrentProcess();
|
||||||
// See if the user specified a port on the command line (useful for
|
// See if the user specified a port on the command line (useful for
|
||||||
|
@ -88,77 +79,24 @@ CreateSocketFactory() {
|
||||||
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>(
|
return scoped_ptr<
|
||||||
new TCPServerSocketFactory("127.0.0.1", port));
|
devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory>(
|
||||||
|
new TCPServerSocketFactory("127.0.0.1", port));
|
||||||
}
|
}
|
||||||
|
|
||||||
class Target : public content::DevToolsTarget {
|
|
||||||
public:
|
|
||||||
explicit Target(scoped_refptr<DevToolsAgentHost> agent_host);
|
|
||||||
|
|
||||||
std::string GetId() const override { return agent_host_->GetId(); }
|
|
||||||
std::string GetParentId() const override { return std::string(); }
|
|
||||||
std::string GetType() const override {
|
|
||||||
switch (agent_host_->GetType()) {
|
|
||||||
case DevToolsAgentHost::TYPE_WEB_CONTENTS:
|
|
||||||
return kTargetTypePage;
|
|
||||||
case DevToolsAgentHost::TYPE_SERVICE_WORKER:
|
|
||||||
return kTargetTypeServiceWorker;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return kTargetTypeOther;
|
|
||||||
}
|
|
||||||
std::string GetTitle() const override { return agent_host_->GetTitle(); }
|
|
||||||
std::string GetDescription() const override { return std::string(); }
|
|
||||||
GURL GetURL() const override { return agent_host_->GetURL(); }
|
|
||||||
GURL GetFaviconURL() const override { return favicon_url_; }
|
|
||||||
base::TimeTicks GetLastActivityTime() const override {
|
|
||||||
return last_activity_time_;
|
|
||||||
}
|
|
||||||
bool IsAttached() const override { return agent_host_->IsAttached(); }
|
|
||||||
scoped_refptr<DevToolsAgentHost> GetAgentHost() const override {
|
|
||||||
return agent_host_;
|
|
||||||
}
|
|
||||||
bool Activate() const override;
|
|
||||||
bool Close() const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
scoped_refptr<DevToolsAgentHost> agent_host_;
|
|
||||||
GURL favicon_url_;
|
|
||||||
base::TimeTicks last_activity_time_;
|
|
||||||
};
|
|
||||||
|
|
||||||
Target::Target(scoped_refptr<DevToolsAgentHost> agent_host)
|
|
||||||
: agent_host_(agent_host) {
|
|
||||||
if (WebContents* web_contents = agent_host_->GetWebContents()) {
|
|
||||||
content::NavigationController& controller = web_contents->GetController();
|
|
||||||
content::NavigationEntry* entry = controller.GetActiveEntry();
|
|
||||||
if (entry != NULL && entry->GetURL().is_valid())
|
|
||||||
favicon_url_ = entry->GetFavicon().url;
|
|
||||||
last_activity_time_ = web_contents->GetLastActiveTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Target::Activate() const {
|
|
||||||
return agent_host_->Activate();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Target::Close() const {
|
|
||||||
return agent_host_->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DevToolsDelegate --------------------------------------------------------
|
// DevToolsDelegate --------------------------------------------------------
|
||||||
|
|
||||||
class DevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
|
class DevToolsDelegate :
|
||||||
|
public devtools_http_handler::DevToolsHttpHandlerDelegate {
|
||||||
public:
|
public:
|
||||||
DevToolsDelegate();
|
DevToolsDelegate();
|
||||||
virtual ~DevToolsDelegate();
|
virtual ~DevToolsDelegate();
|
||||||
|
|
||||||
// content::DevToolsHttpHandlerDelegate.
|
// devtools_http_handler::DevToolsHttpHandlerDelegate.
|
||||||
std::string GetDiscoveryPageHTML() override;
|
std::string GetDiscoveryPageHTML() override;
|
||||||
bool BundlesFrontendResources() override;
|
std::string GetFrontendResource(const std::string& path) override;
|
||||||
base::FilePath GetDebugFrontendDir() override;
|
std::string GetPageThumbnailData(const GURL& url) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
|
DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
|
||||||
|
@ -175,12 +113,14 @@ std::string DevToolsDelegate::GetDiscoveryPageHTML() {
|
||||||
kIDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
|
kIDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DevToolsDelegate::BundlesFrontendResources() {
|
|
||||||
return true;
|
std::string DevToolsDelegate::GetFrontendResource(
|
||||||
|
const std::string& path) {
|
||||||
|
return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
base::FilePath DevToolsDelegate::GetDebugFrontendDir() {
|
std::string DevToolsDelegate::GetPageThumbnailData(const GURL& url) {
|
||||||
return base::FilePath();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -188,15 +128,25 @@ base::FilePath DevToolsDelegate::GetDebugFrontendDir() {
|
||||||
// DevToolsManagerDelegate ---------------------------------------------------
|
// DevToolsManagerDelegate ---------------------------------------------------
|
||||||
|
|
||||||
// static
|
// static
|
||||||
content::DevToolsHttpHandler*
|
devtools_http_handler::DevToolsHttpHandler*
|
||||||
DevToolsManagerDelegate::CreateHttpHandler() {
|
DevToolsManagerDelegate::CreateHttpHandler() {
|
||||||
return DevToolsHttpHandler::Start(CreateSocketFactory(),
|
return new devtools_http_handler::DevToolsHttpHandler(
|
||||||
std::string(),
|
CreateSocketFactory(),
|
||||||
new DevToolsDelegate,
|
std::string(),
|
||||||
base::FilePath());
|
new DevToolsDelegate,
|
||||||
|
base::FilePath(),
|
||||||
|
base::FilePath(),
|
||||||
|
std::string(),
|
||||||
|
GetBrightrayUserAgent());
|
||||||
}
|
}
|
||||||
|
|
||||||
DevToolsManagerDelegate::DevToolsManagerDelegate() {
|
DevToolsManagerDelegate::DevToolsManagerDelegate() {
|
||||||
|
// NB(zcbenz): This call does nothing, the only purpose is to make sure the
|
||||||
|
// devtools_discovery module is linked into the final executable on Linux.
|
||||||
|
// Though it is possible to achieve this by modifying the gyp settings, it
|
||||||
|
// would greatly increase gyp file's complexity, so I chose to instead do
|
||||||
|
// this hack.
|
||||||
|
devtools_discovery::DevToolsDiscoveryManager::GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
DevToolsManagerDelegate::~DevToolsManagerDelegate() {
|
DevToolsManagerDelegate::~DevToolsManagerDelegate() {
|
||||||
|
@ -208,22 +158,4 @@ base::DictionaryValue* DevToolsManagerDelegate::HandleCommand(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DevToolsManagerDelegate::GetPageThumbnailData(
|
|
||||||
const GURL& url) {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_ptr<content::DevToolsTarget>
|
|
||||||
DevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
|
|
||||||
return scoped_ptr<content::DevToolsTarget>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) {
|
|
||||||
TargetList targets;
|
|
||||||
for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) {
|
|
||||||
targets.push_back(new Target(agent_host));
|
|
||||||
}
|
|
||||||
callback.Run(targets);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "content/public/browser/devtools_http_handler_delegate.h"
|
#include "components/devtools_http_handler/devtools_http_handler_delegate.h"
|
||||||
#include "content/public/browser/devtools_manager_delegate.h"
|
#include "content/public/browser/devtools_manager_delegate.h"
|
||||||
|
|
||||||
namespace content {
|
namespace devtools_http_handler {
|
||||||
class DevToolsHttpHandler;
|
class DevToolsHttpHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace brightray {
|
||||||
|
|
||||||
class DevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
class DevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
||||||
public:
|
public:
|
||||||
static content::DevToolsHttpHandler* CreateHttpHandler();
|
static devtools_http_handler::DevToolsHttpHandler* CreateHttpHandler();
|
||||||
|
|
||||||
DevToolsManagerDelegate();
|
DevToolsManagerDelegate();
|
||||||
virtual ~DevToolsManagerDelegate();
|
virtual ~DevToolsManagerDelegate();
|
||||||
|
@ -30,9 +30,6 @@ class DevToolsManagerDelegate : public content::DevToolsManagerDelegate {
|
||||||
bool attached) override {}
|
bool attached) override {}
|
||||||
base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host,
|
base::DictionaryValue* HandleCommand(content::DevToolsAgentHost* agent_host,
|
||||||
base::DictionaryValue* command) override;
|
base::DictionaryValue* command) override;
|
||||||
scoped_ptr<content::DevToolsTarget> CreateNewTarget(const GURL& url) override;
|
|
||||||
void EnumerateTargets(TargetCallback callback) override;
|
|
||||||
std::string GetPageThumbnailData(const GURL& url) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(DevToolsManagerDelegate);
|
DISALLOW_COPY_AND_ASSIGN(DevToolsManagerDelegate);
|
||||||
|
|
|
@ -11,11 +11,10 @@
|
||||||
#include "base/memory/ref_counted_memory.h"
|
#include "base/memory/ref_counted_memory.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "content/public/browser/devtools_frontend_host.h"
|
||||||
#include "content/public/browser/url_data_source.h"
|
#include "content/public/browser/url_data_source.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_ui.h"
|
#include "content/public/browser/web_ui.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
|
||||||
|
|
||||||
using content::WebContents;
|
using content::WebContents;
|
||||||
|
|
||||||
|
@ -64,17 +63,10 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
int render_view_id,
|
int render_view_id,
|
||||||
const GotDataCallback& callback) override {
|
const GotDataCallback& callback) override {
|
||||||
std::string filename = PathWithoutParams(path);
|
std::string filename = PathWithoutParams(path);
|
||||||
|
base::StringPiece resource =
|
||||||
int resource_id =
|
content::DevToolsFrontendHost::GetFrontendResource(filename);
|
||||||
content::DevToolsHttpHandler::GetFrontendResourceId(filename);
|
scoped_refptr<base::RefCountedStaticMemory> bytes(
|
||||||
|
new base::RefCountedStaticMemory(resource.data(), resource.length()));
|
||||||
DLOG_IF(WARNING, resource_id == -1)
|
|
||||||
<< "Unable to find dev tool resource: " << filename
|
|
||||||
<< ". If you compiled with debug_devtools=1, try running with "
|
|
||||||
"--debug-devtools.";
|
|
||||||
const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
|
||||||
scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes(
|
|
||||||
resource_id));
|
|
||||||
callback.Run(bytes.get());
|
callback.Run(bytes.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#include "base/metrics/histogram.h"
|
#include "base/metrics/histogram.h"
|
||||||
#include "base/prefs/pref_registry_simple.h"
|
#include "base/prefs/pref_registry_simple.h"
|
||||||
#include "base/prefs/pref_service.h"
|
#include "base/prefs/pref_service.h"
|
||||||
|
#include "base/prefs/scoped_user_pref_update.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
|
||||||
#include "content/public/browser/host_zoom_map.h"
|
#include "content/public/browser/host_zoom_map.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
@ -45,6 +45,7 @@ const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?"
|
||||||
"experiments=true";
|
"experiments=true";
|
||||||
const char kDevToolsBoundsPref[] = "brightray.devtools.bounds";
|
const char kDevToolsBoundsPref[] = "brightray.devtools.bounds";
|
||||||
const char kDevToolsZoomPref[] = "brightray.devtools.zoom";
|
const char kDevToolsZoomPref[] = "brightray.devtools.zoom";
|
||||||
|
const char kDevToolsPreferences[] = "brightray.devtools.preferences";
|
||||||
|
|
||||||
const char kFrontendHostId[] = "id";
|
const char kFrontendHostId[] = "id";
|
||||||
const char kFrontendHostMethod[] = "method";
|
const char kFrontendHostMethod[] = "method";
|
||||||
|
@ -161,6 +162,7 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
||||||
RectToDictionary(gfx::Rect(0, 0, 800, 600), bounds_dict.get());
|
RectToDictionary(gfx::Rect(0, 0, 800, 600), bounds_dict.get());
|
||||||
registry->RegisterDictionaryPref(kDevToolsBoundsPref, bounds_dict.release());
|
registry->RegisterDictionaryPref(kDevToolsBoundsPref, bounds_dict.release());
|
||||||
registry->RegisterDoublePref(kDevToolsZoomPref, 0.);
|
registry->RegisterDoublePref(kDevToolsZoomPref, 0.);
|
||||||
|
registry->RegisterDictionaryPref(kDevToolsPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||||
|
@ -364,7 +366,7 @@ void InspectableWebContentsImpl::LoadNetworkResource(
|
||||||
auto browser_context = static_cast<BrowserContext*>(devtools_web_contents_->GetBrowserContext());
|
auto browser_context = static_cast<BrowserContext*>(devtools_web_contents_->GetBrowserContext());
|
||||||
|
|
||||||
net::URLFetcher* fetcher =
|
net::URLFetcher* fetcher =
|
||||||
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this);
|
(net::URLFetcher::Create(gurl, net::URLFetcher::GET, this)).release();
|
||||||
pending_requests_[fetcher] = callback;
|
pending_requests_[fetcher] = callback;
|
||||||
fetcher->SetRequestContext(browser_context->url_request_context_getter());
|
fetcher->SetRequestContext(browser_context->url_request_context_getter());
|
||||||
fetcher->SetExtraRequestHeaders(headers);
|
fetcher->SetExtraRequestHeaders(headers);
|
||||||
|
@ -470,6 +472,29 @@ void InspectableWebContentsImpl::SendJsonRequest(const DispatchCallback& callbac
|
||||||
callback.Run(nullptr);
|
callback.Run(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::GetPreferences(
|
||||||
|
const DispatchCallback& callback) {
|
||||||
|
const base::DictionaryValue* prefs = pref_service_->GetDictionary(
|
||||||
|
kDevToolsPreferences);
|
||||||
|
callback.Run(prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetPreference(const std::string& name,
|
||||||
|
const std::string& value) {
|
||||||
|
DictionaryPrefUpdate update(pref_service_, kDevToolsPreferences);
|
||||||
|
update.Get()->SetStringWithoutPathExpansion(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::RemovePreference(const std::string& name) {
|
||||||
|
DictionaryPrefUpdate update(pref_service_, kDevToolsPreferences);
|
||||||
|
update.Get()->RemoveWithoutPathExpansion(name, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::ClearPreferences() {
|
||||||
|
DictionaryPrefUpdate update(pref_service_, kDevToolsPreferences);
|
||||||
|
update.Get()->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::string& message) {
|
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::string& message) {
|
||||||
std::string method;
|
std::string method;
|
||||||
base::ListValue empty_params;
|
base::ListValue empty_params;
|
||||||
|
@ -577,8 +602,7 @@ void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
||||||
CloseDevTools();
|
CloseDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsFocused(
|
void InspectableWebContentsImpl::OnWebContentsFocused() {
|
||||||
content::WebContents* contents) {
|
|
||||||
if (view_->GetDelegate())
|
if (view_->GetDelegate())
|
||||||
view_->GetDelegate()->DevToolsFocused();
|
view_->GetDelegate()->DevToolsFocused();
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,11 @@ class InspectableWebContentsImpl :
|
||||||
void SendJsonRequest(const DispatchCallback& callback,
|
void SendJsonRequest(const DispatchCallback& callback,
|
||||||
const std::string& browser_id,
|
const std::string& browser_id,
|
||||||
const std::string& url) override;
|
const std::string& url) override;
|
||||||
|
void GetPreferences(const DispatchCallback& callback) override;
|
||||||
|
void SetPreference(const std::string& name,
|
||||||
|
const std::string& value) override;
|
||||||
|
void RemovePreference(const std::string& name) override;
|
||||||
|
void ClearPreferences() override;
|
||||||
|
|
||||||
// content::DevToolsFrontendHostDelegate:
|
// content::DevToolsFrontendHostDelegate:
|
||||||
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
||||||
|
@ -125,6 +130,7 @@ class InspectableWebContentsImpl :
|
||||||
void AboutToNavigateRenderFrame(content::RenderFrameHost* old_host,
|
void AboutToNavigateRenderFrame(content::RenderFrameHost* old_host,
|
||||||
content::RenderFrameHost* new_host) override;
|
content::RenderFrameHost* new_host) override;
|
||||||
void WebContentsDestroyed() override;
|
void WebContentsDestroyed() override;
|
||||||
|
void OnWebContentsFocused() override;
|
||||||
|
|
||||||
// content::WebContentsDelegate:
|
// content::WebContentsDelegate:
|
||||||
bool AddMessageToConsole(content::WebContents* source,
|
bool AddMessageToConsole(content::WebContents* source,
|
||||||
|
@ -144,7 +150,6 @@ class InspectableWebContentsImpl :
|
||||||
void HandleKeyboardEvent(
|
void HandleKeyboardEvent(
|
||||||
content::WebContents*, const content::NativeWebKeyboardEvent&) override;
|
content::WebContents*, const content::NativeWebKeyboardEvent&) override;
|
||||||
void CloseContents(content::WebContents* source) override;
|
void CloseContents(content::WebContents* source) override;
|
||||||
void WebContentsFocused(content::WebContents* contents) override;
|
|
||||||
|
|
||||||
// net::URLFetcherDelegate:
|
// net::URLFetcherDelegate:
|
||||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||||
|
|
|
@ -4,14 +4,13 @@
|
||||||
|
|
||||||
#include "browser/net_log.h"
|
#include "browser/net_log.h"
|
||||||
|
|
||||||
#include "browser/browser_context.h"
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/json/json_writer.h"
|
#include "base/values.h"
|
||||||
#include "base/logging.h"
|
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
#include "net/log/net_log_util.h"
|
#include "net/log/net_log_util.h"
|
||||||
#include "net/url_request/url_request_context.h"
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -30,62 +29,34 @@ scoped_ptr<base::DictionaryValue> GetConstants() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace brightray {
|
NetLog::NetLog() {
|
||||||
|
|
||||||
NetLog::NetLog(net::URLRequestContext* context)
|
|
||||||
: added_events_(false),
|
|
||||||
context_(context) {
|
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
if (command_line->HasSwitch(switches::kLogNetLog)) {
|
if (!command_line->HasSwitch(switches::kLogNetLog))
|
||||||
base::FilePath log_path =
|
return;
|
||||||
command_line->GetSwitchValuePath(switches::kLogNetLog);
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
base::FilePath log_path = command_line->GetSwitchValuePath(switches::kLogNetLog);
|
||||||
log_file_.reset(_wfopen(log_path.value().c_str(), L"w"));
|
#if defined(OS_WIN)
|
||||||
#elif defined(OS_POSIX)
|
log_file_.reset(_wfopen(log_path.value().c_str(), L"w"));
|
||||||
log_file_.reset(fopen(log_path.value().c_str(), "w"));
|
#elif defined(OS_POSIX)
|
||||||
#endif
|
log_file_.reset(fopen(log_path.value().c_str(), "w"));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!log_file_) {
|
if (!log_file_) {
|
||||||
LOG(ERROR) << "Could not open file: " << log_path.value()
|
LOG(ERROR) << "Could not open file: " << log_path.value()
|
||||||
<< "for net logging";
|
<< "for net logging";
|
||||||
} else {
|
return;
|
||||||
std::string json;
|
|
||||||
scoped_ptr<base::Value> constants(GetConstants().Pass());
|
|
||||||
base::JSONWriter::Write(constants.get(), &json);
|
|
||||||
fprintf(log_file_.get(), "{\"constants\": %s, \n", json.c_str());
|
|
||||||
fprintf(log_file_.get(), "\"events\": [\n");
|
|
||||||
|
|
||||||
if (context_) {
|
|
||||||
DCHECK(context_->CalledOnValidThread());
|
|
||||||
|
|
||||||
std::set<net::URLRequestContext*> contexts;
|
|
||||||
contexts.insert(context_);
|
|
||||||
|
|
||||||
net::CreateNetLogEntriesForActiveObjects(contexts, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeprecatedAddObserver(this, net::NetLog::LogLevel::LOG_STRIP_PRIVATE_DATA);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetLog::~NetLog() {
|
NetLog::~NetLog() {
|
||||||
if (log_file_) {
|
|
||||||
DeprecatedRemoveObserver(this);
|
|
||||||
|
|
||||||
// Ending events array.
|
|
||||||
fprintf(log_file_.get(), "]}");
|
|
||||||
log_file_.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetLog::OnAddEntry(const net::NetLog::Entry& entry) {
|
void NetLog::StartLogging(net::URLRequestContext* url_request_context) {
|
||||||
std::string json;
|
if (!log_file_)
|
||||||
base::JSONWriter::Write(entry.ToValue(), &json);
|
return;
|
||||||
|
|
||||||
fprintf(log_file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
|
scoped_ptr<base::Value> constants(GetConstants());
|
||||||
added_events_ = true;
|
write_to_file_observer_.StartObserving(this, log_file_.Pass(), constants.get(), url_request_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -5,29 +5,22 @@
|
||||||
#ifndef BROWSER_NET_LOG_H_
|
#ifndef BROWSER_NET_LOG_H_
|
||||||
#define BROWSER_NET_LOG_H_
|
#define BROWSER_NET_LOG_H_
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
|
||||||
#include "base/files/scoped_file.h"
|
#include "base/files/scoped_file.h"
|
||||||
#include "net/log/net_log.h"
|
#include "net/log/net_log.h"
|
||||||
|
#include "net/log/write_to_file_net_log_observer.h"
|
||||||
namespace net {
|
|
||||||
class URLRequestContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class NetLog : public net::NetLog,
|
class NetLog : public net::NetLog {
|
||||||
public net::NetLog::ThreadSafeObserver {
|
|
||||||
public:
|
public:
|
||||||
explicit NetLog(net::URLRequestContext* context);
|
NetLog();
|
||||||
~NetLog() override;
|
~NetLog() override;
|
||||||
|
|
||||||
void OnAddEntry(const net::NetLog::Entry& entry) override;
|
void StartLogging(net::URLRequestContext* url_request_context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool added_events_;
|
|
||||||
// We use raw pointer to prevent reference cycle.
|
|
||||||
net::URLRequestContext* const context_;
|
|
||||||
base::ScopedFILE log_file_;
|
base::ScopedFILE log_file_;
|
||||||
|
net::WriteToFileNetLogObserver write_to_file_observer_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,10 +6,13 @@
|
||||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
||||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
||||||
|
|
||||||
#import "browser/notification_presenter.h"
|
#include "browser/notification_presenter.h"
|
||||||
|
|
||||||
#import "base/mac/scoped_nsobject.h"
|
#include <map>
|
||||||
#import <map>
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#include "base/mac/scoped_nsobject.h"
|
||||||
|
|
||||||
@class BRYUserNotificationCenterDelegate;
|
@class BRYUserNotificationCenterDelegate;
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include "content/public/browser/desktop_notification_delegate.h"
|
#include "content/public/browser/desktop_notification_delegate.h"
|
||||||
#include "skia/ext/skia_utils_mac.h"
|
#include "skia/ext/skia_utils_mac.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
@interface BRYUserNotificationCenterDelegate : NSObject<NSUserNotificationCenterDelegate> {
|
@interface BRYUserNotificationCenterDelegate : NSObject<NSUserNotificationCenterDelegate> {
|
||||||
@private
|
@private
|
||||||
brightray::NotificationPresenterMac* presenter_;
|
brightray::NotificationPresenterMac* presenter_;
|
||||||
|
|
|
@ -63,7 +63,13 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification(
|
||||||
|
|
||||||
void PlatformNotificationServiceImpl::ClosePersistentNotification(
|
void PlatformNotificationServiceImpl::ClosePersistentNotification(
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
const std::string& persistent_notification_id) {
|
int64_t persistent_notification_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
std::set<std::string>* displayed_notifications) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -51,7 +51,10 @@ class PlatformNotificationServiceImpl
|
||||||
const content::PlatformNotificationData& notification_data) override;
|
const content::PlatformNotificationData& notification_data) override;
|
||||||
void ClosePersistentNotification(
|
void ClosePersistentNotification(
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
const std::string& persistent_notification_id) override;
|
int64_t persistent_notification_id) override;
|
||||||
|
bool GetDisplayedPersistentNotifications(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
std::set<std::string>* displayed_notifications) override;
|
||||||
|
|
||||||
scoped_ptr<NotificationPresenter> notification_presenter_;
|
scoped_ptr<NotificationPresenter> notification_presenter_;
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,14 @@ URLRequestContextGetter::Delegate::CreateHttpCacheBackendFactory(const base::Fil
|
||||||
|
|
||||||
URLRequestContextGetter::URLRequestContextGetter(
|
URLRequestContextGetter::URLRequestContextGetter(
|
||||||
Delegate* delegate,
|
Delegate* delegate,
|
||||||
|
NetLog* net_log,
|
||||||
const base::FilePath& base_path,
|
const base::FilePath& base_path,
|
||||||
base::MessageLoop* io_loop,
|
base::MessageLoop* io_loop,
|
||||||
base::MessageLoop* file_loop,
|
base::MessageLoop* file_loop,
|
||||||
content::ProtocolHandlerMap* protocol_handlers,
|
content::ProtocolHandlerMap* protocol_handlers,
|
||||||
content::URLRequestInterceptorScopedVector protocol_interceptors)
|
content::URLRequestInterceptorScopedVector protocol_interceptors)
|
||||||
: delegate_(delegate),
|
: delegate_(delegate),
|
||||||
|
net_log_(net_log),
|
||||||
base_path_(base_path),
|
base_path_(base_path),
|
||||||
io_loop_(io_loop),
|
io_loop_(io_loop),
|
||||||
file_loop_(file_loop),
|
file_loop_(file_loop),
|
||||||
|
@ -157,8 +159,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||||
url_request_context_.reset(new net::URLRequestContext);
|
url_request_context_.reset(new net::URLRequestContext);
|
||||||
|
|
||||||
// --log-net-log
|
// --log-net-log
|
||||||
net_log_.reset(new NetLog(url_request_context_.get()));
|
net_log_->StartLogging(url_request_context_.get());
|
||||||
url_request_context_->set_net_log(net_log_.get());
|
url_request_context_->set_net_log(net_log_);
|
||||||
|
|
||||||
network_delegate_.reset(delegate_->CreateNetworkDelegate());
|
network_delegate_.reset(delegate_->CreateNetworkDelegate());
|
||||||
url_request_context_->set_network_delegate(network_delegate_.get());
|
url_request_context_->set_network_delegate(network_delegate_.get());
|
||||||
|
|
|
@ -17,7 +17,6 @@ class MessageLoop;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
class NetLog;
|
|
||||||
class HostMappingRules;
|
class HostMappingRules;
|
||||||
class HostResolver;
|
class HostResolver;
|
||||||
class NetworkDelegate;
|
class NetworkDelegate;
|
||||||
|
@ -28,6 +27,8 @@ class URLRequestJobFactory;
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
class NetLog;
|
||||||
|
|
||||||
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
public:
|
public:
|
||||||
class Delegate {
|
class Delegate {
|
||||||
|
@ -46,6 +47,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
|
|
||||||
URLRequestContextGetter(
|
URLRequestContextGetter(
|
||||||
Delegate* delegate,
|
Delegate* delegate,
|
||||||
|
NetLog* net_log,
|
||||||
const base::FilePath& base_path,
|
const base::FilePath& base_path,
|
||||||
base::MessageLoop* io_loop,
|
base::MessageLoop* io_loop,
|
||||||
base::MessageLoop* file_loop,
|
base::MessageLoop* file_loop,
|
||||||
|
@ -58,17 +60,16 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
||||||
|
|
||||||
net::HostResolver* host_resolver();
|
net::HostResolver* host_resolver();
|
||||||
net::NetLog* net_log() { return net_log_.get(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_;
|
Delegate* delegate_;
|
||||||
|
|
||||||
|
NetLog* net_log_;
|
||||||
base::FilePath base_path_;
|
base::FilePath base_path_;
|
||||||
base::MessageLoop* io_loop_;
|
base::MessageLoop* io_loop_;
|
||||||
base::MessageLoop* file_loop_;
|
base::MessageLoop* file_loop_;
|
||||||
|
|
||||||
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
|
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
|
||||||
scoped_ptr<net::NetLog> net_log_;
|
|
||||||
scoped_ptr<net::NetworkDelegate> network_delegate_;
|
scoped_ptr<net::NetworkDelegate> network_delegate_;
|
||||||
scoped_ptr<net::URLRequestContextStorage> storage_;
|
scoped_ptr<net::URLRequestContextStorage> storage_;
|
||||||
scoped_ptr<net::URLRequestContext> url_request_context_;
|
scoped_ptr<net::URLRequestContext> url_request_context_;
|
||||||
|
|
|
@ -14,6 +14,17 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
std::string GetProductInternal() {
|
||||||
|
auto name = GetApplicationName();
|
||||||
|
base::RemoveChars(name, base::kWhitespaceASCII, &name);
|
||||||
|
return base::StringPrintf("%s/%s",
|
||||||
|
name.c_str(), GetApplicationVersion().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetBrightrayUserAgent() {
|
||||||
|
return content::BuildUserAgentFromProduct(GetProductInternal());
|
||||||
|
}
|
||||||
|
|
||||||
ContentClient::ContentClient() {
|
ContentClient::ContentClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +32,11 @@ ContentClient::~ContentClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ContentClient::GetProduct() const {
|
std::string ContentClient::GetProduct() const {
|
||||||
auto name = GetApplicationName();
|
return GetProductInternal();
|
||||||
base::RemoveChars(name, base::kWhitespaceASCII, &name);
|
|
||||||
return base::StringPrintf("%s/%s",
|
|
||||||
name.c_str(), GetApplicationVersion().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ContentClient::GetUserAgent() const {
|
std::string ContentClient::GetUserAgent() const {
|
||||||
return content::BuildUserAgentFromProduct(GetProduct());
|
return GetBrightrayUserAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string16 ContentClient::GetLocalizedString(int message_id) const {
|
base::string16 ContentClient::GetLocalizedString(int message_id) const {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
std::string GetBrightrayUserAgent();
|
||||||
|
|
||||||
class ContentClient : public content::ContentClient {
|
class ContentClient : public content::ContentClient {
|
||||||
public:
|
public:
|
||||||
ContentClient();
|
ContentClient();
|
||||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 534e0fbaaca61a7b8d57578b2646d47cf4237d2a
|
Subproject commit cf133b8ebfeb3579032d3092351c801a3112aa7c
|
Loading…
Add table
Reference in a new issue