Merge pull request #58 from brightray/chrome35

Update to Chrome 35
This commit is contained in:
Adam Roben 2014-07-07 14:43:14 -04:00
commit 6c825042b5
24 changed files with 236 additions and 178 deletions

View file

@ -2,6 +2,8 @@
/brightray.sdf
/brightray.sln
/brightray.vcxproj*
/brightray.suo
/brightray.v12.suo
/brightray.xcodeproj/
/build/

View file

@ -12,17 +12,21 @@
'include_dirs': [
'.',
'<(libchromiumcontent_include_dir)',
'<(libchromiumcontent_include_dir)/third_party/skia/include/config',
'<(libchromiumcontent_include_dir)/skia/config',
'<(libchromiumcontent_include_dir)/third_party/skia/include/core',
'<(libchromiumcontent_include_dir)/third_party/WebKit',
'<(libchromiumcontent_library_dir)/gen',
],
'direct_dependent_settings': {
'include_dirs': [
'.',
'..',
'<(libchromiumcontent_include_dir)',
'<(libchromiumcontent_include_dir)/third_party/skia/include/config',
# For SkMatrix.h.
'<(libchromiumcontent_include_dir)/skia/config',
'<(libchromiumcontent_include_dir)/third_party/skia/include/core',
'<(libchromiumcontent_include_dir)/third_party/icu/source/common',
'<(libchromiumcontent_include_dir)/third_party/WebKit',
'<(libchromiumcontent_library_dir)/gen',
],
},
'sources': [
@ -113,6 +117,7 @@
'link_settings': {
'libraries': [
'<(brightray_source_root)/<(libchromiumcontent_library_dir)/base_static.lib',
'<(brightray_source_root)/<(libchromiumcontent_library_dir)/chromiumviews.lib',
'<(brightray_source_root)/<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib',
'<(brightray_source_root)/<(libchromiumcontent_library_dir)/sandbox_static.lib',
],

View file

@ -72,11 +72,21 @@
'VCLinkerTool': {
'AdditionalDependencies': [
'advapi32.lib',
'dwmapi.lib',
'gdi32.lib',
'oleacc.lib',
'user32.lib',
],
},
},
'conditions': [
['OS=="win"', {
'defines': [
'USE_AURA',
'VIEWS_IMPLEMENTATION',
'WEBVIEW_IMPLEMENTATION',
],
}],
['OS not in ["mac", "win"]', {
'defines': [
'USE_X11',

View file

@ -56,9 +56,10 @@ content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers) {
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) {
auto context = static_cast<BrowserContext*>(browser_context);
return context->CreateRequestContext(protocol_handlers);
return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass());
}
void BrowserClient::ShowDesktopNotification(

View file

@ -34,7 +34,9 @@ class BrowserClient : public content::ContentBrowserClient {
// Subclasses that override this (e.g., to provide their own protocol
// handlers) should call this implementation after doing their own work.
virtual net::URLRequestContextGetter* CreateRequestContext(
content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
content::BrowserContext* browser_context,
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE;
private:
virtual content::BrowserMainParts* CreateBrowserMainParts(

View file

@ -16,7 +16,7 @@
#include "base/prefs/json_pref_store.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_builder.h"
#include "base/prefs/pref_service_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition.h"
@ -76,8 +76,8 @@ void BrowserContext::Initialize() {
path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences"));
PrefServiceBuilder builder;
builder.WithUserFilePrefs(prefs_path,
base::PrefServiceFactory prefs_factory;
prefs_factory.SetUserPrefsFile(prefs_path,
JsonPrefStore::GetTaskRunnerForFile(
prefs_path, content::BrowserThread::GetBlockingPool()));
@ -85,7 +85,7 @@ void BrowserContext::Initialize() {
RegisterInternalPrefs(registry);
RegisterPrefs(registry);
prefs_.reset(builder.Create(registry));
prefs_ = prefs_factory.Create(registry);
}
BrowserContext::~BrowserContext() {
@ -99,7 +99,8 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) {
}
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers) {
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors) {
DCHECK(!url_request_getter_);
auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread(
content::BrowserThread::IO);
@ -110,7 +111,8 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
io_loop,
file_loop,
base::Bind(&BrowserContext::CreateNetworkDelegate, base::Unretained(this)),
protocol_handlers);
protocol_handlers,
protocol_interceptors.Pass());
resource_context_->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get();
}
@ -153,14 +155,36 @@ net::URLRequestContextGetter*
return GetRequestContext();
}
void BrowserContext::RequestMIDISysExPermission(
void BrowserContext::RequestMidiSysExPermission(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame,
const MIDISysExPermissionCallback& callback) {
bool user_gesture,
const MidiSysExPermissionCallback& callback) {
callback.Run(false);
}
void BrowserContext::CancelMidiSysExPermissionRequest(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame) {
}
void BrowserContext::RequestProtectedMediaIdentifierPermission(
int render_process_id,
int render_view_id,
int bridge_id,
int group_id,
const GURL& requesting_frame,
const ProtectedMediaIdentifierPermissionCallback& callback) {
callback.Run(false);
}
void BrowserContext::CancelProtectedMediaIdentifierPermissionRequests(int group_id) {
}
content::ResourceContext* BrowserContext::GetResourceContext() {
return resource_context_.get();
}

View file

@ -25,7 +25,8 @@ class BrowserContext : public content::BrowserContext {
virtual void Initialize();
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap*);
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors);
PrefService* prefs() { return prefs_.get(); }
@ -54,11 +55,26 @@ class BrowserContext : public content::BrowserContext {
virtual net::URLRequestContextGetter*
GetMediaRequestContextForStoragePartition(
const base::FilePath& partition_path, bool in_memory);
virtual void RequestMIDISysExPermission(
virtual void RequestMidiSysExPermission(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame,
const MIDISysExPermissionCallback&) OVERRIDE;
bool user_gesture,
const MidiSysExPermissionCallback& callback) OVERRIDE;
virtual void CancelMidiSysExPermissionRequest(
int render_process_id,
int render_view_id,
int bridge_id,
const GURL& requesting_frame) OVERRIDE;
virtual void RequestProtectedMediaIdentifierPermission(
int render_process_id,
int render_view_id,
int bridge_id,
int group_id,
const GURL& requesting_frame,
const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE;
virtual void CancelProtectedMediaIdentifierPermissionRequests(int group_id) OVERRIDE;
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::DownloadManagerDelegate*
GetDownloadManagerDelegate() OVERRIDE;

View file

@ -7,6 +7,8 @@
#include "browser/browser_context.h"
#include "browser/web_ui_controller_factory.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
namespace brightray {
@ -24,6 +26,10 @@ void BrowserMainParts::PreMainMessageLoopRun() {
new WebUIControllerFactory(browser_context_.get()));
content::WebUIControllerFactory::RegisterFactory(
web_ui_controller_factory_.get());
#if defined(OS_WIN)
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen());
#endif
}
void BrowserMainParts::PostMainMessageLoopRun() {

View file

@ -117,7 +117,7 @@ void InspectableWebContentsImpl::UpdateFrontendDockSide() {
auto javascript = base::StringPrintf(
"InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
string16(), ASCIIToUTF16(javascript));
base::string16(), base::ASCIIToUTF16(javascript));
}
void InspectableWebContentsImpl::ActivateWindow() {

View file

@ -6,8 +6,7 @@
#include "base/logging.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_devices_monitor.h"
#include "content/public/common/desktop_media_id.h"
#include "content/public/browser/media_capture_devices.h"
#include "content/public/common/media_stream_request.h"
namespace brightray {
@ -30,6 +29,11 @@ const content::MediaStreamDevice* FindDeviceWithId(
return NULL;
}
const MediaStreamDevices& EmptyDevices() {
static MediaStreamDevices* devices = new MediaStreamDevices;
return *devices;
}
} // namespace
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
@ -37,8 +41,7 @@ MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
}
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher()
: devices_enumerated_(false),
is_device_enumeration_disabled_(false) {
: is_device_enumeration_disabled_(false) {
// MediaCaptureDevicesDispatcher is a singleton. It should be created on
// UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@ -49,21 +52,17 @@ MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
const MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
content::EnsureMonitorCaptureDevices();
devices_enumerated_ = true;
}
return audio_devices_;
if (is_device_enumeration_disabled_)
return EmptyDevices();
return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices();
}
const MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
content::EnsureMonitorCaptureDevices();
devices_enumerated_ = true;
}
return video_devices_;
if (is_device_enumeration_disabled_)
return EmptyDevices();
return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices();
}
void MediaCaptureDevicesDispatcher::GetDefaultDevices(
@ -128,36 +127,33 @@ void MediaCaptureDevicesDispatcher::DisableDeviceEnumerationForTesting() {
is_device_enumeration_disabled_ = true;
}
void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged(
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread,
base::Unretained(this), devices));
void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() {
}
void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged(
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread,
base::Unretained(this), devices));
void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() {
}
void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int render_process_id,
int render_view_id,
int page_request_id,
const GURL& security_origin,
const content::MediaStreamDevice& device,
content::MediaRequestState state) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
int render_process_id, int render_view_id, int stream_id,
bool is_playing, float power_dbfs, bool clipped) {
void MediaCaptureDevicesDispatcher::OnAudioStreamPlaying(
int render_process_id,
int render_frame_id,
int stream_id,
const ReadPowerAndClipCallback& power_read_callback) {
}
void MediaCaptureDevicesDispatcher::OnAudioStreamStopped(
int render_process_id,
int render_frame_id,
int stream_id) {
}
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(
@ -166,18 +162,4 @@ void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
devices_enumerated_ = true;
audio_devices_ = devices;
}
void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread(
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
devices_enumerated_ = true;
video_devices_ = devices;
}
} // namespace brightray

View file

@ -51,23 +51,24 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
void DisableDeviceEnumerationForTesting();
// Overridden from content::MediaObserver:
virtual void OnAudioCaptureDevicesChanged(
const content::MediaStreamDevices& devices) OVERRIDE;
virtual void OnVideoCaptureDevicesChanged(
const content::MediaStreamDevices& devices) OVERRIDE;
virtual void OnAudioCaptureDevicesChanged() OVERRIDE;
virtual void OnVideoCaptureDevicesChanged() OVERRIDE;
virtual void OnMediaRequestStateChanged(
int render_process_id,
int render_view_id,
int page_request_id,
const GURL& security_origin,
const content::MediaStreamDevice& device,
content::MediaRequestState state) OVERRIDE;
virtual void OnAudioStreamPlayingChanged(
virtual void OnAudioStreamPlaying(
int render_process_id,
int render_view_id,
int render_frame_id,
int stream_id,
bool is_playing,
float power_dBFS,
bool clipped) OVERRIDE;
const ReadPowerAndClipCallback& power_read_callback) OVERRIDE;
virtual void OnAudioStreamStopped(
int render_process_id,
int render_frame_id,
int stream_id) OVERRIDE;
virtual void OnCreatingAudioStream(int render_process_id,
int render_view_id) OVERRIDE;
@ -77,20 +78,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
MediaCaptureDevicesDispatcher();
virtual ~MediaCaptureDevicesDispatcher();
// Called by the MediaObserver() functions, executed on UI thread.
void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices);
// A list of cached audio capture devices.
content::MediaStreamDevices audio_devices_;
// A list of cached video capture devices.
content::MediaStreamDevices video_devices_;
// Flag to indicate if device enumeration has been done/doing.
// Only accessed on UI thread.
bool devices_enumerated_;
// Flag used by unittests to disable device enumeration.
bool is_device_enumeration_disabled_;

