summaryrefslogtreecommitdiff
path: root/android_webview/browser
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-09-19 22:36:51 +0100
committerTorne (Richard Coles) <torne@google.com>2013-09-19 22:36:51 +0100
commitd0247b1b59f9c528cb6df88b4f2b9afaf80d181e (patch)
tree5c397fadc190cc71bffe2ffad1efc27a5b95309d /android_webview/browser
parentf7571f5f07547e2f3e0addf48d1f2a7ec3632957 (diff)
downloadchromium_org-d0247b1b59f9c528cb6df88b4f2b9afaf80d181e.tar.gz
Merge from Chromium at DEPS revision 224184
This commit was generated by merge_to_master.py. Change-Id: Ia3424df5abed9bea642c522b9e2358dceabd8423
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/aw_browser_context.cc45
-rw-r--r--android_webview/browser/aw_contents_io_thread_client.h4
-rw-r--r--android_webview/browser/aw_javascript_dialog_manager.cc1
-rw-r--r--android_webview/browser/aw_javascript_dialog_manager.h1
-rw-r--r--android_webview/browser/icon_helper.cc9
-rw-r--r--android_webview/browser/icon_helper.h13
-rw-r--r--android_webview/browser/in_process_view_renderer.cc7
-rw-r--r--android_webview/browser/renderer_host/aw_render_view_host_ext.cc16
-rw-r--r--android_webview/browser/renderer_host/aw_render_view_host_ext.h10
-rw-r--r--android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc26
10 files changed, 99 insertions, 33 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 6b52f8a95d..97978ca4e6 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -10,9 +10,14 @@
#include "android_webview/browser/jni_dependency_factory.h"
#include "android_webview/browser/net/aw_url_request_context_getter.h"
#include "android_webview/browser/net/init_native_callback.h"
+#include "base/android/path_utils.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_builder.h"
+#include "base/sequenced_task_runner.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_master.h"
@@ -23,6 +28,7 @@
#include "content/public/browser/web_contents.h"
#include "net/url_request/url_request_context.h"
+using base::FilePath;
using content::BrowserThread;
namespace android_webview {
@@ -65,10 +71,31 @@ class AwResourceContext : public content::ResourceContext {
AwBrowserContext* g_browser_context = NULL;
+void ImportLegacyCookieStore(const FilePath& cookie_store_path) {
+ // We use the old cookie store to create the new cookie store only if the
+ // new cookie store does not exist.
+ if (base::PathExists(cookie_store_path))
+ return;
+
+ // WebViewClassic gets the database path from Context and appends a
+ // hardcoded name. (see https://android.googlesource.com/platform/frameworks/base/+/bf6f6f9de72c9fd15e6bd/core/java/android/webkit/JniUtil.java and
+ // https://android.googlesource.com/platform/external/webkit/+/7151ed0c74599/Source/WebKit/android/WebCoreSupport/WebCookieJar.cpp)
+ FilePath old_cookie_store_path;
+ base::android::GetDatabaseDirectory(&old_cookie_store_path);
+ old_cookie_store_path = old_cookie_store_path.Append(
+ FILE_PATH_LITERAL("webviewCookiesChromium.db"));
+ if (base::PathExists(old_cookie_store_path) &&
+ !base::Move(old_cookie_store_path, cookie_store_path)) {
+ LOG(WARNING) << "Failed to move old cookie store path from "
+ << old_cookie_store_path.AsUTF8Unsafe() << " to "
+ << cookie_store_path.AsUTF8Unsafe();
+ }
+}
+
} // namespace
AwBrowserContext::AwBrowserContext(
- const base::FilePath path,
+ const FilePath path,
JniDependencyFactory* native_factory)
: context_storage_path_(path),
native_factory_(native_factory),
@@ -101,11 +128,23 @@ AwBrowserContext* AwBrowserContext::FromWebContents(
}
void AwBrowserContext::PreMainMessageLoopRun() {
+
+ FilePath cookie_store_path = GetPath().Append(FILE_PATH_LITERAL("Cookies"));
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner =
+ BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
+ BrowserThread::GetBlockingPool()->GetSequenceToken());
+
+ background_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(ImportLegacyCookieStore, cookie_store_path));
+
cookie_store_ = content::CreatePersistentCookieStore(
- GetPath().Append(FILE_PATH_LITERAL("Cookies")),
+ cookie_store_path,
true,
NULL,
- NULL);
+ NULL,
+ background_task_runner);
+
cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true);
url_request_context_getter_ =
new AwURLRequestContextGetter(GetPath(), cookie_store_.get());
diff --git a/android_webview/browser/aw_contents_io_thread_client.h b/android_webview/browser/aw_contents_io_thread_client.h
index fd1de8b37b..aedfba22d9 100644
--- a/android_webview/browser/aw_contents_io_thread_client.h
+++ b/android_webview/browser/aw_contents_io_thread_client.h
@@ -47,6 +47,10 @@ class AwContentsIoThreadClient {
virtual ~AwContentsIoThreadClient() {}
+ // Returns whether this is a new pop up that is still waiting for association
+ // with the java counter part.
+ virtual bool PendingAssociation() const = 0;
+
// Retrieve CacheMode setting value of this AwContents.
// This method is called on the IO thread only.
virtual CacheMode GetCacheMode() const = 0;
diff --git a/android_webview/browser/aw_javascript_dialog_manager.cc b/android_webview/browser/aw_javascript_dialog_manager.cc
index d9ec1c138b..1690eac737 100644
--- a/android_webview/browser/aw_javascript_dialog_manager.cc
+++ b/android_webview/browser/aw_javascript_dialog_manager.cc
@@ -21,7 +21,6 @@ void AwJavaScriptDialogManager::RunJavaScriptDialog(
content::JavaScriptMessageType message_type,
const string16& message_text,
const string16& default_prompt_text,
- bool user_gesture,
const DialogClosedCallback& callback,
bool* did_suppress_message) {
AwContentsClientBridgeBase* bridge =
diff --git a/android_webview/browser/aw_javascript_dialog_manager.h b/android_webview/browser/aw_javascript_dialog_manager.h
index 0abb432c4a..f8db746edc 100644
--- a/android_webview/browser/aw_javascript_dialog_manager.h
+++ b/android_webview/browser/aw_javascript_dialog_manager.h
@@ -22,7 +22,6 @@ class AwJavaScriptDialogManager : public content::JavaScriptDialogManager {
content::JavaScriptMessageType message_type,
const string16& message_text,
const string16& default_prompt_text,
- bool user_gesture,
const DialogClosedCallback& callback,
bool* did_suppress_message) OVERRIDE;
virtual void RunBeforeUnloadDialog(
diff --git a/android_webview/browser/icon_helper.cc b/android_webview/browser/icon_helper.cc
index 77c98d46eb..80233fca23 100644
--- a/android_webview/browser/icon_helper.cc
+++ b/android_webview/browser/icon_helper.cc
@@ -11,6 +11,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/favicon_url.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/size.h"
using content::BrowserThread;
using content::WebContents;
@@ -30,8 +31,11 @@ void IconHelper::SetListener(Listener* listener) {
}
void IconHelper::DownloadFaviconCallback(
- int id, int http_status_code, const GURL& image_url, int requested_size,
- const std::vector<SkBitmap>& bitmaps) {
+ int id,
+ int http_status_code,
+ const GURL& image_url,
+ const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& original_bitmap_sizes) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (bitmaps.size() == 0) {
return;
@@ -61,7 +65,6 @@ void IconHelper::DidUpdateFaviconURL(int32 page_id,
// but we should decouple that setting via a boolean setting)
web_contents()->DownloadImage(i->icon_url,
true, // Is a favicon
- 0, // No preferred size
0, // No maximum size
base::Bind(
&IconHelper::DownloadFaviconCallback, base::Unretained(this)));
diff --git a/android_webview/browser/icon_helper.h b/android_webview/browser/icon_helper.h
index 97539ebc40..7498874324 100644
--- a/android_webview/browser/icon_helper.h
+++ b/android_webview/browser/icon_helper.h
@@ -15,6 +15,10 @@ namespace content {
struct FaviconURL;
}
+namespace gfx {
+class Size;
+}
+
namespace android_webview {
// A helper that observes favicon changes for Webview.
@@ -39,9 +43,12 @@ class IconHelper : public content::WebContentsObserver {
virtual void DidUpdateFaviconURL(int32 page_id,
const std::vector<content::FaviconURL>& candidates) OVERRIDE;
- void DownloadFaviconCallback(int id, int http_status_code,
- const GURL& image_url, int requested_size,
- const std::vector<SkBitmap>& bitmaps);
+ void DownloadFaviconCallback(
+ int id,
+ int http_status_code,
+ const GURL& image_url,
+ const std::vector<SkBitmap>& bitmaps,
+ const std::vector<gfx::Size>& original_bitmap_sizes);
private:
Listener* listener_;
diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
index 07b4d67531..31ca5dc1e3 100644
--- a/android_webview/browser/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -260,18 +260,11 @@ InProcessViewRenderer::~InProcessViewRenderer() {
DCHECK(web_contents_ == NULL); // WebContentsGone should have been called.
}
-
-// TODO(boliu): Should also call this when we know for sure we are no longer,
-// for example, when visible rect becomes 0.
void InProcessViewRenderer::NoLongerExpectsDrawGL() {
GLViewRendererManager& mru = g_view_renderer_manager.Get();
if (manager_key_ != mru.NullKey()) {
mru.NoLongerExpectsDrawGL(manager_key_);
manager_key_ = mru.NullKey();
-
- // TODO(boliu): If this is the first one and there are GL pending,
- // requestDrawGL on next one.
- // TODO(boliu): If this is the last one, lose all global contexts.
}
}
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
index 78d6cf4b4e..8efdf04c05 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.cc
@@ -70,9 +70,14 @@ const AwHitTestData& AwRenderViewHostExt::GetLastHitTestData() const {
return last_hit_test_data_;
}
-void AwRenderViewHostExt::SetTextZoomLevel(double level) {
+void AwRenderViewHostExt::SetTextZoomFactor(float factor) {
DCHECK(CalledOnValidThread());
- Send(new AwViewMsg_SetTextZoomLevel(web_contents()->GetRoutingID(), level));
+ Send(new AwViewMsg_SetTextZoomFactor(web_contents()->GetRoutingID(), factor));
+}
+
+void AwRenderViewHostExt::SetFixedLayoutSize(const gfx::Size& size) {
+ DCHECK(CalledOnValidThread());
+ Send(new AwViewMsg_SetFixedLayoutSize(web_contents()->GetRoutingID(), size));
}
void AwRenderViewHostExt::ResetScrollAndScaleState() {
@@ -134,6 +139,8 @@ bool AwRenderViewHostExt::OnMessageReceived(const IPC::Message& message) {
OnUpdateHitTestData)
IPC_MESSAGE_HANDLER(AwViewHostMsg_PageScaleFactorChanged,
OnPageScaleFactorChanged)
+ IPC_MESSAGE_HANDLER(AwViewHostMsg_OnContentsSizeChanged,
+ OnContentsSizeChanged)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -164,4 +171,9 @@ void AwRenderViewHostExt::OnPageScaleFactorChanged(float page_scale_factor) {
client_->OnWebLayoutPageScaleFactorChanged(page_scale_factor);
}
+void AwRenderViewHostExt::OnContentsSizeChanged(
+ const gfx::Size& contents_size) {
+ client_->OnWebLayoutContentsSizeChanged(contents_size);
+}
+
} // namespace android_webview
diff --git a/android_webview/browser/renderer_host/aw_render_view_host_ext.h b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
index 3007f15556..c9d90c680e 100644
--- a/android_webview/browser/renderer_host/aw_render_view_host_ext.h
+++ b/android_webview/browser/renderer_host/aw_render_view_host_ext.h
@@ -11,6 +11,7 @@
#include "base/callback_forward.h"
#include "base/threading/non_thread_safe.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/size.h"
class GURL;
@@ -25,6 +26,8 @@ class AwRenderViewHostExtClient {
public:
// Called when the RenderView page scale changes.
virtual void OnWebLayoutPageScaleFactorChanged(float page_scale_factor) = 0;
+ virtual void OnWebLayoutContentsSizeChanged(
+ const gfx::Size& contents_size) = 0;
protected:
virtual ~AwRenderViewHostExtClient() {}
@@ -62,9 +65,11 @@ class AwRenderViewHostExt : public content::WebContentsObserver,
// the corresponding public WebView API is as well.
const AwHitTestData& GetLastHitTestData() const;
- // Sets the zoom level for text only. Used in layout modes other than
+ // Sets the zoom factor for text only. Used in layout modes other than
// Text Autosizing.
- void SetTextZoomLevel(double level);
+ void SetTextZoomFactor(float factor);
+
+ void SetFixedLayoutSize(const gfx::Size& size);
void ResetScrollAndScaleState();
@@ -86,6 +91,7 @@ class AwRenderViewHostExt : public content::WebContentsObserver,
void OnDocumentHasImagesResponse(int msg_id, bool has_images);
void OnUpdateHitTestData(const AwHitTestData& hit_test_data);
void OnPageScaleFactorChanged(float page_scale_factor);
+ void OnContentsSizeChanged(const gfx::Size& contents_size);
bool IsRenderViewReady() const;
diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
index 1bab66bfba..6f4c3659bb 100644
--- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
+++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
@@ -70,7 +70,6 @@ class IoThreadClientThrottle : public content::ResourceThrottle {
void OnIoThreadClientReady(int new_child_id, int new_route_id);
bool MaybeBlockRequest();
bool ShouldBlockRequest();
- scoped_ptr<AwContentsIoThreadClient> GetIoThreadClient();
int get_child_id() const { return child_id_; }
int get_route_id() const { return route_id_; }
@@ -112,10 +111,13 @@ void IoThreadClientThrottle::WillRedirectRequest(const GURL& new_url,
}
bool IoThreadClientThrottle::MaybeDeferRequest(bool* defer) {
+ *defer = false;
+
+ // Defer all requests of a pop up that is still not associated with Java
+ // client so that the client will get a chance to override requests.
scoped_ptr<AwContentsIoThreadClient> io_client =
AwContentsIoThreadClient::FromID(child_id_, route_id_);
- *defer = false;
- if (!io_client.get()) {
+ if (io_client && io_client->PendingAssociation()) {
*defer = true;
AwResourceDispatcherHostDelegate::AddPendingThrottle(
child_id_, route_id_, this);
@@ -169,8 +171,7 @@ bool IoThreadClientThrottle::ShouldBlockRequest() {
}
SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE);
} else {
- AwContentsIoThreadClient::CacheMode cache_mode =
- GetIoThreadClient()->GetCacheMode();
+ AwContentsIoThreadClient::CacheMode cache_mode = io_client->GetCacheMode();
switch(cache_mode) {
case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK:
SetCacheControlFlag(request_, net::LOAD_PREFERRING_CACHE);
@@ -188,11 +189,6 @@ bool IoThreadClientThrottle::ShouldBlockRequest() {
return false;
}
-scoped_ptr<AwContentsIoThreadClient>
- IoThreadClientThrottle::GetIoThreadClient() {
- return AwContentsIoThreadClient::FromID(child_id_, route_id_);
-}
-
// static
void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() {
content::ResourceDispatcherHost::Get()->SetDelegate(
@@ -215,6 +211,14 @@ void AwResourceDispatcherHostDelegate::RequestBeginning(
int route_id,
bool is_continuation_of_transferred_request,
ScopedVector<content::ResourceThrottle>* throttles) {
+ // If io_client is NULL, then the browser side objects have already been
+ // destroyed, so do not do anything to the request. Conversely if the
+ // request relates to a not-yet-created popup window, then the client will
+ // be non-NULL but PopupPendingAssociation() will be set.
+ scoped_ptr<AwContentsIoThreadClient> io_client =
+ AwContentsIoThreadClient::FromID(child_id, route_id);
+ if (!io_client)
+ return;
throttles->push_back(new IoThreadClientThrottle(
child_id, route_id, request));
@@ -230,7 +234,7 @@ void AwResourceDispatcherHostDelegate::RequestBeginning(
// embedder.
(resource_type == ResourceType::MAIN_FRAME ||
(resource_type == ResourceType::SUB_FRAME &&
- !request->url().SchemeIs(chrome::kHttpScheme) &&
+ !request->url().SchemeIs(content::kHttpScheme) &&
!request->url().SchemeIs(content::kHttpsScheme)));
if (allow_intercepting) {
throttles->push_back(InterceptNavigationDelegate::CreateThrottleFor(