commit
afca245916
29 changed files with 270 additions and 200 deletions
|
@ -71,10 +71,10 @@
|
|||
'browser/notification_presenter.h',
|
||||
'browser/notification_presenter_mac.h',
|
||||
'browser/notification_presenter_mac.mm',
|
||||
'browser/platform_notification_service_impl.cc',
|
||||
'browser/platform_notification_service_impl.h',
|
||||
'browser/linux/notification_presenter_linux.h',
|
||||
'browser/linux/notification_presenter_linux.cc',
|
||||
'browser/remote_debugging_server.cc',
|
||||
'browser/remote_debugging_server.h',
|
||||
'browser/url_request_context_getter.cc',
|
||||
'browser/url_request_context_getter.h',
|
||||
'browser/views/inspectable_web_contents_view_views.h',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "browser/browser_main_parts.h"
|
||||
#include "browser/devtools_manager_delegate.h"
|
||||
#include "browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "browser/notification_presenter.h"
|
||||
#include "browser/platform_notification_service_impl.h"
|
||||
|
||||
#include "base/base_paths.h"
|
||||
#include "base/path_service.h"
|
||||
|
@ -39,14 +39,6 @@ BrowserContext* BrowserClient::browser_context() {
|
|||
return browser_main_parts_->browser_context();
|
||||
}
|
||||
|
||||
NotificationPresenter* BrowserClient::notification_presenter() {
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
if (!notification_presenter_)
|
||||
notification_presenter_.reset(NotificationPresenter::Create());
|
||||
#endif
|
||||
return notification_presenter_.get();
|
||||
}
|
||||
|
||||
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) {
|
||||
return new BrowserMainParts;
|
||||
|
@ -67,21 +59,14 @@ net::URLRequestContextGetter* BrowserClient::CreateRequestContext(
|
|||
return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass());
|
||||
}
|
||||
|
||||
void BrowserClient::ShowDesktopNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) {
|
||||
auto presenter = notification_presenter();
|
||||
if (presenter)
|
||||
presenter->ShowNotification(params, delegate.Pass(), cancel_callback);
|
||||
}
|
||||
|
||||
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
||||
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||
}
|
||||
|
||||
content::PlatformNotificationService* BrowserClient::GetPlatformNotificationService() {
|
||||
return PlatformNotificationServiceImpl::GetInstance();
|
||||
}
|
||||
|
||||
void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* additional_schemes) {
|
||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace brightray {
|
|||
|
||||
class BrowserContext;
|
||||
class BrowserMainParts;
|
||||
class NotificationPresenter;
|
||||
|
||||
class BrowserClient : public content::ContentBrowserClient {
|
||||
public:
|
||||
|
@ -22,7 +21,6 @@ class BrowserClient : public content::ContentBrowserClient {
|
|||
|
||||
BrowserContext* browser_context();
|
||||
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
||||
NotificationPresenter* notification_presenter();
|
||||
|
||||
protected:
|
||||
// Subclasses should override this to provide their own BrowserMainParts
|
||||
|
@ -41,20 +39,14 @@ class BrowserClient : public content::ContentBrowserClient {
|
|||
private:
|
||||
content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) override;
|
||||
void ShowDesktopNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) override;
|
||||
content::MediaObserver* GetMediaObserver() override;
|
||||
content::PlatformNotificationService* GetPlatformNotificationService() override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* additional_schemes) override;
|
||||
base::FilePath GetDefaultDownloadDirectory() override;
|
||||
content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
|
||||
|
||||
BrowserMainParts* browser_main_parts_;
|
||||
scoped_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||
};
|
||||
|
|
|
@ -99,6 +99,11 @@ base::FilePath BrowserContext::GetPath() const {
|
|||
return path_;
|
||||
}
|
||||
|
||||
scoped_ptr<content::ZoomLevelDelegate> BrowserContext::CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) {
|
||||
return scoped_ptr<content::ZoomLevelDelegate>();
|
||||
}
|
||||
|
||||
bool BrowserContext::IsOffTheRecord() const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ class BrowserContext : public content::BrowserContext,
|
|||
|
||||
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||
|
||||
scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
|
||||
const base::FilePath& partition_path) override;
|
||||
bool IsOffTheRecord() const override;
|
||||
net::URLRequestContextGetter* GetRequestContext() override;
|
||||
net::URLRequestContextGetter* GetRequestContextForRenderProcess(
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
#include "browser/browser_main_parts.h"
|
||||
|
||||
#include "browser/browser_context.h"
|
||||
#include "browser/remote_debugging_server.h"
|
||||
#include "browser/devtools_manager_delegate.h"
|
||||
#include "browser/web_ui_controller_factory.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "content/public/browser/devtools_http_handler.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "net/proxy/proxy_resolver_v8.h"
|
||||
|
||||
|
@ -125,16 +126,9 @@ void BrowserMainParts::PreMainMessageLoopRun() {
|
|||
web_ui_controller_factory_.get());
|
||||
|
||||
// --remote-debugging-port
|
||||
base::CommandLine* command_line = CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kRemoteDebuggingPort)) {
|
||||
std::string port_str = command_line->GetSwitchValueASCII(switches::kRemoteDebuggingPort);
|
||||
int port;
|
||||
if (base::StringToInt(port_str, &port) && port >= 0 && port < 65535)
|
||||
remote_debugging_server_.reset(
|
||||
new RemoteDebuggingServer("127.0.0.1", static_cast<uint16>(port)));
|
||||
else
|
||||
DLOG(WARNING) << "Invalid http debugger port number " << port;
|
||||
}
|
||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kRemoteDebuggingPort))
|
||||
devtools_http_handler_.reset(DevToolsManagerDelegate::CreateHttpHandler());
|
||||
}
|
||||
|
||||
void BrowserMainParts::PostMainMessageLoopRun() {
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
#include "base/memory/scoped_ptr.h"
|
||||
#include "content/public/browser/browser_main_parts.h"
|
||||
|
||||
namespace content {
|
||||
class DevToolsHttpHandler;
|
||||
}
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
namespace brightray {
|
||||
class ViewsDelegate;
|
||||
|
@ -25,7 +29,6 @@ namespace brightray {
|
|||
|
||||
class BrowserContext;
|
||||
class WebUIControllerFactory;
|
||||
class RemoteDebuggingServer;
|
||||
|
||||
class BrowserMainParts : public content::BrowserMainParts {
|
||||
public:
|
||||
|
@ -58,7 +61,7 @@ class BrowserMainParts : public content::BrowserMainParts {
|
|||
|
||||
scoped_ptr<BrowserContext> browser_context_;
|
||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||
scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
|
||||
scoped_ptr<content::DevToolsHttpHandler> devtools_http_handler_;
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
scoped_ptr<ViewsDelegate> views_delegate_;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define BRIGHTRAY_BROWSER_DEVTOOLS_CONTENTS_RESIZING_STRATEGY_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "ui/gfx/insets.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
// This class knows how to resize both DevTools and inspected WebContents
|
||||
// inside a browser window hierarchy.
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include <string>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "ui/gfx/insets.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
namespace base {
|
||||
class ListValue;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
#include "net/socket/tcp_server_socket.h"
|
||||
#include "net/socket/stream_socket.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
using content::DevToolsAgentHost;
|
||||
|
@ -65,7 +66,7 @@ class TCPServerSocketFactory
|
|||
|
||||
scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
|
||||
CreateSocketFactory() {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
auto& command_line = *base::CommandLine::ForCurrentProcess();
|
||||
// See if the user specified a port on the command line (useful for
|
||||
// automation). If not, use an ephemeral port by specifying 0.
|
||||
int port = 0;
|
||||
|
@ -151,8 +152,7 @@ class DevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
|
|||
std::string GetDiscoveryPageHTML() override;
|
||||
bool BundlesFrontendResources() override;
|
||||
base::FilePath GetDebugFrontendDir() override;
|
||||
scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
|
||||
net::StreamListenSocket::Delegate* delegate,
|
||||
scoped_ptr<net::ServerSocket> CreateSocketForTethering(
|
||||
std::string* name) override;
|
||||
|
||||
private:
|
||||
|
@ -178,11 +178,9 @@ base::FilePath DevToolsDelegate::GetDebugFrontendDir() {
|
|||
return base::FilePath();
|
||||
}
|
||||
|
||||
scoped_ptr<net::StreamListenSocket>
|
||||
DevToolsDelegate::CreateSocketForTethering(
|
||||
net::StreamListenSocket::Delegate* delegate,
|
||||
scoped_ptr<net::ServerSocket> DevToolsDelegate::CreateSocketForTethering(
|
||||
std::string* name) {
|
||||
return scoped_ptr<net::StreamListenSocket>();
|
||||
return scoped_ptr<net::ServerSocket>();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -162,7 +162,7 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
|||
|
||||
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
|
||||
frontend_host_.reset(content::DevToolsFrontendHost::Create(
|
||||
web_contents_->GetRenderViewHost(), this));
|
||||
web_contents_->GetMainFrame(), this));
|
||||
agent_host_->AttachClient(this);
|
||||
|
||||
GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, can_dock_ ? "true" : ""));
|
||||
|
@ -243,7 +243,7 @@ void InspectableWebContentsImpl::AppendToFile(
|
|||
|
||||
void InspectableWebContentsImpl::RequestFileSystems() {
|
||||
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(
|
||||
base::ASCIIToUTF16("InspectorFrontendAPI.fileSystemsLoaded([])"));
|
||||
base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([])"));
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::AddFileSystem() {
|
||||
|
@ -296,7 +296,7 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::st
|
|||
std::string error = embedder_message_dispatcher_->Dispatch(method, ¶ms);
|
||||
if (id) {
|
||||
std::string ack = base::StringPrintf(
|
||||
"InspectorFrontendAPI.embedderMessageAck(%d, \"%s\");", id, error.c_str());
|
||||
"DevToolsAPI.embedderMessageAck(%d, \"%s\");", id, error.c_str());
|
||||
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(ack));
|
||||
}
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend(
|
|||
|
||||
void InspectableWebContentsImpl::DispatchProtocolMessage(
|
||||
content::DevToolsAgentHost* agent_host, const std::string& message) {
|
||||
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
|
||||
std::string code = "DevToolsAPI.dispatchMessage(" + message + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||
}
|
||||
|
@ -317,10 +317,11 @@ void InspectableWebContentsImpl::AgentHostClosed(
|
|||
content::DevToolsAgentHost* agent_host, bool replaced) {
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::AboutToNavigateRenderView(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
frontend_host_.reset(content::DevToolsFrontendHost::Create(
|
||||
render_view_host, this));
|
||||
void InspectableWebContentsImpl::AboutToNavigateRenderFrame(
|
||||
content::RenderFrameHost* new_host) {
|
||||
if (new_host->GetParent())
|
||||
return;
|
||||
frontend_host_.reset(content::DevToolsFrontendHost::Create(new_host, this));
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
|
@ -355,6 +356,7 @@ bool InspectableWebContentsImpl::AddMessageToConsole(
|
|||
bool InspectableWebContentsImpl::ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
int main_frame_route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const base::string16& frame_name,
|
||||
const GURL& target_url,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "content/public/browser/devtools_frontend_host.h"
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
|
||||
|
@ -104,7 +104,7 @@ class InspectableWebContentsImpl :
|
|||
bool replaced) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) override;
|
||||
void AboutToNavigateRenderFrame(content::RenderFrameHost* new_host) override;
|
||||
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) override;
|
||||
void WebContentsDestroyed() override;
|
||||
|
@ -118,6 +118,7 @@ class InspectableWebContentsImpl :
|
|||
bool ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
int main_frame_route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const base::string16& frame_name,
|
||||
const GURL& target_url,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "base/logging.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/desktop_notification_delegate.h"
|
||||
#include "content/public/common/show_desktop_notification_params.h"
|
||||
#include "content/public/common/platform_notification_data.h"
|
||||
#include "common/application_info.h"
|
||||
|
||||
namespace brightray {
|
||||
|
@ -51,11 +51,11 @@ NotificationPresenterLinux::~NotificationPresenterLinux() {
|
|||
}
|
||||
|
||||
void NotificationPresenterLinux::ShowNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
const content::PlatformNotificationData& data,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate_ptr,
|
||||
base::Closure* cancel_callback) {
|
||||
std::string title = base::UTF16ToUTF8(params.title);
|
||||
std::string body = base::UTF16ToUTF8(params.body);
|
||||
std::string title = base::UTF16ToUTF8(data.title);
|
||||
std::string body = base::UTF16ToUTF8(data.body);
|
||||
NotifyNotification* notification = notify_notification_new(title.c_str(), body.c_str(), nullptr);
|
||||
|
||||
content::DesktopNotificationDelegate* delegate = delegate_ptr.release();
|
||||
|
|
|
@ -25,8 +25,8 @@ class NotificationPresenterLinux : public NotificationPresenter {
|
|||
|
||||
private:
|
||||
// NotificationPresenter:
|
||||
virtual void ShowNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams&,
|
||||
void ShowNotification(
|
||||
const content::PlatformNotificationData&,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) override;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ bool MediaStreamDevicesController::TakeAction() {
|
|||
// Do special handling of desktop screen cast.
|
||||
if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE ||
|
||||
request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE ||
|
||||
request_.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE ||
|
||||
request_.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE ||
|
||||
request_.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
|
||||
HandleUserMediaRequest();
|
||||
return true;
|
||||
|
@ -59,7 +59,7 @@ bool MediaStreamDevicesController::TakeAction() {
|
|||
|
||||
// Deny the request if there is no device attached to the OS.
|
||||
if (!HasAnyAvailableDevice()) {
|
||||
Deny();
|
||||
Deny(content::MEDIA_DEVICE_NO_HARDWARE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,11 @@ void MediaStreamDevicesController::Accept() {
|
|||
cb.Run(devices, content::MEDIA_DEVICE_OK, scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny() {
|
||||
void MediaStreamDevicesController::Deny(content::MediaStreamRequestResult result) {
|
||||
content::MediaResponseCallback cb = callback_;
|
||||
callback_.Reset();
|
||||
cb.Run(content::MediaStreamDevices(),
|
||||
content::MEDIA_DEVICE_PERMISSION_DENIED,
|
||||
result,
|
||||
scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
|
@ -168,9 +168,9 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
|
|||
devices.push_back(content::MediaStreamDevice(
|
||||
content::MEDIA_TAB_VIDEO_CAPTURE, "", ""));
|
||||
}
|
||||
if (request_.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE) {
|
||||
if (request_.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE) {
|
||||
devices.push_back(content::MediaStreamDevice(
|
||||
content::MEDIA_LOOPBACK_AUDIO_CAPTURE, "loopback", "System Audio"));
|
||||
content::MEDIA_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio"));
|
||||
}
|
||||
if (request_.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) {
|
||||
content::DesktopMediaID screen_id;
|
||||
|
|
|
@ -23,7 +23,7 @@ class MediaStreamDevicesController {
|
|||
|
||||
// Explicitly accept or deny the request.
|
||||
void Accept();
|
||||
void Deny();
|
||||
void Deny(content::MediaStreamRequestResult result);
|
||||
|
||||
private:
|
||||
// Handle the request of desktop or tab screen cast.
|
||||
|
|
|
@ -21,6 +21,15 @@ int NetworkDelegate::OnBeforeURLRequest(
|
|||
return net::OK;
|
||||
}
|
||||
|
||||
void NetworkDelegate::OnResolveProxy(const GURL& url,
|
||||
int load_flags,
|
||||
const net::ProxyService& proxy_service,
|
||||
net::ProxyInfo* result) {
|
||||
}
|
||||
|
||||
void NetworkDelegate::OnProxyFallback(const net::ProxyServer& bad_proxy, int net_error) {
|
||||
}
|
||||
|
||||
int NetworkDelegate::OnBeforeSendHeaders(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
|
@ -28,6 +37,11 @@ int NetworkDelegate::OnBeforeSendHeaders(
|
|||
return net::OK;
|
||||
}
|
||||
|
||||
void NetworkDelegate::OnBeforeSendProxyHeaders(net::URLRequest* request,
|
||||
const net::ProxyInfo& proxy_info,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
}
|
||||
|
||||
void NetworkDelegate::OnSendHeaders(
|
||||
net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
|
@ -92,10 +106,17 @@ bool NetworkDelegate::OnCanThrottleRequest(
|
|||
return false;
|
||||
}
|
||||
|
||||
int NetworkDelegate::OnBeforeSocketStreamConnect(
|
||||
net::SocketStream* socket,
|
||||
const net::CompletionCallback& callback) {
|
||||
return net::OK;
|
||||
bool NetworkDelegate::OnCanEnablePrivacyMode(
|
||||
const GURL& url,
|
||||
const GURL& first_party_for_cookies) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
|
||||
const net::URLRequest& request,
|
||||
const GURL& target_url,
|
||||
const GURL& referrer_url) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
|
|
|
@ -15,46 +15,57 @@ class NetworkDelegate : public net::NetworkDelegate {
|
|||
virtual ~NetworkDelegate();
|
||||
|
||||
protected:
|
||||
virtual int OnBeforeURLRequest(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
GURL* new_url) override;
|
||||
virtual int OnBeforeSendHeaders(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) override;
|
||||
virtual void OnSendHeaders(net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) override;
|
||||
virtual int OnHeadersReceived(
|
||||
int OnBeforeURLRequest(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
GURL* new_url) override;
|
||||
void OnResolveProxy(const GURL& url,
|
||||
int load_flags,
|
||||
const net::ProxyService& proxy_service,
|
||||
net::ProxyInfo* result) override;
|
||||
void OnProxyFallback(const net::ProxyServer& bad_proxy, int net_error) override;
|
||||
int OnBeforeSendHeaders(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) override;
|
||||
void OnBeforeSendProxyHeaders(net::URLRequest* request,
|
||||
const net::ProxyInfo& proxy_info,
|
||||
net::HttpRequestHeaders* headers) override;
|
||||
void OnSendHeaders(net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) override;
|
||||
int OnHeadersReceived(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
const net::HttpResponseHeaders* original_response_headers,
|
||||
scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
|
||||
GURL* allowed_unsafe_redirect_url) override;
|
||||
virtual void OnBeforeRedirect(net::URLRequest* request,
|
||||
const GURL& new_location) override;
|
||||
virtual void OnResponseStarted(net::URLRequest* request) override;
|
||||
virtual void OnRawBytesRead(const net::URLRequest& request,
|
||||
int bytes_read) override;
|
||||
virtual void OnCompleted(net::URLRequest* request, bool started) override;
|
||||
virtual void OnURLRequestDestroyed(net::URLRequest* request) override;
|
||||
virtual void OnPACScriptError(int line_number,
|
||||
const base::string16& error) override;
|
||||
virtual AuthRequiredResponse OnAuthRequired(
|
||||
void OnBeforeRedirect(net::URLRequest* request,
|
||||
const GURL& new_location) override;
|
||||
void OnResponseStarted(net::URLRequest* request) override;
|
||||
void OnRawBytesRead(const net::URLRequest& request,
|
||||
int bytes_read) override;
|
||||
void OnCompleted(net::URLRequest* request, bool started) override;
|
||||
void OnURLRequestDestroyed(net::URLRequest* request) override;
|
||||
void OnPACScriptError(int line_number,
|
||||
const base::string16& error) override;
|
||||
AuthRequiredResponse OnAuthRequired(
|
||||
net::URLRequest* request,
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
const AuthCallback& callback,
|
||||
net::AuthCredentials* credentials) override;
|
||||
virtual bool OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) override;
|
||||
virtual bool OnCanSetCookie(const net::URLRequest& request,
|
||||
const std::string& cookie_line,
|
||||
net::CookieOptions* options) override;
|
||||
virtual bool OnCanAccessFile(const net::URLRequest& request,
|
||||
const base::FilePath& path) const override;
|
||||
virtual bool OnCanThrottleRequest(
|
||||
const net::URLRequest& request) const override;
|
||||
virtual int OnBeforeSocketStreamConnect(
|
||||
net::SocketStream* stream,
|
||||
const net::CompletionCallback& callback) override;
|
||||
bool OnCanGetCookies(const net::URLRequest& request,
|
||||
const net::CookieList& cookie_list) override;
|
||||
bool OnCanSetCookie(const net::URLRequest& request,
|
||||
const std::string& cookie_line,
|
||||
net::CookieOptions* options) override;
|
||||
bool OnCanAccessFile(const net::URLRequest& request,
|
||||
const base::FilePath& path) const override;
|
||||
bool OnCanThrottleRequest(const net::URLRequest& request) const override;
|
||||
bool OnCanEnablePrivacyMode(
|
||||
const GURL& url,
|
||||
const GURL& first_party_for_cookies) const override;
|
||||
bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
|
||||
const net::URLRequest& request,
|
||||
const GURL& target_url,
|
||||
const GURL& referrer_url) const override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace content {
|
||||
class DesktopNotificationDelegate;
|
||||
struct ShowDesktopNotificationHostMsgParams;
|
||||
struct PlatformNotificationData;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
|
@ -18,7 +18,7 @@ class NotificationPresenter {
|
|||
static NotificationPresenter* Create();
|
||||
|
||||
virtual void ShowNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams&,
|
||||
const content::PlatformNotificationData&,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) = 0;
|
||||
};
|
||||
|
|
|
@ -20,8 +20,9 @@ class NotificationPresenterMac : public NotificationPresenter {
|
|||
NotificationPresenterMac();
|
||||
~NotificationPresenterMac();
|
||||
|
||||
virtual void ShowNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams&,
|
||||
// NotificationPresenter:
|
||||
void ShowNotification(
|
||||
const content::PlatformNotificationData&,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) override;
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include "base/bind.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "content/public/common/platform_notification_data.h"
|
||||
#include "content/public/browser/desktop_notification_delegate.h"
|
||||
#include "content/public/common/show_desktop_notification_params.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
@ -40,12 +40,12 @@ NotificationPresenterMac::~NotificationPresenterMac() {
|
|||
}
|
||||
|
||||
void NotificationPresenterMac::ShowNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
const content::PlatformNotificationData& data,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
base::Closure* cancel_callback) {
|
||||
auto notification = [[NSUserNotification alloc] init];
|
||||
notification.title = base::SysUTF16ToNSString(params.title);
|
||||
notification.informativeText = base::SysUTF16ToNSString(params.body);
|
||||
notification.title = base::SysUTF16ToNSString(data.title);
|
||||
notification.informativeText = base::SysUTF16ToNSString(data.body);
|
||||
|
||||
notifications_map_[delegate.get()].reset(notification);
|
||||
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
|
||||
|
|
64
brightray/browser/platform_notification_service_impl.cc
Normal file
64
brightray/browser/platform_notification_service_impl.cc
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) 2015 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-CHROMIUM file.
|
||||
|
||||
#include "browser/platform_notification_service_impl.h"
|
||||
|
||||
#include "browser/notification_presenter.h"
|
||||
|
||||
#include "content/public/browser/desktop_notification_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
// static
|
||||
PlatformNotificationServiceImpl*
|
||||
PlatformNotificationServiceImpl::GetInstance() {
|
||||
return Singleton<PlatformNotificationServiceImpl>::get();
|
||||
}
|
||||
|
||||
PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() {}
|
||||
PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {}
|
||||
|
||||
NotificationPresenter* PlatformNotificationServiceImpl::notification_presenter() {
|
||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
||||
if (!notification_presenter_)
|
||||
notification_presenter_.reset(NotificationPresenter::Create());
|
||||
#endif
|
||||
return notification_presenter_.get();
|
||||
}
|
||||
|
||||
blink::WebNotificationPermission PlatformNotificationServiceImpl::CheckPermission(
|
||||
content::ResourceContext* resource_context,
|
||||
const GURL& origin,
|
||||
int render_process_id) {
|
||||
return blink::WebNotificationPermissionAllowed;
|
||||
}
|
||||
|
||||
void PlatformNotificationServiceImpl::DisplayNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& origin,
|
||||
const SkBitmap& icon,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
int render_process_id,
|
||||
base::Closure* cancel_callback) {
|
||||
auto presenter = notification_presenter();
|
||||
if (presenter)
|
||||
presenter->ShowNotification(notification_data, delegate.Pass(), cancel_callback);
|
||||
}
|
||||
|
||||
void PlatformNotificationServiceImpl::DisplayPersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
int64 service_worker_registration_id,
|
||||
const GURL& origin,
|
||||
const SkBitmap& icon,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
int render_process_id) {
|
||||
}
|
||||
|
||||
void PlatformNotificationServiceImpl::ClosePersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& persistent_notification_id) {
|
||||
}
|
||||
|
||||
} // namespace brightray
|
61
brightray/browser/platform_notification_service_impl.h
Normal file
61
brightray/browser/platform_notification_service_impl.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) 2015 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-CHROMIUM file.
|
||||
|
||||
#ifndef BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
|
||||
#define BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
|
||||
|
||||
#include "base/memory/singleton.h"
|
||||
#include "content/public/browser/platform_notification_service.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class NotificationPresenter;
|
||||
|
||||
class PlatformNotificationServiceImpl
|
||||
: public content::PlatformNotificationService {
|
||||
public:
|
||||
// Returns the active instance of the service in the browser process. Safe to
|
||||
// be called from any thread.
|
||||
static PlatformNotificationServiceImpl* GetInstance();
|
||||
|
||||
NotificationPresenter* notification_presenter();
|
||||
|
||||
private:
|
||||
friend struct DefaultSingletonTraits<PlatformNotificationServiceImpl>;
|
||||
|
||||
PlatformNotificationServiceImpl();
|
||||
~PlatformNotificationServiceImpl() override;
|
||||
|
||||
// content::PlatformNotificationService:
|
||||
virtual blink::WebNotificationPermission CheckPermission(
|
||||
content::ResourceContext* resource_context,
|
||||
const GURL& origin,
|
||||
int render_process_id) override;
|
||||
virtual void DisplayNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
const GURL& origin,
|
||||
const SkBitmap& icon,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
||||
int render_process_id,
|
||||
base::Closure* cancel_callback) override;
|
||||
virtual void DisplayPersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
int64 service_worker_registration_id,
|
||||
const GURL& origin,
|
||||
const SkBitmap& icon,
|
||||
const content::PlatformNotificationData& notification_data,
|
||||
int render_process_id) override;
|
||||
virtual void ClosePersistentNotification(
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& persistent_notification_id) override;
|
||||
|
||||
scoped_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (c) 2015 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-CHROMIUM file.
|
||||
|
||||
#include "browser/remote_debugging_server.h"
|
||||
|
||||
#include "browser/devtools_manager_delegate.h"
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "content/public/browser/devtools_http_handler.h"
|
||||
#include "net/socket/tcp_server_socket.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
namespace {
|
||||
|
||||
class TCPServerSocketFactory
|
||||
: public content::DevToolsHttpHandler::ServerSocketFactory {
|
||||
public:
|
||||
TCPServerSocketFactory(const std::string& address, uint16 port, int backlog)
|
||||
: content::DevToolsHttpHandler::ServerSocketFactory(address, port, backlog) {}
|
||||
|
||||
private:
|
||||
// content::DevToolsHttpHandler::ServerSocketFactory:
|
||||
scoped_ptr<net::ServerSocket> Create() const override {
|
||||
return scoped_ptr<net::ServerSocket>(new net::TCPServerSocket(NULL, net::NetLog::Source()));
|
||||
}
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
RemoteDebuggingServer::RemoteDebuggingServer(const std::string& ip, uint16 port) {
|
||||
scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> factory(
|
||||
new TCPServerSocketFactory(ip, port, 1));
|
||||
devtools_http_handler_ = DevToolsManagerDelegate::CreateHttpHandler();
|
||||
}
|
||||
|
||||
RemoteDebuggingServer::~RemoteDebuggingServer() {
|
||||
devtools_http_handler_->Stop();
|
||||
}
|
||||
|
||||
} // namespace brightray
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2015 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-CHROMIUM file.
|
||||
|
||||
#ifndef BROWSER_REMOTE_DEBUGGING_SERVER_H_
|
||||
#define BROWSER_REMOTE_DEBUGGING_SERVER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
|
||||
namespace content {
|
||||
class DevToolsHttpHandler;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class RemoteDebuggingServer {
|
||||
public:
|
||||
RemoteDebuggingServer(const std::string& ip, uint16 port);
|
||||
virtual ~RemoteDebuggingServer();
|
||||
|
||||
private:
|
||||
content::DevToolsHttpHandler* devtools_http_handler_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RemoteDebuggingServer);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BROWSER_REMOTE_DEBUGGING_SERVER_H_
|
|
@ -142,7 +142,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() {
|
|||
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
auto& command_line = *base::CommandLine::ForCurrentProcess();
|
||||
if (!url_request_context_.get()) {
|
||||
url_request_context_.reset(new net::URLRequestContext);
|
||||
network_delegate_.reset(delegate_->CreateNetworkDelegate());
|
||||
|
|
|
@ -54,6 +54,10 @@ HICON ViewsDelegate::GetDefaultWindowIcon() const {
|
|||
return LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(1 /* IDR_MAINFRAME */));
|
||||
}
|
||||
|
||||
HICON ViewsDelegate::GetSmallWindowIcon() const {
|
||||
return GetDefaultWindowIcon();
|
||||
}
|
||||
|
||||
bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class ViewsDelegate : public views::ViewsDelegate {
|
|||
|
||||
#if defined(OS_WIN)
|
||||
virtual HICON GetDefaultWindowIcon() const override;
|
||||
virtual HICON GetSmallWindowIcon() const override;
|
||||
virtual bool IsWindowInMetro(gfx::NativeWindow window) const override;
|
||||
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
||||
virtual gfx::ImageSkia* GetDefaultWindowIcon() const override;
|
||||
|
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 3f108160eded696b3e843c2fbb4e5e2ac696555e
|
||||
Subproject commit 78ddaee2158886da53d0801db572be38230fd814
|
Loading…
Reference in a new issue