diff options
39 files changed, 267 insertions, 290 deletions
diff --git a/android_webview/Android.mk b/android_webview/Android.mk index 312ed43..90a3860 100644 --- a/android_webview/Android.mk +++ b/android_webview/Android.mk @@ -40,7 +40,7 @@ LOCAL_SRC_FILES += \ $(call all-java-files-under, \ ../components/web_contents_delegate_android/android/java/src) \ $(call all-java-files-under, \ - ../content/components/navigation_interception/java/src) \ + ../components/navigation_interception/android/java/src) \ # Generated by net.gyp:net_errors_java, net.gyp:certificate_mime_types_java, diff --git a/android_webview/DEPS b/android_webview/DEPS index fa3868b..d5e52b5 100644 --- a/android_webview/DEPS +++ b/android_webview/DEPS @@ -1,5 +1,5 @@ # Please include joth@ and (joi@ or erikwright@) on the review for any changes -# to DEPS files under android_webview/ +# to DEPS files under android_webview/ # Do not add any includes under chrome/ anywhere in android_webview. @@ -9,8 +9,6 @@ include_rules = [ "!chrome/browser/component", "+cc", - # TODO(boliu): Remove this when content/components is moved to components/. - "+content/components", "+content/public/common", "+jni", "+net", diff --git a/android_webview/android_webview.gyp b/android_webview/android_webview.gyp index b033141..2011891 100644 --- a/android_webview/android_webview.gyp +++ b/android_webview/android_webview.gyp @@ -100,9 +100,9 @@ 'type': 'static_library', 'dependencies': [ '../android_webview/native/webview_native.gyp:webview_native', + '../components/components.gyp:navigation_interception', '../components/components.gyp:web_contents_delegate_android', '../content/content.gyp:content', - '../content/content.gyp:navigation_interception', '../skia/skia.gyp:skia', 'android_webview_pak', ], @@ -187,9 +187,9 @@ 'target_name': 'android_webview_java', 'type': 'none', 'dependencies': [ - '../content/content.gyp:content_java', - '../content/content.gyp:navigation_interception_java', + '../components/components.gyp:navigation_interception_java', '../components/components.gyp:web_contents_delegate_android_java', + '../content/content.gyp:content_java', '../ui/ui.gyp:ui_java', ], 'variables': { @@ -203,9 +203,9 @@ 'type': 'none', 'dependencies': [ '../base/base.gyp:base_java', + '../components/components.gyp:navigation_interception_java', '../components/components.gyp:web_contents_delegate_android_java', '../content/content.gyp:content_java', - '../content/content.gyp:navigation_interception_java', '../media/media.gyp:media_java', '../net/net.gyp:net_java', '../ui/ui.gyp:ui_java', diff --git a/android_webview/browser/DEPS b/android_webview/browser/DEPS index 2892748..1bcae2d 100644 --- a/android_webview/browser/DEPS +++ b/android_webview/browser/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+android_webview/browser", "+android_webview/common", + "+components/navigation_interception", "+content/public/browser", # Temporary until we bundle our own favicon. See 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 03652da..c00a8ed 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 @@ -11,7 +11,7 @@ #include "android_webview/common/url_constants.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "content/components/navigation_interception/intercept_navigation_delegate.h" +#include "components/navigation_interception/intercept_navigation_delegate.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/resource_controller.h" #include "content/public/browser/resource_dispatcher_host.h" @@ -22,8 +22,8 @@ #include "net/url_request/url_request.h" using android_webview::AwContentsIoThreadClient; +using components::InterceptNavigationDelegate; using content::BrowserThread; -using content::InterceptNavigationDelegate; namespace { diff --git a/android_webview/java/DEPS b/android_webview/java/DEPS index 9f7ec84..a6c4c30 100644 --- a/android_webview/java/DEPS +++ b/android_webview/java/DEPS @@ -1,4 +1,5 @@ include_rules = [ "+content/public/android/java", + "+components/navigation_interception/android/java", "+components/web_contents_delegate_android/android/java", ] diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 754c87b7..317ac1d 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -31,7 +31,7 @@ import org.chromium.content.browser.LoadUrlParams; import org.chromium.content.browser.NavigationHistory; import org.chromium.content.browser.PageTransitionTypes; import org.chromium.content.common.CleanupReference; -import org.chromium.content.components.navigation_interception.InterceptNavigationDelegate; +import org.chromium.components.navigation_interception.InterceptNavigationDelegate; import org.chromium.net.GURLUtils; import org.chromium.net.X509Util; import org.chromium.ui.gfx.NativeWindow; diff --git a/android_webview/lib/main/webview_entry_point.cc b/android_webview/lib/main/webview_entry_point.cc index a7338b1..e005098 100644 --- a/android_webview/lib/main/webview_entry_point.cc +++ b/android_webview/lib/main/webview_entry_point.cc @@ -6,16 +6,17 @@ #include "android_webview/native/android_webview_jni_registrar.h" #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" +#include "components/navigation_interception/component_jni_registrar.h" #include "components/web_contents_delegate_android/component_jni_registrar.h" -#include "content/components/navigation_interception/component_jni_registrar.h" #include "content/public/app/android_library_loader_hooks.h" #include "content/public/app/content_main.h" static base::android::RegistrationMethod -kWebViewDependencyRegisteredMethods[] = { - { "NavigationInterception", content::RegisterNavigationInterceptionJni }, - { "WebContentsDelegateAndroid", - components::RegisterWebContentsDelegateAndroidJni }, + kWebViewDependencyRegisteredMethods[] = { + { "NavigationInterception", + components::RegisterNavigationInterceptionJni }, + { "WebContentsDelegateAndroid", + components::RegisterWebContentsDelegateAndroidJni }, }; // This is called by the VM when the shared library is first loaded. diff --git a/android_webview/native/DEPS b/android_webview/native/DEPS index 452c80b..6693d30 100644 --- a/android_webview/native/DEPS +++ b/android_webview/native/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+ui/gl", # Components that Android WebView depends on. + "+components/navigation_interception", "+components/web_contents_delegate_android", # TODO(joth): Remove if we can move the compositor driver into ../browser/ diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index e319f58..3750650 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -27,7 +27,7 @@ #include "base/pickle.h" #include "base/supports_user_data.h" #include "cc/layer.h" -#include "content/components/navigation_interception/intercept_navigation_delegate.h" +#include "components/navigation_interception/intercept_navigation_delegate.h" #include "content/public/browser/android/content_view_core.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cert_store.h" @@ -65,9 +65,9 @@ using base::android::ConvertUTF8ToJavaString; using base::android::JavaRef; using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaLocalRef; +using components::InterceptNavigationDelegate; using content::BrowserThread; using content::ContentViewCore; -using content::InterceptNavigationDelegate; using content::WebContents; extern "C" { diff --git a/build/all.gyp b/build/all.gyp index bf78863..4309175 100644 --- a/build/all.gyp +++ b/build/all.gyp @@ -12,7 +12,6 @@ 'some.gyp:*', '../base/base.gyp:*', '../chrome/chrome.gyp:*', - '../components/components.gyp:*', '../content/content.gyp:*', '../crypto/crypto.gyp:*', '../media/media.gyp:*', @@ -35,6 +34,7 @@ ['OS!="ios"', { 'dependencies': [ '../cc/cc_tests.gyp:*', + '../components/components.gyp:*', '../device/device.gyp:*', '../gpu/gpu.gyp:*', '../gpu/tools/tools.gyp:*', diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 00ea7c6..55e162e 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -6,10 +6,9 @@ include_rules = [ "+chrome/tools/profiles", # For history unit tests. "+chromeos", "+components/auto_login_parser", + "+components/navigation_interception", "+components/visitedlink/browser", "+components/web_contents_delegate_android", - # TODO(boliu): Remove when content/components is moved to components. - "+content/components", "+content/public/browser", "+device/bluetooth", "+device/media_transfer_protocol", diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index a3f9f8a..2fca549 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -18,15 +18,15 @@ #include "chrome/browser/ui/android/chrome_http_auth_handler.h" #include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h" #include "chrome/browser/ui/android/navigation_popup.h" +#include "components/navigation_interception/component_jni_registrar.h" #include "components/web_contents_delegate_android/component_jni_registrar.h" -#include "content/components/navigation_interception/component_jni_registrar.h" namespace chrome { namespace android { static base::android::RegistrationMethod kChromeRegisteredMethods[] = { // Register JNI for components we depend on. - { "NavigationInterception", content::RegisterNavigationInterceptionJni }, + { "NavigationInterception", components::RegisterNavigationInterceptionJni }, { "WebContentsDelegateAndroid", components::RegisterWebContentsDelegateAndroidJni }, // Register JNI for chrome classes. diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc index 5ee7d58..1128b52 100644 --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc @@ -55,7 +55,7 @@ #endif #if defined(OS_ANDROID) -#include "content/components/navigation_interception/intercept_navigation_delegate.h" +#include "components/navigation_interception/intercept_navigation_delegate.h" #endif #if defined(OS_CHROMEOS) @@ -153,8 +153,7 @@ void ChromeResourceDispatcherHostDelegate::RequestBeginning( #if defined(OS_ANDROID) if (!is_prerendering && resource_type == ResourceType::MAIN_FRAME) { throttles->push_back( - content::InterceptNavigationDelegate::CreateThrottleFor( - request)); + components::InterceptNavigationDelegate::CreateThrottleFor(request)); } #endif #if defined(OS_CHROMEOS) diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 8f30ae0..a42e822 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1074,9 +1074,9 @@ 'type': 'none', 'dependencies': [ '../base/base.gyp:base', + '../components/components.gyp:navigation_interception_java', '../components/components.gyp:web_contents_delegate_android_java', '../content/content.gyp:content_java', - '../content/content.gyp:navigation_interception_java', '../sync/sync.gyp:sync_java', '../third_party/guava/guava.gyp:guava_javalib', '../ui/ui.gyp:ui_java', diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 3abb5ae..2e3ec6d 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2269,7 +2269,7 @@ 'installer_util', 'sync_file_system_proto', '../cc/cc.gyp:cc', - '../content/content.gyp:navigation_interception', + '../components/components.gyp:navigation_interception', '../net/net.gyp:net_with_v8', '../printing/printing.gyp:printing', '../third_party/adobe/flash/flash_player.gyp:flapper_version_h', diff --git a/components/DEPS b/components/DEPS index eb8bee4..d6fbc7c 100644 --- a/components/DEPS +++ b/components/DEPS @@ -13,5 +13,4 @@ include_rules = [ # "+content/public/browser" rule. "-content", "+content/public/common", - "+content/public/test", ] diff --git a/components/components.gyp b/components/components.gyp index a55fe44..eea034a 100644 --- a/components/components.gyp +++ b/components/components.gyp @@ -6,6 +6,7 @@ 'includes': [ 'auto_login_parser.gypi', 'components_tests.gypi', + 'navigation_interception.gypi', 'visitedlink.gypi', 'web_contents_delegate_android.gypi', ], diff --git a/components/components_tests.gypi b/components/components_tests.gypi index 537a8c0..ef40684 100644 --- a/components/components_tests.gypi +++ b/components/components_tests.gypi @@ -3,17 +3,31 @@ # found in the LICENSE file. { - 'targets': [ - { - 'target_name': 'components_unittests', - 'type': '<(gtest_target_type)', - 'sources': [ - 'test/run_all_unittests.cc', - ], - 'dependencies': [ - '../base/base.gyp:test_support_base', - '../testing/gtest.gyp:gtest', + 'conditions': [ + ['OS != "ios"', { + 'targets': [ + { + 'target_name': 'components_unittests', + 'type': '<(gtest_target_type)', + 'sources': [ + 'navigation_interception/intercept_navigation_resource_throttle_unittest.cc', + 'test/run_all_unittests.cc', + ], + 'include_dirs': [ + '..', + ], + 'dependencies': [ + '../base/base.gyp:test_support_base', + '../testing/gmock.gyp:gmock', + '../testing/gtest.gyp:gtest', + + # Dependencies of intercept_navigation_resource_throttle_unittest.cc + '../content/content.gyp:test_support_content', + '../skia/skia.gyp:skia', + 'navigation_interception', + ], + } ], - } - ] + }], + ], } diff --git a/components/navigation_interception.gypi b/components/navigation_interception.gypi new file mode 100644 index 0000000..4912929 --- /dev/null +++ b/components/navigation_interception.gypi @@ -0,0 +1,76 @@ +# 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. + +{ + 'conditions': [ + ['OS != "ios"', { + 'targets': [ + { + 'target_name': 'navigation_interception', + 'type': 'static_library', + 'defines!': ['CONTENT_IMPLEMENTATION'], + 'dependencies': [ + '../base/base.gyp:base', + '../content/content.gyp:content_browser', + '../content/content.gyp:content_common', + '../net/net.gyp:net', + ], + 'include_dirs': [ + '..', + '../skia/config', + '<(SHARED_INTERMEDIATE_DIR)/navigation_interception', + + ], + 'sources': [ + 'navigation_interception/intercept_navigation_resource_throttle.cc', + 'navigation_interception/intercept_navigation_resource_throttle.h', + ], + 'conditions': [ + ['OS=="android"', { + 'dependencies': [ + 'navigation_interception_jni_headers', + ], + 'sources': [ + 'navigation_interception/component_jni_registrar.cc', + 'navigation_interception/component_jni_registrar.h', + 'navigation_interception/intercept_navigation_delegate.cc', + 'navigation_interception/intercept_navigation_delegate.h', + ], + }], + ], + }, + ], + 'conditions': [ + ['OS=="android"', { + 'targets': [ + { + 'target_name': 'navigation_interception_java', + 'type': 'none', + 'dependencies': [ + '../base/base.gyp:base', + ], + 'variables': { + 'package_name': 'navigation_interception', + 'java_in_dir': 'navigation_interception/android/java', + }, + 'includes': [ '../build/java.gypi' ], + }, + { + 'target_name': 'navigation_interception_jni_headers', + 'type': 'none', + 'sources': [ + 'navigation_interception/android/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java', + ], + 'variables': { + 'jni_gen_dir': 'navigation_interception', + }, + 'includes': [ '../build/jni_generator.gypi' ], + }, + ], + }], + ], + }], + ], +} diff --git a/components/navigation_interception/DEPS b/components/navigation_interception/DEPS new file mode 100644 index 0000000..cee4d3e --- /dev/null +++ b/components/navigation_interception/DEPS @@ -0,0 +1,8 @@ +include_rules = [ + "+jni", + "+net", + + "+content/public/browser", + "+content/public/common", + "+content/public/test", +] diff --git a/content/components/navigation_interception/OWNERS b/components/navigation_interception/OWNERS index d7b0401..d7b0401 100644 --- a/content/components/navigation_interception/OWNERS +++ b/components/navigation_interception/OWNERS diff --git a/content/components/navigation_interception/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java b/components/navigation_interception/android/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java index 973ee27..4f3938e 100644 --- a/content/components/navigation_interception/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java +++ b/components/navigation_interception/android/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.content.components.navigation_interception; +package org.chromium.components.navigation_interception; import org.chromium.base.CalledByNative; diff --git a/content/components/navigation_interception/component_jni_registrar.cc b/components/navigation_interception/component_jni_registrar.cc index fe7fa56..9d2c30e 100644 --- a/content/components/navigation_interception/component_jni_registrar.cc +++ b/components/navigation_interception/component_jni_registrar.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/components/navigation_interception/component_jni_registrar.h" +#include "components/navigation_interception/component_jni_registrar.h" #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" -#include "content/components/navigation_interception/intercept_navigation_delegate.h" +#include "components/navigation_interception/intercept_navigation_delegate.h" -namespace content { +namespace components { static base::android::RegistrationMethod kComponentRegisteredMethods[] = { { "InterceptNavigationDelegate", RegisterInterceptNavigationDelegate }, @@ -19,4 +19,4 @@ bool RegisterNavigationInterceptionJni(JNIEnv* env) { kComponentRegisteredMethods, arraysize(kComponentRegisteredMethods)); } -} // namespace content +} // namespace components diff --git a/content/components/navigation_interception/component_jni_registrar.h b/components/navigation_interception/component_jni_registrar.h index 62ead61..ada59b2 100644 --- a/content/components/navigation_interception/component_jni_registrar.h +++ b/components/navigation_interception/component_jni_registrar.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ -#define CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ +#ifndef COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ +#define COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ #include <jni.h> -namespace content { +namespace components { // Register all JNI bindings necessary for the navigation_interception // component. bool RegisterNavigationInterceptionJni(JNIEnv* env); -} // namespace content +} // namespace components -#endif // CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ +#endif // COMPONENTS_NAVIGATION_INTERCEPTION_COMPONENT_JNI_REGISTRAR_H_ diff --git a/content/components/navigation_interception/intercept_navigation_delegate.cc b/components/navigation_interception/intercept_navigation_delegate.cc index 17f7324..a0cbc86 100644 --- a/content/components/navigation_interception/intercept_navigation_delegate.cc +++ b/components/navigation_interception/intercept_navigation_delegate.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/components/navigation_interception/intercept_navigation_delegate.h" +#include "components/navigation_interception/intercept_navigation_delegate.h" #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/callback.h" -#include "content/components/navigation_interception/intercept_navigation_resource_throttle.h" +#include "components/navigation_interception/intercept_navigation_resource_throttle.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" @@ -18,10 +18,11 @@ using base::android::ConvertUTF8ToJavaString; using base::android::ScopedJavaLocalRef; using content::BrowserThread; +using content::PageTransition; using content::RenderViewHost; using content::WebContents; -namespace content { +namespace components { namespace { @@ -112,4 +113,4 @@ bool RegisterInterceptNavigationDelegate(JNIEnv* env) { return RegisterNativesImpl(env); } -} // namespace content +} // namespace components diff --git a/content/components/navigation_interception/intercept_navigation_delegate.h b/components/navigation_interception/intercept_navigation_delegate.h index ab60a68..66a2518 100644 --- a/content/components/navigation_interception/intercept_navigation_delegate.h +++ b/components/navigation_interception/intercept_navigation_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ -#define CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ +#ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ +#define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ #include "base/android/jni_helper.h" #include "base/memory/scoped_ptr.h" @@ -21,7 +21,7 @@ namespace net { class URLRequest; } -namespace content { +namespace components { // Native side of the InterceptNavigationDelegate Java interface. // This is used to create a InterceptNavigationResourceThrottle that calls the @@ -57,13 +57,13 @@ class InterceptNavigationDelegate : public base::SupportsUserData::Data { virtual bool ShouldIgnoreNavigation(const GURL& url, bool is_post, bool has_user_gesture, - PageTransition transition_type); + content::PageTransition transition_type); private: JavaObjectWeakGlobalRef weak_jdelegate_; }; bool RegisterInterceptNavigationDelegate(JNIEnv* env); -} // namespace content +} // namespace components -#endif // CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ +#endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_DELEGATE_H_ diff --git a/content/components/navigation_interception/intercept_navigation_resource_throttle.cc b/components/navigation_interception/intercept_navigation_resource_throttle.cc index daf93a6..5f7c090 100644 --- a/content/components/navigation_interception/intercept_navigation_resource_throttle.cc +++ b/components/navigation_interception/intercept_navigation_resource_throttle.cc @@ -2,25 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/components/navigation_interception/intercept_navigation_resource_throttle.h" +#include "components/navigation_interception/intercept_navigation_resource_throttle.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" -#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_process_host.h" -#include "content/public/browser/resource_request_info.h" +#include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_controller.h" +#include "content/public/browser/resource_request_info.h" #include "content/public/common/page_transition_types.h" #include "content/public/common/referrer.h" #include "net/url_request/url_request.h" using content::BrowserThread; using content::ChildProcessSecurityPolicy; +using content::PageTransition; using content::Referrer; using content::RenderViewHost; using content::ResourceRequestInfo; -namespace content { +namespace components { namespace { @@ -134,4 +135,4 @@ void InterceptNavigationResourceThrottle::OnResultObtained( } } -} // namespace content +} // namespace components diff --git a/content/components/navigation_interception/intercept_navigation_resource_throttle.h b/components/navigation_interception/intercept_navigation_resource_throttle.h index cbff601..7bfe6fa 100644 --- a/content/components/navigation_interception/intercept_navigation_resource_throttle.h +++ b/components/navigation_interception/intercept_navigation_resource_throttle.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ -#define CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ +#ifndef COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ +#define COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ #include <string> @@ -23,18 +23,19 @@ namespace net { class URLRequest; } -namespace content { +namespace components { // This class allows the provider of the Callback to selectively ignore top // level navigations. class InterceptNavigationResourceThrottle : public content::ResourceThrottle { public: - typedef base::Callback<bool(content::RenderViewHost* /* source */, - const GURL& /* url */, - const content::Referrer& /*referrer*/, - bool /* is_post */, - bool /* has_user_gesture */, - PageTransition /* page transition type */)> + typedef base::Callback< + bool(content::RenderViewHost* /* source */, + const GURL& /* url */, + const content::Referrer& /*referrer*/, + bool /* is_post */, + bool /* has_user_gesture */, + content::PageTransition /* page transition type */)> CheckOnUIThreadCallback; InterceptNavigationResourceThrottle( @@ -57,6 +58,6 @@ class InterceptNavigationResourceThrottle : public content::ResourceThrottle { DISALLOW_COPY_AND_ASSIGN(InterceptNavigationResourceThrottle); }; -} // namespace content +} // namespace components -#endif // CONTENT_COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ +#endif // COMPONENTS_NAVIGATION_INTERCEPTION_INTERCEPT_NAVIGATION_RESOURCE_THROTTLE_H_ diff --git a/content/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc index 26964d4..8d9943c 100644 --- a/content/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc +++ b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc @@ -7,7 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/synchronization/waitable_event.h" -#include "content/components/navigation_interception/intercept_navigation_resource_throttle.h" +#include "components/navigation_interception/intercept_navigation_resource_throttle.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/resource_controller.h" @@ -30,7 +30,7 @@ using testing::Eq; using testing::Ne; using testing::Return; -namespace content { +namespace components { namespace { @@ -38,10 +38,8 @@ const char kTestUrl[] = "http://www.test.com/"; const char kUnsafeTestUrl[] = "about:crash"; void ContinueTestCase() { - BrowserThread::PostTask( - BrowserThread::UI, - FROM_HERE, - MessageLoop::QuitClosure()); + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure()); } } // namespace @@ -50,16 +48,17 @@ void ContinueTestCase() { class MockInterceptCallbackReceiver { public: - MOCK_METHOD6(ShouldIgnoreNavigation, bool(RenderViewHost* source, - const GURL& url, - const Referrer& referrer, - bool is_post, - bool has_user_gesture, - PageTransition page_transition)); + MOCK_METHOD6(ShouldIgnoreNavigation, + bool(content::RenderViewHost* source, + const GURL& url, + const content::Referrer& referrer, + bool is_post, + bool has_user_gesture, + content::PageTransition page_transition)); }; // MockResourceController ----------------------------------------------------- -class MockResourceController : public ResourceController { +class MockResourceController : public content::ResourceController { public: enum Status { UNKNOWN, @@ -103,14 +102,15 @@ class TestIOThreadState { MockInterceptCallbackReceiver* callback_receiver) : request_(url, NULL, resource_context_.GetRequestContext()), throttle_(NULL) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); if (render_process_id != MSG_ROUTING_NONE && render_view_id != MSG_ROUTING_NONE) { - ResourceRequestInfo::AllocateForTesting(&request_, - ResourceType::MAIN_FRAME, - &resource_context_, - render_process_id, - render_view_id); + content::ResourceRequestInfo::AllocateForTesting( + &request_, + ResourceType::MAIN_FRAME, + &resource_context_, + render_process_id, + render_view_id); } throttle_.reset(new InterceptNavigationResourceThrottle( &request_, @@ -121,7 +121,7 @@ class TestIOThreadState { } void ThrottleWillStartRequest(bool* defer) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); throttle_->WillStartRequest(defer); } @@ -136,7 +136,7 @@ class TestIOThreadState { } private: - MockResourceContext resource_context_; + content::MockResourceContext resource_context_; net::URLRequest request_; scoped_ptr<InterceptNavigationResourceThrottle> throttle_; MockResourceController throttle_controller_; @@ -145,12 +145,12 @@ class TestIOThreadState { // InterceptNavigationResourceThrottleTest ------------------------------------ class InterceptNavigationResourceThrottleTest - : public RenderViewHostTestHarness { + : public content::RenderViewHostTestHarness { public: InterceptNavigationResourceThrottleTest() : mock_callback_receiver_(new MockInterceptCallbackReceiver()), - ui_thread_(BrowserThread::UI, &message_loop_), - io_thread_(BrowserThread::IO), + ui_thread_(content::BrowserThread::UI, &message_loop_), + io_thread_(content::BrowserThread::IO), io_thread_state_(NULL) { } @@ -164,8 +164,8 @@ class InterceptNavigationResourceThrottleTest if (web_contents()) web_contents()->SetDelegate(NULL); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind(&base::DeletePointer<TestIOThreadState>, io_thread_state_)); @@ -182,7 +182,7 @@ class InterceptNavigationResourceThrottleTest int render_process_id, int render_view_id, bool* defer) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); TestIOThreadState* io_thread_state = new TestIOThreadState(url, render_process_id, render_view_id, request_method, mock_callback_receiver_.get()); @@ -212,8 +212,8 @@ class InterceptNavigationResourceThrottleTest ShouldIgnoreNavigation(rvh(), Eq(GURL(kTestUrl)), _, _, _, _)) .Times(1); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -231,8 +231,8 @@ class InterceptNavigationResourceThrottleTest void WaitForPreviouslyScheduledIoThreadWork() { base::WaitableEvent io_thread_work_done(true, false); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &base::WaitableEvent::Signal, @@ -241,8 +241,8 @@ class InterceptNavigationResourceThrottleTest } scoped_ptr<MockInterceptCallbackReceiver> mock_callback_receiver_; - TestBrowserThread ui_thread_; - TestBrowserThread io_thread_; + content::TestBrowserThread ui_thread_; + content::TestBrowserThread io_thread_; TestIOThreadState* io_thread_state_; }; @@ -273,8 +273,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, // The tested scenario is when the WebContents is deleted after the // ResourceThrottle has finished processing on the IO thread but before the // UI thread callback has been processed. - BrowserThread::PostTask( - BrowserThread::UI, + content::BrowserThread::PostTask( + content::BrowserThread::UI, FROM_HERE, base::Bind( &RenderViewHostTestHarness::DeleteContents, @@ -284,8 +284,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, ShouldIgnoreNavigation(_, _, _, _, _, _)) .Times(0); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -312,8 +312,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, RequestNotDeferredForRequestNotAssociatedWithARenderView) { bool defer = false; - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -342,8 +342,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, ShouldIgnoreNavigation(_, Ne(GURL(kUnsafeTestUrl)), _, _, _, _)) .Times(1); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -368,8 +368,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, _)) .WillOnce(Return(false)); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -394,8 +394,8 @@ TEST_F(InterceptNavigationResourceThrottleTest, _)) .WillOnce(Return(false)); - BrowserThread::PostTask( - BrowserThread::IO, + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, base::Bind( &InterceptNavigationResourceThrottleTest:: @@ -411,4 +411,4 @@ TEST_F(InterceptNavigationResourceThrottleTest, message_loop_.Run(); } -} // namespace content +} // namespace components diff --git a/components/test/DEPS b/components/test/DEPS new file mode 100644 index 0000000..c220939 --- /dev/null +++ b/components/test/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + "+content/public/test", + "+ui/compositor", +] diff --git a/components/test/run_all_unittests.cc b/components/test/run_all_unittests.cc index 2c8d29c..49032ba 100644 --- a/components/test/run_all_unittests.cc +++ b/components/test/run_all_unittests.cc @@ -2,8 +2,46 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/memory/scoped_ptr.h" #include "base/test/test_suite.h" +#include "content/public/test/test_content_client_initializer.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/compositor/compositor_setup.h" + +namespace components { + +class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { + public: + ComponentsUnitTestEventListener() {} + virtual ~ComponentsUnitTestEventListener() {} + + virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { + content_initializer_.reset(new content::TestContentClientInitializer()); + } + + virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { + content_initializer_.reset(); + } + + private: + scoped_ptr<content::TestContentClientInitializer> content_initializer_; + + DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); +}; + +} // namespace components int main(int argc, char** argv) { - return base::TestSuite(argc, argv).Run(); + base::TestSuite test_suite(argc, argv); + + // Mock out the compositor on platforms that use it. + ui::SetupTestCompositor(); + + // The listener will set up common test environment for all components unit + // tests. + testing::TestEventListeners& listeners = + testing::UnitTest::GetInstance()->listeners(); + listeners.Append(new components::ComponentsUnitTestEventListener()); + + return test_suite.Run(); } diff --git a/content/components/DEPS b/content/components/DEPS deleted file mode 100644 index 7d2de7d..0000000 --- a/content/components/DEPS +++ /dev/null @@ -1,12 +0,0 @@ -include_rules = [ - # Do not add chrome/ as an allowed include. Components under - # content/components MUST NOT depend on anything under src/chrome. - - # Subdirectories of content/components/component_name should add the - # parts of the Content API that they need, - # e.g. content/components/component_name/browser would add a - # "+content/public/browser" rule. - "-content", - "+content/public/common", - "+content/public/test", -] diff --git a/content/components/OWNERS b/content/components/OWNERS deleted file mode 100644 index c075174..0000000 --- a/content/components/OWNERS +++ /dev/null @@ -1,16 +0,0 @@ -# =============== BLINK BLINK BLINK =============== -# =============== BLINK BLINK BLINK =============== -# -# Warning: The decision has been made that the new home for components -# that depend on the Content Module and layers below it is -# src/components/. Full details at -# http://www.chromium.org/developers/design-documents/browser-components -# -# The components currently in src/content/components/ -# (this directory) will be moving there. Talk to joi@chromium.org for -# coordination if you are creating a new component. -# -# =============== BLINK BLINK BLINK =============== -# =============== BLINK BLINK BLINK =============== - -joi@chromium.org diff --git a/content/components/README b/content/components/README deleted file mode 100644 index 00266a7..0000000 --- a/content/components/README +++ /dev/null @@ -1,50 +0,0 @@ -=============== BLINK BLINK BLINK =============== -=============== BLINK BLINK BLINK =============== - -Warning: The decision has been made that the new home for components -that depend on the Content Module and layers below it is -src/components/. Full details at -http://www.chromium.org/developers/design-documents/browser-components - -The components currently in src/content/components/ -(this directory) will be moving there. Talk to joi@chromium.org for -coordination if you are creating a new component. - -=============== BLINK BLINK BLINK =============== -=============== BLINK BLINK BLINK =============== - - -This directory is for components that have the Content Module as the -uppermost layer they depend on. They may depend only on the Content -API (content/public) and on lower layers (e.g. base/, net/, ipc/ -etc.). - -These components are not part of the Content Module itself. They are -built in a separate .gyp file (content_components.gyp in this -directory). - -Components that have bits of code that need to live in different -processes (e.g. some code in the browser process, some in the renderer -process, etc.) should separate the code into different subdirectories. -Hence for a component named 'foo' you might end up with a structure -like the following: - -content/components/foo - DEPS, OWNERS, foo.gypi -content/components/foo/browser - code that needs the browser process -content/components/foo/common - for e.g. IPC constants and such -content/components/foo/renderer - code that needs renderer process - -These subdirectories should have DEPS files with the relevant -restrictions in place, e.g. only content/components/foo/browser should -be allowed to #include from content/public/browser. - -Note that there may also be an 'android' subdir, with a Java source -code structure underneath it where the package name is -org.chromium.content.component.foo, and with subdirs after 'foo' -to illustrate process, e.g. 'browser' or 'renderer': - -content/components/foo/android/OWNERS, DEPS -content/components/foo/android/java/src/org/chromium/content/component/foo/browser/ -content/components/foo/android/javatests/src/org/chromium/content/component/foo/browser/ - -Code in content/components/ should be placed in the content:: namespace. diff --git a/content/components/navigation_interception/DEPS b/content/components/navigation_interception/DEPS deleted file mode 100644 index 8ff1d13..0000000 --- a/content/components/navigation_interception/DEPS +++ /dev/null @@ -1,13 +0,0 @@ -include_rules = [ - "+content/public", - "+net/url_request", - - # For generated JNI includes - "+jni", -] - -specific_include_rules = { - '.*_(a-z)+test\.cc': [ - "+testing", - ], -} diff --git a/content/content.gyp b/content/content.gyp index 31b8335..0155546 100644 --- a/content/content.gyp +++ b/content/content.gyp @@ -33,7 +33,6 @@ ['OS != "ios"', { 'includes': [ '../build/win_precompile.gypi', - 'content_components_navigation_interception.gypi', 'content_shell.gypi', ], }], diff --git a/content/content_components_navigation_interception.gypi b/content/content_components_navigation_interception.gypi deleted file mode 100644 index f4d6b8b..0000000 --- a/content/content_components_navigation_interception.gypi +++ /dev/null @@ -1,72 +0,0 @@ -# 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. - -{ - 'targets': [ - { - 'target_name': 'navigation_interception', - 'type': 'static_library', - 'defines!': ['CONTENT_IMPLEMENTATION'], - 'dependencies': [ - '../base/base.gyp:base', - '../net/net.gyp:net', - 'content_browser', - 'content_common', - ], - 'include_dirs': [ - '..', - '../skia/config', - '<(SHARED_INTERMEDIATE_DIR)/navigation_interception', - - ], - 'sources': [ - 'components/navigation_interception/intercept_navigation_resource_throttle.cc', - 'components/navigation_interception/intercept_navigation_resource_throttle.h', - ], - 'conditions': [ - ['OS=="android"', { - 'dependencies': [ - 'navigation_interception_jni_headers', - ], - 'sources': [ - 'components/navigation_interception/component_jni_registrar.cc', - 'components/navigation_interception/component_jni_registrar.h', - 'components/navigation_interception/intercept_navigation_delegate.cc', - 'components/navigation_interception/intercept_navigation_delegate.h', - ], - }], - ], - }, - ], - 'conditions': [ - ['OS=="android"', { - 'targets': [ - { - 'target_name': 'navigation_interception_java', - 'type': 'none', - 'dependencies': [ - '../base/base.gyp:base', - ], - 'variables': { - 'package_name': 'navigation_interception', - 'java_in_dir': 'components/navigation_interception/java', - }, - 'includes': [ '../build/java.gypi' ], - }, - { - 'target_name': 'navigation_interception_jni_headers', - 'type': 'none', - 'sources': [ - 'components/navigation_interception/java/src/org/chromium/content/components/navigation_interception/InterceptNavigationDelegate.java', - ], - 'variables': { - 'jni_gen_dir': 'navigation_interception', - }, - 'includes': [ '../build/jni_generator.gypi' ], - }, - ], - }], - ], -} diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 2841260..719ff2b 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -360,7 +360,6 @@ 'common/sandbox_mac_unittest_helper.h', 'common/sandbox_mac_unittest_helper.mm', 'common/sandbox_mac_system_access_unittest.mm', - 'components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc', 'gpu/gpu_info_collector_unittest.cc', 'renderer/active_notification_tracker_unittest.cc', 'renderer/android/email_detector_unittest.cc', @@ -508,7 +507,6 @@ 'content_plugin', 'content_renderer', 'content_resources.gyp:content_resources', - 'navigation_interception', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '../gpu/gpu.gyp:gpu_unittest_utils', '../ipc/ipc.gyp:test_support_ipc', |