diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index c6a27cc1e..8f857acd7 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -7,6 +7,12 @@ development team. The current CEF revision may be newer than the last CEF revision listed in this document. In that case, it means that the current CEF revision is compatible with the last listed Chromium revision. +To update Chromium to a specific revision run the following command, where #### +is the Chromium revision number that you wish to download. + +gclient sync --revision src@#### --force + + Date | CEF Revision | Chromium Revision ------------------------------------------------------------------------------- @@ -22,3 +28,4 @@ Date | CEF Revision | Chromium Revision 2009-02-12 | /trunk@15 | /trunk@9652 2009-03-05 | /trunk@17 | /trunk@10987 2009-03-09 | /trunk@21 | /trunk@11252 +2009-03-24 | /trunk@22 | /trunk@11768 diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 624d3bece..43e919ca0 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -10,13 +10,15 @@ #include "base/string_util.h" #include "webkit/glue/webframe.h" +#include "webkit/glue/webscriptsource.h" CefBrowserImpl::CefBrowserImpl(CefWindowInfo& windowInfo, bool popup, CefRefPtr handler, const std::wstring& url) : window_info_(windowInfo), is_popup_(popup), is_modal_(false), - handler_(handler), webviewhost_(NULL), popuphost_(NULL), url_(url) + handler_(handler), webviewhost_(NULL), popuphost_(NULL), url_(url), + unique_id_(0) { delegate_ = new BrowserWebViewDelegate(this); nav_controller_.reset(new BrowserNavigationController(this)); @@ -451,7 +453,9 @@ void CefBrowserImpl::UIT_ExecuteJavaScript(const std::wstring& js_code, else frame = UIT_GetWebView()->GetMainFrame(); - frame->ExecuteJavaScript(WideToUTF8(js_code), GURL(script_url), start_line); + frame->ExecuteScript( + webkit_glue::WebScriptSource(WideToUTF8(js_code), GURL(script_url), + start_line)); } void CefBrowserImpl::UIT_GoBackOrForward(int offset) diff --git a/libcef/browser_impl.h b/libcef/browser_impl.h index 915e47f49..e29811303 100644 --- a/libcef/browser_impl.h +++ b/libcef/browser_impl.h @@ -192,6 +192,9 @@ public: int UIT_SwitchFrameToPrintMediaType(WebFrame* frame); int UIT_GetPagesCount(WebFrame* frame); + void UIT_SetUniqueID(int id) { unique_id_ = id; } + int UIT_GetUniqueID() { return unique_id_; } + #if defined(OS_WIN) void UIT_DisableWebView(bool val); bool UIT_IsWebViewDisabled() { return (webview_bitmap_ != NULL); } @@ -228,6 +231,9 @@ protected: typedef std::map > JSContainerMap; JSContainerMap jscontainers_; + // Unique browser ID assigned by the context. + int unique_id_; + #if defined(OS_WIN) HBITMAP webview_bitmap_; SIZE webview_bitmap_size_; diff --git a/libcef/browser_resource_loader_bridge.cc b/libcef/browser_resource_loader_bridge.cc index 2baf0cfcc..7f3d4853c 100644 --- a/libcef/browser_resource_loader_bridge.cc +++ b/libcef/browser_resource_loader_bridge.cc @@ -40,10 +40,12 @@ #include "base/message_loop.h" #include "base/ref_counted.h" #include "base/string_util.h" +#include "base/time.h" #include "base/thread.h" #include "base/waitable_event.h" #include "net/base/cookie_monster.h" #include "net/base/io_buffer.h" +#include "net/base/load_flags.h" #include "net/base/net_util.h" #include "net/base/upload_data.h" #include "net/http/http_response_headers.h" @@ -107,6 +109,9 @@ struct RequestParams { scoped_refptr upload; }; +// The interval for calls to RequestProxy::MaybeUpdateUploadProgress +static const int kUpdateUploadProgressIntervalMsec = 100; + // The RequestProxy does most of its work on the IO thread. The Start and // Cancel methods are proxied over to the IO thread, where an URLRequest object // is instantiated. @@ -115,7 +120,9 @@ class RequestProxy : public URLRequest::Delegate, public: // Takes ownership of the params. RequestProxy(CefRefPtr browser) - : browser_(browser), buf_(new net::IOBuffer(kDataSize)) + : browser_(browser), + buf_(new net::IOBuffer(kDataSize)), + last_upload_position_(0) { } @@ -150,6 +157,11 @@ class RequestProxy : public URLRequest::Delegate, // various URLRequest callbacks. The event hooks, defined below, trigger // these methods asynchronously. + void NotifyUploadProgress(uint64 position, uint64 size) { + if (peer_) + peer_->OnUploadProgress(position, size); + } + void NotifyReceivedRedirect(const GURL& new_url) { if (peer_) peer_->OnReceivedRedirect(new_url); @@ -197,7 +209,7 @@ class RequestProxy : public URLRequest::Delegate, void AsyncStart(RequestParams* params) { bool handled = false; - if (browser_) { + if (browser_.get()) { CefRefPtr handler = browser_->GetHandler(); if(handler.get()) { @@ -259,18 +271,25 @@ class RequestProxy : public URLRequest::Delegate, AsyncReadData(); } } + } - if(!handled) - { - request_.reset(new URLRequest(params->url, this)); - request_->set_method(params->method); - request_->set_policy_url(params->policy_url); - request_->set_referrer(params->referrer.spec()); - request_->SetExtraRequestHeaders(params->headers); - request_->set_load_flags(params->load_flags); - request_->set_upload(params->upload.get()); - request_->set_context(request_context); - request_->Start(); + if(!handled) + { + request_.reset(new URLRequest(params->url, this)); + request_->set_method(params->method); + request_->set_policy_url(params->policy_url); + request_->set_referrer(params->referrer.spec()); + request_->SetExtraRequestHeaders(params->headers); + request_->set_load_flags(params->load_flags); + request_->set_upload(params->upload.get()); + request_->set_context(request_context); + request_->Start(); + + if (request_->has_upload() && + params->load_flags & net::LOAD_ENABLE_UPLOAD_PROGRESS) { + upload_progress_timer_.Start( + base::TimeDelta::FromMilliseconds(kUpdateUploadProgressIntervalMsec), + this, &RequestProxy::MaybeUpdateUploadProgress); } } @@ -384,12 +403,44 @@ class RequestProxy : public URLRequest::Delegate, std::string()); resource_stream_ = NULL; } else { + if (upload_progress_timer_.IsRunning()) { + MaybeUpdateUploadProgress(); + upload_progress_timer_.Stop(); + } + DCHECK(request_.get()); OnCompletedRequest(request_->status(), std::string()); request_.reset(); // destroy on the io thread } } + // Called on the IO thread. + void MaybeUpdateUploadProgress() { + uint64 size = request_->get_upload()->GetContentLength(); + uint64 position = request_->GetUploadProgress(); + if (position == last_upload_position_) + return; // no progress made since last time + + const uint64 kHalfPercentIncrements = 200; + const base::TimeDelta kOneSecond = base::TimeDelta::FromMilliseconds(1000); + + uint64 amt_since_last = position - last_upload_position_; + base::TimeDelta time_since_last = base::TimeTicks::Now() - + last_upload_ticks_; + + bool is_finished = (size == position); + bool enough_new_progress = (amt_since_last > (size / + kHalfPercentIncrements)); + bool too_much_time_passed = time_since_last > kOneSecond; + + if (is_finished || enough_new_progress || too_much_time_passed) { + owner_loop_->PostTask(FROM_HERE, NewRunnableMethod( + this, &RequestProxy::NotifyUploadProgress, position, size)); + last_upload_ticks_ = base::TimeTicks::Now(); + last_upload_position_ = position; + } + } + scoped_ptr request_; CefRefPtr resource_stream_; @@ -407,6 +458,13 @@ class RequestProxy : public URLRequest::Delegate, // not manage its lifetime, and we may only access it from the owner's // message loop (owner_loop_). ResourceLoaderBridge::Peer* peer_; + + // Timer used to pull upload progress info. + base::RepeatingTimer upload_progress_timer_; + + // Info used to determine whether or not to send an upload progress update. + uint64 last_upload_position_; + base::TimeTicks last_upload_ticks_; }; //----------------------------------------------------------------------------- @@ -590,21 +648,19 @@ namespace webkit_glue { // factory function ResourceLoaderBridge* ResourceLoaderBridge::Create( - WebFrame* webframe, const std::string& method, const GURL& url, const GURL& policy_url, const GURL& referrer, const std::string& headers, int load_flags, - int origin_pid, + int requestor_pid, ResourceType::Type request_type, - bool mixed_contents) { - return new ResourceLoaderBridgeImpl( - (webframe->GetView()->GetDelegate() ? - static_cast( - webframe->GetView()->GetDelegate())->GetBrowser() : NULL), - method, url, policy_url, referrer, headers, load_flags); + bool mixed_contents, + int routing_id) { + CefRefPtr browser = _Context->GetBrowserByID(routing_id); + return new ResourceLoaderBridgeImpl(browser, method, url, policy_url, + referrer, headers, load_flags); } // Issue the proxy resolve request on the io thread, and wait diff --git a/libcef/browser_webkit_glue.cc b/libcef/browser_webkit_glue.cc index db18d10a3..42b6af506 100644 --- a/libcef/browser_webkit_glue.cc +++ b/libcef/browser_webkit_glue.cc @@ -7,6 +7,7 @@ #include "browser_webkit_glue.h" #include "base/compiler_specific.h" +#include "base/logging.h" #include "config.h" #include "webkit_version.h" diff --git a/libcef/browser_webkit_init.h b/libcef/browser_webkit_init.h index dc1e8b782..e72560bce 100644 --- a/libcef/browser_webkit_init.h +++ b/libcef/browser_webkit_init.h @@ -22,10 +22,14 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { public: BrowserWebKitInit() { + v8::V8::SetCounterFunction(StatsTable::FindLocation); + WebKit::initialize(this); WebKit::setLayoutTestMode(false); WebKit::registerURLSchemeAsLocal( ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); + WebKit::registerURLSchemeAsNoAccess( + ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); WebKit::registerExtension(extensions_v8::GearsExtension::Get()); WebKit::registerExtension(extensions_v8::IntervalExtension::Get()); } @@ -38,6 +42,10 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { return &mime_registry_; } + virtual WebKit::WebSandboxSupport* sandboxSupport() { + return NULL; + } + virtual uint64_t visitedLinkHash(const char* canonicalURL, size_t length) { return 0; } @@ -84,11 +92,6 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl { return ASCIIToUTF16("en-US"); } - virtual void decrementStatsCounter(const char* name) {} - virtual void incrementStatsCounter(const char* name) {} - virtual void traceEventBegin(const char* name, void* id, const char* extra) {} - virtual void traceEventEnd(const char* name, void* id, const char* extra) {} - private: webkit_glue::SimpleWebMimeRegistryImpl mime_registry_; }; diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 4fd463880..ef24df7df 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -166,6 +166,9 @@ void BrowserWebViewDelegate::AssignIdentifierToRequest(WebView* webview, void BrowserWebViewDelegate::WillSendRequest(WebView* webview, uint32 identifier, WebRequest* request) { + // The requestor ID is used by the resource loader bridge to locate the + // browser that originated the request. + request->SetRequestorID(browser_->UIT_GetUniqueID()); } void BrowserWebViewDelegate::DidFinishLoading(WebView* webview, diff --git a/libcef/context.cc b/libcef/context.cc index 41f78a4d8..f02c9a54a 100644 --- a/libcef/context.cc +++ b/libcef/context.cc @@ -255,6 +255,7 @@ CefContext::CefContext() in_transition_ = false; webprefs_ = NULL; hinstance_ = ::GetModuleHandle(NULL); + next_browser_id_ = 1; } CefContext::~CefContext() @@ -462,7 +463,10 @@ bool CefContext::AddBrowser(CefRefPtr browser) } if(!found) + { + browser->UIT_SetUniqueID(next_browser_id_++); browserlist_.push_back(browser); + } Unlock(); return !found; @@ -483,11 +487,32 @@ bool CefContext::RemoveBrowser(CefRefPtr browser) } } + if (browserlist_.empty()) + next_browser_id_ = 1; + Unlock(); return deleted; } +CefRefPtr CefContext::GetBrowserByID(int id) +{ + CefRefPtr browser; + Lock(); + + BrowserList::const_iterator it = browserlist_.begin(); + for(; it != browserlist_.end(); ++it) { + if(it->get()->UIT_GetUniqueID() == id) { + browser = it->get(); + break; + } + } + + Unlock(); + + return browser; +} + void CefContext::SetMessageLoopForUI(MessageLoopForUI* loop) { Lock(); diff --git a/libcef/context.h b/libcef/context.h index a3628e83e..86ecc763e 100644 --- a/libcef/context.h +++ b/libcef/context.h @@ -40,6 +40,7 @@ public: bool AddBrowser(CefRefPtr browser); bool RemoveBrowser(CefRefPtr browser); + CefRefPtr GetBrowserByID(int id); BrowserList* GetBrowserList() { return &browserlist_; } // Returns true if the calling thread is the same as the UI thread @@ -79,6 +80,9 @@ protected: base::AtExitManager at_exit_manager_; // Initialize WebKit for this scope. BrowserWebKitInit webkit_init_; + + // Used for assigning unique IDs to browser instances. + int next_browser_id_; friend DWORD WINAPI ThreadHandlerUI(LPVOID lpParam); }; diff --git a/libcef/webview_host.h b/libcef/webview_host.h index 2ecd13e44..5ca8bb4e5 100644 --- a/libcef/webview_host.h +++ b/libcef/webview_host.h @@ -8,7 +8,6 @@ #include "base/basictypes.h" #include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" -#include "base/scoped_ptr.h" #include "webwidget_host.h" struct WebPreferences;