libcef: Update due to underlying chromium changes.

- Underlying chromium changes fix Issue #27.
- Navigation-related changes to work with WebDataSource.
- Cookie-related changes for ResourceLoaderBridge.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@28 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2009-06-02 23:27:47 +00:00
parent a0a0ae326c
commit ff7e8379fb
11 changed files with 116 additions and 77 deletions

View File

@ -31,3 +31,4 @@ Date | CEF Revision | Chromium Revision
2009-03-24 | /trunk@22 | /trunk@11768 2009-03-24 | /trunk@22 | /trunk@11768
2009-04-27 | /trunk@23 | /trunk@14651 2009-04-27 | /trunk@23 | /trunk@14651
2009-05-15 | /trunk@24 | /trunk@16080 2009-05-15 | /trunk@24 | /trunk@16080
2009-06-02 | /trunk@28 | /trunk@17397

View File

@ -489,50 +489,65 @@ bool CefBrowserImpl::UIT_Navigate(const BrowserNavigationEntry& entry,
{ {
REQUIRE_UIT(); REQUIRE_UIT();
WebRequestCachePolicy cache_policy;
if (reload) {
cache_policy = WebRequestReloadIgnoringCacheData;
} else if (entry.GetPageID() != -1) {
cache_policy = WebRequestReturnCacheDataElseLoad;
} else {
cache_policy = WebRequestUseProtocolCachePolicy;
}
scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL()));
request->SetCachePolicy(cache_policy);
// If we are reloading, then WebKit will use the state of the current page.
// Otherwise, we give it the state to navigate to.
if (!reload)
request->SetHistoryState(entry.GetContentState());
request->SetExtraData(
new BrowserExtraRequestData(entry.GetPageID()));
if(entry.GetMethod().size() > 0)
request->SetHttpMethod(WideToUTF8(entry.GetMethod()));
if(entry.GetHeaders().size() > 0)
request->SetHttpHeaders(entry.GetHeaders());
if(entry.GetUploadData())
{
if(request->GetHttpMethod() == "GET" || request->GetHttpMethod() == "HEAD")
request->SetHttpMethod("POST");
if(request->GetHttpHeaderValue("Content-Type").size() == 0) {
request->SetHttpHeaderValue(
"Content-Type", "application/x-www-form-urlencoded");
}
request->SetUploadData(*entry.GetUploadData());
}
// Get the right target frame for the entry. // Get the right target frame for the entry.
WebFrame* frame = GetWebView()->GetMainFrame(); WebFrame* frame;
if (!entry.GetTargetFrame().empty()) if (!entry.GetTargetFrame().empty())
frame = GetWebView()->GetFrameWithName(entry.GetTargetFrame()); frame = GetWebView()->GetFrameWithName(entry.GetTargetFrame());
else
frame = GetWebView()->GetMainFrame();
// TODO(mpcomplete): should we clear the target frame, or should // TODO(mpcomplete): should we clear the target frame, or should
// back/forward navigations maintain the target frame? // back/forward navigations maintain the target frame?
frame->LoadRequest(request.get()); // A navigation resulting from loading a javascript URL should not be
// treated as a browser initiated event. Instead, we want it to look as if
// the page initiated any load resulting from JS execution.
if (!entry.GetURL().SchemeIs("javascript")) {
delegate_->set_pending_extra_data(
new BrowserExtraData(entry.GetPageID()));
}
// If we are reloading, then WebKit will use the state of the current page.
// Otherwise, we give it the state to navigate to.
if (!reload && !entry.GetContentState().empty()) {
DCHECK(entry.GetPageID() != -1);
frame->LoadHistoryState(entry.GetContentState());
} else {
WebRequestCachePolicy cache_policy;
if (reload) {
cache_policy = WebRequestReloadIgnoringCacheData;
} else {
DCHECK(entry.GetPageID() == -1);
cache_policy = WebRequestUseProtocolCachePolicy;
}
scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL()));
request->SetCachePolicy(cache_policy);
if(entry.GetMethod().size() > 0)
request->SetHttpMethod(WideToUTF8(entry.GetMethod()));
if(entry.GetHeaders().size() > 0)
request->SetHttpHeaders(entry.GetHeaders());
if(entry.GetUploadData())
{
if(request->GetHttpMethod() == "GET"
|| request->GetHttpMethod() == "HEAD") {
request->SetHttpMethod("POST");
}
if(request->GetHttpHeaderValue("Content-Type").size() == 0) {
request->SetHttpHeaderValue(
"Content-Type", "application/x-www-form-urlencoded");
}
request->SetUploadData(*entry.GetUploadData());
}
frame->LoadRequest(request.get());
}
// In case LoadRequest failed before DidCreateDataSource was called.
delegate_->set_pending_extra_data(NULL);
// Restore focus to the main frame prior to loading new request. // Restore focus to the main frame prior to loading new request.
// This makes sure that we don't have a focused iframe. Otherwise, that // This makes sure that we don't have a focused iframe. Otherwise, that
// iframe would keep focus when the SetFocus called immediately after // iframe would keep focus when the SetFocus called immediately after