View file

@ -41,6 +41,7 @@ MediaStreamDevicesController::MediaStreamDevicesController(
MediaStreamDevicesController::~MediaStreamDevicesController() {
if (!callback_.is_null()) {
callback_.Run(content::MediaStreamDevices(),
content::MEDIA_DEVICE_INVALID_STATE,
scoped_ptr<content::MediaStreamUI>());
}
}
@ -150,13 +151,15 @@ void MediaStreamDevicesController::Accept() {
content::MediaResponseCallback cb = callback_;
callback_.Reset();
cb.Run(devices, scoped_ptr<content::MediaStreamUI>());
cb.Run(devices, content::MEDIA_DEVICE_OK, scoped_ptr<content::MediaStreamUI>());
}
void MediaStreamDevicesController::Deny() {
content::MediaResponseCallback cb = callback_;
callback_.Reset();
cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
cb.Run(content::MediaStreamDevices(),
content::MEDIA_DEVICE_PERMISSION_DENIED,
scoped_ptr<content::MediaStreamUI>());
}
} // namespace brightray

View file

@ -37,7 +37,8 @@ int NetworkDelegate::OnHeadersReceived(
net::URLRequest* request,
const net::CompletionCallback& callback,
const net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
GURL* allowed_unsafe_redirect_url) {
return net::OK;
}
@ -59,7 +60,7 @@ void NetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
}
void NetworkDelegate::OnPACScriptError(int line_number,
const string16& error) {
const base::string16& error) {
}
NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired(
@ -97,9 +98,4 @@ int NetworkDelegate::OnBeforeSocketStreamConnect(
return net::OK;
}
void NetworkDelegate::OnRequestWaitStateChange(
const net::URLRequest& request,
RequestWaitState waiting) {
}
} // namespace brightray

