summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 16:01:47 +0000
committerboliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-10 16:01:47 +0000
commit9b57401b4b654bbbc98fe4fad3d10894fc2b3f30 (patch)
tree6f2ec166906f552cee3f013e166310e587570f4f
parent8f358834ef3678b8673160b2611a8fec4361f445 (diff)
downloadchromium_src-9b57401b4b654bbbc98fe4fad3d10894fc2b3f30.zip
chromium_src-9b57401b4b654bbbc98fe4fad3d10894fc2b3f30.tar.gz
chromium_src-9b57401b4b654bbbc98fe4fad3d10894fc2b3f30.tar.bz2
Implement AwContentsClient and remove dependency on chrome/
We are not depending on much functionality from ContentClient yet, so most methods are either no-op, left unimplemented with a TODO, or copied straight from the ChromeContentsClient implementation. BUG= Review URL: https://chromiumcodereview.appspot.com/11017024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161120 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/DEPS2
-rw-r--r--android_webview/android_webview.gyp2
-rw-r--r--android_webview/common/aw_content_client.cc39
-rw-r--r--android_webview/common/aw_content_client.h27
-rw-r--r--android_webview/lib/DEPS4
-rw-r--r--android_webview/lib/main/aw_main_delegate.cc2
-rw-r--r--android_webview/lib/main/aw_main_delegate.h4
-rw-r--r--content/browser/android/content_settings.cc7
8 files changed, 76 insertions, 11 deletions
diff --git a/android_webview/DEPS b/android_webview/DEPS
index 871dd41..8846a62 100644
--- a/android_webview/DEPS
+++ b/android_webview/DEPS
@@ -15,4 +15,6 @@ include_rules = [
"+jni",
"+net",
"+ui/android",
+ "+ui/base",
+ "+webkit",
]
diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp
index c83cfe3..db03ff3 100644
--- a/android_webview/android_webview.gyp
+++ b/android_webview/android_webview.gyp
@@ -25,6 +25,8 @@
'sources': [
'common/android_webview_message_generator.cc',
'common/android_webview_message_generator.h',
+ 'common/aw_content_client.cc',
+ 'common/aw_content_client.h',
'common/render_view_messages.cc',
'common/render_view_messages.h',
'common/url_constants.cc',
diff --git a/android_webview/common/aw_content_client.cc b/android_webview/common/aw_content_client.cc
new file mode 100644
index 0000000..c8823e6
--- /dev/null
+++ b/android_webview/common/aw_content_client.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 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 file.
+
+#include "android_webview/common/aw_content_client.h"
+
+#include "base/basictypes.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "webkit/user_agent/user_agent_util.h"
+
+namespace android_webview {
+
+std::string AwContentClient::GetProduct() const {
+ // "Version/4.0" had been hardcoded in the legacy WebView.
+ return std::string("Version/4.0");
+}
+
+std::string AwContentClient::GetUserAgent() const {
+ return webkit_glue::BuildUserAgentFromProduct(GetProduct());
+}
+
+string16 AwContentClient::GetLocalizedString(int message_id) const {
+ // TODO(boliu): Used only by WebKit, so only bundle those resources for
+ // Android WebView.
+ return l10n_util::GetStringUTF16(message_id);
+}
+
+base::StringPiece AwContentClient::GetDataResource(
+ int resource_id,
+ ui::ScaleFactor scale_factor) const {
+ // TODO(boliu): Used only by WebKit, so only bundle those resources for
+ // Android WebView.
+ return ResourceBundle::GetSharedInstance().GetRawDataResource(
+ resource_id, scale_factor);
+}
+
+} // namespace android_webview
+
diff --git a/android_webview/common/aw_content_client.h b/android_webview/common/aw_content_client.h
new file mode 100644
index 0000000..e0b5c24
--- /dev/null
+++ b/android_webview/common/aw_content_client.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 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 file.
+
+#ifndef ANDROID_WEBVIEW_COMMON_AW_CONTENT_CLIENT_H_
+#define ANDROID_WEBVIEW_COMMON_AW_CONTENT_CLIENT_H_
+
+#include "content/public/common/content_client.h"
+
+#include "base/compiler_specific.h"
+
+namespace android_webview {
+
+class AwContentClient : public content::ContentClient {
+ public:
+ // ContentClient implementation.
+ virtual std::string GetProduct() const OVERRIDE;
+ virtual std::string GetUserAgent() const OVERRIDE;
+ virtual string16 GetLocalizedString(int message_id) const OVERRIDE;
+ virtual base::StringPiece GetDataResource(
+ int resource_id,
+ ui::ScaleFactor scale_factor) const OVERRIDE;
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_COMMON_AW_CONTENT_CLIENT_H_
diff --git a/android_webview/lib/DEPS b/android_webview/lib/DEPS
index 31fdc7c..b448af7 100644
--- a/android_webview/lib/DEPS
+++ b/android_webview/lib/DEPS
@@ -4,7 +4,6 @@
include_rules = [
# Temporary until we implement our own versions of the *Client classes.
- "!chrome/common/chrome_content_client.h",
"!chrome/browser/chrome_content_browser_client.h",
"!chrome/renderer/chrome_content_renderer_client.h",
# Needed for content: scheme registation, will be moved away together with *Client classes.
@@ -28,9 +27,6 @@ include_rules = [
"!chrome/browser/profiles/profile.h",
"!chrome/browser/profiles/profile_manager.h",
- # Temporary until the javascript dialog creator is unpicked from WebView.
- "!chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h",
-
# Temporary until fixing bug 153758.
"!ui/base/ui_base_switches.h",
diff --git a/android_webview/lib/main/aw_main_delegate.cc b/android_webview/lib/main/aw_main_delegate.cc
index 11299d5..ee76606 100644
--- a/android_webview/lib/main/aw_main_delegate.cc
+++ b/android_webview/lib/main/aw_main_delegate.cc
@@ -62,7 +62,7 @@ AwMainDelegate::~AwMainDelegate() {
}
bool AwMainDelegate::BasicStartupComplete(int* exit_code) {
- content::SetContentClient(&chrome_content_client_);
+ content::SetContentClient(&content_client_);
return false;
}
diff --git a/android_webview/lib/main/aw_main_delegate.h b/android_webview/lib/main/aw_main_delegate.h
index d005ef7..b518536 100644
--- a/android_webview/lib/main/aw_main_delegate.h
+++ b/android_webview/lib/main/aw_main_delegate.h
@@ -5,8 +5,8 @@
#ifndef ANDROID_WEBVIEW_LIB_MAIN_AW_MAIN_DELEGATE_H_
#define ANDROID_WEBVIEW_LIB_MAIN_AW_MAIN_DELEGATE_H_
+#include "android_webview/common/aw_content_client.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/common/chrome_content_client.h"
#include "content/public/app/content_main_delegate.h"
namespace content {
@@ -35,7 +35,7 @@ class AwMainDelegate : public content::ContentMainDelegate {
CreateContentRendererClient() OVERRIDE;
scoped_ptr<content::BrowserMainRunner> browser_runner_;
- chrome::ChromeContentClient chrome_content_client_;
+ android_webview::AwContentClient content_client_;
DISALLOW_COPY_AND_ASSIGN(AwMainDelegate);
};
diff --git a/content/browser/android/content_settings.cc b/content/browser/android/content_settings.cc
index 48cd89a..fd59512 100644
--- a/content/browser/android/content_settings.cc
+++ b/content/browser/android/content_settings.cc
@@ -10,11 +10,11 @@
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_client.h"
#include "jni/ContentSettings_jni.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/user_agent/user_agent.h"
-#include "webkit/user_agent/user_agent_util.h"
using base::android::CheckException;
using base::android::ConvertJavaStringToUTF16;
@@ -343,9 +343,8 @@ static jint Init(JNIEnv* env, jobject obj, jint nativeContentViewCore,
}
static jstring GetDefaultUserAgent(JNIEnv* env, jclass clazz) {
- // "Version/4.0" had been hardcoded in the legacy WebView.
- std::string ua = webkit_glue::BuildUserAgentFromProduct("Version/4.0");
- return base::android::ConvertUTF8ToJavaString(env, ua).Release();
+ return base::android::ConvertUTF8ToJavaString(
+ env, GetContentClient()->GetUserAgent()).Release();
}
} // namespace content