summaryrefslogtreecommitdiffstats
path: root/content/app/android
diff options
context:
space:
mode:
authoryfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 16:56:09 +0000
committeryfriedman@chromium.org <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 16:56:09 +0000
commitd0924cb339decdcc5d9924bae3550e2531d48207 (patch)
tree264b19ca050b454ff4890f5f06f1d007e76386a6 /content/app/android
parentb0ddd14c6fef8a42cd922ff62dce62fb3e89439e (diff)
downloadchromium_src-d0924cb339decdcc5d9924bae3550e2531d48207.zip
chromium_src-d0924cb339decdcc5d9924bae3550e2531d48207.tar.gz
chromium_src-d0924cb339decdcc5d9924bae3550e2531d48207.tar.bz2
Upstream most of the user agent code for Android.
Brought along most of the command-line start-up switches. As for requiring the InitUserAgent (and not just having the logic in webkit/glue/user_agent), that's because currently unit tests can't access Java code directly. Using pseudo dependency-injection allows this to work for prod and test. Once apk-based tests are online, we can remove this. Review URL: https://chromiumcodereview.appspot.com/10473002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/app/android')
-rw-r--r--content/app/android/content_jni_registrar.cc2
-rw-r--r--content/app/android/content_main.cc10
-rw-r--r--content/app/android/user_agent.cc30
-rw-r--r--content/app/android/user_agent.h22
4 files changed, 56 insertions, 8 deletions
diff --git a/content/app/android/content_jni_registrar.cc b/content/app/android/content_jni_registrar.cc
index 9f858b9..61f2192 100644
--- a/content/app/android/content_jni_registrar.cc
+++ b/content/app/android/content_jni_registrar.cc
@@ -8,6 +8,7 @@
#include "base/android/jni_registrar.h"
#include "content/app/android/content_main.h"
#include "content/app/android/sandboxed_process_service.h"
+#include "content/app/android/user_agent.h"
#include "content/browser/android/android_browser_process.h"
#include "content/browser/android/content_view_client.h"
#include "content/browser/android/content_view_impl.h"
@@ -35,6 +36,7 @@ base::android::RegistrationMethod kContentRegisteredMethods[] = {
{ "SurfaceCallback", content::RegisterSurfaceCallback },
{ "TouchPoint", content::RegisterTouchPoint },
{ "TraceEvent", RegisterTraceEvent },
+ { "UserAgent", content::RegisterUserAgent },
};
bool RegisterJni(JNIEnv* env) {
diff --git a/content/app/android/content_main.cc b/content/app/android/content_main.cc
index 53692c5..bdfd975 100644
--- a/content/app/android/content_main.cc
+++ b/content/app/android/content_main.cc
@@ -8,16 +8,12 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#if !defined(ANDROID_UPSTREAM_BRINGUP)
-#include "content/common/android/user_agent.h"
-#endif
+#include "content/app/android/user_agent.h"
#include "content/public/app/content_main_delegate.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/common/content_switches.h"
#include "jni/content_main_jni.h"
-#if !defined(ANDROID_UPSTREAM_BRINGUP)
#include "webkit/glue/user_agent.h"
-#endif
using base::LazyInstance;
using content::ContentMainRunner;
@@ -51,9 +47,7 @@ static jint Start(JNIEnv* env, jclass clazz) {
base::debug::WaitForDebugger(24*60*60, false);
}
-#if !defined(ANDROID_UPSTREAM_BRINGUP)
- webkit_glue::InitUserAgent(GetUserAgentOSInfo());
-#endif
+ webkit_glue::SetUserAgentOSInfo(content::GetUserAgentOSInfo());
DCHECK(!g_content_runner.Get().get());
g_content_runner.Get().reset(ContentMainRunner::Create());
diff --git a/content/app/android/user_agent.cc b/content/app/android/user_agent.cc
new file mode 100644
index 0000000..aa284e5
--- /dev/null
+++ b/content/app/android/user_agent.cc
@@ -0,0 +1,30 @@
+// 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 "content/app/android/user_agent.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "base/android/scoped_java_ref.h"
+#include "jni/user_agent_jni.h"
+
+using base::android::AttachCurrentThread;
+using base::android::ScopedJavaLocalRef;
+using base::android::ConvertJavaStringToUTF8;
+using base::android::GetApplicationContext;
+
+namespace content {
+
+std::string GetUserAgentOSInfo() {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> os_info =
+ Java_UserAgent_getUserAgentOSInfo(env);
+ return ConvertJavaStringToUTF8(os_info);
+}
+
+bool RegisterUserAgent(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace content
diff --git a/content/app/android/user_agent.h b/content/app/android/user_agent.h
new file mode 100644
index 0000000..cc0dcce
--- /dev/null
+++ b/content/app/android/user_agent.h
@@ -0,0 +1,22 @@
+// 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 CONTENT_APP_ANDROID_USER_AGENT_H_
+#define CONTENT_APP_ANDROID_USER_AGENT_H_
+#pragma once
+
+#include <jni.h>
+#include <string>
+
+namespace content {
+
+// Returns the OS information component required by user agent composition.
+std::string GetUserAgentOSInfo();
+
+// Register JNI method.
+bool RegisterUserAgent(JNIEnv* env);
+
+} // namespace content
+
+#endif // CONTENT_APP_ANDROID_USER_AGENT_H_