View File

@ -13,6 +13,7 @@
#include "base/linked_ptr.h" #include "base/linked_ptr.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "webkit/glue/webdatasource.h"
#include "webkit/glue/weburlrequest.h" #include "webkit/glue/weburlrequest.h"
namespace net { namespace net {
@ -23,11 +24,10 @@ class GURL;
class CefBrowserImpl; class CefBrowserImpl;
// Associated with browser-initated navigations to hold tracking data. // Associated with browser-initated navigations to hold tracking data.
class BrowserExtraRequestData : public WebRequest::ExtraData { class BrowserExtraData : public WebDataSource::ExtraData {
public: public:
BrowserExtraRequestData(int32 pending_page_id) BrowserExtraData(int32 pending_page_id)
: WebRequest::ExtraData(), : pending_page_id(pending_page_id),
pending_page_id(pending_page_id),
request_committed(false) { request_committed(false) {
} }

View File

@ -32,7 +32,8 @@ void BrowserRequestContext::Init(
accept_charset_ = "iso-8859-1,*,utf-8"; accept_charset_ = "iso-8859-1,*,utf-8";
net::ProxyConfig proxy_config; net::ProxyConfig proxy_config;
proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL); proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL,
false, NULL, NULL);
net::HttpCache *cache; net::HttpCache *cache;
if (cache_path.empty()) { if (cache_path.empty()) {

View File

@ -46,6 +46,7 @@
#include "net/base/cookie_monster.h" #include "net/base/cookie_monster.h"
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/base/upload_data.h" #include "net/base/upload_data.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
@ -103,7 +104,7 @@ bool EnsureIOThread() {
struct RequestParams { struct RequestParams {
std::string method; std::string method;
GURL url; GURL url;
GURL policy_url; GURL first_party_for_cookies;
GURL referrer; GURL referrer;
std::string headers; std::string headers;
int load_flags; int load_flags;
@ -279,7 +280,7 @@ class RequestProxy : public URLRequest::Delegate,
{ {
request_.reset(new URLRequest(params->url, this)); request_.reset(new URLRequest(params->url, this));
request_->set_method(params->method); request_->set_method(params->method);
request_->set_policy_url(params->policy_url); request_->set_first_party_for_cookies(params->first_party_for_cookies);
request_->set_referrer(params->referrer.spec()); request_->set_referrer(params->referrer.spec());
request_->SetExtraRequestHeaders(params->headers); request_->SetExtraRequestHeaders(params->headers);
request_->set_load_flags(params->load_flags); request_->set_load_flags(params->load_flags);
@ -528,7 +529,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
ResourceLoaderBridgeImpl(CefRefPtr<CefBrowser> browser, ResourceLoaderBridgeImpl(CefRefPtr<CefBrowser> browser,
const std::string& method, const std::string& method,
const GURL& url, const GURL& url,
const GURL& policy_url, const GURL& first_party_for_cookies,
const GURL& referrer, const GURL& referrer,
const std::string& headers, const std::string& headers,
int load_flags, int load_flags,
@ -538,7 +539,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
proxy_(NULL) { proxy_(NULL) {
params_->method = method; params_->method = method;
params_->url = url; params_->url = url;
params_->policy_url = policy_url; params_->first_party_for_cookies = first_party_for_cookies;
params_->referrer = referrer; params_->referrer = referrer;
params_->headers = headers; params_->headers = headers;
params_->load_flags = load_flags; params_->load_flags = load_flags;
@ -670,7 +671,7 @@ namespace webkit_glue {
ResourceLoaderBridge* ResourceLoaderBridge::Create( ResourceLoaderBridge* ResourceLoaderBridge::Create(
const std::string& method, const std::string& method,
const GURL& url, const GURL& url,
const GURL& policy_url, const GURL& first_party_for_cookies,
const GURL& referrer, const GURL& referrer,
const std::string& frame_origin, const std::string& frame_origin,
const std::string& main_frame_origin, const std::string& main_frame_origin,
@ -681,7 +682,8 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create(
int app_cache_context_id, int app_cache_context_id,
int routing_id) { int routing_id) {
CefRefPtr<CefBrowser> browser = _Context->GetBrowserByID(routing_id); CefRefPtr<CefBrowser> browser = _Context->GetBrowserByID(routing_id);
return new ResourceLoaderBridgeImpl(browser, method, url, policy_url, return new ResourceLoaderBridgeImpl(browser, method, url,
first_party_for_cookies,
referrer, headers, load_flags, referrer, headers, load_flags,
app_cache_context_id); app_cache_context_id);
} }
@ -732,8 +734,9 @@ void BrowserResourceLoaderBridge::Shutdown() {
} }
} }
void BrowserResourceLoaderBridge::SetCookie( void BrowserResourceLoaderBridge::SetCookie(const GURL& url,
const GURL& url, const GURL& policy_url, const std::string& cookie) { const GURL& first_party_for_cookies,
const std::string& cookie) {
// Proxy to IO thread to synchronize w/ network loading. // Proxy to IO thread to synchronize w/ network loading.
if (!EnsureIOThread()) { if (!EnsureIOThread()) {
@ -747,7 +750,7 @@ void BrowserResourceLoaderBridge::SetCookie(
} }
std::string BrowserResourceLoaderBridge::GetCookies( std::string BrowserResourceLoaderBridge::GetCookies(
const GURL& url, const GURL& policy_url) { const GURL& url, const GURL& first_party_for_cookies) {
// Proxy to IO thread to synchronize w/ network loading // Proxy to IO thread to synchronize w/ network loading
if (!EnsureIOThread()) { if (!EnsureIOThread()) {

View File

@ -29,10 +29,11 @@ class BrowserResourceLoaderBridge {
static void Shutdown(); static void Shutdown();
// May only be called after Init. // May only be called after Init.
static void SetCookie( static void SetCookie(const GURL& url,
const GURL& url, const GURL& policy_url, const std::string& cookie); const GURL& first_party_for_cookies,
static std::string GetCookies( const std::string& cookie);
const GURL& url, const GURL& policy_url); static std::string GetCookies(const GURL& url,
const GURL& first_party_for_cookies);
}; };
#endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H #endif // _BROWSER_RESOURCE_LOADER_BRIDGE_H

View File

@ -64,15 +64,18 @@ class BrowserWebKitInit : public webkit_glue::WebKitClientImpl {
return false; return false;
} }
virtual void setCookies( virtual void setCookies(const WebKit::WebURL& url,
const WebKit::WebURL& url, const WebKit::WebURL& policy_url, const WebKit::WebURL& first_party_for_cookies,
const WebKit::WebString& value) { const WebKit::WebString& value) {
BrowserResourceLoaderBridge::SetCookie(url, policy_url, UTF16ToUTF8(value)); BrowserResourceLoaderBridge::SetCookie(
url, first_party_for_cookies, UTF16ToUTF8(value));
} }
virtual WebKit::WebString cookies( virtual WebKit::WebString cookies(
const WebKit::WebURL& url, const WebKit::WebURL& policy_url) { const WebKit::WebURL& url,
return UTF8ToUTF16(BrowserResourceLoaderBridge::GetCookies(url, policy_url)); const WebKit::WebURL& first_party_for_cookies) {
return UTF8ToUTF16(BrowserResourceLoaderBridge::GetCookies(
url, first_party_for_cookies));
} }
virtual void prefetchHostName(const WebKit::WebString&) { virtual void prefetchHostName(const WebKit::WebString&) {

View File

@ -217,6 +217,11 @@ void BrowserWebViewDelegate::DidFailLoadingWithError(WebView* webview,
} }
void BrowserWebViewDelegate::DidCreateDataSource(WebFrame* frame,
WebDataSource* ds) {
ds->SetExtraData(pending_extra_data_.release());
}
void BrowserWebViewDelegate::DidStartProvisionalLoadForFrame( void BrowserWebViewDelegate::DidStartProvisionalLoadForFrame(
WebView* webview, WebView* webview,
WebFrame* frame, WebFrame* frame,
@ -246,13 +251,12 @@ void BrowserWebViewDelegate::DidFailProvisionalLoadWithError(
if (error.GetErrorCode() == net::ERR_ABORTED) if (error.GetErrorCode() == net::ERR_ABORTED)
return; return;
const WebRequest& failed_request = const WebDataSource* failed_ds = frame->GetProvisionalDataSource();
frame->GetProvisionalDataSource()->GetRequest(); BrowserExtraData* extra_data =
BrowserExtraRequestData* extra_data = static_cast<BrowserExtraData*>(failed_ds->GetExtraData());
static_cast<BrowserExtraRequestData*>(failed_request.GetExtraData());
bool replace = extra_data && extra_data->pending_page_id != -1; bool replace = extra_data && extra_data->pending_page_id != -1;
scoped_ptr<WebRequest> request(failed_request.Clone()); scoped_ptr<WebRequest> request(failed_ds->GetRequest().Clone());
request->SetURL(GURL("cef-error:")); request->SetURL(GURL("cef-error:"));
std::string error_text; std::string error_text;
@ -326,6 +330,7 @@ void BrowserWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview,
void BrowserWebViewDelegate::DidChangeLocationWithinPageForFrame( void BrowserWebViewDelegate::DidChangeLocationWithinPageForFrame(
WebView* webview, WebFrame* frame, bool is_new_navigation) { WebView* webview, WebFrame* frame, bool is_new_navigation) {
frame->GetDataSource()->SetExtraData(pending_extra_data_.release());
UpdateForCommittedLoad(frame, is_new_navigation); UpdateForCommittedLoad(frame, is_new_navigation);
} }
@ -607,7 +612,7 @@ void BrowserWebViewDelegate::UpdateAddressBar(WebView* webView) {
if (!dataSource) if (!dataSource)
return; return;
GURL gUrl = dataSource->GetRequest().GetMainDocumentURL(); GURL gUrl = dataSource->GetRequest().GetFirstPartyForCookies();
*/ */
} }
@ -629,10 +634,8 @@ void BrowserWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame,
WebView* webview = browser_->GetWebView(); WebView* webview = browser_->GetWebView();
// Code duplicated from RenderView::DidCommitLoadForFrame. // Code duplicated from RenderView::DidCommitLoadForFrame.
const WebRequest& request = BrowserExtraData* extra_data = static_cast<BrowserExtraData*>(
webview->GetMainFrame()->GetDataSource()->GetRequest(); frame->GetDataSource()->GetExtraData());
BrowserExtraRequestData* extra_data =
static_cast<BrowserExtraRequestData*>(request.GetExtraData());
if (is_new_navigation) { if (is_new_navigation) {
// New navigation. // New navigation.
@ -678,6 +681,10 @@ void BrowserWebViewDelegate::UpdateURL(WebFrame* frame) {
handler->HandleAddressChange(browser_, browser_->GetCefFrame(frame), url); handler->HandleAddressChange(browser_, browser_->GetCefFrame(frame), url);
} }
std::string state;
if (frame->GetCurrentHistoryState(&state))
entry->SetContentState(state);
browser_->UIT_GetNavigationController()->DidNavigateToEntry(entry.release()); browser_->UIT_GetNavigationController()->DidNavigateToEntry(entry.release());
last_page_id_updated_ = std::max(last_page_id_updated_, page_id_); last_page_id_updated_ = std::max(last_page_id_updated_, page_id_);

View File

@ -20,6 +20,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/ref_counted.h" #include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "webkit/glue/webcursor.h" #include "webkit/glue/webcursor.h"
#include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webwidget_delegate.h" #include "webkit/glue/webwidget_delegate.h"
@ -27,6 +28,7 @@
#include "browser_drag_delegate.h" #include "browser_drag_delegate.h"
#include "browser_drop_delegate.h" #include "browser_drop_delegate.h"
#endif #endif
#include "browser_navigation_controller.h"
class CefBrowserImpl; class CefBrowserImpl;
struct WebPreferences; struct WebPreferences;
@ -102,6 +104,8 @@ class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
int edit_flags, int edit_flags,
const std::string& security_info, const std::string& security_info,
const std::string& frame_charset); const std::string& frame_charset);
virtual void DidCreateDataSource(WebFrame* frame,
WebDataSource* ds);
virtual void DidStartProvisionalLoadForFrame( virtual void DidStartProvisionalLoadForFrame(
WebView* webview, WebView* webview,
WebFrame* frame, WebFrame* frame,
@ -233,6 +237,10 @@ class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
IDropSource* drag_delegate() { return drag_delegate_.get(); } IDropSource* drag_delegate() { return drag_delegate_.get(); }
#endif #endif
void set_pending_extra_data(BrowserExtraData* extra_data) {
pending_extra_data_.reset(extra_data);
}
// Methods for modifying WebPreferences // Methods for modifying WebPreferences
void SetUserStyleSheetEnabled(bool is_enabled); void SetUserStyleSheetEnabled(bool is_enabled);
void SetUserStyleSheetLocation(const GURL& location); void SetUserStyleSheetLocation(const GURL& location);
@ -289,6 +297,8 @@ class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
int page_id_; int page_id_;
int last_page_id_updated_; int last_page_id_updated_;
scoped_ptr<BrowserExtraData> pending_extra_data_;
// true if we want to enable smart insert/delete. // true if we want to enable smart insert/delete.
bool smart_insert_delete_enabled_; bool smart_insert_delete_enabled_;

View File

@ -11,10 +11,9 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/string16.h" #include "base/string16.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "webkit/glue/scoped_clipboard_writer_glue.h" #include "webkit/glue/scoped_clipboard_writer_glue.h"
#include "SkBitmap.h"
// Clipboard glue // Clipboard glue
#if defined(OS_WIN) #if defined(OS_WIN)

View File

@ -51,7 +51,6 @@ WebWidgetHost* WebWidgetHost::Create(HWND parent_view,
0, 0, 0, 0, 0, 0, 0, 0,
parent_view, NULL, GetModuleHandle(NULL), NULL); parent_view, NULL, GetModuleHandle(NULL), NULL);
TRACK_HWND_CREATION(host->view_);
win_util::SetWindowUserData(host->view_, host); win_util::SetWindowUserData(host->view_, host);
host->webwidget_ = WebWidget::Create(delegate); host->webwidget_ = WebWidget::Create(delegate);