View file

@ -27,8 +27,8 @@ class NetworkDelegate : public net::NetworkDelegate {
net::URLRequest* request,
const net::CompletionCallback& callback,
const net::HttpResponseHeaders* original_response_headers,
scoped_refptr<net::HttpResponseHeaders>*
override_response_headers) OVERRIDE;
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;
@ -37,7 +37,7 @@ class NetworkDelegate : public net::NetworkDelegate {
virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
virtual void OnPACScriptError(int line_number,
const string16& error) OVERRIDE;
const base::string16& error) OVERRIDE;
virtual AuthRequiredResponse OnAuthRequired(
net::URLRequest* request,
const net::AuthChallengeInfo& auth_info,
@ -55,8 +55,6 @@ class NetworkDelegate : public net::NetworkDelegate {
virtual int OnBeforeSocketStreamConnect(
net::SocketStream* stream,
const net::CompletionCallback& callback) OVERRIDE;
virtual void OnRequestWaitStateChange(const net::URLRequest& request,
RequestWaitState state) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);

View file

@ -29,10 +29,12 @@
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/data_protocol_handler.h"
#include "net/url_request/file_protocol_handler.h"
#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_storage.h"
#include "net/url_request/url_request_job_factory_impl.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace brightray {
@ -41,11 +43,13 @@ URLRequestContextGetter::URLRequestContextGetter(
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
base::Callback<scoped_ptr<NetworkDelegate>(void)> network_delegate_factory,
content::ProtocolHandlerMap* protocol_handlers)
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors)
: base_path_(base_path),
io_loop_(io_loop),
file_loop_(file_loop),
network_delegate_factory_(network_delegate_factory) {
network_delegate_factory_(network_delegate_factory),
protocol_interceptors_(protocol_interceptors.Pass()) {
// Must first be created on the UI thread.
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@ -71,18 +75,18 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
url_request_context_->set_network_delegate(network_delegate_.get());
storage_.reset(
new net::URLRequestContextStorage(url_request_context_.get()));
storage_->set_cookie_store(content::CreatePersistentCookieStore(
auto cookie_config = content::CookieStoreConfig(
base_path_.Append(FILE_PATH_LITERAL("Cookies")),
false,
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
nullptr,
nullptr,
nullptr));
nullptr);
storage_->set_cookie_store(content::CreateCookieStore(cookie_config));
storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
new net::DefaultServerBoundCertStore(NULL),
base::WorkerPool::GetTaskRunner(true)));
storage_->set_http_user_agent_settings(
new net::StaticHttpUserAgentSettings(
"en-us,en", EmptyString()));
"en-us,en", base::EmptyString()));
scoped_ptr<net::HostResolver> host_resolver(
net::HostResolver::CreateDefaultResolver(NULL));
@ -151,17 +155,31 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
bool set_protocol = job_factory->SetProtocolHandler(
it->first, it->second.release());
DCHECK(set_protocol);
(void)set_protocol; // silence unused-variable warning in Release builds on Windows
}
protocol_handlers_.clear();
job_factory->SetProtocolHandler(
chrome::kDataScheme, new net::DataProtocolHandler);
content::kDataScheme, new net::DataProtocolHandler);
job_factory->SetProtocolHandler(
chrome::kFileScheme,
content::kFileScheme,
new net::FileProtocolHandler(
content::BrowserThread::GetBlockingPool()->
GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
storage_->set_job_factory(job_factory.release());
// Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory =
job_factory.PassAs<net::URLRequestJobFactory>();
for (content::ProtocolHandlerScopedVector::reverse_iterator i =
protocol_interceptors_.rbegin();
i != protocol_interceptors_.rend();
++i) {
top_job_factory.reset(new net::ProtocolInterceptJobFactory(
top_job_factory.Pass(), make_scoped_ptr(*i)));
}
protocol_interceptors_.weak_clear();
storage_->set_job_factory(top_job_factory.release());
}
return url_request_context_.get();

View file

@ -32,7 +32,8 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
base::MessageLoop* io_loop,
base::MessageLoop* file_loop,
base::Callback<scoped_ptr<NetworkDelegate>(void)>,
content::ProtocolHandlerMap*);
content::ProtocolHandlerMap* protocol_handlers,
content::ProtocolHandlerScopedVector protocol_interceptors);
virtual ~URLRequestContextGetter();
net::HostResolver* host_resolver();
@ -53,6 +54,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
scoped_ptr<net::URLRequestContextStorage> storage_;
scoped_ptr<net::URLRequestContext> url_request_context_;
content::ProtocolHandlerMap protocol_handlers_;
content::ProtocolHandlerScopedVector protocol_interceptors_;
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
};

View file

@ -4,52 +4,63 @@
#include "browser/win/inspectable_web_contents_view_win.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/base/win/hidden_window.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/widget_delegate.h"
namespace brightray {
namespace {
class WidgetDelegateView : public views::WidgetDelegateView {
public:
WidgetDelegateView() {
SetLayoutManager(new views::FillLayout);
}
virtual void DeleteDelegate() OVERRIDE { delete this; }
virtual views::View* GetContentsView() OVERRIDE { return this; }
virtual bool CanResize() const OVERRIDE { return true; }
virtual bool CanMaximize() const OVERRIDE { return true; }
virtual base::string16 GetWindowTitle() const OVERRIDE { return L"Developer Tools"; }
virtual gfx::Size GetPreferredSize() OVERRIDE { return gfx::Size(800, 600); }
virtual gfx::Size GetMinimumSize() OVERRIDE { return gfx::Size(100, 100); }
};
} // namespace
DevToolsWindow* DevToolsWindow::Create(
InspectableWebContentsViewWin* controller) {
return new DevToolsWindow(controller);
}
DevToolsWindow::DevToolsWindow(InspectableWebContentsViewWin* controller)
: controller_(controller) {
: controller_(controller),
widget_(new views::Widget) {
auto delegate_view = new WidgetDelegateView;
views::Widget::InitParams params;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.top_level = true;
params.native_widget = new views::DesktopNativeWidgetAura(widget_.get());
params.delegate = delegate_view;
widget_->Init(params);
delegate_view->AddChildView(controller->GetView());
delegate_view->Layout();
}
DevToolsWindow::~DevToolsWindow() {
}
LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {
auto devtools_web_contents =
controller_->inspectable_web_contents()->devtools_web_contents();
SetParent(devtools_web_contents->GetView()->GetNativeView(), hwnd());
SetWindowText(hwnd(), L"Developer Tools");
return 0;
void DevToolsWindow::Show() {
widget_->Show();
}
LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) {
auto devtools_web_contents =
controller_->inspectable_web_contents()->devtools_web_contents();
SetParent(
devtools_web_contents->GetView()->GetNativeView(), ui::GetHiddenWindow());
void DevToolsWindow::Close() {
widget_->Hide();
}
void DevToolsWindow::Destroy() {
delete this;
return 0;
}
LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
RECT rect;
GetClientRect(hwnd(), &rect);
auto devtools_web_contents =
controller_->inspectable_web_contents()->devtools_web_contents();
SetWindowPos(devtools_web_contents->GetView()->GetNativeView(),
nullptr,
rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOZORDER | SWP_SHOWWINDOW);
return 0;
}
} // namespace brightray

View file

@ -1,35 +1,33 @@
#ifndef BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
#define BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "ui/gfx/win/window_impl.h"
namespace views {
class Widget;
}
namespace brightray {
class InspectableWebContentsViewWin;
class DevToolsWindow : public gfx::WindowImpl,
public base::SupportsWeakPtr<DevToolsWindow> {
class DevToolsWindow : public base::SupportsWeakPtr<DevToolsWindow> {
public:
static DevToolsWindow* Create(
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
BEGIN_MSG_MAP_EX(DevToolsWindow)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_SIZE, OnSize)
END_MSG_MAP()
void Show();
void Close();
void Destroy();
private:
explicit DevToolsWindow(
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
~DevToolsWindow();
LRESULT OnCreate(UINT message, WPARAM, LPARAM, BOOL& handled);
LRESULT OnDestroy(UINT message, WPARAM, LPARAM, BOOL& handled);
LRESULT OnSize(UINT message, WPARAM, LPARAM, BOOL& handled);
InspectableWebContentsViewWin* controller_;
scoped_ptr<views::Widget> widget_;
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
};

View file

@ -143,7 +143,7 @@ InspectableWebContentsViewWin::InspectableWebContentsViewWin(
InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
if (devtools_window_)
DestroyWindow(devtools_window_->hwnd());
devtools_window_->Destroy();
}
views::View* InspectableWebContentsViewWin::GetView() const {
@ -161,19 +161,10 @@ gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
void InspectableWebContentsViewWin::ShowDevTools() {
if (undocked_) {
if (!devtools_window_) {
if (!devtools_window_)
devtools_window_ = DevToolsWindow::Create(this)->AsWeakPtr();
devtools_window_->Init(HWND_DESKTOP, gfx::Rect());
}
auto contents_view = inspectable_web_contents_->GetWebContents()->GetView();
auto size = contents_view->GetContainerSize();
size.Enlarge(-kWindowInset, -kWindowInset);
gfx::CenterAndSizeWindow(contents_view->GetNativeView(),
devtools_window_->hwnd(),
size);
ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL);
devtools_window_->Show();
} else {
container_->ShowDevTools();
}
@ -181,7 +172,7 @@ void InspectableWebContentsViewWin::ShowDevTools() {
void InspectableWebContentsViewWin::CloseDevTools() {
if (undocked_)
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
devtools_window_->Close();
else
container_->CloseDevTools();
}
@ -197,7 +188,7 @@ bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
} else if (side == "right" || side == "bottom") {
undocked_ = false;
if (devtools_window_)
SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0);
devtools_window_->Close();
container_->SetDockSide(side);
} else {
return false;

View file

@ -10,14 +10,14 @@ std::string GetApplicationName() {
auto module = GetModuleHandle(nullptr);
auto info = make_scoped_ptr(
FileVersionInfo::CreateFileVersionInfoForModule(module));
return UTF16ToUTF8(info->product_name());
return base::UTF16ToUTF8(info->product_name());
}
std::string GetApplicationVersion() {
auto module = GetModuleHandle(nullptr);
auto info = make_scoped_ptr(
FileVersionInfo::CreateFileVersionInfoForModule(module));
return UTF16ToUTF8(info->product_version());
return base::UTF16ToUTF8(info->product_version());
}
} // namespace brightray

View file

@ -8,8 +8,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/string_util.h"
#include "content/public/common/user_agent.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/common/user_agent/user_agent_util.h"
namespace brightray {
@ -21,13 +21,13 @@ ContentClient::~ContentClient() {
std::string ContentClient::GetProduct() const {
auto name = GetApplicationName();
RemoveChars(name, kWhitespaceASCII, &name);
base::RemoveChars(name, base::kWhitespaceASCII, &name);
return base::StringPrintf("%s/%s",
name.c_str(), GetApplicationVersion().c_str());
}
std::string ContentClient::GetUserAgent() const {
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
return content::BuildUserAgentFromProduct(GetProduct());
}
base::StringPiece ContentClient::GetDataResource(

View file

@ -27,14 +27,14 @@ scoped_ptr<ContentClient> MainDelegate::CreateContentClient() {
bool MainDelegate::BasicStartupComplete(int* exit_code) {
content_client_ = CreateContentClient().Pass();
SetContentClient(content_client_.get());
return false;
}
void MainDelegate::PreSandboxStartup() {
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
#endif
return false;
}
void MainDelegate::PreSandboxStartup() {
InitializeResourceBundle();
}

View file

@ -15,7 +15,12 @@ def main():
def run_gyp():
return subprocess.call([sys.executable, GYP, '--depth', '.', 'brightray.gyp'])
env = os.environ.copy()
gyp_pylib = os.path.join(os.path.dirname(GYP), 'pylib')
env['PYTHONPATH'] = os.path.pathsep.join([gyp_pylib,
env.get('PYTHONPATH', '')])
return subprocess.call([sys.executable, GYP, '--depth', '.',
'brightray.gyp'], env=env)
def build():
@ -25,7 +30,8 @@ def build():
return subprocess.call(['make'])
assert sys.platform == 'win32', sys.platform
msbuild = os.path.join(os.environ['windir'], 'Microsoft.NET', 'Framework', 'v4.0.30319', 'MSBuild.exe')
program_files = os.environ.get('PROGRAMFILES(X86)', os.environ['PROGRAMFILES'])
msbuild = os.path.join(program_files, 'MSBuild', '12.0', 'Bin', 'MSBuild.exe')
return subprocess.call([msbuild, 'brightray.sln'])

@ -1 +1 @@
Subproject commit 656be9408484de40ba4938ef47acdebeec8a1784
Subproject commit 331dbed44676c534faf21f7db1985e796260649a