diff --git a/DEPS b/DEPS index 022a6703..9f33847 100644 --- a/DEPS +++ b/DEPS
@@ -40,11 +40,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '7f22511c1cb4e823e17446c54aa308a2f2203899', + 'skia_revision': '4a0f180211dbcf5c400f797aafe6cc3ff6fc021f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '6a79f5845673d1acf062be74e4bd33520033c0e7', + 'v8_revision': '8ff4cb255b571e8d39ad09deb32e22fbd4a19fe8', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other. @@ -214,7 +214,7 @@ Var('chromium_git') + '/external/github.com/sctplab/usrsctp' + '@' + '2f6478eb8d40f1766a96b5b033ed26c0c2244589', 'src/third_party/libsrtp': - Var('chromium_git') + '/chromium/deps/libsrtp.git' + '@' + 'ccf84786f8ef803cb9c75e919e5a3976b9f5a672', + Var('chromium_git') + '/chromium/deps/libsrtp.git' + '@' + '1d45b8e599dc2db6ea3ae22dbc94a8c504652423', 'src/third_party/yasm/source/patched-yasm': Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + '7da28c6c7c6a1387217352ce02b31754deb54d2a',
diff --git a/android_webview/test/embedded_test_server/BUILD.gn b/android_webview/test/embedded_test_server/BUILD.gn index f9d6dbf9..e9b2f3af 100644 --- a/android_webview/test/embedded_test_server/BUILD.gn +++ b/android_webview/test/embedded_test_server/BUILD.gn
@@ -57,8 +57,6 @@ ":aw_java_test_native_support", "//net:test_support", ] - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - configs += [ "//build/config/android:hide_all_but_jni" ] } android_apk("aw_net_test_support_apk") {
diff --git a/ash/metrics/user_metrics_action.h b/ash/metrics/user_metrics_action.h index 82714330..d713c113 100644 --- a/ash/metrics/user_metrics_action.h +++ b/ash/metrics/user_metrics_action.h
@@ -8,6 +8,8 @@ namespace ash { // Ash-owned user metrics. +// DEPRECATED: Use base::RecordAction(base::UserMetricsAction("my_action")) +// instead of adding things here. enum UserMetricsAction { UMA_ACCEL_EXIT_FIRST_Q, UMA_ACCEL_EXIT_SECOND_Q, @@ -99,8 +101,6 @@ UMA_STATUS_AREA_ENABLE_TAP_DRAGGING, UMA_STATUS_AREA_ENABLE_WIFI, UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD, - UMA_STATUS_AREA_IME_SHOW_DETAILED, - UMA_STATUS_AREA_IME_SWITCH_MODE, UMA_STATUS_AREA_MENU_OPENED, UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED, UMA_STATUS_AREA_NETWORK_SETTINGS_OPENED, @@ -162,6 +162,8 @@ // Closing a window in overview mode by pressing Ctrl+w shortcut. UMA_WINDOW_OVERVIEW_CLOSE_KEY, + + // DEPRECATED: Do not add new values. See top of file. }; } // namespace ash
diff --git a/ash/metrics/user_metrics_recorder.cc b/ash/metrics/user_metrics_recorder.cc index 83c6e9a..1734a3d 100644 --- a/ash/metrics/user_metrics_recorder.cc +++ b/ash/metrics/user_metrics_recorder.cc
@@ -467,12 +467,6 @@ case UMA_STATUS_AREA_ENABLE_WIFI: RecordAction(UserMetricsAction("StatusArea_Network_WifiEnabled")); break; - case UMA_STATUS_AREA_IME_SHOW_DETAILED: - RecordAction(UserMetricsAction("StatusArea_IME_Detailed")); - break; - case UMA_STATUS_AREA_IME_SWITCH_MODE: - RecordAction(UserMetricsAction("StatusArea_IME_SwitchMode")); - break; case UMA_STATUS_AREA_MENU_OPENED: RecordAction(UserMetricsAction("StatusArea_MenuOpened")); break;
diff --git a/ash/system/ime/tray_ime_chromeos.cc b/ash/system/ime/tray_ime_chromeos.cc index a5b3e82..900c115 100644 --- a/ash/system/ime/tray_ime_chromeos.cc +++ b/ash/system/ime/tray_ime_chromeos.cc
@@ -8,7 +8,6 @@ #include <vector> #include "ash/ime/ime_controller.h" -#include "ash/metrics/user_metrics_recorder.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/shell.h" #include "ash/strings/grit/ash_strings.h" @@ -25,6 +24,7 @@ #include "ash/system/tray/tri_view.h" #include "ash/system/tray_accessibility.h" #include "base/logging.h" +#include "base/metrics/user_metrics.h" #include "base/strings/utf_string_conversions.h" #include "ui/accessibility/ax_enums.h" #include "ui/accessibility/ax_node_data.h" @@ -128,8 +128,7 @@ } void ShowSettings() { - Shell::Get()->metrics()->RecordUserMetricsAction( - UMA_STATUS_AREA_IME_SHOW_DETAILED); + base::RecordAction(base::UserMetricsAction("StatusArea_IME_Detailed")); Shell::Get()->system_tray_controller()->ShowIMESettings(); if (owner()->system_tray()) owner()->system_tray()->CloseSystemBubble();
diff --git a/ash/system/ime_menu/ime_list_view.cc b/ash/system/ime_menu/ime_list_view.cc index 10fcbb3..a753ee9 100644 --- a/ash/system/ime_menu/ime_list_view.cc +++ b/ash/system/ime_menu/ime_list_view.cc
@@ -6,7 +6,6 @@ #include "ash/ime/ime_controller.h" #include "ash/ime/ime_switch_type.h" -#include "ash/metrics/user_metrics_recorder.h" #include "ash/public/interfaces/ime_info.mojom.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/shell.h" @@ -21,6 +20,7 @@ #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tri_view.h" #include "base/metrics/histogram_macros.h" +#include "base/metrics/user_metrics.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -296,8 +296,7 @@ ImeController* ime_controller = Shell::Get()->ime_controller(); std::map<views::View*, std::string>::const_iterator ime = ime_map_.find(view); if (ime != ime_map_.end()) { - Shell::Get()->metrics()->RecordUserMetricsAction( - UMA_STATUS_AREA_IME_SWITCH_MODE); + base::RecordAction(base::UserMetricsAction("StatusArea_IME_SwitchMode")); std::string ime_id = ime->second; last_selected_item_id_ = ime_id; ime_controller->SwitchImeById(ime_id, false /* show_message */);
diff --git a/ash/system/ime_menu/ime_menu_tray.cc b/ash/system/ime_menu/ime_menu_tray.cc index fa6a839..0942091 100644 --- a/ash/system/ime_menu/ime_menu_tray.cc +++ b/ash/system/ime_menu/ime_menu_tray.cc
@@ -8,7 +8,6 @@ #include "ash/accessibility_delegate.h" #include "ash/ash_constants.h" #include "ash/ime/ime_controller.h" -#include "ash/metrics/user_metrics_recorder.h" #include "ash/root_window_controller.h" #include "ash/session/session_controller.h" #include "ash/shelf/shelf.h" @@ -24,6 +23,7 @@ #include "ash/system/tray/tray_popup_utils.h" #include "ash/system/tray/tray_utils.h" #include "base/metrics/histogram_macros.h" +#include "base/metrics/user_metrics.h" #include "base/strings/utf_string_conversions.h" #include "components/session_manager/session_manager_types.h" #include "ui/base/ime/chromeos/input_method_manager.h" @@ -57,8 +57,7 @@ // Shows language and input settings page. void ShowIMESettings() { - Shell::Get()->metrics()->RecordUserMetricsAction( - UMA_STATUS_AREA_IME_SHOW_DETAILED); + base::RecordAction(base::UserMetricsAction("StatusArea_IME_Detailed")); Shell::Get()->system_tray_controller()->ShowIMESettings(); }
diff --git a/base/android/jni_generator/SampleForTests_jni.golden b/base/android/jni_generator/SampleForTests_jni.golden index e50583ab..7b384252 100644 --- a/base/android/jni_generator/SampleForTests_jni.golden +++ b/base/android/jni_generator/SampleForTests_jni.golden
@@ -482,35 +482,24 @@ }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -} // namespace android -} // namespace base - -JNI_REGISTRATION_EXPORT bool - RegisterNative_org_chromium_example_jni_1generator_SampleForTests(JNIEnv* - env) { - - const int kMethodsInnerClassSize = - arraysize(base::android::kMethodsInnerClass); + const int kMethodsInnerClassSize = arraysize(kMethodsInnerClass); if (env->RegisterNatives(InnerClass_clazz(env), - base::android::kMethodsInnerClass, + kMethodsInnerClass, kMethodsInnerClassSize) < 0) { jni_generator::HandleRegistrationError( env, InnerClass_clazz(env), __FILE__); return false; } - const int kMethodsSampleForTestsSize = - arraysize(base::android::kMethodsSampleForTests); + const int kMethodsSampleForTestsSize = arraysize(kMethodsSampleForTests); if (env->RegisterNatives(SampleForTests_clazz(env), - base::android::kMethodsSampleForTests, + kMethodsSampleForTests, kMethodsSampleForTestsSize) < 0) { jni_generator::HandleRegistrationError( env, SampleForTests_clazz(env), __FILE__); @@ -520,4 +509,7 @@ return true; } +} // namespace android +} // namespace base + #endif // org_chromium_example_jni_generator_SampleForTests_JNI
diff --git a/base/android/jni_generator/jni_generator.py b/base/android/jni_generator/jni_generator.py index 8249fc9e..3818009 100755 --- a/base/android/jni_generator/jni_generator.py +++ b/base/android/jni_generator/jni_generator.py
@@ -401,7 +401,7 @@ def IsMainDexJavaClass(contents): - """Returns True if the class is annotated with "@MainDex", False if not. + """Returns "true" if the class is annotated with "@MainDex", "false" if not. JNI registration doesn't always need to be completed for non-browser processes since most Java code is only used by the browser process. Classes that are @@ -409,17 +409,8 @@ to force JNI registration. """ re_maindex = re.compile(r'@MainDex[\s\S]*class({|[\s\S]*{)') - return bool(re.search(re_maindex, contents)) - - -def GetBinaryClassName(fully_qualified_class): - """Returns a string concatenating the Java package and class.""" - return fully_qualified_class.replace('_', '_1').replace('/', '_') - - -def GetRegistrationFunctionName(fully_qualified_class): - """Returns the register name with a given class.""" - return 'RegisterNative_' + GetBinaryClassName(fully_qualified_class) + found = re.search(re_maindex, contents) + return 'true' if found else 'false' def GetStaticCastForReturnType(return_type): @@ -629,6 +620,7 @@ is_constructor=True)] self.called_by_natives = MangleCalledByNatives(self.jni_params, self.called_by_natives) + self.constant_fields = [] re_constant_field = re.compile('.*?public static final int (?P<name>.*?);') re_constant_field_value = re.compile( @@ -681,12 +673,13 @@ jni_namespace = ExtractJNINamespace(contents) or options.namespace natives = ExtractNatives(contents, options.ptr_type) called_by_natives = ExtractCalledByNatives(self.jni_params, contents) + maindex = IsMainDexJavaClass(contents) if len(natives) == 0 and len(called_by_natives) == 0: raise SyntaxError('Unable to find any JNI methods for %s.' % fully_qualified_class) inl_header_file_generator = InlHeaderFileGenerator( jni_namespace, fully_qualified_class, natives, called_by_natives, [], - self.jni_params, options) + self.jni_params, options, maindex) self.content = inl_header_file_generator.GetContent() @classmethod @@ -722,7 +715,8 @@ """Generates an inline header file for JNI integration.""" def __init__(self, namespace, fully_qualified_class, natives, - called_by_natives, constant_fields, jni_params, options): + called_by_natives, constant_fields, jni_params, options, + maindex='false'): self.namespace = namespace self.fully_qualified_class = fully_qualified_class self.class_name = self.fully_qualified_class.split('/')[-1] @@ -730,6 +724,7 @@ self.called_by_natives = called_by_natives self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI' self.constant_fields = constant_fields + self.maindex = maindex self.jni_params = jni_params self.options = options @@ -771,9 +766,8 @@ // Step 3: RegisterNatives. $JNI_NATIVE_METHODS -$REGISTER_NATIVES_EMPTY -$CLOSE_NAMESPACE $REGISTER_NATIVES +$CLOSE_NAMESPACE #endif // ${HEADER_GUARD} """) @@ -785,9 +779,8 @@ 'METHOD_STUBS': self.GetMethodStubsString(), 'OPEN_NAMESPACE': self.GetOpenNamespaceString(), 'JNI_NATIVE_METHODS': self.GetJNINativeMethodsString(), - 'REGISTER_NATIVES_EMPTY': self.GetOriginalRegisterNativesString(), - 'CLOSE_NAMESPACE': self.GetCloseNamespaceString(), 'REGISTER_NATIVES': self.GetRegisterNativesString(), + 'CLOSE_NAMESPACE': self.GetCloseNamespaceString(), 'HEADER_GUARD': self.header_guard, 'INCLUDES': self.GetIncludesString(), } @@ -836,19 +829,14 @@ return '\n'.join(ret) def SubstituteNativeMethods(self, template): - """Substitutes NAMESPACE, JAVA_CLASS and KMETHODS in the provided - template.""" + """Substitutes JAVA_CLASS and KMETHODS in the provided template.""" ret = [] all_classes = self.GetUniqueClasses(self.natives) all_classes[self.class_name] = self.fully_qualified_class for clazz in all_classes: kmethods = self.GetKMethodsString(clazz) - namespace_str = '' - if self.namespace: - namespace_str = self.namespace + '::' if kmethods: - values = {'NAMESPACE': namespace_str, - 'JAVA_CLASS': clazz, + values = {'JAVA_CLASS': clazz, 'KMETHODS': kmethods} ret += [template.substitute(values)] if not ret: return '' @@ -865,38 +853,32 @@ """) return self.SubstituteNativeMethods(template) - # TODO(agrieve): Remove this function when deleting original registers. - # https://crbug.com/683256. - def GetOriginalRegisterNativesString(self): - """Return the code for original RegisterNatives""" - natives = self.GetRegisterNativesImplString() - if not natives: - return '' - - return """ -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. -static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} -""" - def GetRegisterNativesString(self): """Returns the code for RegisterNatives.""" natives = self.GetRegisterNativesImplString() if not natives: return '' + template = Template("""\ -JNI_REGISTRATION_EXPORT bool ${REGISTER_NAME}(JNIEnv* env) { +${REGISTER_NATIVES_SIGNATURE} { +${EARLY_EXIT} ${NATIVES} return true; } """) - values = { - 'REGISTER_NAME': - GetRegistrationFunctionName(self.fully_qualified_class), - 'NATIVES': natives - } + signature = 'static bool RegisterNativesImpl(JNIEnv* env)' + early_exit = '' + if self.options.native_exports_optional: + early_exit = """\ + if (jni_generator::ShouldSkipJniRegistration(%s)) + return true; +""" % self.maindex + + values = {'REGISTER_NATIVES_SIGNATURE': signature, + 'EARLY_EXIT': early_exit, + 'NATIVES': natives, + } + return template.substitute(values) def GetRegisterNativesImplString(self): @@ -905,11 +887,10 @@ return '' template = Template("""\ - const int kMethods${JAVA_CLASS}Size = - arraysize(${NAMESPACE}kMethods${JAVA_CLASS}); + const int kMethods${JAVA_CLASS}Size = arraysize(kMethods${JAVA_CLASS}); if (env->RegisterNatives(${JAVA_CLASS}_clazz(env), - ${NAMESPACE}kMethods${JAVA_CLASS}, + kMethods${JAVA_CLASS}, kMethods${JAVA_CLASS}Size) < 0) { jni_generator::HandleRegistrationError( env, ${JAVA_CLASS}_clazz(env), __FILE__); @@ -993,7 +974,7 @@ """ template = Template("Java_${JAVA_NAME}_native${NAME}") - java_name = GetBinaryClassName(self.fully_qualified_class) + java_name = self.fully_qualified_class.replace('_', '_1').replace('/', '_') if native.java_class_name: java_name += '_00024' + native.java_class_name @@ -1333,21 +1314,19 @@ print e sys.exit(1) if output_file: - WriteOutput(output_file, content) + if not os.path.exists(os.path.dirname(os.path.abspath(output_file))): + os.makedirs(os.path.dirname(os.path.abspath(output_file))) + if options.optimize_generation and os.path.exists(output_file): + with file(output_file, 'r') as f: + existing_content = f.read() + if existing_content == content: + return + with file(output_file, 'w') as f: + f.write(content) else: print content -def WriteOutput(output_file, content): - if os.path.exists(output_file): - with open(output_file) as f: - existing_content = f.read() - if existing_content == content: - return - with open(output_file, 'w') as f: - f.write(content) - - def GetScriptName(): script_components = os.path.abspath(sys.argv[0]).split(os.path.sep) base_index = 0 @@ -1384,6 +1363,10 @@ option_parser.add_option('--output_dir', help='The output directory. Must be used with ' '--input') + option_parser.add_option('--optimize_generation', type="int", + default=0, help='Whether we should optimize JNI ' + 'generation by not regenerating files if they have ' + 'not changed.') option_parser.add_option('--script_name', default=GetScriptName(), help='The name of this script in the generated ' 'header.')
diff --git a/base/android/jni_generator/jni_generator_helper.h b/base/android/jni_generator/jni_generator_helper.h index 53629a657..3062806 100644 --- a/base/android/jni_generator/jni_generator_helper.h +++ b/base/android/jni_generator/jni_generator_helper.h
@@ -30,13 +30,6 @@ #define JNI_GENERATOR_EXPORT extern "C" __attribute__((visibility("default"))) #endif -// Used to export JNI registration functions. -#if defined(COMPONENT_BUILD) -#define JNI_REGISTRATION_EXPORT __attribute__((visibility("default"))) -#else -#define JNI_REGISTRATION_EXPORT -#endif - namespace jni_generator { inline void HandleRegistrationError(JNIEnv* env, @@ -49,14 +42,12 @@ base::android::CheckException(env); } -// TODO(estevenson): Remove this function since all natives are registered -// together. Currently gvr-android-sdk stil calls it. -// https://crbug.com/664306. inline bool ShouldSkipJniRegistration(bool is_maindex_class) { switch (base::android::GetJniRegistrationType()) { case base::android::ALL_JNI_REGISTRATION: return false; case base::android::NO_JNI_REGISTRATION: + // TODO(estevenson): Change this to a DCHECK. return true; case base::android::SELECTIVE_JNI_REGISTRATION: return !is_maindex_class;
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py index 41e617f..d667a47 100755 --- a/base/android/jni_generator/jni_generator_tests.py +++ b/base/android/jni_generator/jni_generator_tests.py
@@ -967,6 +967,33 @@ test_options) self.assertGoldenTextEquals(h.GetContent()) + def testMainDexFile(self): + test_data = """ + package org.chromium.example.jni_generator; + + @MainDex + class Test { + private static native int nativeStaticMethod(long nativeTest, int arg1); + } + """ + options = TestOptions() + jni_from_java = jni_generator.JNIFromJavaSource( + test_data, 'org/chromium/foo/Bar', options) + self.assertGoldenTextEquals(jni_from_java.GetContent()) + + def testNonMainDexFile(self): + test_data = """ + package org.chromium.example.jni_generator; + + class Test { + private static native int nativeStaticMethod(long nativeTest, int arg1); + } + """ + options = TestOptions() + jni_from_java = jni_generator.JNIFromJavaSource( + test_data, 'org/chromium/foo/Bar', options) + self.assertGoldenTextEquals(jni_from_java.GetContent()) + def testMainDexAnnotation(self): mainDexEntries = [ '@MainDex public class Test {', @@ -994,7 +1021,7 @@ '@MainDex public class Test extends Testable<java.io.Serializable> {', ] for entry in mainDexEntries: - self.assertEquals(True, IsMainDexJavaClass(entry)) + self.assertEquals("true", IsMainDexJavaClass(entry)) def testNoMainDexAnnotation(self): noMainDexEntries = [ @@ -1004,7 +1031,7 @@ 'public class Test extends BaseTest {' ] for entry in noMainDexEntries: - self.assertEquals(False, IsMainDexJavaClass(entry)) + self.assertEquals("false", IsMainDexJavaClass(entry)) def testNativeExportsOnlyOption(self): test_data = """
diff --git a/base/android/jni_generator/jni_registration_generator.py b/base/android/jni_generator/jni_registration_generator.py deleted file mode 100755 index febb5b7..0000000 --- a/base/android/jni_generator/jni_registration_generator.py +++ /dev/null
@@ -1,179 +0,0 @@ -#!/usr/bin/env python -# Copyright 2017 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. - -"""Generate JNI registration entry points - -Creates a header file with two static functions: RegisterMainDexNatives() and -RegisterNonMainDexNatives(). Together, these will use manual JNI registration -to register all native methods that exist within an application.""" - -import argparse -import jni_generator -import os -import string -import sys -from util import build_utils - - -def GenerateJNIHeader(java_file_paths, output_file, args): - """Generate a header file including two registration functions. - - Forward declares all JNI registration functions created by jni_generator.py. - Calls the functions in RegisterMainDexNatives() if they are main dex. And - calls them in RegisterNonMainDexNatives() if they are non-main dex. - - Args: - java_file_paths: A list of java file paths. - output_file: A relative path to output file. - args: All input arguments. - """ - registration_dict = { - 'FORWARD_DECLARATIONS': '', - 'REGISTER_MAIN_DEX_NATIVES': '', - 'REGISTER_NON_MAIN_DEX_NATIVES': '' - } - # Sort the file list to make sure the order is deterministic. - java_file_paths.sort() - for path in java_file_paths: - if path in args.no_register_java: - continue - with open(path) as f: - contents = f.read() - natives = jni_generator.ExtractNatives(contents, 'long') - if len(natives) == 0: - continue - fully_qualified_class = jni_generator.ExtractFullyQualifiedJavaClassName( - path, contents) - main_dex = jni_generator.IsMainDexJavaClass(contents) - header_generator = HeaderGenerator( - fully_qualified_class, registration_dict, main_dex) - registration_dict = header_generator.GetContent() - - header_content = CreateFromDict(registration_dict) - if output_file: - jni_generator.WriteOutput(output_file, header_content) - else: - print header_content - - -def CreateFromDict(registration_dict): - """Returns the content of the header file.""" - - template = string.Template("""\ -// Copyright 2017 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. - - -// This file is autogenerated by -// base/android/jni_generator/jni_registration_generator.py -// Please do not change its content. - -#ifndef HEADER_GUARD -#define HEADER_GUARD - -#include <jni.h> - -#include "base/android/jni_generator/jni_generator_helper.h" -#include "base/android/jni_int_wrapper.h" - -// Step 1: Forward declaration. -${FORWARD_DECLARATIONS} - -// Step 2: Main dex and non-main dex registration functions. - -bool RegisterMainDexNatives(JNIEnv* env) { -${REGISTER_MAIN_DEX_NATIVES} - - return true; -} - -bool RegisterNonMainDexNatives(JNIEnv* env) { -${REGISTER_NON_MAIN_DEX_NATIVES} - - return true; -} - -#endif // HEADER_GUARD -""") - if len(registration_dict['FORWARD_DECLARATIONS']) == 0: - return '' - return jni_generator.WrapOutput(template.substitute(registration_dict)) - - -class HeaderGenerator(object): - """Generates an inline header file for JNI registration.""" - - def __init__(self, fully_qualified_class, registration_dict, main_dex): - self.fully_qualified_class = fully_qualified_class - self.class_name = self.fully_qualified_class.split('/')[-1] - self.registration_dict = registration_dict - self.main_dex = main_dex - - def GetContent(self): - self._AddForwardDeclaration() - self._AddRegisterNatives() - return self.registration_dict - - def _AddForwardDeclaration(self): - """Add the content of the forward declaration to the dictionary.""" - template = string.Template('JNI_REGISTRATION_EXPORT bool ${METHOD_NAME}(' - 'JNIEnv* env);\n') - value = { - 'METHOD_NAME': - jni_generator.GetRegistrationFunctionName( - self.fully_qualified_class) - } - self.registration_dict['FORWARD_DECLARATIONS'] += template.substitute(value) - - def _AddRegisterNatives(self): - """Add the body of the RegisterNativesImpl method to the dictionary.""" - template = string.Template(""" -if (!${REGISTER_NAME}(env)) - return false; -""") - value = { - 'REGISTER_NAME': - jni_generator.GetRegistrationFunctionName( - self.fully_qualified_class) - } - register_body = template.substitute(value) - if self.main_dex: - self.registration_dict['REGISTER_MAIN_DEX_NATIVES'] += register_body - else: - self.registration_dict['REGISTER_NON_MAIN_DEX_NATIVES'] += register_body - - -def main(argv): - arg_parser = argparse.ArgumentParser() - build_utils.AddDepfileOption(arg_parser) - - arg_parser.add_argument('--sources_files', - help='A list of .sources files which contain Java ' - 'file paths. Must be used with --output.') - arg_parser.add_argument('--output', - help='The output file path.') - arg_parser.add_argument('--no_register_java', - help='A list of Java files which should be ignored ' - 'by the parser.') - args = arg_parser.parse_args(build_utils.ExpandFileArgs(argv[1:])) - args.sources_files = build_utils.ParseGnList(args.sources_files) - - if args.sources_files: - java_file_paths = [] - for f in args.sources_files: - # java_file_paths stores each Java file path as a string. - java_file_paths += build_utils.ReadSourcesList(f) - else: - print '\nError: Must specify --sources_files.' - return 1 - output_file = args.output - GenerateJNIHeader(java_file_paths, output_file, args) - - if args.depfile: - build_utils.WriteDepfile(args.depfile, output_file) - -if __name__ == '__main__': - sys.exit(main(sys.argv))
diff --git a/base/android/jni_generator/testInnerClassNatives.golden b/base/android/jni_generator/testInnerClassNatives.golden index 363f916..20b8830 100644 --- a/base/android/jni_generator/testInnerClassNatives.golden +++ b/base/android/jni_generator/testInnerClassNatives.golden
@@ -51,16 +51,11 @@ }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_TestJni(JNIEnv* env) { - - const int kMethodsMyInnerClassSize = - arraysize(kMethodsMyInnerClass); + const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); if (env->RegisterNatives(MyInnerClass_clazz(env), kMethodsMyInnerClass,
diff --git a/base/android/jni_generator/testInnerClassNativesBothInnerAndOuter.golden b/base/android/jni_generator/testInnerClassNativesBothInnerAndOuter.golden index 6c07b58..67352e7 100644 --- a/base/android/jni_generator/testInnerClassNativesBothInnerAndOuter.golden +++ b/base/android/jni_generator/testInnerClassNativesBothInnerAndOuter.golden
@@ -67,13 +67,9 @@ "I", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeInit) }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} - -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_TestJni(JNIEnv* env) { + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; const int kMethodsMyOtherInnerClassSize = arraysize(kMethodsMyOtherInnerClass); @@ -86,8 +82,7 @@ return false; } - const int kMethodsTestJniSize = - arraysize(kMethodsTestJni); + const int kMethodsTestJniSize = arraysize(kMethodsTestJni); if (env->RegisterNatives(TestJni_clazz(env), kMethodsTestJni,
diff --git a/base/android/jni_generator/testInnerClassNativesMultiple.golden b/base/android/jni_generator/testInnerClassNativesMultiple.golden index add5ac9..7807efa 100644 --- a/base/android/jni_generator/testInnerClassNativesMultiple.golden +++ b/base/android/jni_generator/testInnerClassNativesMultiple.golden
@@ -74,13 +74,9 @@ }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} - -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_TestJni(JNIEnv* env) { + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; const int kMethodsMyOtherInnerClassSize = arraysize(kMethodsMyOtherInnerClass); @@ -93,8 +89,7 @@ return false; } - const int kMethodsMyInnerClassSize = - arraysize(kMethodsMyInnerClass); + const int kMethodsMyInnerClassSize = arraysize(kMethodsMyInnerClass); if (env->RegisterNatives(MyInnerClass_clazz(env), kMethodsMyInnerClass,
diff --git a/base/android/jni_generator/testMainDexFile.golden b/base/android/jni_generator/testMainDexFile.golden new file mode 100644 index 0000000..cbb2a7d --- /dev/null +++ b/base/android/jni_generator/testMainDexFile.golden
@@ -0,0 +1,67 @@ +// Copyright 2014 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. + +// This file is autogenerated by +// base/android/jni_generator/jni_generator.py +// For +// org/chromium/foo/Bar + +#ifndef org_chromium_foo_Bar_JNI +#define org_chromium_foo_Bar_JNI + +#include <jni.h> + +#include "base/android/jni_generator/jni_generator_helper.h" + +#include "base/android/jni_int_wrapper.h" + +// Step 1: forward declarations. +namespace { +const char kBarClassPath[] = "org/chromium/foo/Bar"; +// Leaking this jclass as we cannot use LazyInstance from some threads. +base::subtle::AtomicWord g_Bar_clazz __attribute__((unused)) = 0; +#define Bar_clazz(env) base::android::LazyGetClass(env, kBarClassPath, &g_Bar_clazz) + +} // namespace + +// Step 2: method stubs. +JNI_GENERATOR_EXPORT jint Java_org_chromium_foo_Bar_nativeStaticMethod(JNIEnv* + env, jobject jcaller, + jlong nativeTest, + jint arg1) { + Test* native = reinterpret_cast<Test*>(nativeTest); + CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); + return native->StaticMethod(env, base::android::JavaParamRef<jobject>(env, + jcaller), arg1); +} + +// Step 3: RegisterNatives. + +static const JNINativeMethod kMethodsBar[] = { + { "nativeStaticMethod", +"(" +"J" +"I" +")" +"I", reinterpret_cast<void*>(Java_org_chromium_foo_Bar_nativeStaticMethod) }, +}; + +static bool RegisterNativesImpl(JNIEnv* env) { + if (jni_generator::ShouldSkipJniRegistration(true)) + return true; + + const int kMethodsBarSize = arraysize(kMethodsBar); + + if (env->RegisterNatives(Bar_clazz(env), + kMethodsBar, + kMethodsBarSize) < 0) { + jni_generator::HandleRegistrationError( + env, Bar_clazz(env), __FILE__); + return false; + } + + return true; +} + +#endif // org_chromium_foo_Bar_JNI
diff --git a/base/android/jni_generator/testMultipleJNIAdditionalImport.golden b/base/android/jni_generator/testMultipleJNIAdditionalImport.golden index 03aac48e..0eecb5a 100644 --- a/base/android/jni_generator/testMultipleJNIAdditionalImport.golden +++ b/base/android/jni_generator/testMultipleJNIAdditionalImport.golden
@@ -75,16 +75,11 @@ "V", reinterpret_cast<void*>(Java_org_chromium_foo_Foo_nativeDoSomething) }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_foo_Foo(JNIEnv* env) { - - const int kMethodsFooSize = - arraysize(kMethodsFoo); + const int kMethodsFooSize = arraysize(kMethodsFoo); if (env->RegisterNatives(Foo_clazz(env), kMethodsFoo,
diff --git a/base/android/jni_generator/testNatives.golden b/base/android/jni_generator/testNatives.golden index 0bfbe04..3362c928 100644 --- a/base/android/jni_generator/testNatives.golden +++ b/base/android/jni_generator/testNatives.golden
@@ -320,16 +320,11 @@ }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_TestJni(JNIEnv* env) { - - const int kMethodsTestJniSize = - arraysize(kMethodsTestJni); + const int kMethodsTestJniSize = arraysize(kMethodsTestJni); if (env->RegisterNatives(TestJni_clazz(env), kMethodsTestJni,
diff --git a/base/android/jni_generator/testNativesLong.golden b/base/android/jni_generator/testNativesLong.golden index 201a066..ec029ce3 100644 --- a/base/android/jni_generator/testNativesLong.golden +++ b/base/android/jni_generator/testNativesLong.golden
@@ -46,16 +46,11 @@ "V", reinterpret_cast<void*>(Java_org_chromium_TestJni_nativeDestroy) }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_TestJni(JNIEnv* env) { - - const int kMethodsTestJniSize = - arraysize(kMethodsTestJni); + const int kMethodsTestJniSize = arraysize(kMethodsTestJni); if (env->RegisterNatives(TestJni_clazz(env), kMethodsTestJni,
diff --git a/base/android/jni_generator/testNonMainDexFile.golden b/base/android/jni_generator/testNonMainDexFile.golden new file mode 100644 index 0000000..533241e --- /dev/null +++ b/base/android/jni_generator/testNonMainDexFile.golden
@@ -0,0 +1,67 @@ +// Copyright 2014 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. + +// This file is autogenerated by +// base/android/jni_generator/jni_generator.py +// For +// org/chromium/foo/Bar + +#ifndef org_chromium_foo_Bar_JNI +#define org_chromium_foo_Bar_JNI + +#include <jni.h> + +#include "base/android/jni_generator/jni_generator_helper.h" + +#include "base/android/jni_int_wrapper.h" + +// Step 1: forward declarations. +namespace { +const char kBarClassPath[] = "org/chromium/foo/Bar"; +// Leaking this jclass as we cannot use LazyInstance from some threads. +base::subtle::AtomicWord g_Bar_clazz __attribute__((unused)) = 0; +#define Bar_clazz(env) base::android::LazyGetClass(env, kBarClassPath, &g_Bar_clazz) + +} // namespace + +// Step 2: method stubs. +JNI_GENERATOR_EXPORT jint Java_org_chromium_foo_Bar_nativeStaticMethod(JNIEnv* + env, jobject jcaller, + jlong nativeTest, + jint arg1) { + Test* native = reinterpret_cast<Test*>(nativeTest); + CHECK_NATIVE_PTR(env, jcaller, native, "StaticMethod", 0); + return native->StaticMethod(env, base::android::JavaParamRef<jobject>(env, + jcaller), arg1); +} + +// Step 3: RegisterNatives. + +static const JNINativeMethod kMethodsBar[] = { + { "nativeStaticMethod", +"(" +"J" +"I" +")" +"I", reinterpret_cast<void*>(Java_org_chromium_foo_Bar_nativeStaticMethod) }, +}; + +static bool RegisterNativesImpl(JNIEnv* env) { + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; + + const int kMethodsBarSize = arraysize(kMethodsBar); + + if (env->RegisterNatives(Bar_clazz(env), + kMethodsBar, + kMethodsBarSize) < 0) { + jni_generator::HandleRegistrationError( + env, Bar_clazz(env), __FILE__); + return false; + } + + return true; +} + +#endif // org_chromium_foo_Bar_JNI
diff --git a/base/android/jni_generator/testSingleJNIAdditionalImport.golden b/base/android/jni_generator/testSingleJNIAdditionalImport.golden index a367ae7..ef618da8 100644 --- a/base/android/jni_generator/testSingleJNIAdditionalImport.golden +++ b/base/android/jni_generator/testSingleJNIAdditionalImport.golden
@@ -69,16 +69,11 @@ "V", reinterpret_cast<void*>(Java_org_chromium_foo_Foo_nativeDoSomething) }, }; -// TODO(agrieve): Remove these empty registration functions and functions -// calling them. https://crbug.com/683256. static bool RegisterNativesImpl(JNIEnv* env) { - return true; -} + if (jni_generator::ShouldSkipJniRegistration(false)) + return true; -JNI_REGISTRATION_EXPORT bool RegisterNative_org_chromium_foo_Foo(JNIEnv* env) { - - const int kMethodsFooSize = - arraysize(kMethodsFoo); + const int kMethodsFooSize = arraysize(kMethodsFoo); if (env->RegisterNatives(Foo_clazz(env), kMethodsFoo,
diff --git a/build/android/gradle/generate_gradle.py b/build/android/gradle/generate_gradle.py index ba2311a..e7bf827 100755 --- a/build/android/gradle/generate_gradle.py +++ b/build/android/gradle/generate_gradle.py
@@ -211,7 +211,7 @@ def JavaFiles(self): if self._java_files is None: - java_sources_file = self.DepsInfo().get('java_sources_file') + java_sources_file = self.Gradle().get('java_sources_file') java_files = [] if java_sources_file: java_sources_file = _RebasePath(java_sources_file)
diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py index 6eab4b2..c085176 100755 --- a/build/android/gyp/write_build_config.py +++ b/build/android/gyp/write_build_config.py
@@ -413,7 +413,7 @@ gradle['android_manifest'] = options.android_manifest if options.type in ('java_binary', 'java_library', 'android_apk'): if options.java_sources_file: - deps_info['java_sources_file'] = options.java_sources_file + gradle['java_sources_file'] = options.java_sources_file if options.bundled_srcjars: gradle['bundled_srcjars'] = ( build_utils.ParseGnList(options.bundled_srcjars)) @@ -436,14 +436,6 @@ gradle['dependent_java_projects'].append(c['path']) - if options.type == 'android_apk': - config['jni'] = {} - all_java_sources = [c['java_sources_file'] for c in all_library_deps - if 'java_sources_file' in c] - if options.java_sources_file: - all_java_sources.append(options.java_sources_file) - config['jni']['all_source'] = all_java_sources - if (options.type in ('java_binary', 'java_library')): deps_info['requires_android'] = options.requires_android deps_info['supports_android'] = options.supports_android
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index ceffd063..38032b768 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni
@@ -192,6 +192,7 @@ "--depfile", rebase_path(depfile, root_build_dir), "--input_file={{source}}", + "--optimize_generation=1", "--ptr_type=long", "--output_dir", rebase_path(jni_output_dir, root_build_dir), @@ -301,6 +302,7 @@ rebase_path(jar_file, root_build_dir), "--input_file", class, + "--optimize_generation=1", "--ptr_type=long", "--output_dir", rebase_path(jni_output_dir, root_build_dir), @@ -332,61 +334,6 @@ } } - # Declare a jni registration target. - # - # This target generates a header file calling JNI registration functions - # created by generate_jni and generate_jar_jni. - # - # See base/android/jni_generator/jni_registration_generator.py for more info - # about the format of the header file. - # - # Variables - # target: The Apk target to generate registrations for. - # output: Path to the generated .h file. - # exception_files: List of .java files that should be ignored when searching - # for native methods. (optional) - # - # Example - # generate_jni_registration("chrome_jni_registration") { - # target = ":chrome_public_apk" - # output = "$root_gen_dir/chrome/browser/android/${target_name}.h" - # exception_files = [ - # "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - # "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - # "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - # ] - # } - template("generate_jni_registration") { - action(target_name) { - forward_variables_from(invoker, [ "testonly" ]) - _build_config = get_label_info(invoker.target, "target_gen_dir") + "/" + - get_label_info(invoker.target, "name") + ".build_config" - _rebased_build_config = rebase_path(_build_config, root_build_dir) - - _rebase_exception_java_files = - rebase_path(invoker.exception_files, root_build_dir) - - script = "//base/android/jni_generator/jni_registration_generator.py" - deps = [ - "${invoker.target}__build_config", - ] - inputs = [ - _build_config, - ] - outputs = [ - invoker.output, - ] - - args = [ - # This is a list of .sources files. - "--sources_files=@FileArg($_rebased_build_config:jni:all_source)", - "--output", - rebase_path(invoker.output, root_build_dir), - "--no_register_java=$_rebase_exception_java_files", - ] - } - } - # Declare a target for c-preprocessor-generated java files # # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index caf727c..b80a1d6f 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -672,7 +672,6 @@ "../browser/android/chrome_entry_point.cc", ] deps = [ - ":chrome_jni_registration($default_toolchain)", "//build/config:exe_and_shlib_deps", "//chrome:chrome_android_core", ] @@ -697,30 +696,8 @@ } # Ensure that .pak files are built only once (build them in the default -# toolchain). The central header file calling JNI registration functions -# is generated from Java code so it just needs to be generated once. +# toolchain). if (current_toolchain == default_toolchain) { - generate_jni_registration("chrome_jni_registration") { - target = ":chrome_public_apk" - output = "$root_gen_dir/chrome/browser/android/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] - } - - generate_jni_registration("chrome_sync_shell_jni_registration") { - testonly = true - target = ":chrome_sync_shell_apk" - output = "$root_gen_dir/chrome/browser/android/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] - } - if (enable_resource_whitelist_generation) { generate_resource_whitelist("monochrome_resource_whitelist") { # Always use the 32-bit library's whitelist since the 64-bit one is @@ -816,13 +793,12 @@ shared_library("chrome_sync_shell") { testonly = true sources = [ - "../browser/android/chrome_sync_shell_entry_point.cc", + "../browser/android/chrome_entry_point.cc", "../browser/android/chrome_sync_shell_main_delegate.cc", "../browser/android/chrome_sync_shell_main_delegate.h", "../browser/android/chrome_sync_shell_main_delegate_initializer.cc", ] deps = [ - ":chrome_sync_shell_jni_registration($default_toolchain)", "//build/config:exe_and_shlib_deps", "//chrome:chrome_android_core", "//components/sync", @@ -903,9 +879,6 @@ apk_name = "ChromeSyncShell" shared_libraries = [ ":chrome_sync_shell" ] - # This exists here rather than in chrome_sync_shell_test_apk for JNI - # registration to be able to find the native side functions. - java_files = [ "sync_shell/javatests/src/org/chromium/chrome/browser/sync/FakeServerHelper.java" ] deps = [ ":chrome_sync_shell_apk_template_resources", @@ -913,7 +886,6 @@ # but that code is stripped out via proguard. Adding this deps adds # usages and prevents removal of the proto code. "//components/sync:test_support_proto_java", - "//third_party/android_protobuf:protobuf_nano_javalib", ] } @@ -1007,23 +979,11 @@ } } -instrumentation_test_apk("chrome_sync_shell_test_apk") { - apk_name = "ChromeSyncShellTest" - apk_under_test = ":chrome_sync_shell_apk" - android_manifest = chrome_sync_shell_test_apk_manifest - android_manifest_dep = ":chrome_sync_shell_test_apk_manifest" - java_files = [ - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/AutofillTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/GmsCoreSyncListenerTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java", - "sync_shell/javatests/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragmentTest.java", - ] +android_library("chrome_sync_shell_test_apk_java") { + testonly = true + + # From java_sources.jni. + java_files = sync_shell_test_java_sources deps = [ "//base:base_java", @@ -1039,9 +999,21 @@ "//components/sync/android:sync_java", "//content/public/android:content_java", "//content/public/test/android:content_java_test_support", + "//third_party/android_protobuf:protobuf_nano_javalib", "//third_party/android_support_test_runner:runner_java", "//third_party/android_tools:android_support_v7_appcompat_java", "//ui/android:ui_java", ] +} + +instrumentation_test_apk("chrome_sync_shell_test_apk") { + apk_name = "ChromeSyncShellTest" + apk_under_test = ":chrome_sync_shell_apk" + android_manifest = chrome_sync_shell_test_apk_manifest + android_manifest_dep = ":chrome_sync_shell_test_apk_manifest" + deps = [ + ":chrome_sync_shell_test_apk_java", + "//third_party/android_support_test_runner:runner_java", + ] proguard_enabled = !is_java_debug }
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index 0f18e3e..3b1bc49 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni
@@ -1812,6 +1812,20 @@ "junit/src/org/chromium/chrome/browser/widget/selection/SelectionDelegateTest.java", ] +sync_shell_test_java_sources = [ + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/AutofillTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/BookmarksTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/FakeServerHelper.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/GmsCoreSyncListenerTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java", + "sync_shell/javatests/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragmentTest.java", +] + # Only used for testing, should not be shipped to end users. if (enable_offline_pages_harness) { chrome_java_sources += [ "java/src/org/chromium/chrome/browser/offlinepages/evaluation/OfflinePageEvaluationBridge.java" ]
diff --git a/chrome/browser/android/DEPS b/chrome/browser/android/DEPS index 8f032b7..bb55a8c 100644 --- a/chrome/browser/android/DEPS +++ b/chrome/browser/android/DEPS
@@ -2,7 +2,6 @@ "-components/devtools_bridge", "+cc/layers/layer.h", "+cc/output/context_provider.h", - "+chrome_jni_registration/chrome_jni_registration.h", "+components/doodle", "+components/ntp_snippets", "+components/spellcheck/browser",
diff --git a/chrome/browser/android/chrome_entry_point.cc b/chrome/browser/android/chrome_entry_point.cc index 079358b..ee46cd6c 100644 --- a/chrome/browser/android/chrome_entry_point.cc +++ b/chrome/browser/android/chrome_entry_point.cc
@@ -7,7 +7,6 @@ #include "base/android/library_loader/library_loader_hooks.h" #include "base/bind.h" #include "chrome/app/android/chrome_jni_onload.h" -#include "chrome/browser/android/chrome_jni_registration.h" namespace { @@ -24,19 +23,6 @@ // Java side and only register a subset of JNI methods. base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - - if (!base::android::IsSelectiveJniRegistrationEnabled(env)) { - if (!RegisterNonMainDexNatives(env)) { - return -1; - } - } - - if (!RegisterMainDexNatives(env)) { - return -1; - } - - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (base::android::IsSelectiveJniRegistrationEnabled(env)) { base::android::SetJniRegistrationType( base::android::SELECTIVE_JNI_REGISTRATION);
diff --git a/chrome/browser/android/chrome_sync_shell_entry_point.cc b/chrome/browser/android/chrome_sync_shell_entry_point.cc deleted file mode 100644 index e14ea511..0000000 --- a/chrome/browser/android/chrome_sync_shell_entry_point.cc +++ /dev/null
@@ -1,49 +0,0 @@ -// Copyright 2017 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 "base/android/jni_android.h" -#include "base/android/jni_utils.h" -#include "base/android/library_loader/library_loader_hooks.h" -#include "base/bind.h" -#include "chrome/app/android/chrome_jni_onload.h" -#include "chrome/browser/android/chrome_sync_shell_jni_registration.h" - -namespace { - -bool NativeInit() { - return android::OnJNIOnLoadInit(); -} - -} // namespace - -// This is called by the VM when the shared library is first loaded. -JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { - // By default, all JNI methods are registered. However, since render processes - // don't need very much Java code, we enable selective JNI registration on the - // Java side and only register a subset of JNI methods. - base::android::InitVM(vm); - JNIEnv* env = base::android::AttachCurrentThread(); - - if (!base::android::IsSelectiveJniRegistrationEnabled(env)) { - if (!RegisterNonMainDexNatives(env)) { - return -1; - } - } - - if (!RegisterMainDexNatives(env)) { - return -1; - } - - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. - if (base::android::IsSelectiveJniRegistrationEnabled(env)) { - base::android::SetJniRegistrationType( - base::android::SELECTIVE_JNI_REGISTRATION); - } - if (!android::OnJNIOnLoadRegisterJNI(env)) { - return -1; - } - base::android::SetNativeInitializationHook(NativeInit); - return JNI_VERSION_1_4; -}
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index deff8885..795186d 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -111,14 +111,14 @@ EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); location_bar->Revert(); EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); } // Autocomplete test is flaky on ChromeOS. @@ -163,7 +163,7 @@ location_bar->Revert(); EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); const AutocompleteResult& result = autocomplete_controller->result(); EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); }
diff --git a/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto b/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto index e12ba924..79c14c4c 100644 --- a/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto +++ b/chrome/browser/chromeos/policy/proto/chrome_device_policy.proto
@@ -380,7 +380,7 @@ // network configuration will be offered. Otherwise (policy is omitted or set // to false), only an error message is displayed. // Note: If enable_auto_login_bailout policy above is set to false and this - // policy is omitted or set to false, there are chances that the device might + // policy is omitted or set to false, there are chances that the device might // become totally unusable when there is no Internet access and has to go // through the recovery process. // If the device is offline at startup then the network configuration screen
diff --git a/chrome/browser/media/android/remote/remote_media_player_bridge.cc b/chrome/browser/media/android/remote/remote_media_player_bridge.cc index 6c3e609..531e3f4 100644 --- a/chrome/browser/media/android/remote/remote_media_player_bridge.cc +++ b/chrome/browser/media/android/remote/remote_media_player_bridge.cc
@@ -262,6 +262,7 @@ // static bool RemoteMediaPlayerBridge::RegisterRemoteMediaPlayerBridge(JNIEnv* env) { bool ret = RegisterNativesImpl(env); + DCHECK(g_RemoteMediaPlayerBridge_clazz); return ret; }
diff --git a/chrome/browser/media/android/router/media_router_android_bridge.cc b/chrome/browser/media/android/router/media_router_android_bridge.cc index 4c57cde..e56bbb59 100644 --- a/chrome/browser/media/android/router/media_router_android_bridge.cc +++ b/chrome/browser/media/android/router/media_router_android_bridge.cc
@@ -29,6 +29,7 @@ // static bool MediaRouterAndroidBridge::Register(JNIEnv* env) { bool ret = RegisterNativesImpl(env); + DCHECK(g_ChromeMediaRouter_clazz); return ret; }
diff --git a/chrome/browser/metrics/field_trial_synchronizer.cc b/chrome/browser/metrics/field_trial_synchronizer.cc index 3b3ffef..4961249d0 100644 --- a/chrome/browser/metrics/field_trial_synchronizer.cc +++ b/chrome/browser/metrics/field_trial_synchronizer.cc
@@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/threading/thread.h" #include "chrome/common/renderer_configuration.mojom.h" +#include "components/metrics/persistent_system_profile.h" #include "components/variations/variations_util.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" @@ -39,6 +40,11 @@ // need to be on the UI thread. DCHECK_CURRENTLY_ON(BrowserThread::UI); + // Note this in the persistent profile as it will take a while for a new + // "complete" profile to be genereated. + metrics::GlobalPersistentSystemProfile::GetInstance()->AddFieldTrial( + field_trial_name, group_name); + for (content::RenderProcessHost::iterator it( content::RenderProcessHost::AllHostsIterator()); !it.IsAtEnd(); it.Advance()) {
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm index c38ea78..f6123f0b 100644 --- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -248,25 +248,8 @@ void OmniboxViewMac::Update() { if (model()->UpdatePermanentText()) { - const bool was_select_all = IsSelectAll(); - NSTextView* text_view = - base::mac::ObjCCastStrict<NSTextView>([field_ currentEditor]); - const bool was_reversed = - [text_view selectionAffinity] == NSSelectionAffinityUpstream; - // Restore everything to the baseline look. RevertAll(); - - // Only select all when we have focus. If we don't have focus, selecting - // all is unnecessary since the selection will change on regaining focus, - // and can in fact cause artifacts, e.g. if the user is on the NTP and - // clicks a link to navigate, causing |was_select_all| to be vacuously true - // for the empty omnibox, and we then select all here, leading to the - // trailing portion of a long URL being scrolled into view. We could try - // and address cases like this, but it seems better to just not muck with - // things when the omnibox isn't focused to begin with. - if (was_select_all && model()->has_focus()) - SelectAll(was_reversed); } else { // TODO(shess): This corresponds to _win and _gtk, except those // guard it with a test for whether the security level changed.
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc index 454864c4..a3704890 100644 --- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc +++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -866,11 +866,18 @@ // Check if RevertAll() resets the text and preserves the cursor position. omnibox_view->RevertAll(); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); EXPECT_EQ(old_text, omnibox_view->GetText()); omnibox_view->GetSelectionBounds(&start, &end); - EXPECT_EQ(3U, start); - EXPECT_EQ(3U, end); +#if defined(OS_MACOSX) + // Cocoa doesn't choose a direction until the user interacts with it, + // so it will have a default direction here. + std::swap(start, end); +#endif + // When |Revert()| calls |SelectAll()|, it requests a reverse selection + // so that the start of a long URL is in view. + EXPECT_EQ(11U, start); + EXPECT_EQ(0U, end); // Check that reverting clamps the cursor to the bounds of the new text. // Move the cursor to the end. @@ -886,8 +893,11 @@ omnibox_view->RevertAll(); // Cursor should be no further than original text. omnibox_view->GetSelectionBounds(&start, &end); +#if defined(OS_MACOSX) + std::swap(start, end); +#endif EXPECT_EQ(11U, start); - EXPECT_EQ(11U, end); + EXPECT_EQ(0U, end); } // Make sure the cursor position doesn't get set past the last character of @@ -1956,13 +1966,13 @@ test_toolbar_model->set_text(url_a); omnibox_view->Update(); EXPECT_EQ(url_a, omnibox_view->GetText()); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); // Test behavior of the "reversed" attribute of OmniboxView::SelectAll(). test_toolbar_model->set_text(ASCIIToUTF16("AB")); omnibox_view->Update(); // Should be at the end already. Shift+Left to select "reversed". - EXPECT_EQ(0u, GetSelectionSize(omnibox_view)); + EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); @@ -1989,6 +1999,8 @@ omnibox_view->Update(); EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); + // Force a forwards select-all because Cocoa will anyways. + omnibox_view->SelectAll(false); // Now Shift+Right should do nothing, and Shift+Left should reduce. // At the end, so Shift+Right should do nothing. ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN));
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index b77191b..f87cf715 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -203,31 +203,10 @@ void OmniboxViewViews::Update() { const security_state::SecurityLevel old_security_level = security_level_; UpdateSecurityLevel(); - if (model()->UpdatePermanentText()) { - // Select all the new text if the user had all the old text selected, or if - // there was no previous text (for new tab page URL replacement extensions). - // This makes one particular case better: the user clicks in the box to - // change it right before the permanent URL is changed. Since the new URL - // is still fully selected, the user's typing will replace the edit contents - // as they'd intended. - const bool was_select_all = IsSelectAll(); - const bool was_reversed = GetSelectedRange().is_reversed(); - + if (model()->UpdatePermanentText()) RevertAll(); - - // Only select all when we have focus. If we don't have focus, selecting - // all is unnecessary since the selection will change on regaining focus, - // and can in fact cause artifacts, e.g. if the user is on the NTP and - // clicks a link to navigate, causing |was_select_all| to be vacuously true - // for the empty omnibox, and we then select all here, leading to the - // trailing portion of a long URL being scrolled into view. We could try - // and address cases like this, but it seems better to just not muck with - // things when the omnibox isn't focused to begin with. - if (was_select_all && model()->has_focus()) - SelectAll(was_reversed); - } else if (old_security_level != security_level_) { + else if (old_security_level != security_level_) EmphasizeURLComponents(); - } } base::string16 OmniboxViewViews::GetText() const {
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc index c1955e5c..7435951 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc
@@ -286,7 +286,7 @@ // RevertAll after navigation to invalidate the selection range saved on blur. omnibox_view->RevertAll(); EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); - EXPECT_FALSE(omnibox_view->IsSelectAll()); + EXPECT_TRUE(omnibox_view->IsSelectAll()); // Pressing tab to focus the omnibox should select all text. while (!ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)) {
diff --git a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.cc b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.cc index aaf637e65..1524cdb 100644 --- a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.cc +++ b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.cc
@@ -171,8 +171,13 @@ ResetToIdealState(); return; } - int active_x = (index + 1 == tab_count()) ? + + int active_x = ideal_x(active_index()); + if (add_types & kAddTypeActive) { + active_x = (index + 1 == tab_count()) ? width_ - size_.width() : ideal_x(index + 1); + } + SetIdealBoundsAt(active_index(), ConstrainActiveX(active_x)); LayoutByTabOffsetAfter(active_index()); LayoutByTabOffsetBefore(active_index()); @@ -336,24 +341,27 @@ if (index <= active_index() || !requires_stacking() || !IsStacked(index)) return; - int ideal_delta = width_for_count(index - active_index()) - overlap_; + const int ideal_delta = width_for_count(index - active_index()) - overlap_; if (ideal_x(index) - ideal_x(active_index()) == ideal_delta) return; - // First push active index as far to the left as it'll go. - int active_x = std::max(GetMinX(active_index()), - std::min(ideal_x(index) - ideal_delta, - ideal_x(active_index()))); + // Move the active tab to the left so that all tabs between the active tab + // and |index| (inclusive) can be made visible. + const int active_x = std::max(GetMinX(active_index()), + std::min(ideal_x(index) - ideal_delta, + ideal_x(active_index()))); SetIdealBoundsAt(active_index(), active_x); - LayoutUsingCurrentBefore(active_index()); - LayoutUsingCurrentAfter(active_index()); + LayoutByTabOffsetBefore(active_index()); + LayoutByTabOffsetAfter(active_index()); AdjustStackedTabs(); + if (ideal_x(index) - ideal_x(active_index()) == ideal_delta) return; // If we get here active_index() is left aligned. Push |index| as far to - // the right as possible. - int x = std::min(GetMaxX(index), active_x + ideal_delta); + // the right as possible, forming a stack immediately to the right of the + // active tab if necessary. + const int x = std::min(GetMaxX(index), active_x + ideal_delta); SetIdealBoundsAt(index, x); LayoutByTabOffsetAfter(index); for (int next_x = x, i = index - 1; i > active_index(); --i) {
diff --git a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h index ac671af..bbfd1e7 100644 --- a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h +++ b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h
@@ -103,8 +103,10 @@ // Resets to an ideal layout state. void ResetToIdealState(); - // Makes |index| visible. This is used when a new tab is added that isn't - // active. + // Makes all tabs between the active tab and |index| (inclusive) visible. If + // this is not possible, then |index| is made visible and a stack forms + // immediately to the right of the active tab. This is used when a new tab is + // added that isn't active. void MakeVisible(int index); // Returns the x-coordinate for the active tab constrained by the current tab
diff --git a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc index 470d5cb..f69fb5c 100644 --- a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc +++ b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc
@@ -322,15 +322,38 @@ bool add_active; bool add_pinned; } test_data[] = { - // Adding a background tab test cases. { { 0, 300, 100, 10, 2, 0, 1, "0 90 180 198 200", "0 16 106 196 198 200"}, 3, false, false }, + + // If the active tab is in its leftmost position and it is not possible + // for all of the tabs between the active tab and the newly-added tab + // (inclusive) to be shown, then a stack should form to the right of + // the active tab. + { { 0, 284, 100, 10, 2, 0, 2, "0 2 4 94 184", "0 2 4 6 94 184"}, + 5, false, false }, { { 0, 300, 100, 10, 2, 0, 1, "0 90 180 198 200", "0 2 4 20 110 200"}, 5, false, false }, + { { 0, 300, 100, 10, 2, 0, 1, "0 90 180 198 200", "0 90 180 196 198 200"}, 2, false, false }, - { { 0, 300, 100, 10, 2, 0, 1, "0 90 180 198 200", "0 2 4 94 184 200"}, - 0, false, false }, + + // Add to the end of the tab strip. All tabs between the active tab and the + // newly-added tab (inclusive) should be fully visible (indices 3-5 in the + // resulting tab strip) and tabs to the left of the active tab should be + // stacked at the left side of the tab strip rather than immediately to the + // left of the active tab. + { { 0, 300, 100, 10, 2, 0, 3, "0 90 180 198 200", "0 2 4 20 110 200"}, + 5, false, false }, + + // If it is possible for all of the tabs between the active tab and the + // newly-added tab (inclusive) to be fully visible without changing the + // position of the active tab, then do not do so. + { { 0, 378, 100, 10, 2, 0, 2, "0 2 4 94 184 274 276 278", + "0 2 4 94 184 272 274 276 278"}, + 3, false, false }, + { { 0, 378, 100, 10, 2, 0, 2, "0 2 4 94 184 274 276 278", + "0 2 4 94 184 272 274 276 278"}, + 4, false, false }, { { 4, 200, 100, 10, 2, 1, 2, "0 4 10 100", "0 0 8 10 100"}, 1, false, true },
diff --git a/chromecast/BUILD.gn b/chromecast/BUILD.gn index 93f65e7..08cbad2c 100644 --- a/chromecast/BUILD.gn +++ b/chromecast/BUILD.gn
@@ -481,15 +481,6 @@ } if (is_android) { - generate_jni_registration("cast_shell_jni_registration") { - target = ":cast_shell_apk" - output = "$root_gen_dir/chromecast/android/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] - } android_assets("cast_shell_apk_assets") { assert(v8_use_external_startup_data)
diff --git a/chromecast/android/BUILD.gn b/chromecast/android/BUILD.gn index 321a3d2..1d29974 100644 --- a/chromecast/android/BUILD.gn +++ b/chromecast/android/BUILD.gn
@@ -27,7 +27,6 @@ deps = [ ":platform_jni_loader", "//base", - "//chromecast:cast_shell_jni_registration", "//chromecast:cast_shell_lib", "//chromecast:chromecast_features", "//chromecast/app",
diff --git a/chromecast/app/android/cast_jni_loader.cc b/chromecast/app/android/cast_jni_loader.cc index 73b829bb..79a32fe 100644 --- a/chromecast/app/android/cast_jni_loader.cc +++ b/chromecast/app/android/cast_jni_loader.cc
@@ -6,7 +6,6 @@ #include "base/android/library_loader/library_loader_hooks.h" #include "base/bind.h" #include "chromecast/android/cast_jni_registrar.h" -#include "chromecast/android/cast_shell_jni_registration.h" #include "chromecast/android/platform_jni_loader.h" #include "chromecast/app/cast_main_delegate.h" #include "chromecast/browser/android/jni_registrar.h" @@ -43,12 +42,6 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!RegisterMainDexNatives(env) || !RegisterNonMainDexNatives(env)) { - return -1; - } - - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (!content::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || !NativeInit()) { return -1;
diff --git a/components/cronet/android/BUILD.gn b/components/cronet/android/BUILD.gn index fe36337..b5f646d 100644 --- a/components/cronet/android/BUILD.gn +++ b/components/cronet/android/BUILD.gn
@@ -25,16 +25,6 @@ jni_package = "cronet" } -generate_jni_registration("cronet_jni_registration") { - target = ":cronet_sample_apk" - output = "$root_gen_dir/components/cronet/android/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] -} - java_cpp_enum("effective_connection_type_java") { sources = [ "//net/nqe/effective_connection_type.h", @@ -175,7 +165,6 @@ deps = [ ":cronet_android_cert_proto", ":cronet_jni_headers", - ":cronet_jni_registration", ":cronet_version_header", "//base", "//base/third_party/dynamic_annotations", @@ -543,9 +532,6 @@ ] include_dirs = [ _cronet_version_header_include_dir ] - - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - configs += [ "//build/config/android:hide_all_but_jni" ] } android_resources("cronet_test_apk_resources") {
diff --git a/components/cronet/android/cronet_library_loader.cc b/components/cronet/android/cronet_library_loader.cc index b7aa07a..72c416e 100644 --- a/components/cronet/android/cronet_library_loader.cc +++ b/components/cronet/android/cronet_library_loader.cc
@@ -19,7 +19,6 @@ #include "base/message_loop/message_loop.h" #include "base/metrics/statistics_recorder.h" #include "components/cronet/android/cronet_bidirectional_stream_adapter.h" -#include "components/cronet/android/cronet_jni_registration.h" #include "components/cronet/android/cronet_upload_data_stream_adapter.h" #include "components/cronet/android/cronet_url_request_adapter.h" #include "components/cronet/android/cronet_url_request_context_adapter.h" @@ -85,11 +84,6 @@ jint CronetOnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!RegisterMainDexNatives(env) || !RegisterNonMainDexNatives(env)) { - return -1; - } - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (!RegisterJNI(env) || !NativeInit()) { return -1; }
diff --git a/components/cronet/tools/cr_cronet.py b/components/cronet/tools/cr_cronet.py index a0d111cc..d424b93a 100755 --- a/components/cronet/tools/cr_cronet.py +++ b/components/cronet/tools/cr_cronet.py
@@ -102,6 +102,7 @@ gn_args += 'target_os="' + target_os + '" enable_websockets=false '+ \ 'disable_file_support=true disable_ftp_support=true '+ \ 'use_platform_icu_alternatives=true '+ \ + 'enable_reporting=false '+ \ 'is_component_build=false ' + \ 'ignore_elf32_limitations=true use_partition_alloc=false'
diff --git a/components/metrics/persistent_system_profile.cc b/components/metrics/persistent_system_profile.cc index 88b2a76..6c52550 100644 --- a/components/metrics/persistent_system_profile.cc +++ b/components/metrics/persistent_system_profile.cc
@@ -4,10 +4,15 @@ #include "components/metrics/persistent_system_profile.h" +#include <set> + #include "base/atomicops.h" +#include "base/bits.h" #include "base/memory/singleton.h" #include "base/metrics/persistent_memory_allocator.h" +#include "base/pickle.h" #include "base/stl_util.h" +#include "components/variations/active_field_trials.h" namespace metrics { @@ -36,8 +41,8 @@ // for the record header and rounds up to the next multiple of the record-header // size. size_t CalculateRecordSize(size_t data_amount) { - return (data_amount + sizeof(RecordHeader) + sizeof(RecordHeader) - 1) & - ~(sizeof(RecordHeader) - 1); + return base::bits::Align(data_amount + sizeof(RecordHeader), + sizeof(RecordHeader)); } } // namespace @@ -82,9 +87,8 @@ end_offset_ = 0; } -bool PersistentSystemProfile::RecordAllocator::Write( - RecordType type, - const std::string& record) { +bool PersistentSystemProfile::RecordAllocator::Write(RecordType type, + base::StringPiece record) { const char* data = record.data(); size_t remaining_size = record.size(); @@ -169,28 +173,29 @@ return true; } -bool PersistentSystemProfile::RecordAllocator::WriteData( - RecordType type, - const char** data, - size_t* remaining_size) { +bool PersistentSystemProfile::RecordAllocator::WriteData(RecordType type, + const char** data, + size_t* data_size) { char* block = allocator_->GetAsArray<char>(alloc_reference_, kTypeIdSystemProfile, base::PersistentMemoryAllocator::kSizeAny); if (!block) return false; // It's bad if there is no accessible block. - size_t write_size = std::min(*remaining_size, kMaxRecordSize); - write_size = - std::min(write_size, alloc_size_ - end_offset_ - sizeof(RecordHeader)); + const size_t max_write_size = std::min( + kMaxRecordSize, alloc_size_ - end_offset_ - sizeof(RecordHeader)); + const size_t write_size = std::min(*data_size, max_write_size); + const size_t record_size = CalculateRecordSize(write_size); + DCHECK_LT(write_size, record_size); // Write the data and the record header. RecordHeader header; header.as_atomic = 0; header.as_parts.type = type; header.as_parts.amount = write_size; - header.as_parts.continued = (write_size < *remaining_size); + header.as_parts.continued = (write_size < *data_size); size_t offset = end_offset_; - end_offset_ += CalculateRecordSize(write_size); + end_offset_ += record_size; DCHECK_GE(alloc_size_, end_offset_); if (end_offset_ < alloc_size_) { // An empty record header has to be next before this one gets written. @@ -198,13 +203,14 @@ reinterpret_cast<base::subtle::Atomic32*>(block + end_offset_), 0); } memcpy(block + offset + sizeof(header), *data, write_size); - base::subtle::Release_Store(reinterpret_cast<base::subtle::Atomic32*>(block), - header.as_atomic); + base::subtle::Release_Store( + reinterpret_cast<base::subtle::Atomic32*>(block + offset), + header.as_atomic); // Account for what was stored and prepare for follow-on records with any // remaining data. *data += write_size; - *remaining_size -= write_size; + *data_size -= write_size; return true; } @@ -239,15 +245,14 @@ return false; } size_t read_size = header.as_parts.amount; - if (read_size < sizeof(header) || - end_offset_ + sizeof(header) + read_size > alloc_size_) { + if (end_offset_ + sizeof(header) + read_size > alloc_size_) { NOTREACHED(); // Invalid header amount. *type = kUnusedSpace; return true; // Don't try again. } // Append the record data to the output string. - record->append(block + sizeof(header), read_size); + record->append(block + end_offset_ + sizeof(header), read_size); end_offset_ += CalculateRecordSize(read_size); DCHECK_GE(alloc_size_, end_offset_); @@ -292,8 +297,10 @@ // Don't overwrite a complete profile with an incomplete one. if (!complete && allocator.has_complete_profile()) continue; - // A full system profile always starts fresh. - allocator.Reset(); + // A full system profile always starts fresh. Incomplete keeps existing + // records for merging. + if (complete) + allocator.Reset(); // Write out the serialized profile. allocator.Write(kSystemProfileProto, serialized_profile); // Indicate if this is a complete profile. @@ -319,6 +326,21 @@ SetSystemProfile(serialized_profile, complete); } +void PersistentSystemProfile::AddFieldTrial(base::StringPiece trial, + base::StringPiece group) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + DCHECK(!trial.empty()); + DCHECK(!group.empty()); + + base::Pickle pickler; + if (!pickler.WriteString(trial) || !pickler.WriteString(group)) + return; + + WriteToAll(kFieldTrialInfo, + base::StringPiece(static_cast<const char*>(pickler.data()), + pickler.size())); +} + // static bool PersistentSystemProfile::HasSystemProfile( const base::PersistentMemoryAllocator& memory_allocator) { @@ -334,12 +356,76 @@ RecordType type; std::string record; - if (!records.Read(&type, &record)) - return false; - if (type != kSystemProfileProto) + do { + if (!records.Read(&type, &record)) + return false; + } while (type != kSystemProfileProto); + + if (!system_profile->ParseFromString(record)) return false; - return system_profile->ParseFromString(record); + MergeUpdateRecords(memory_allocator, system_profile); + return true; +} + +// static +void PersistentSystemProfile::MergeUpdateRecords( + const base::PersistentMemoryAllocator& memory_allocator, + SystemProfileProto* system_profile) { + const RecordAllocator records(&memory_allocator); + + RecordType type; + std::string record; + std::set<uint32_t> known_field_trial_ids; + + // This is done separate from the code that gets the profile because it + // compartmentalizes the code and makes it possible to reuse this section + // should it be needed to merge "update" records into a new "complete" + // system profile that somehow didn't get all the updates. + while (records.Read(&type, &record)) { + switch (type) { + case kUnusedSpace: + // These should never be returned. + NOTREACHED(); + break; + + case kSystemProfileProto: + // Profile was passed in; ignore this one. + break; + + case kFieldTrialInfo: { + // Get the set of known trial IDs so duplicates don't get added. + if (known_field_trial_ids.empty()) { + for (int i = 0; i < system_profile->field_trial_size(); ++i) { + known_field_trial_ids.insert( + system_profile->field_trial(i).name_id()); + } + } + + base::Pickle pickler(record.data(), record.size()); + base::PickleIterator iter(pickler); + base::StringPiece trial; + base::StringPiece group; + if (iter.ReadStringPiece(&trial) && iter.ReadStringPiece(&group)) { + variations::ActiveGroupId field_ids = + variations::MakeActiveGroupId(trial, group); + if (!base::ContainsKey(known_field_trial_ids, field_ids.name)) { + SystemProfileProto::FieldTrial* field_trial = + system_profile->add_field_trial(); + field_trial->set_name_id(field_ids.name); + field_trial->set_group_id(field_ids.group); + known_field_trial_ids.insert(field_ids.name); + } + } + } break; + } + } +} + +void PersistentSystemProfile::WriteToAll(RecordType type, + base::StringPiece record) { + for (auto& allocator : allocators_) + allocator.Write(type, record); } GlobalPersistentSystemProfile* GlobalPersistentSystemProfile::GetInstance() {
diff --git a/components/metrics/persistent_system_profile.h b/components/metrics/persistent_system_profile.h index 2f687811..98352e9 100644 --- a/components/metrics/persistent_system_profile.h +++ b/components/metrics/persistent_system_profile.h
@@ -7,6 +7,7 @@ #include <vector> +#include "base/strings/string_piece.h" #include "base/threading/thread_checker.h" #include "components/metrics/proto/system_profile.pb.h" @@ -38,6 +39,9 @@ void SetSystemProfile(const std::string& serialized_profile, bool complete); void SetSystemProfile(const SystemProfileProto& profile, bool complete); + // Records the existence of a field trial. + void AddFieldTrial(base::StringPiece trial, base::StringPiece group); + // Tests if a persistent memory allocator contains an system profile. static bool HasSystemProfile( const base::PersistentMemoryAllocator& memory_allocator); @@ -55,6 +59,7 @@ enum RecordType : uint8_t { kUnusedSpace = 0, // The default value for empty memory. kSystemProfileProto, + kFieldTrialInfo, }; // A class for managing record allocations inside a persistent memory segment. @@ -70,7 +75,7 @@ // These methods manage writing records to the allocator. Do not mix these // with "read" calls; it's one or the other. void Reset(); - bool Write(RecordType type, const std::string& record); + bool Write(RecordType type, base::StringPiece record); // Read a record from the allocator. Do not mix this with "write" calls; // it's one or the other. @@ -92,7 +97,7 @@ // Writes data to the current position, updating the passed values past // the amount written. Returns false in case of an error. - bool WriteData(RecordType type, const char** data, size_t* remaining_size); + bool WriteData(RecordType type, const char** data, size_t* data_size); // Reads data from the current position, updating the passed string // in-place. |type| must be initialized to kUnusedSpace and |record| must @@ -114,6 +119,14 @@ // Copy and assign are allowed for easy use with STL containers. }; + // Write a record to all registered allocators. + void WriteToAll(RecordType type, base::StringPiece record); + + // Merges all "update" records into a system profile. + static void MergeUpdateRecords( + const base::PersistentMemoryAllocator& memory_allocator, + SystemProfileProto* system_profile); + // The list of registered persistent allocators, described by RecordAllocator // instances. std::vector<RecordAllocator> allocators_;
diff --git a/components/metrics/persistent_system_profile_unittest.cc b/components/metrics/persistent_system_profile_unittest.cc index a2e038a4..4adaed3 100644 --- a/components/metrics/persistent_system_profile_unittest.cc +++ b/components/metrics/persistent_system_profile_unittest.cc
@@ -8,6 +8,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/persistent_memory_allocator.h" #include "base/rand_util.h" +#include "components/variations/metrics_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace metrics { @@ -134,4 +135,37 @@ EXPECT_EQ(90U, proto2.field_trial(1).group_id()); } +TEST_F(PersistentSystemProfileTest, ProfileExtensions) { + persistent_profile()->AddFieldTrial("sna", "foo"); + + SystemProfileProto fetched; + ASSERT_FALSE( + PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched)); + + SystemProfileProto proto; + SystemProfileProto::FieldTrial* trial = proto.add_field_trial(); + trial->set_name_id(123); + trial->set_group_id(456); + + persistent_profile()->SetSystemProfile(proto, false); + ASSERT_TRUE( + PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched)); + ASSERT_EQ(2, fetched.field_trial_size()); + EXPECT_EQ(123U, fetched.field_trial(0).name_id()); + EXPECT_EQ(456U, fetched.field_trial(0).group_id()); + EXPECT_EQ(metrics::HashName("sna"), fetched.field_trial(1).name_id()); + EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(1).group_id()); + + persistent_profile()->AddFieldTrial("foo", "bar"); + ASSERT_TRUE( + PersistentSystemProfile::GetSystemProfile(*memory_allocator(), &fetched)); + ASSERT_EQ(3, fetched.field_trial_size()); + EXPECT_EQ(123U, fetched.field_trial(0).name_id()); + EXPECT_EQ(456U, fetched.field_trial(0).group_id()); + EXPECT_EQ(metrics::HashName("sna"), fetched.field_trial(1).name_id()); + EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(1).group_id()); + EXPECT_EQ(metrics::HashName("foo"), fetched.field_trial(2).name_id()); + EXPECT_EQ(metrics::HashName("bar"), fetched.field_trial(2).group_id()); +} + } // namespace metrics
diff --git a/components/omnibox/browser/omnibox_edit_model.cc b/components/omnibox/browser/omnibox_edit_model.cc index 4868f41..7a8e739 100644 --- a/components/omnibox/browser/omnibox_edit_model.cc +++ b/components/omnibox/browser/omnibox_edit_model.cc
@@ -149,7 +149,6 @@ if (MaybePrependKeyword(display_text).empty()) { base::AutoReset<bool> tmp(&in_revert_, true); view_->RevertAll(); - view_->SelectAll(true); } else { InternalSetUserText(display_text); } @@ -370,13 +369,8 @@ keyword_.clear(); is_keyword_hint_ = false; has_temporary_text_ = false; - size_t start, end; - view_->GetSelectionBounds(&start, &end); - // First home the cursor, so view of text is scrolled to left, then correct - // it. |SetCaretPos()| doesn't scroll the text, so doing that first wouldn't - // accomplish anything. view_->SetWindowTextAndCaretPos(permanent_text_, 0, false, true); - view_->SetCaretPos(std::min(permanent_text_.length(), start)); + view_->SelectAll(true); client_->OnRevert(); } @@ -659,9 +653,6 @@ SEARCH_ENGINE_MAX); } - // Get the current text before we call RevertAll() which will clear it. - base::string16 current_text = view_->GetText(); - if (disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB) { base::AutoReset<bool> tmp(&in_revert_, true); view_->RevertAll(); // Revert the box to its unedited state. @@ -937,7 +928,6 @@ // for ease of replacement, and matches other browsers. bool user_input_was_in_progress = user_input_in_progress_; view_->RevertAll(); - view_->SelectAll(true); // If the user was in the midst of editing, don't cancel any underlying page // load. This doesn't match IE or Firefox, but seems more correct. Note that
diff --git a/components/password_manager/DEPS b/components/password_manager/DEPS index d5d8ecef..174fecf5 100644 --- a/components/password_manager/DEPS +++ b/components/password_manager/DEPS
@@ -12,6 +12,7 @@ "+net/traffic_annotation", "+net/url_request", "+sql", + "+third_party/boringssl/src/include/openssl", "+third_party/re2", "+third_party/sqlite/sqlite3.h", "+ui",
diff --git a/components/password_manager/core/browser/password_manager_util.cc b/components/password_manager/core/browser/password_manager_util.cc index d104a6b..5065028 100644 --- a/components/password_manager/core/browser/password_manager_util.cc +++ b/components/password_manager/core/browser/password_manager_util.cc
@@ -11,7 +11,9 @@ #include "components/autofill/core/common/password_form.h" #include "components/password_manager/core/browser/log_manager.h" #include "components/sync/driver/sync_service.h" +#include "crypto/openssl_util.h" #include "crypto/sha2.h" +#include "third_party/boringssl/src/include/openssl/evp.h" namespace password_manager_util { @@ -98,4 +100,38 @@ return hash37; } +uint64_t CalculateSyncPasswordHash(const base::StringPiece16& text, + const std::string& salt) { + crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); + constexpr size_t kBytesFromHash = 8; + constexpr uint64_t kScryptCost = 32; // It must be power of 2. + constexpr uint64_t kScryptBlockSize = 8; + constexpr uint64_t kScryptParallelization = 1; + constexpr size_t kScryptMaxMemory = 1024 * 1024; + + uint8_t hash[kBytesFromHash]; + base::StringPiece text_8bits(reinterpret_cast<const char*>(text.data()), + text.size() * 2); + const uint8_t* salt_ptr = reinterpret_cast<const uint8_t*>(salt.c_str()); + + int scrypt_ok = EVP_PBE_scrypt(text_8bits.data(), text_8bits.size(), salt_ptr, + salt.size(), kScryptCost, kScryptBlockSize, + kScryptParallelization, kScryptMaxMemory, hash, + kBytesFromHash); + + // EVP_PBE_scrypt can only fail due to memory allocation error (which aborts + // Chromium) or invalid parameters. In case of a failure a hash could leak + // information from the stack, so using CHECK is better than DCHECK. + CHECK(scrypt_ok); + + // Take 37 bits of |hash|. + uint64_t hash37 = ((static_cast<uint64_t>(hash[0]))) | + ((static_cast<uint64_t>(hash[1])) << 8) | + ((static_cast<uint64_t>(hash[2])) << 16) | + ((static_cast<uint64_t>(hash[3])) << 24) | + (((static_cast<uint64_t>(hash[4])) & 0x1F) << 32); + + return hash37; +} + } // namespace password_manager_util
diff --git a/components/password_manager/core/browser/password_manager_util.h b/components/password_manager/core/browser/password_manager_util.h index 65a0c097..d5cf331 100644 --- a/components/password_manager/core/browser/password_manager_util.h +++ b/components/password_manager/core/browser/password_manager_util.h
@@ -52,6 +52,11 @@ // Returns 37 bits from Sha256 hash. uint64_t Calculate37BitsOfSHA256Hash(const base::StringPiece16& text); +// Calculates 37 bits hash for a sync password. The calculation is based on a +// slow hash function. The running time is ~10^{-4} seconds on Desktop. +uint64_t CalculateSyncPasswordHash(const base::StringPiece16& text, + const std::string& salt); + } // namespace password_manager_util #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_UTIL_H_
diff --git a/components/password_manager/core/browser/password_manager_util_unittest.cc b/components/password_manager/core/browser/password_manager_util_unittest.cc index 3cc9fe2..ae4d26f5 100644 --- a/components/password_manager/core/browser/password_manager_util_unittest.cc +++ b/components/password_manager/core/browser/password_manager_util_unittest.cc
@@ -61,7 +61,7 @@ TEST(PasswordManagerUtil, Calculate37BitsOfSHA256Hash) { const char* kInputData[] = {"", "password", "secret"}; - const uint64_t kExpectedResult[] = { + constexpr uint64_t kExpectedResult[] = { UINT64_C(0x1842c4b0e3), UINT64_C(0x55d0601e2), UINT64_C(0x8b9dea8b3)}; ASSERT_EQ(arraysize(kInputData), arraysize(kExpectedResult)); @@ -73,3 +73,25 @@ password_manager_util::Calculate37BitsOfSHA256Hash(input)); } } + +TEST(PasswordManagerUtil, CalculateSyncPasswordHash) { + const char* kPlainText[] = {"", "password", "password", "secret"}; + const char* kSalt[] = {"", "salt", "123", "456"}; + + constexpr uint64_t kExpectedHash[] = { + UINT64_C(0x1c610a7950), UINT64_C(0x1927dc525e), UINT64_C(0xf72f81aa6), + UINT64_C(0x3645af77f), + }; + + static_assert(arraysize(kPlainText) == arraysize(kSalt), + "Arrays must have the same size"); + static_assert(arraysize(kPlainText) == arraysize(kExpectedHash), + "Arrays must have the same size"); + + for (size_t i = 0; i < arraysize(kPlainText); ++i) { + SCOPED_TRACE(i); + base::string16 text = base::UTF8ToUTF16(kPlainText[i]); + EXPECT_EQ(kExpectedHash[i], + password_manager_util::CalculateSyncPasswordHash(text, kSalt[i])); + } +}
diff --git a/components/policy/proto/device_management_backend.proto b/components/policy/proto/device_management_backend.proto index 4785bab..d30bfe39 100644 --- a/components/policy/proto/device_management_backend.proto +++ b/components/policy/proto/device_management_backend.proto
@@ -1256,7 +1256,7 @@ // * ping // * policy // * register -// * status +// * status_upload // * unregister // * remote_commands // * attribute_update_permission
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 552424f..233cd9b 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -1355,7 +1355,7 @@ 'id': 17, 'caption': '''Allow users to show passwords in Password Manager (deprecated)''', 'tags': [], - 'desc': '''The associated setting was used before reauthentication on viewing passwords was introduced. Since then, the setting and hence this policy had no effect on the behavior of Chrome. The current behavior of Chrome is now the same as if the the policy was set to disable showing passwords in clear text in the password manager settings page. That means that the settings page contains just a placeholder, and only upon the user clicking "Show" (and reauthenticating, if applicable) Chrome shows the password. Original description of the policy follows below. + 'desc': '''The associated setting was used before reauthentication on viewing passwords was introduced. Since then, the setting and hence this policy had no effect on the behavior of Chrome. The current behavior of Chrome is now the same as if the policy was set to disable showing passwords in clear text in the password manager settings page. That means that the settings page contains just a placeholder, and only upon the user clicking "Show" (and reauthenticating, if applicable) Chrome shows the password. Original description of the policy follows below. Controls whether the user may show passwords in clear text in the password manager. @@ -8502,7 +8502,7 @@ 'id': 298, 'caption': '''Maximize the first browser window on first run''', 'tags': [], - 'desc': '''If this policy is set to true, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will unconditionally maximize the the first window shown on first run. + 'desc': '''If this policy is set to true, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will unconditionally maximize the first window shown on first run. If this policy is set to false or not configured, the decision whether to maximize the first window shown will be based on the screen size.''', }, { @@ -9248,7 +9248,7 @@ If this setting is not configured then users are able to turn Google Location Service on and off in the Android Settings app. - Note that this policy value may be overriden by the <ph name="DEFAULT_GEOLOCATION_SETTING_POLICY_NAME">DefaultGeolocationSetting</ph> policy, when the latter is set to <ph name="BLOCK_GEOLOCATION_SETTING">BlockGeolocation</ph>. + Note that this policy value may be overridden by the <ph name="DEFAULT_GEOLOCATION_SETTING_POLICY_NAME">DefaultGeolocationSetting</ph> policy, when the latter is set to <ph name="BLOCK_GEOLOCATION_SETTING">BlockGeolocation</ph>. This policy is applicable only to the users that are able to run Android apps.''', },
diff --git a/components/variations/active_field_trials.cc b/components/variations/active_field_trials.cc index 71ff95d..bf35bc0 100644 --- a/components/variations/active_field_trials.cc +++ b/components/variations/active_field_trials.cc
@@ -40,8 +40,8 @@ } // namespace -ActiveGroupId MakeActiveGroupId(const std::string& trial_name, - const std::string& group_name) { +ActiveGroupId MakeActiveGroupId(base::StringPiece trial_name, + base::StringPiece group_name) { ActiveGroupId id; id.name = metrics::HashName(trial_name); id.group = metrics::HashName(group_name);
diff --git a/components/variations/active_field_trials.h b/components/variations/active_field_trials.h index 9e46677..486377b 100644 --- a/components/variations/active_field_trials.h +++ b/components/variations/active_field_trials.h
@@ -10,6 +10,7 @@ #include <string> #include "base/metrics/field_trial.h" +#include "base/strings/string_piece.h" namespace variations { @@ -21,8 +22,8 @@ }; // Returns an ActiveGroupId struct for the given trial and group names. -ActiveGroupId MakeActiveGroupId(const std::string& trial_name, - const std::string& group_name); +ActiveGroupId MakeActiveGroupId(base::StringPiece trial_name, + base::StringPiece group_name); // We need to supply a Compare class for templates since ActiveGroupId is a // user-defined type.
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 1b664a14..457e51b 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -1334,8 +1334,6 @@ "screen_orientation/screen_orientation_provider.h", "service_manager/common_browser_interfaces.cc", "service_manager/common_browser_interfaces.h", - "service_manager/merge_dictionary.cc", - "service_manager/merge_dictionary.h", "service_manager/service_manager_context.cc", "service_manager/service_manager_context.h", "service_worker/embedded_worker_instance.cc",
diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc index b3de3e5..d791db1 100644 --- a/content/browser/renderer_host/p2p/socket_dispatcher_host.cc +++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.cc
@@ -10,6 +10,7 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" +#include "base/task_scheduler/post_task.h" #include "content/browser/bad_message.h" #include "content/browser/renderer_host/p2p/socket_host.h" #include "content/common/p2p_messages.h" @@ -119,8 +120,9 @@ url_context_(url_context), monitoring_networks_(false), dump_incoming_rtp_packet_(false), - dump_outgoing_rtp_packet_(false) { -} + dump_outgoing_rtp_packet_(false), + network_list_task_runner_(base::CreateSequencedTaskRunnerWithTraits( + {base::MayBlock(), base::TaskPriority::USER_VISIBLE})) {} void P2PSocketDispatcherHost::OnChannelClosing() { // Since the IPC sender is gone, close pending connections. @@ -159,9 +161,8 @@ void P2PSocketDispatcherHost::OnIPAddressChanged() { // Notify the renderer about changes to list of network interfaces. - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, base::Bind( - &P2PSocketDispatcherHost::DoGetNetworkList, this)); + network_list_task_runner_->PostTask( + FROM_HERE, base::Bind(&P2PSocketDispatcherHost::DoGetNetworkList, this)); } void P2PSocketDispatcherHost::StartRtpDump( @@ -215,9 +216,8 @@ monitoring_networks_ = true; } - BrowserThread::PostTask( - BrowserThread::FILE, FROM_HERE, base::Bind( - &P2PSocketDispatcherHost::DoGetNetworkList, this)); + network_list_task_runner_->PostTask( + FROM_HERE, base::Bind(&P2PSocketDispatcherHost::DoGetNetworkList, this)); } void P2PSocketDispatcherHost::OnStopNetworkNotifications() { @@ -367,7 +367,7 @@ DCHECK(family == AF_INET || family == AF_INET6); // Creation and connection of a UDP socket might be janky. - DCHECK_CURRENTLY_ON(BrowserThread::FILE); + DCHECK(network_list_task_runner_->RunsTasksInCurrentSequence()); std::unique_ptr<net::DatagramClientSocket> socket( net::ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket(
diff --git a/content/browser/renderer_host/p2p/socket_dispatcher_host.h b/content/browser/renderer_host/p2p/socket_dispatcher_host.h index 59b69a9..be6b2d78 100644 --- a/content/browser/renderer_host/p2p/socket_dispatcher_host.h +++ b/content/browser/renderer_host/p2p/socket_dispatcher_host.h
@@ -14,6 +14,7 @@ #include <vector> #include "base/macros.h" +#include "base/sequenced_task_runner.h" #include "content/browser/renderer_host/p2p/socket_host_throttler.h" #include "content/common/p2p_socket_type.h" #include "content/public/browser/browser_message_filter.h" @@ -126,6 +127,10 @@ bool dump_outgoing_rtp_packet_; RenderProcessHost::WebRtcRtpPacketCallback packet_callback_; + // Used to call DoGetNetworkList, which may briefly block since getting the + // default local address involves creating a dummy socket. + const scoped_refptr<base::SequencedTaskRunner> network_list_task_runner_; + DISALLOW_COPY_AND_ASSIGN(P2PSocketDispatcherHost); };
diff --git a/content/browser/service_manager/merge_dictionary.h b/content/browser/service_manager/merge_dictionary.h deleted file mode 100644 index b29e1596..0000000 --- a/content/browser/service_manager/merge_dictionary.h +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2016 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_BROWSER_SERVICE_MANAGER_MERGE_DICTIONARY_H_ -#define CONTENT_BROWSER_SERVICE_MANAGER_MERGE_DICTIONARY_H_ - -#include "base/values.h" -#include "content/common/content_export.h" - -namespace content { - -// Similar to base::DictionaryValue::MergeDictionary(), except concatenates -// ListValue contents. -// This is explicitly not part of base::DictionaryValue at brettw's request. -void CONTENT_EXPORT MergeDictionary(base::DictionaryValue* target, - const base::DictionaryValue* source); - -} // namespace content - -#endif // CONTENT_BROWSER_SERVICE_MANAGER_MERGE_DICTIONARY_H_
diff --git a/content/browser/service_manager/service_manager_context.cc b/content/browser/service_manager/service_manager_context.cc index eee0ac9..18d7950 100644 --- a/content/browser/service_manager/service_manager_context.cc +++ b/content/browser/service_manager/service_manager_context.cc
@@ -21,7 +21,6 @@ #include "content/browser/child_process_launcher.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/service_manager/common_browser_interfaces.h" -#include "content/browser/service_manager/merge_dictionary.h" #include "content/browser/wake_lock/wake_lock_context_host.h" #include "content/common/service_manager/service_manager_connection_impl.h" #include "content/grit/content_resources.h" @@ -47,6 +46,7 @@ #include "services/resource_coordinator/public/interfaces/service_constants.mojom.h" #include "services/resource_coordinator/resource_coordinator_service.h" #include "services/service_manager/connect_params.h" +#include "services/service_manager/embedder/manifest_utils.h" #include "services/service_manager/public/cpp/connector.h" #include "services/service_manager/public/cpp/service.h" #include "services/service_manager/public/interfaces/service.mojom.h" @@ -129,15 +129,9 @@ std::unique_ptr<base::Value> overlay_value = GetContentClient()->browser()->GetServiceManifestOverlay(name); - if (overlay_value) { - base::DictionaryValue* manifest_dictionary = nullptr; - bool result = manifest_value->GetAsDictionary(&manifest_dictionary); - DCHECK(result); - base::DictionaryValue* overlay_dictionary = nullptr; - result = overlay_value->GetAsDictionary(&overlay_dictionary); - DCHECK(result); - MergeDictionary(manifest_dictionary, overlay_dictionary); - } + + service_manager::MergeManifestWithOverlay(manifest_value.get(), + overlay_value.get()); base::Optional<catalog::RequiredFileMap> required_files = catalog::RetrieveRequiredFiles(*manifest_value);
diff --git a/content/child/request_extra_data.cc b/content/child/request_extra_data.cc index aa76335..e18759d 100644 --- a/content/child/request_extra_data.cc +++ b/content/child/request_extra_data.cc
@@ -29,8 +29,7 @@ is_prefetch_(false), download_to_network_cache_only_(false), block_mixed_plugin_content_(false), - navigation_initiated_by_renderer_(false), - url_loader_factory_override_(nullptr) {} + navigation_initiated_by_renderer_(false) {} RequestExtraData::~RequestExtraData() { }
diff --git a/content/child/request_extra_data.h b/content/child/request_extra_data.h index 2855b49..5d35607d 100644 --- a/content/child/request_extra_data.h +++ b/content/child/request_extra_data.h
@@ -12,7 +12,6 @@ #include "content/child/web_url_loader_impl.h" #include "content/common/content_export.h" #include "content/common/navigation_params.h" -#include "content/common/url_loader_factory.mojom.h" #include "content/public/common/url_loader_throttle.h" #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" #include "third_party/WebKit/public/platform/WebString.h" @@ -169,13 +168,6 @@ navigation_initiated_by_renderer_ = navigation_by_renderer; } - mojom::URLLoaderFactory* url_loader_factory_override() const { - return url_loader_factory_override_; - } - void set_url_loader_factory_override(mojom::URLLoaderFactory* factory) { - url_loader_factory_override_ = factory; - } - std::vector<std::unique_ptr<URLLoaderThrottle>> TakeURLLoaderThrottles() { return std::move(url_loader_throttles_); } @@ -208,7 +200,6 @@ bool download_to_network_cache_only_; bool block_mixed_plugin_content_; bool navigation_initiated_by_renderer_; - mojom::URLLoaderFactory* url_loader_factory_override_; std::vector<std::unique_ptr<URLLoaderThrottle>> url_loader_throttles_; DISALLOW_COPY_AND_ASSIGN(RequestExtraData);
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc index c0e2943..956cf1eae 100644 --- a/content/child/web_url_loader_impl.cc +++ b/content/child/web_url_loader_impl.cc
@@ -631,8 +631,6 @@ else extra_data = &empty_extra_data; extra_data->CopyToResourceRequest(resource_request.get()); - if (extra_data->url_loader_factory_override()) - url_loader_factory_ = extra_data->url_loader_factory_override(); if (sync_load_response) { DCHECK(defers_loading_ == NOT_DEFERRING);
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 0081a29c..7820e498 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -4343,18 +4343,6 @@ } } - // TODO: generalize how non-network schemes are sent to the renderer and used. - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableNetworkService)) { - if (request.Url().ProtocolIs(url::kBlobScheme)) { - extra_data->set_url_loader_factory_override( - RenderThreadImpl::current()->GetBlobURLLoaderFactory()); - } - } - - if (!extra_data->url_loader_factory_override()) - extra_data->set_url_loader_factory_override(url_loader_factory_.get()); - // TODO(kinuko, yzshen): We need to set up throttles for some worker cases // that don't go through here. extra_data->set_url_loader_throttles(std::move(throttles)); @@ -6714,8 +6702,22 @@ std::unique_ptr<blink::WebURLLoader> RenderFrameImpl::CreateURLLoader( const blink::WebURLRequest& request, base::SingleThreadTaskRunner* task_runner) { - // TODO(yhirano): Stop using Platform::CreateURLLoader() here. - return blink::Platform::Current()->CreateURLLoader(request, task_runner); + ChildThreadImpl* child_thread = ChildThreadImpl::current(); + const bool network_service_enabled = + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNetworkService); + if (network_service_enabled && child_thread) { + mojom::URLLoaderFactory* factory = url_loader_factory_.get(); + + if (request.Url().ProtocolIs(url::kBlobScheme)) + factory = RenderThreadImpl::current()->GetBlobURLLoaderFactory(); + + return base::MakeUnique<WebURLLoaderImpl>( + child_thread->resource_dispatcher(), task_runner, factory); + } + + return RenderThreadImpl::current()->blink_platform_impl()->CreateURLLoader( + request, task_runner); } void RenderFrameImpl::DraggableRegionsChanged() {
diff --git a/content/shell/android/BUILD.gn b/content/shell/android/BUILD.gn index eceffc1d..2a0443ee 100644 --- a/content/shell/android/BUILD.gn +++ b/content/shell/android/BUILD.gn
@@ -15,22 +15,10 @@ ] } -generate_jni_registration("content_shell_jni_registration") { - testonly = true - target = ":content_shell_apk" - output = "$root_gen_dir/content/shell/android/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] -} - shared_library("libcontent_shell_content_view") { testonly = true deps = [ ":content_shell_jni_headers", - ":content_shell_jni_registration", "//build/config:exe_and_shlib_deps", "//components/crash/content/browser", "//content/shell:content_shell_lib", @@ -38,17 +26,6 @@ "//media", "//skia", ] - - # Explicit dependency required for JNI registration to be able to - # find the native side functions. - if (is_component_build) { - deps += [ - "//device/gamepad", - "//device/generic_sensor", - "//device/sensors", - "//media/midi", - ] - } sources = [ "shell_library_loader.cc", ] @@ -265,7 +242,6 @@ deps = [ ":linker_test_jni_headers", - ":linker_test_jni_registration", "//build/config:exe_and_shlib_deps", "//content/shell:content_shell_lib", @@ -274,17 +250,6 @@ "//skia", "//third_party/re2", ] - - # Explicit dependency required for JNI registration to be able to - # find the native side functions. - if (is_component_build) { - deps += [ - "//device/gamepad", - "//device/generic_sensor", - "//device/sensors", - "//media/midi", - ] - } } generate_jni("linker_test_jni_headers") { @@ -294,18 +259,6 @@ "linker_test_apk/src/org/chromium/chromium_linker_test_apk/LinkerTests.java", ] } - - generate_jni_registration("linker_test_jni_registration") { - testonly = true - target = ":chromium_linker_test_apk__apk" - output = - "$root_gen_dir/content/shell/android/linker_test_apk/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] - } } android_library("content_shell_browsertests_java") {
diff --git a/content/shell/android/linker_test_apk/chromium_linker_test_android.cc b/content/shell/android/linker_test_apk/chromium_linker_test_android.cc index 310bb2a..19f9c47 100644 --- a/content/shell/android/linker_test_apk/chromium_linker_test_android.cc +++ b/content/shell/android/linker_test_apk/chromium_linker_test_android.cc
@@ -9,7 +9,6 @@ #include "content/public/app/content_main.h" #include "content/public/browser/android/compositor.h" #include "content/shell/android/linker_test_apk/chromium_linker_test_linker_tests.h" -#include "content/shell/android/linker_test_apk/linker_test_jni_registration.h" #include "content/shell/android/shell_jni_registrar.h" #include "content/shell/app/shell_main_delegate.h" @@ -41,11 +40,6 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!RegisterMainDexNatives(env) || !RegisterNonMainDexNatives(env)) { - return -1; - } - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (!content::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || !NativeInit()) { return -1;
diff --git a/content/shell/android/shell_library_loader.cc b/content/shell/android/shell_library_loader.cc index 8cd2e99..dc88bd67 100644 --- a/content/shell/android/shell_library_loader.cc +++ b/content/shell/android/shell_library_loader.cc
@@ -8,7 +8,6 @@ #include "content/public/app/content_jni_onload.h" #include "content/public/app/content_main.h" #include "content/public/browser/android/compositor.h" -#include "content/shell/android/content_shell_jni_registration.h" #include "content/shell/android/shell_jni_registrar.h" #include "content/shell/app/shell_main_delegate.h" @@ -34,12 +33,6 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!RegisterMainDexNatives(env) || !RegisterNonMainDexNatives(env)) { - return -1; - } - - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (!content::android::OnJNIOnLoadRegisterJNI(env) || !RegisterJNI(env) || !NativeInit()) { return -1;
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index d1855cb..7ea62c4 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -1301,7 +1301,6 @@ "../browser/renderer_host/text_input_client_mac_unittest.mm", "../browser/resolve_proxy_msg_helper_unittest.cc", "../browser/screen_orientation/screen_orientation_provider_unittest.cc", - "../browser/service_manager/merge_dictionary_unittest.cc", "../browser/service_worker/embedded_worker_instance_unittest.cc", "../browser/service_worker/foreign_fetch_request_handler_unittest.cc", "../browser/service_worker/link_header_support_unittest.cc",
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index a14bbdf..3cdc37d 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc
@@ -5,6 +5,8 @@ #include "content/test/test_render_frame.h" #include "base/memory/ptr_util.h" +#include "base/threading/thread_task_runner_handle.h" +#include "content/child/web_url_loader_impl.h" #include "content/common/frame_messages.h" #include "content/common/navigation_params.h" #include "content/common/resource_request_body_impl.h" @@ -122,6 +124,13 @@ return RenderFrameImpl::DecidePolicyForNavigation(info); } +std::unique_ptr<blink::WebURLLoader> TestRenderFrame::CreateURLLoader( + const blink::WebURLRequest& request, + base::SingleThreadTaskRunner* task_runner) { + return base::MakeUnique<WebURLLoaderImpl>( + nullptr, base::ThreadTaskRunnerHandle::Get(), nullptr); +} + mojom::FrameHostAssociatedPtr TestRenderFrame::GetFrameHost() { mojom::FrameHostAssociatedPtr ptr = RenderFrameImpl::GetFrameHost();
diff --git a/content/test/test_render_frame.h b/content/test/test_render_frame.h index 448ac93..c5eb744 100644 --- a/content/test/test_render_frame.h +++ b/content/test/test_render_frame.h
@@ -54,6 +54,10 @@ blink::WebNavigationPolicy DecidePolicyForNavigation( const blink::WebFrameClient::NavigationPolicyInfo& info) override; + std::unique_ptr<blink::WebURLLoader> CreateURLLoader( + const blink::WebURLRequest& request, + base::SingleThreadTaskRunner* task_runner) override; + mojom::FrameHostAssociatedPtr GetFrameHost() override; private:
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index 10bc0c8c..d6b878c 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -1092,6 +1092,9 @@ <message name="IDS_IOS_SAFE_MODE_UNKNOWN_CAUSE" desc="The message indicating that Chrome crashed for an unknown reason. [Length: 140em]"> Something went really wrong. We'll work on that. </message> + <message name="IDS_IOS_SAVE_IMAGE_NO_INTERNET_CONNECTION" desc="Message informing the user that the image could not be saved because the device has no internet connection."> + No internet connection. + </message> <message name="IDS_IOS_SAVE_IMAGE_PRIVACY_ALERT_GO_TO_SETTINGS" desc="Title for a button to go to System settings app. [Length: 25em] [iOS only]."> Settings </message>
diff --git a/ios/chrome/browser/content_suggestions/BUILD.gn b/ios/chrome/browser/content_suggestions/BUILD.gn index 06a438a..7aebf2d1 100644 --- a/ios/chrome/browser/content_suggestions/BUILD.gn +++ b/ios/chrome/browser/content_suggestions/BUILD.gn
@@ -5,6 +5,9 @@ source_set("content_suggestions") { configs += [ "//build/config/compiler:enable_arc" ] sources = [ + "content_suggestions_alert_commands.h", + "content_suggestions_alert_factory.h", + "content_suggestions_alert_factory.mm", "content_suggestions_category_wrapper.h", "content_suggestions_category_wrapper.mm", "content_suggestions_coordinator.h", @@ -73,3 +76,27 @@ ] configs += [ "//build/config/compiler:enable_arc" ] } + +source_set("eg_tests") { + configs += [ "//build/config/compiler:enable_arc" ] + testonly = true + sources = [ + "content_suggestions_alert_egtest.mm", + ] + deps = [ + ":content_suggestions", + "//base", + "//base/test:test_support", + "//ios/chrome/app/strings", + "//ios/chrome/browser/ui/alert_coordinator", + "//ios/chrome/browser/ui/alert_coordinator", + "//ios/chrome/browser/ui/collection_view/cells", + "//ios/chrome/browser/ui/util", + "//ios/chrome/test/earl_grey:test_support", + "//ui/strings", + ] + libs = [ + "UIKit.framework", + "XCTest.framework", + ] +}
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h b/ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h new file mode 100644 index 0000000..d734e65 --- /dev/null +++ b/ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h
@@ -0,0 +1,39 @@ +// Copyright 2017 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 IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_ +#define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_ + +#import <UIKit/UIKit.h> + +@class CollectionViewItem; + +// Command protocol for the ContentSuggestionsAlertFactory, handling the +// callbacks from the alerts. +@protocol ContentSuggestionsAlertCommands + +// Opens the URL corresponding to the |item| in a new tab, |incognito| or not. +// The item has to be a suggestion item. +- (void)openNewTabWithSuggestionsItem:(nonnull CollectionViewItem*)item + incognito:(BOOL)incognito; + +// Adds the |item| to the reading list. The item has to be a suggestion item. +- (void)addItemToReadingList:(nonnull CollectionViewItem*)item; + +// Dismiss the |item| at |indexPath|. The item has to be a suggestion item. +- (void)dismissSuggestion:(nonnull CollectionViewItem*)item + atIndexPath:(nonnull NSIndexPath*)indexPath; + +// Open the URL corresponding to the |item| in a new tab, |incognito| or not. +// The item has to be a Most Visited item. +- (void)openNewTabWithMostVisitedItem:(nonnull CollectionViewItem*)item + incognito:(BOOL)incognito + atIndex:(NSInteger)mostVisitedIndex; + +// Removes the most visited |item|. +- (void)removeMostVisited:(nonnull CollectionViewItem*)item; + +@end + +#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_COMMANDS_H_
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_alert_egtest.mm b/ios/chrome/browser/content_suggestions/content_suggestions_alert_egtest.mm new file mode 100644 index 0000000..05399ae1 --- /dev/null +++ b/ios/chrome/browser/content_suggestions/content_suggestions_alert_egtest.mm
@@ -0,0 +1,95 @@ +// Copyright 2017 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. + +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h" + +#import <EarlGrey/EarlGrey.h> +#import <XCTest/XCTest.h> + +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h" +#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" +#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" +#import "ios/chrome/browser/ui/util/top_view_controller.h" +#include "ios/chrome/grit/ios_strings.h" +#import "ios/chrome/test/earl_grey/chrome_matchers.h" +#import "ios/chrome/test/earl_grey/chrome_test_case.h" +#include "ui/strings/grit/ui_strings.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@interface ContentSuggestionsAlertFactoryTestCase : XCTestCase + +@end + +@implementation ContentSuggestionsAlertFactoryTestCase + +- (void)testSuggestionsAlert { + UIViewController* viewController = + top_view_controller::TopPresentedViewController(); + AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory + alertCoordinatorForSuggestionItem:nil + onViewController:viewController + atPoint:CGPointMake(50, 50) + atIndexPath:nil + commandHandler:nil]; + [coordinator start]; + + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey selectElementWithMatcher: + chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_APP_CANCEL)] + assertWithMatcher:grey_interactable()]; + + [coordinator stop]; +} + +- (void)testMostVisitedAlert { + UIViewController* viewController = + top_view_controller::TopPresentedViewController(); + AlertCoordinator* coordinator = [ContentSuggestionsAlertFactory + alertCoordinatorForSuggestionItem:nil + onViewController:viewController + atPoint:CGPointMake(50, 50) + atIndexPath:nil + commandHandler:nil]; + [coordinator start]; + + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey selectElementWithMatcher: + chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_IOS_CONTENT_SUGGESTIONS_REMOVE)] + assertWithMatcher:grey_interactable()]; + [[EarlGrey + selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( + IDS_APP_CANCEL)] + assertWithMatcher:grey_interactable()]; + + [coordinator stop]; +} + +@end
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h b/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h new file mode 100644 index 0000000..accca13 --- /dev/null +++ b/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h
@@ -0,0 +1,41 @@ +// Copyright 2017 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 IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_FACTORY_H_ +#define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_FACTORY_H_ + +#import <UIKit/UIKit.h> + +@class AlertCoordinator; +@class CollectionViewItem; +@protocol ContentSuggestionsAlertCommands; + +// Factory for AlertCoordinators for ContentSuggestions. +@interface ContentSuggestionsAlertFactory : NSObject + +// Returns an AlertCoordinator for a suggestions |item| with the indexPath +// |indexPath|. The alert will be presented on the |viewController| at the +// |touchLocation|, in the coordinates of the |viewController|'s view. The +// |commandHandler| will receive callbacks when the user chooses one of the +// options displayed by the alert. ++ (AlertCoordinator*) +alertCoordinatorForSuggestionItem:(CollectionViewItem*)item + onViewController:(UIViewController*)viewController + atPoint:(CGPoint)touchLocation + atIndexPath:(NSIndexPath*)indexPath + commandHandler: + (id<ContentSuggestionsAlertCommands>)commandHandler; + +// Same as above but for a MostVisited item. ++ (AlertCoordinator*) +alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item + onViewController:(UIViewController*)viewController + atPoint:(CGPoint)touchLocation + atIndexPath:(NSIndexPath*)indexPath + commandHandler: + (id<ContentSuggestionsAlertCommands>)commandHandler; + +@end + +#endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_ALERT_FACTORY_H_
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.mm b/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.mm new file mode 100644 index 0000000..1deedfb5 --- /dev/null +++ b/ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.mm
@@ -0,0 +1,167 @@ +// Copyright 2017 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. + +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h" + +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h" +#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" +#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" +#include "ios/chrome/grit/ios_strings.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/strings/grit/ui_strings.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@implementation ContentSuggestionsAlertFactory + ++ (AlertCoordinator*) +alertCoordinatorForSuggestionItem:(CollectionViewItem*)item + onViewController:(UIViewController*)viewController + atPoint:(CGPoint)touchLocation + atIndexPath:(NSIndexPath*)indexPath + commandHandler: + (id<ContentSuggestionsAlertCommands>)commandHandler { + AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] + initWithBaseViewController:viewController + title:nil + message:nil + rect:CGRectMake(touchLocation.x, touchLocation.y, 0, + 0) + view:[viewController view]]; + + __weak CollectionViewItem* weakItem = item; + __weak id<ContentSuggestionsAlertCommands> weakCommandHandler = + commandHandler; + + NSString* openInNewTabTitle = + l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); + [alertCoordinator addItemWithTitle:openInNewTabTitle + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + // TODO(crbug.com/691979): Add metrics. + [weakCommandHandler + openNewTabWithSuggestionsItem:strongItem + incognito:NO]; + } + } + style:UIAlertActionStyleDefault]; + + NSString* openInNewTabIncognitoTitle = + l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB); + [alertCoordinator addItemWithTitle:openInNewTabIncognitoTitle + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + // TODO(crbug.com/691979): Add metrics. + [weakCommandHandler + openNewTabWithSuggestionsItem:strongItem + incognito:YES]; + } + } + style:UIAlertActionStyleDefault]; + + NSString* readLaterTitle = + l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); + [alertCoordinator + addItemWithTitle:readLaterTitle + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + // TODO(crbug.com/691979): Add metrics. + [weakCommandHandler addItemToReadingList:strongItem]; + } + } + style:UIAlertActionStyleDefault]; + + NSString* deleteTitle = + l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE); + [alertCoordinator addItemWithTitle:deleteTitle + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + // TODO(crbug.com/691979): Add metrics. + [weakCommandHandler + dismissSuggestion:strongItem + atIndexPath:indexPath]; + } + } + style:UIAlertActionStyleDestructive]; + + [alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) + action:^{ + // TODO(crbug.com/691979): Add metrics. + } + style:UIAlertActionStyleCancel]; + return alertCoordinator; +} + ++ (AlertCoordinator*) +alertCoordinatorForMostVisitedItem:(CollectionViewItem*)item + onViewController:(UIViewController*)viewController + atPoint:(CGPoint)touchLocation + atIndexPath:(NSIndexPath*)indexPath + commandHandler: + (id<ContentSuggestionsAlertCommands>)commandHandler { + AlertCoordinator* alertCoordinator = [[ActionSheetCoordinator alloc] + initWithBaseViewController:viewController + title:nil + message:nil + rect:CGRectMake(touchLocation.x, touchLocation.y, 0, + 0) + view:[viewController view]]; + + __weak CollectionViewItem* weakItem = item; + __weak id<ContentSuggestionsAlertCommands> weakCommandHandler = + commandHandler; + + [alertCoordinator + addItemWithTitle:l10n_util::GetNSStringWithFixup( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + [weakCommandHandler + openNewTabWithMostVisitedItem:strongItem + incognito:NO + atIndex:indexPath.item]; + } + } + style:UIAlertActionStyleDefault]; + + [alertCoordinator + addItemWithTitle:l10n_util::GetNSStringWithFixup( + IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + [weakCommandHandler + openNewTabWithMostVisitedItem:strongItem + incognito:YES + atIndex:indexPath.item]; + } + } + style:UIAlertActionStyleDefault]; + + [alertCoordinator + addItemWithTitle:l10n_util::GetNSStringWithFixup( + IDS_IOS_CONTENT_SUGGESTIONS_REMOVE) + action:^{ + CollectionViewItem* strongItem = weakItem; + if (strongItem) { + [weakCommandHandler removeMostVisited:strongItem]; + } + } + style:UIAlertActionStyleDestructive]; + + [alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) + action:nil + style:UIAlertActionStyleCancel]; + + return alertCoordinator; +} + +@end
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm index 2d3ee36..c42c369 100644 --- a/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm +++ b/ios/chrome/browser/content_suggestions/content_suggestions_coordinator.mm
@@ -16,6 +16,8 @@ #include "components/reading_list/core/reading_list_model.h" #include "components/strings/grit/components_strings.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h" +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_commands.h" +#import "ios/chrome/browser/content_suggestions/content_suggestions_alert_factory.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_header_controller.h" #import "ios/chrome/browser/content_suggestions/content_suggestions_mediator.h" #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" @@ -23,7 +25,7 @@ #include "ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.h" #include "ios/chrome/browser/ntp_tiles/ios_most_visited_sites_factory.h" #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" -#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" +#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h" @@ -52,6 +54,7 @@ #endif @interface ContentSuggestionsCoordinator ()< + ContentSuggestionsAlertCommands, ContentSuggestionsCommands, ContentSuggestionsHeaderCommands, ContentSuggestionsViewControllerDelegate, @@ -71,13 +74,6 @@ // |YES| if the fakebox header should be animated on scroll. @property(nonatomic, assign) BOOL animateHeader; -// Opens the |URL| in a new tab |incognito| or not. -- (void)openNewTabWithURL:(const GURL&)URL incognito:(BOOL)incognito; -// Dismisses the |article|, removing it from the content service, and dismisses -// the item at |indexPath| in the view controller. -- (void)dismissArticle:(ContentSuggestionsItem*)article - atIndexPath:(NSIndexPath*)indexPath; - @end @implementation ContentSuggestionsCoordinator @@ -169,8 +165,6 @@ referrer:web::Referrer() transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK rendererInitiated:NO]; - - [self stop]; } - (void)openMostVisitedItem:(CollectionViewItem*)item @@ -184,85 +178,17 @@ referrer:web::Referrer() transition:ui::PAGE_TRANSITION_AUTO_BOOKMARK rendererInitiated:NO]; - - [self stop]; } - (void)displayContextMenuForArticle:(CollectionViewItem*)item atPoint:(CGPoint)touchLocation atIndexPath:(NSIndexPath*)indexPath { - ContentSuggestionsItem* articleItem = - base::mac::ObjCCastStrict<ContentSuggestionsItem>(item); - self.alertCoordinator = [[ActionSheetCoordinator alloc] - initWithBaseViewController:self.suggestionsViewController - title:nil - message:nil - rect:CGRectMake(touchLocation.x, touchLocation.y, 0, - 0) - view:self.suggestionsViewController.collectionView]; - - __weak ContentSuggestionsCoordinator* weakSelf = self; - GURL articleURL = articleItem.URL; - NSString* articleTitle = articleItem.title; - __weak ContentSuggestionsItem* weakArticle = articleItem; - - NSString* openInNewTabTitle = - l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); - [self.alertCoordinator - addItemWithTitle:openInNewTabTitle - action:^{ - // TODO(crbug.com/691979): Add metrics. - [weakSelf openNewTabWithURL:articleURL incognito:NO]; - } - style:UIAlertActionStyleDefault]; - - NSString* openInNewTabIncognitoTitle = - l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB); - [self.alertCoordinator - addItemWithTitle:openInNewTabIncognitoTitle - action:^{ - // TODO(crbug.com/691979): Add metrics. - [weakSelf openNewTabWithURL:articleURL incognito:YES]; - } - style:UIAlertActionStyleDefault]; - - NSString* readLaterTitle = - l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); - [self.alertCoordinator - addItemWithTitle:readLaterTitle - action:^{ - ContentSuggestionsCoordinator* strongSelf = weakSelf; - if (!strongSelf) - return; - - base::RecordAction( - base::UserMetricsAction("MobileReadingListAdd")); - // TODO(crbug.com/691979): Add metrics. - - ReadingListModel* readingModel = - ReadingListModelFactory::GetForBrowserState( - strongSelf.browserState); - readingModel->AddEntry(articleURL, - base::SysNSStringToUTF8(articleTitle), - reading_list::ADDED_VIA_CURRENT_APP); - } - style:UIAlertActionStyleDefault]; - - NSString* deleteTitle = - l10n_util::GetNSString(IDS_IOS_CONTENT_SUGGESTIONS_REMOVE); - [self.alertCoordinator addItemWithTitle:deleteTitle - action:^{ - // TODO(crbug.com/691979): Add metrics. - [weakSelf dismissArticle:weakArticle - atIndexPath:indexPath]; - } - style:UIAlertActionStyleDestructive]; - - [self.alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) - action:^{ - // TODO(crbug.com/691979): Add metrics. - } - style:UIAlertActionStyleCancel]; + self.alertCoordinator = [ContentSuggestionsAlertFactory + alertCoordinatorForSuggestionItem:item + onViewController:self.suggestionsViewController + atPoint:touchLocation + atIndexPath:indexPath + commandHandler:self]; [self.alertCoordinator start]; } @@ -270,68 +196,12 @@ - (void)displayContextMenuForMostVisitedItem:(CollectionViewItem*)item atPoint:(CGPoint)touchLocation atIndexPath:(NSIndexPath*)indexPath { - ContentSuggestionsMostVisitedItem* mostVisitedItem = - base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item); - self.alertCoordinator = [[ActionSheetCoordinator alloc] - initWithBaseViewController:self.suggestionsViewController - title:nil - message:nil - rect:CGRectMake(touchLocation.x, touchLocation.y, 0, - 0) - view:self.suggestionsViewController.collectionView]; - - __weak ContentSuggestionsCoordinator* weakSelf = self; - __weak ContentSuggestionsMostVisitedItem* weakItem = mostVisitedItem; - - [self.alertCoordinator - addItemWithTitle:l10n_util::GetNSStringWithFixup( - IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) - action:^{ - ContentSuggestionsCoordinator* strongSelf = weakSelf; - ContentSuggestionsMostVisitedItem* strongItem = weakItem; - if (!strongSelf || !strongItem) - return; - [strongSelf logMostVisitedOpening:strongItem - atIndex:indexPath.item]; - [strongSelf openNewTabWithURL:strongItem.URL incognito:NO]; - } - style:UIAlertActionStyleDefault]; - - if (!self.browserState->IsOffTheRecord()) { - [self.alertCoordinator - addItemWithTitle:l10n_util::GetNSStringWithFixup( - IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) - action:^{ - ContentSuggestionsCoordinator* strongSelf = weakSelf; - ContentSuggestionsMostVisitedItem* strongItem = weakItem; - if (!strongSelf || !strongItem) - return; - [strongSelf logMostVisitedOpening:strongItem - atIndex:indexPath.item]; - [strongSelf openNewTabWithURL:strongItem.URL incognito:YES]; - } - style:UIAlertActionStyleDefault]; - } - - [self.alertCoordinator - addItemWithTitle:l10n_util::GetNSStringWithFixup( - IDS_IOS_CONTENT_SUGGESTIONS_REMOVE) - action:^{ - ContentSuggestionsCoordinator* strongSelf = weakSelf; - ContentSuggestionsMostVisitedItem* strongItem = weakItem; - if (!strongSelf || !strongItem) - return; - base::RecordAction( - base::UserMetricsAction("MostVisited_UrlBlacklisted")); - [strongSelf.contentSuggestionsMediator - blacklistMostVisitedURL:strongItem.URL]; - [strongSelf showMostVisitedUndoForURL:strongItem.URL]; - } - style:UIAlertActionStyleDestructive]; - - [self.alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) - action:nil - style:UIAlertActionStyleCancel]; + self.alertCoordinator = [ContentSuggestionsAlertFactory + alertCoordinatorForMostVisitedItem:item + onViewController:self.suggestionsViewController + atPoint:touchLocation + atIndexPath:indexPath + commandHandler:self]; [self.alertCoordinator start]; } @@ -364,6 +234,54 @@ NOTREACHED(); } +#pragma mark - ContentSuggestionsAlertCommands + +- (void)openNewTabWithSuggestionsItem:(CollectionViewItem*)item + incognito:(BOOL)incognito { + ContentSuggestionsItem* suggestionsItem = + base::mac::ObjCCastStrict<ContentSuggestionsItem>(item); + [self openNewTabWithURL:suggestionsItem.URL incognito:incognito]; +} + +- (void)addItemToReadingList:(CollectionViewItem*)item { + ContentSuggestionsItem* suggestionsItem = + base::mac::ObjCCastStrict<ContentSuggestionsItem>(item); + base::RecordAction(base::UserMetricsAction("MobileReadingListAdd")); + ReadingListModel* readingModel = + ReadingListModelFactory::GetForBrowserState(self.browserState); + readingModel->AddEntry(suggestionsItem.URL, + base::SysNSStringToUTF8(suggestionsItem.title), + reading_list::ADDED_VIA_CURRENT_APP); +} + +- (void)dismissSuggestion:(CollectionViewItem*)item + atIndexPath:(NSIndexPath*)indexPath { + ContentSuggestionsItem* suggestionsItem = + base::mac::ObjCCastStrict<ContentSuggestionsItem>(item); + + // TODO(crbug.com/691979): Add metrics. + [self.contentSuggestionsMediator + dismissSuggestion:suggestionsItem.suggestionIdentifier]; + [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; +} + +- (void)openNewTabWithMostVisitedItem:(CollectionViewItem*)item + incognito:(BOOL)incognito + atIndex:(NSInteger)index { + ContentSuggestionsMostVisitedItem* mostVisitedItem = + base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item); + [self logMostVisitedOpening:mostVisitedItem atIndex:index]; + [self openNewTabWithURL:mostVisitedItem.URL incognito:incognito]; +} + +- (void)removeMostVisited:(CollectionViewItem*)item { + ContentSuggestionsMostVisitedItem* mostVisitedItem = + base::mac::ObjCCastStrict<ContentSuggestionsMostVisitedItem>(item); + base::RecordAction(base::UserMetricsAction("MostVisited_UrlBlacklisted")); + [self.contentSuggestionsMediator blacklistMostVisitedURL:mostVisitedItem.URL]; + [self showMostVisitedUndoForURL:mostVisitedItem.URL]; +} + #pragma mark - ContentSuggestionsHeaderCommands - (void)updateFakeOmniboxForScrollView:(UIScrollView*)scrollView { @@ -487,6 +405,7 @@ #pragma mark - Private +// Opens the |URL| in a new tab |incognito| or not. - (void)openNewTabWithURL:(const GURL&)URL incognito:(BOOL)incognito { // TODO(crbug.com/691979): Add metrics. @@ -495,19 +414,6 @@ inIncognito:incognito inBackground:NO appendTo:kCurrentTab]; - - [self stop]; -} - -- (void)dismissArticle:(ContentSuggestionsItem*)article - atIndexPath:(NSIndexPath*)indexPath { - if (!article) - return; - - // TODO(crbug.com/691979): Add metrics. - [self.contentSuggestionsMediator - dismissSuggestion:article.suggestionIdentifier]; - [self.suggestionsViewController dismissEntryAtIndexPath:indexPath]; } // Logs a histogram due to a Most Visited item being opened.
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm index 8e0f5f9..966f4be 100644 --- a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm +++ b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
@@ -257,6 +257,13 @@ known_suggestion_ids.insert(identifier.IDInSection); } + if (known_suggestion_ids.size() == 0) { + // No elements in the section, reloads everything to have suggestions + // for the next NTP. Fetch() do not store the new data. + self.contentService->ReloadSuggestions(); + return; + } + __weak ContentSuggestionsMediator* weakSelf = self; ntp_snippets::FetchDoneCallback serviceCallback = base::Bind( &BindWrapper,
diff --git a/ios/chrome/browser/signin/BUILD.gn b/ios/chrome/browser/signin/BUILD.gn index 6171f03..6134059 100644 --- a/ios/chrome/browser/signin/BUILD.gn +++ b/ios/chrome/browser/signin/BUILD.gn
@@ -3,6 +3,7 @@ # found in the LICENSE file. source_set("signin") { + configs += [ "//build/config/compiler:enable_arc" ] sources = [ "about_signin_internals_factory.cc", "about_signin_internals_factory.h",
diff --git a/ios/chrome/browser/signin/account_consistency_service_factory.mm b/ios/chrome/browser/signin/account_consistency_service_factory.mm index 43409ac..318db6a 100644 --- a/ios/chrome/browser/signin/account_consistency_service_factory.mm +++ b/ios/chrome/browser/signin/account_consistency_service_factory.mm
@@ -15,6 +15,10 @@ #include "ios/chrome/browser/signin/signin_client_factory.h" #include "ios/chrome/browser/signin/signin_manager_factory.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + namespace ios { AccountConsistencyServiceFactory::AccountConsistencyServiceFactory()
diff --git a/ios/chrome/browser/signin/authentication_service.mm b/ios/chrome/browser/signin/authentication_service.mm index 37501c3..109946a 100644 --- a/ios/chrome/browser/signin/authentication_service.mm +++ b/ios/chrome/browser/signin/authentication_service.mm
@@ -37,6 +37,10 @@ #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + namespace { // Enum describing the different sync states per login methods. @@ -119,20 +123,20 @@ OnApplicationEnterForeground(); NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - foreground_observer_.reset( - [[center addObserverForName:UIApplicationWillEnterForegroundNotification - object:nil - queue:nil - usingBlock:^(NSNotification* notification) { - OnApplicationEnterForeground(); - }] retain]); - background_observer_.reset( - [[center addObserverForName:UIApplicationDidEnterBackgroundNotification - object:nil - queue:nil - usingBlock:^(NSNotification* notification) { - OnApplicationEnterBackground(); - }] retain]); + foreground_observer_.reset([center + addObserverForName:UIApplicationWillEnterForegroundNotification + object:nil + queue:nil + usingBlock:^(NSNotification* notification) { + OnApplicationEnterForeground(); + }]); + background_observer_.reset([center + addObserverForName:UIApplicationDidEnterBackgroundNotification + object:nil + queue:nil + usingBlock:^(NSNotification* notification) { + OnApplicationEnterBackground(); + }]); identity_service_observer_.Add( ios::GetChromeBrowserProvider()->GetChromeIdentityService()); @@ -490,7 +494,7 @@ }; if (identity_service->HandleMDMNotification(identity, user_info, callback)) { cached_mdm_infos_[ChromeIdentityToAccountID(browser_state_, identity)] - .reset([user_info retain]); + .reset(user_info); return true; } return false;
diff --git a/ios/chrome/browser/signin/authentication_service_factory.mm b/ios/chrome/browser/signin/authentication_service_factory.mm index 8910744f..f0bc6fd 100644 --- a/ios/chrome/browser/signin/authentication_service_factory.mm +++ b/ios/chrome/browser/signin/authentication_service_factory.mm
@@ -16,6 +16,10 @@ #include "ios/chrome/browser/signin/signin_manager_factory.h" #include "ios/chrome/browser/sync/sync_setup_service_factory.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + // static AuthenticationService* AuthenticationServiceFactory::GetForBrowserState( ios::ChromeBrowserState* browser_state) {
diff --git a/ios/chrome/browser/signin/browser_state_data_remover.mm b/ios/chrome/browser/signin/browser_state_data_remover.mm index 8a4c63c7..3a5c8bb 100644 --- a/ios/chrome/browser/signin/browser_state_data_remover.mm +++ b/ios/chrome/browser/signin/browser_state_data_remover.mm
@@ -14,6 +14,10 @@ #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" #import "ios/chrome/browser/ui/commands/clear_browsing_data_command.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + namespace { const int kRemoveAllDataMask = ~0; } @@ -49,11 +53,10 @@ DCHECK(!callback_); callback_.reset([callback copy]); - base::scoped_nsobject<ClearBrowsingDataCommand> command( - [[ClearBrowsingDataCommand alloc] - initWithBrowserState:browser_state_ - mask:kRemoveAllDataMask - timePeriod:browsing_data::TimePeriod::ALL_TIME]); + ClearBrowsingDataCommand* command = [[ClearBrowsingDataCommand alloc] + initWithBrowserState:browser_state_ + mask:kRemoveAllDataMask + timePeriod:browsing_data::TimePeriod::ALL_TIME]; UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow]; DCHECK(mainWindow);
diff --git a/ios/chrome/browser/signin/chrome_identity_service_observer_bridge.mm b/ios/chrome/browser/signin/chrome_identity_service_observer_bridge.mm index 4f47925..46886bd 100644 --- a/ios/chrome/browser/signin/chrome_identity_service_observer_bridge.mm +++ b/ios/chrome/browser/signin/chrome_identity_service_observer_bridge.mm
@@ -7,6 +7,10 @@ #include "base/logging.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + ChromeIdentityServiceObserverBridge::ChromeIdentityServiceObserverBridge( id<ChromeIdentityServiceObserver> observer) : observer_(observer), scoped_observer_(this) {
diff --git a/ios/chrome/browser/signin/constants.mm b/ios/chrome/browser/signin/constants.mm index 220bc3d..431a985 100644 --- a/ios/chrome/browser/signin/constants.mm +++ b/ios/chrome/browser/signin/constants.mm
@@ -4,6 +4,10 @@ #include "ios/chrome/browser/signin/constants.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + NSString* kAuthenticationErrorDomain = @"ChromeSigninError"; NSString* kGoogleServiceAuthErrorState = @"GoogleServiceAuthErrorState";
diff --git a/ios/chrome/browser/signin/gaia_auth_fetcher_ios.mm b/ios/chrome/browser/signin/gaia_auth_fetcher_ios.mm index 4eb5741b..1b05d07 100644 --- a/ios/chrome/browser/signin/gaia_auth_fetcher_ios.mm +++ b/ios/chrome/browser/signin/gaia_auth_fetcher_ios.mm
@@ -10,7 +10,6 @@ #include "base/logging.h" #import "base/mac/foundation_util.h" #include "base/mac/scoped_block.h" -#import "base/mac/scoped_nsobject.h" #include "base/strings/sys_string_conversions.h" #include "ios/chrome/browser/signin/gaia_auth_fetcher_ios_private.h" #include "ios/web/public/browser_state.h" @@ -21,6 +20,10 @@ #include "net/http/http_request_headers.h" #include "net/url_request/url_request_status.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + namespace { // Whether the iOS specialization of the GaiaAuthFetcher should be used. @@ -81,8 +84,8 @@ NSURLRequest* GetRequest(const std::string& body, const std::string& headers, const GURL& url) { - base::scoped_nsobject<NSMutableURLRequest> request( - [[NSMutableURLRequest alloc] initWithURL:net::NSURLWithGURL(url)]); + NSMutableURLRequest* request = + [[NSMutableURLRequest alloc] initWithURL:net::NSURLWithGURL(url)]; net::HttpRequestHeaders request_headers; request_headers.AddHeadersFromString(headers); for (net::HttpRequestHeaders::Iterator it(request_headers); it.GetNext();) { @@ -98,7 +101,7 @@ [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; } - return request.autorelease(); + return request; } // Escapes and quotes |value| and converts the result to an NSString. @@ -281,7 +284,7 @@ return nil; } if (!web_view_) { - web_view_.reset([BuildWKWebView() retain]); + web_view_.reset(BuildWKWebView()); navigation_delegate_.reset( [[GaiaAuthFetcherNavigationDelegate alloc] initWithBridge:this]); [web_view_ setNavigationDelegate:navigation_delegate_];
diff --git a/ios/chrome/browser/signin/oauth2_token_service_factory.mm b/ios/chrome/browser/signin/oauth2_token_service_factory.mm index fe5f8d6a..9a1e8e9 100644 --- a/ios/chrome/browser/signin/oauth2_token_service_factory.mm +++ b/ios/chrome/browser/signin/oauth2_token_service_factory.mm
@@ -17,6 +17,10 @@ #include "ios/chrome/browser/signin/signin_client_factory.h" #include "ios/chrome/browser/signin/signin_error_controller_factory.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + OAuth2TokenServiceFactory::OAuth2TokenServiceFactory() : BrowserStateKeyedServiceFactory( "ProfileOAuth2TokenService",
diff --git a/ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_impl.mm b/ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_impl.mm index f83189b..bcef1cd2 100644 --- a/ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_impl.mm +++ b/ios/chrome/browser/signin/profile_oauth2_token_service_ios_provider_impl.mm
@@ -13,6 +13,10 @@ #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" #include "ios/public/provider/chrome/browser/signin/signin_error_provider.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + namespace { // Returns the account info for |identity|. // Returns an empty account info if |identity| is nil.
diff --git a/ios/chrome/browser/signin/signin_client_impl.mm b/ios/chrome/browser/signin/signin_client_impl.mm index 1895cd66..c1644816 100644 --- a/ios/chrome/browser/signin/signin_client_impl.mm +++ b/ios/chrome/browser/signin/signin_client_impl.mm
@@ -36,6 +36,10 @@ #include "net/url_request/url_request_context_getter.h" #include "url/gurl.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + SigninClientImpl::SigninClientImpl( ios::ChromeBrowserState* browser_state, SigninErrorController* signin_error_controller)
diff --git a/ios/chrome/browser/signin/signin_util.mm b/ios/chrome/browser/signin/signin_util.mm index a8d66e7..5babbb72 100644 --- a/ios/chrome/browser/signin/signin_util.mm +++ b/ios/chrome/browser/signin/signin_util.mm
@@ -10,8 +10,12 @@ #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" #include "ios/public/provider/chrome/browser/signin/signin_error_provider.h" +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + NSArray* GetScopeArray(const std::set<std::string>& scopes) { - NSMutableArray* scopes_array = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* scopes_array = [[NSMutableArray alloc] init]; for (const auto& scope : scopes) { [scopes_array addObject:base::SysUTF8ToNSString(scope)]; }
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm index ea57dee5..39998f93 100644 --- a/ios/chrome/browser/ui/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -3254,6 +3254,13 @@ NSData* data, const image_fetcher::RequestMetadata& metadata) { DCHECK(data); + if ([data length] == 0) { + [self displayPrivacyErrorAlertOnMainQueue: + l10n_util::GetNSString( + IDS_IOS_SAVE_IMAGE_NO_INTERNET_CONNECTION)]; + return; + } + base::FilePath::StringType extension; bool extensionSuccess =
diff --git a/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm b/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm index e5dfdab..6748805 100644 --- a/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm +++ b/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
@@ -373,27 +373,10 @@ if (_viewLoaded) { [_doodleHeightConstraint setConstant:content_suggestions::doodleHeight(self.logoIsShowing)]; - - // Adjust the height of |_headerView| to fit its content which may have - // been shifted due to the visibility of the doodle. - CGRect headerFrame = [_headerView frame]; - headerFrame.size.height = content_suggestions::heightForLogoHeader( - self.logoIsShowing, self.promoCanShow); - [_headerView setFrame:headerFrame]; - - // Adjust vertical positioning of |_promoHeaderView|. - CGFloat omniboxHeaderHeight = - [self collectionView:_mostVisitedView - layout:[_mostVisitedView - collectionViewLayout] - referenceSizeForHeaderInSection:0] - .height; - CGRect whatsNewFrame = [_promoHeaderView frame]; - whatsNewFrame.origin.y = omniboxHeaderHeight; - [_promoHeaderView setFrame:whatsNewFrame]; } if (IsIPadIdiom()) [_searchTapTarget setHidden:!self.logoIsShowing]; + [[_mostVisitedView collectionViewLayout] invalidateLayout]; } }
diff --git a/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm b/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm index 09804fa..806efc8 100644 --- a/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm +++ b/ios/chrome/browser/ui/ntp/new_tab_page_controller.mm
@@ -599,6 +599,7 @@ } view = panelController.view; [self.homePanel setDelegate:self]; + [self.ntpView.tabBar setShadowAlpha:[self.homePanel alphaForBottomShadow]]; } else if (item.identifier == NewTabPage::kOpenTabsPanel) { if (!_openTabsController) _openTabsController = @@ -716,8 +717,10 @@ [self.homePanel setScrollsToTop:(_currentController == self.homePanel)]; [_openTabsController setScrollsToTop:(_currentController == _openTabsController)]; - [self.ntpView.tabBar - setShadowAlpha:[_currentController alphaForBottomShadow]]; + if (oldController) { + [self.ntpView.tabBar + setShadowAlpha:[_currentController alphaForBottomShadow]]; + } if (oldController != _currentController) { [_currentController wasShown];
diff --git a/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm b/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm index a5b5bfe..a54be123 100644 --- a/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm +++ b/ios/chrome/browser/ui/settings/password_details_collection_view_controller.mm
@@ -45,8 +45,8 @@ ItemTypeUsername, ItemTypeCopyUsername, ItemTypePassword, - ItemTypeShowHide, ItemTypeCopyPassword, + ItemTypeShowHide, ItemTypeDelete, }; @@ -174,12 +174,10 @@ [model addItem:_passwordItem toSectionWithIdentifier:SectionIdentifierPassword]; - // TODO(crbug.com/159166): Change the style of the buttons once there are - // final mocks. - [model addItem:[self showHidePasswordButtonItem] - toSectionWithIdentifier:SectionIdentifierPassword]; [model addItem:[self passwordCopyButtonItem] toSectionWithIdentifier:SectionIdentifierPassword]; + [model addItem:[self showHidePasswordButtonItem] + toSectionWithIdentifier:SectionIdentifierPassword]; [model addSectionWithIdentifier:SectionIdentifierDelete]; [model addItem:[self deletePasswordButtonItem]
diff --git a/ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm b/ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm index 52dd9cd1..fba37884 100644 --- a/ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm +++ b/ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm
@@ -80,8 +80,8 @@ const int kPasswordSection = 2; const int kPasswordItem = 0; -const int kShowHideButtonItem = 1; -const int kCopyPasswordButtonItem = 2; +const int kCopyPasswordButtonItem = 1; +const int kShowHideButtonItem = 2; const int kDeleteSection = 3; const int kDeleteButtonItem = 0; @@ -155,10 +155,10 @@ GetCollectionViewItem(kPasswordSection, kPasswordItem); EXPECT_NSEQ(kPassword, passwordItem.text); EXPECT_FALSE(passwordItem.showingText); - CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_SHOW_BUTTON, - kPasswordSection, kShowHideButtonItem); CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON, kPasswordSection, kCopyPasswordButtonItem); + CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_SHOW_BUTTON, + kPasswordSection, kShowHideButtonItem); // Delete section EXPECT_EQ(1, NumberOfItemsInSection(kDeleteSection)); CheckTextCellTitleWithId(IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON,
diff --git a/ios/chrome/test/earl_grey/BUILD.gn b/ios/chrome/test/earl_grey/BUILD.gn index d497f3cd..07a9fd3 100644 --- a/ios/chrome/test/earl_grey/BUILD.gn +++ b/ios/chrome/test/earl_grey/BUILD.gn
@@ -46,6 +46,7 @@ chrome_ios_eg_test("ios_chrome_ui_egtests") { deps = [ "//ios/chrome/app/safe_mode:eg_tests", + "//ios/chrome/browser/content_suggestions:eg_tests", "//ios/chrome/browser/ui:eg_tests", "//ios/chrome/browser/ui/activity_services:eg_tests", "//ios/chrome/browser/ui/alert_coordinator:eg_tests",
diff --git a/ios/web/web_state/js/common_js_unittest.mm b/ios/web/web_state/js/common_js_unittest.mm index a8afe66..e0c61742 100644 --- a/ios/web/web_state/js/common_js_unittest.mm +++ b/ios/web/web_state/js/common_js_unittest.mm
@@ -142,4 +142,23 @@ } } +TEST_F(CommonJsTest, IsSameOrigin) { + TestScriptAndExpectedValue test_data[] = { + {@"'http://abc.com', 'http://abc.com'", @YES}, + {@"'http://abc.com', 'https://abc.com'", @NO}, + {@"'http://abc.com', 'http://abc.com:123'", @NO}, + {@"'http://abc.com', 'http://def.com'", @NO}}; + + for (size_t i = 0; i < arraysize(test_data); i++) { + TestScriptAndExpectedValue& data = test_data[i]; + LoadHtml(@"<p>"); + id result = ExecuteJavaScript( + [NSString stringWithFormat:@"__gCrWeb.common.isSameOrigin(%@)", + data.test_script]); + EXPECT_NSEQ(data.expected_value, result) + << " in test " << i << ": " + << base::SysNSStringToUTF8(data.test_script); + } +} + } // namespace web
diff --git a/ios/web/web_state/js/resources/common.js b/ios/web/web_state/js/resources/common.js index c6a0969..a8ff508 100644 --- a/ios/web/web_state/js/resources/common.js +++ b/ios/web/web_state/js/resources/common.js
@@ -703,4 +703,12 @@ return false; }; + /** + * Checks whether the two URLs are from the same origin. + */ + __gCrWeb.common.isSameOrigin = function(url_one, url_two) { + return __gCrWeb.common.removeQueryAndReferenceFromURL(url_one) == + __gCrWeb.common.removeQueryAndReferenceFromURL(url_two); + } + }()); // End of anonymous object
diff --git a/ios/web/web_state/js/resources/context_menu.js b/ios/web/web_state/js/resources/context_menu.js index 3df19ec..46a39888 100644 --- a/ios/web/web_state/js/resources/context_menu.js +++ b/ios/web/web_state/js/resources/context_menu.js
@@ -215,9 +215,11 @@ } if (currentElement.tagName.toLowerCase() === 'iframe' || currentElement.tagName.toLowerCase() === 'frame') { - // The following condition is true if the iframe is in a different - // domain; no further information is accessible. - if (typeof(currentElement.contentWindow.document) == 'undefined') { + // Check if the frame is in a different domain using only information + // visible to the current frame (i.e. currentElement.src) to avoid + // triggering a SecurityError in the console. + if (!__gCrWeb.common.isSameOrigin( + window.location.href, currentElement.src)) { return currentElement; } var framePosition = getPositionInWindow(currentElement);
diff --git a/mojo/android/BUILD.gn b/mojo/android/BUILD.gn index 179eb6f..525e7fc 100644 --- a/mojo/android/BUILD.gn +++ b/mojo/android/BUILD.gn
@@ -140,8 +140,6 @@ "//mojo/public/cpp/test_support:test_utils", ] defines = [ "UNIT_TEST" ] - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - configs += [ "//build/config/android:hide_all_but_jni" ] } instrumentation_test_apk("mojo_test_apk") {
diff --git a/net/BUILD.gn b/net/BUILD.gn index b4af1e1..4201f5b 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn
@@ -51,6 +51,7 @@ "DISABLE_FILE_SUPPORT=$disable_file_support", "DISABLE_FTP_SUPPORT=$disable_ftp_support", "ENABLE_MDNS=$enable_mdns", + "ENABLE_REPORTING=$enable_reporting", "ENABLE_WEBSOCKETS=$enable_websockets", "USE_BYTE_CERTS=$use_byte_certs", ] @@ -974,7 +975,9 @@ "http2/http2_constants.h", "http2/http2_structures.cc", "http2/http2_structures.h", + "http2/platform/api/http2_export.h", "http2/platform/api/http2_reconstruct_object.h", + "http2/platform/impl/http2_export_impl.h", "http2/platform/impl/http2_reconstruct_object_impl.h", "http2/tools/http2_bug_tracker.h", "log/file_net_log_observer.cc", @@ -1417,40 +1420,6 @@ "quic/quartc/quartc_stream.h", "quic/quartc/quartc_stream_interface.h", "quic/quartc/quartc_task_runner_interface.h", - "reporting/reporting_browsing_data_remover.cc", - "reporting/reporting_browsing_data_remover.h", - "reporting/reporting_cache.cc", - "reporting/reporting_cache.h", - "reporting/reporting_client.cc", - "reporting/reporting_client.h", - "reporting/reporting_context.cc", - "reporting/reporting_context.h", - "reporting/reporting_delegate.cc", - "reporting/reporting_delegate.h", - "reporting/reporting_delivery_agent.cc", - "reporting/reporting_delivery_agent.h", - "reporting/reporting_endpoint_manager.cc", - "reporting/reporting_endpoint_manager.h", - "reporting/reporting_feature.cc", - "reporting/reporting_feature.h", - "reporting/reporting_garbage_collector.cc", - "reporting/reporting_garbage_collector.h", - "reporting/reporting_header_parser.cc", - "reporting/reporting_header_parser.h", - "reporting/reporting_network_change_observer.cc", - "reporting/reporting_network_change_observer.h", - "reporting/reporting_observer.cc", - "reporting/reporting_observer.h", - "reporting/reporting_persister.cc", - "reporting/reporting_persister.h", - "reporting/reporting_policy.cc", - "reporting/reporting_policy.h", - "reporting/reporting_report.cc", - "reporting/reporting_report.h", - "reporting/reporting_service.cc", - "reporting/reporting_service.h", - "reporting/reporting_uploader.cc", - "reporting/reporting_uploader.h", "sdch/sdch_owner.cc", "sdch/sdch_owner.h", "socket/client_socket_factory.cc", @@ -1737,6 +1706,45 @@ "//third_party/zlib", ] + if (enable_reporting) { + sources += [ + "reporting/reporting_browsing_data_remover.cc", + "reporting/reporting_browsing_data_remover.h", + "reporting/reporting_cache.cc", + "reporting/reporting_cache.h", + "reporting/reporting_client.cc", + "reporting/reporting_client.h", + "reporting/reporting_context.cc", + "reporting/reporting_context.h", + "reporting/reporting_delegate.cc", + "reporting/reporting_delegate.h", + "reporting/reporting_delivery_agent.cc", + "reporting/reporting_delivery_agent.h", + "reporting/reporting_endpoint_manager.cc", + "reporting/reporting_endpoint_manager.h", + "reporting/reporting_feature.cc", + "reporting/reporting_feature.h", + "reporting/reporting_garbage_collector.cc", + "reporting/reporting_garbage_collector.h", + "reporting/reporting_header_parser.cc", + "reporting/reporting_header_parser.h", + "reporting/reporting_network_change_observer.cc", + "reporting/reporting_network_change_observer.h", + "reporting/reporting_observer.cc", + "reporting/reporting_observer.h", + "reporting/reporting_persister.cc", + "reporting/reporting_persister.h", + "reporting/reporting_policy.cc", + "reporting/reporting_policy.h", + "reporting/reporting_report.cc", + "reporting/reporting_report.h", + "reporting/reporting_service.cc", + "reporting/reporting_service.h", + "reporting/reporting_uploader.cc", + "reporting/reporting_uploader.h", + ] + } + if (!use_kerberos) { sources -= [ "http/http_auth_handler_negotiate.cc", @@ -4936,18 +4944,6 @@ "quic/quartc/quartc_session_test.cc", "quic/quartc/quartc_stream_test.cc", "quic/test_tools/crypto_test_utils_test.cc", - "reporting/reporting_browsing_data_remover_unittest.cc", - "reporting/reporting_cache_unittest.cc", - "reporting/reporting_delivery_agent_unittest.cc", - "reporting/reporting_endpoint_manager_unittest.cc", - "reporting/reporting_garbage_collector_unittest.cc", - "reporting/reporting_header_parser_unittest.cc", - "reporting/reporting_network_change_observer_unittest.cc", - "reporting/reporting_persister_unittest.cc", - "reporting/reporting_service_unittest.cc", - "reporting/reporting_test_util.cc", - "reporting/reporting_test_util.h", - "reporting/reporting_uploader_unittest.cc", "sdch/sdch_owner_unittest.cc", "socket/client_socket_pool_base_unittest.cc", "socket/mock_client_socket_pool_manager.cc", @@ -5110,6 +5106,24 @@ "//url", "//url:url_features", ] + + if (enable_reporting) { + sources += [ + "reporting/reporting_browsing_data_remover_unittest.cc", + "reporting/reporting_cache_unittest.cc", + "reporting/reporting_delivery_agent_unittest.cc", + "reporting/reporting_endpoint_manager_unittest.cc", + "reporting/reporting_garbage_collector_unittest.cc", + "reporting/reporting_header_parser_unittest.cc", + "reporting/reporting_network_change_observer_unittest.cc", + "reporting/reporting_persister_unittest.cc", + "reporting/reporting_service_unittest.cc", + "reporting/reporting_test_util.cc", + "reporting/reporting_test_util.h", + "reporting/reporting_uploader_unittest.cc", + ] + } + if (!is_proto_quic) { deps += [ ":extras",
diff --git a/net/android/BUILD.gn b/net/android/BUILD.gn index 8ef6f7c..f855f47 100644 --- a/net/android/BUILD.gn +++ b/net/android/BUILD.gn
@@ -109,9 +109,6 @@ ":java_test_native_support", "//net:test_support", ] - - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - configs += [ "//build/config/android:hide_all_but_jni" ] } android_apk("net_test_support_apk") {
diff --git a/net/features.gni b/net/features.gni index 12ba0e01..95c718e 100644 --- a/net/features.gni +++ b/net/features.gni
@@ -27,4 +27,7 @@ # Multicast DNS. enable_mdns = is_win || is_linux + + # Reporting not used on iOS. + enable_reporting = !is_ios }
diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index a11d80222..49787f6 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h
@@ -249,9 +249,8 @@ // The interface for setting/retrieving the HTTP server properties. // Currently, this class manages servers': -// * SPDY support (based on NPN results). -// * alternative service support. -// * SPDY Settings (like CWND ID field). +// * HTTP/2 support; +// * Alternative Service support; // * QUIC data (like ServerNetworkStats and QuicServerInfo). // // Embedders must ensure that HttpServerProperites is completely initialized
diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 0561e043..2fc33f3 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc
@@ -993,32 +993,13 @@ base::Passed(&quic_server_info_map), completion)); } -// A local or temporary data structure to hold |supports_spdy|, SpdySettings, -// AlternativeServiceInfoVector, and SupportsQuic preferences for a server. This -// is used only in UpdatePrefsOnPrefThread. +// A local or temporary data structure to hold preferences for a server. +// This is used only in UpdatePrefsOnPrefThread. struct ServerPref { - ServerPref() - : supports_spdy(false), - settings_map(nullptr), - alternative_service_info_vector(nullptr), - supports_quic(nullptr), - server_network_stats(nullptr) {} - ServerPref( - bool supports_spdy, - const SettingsMap* settings_map, - const AlternativeServiceInfoVector* alternative_service_info_vector, - const SupportsQuic* supports_quic, - const ServerNetworkStats* server_network_stats) - : supports_spdy(supports_spdy), - settings_map(settings_map), - alternative_service_info_vector(alternative_service_info_vector), - supports_quic(supports_quic), - server_network_stats(server_network_stats) {} - bool supports_spdy; - const SettingsMap* settings_map; - const AlternativeServiceInfoVector* alternative_service_info_vector; - const SupportsQuic* supports_quic; - const ServerNetworkStats* server_network_stats; + bool supports_spdy = false; + const AlternativeServiceInfoVector* alternative_service_info_vector = nullptr; + const SupportsQuic* supports_quic = nullptr; + const ServerNetworkStats* server_network_stats = nullptr; }; // All maps and lists are in MRU order.
diff --git a/net/http/http_server_properties_manager.h b/net/http/http_server_properties_manager.h index bb2132f90..6dbc3fb1 100644 --- a/net/http/http_server_properties_manager.h +++ b/net/http/http_server_properties_manager.h
@@ -222,7 +222,7 @@ // These are used to delay updating the preferences when cached data in // |http_server_properties_impl_| is changing, and execute only one update per - // simultaneous spdy_servers or spdy_settings or alternative_service changes. + // simultaneous changes. // |location| specifies where this method is called from. Virtual for testing. virtual void ScheduleUpdatePrefsOnNetworkSequence(Location location);
diff --git a/net/http2/decoder/decode_buffer.h b/net/http2/decoder/decode_buffer.h index 06aa128a..e23ca683 100644 --- a/net/http2/decoder/decode_buffer.h +++ b/net/http2/decoder/decode_buffer.h
@@ -20,12 +20,12 @@ #include "base/logging.h" #include "base/macros.h" #include "base/strings/string_piece.h" -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { class DecodeBufferSubset; -class NET_EXPORT_PRIVATE DecodeBuffer { +class HTTP2_EXPORT_PRIVATE DecodeBuffer { public: DecodeBuffer(const char* buffer, size_t len) : buffer_(buffer), cursor_(buffer), beyond_(buffer + len) { @@ -160,7 +160,7 @@ // DecodeBuffer, though they can be nested (i.e. a DecodeBufferSubset's // base may itself be a DecodeBufferSubset). This avoids the AdvanceCursor // being called erroneously. -class NET_EXPORT_PRIVATE DecodeBufferSubset : public DecodeBuffer { +class HTTP2_EXPORT_PRIVATE DecodeBufferSubset : public DecodeBuffer { public: DecodeBufferSubset(DecodeBuffer* base, size_t subset_len) : DecodeBuffer(base->cursor(), base->MinLengthRemaining(subset_len)),
diff --git a/net/http2/decoder/decode_http2_structures.h b/net/http2/decoder/decode_http2_structures.h index 1ff4d39..0dc2528 100644 --- a/net/http2/decoder/decode_http2_structures.h +++ b/net/http2/decoder/decode_http2_structures.h
@@ -7,9 +7,9 @@ // Provides functions for decoding the fixed size structures in the HTTP/2 spec. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -17,15 +17,17 @@ // to end, advancing the cursor by STRUCTURE::EncodedSize(). The decode buffer // must be large enough (i.e. b->Remaining() >= STRUCTURE::EncodedSize()). -NET_EXPORT_PRIVATE void DoDecode(Http2FrameHeader* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2PriorityFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2RstStreamFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2SettingFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2PushPromiseFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2PingFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2GoAwayFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2WindowUpdateFields* out, DecodeBuffer* b); -NET_EXPORT_PRIVATE void DoDecode(Http2AltSvcFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2FrameHeader* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2PriorityFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2RstStreamFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2SettingFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2PushPromiseFields* out, + DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2PingFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2GoAwayFields* out, DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2WindowUpdateFields* out, + DecodeBuffer* b); +HTTP2_EXPORT_PRIVATE void DoDecode(Http2AltSvcFields* out, DecodeBuffer* b); } // namespace net
diff --git a/net/http2/decoder/decode_status.h b/net/http2/decoder/decode_status.h index e5fbeeb..926df70 100644 --- a/net/http2/decoder/decode_status.h +++ b/net/http2/decoder/decode_status.h
@@ -10,7 +10,7 @@ #include <ostream> -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -25,7 +25,8 @@ // an HTTP/2 frame has padding declared to be larger than the payload). kDecodeError, }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, DecodeStatus v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + DecodeStatus v); } // namespace net
diff --git a/net/http2/decoder/frame_decoder_state.h b/net/http2/decoder/frame_decoder_state.h index ddf64d1f..4b9d20a4 100644 --- a/net/http2/decoder/frame_decoder_state.h +++ b/net/http2/decoder/frame_decoder_state.h
@@ -15,20 +15,20 @@ #include <stddef.h> #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/http2_frame_decoder_listener.h" #include "net/http2/decoder/http2_structure_decoder.h" #include "net/http2/http2_constants.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class FrameDecoderStatePeer; } // namespace test -class NET_EXPORT_PRIVATE FrameDecoderState { +class HTTP2_EXPORT_PRIVATE FrameDecoderState { public: FrameDecoderState() {}
diff --git a/net/http2/decoder/http2_frame_decoder.h b/net/http2/decoder/http2_frame_decoder.h index f440993..18d030d 100644 --- a/net/http2/decoder/http2_frame_decoder.h +++ b/net/http2/decoder/http2_frame_decoder.h
@@ -21,7 +21,6 @@ #include "base/logging.h" #include "base/macros.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" @@ -39,13 +38,14 @@ #include "net/http2/decoder/payload_decoders/unknown_payload_decoder.h" #include "net/http2/decoder/payload_decoders/window_update_payload_decoder.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class Http2FrameDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE Http2FrameDecoder { +class HTTP2_EXPORT_PRIVATE Http2FrameDecoder { public: explicit Http2FrameDecoder(Http2FrameDecoderListener* listener); Http2FrameDecoder() : Http2FrameDecoder(nullptr) {}
diff --git a/net/http2/decoder/http2_structure_decoder.h b/net/http2/decoder/http2_structure_decoder.h index 8665e96..922723d9f 100644 --- a/net/http2/decoder/http2_structure_decoder.h +++ b/net/http2/decoder/http2_structure_decoder.h
@@ -14,18 +14,18 @@ // those rare occurrences is small, which then simplifies the callers. #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_http2_structures.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class Http2StructureDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE Http2StructureDecoder { +class HTTP2_EXPORT_PRIVATE Http2StructureDecoder { public: // The caller needs to keep track of whether to call Start or Resume. //
diff --git a/net/http2/decoder/payload_decoders/altsvc_payload_decoder.h b/net/http2/decoder/payload_decoders/altsvc_payload_decoder.h index f92fa7f9..f2aec89b 100644 --- a/net/http2/decoder/payload_decoders/altsvc_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/altsvc_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a ALTSVC frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class AltSvcPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE AltSvcPayloadDecoder { +class HTTP2_EXPORT_PRIVATE AltSvcPayloadDecoder { public: // States during decoding of a ALTSVC frame. enum class PayloadState {
diff --git a/net/http2/decoder/payload_decoders/continuation_payload_decoder.h b/net/http2/decoder/payload_decoders/continuation_payload_decoder.h index 4ab58aa..6134c5f 100644 --- a/net/http2/decoder/payload_decoders/continuation_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/continuation_payload_decoder.h
@@ -7,14 +7,14 @@ // Decodes the payload of a CONTINUATION frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE ContinuationPayloadDecoder { +class HTTP2_EXPORT_PRIVATE ContinuationPayloadDecoder { public: // Starts the decoding of a CONTINUATION frame's payload, and completes // it if the entire payload is in the provided decode buffer.
diff --git a/net/http2/decoder/payload_decoders/data_payload_decoder.h b/net/http2/decoder/payload_decoders/data_payload_decoder.h index 2fe09596..d09a9e4 100644 --- a/net/http2/decoder/payload_decoders/data_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/data_payload_decoder.h
@@ -7,17 +7,17 @@ // Decodes the payload of a DATA frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class DataPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE DataPayloadDecoder { +class HTTP2_EXPORT_PRIVATE DataPayloadDecoder { public: // States during decoding of a DATA frame. enum class PayloadState {
diff --git a/net/http2/decoder/payload_decoders/goaway_payload_decoder.h b/net/http2/decoder/payload_decoders/goaway_payload_decoder.h index 5aefc6c..26efb4d 100644 --- a/net/http2/decoder/payload_decoders/goaway_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/goaway_payload_decoder.h
@@ -10,18 +10,18 @@ // TODO(jamessynge): Sweep through all payload decoders, changing the names of // the PayloadState enums so that they are really states, and not actions. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class GoAwayPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE GoAwayPayloadDecoder { +class HTTP2_EXPORT_PRIVATE GoAwayPayloadDecoder { public: // States during decoding of a GOAWAY frame. enum class PayloadState {
diff --git a/net/http2/decoder/payload_decoders/headers_payload_decoder.h b/net/http2/decoder/payload_decoders/headers_payload_decoder.h index 76e6a082..1ec51cb 100644 --- a/net/http2/decoder/payload_decoders/headers_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/headers_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a HEADERS frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class HeadersPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE HeadersPayloadDecoder { +class HTTP2_EXPORT_PRIVATE HeadersPayloadDecoder { public: // States during decoding of a HEADERS frame, unless the fast path kicks // in, in which case the state machine will be bypassed.
diff --git a/net/http2/decoder/payload_decoders/ping_payload_decoder.h b/net/http2/decoder/payload_decoders/ping_payload_decoder.h index 0eb10a2e..4a779bc5e 100644 --- a/net/http2/decoder/payload_decoders/ping_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/ping_payload_decoder.h
@@ -8,18 +8,18 @@ // Decodes the payload of a PING frame; for the RFC, see: // http://httpwg.org/specs/rfc7540.html#PING -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class PingPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE PingPayloadDecoder { +class HTTP2_EXPORT_PRIVATE PingPayloadDecoder { public: // Starts the decoding of a PING frame's payload, and completes it if the // entire payload is in the provided decode buffer.
diff --git a/net/http2/decoder/payload_decoders/priority_payload_decoder.h b/net/http2/decoder/payload_decoders/priority_payload_decoder.h index d41a404..8188f13 100644 --- a/net/http2/decoder/payload_decoders/priority_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/priority_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a PRIORITY frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class PriorityPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE PriorityPayloadDecoder { +class HTTP2_EXPORT_PRIVATE PriorityPayloadDecoder { public: // Starts the decoding of a PRIORITY frame's payload, and completes it if // the entire payload is in the provided decode buffer.
diff --git a/net/http2/decoder/payload_decoders/push_promise_payload_decoder.h b/net/http2/decoder/payload_decoders/push_promise_payload_decoder.h index fe6c523..fadc5f0d 100644 --- a/net/http2/decoder/payload_decoders/push_promise_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/push_promise_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a PUSH_PROMISE frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class PushPromisePayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE PushPromisePayloadDecoder { +class HTTP2_EXPORT_PRIVATE PushPromisePayloadDecoder { public: // States during decoding of a PUSH_PROMISE frame. enum class PayloadState {
diff --git a/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.h b/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.h index cdfd6587..8600701 100644 --- a/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/rst_stream_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a RST_STREAM frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class RstStreamPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE RstStreamPayloadDecoder { +class HTTP2_EXPORT_PRIVATE RstStreamPayloadDecoder { public: // Starts the decoding of a RST_STREAM frame's payload, and completes it if // the entire payload is in the provided decode buffer.
diff --git a/net/http2/decoder/payload_decoders/settings_payload_decoder.h b/net/http2/decoder/payload_decoders/settings_payload_decoder.h index 40d3c36..0050169 100644 --- a/net/http2/decoder/payload_decoders/settings_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/settings_payload_decoder.h
@@ -8,18 +8,18 @@ // Decodes the payload of a SETTINGS frame; for the RFC, see: // http://httpwg.org/specs/rfc7540.html#SETTINGS -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class SettingsPayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE SettingsPayloadDecoder { +class HTTP2_EXPORT_PRIVATE SettingsPayloadDecoder { public: // Starts the decoding of a SETTINGS frame's payload, and completes it if // the entire payload is in the provided decode buffer.
diff --git a/net/http2/decoder/payload_decoders/unknown_payload_decoder.h b/net/http2/decoder/payload_decoders/unknown_payload_decoder.h index 26a1ee2..e08e4788 100644 --- a/net/http2/decoder/payload_decoders/unknown_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/unknown_payload_decoder.h
@@ -10,14 +10,14 @@ // Implementations MUST ignore and discard any frame that has // a type that is unknown. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE UnknownPayloadDecoder { +class HTTP2_EXPORT_PRIVATE UnknownPayloadDecoder { public: // Starts decoding a payload of unknown type; just passes it to the listener. DecodeStatus StartDecodingPayload(FrameDecoderState* state, DecodeBuffer* db);
diff --git a/net/http2/decoder/payload_decoders/window_update_payload_decoder.h b/net/http2/decoder/payload_decoders/window_update_payload_decoder.h index 5764361..dac1cf0 100644 --- a/net/http2/decoder/payload_decoders/window_update_payload_decoder.h +++ b/net/http2/decoder/payload_decoders/window_update_payload_decoder.h
@@ -7,18 +7,18 @@ // Decodes the payload of a WINDOW_UPDATE frame. -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/decoder/frame_decoder_state.h" #include "net/http2/http2_structures.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class WindowUpdatePayloadDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE WindowUpdatePayloadDecoder { +class HTTP2_EXPORT_PRIVATE WindowUpdatePayloadDecoder { public: // Starts decoding a WINDOW_UPDATE frame's payload, and completes it if // the entire payload is in the provided decode buffer.
diff --git a/net/http2/hpack/decoder/hpack_block_decoder.h b/net/http2/hpack/decoder/hpack_block_decoder.h index 18b882e..c5e3409 100644 --- a/net/http2/hpack/decoder/hpack_block_decoder.h +++ b/net/http2/hpack/decoder/hpack_block_decoder.h
@@ -14,15 +14,15 @@ #include "base/logging.h" #include "base/macros.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/hpack/decoder/hpack_entry_decoder.h" #include "net/http2/hpack/decoder/hpack_entry_decoder_listener.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackBlockDecoder { +class HTTP2_EXPORT_PRIVATE HpackBlockDecoder { public: explicit HpackBlockDecoder(HpackEntryDecoderListener* listener) : listener_(listener) { @@ -65,8 +65,8 @@ DISALLOW_COPY_AND_ASSIGN(HpackBlockDecoder); }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackBlockDecoder& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackBlockDecoder& v); } // namespace net
diff --git a/net/http2/hpack/decoder/hpack_decoder_listener.h b/net/http2/hpack/decoder/hpack_decoder_listener.h index a5facd6..9c14168 100644 --- a/net/http2/hpack/decoder/hpack_decoder_listener.h +++ b/net/http2/hpack/decoder/hpack_decoder_listener.h
@@ -9,13 +9,13 @@ #define NET_HTTP2_HPACK_DECODER_HPACK_DECODER_LISTENER_H_ #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/hpack/hpack_string.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT HpackDecoderListener { +class HTTP2_EXPORT_PRIVATE HpackDecoderListener { public: HpackDecoderListener(); virtual ~HpackDecoderListener(); @@ -44,7 +44,8 @@ // A no-op implementation of HpackDecoderListener, useful for ignoring // callbacks once an error is detected. -class NET_EXPORT HpackDecoderNoOpListener : public HpackDecoderListener { +class HTTP2_EXPORT_PRIVATE HpackDecoderNoOpListener + : public HpackDecoderListener { public: HpackDecoderNoOpListener(); ~HpackDecoderNoOpListener() override;
diff --git a/net/http2/hpack/decoder/hpack_decoder_state.h b/net/http2/hpack/decoder/hpack_decoder_state.h index 90fd018..d3fae76 100644 --- a/net/http2/hpack/decoder/hpack_decoder_state.h +++ b/net/http2/hpack/decoder/hpack_decoder_state.h
@@ -17,19 +17,19 @@ #include "base/macros.h" #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/hpack/decoder/hpack_decoder_listener.h" #include "net/http2/hpack/decoder/hpack_decoder_string_buffer.h" #include "net/http2/hpack/decoder/hpack_decoder_tables.h" #include "net/http2/hpack/decoder/hpack_whole_entry_listener.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class HpackDecoderStatePeer; } // namespace test -class NET_EXPORT HpackDecoderState : public HpackWholeEntryListener { +class HTTP2_EXPORT_PRIVATE HpackDecoderState : public HpackWholeEntryListener { public: explicit HpackDecoderState(HpackDecoderListener* listener); ~HpackDecoderState() override;
diff --git a/net/http2/hpack/decoder/hpack_decoder_string_buffer.h b/net/http2/hpack/decoder/hpack_decoder_string_buffer.h index 2f60068..6b927b23 100644 --- a/net/http2/hpack/decoder/hpack_decoder_string_buffer.h +++ b/net/http2/hpack/decoder/hpack_decoder_string_buffer.h
@@ -16,12 +16,12 @@ #include "base/macros.h" #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/hpack/huffman/http2_hpack_huffman_decoder.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackDecoderStringBuffer { +class HTTP2_EXPORT_PRIVATE HpackDecoderStringBuffer { public: enum class State : uint8_t { RESET, COLLECTING, COMPLETE }; enum class Backing : uint8_t { RESET, UNBUFFERED, BUFFERED, STATIC }; @@ -92,8 +92,9 @@ DISALLOW_COPY_AND_ASSIGN(HpackDecoderStringBuffer); }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackDecoderStringBuffer& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<( + std::ostream& out, + const HpackDecoderStringBuffer& v); } // namespace net
diff --git a/net/http2/hpack/decoder/hpack_decoder_tables.h b/net/http2/hpack/decoder/hpack_decoder_tables.h index b3cfccc8..1ac5bde 100644 --- a/net/http2/hpack/decoder/hpack_decoder_tables.h +++ b/net/http2/hpack/decoder/hpack_decoder_tables.h
@@ -22,9 +22,9 @@ #include <vector> #include "base/macros.h" -#include "net/base/net_export.h" #include "net/http2/hpack/hpack_string.h" #include "net/http2/http2_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { @@ -37,7 +37,7 @@ // HpackDecoderTablesDebugListener supports a QUIC experiment, enabling // the gathering of information about the time-line of use of HPACK // dynamic table entries. -class NET_EXPORT_PRIVATE HpackDecoderTablesDebugListener { +class HTTP2_EXPORT_PRIVATE HpackDecoderTablesDebugListener { public: HpackDecoderTablesDebugListener(); virtual ~HpackDecoderTablesDebugListener(); @@ -66,7 +66,7 @@ // See http://httpwg.org/specs/rfc7541.html#static.table.definition for the // contents, and http://httpwg.org/specs/rfc7541.html#index.address.space for // info about accessing the static table. -class NET_EXPORT_PRIVATE HpackDecoderStaticTable { +class HTTP2_EXPORT_PRIVATE HpackDecoderStaticTable { public: explicit HpackDecoderStaticTable(const std::vector<HpackStringPair>* table); // Uses a global table shared by all threads. @@ -86,7 +86,7 @@ // in the dynamic table. See these sections of the RFC: // http://httpwg.org/specs/rfc7541.html#dynamic.table // http://httpwg.org/specs/rfc7541.html#dynamic.table.management -class NET_EXPORT_PRIVATE HpackDecoderDynamicTable { +class HTTP2_EXPORT_PRIVATE HpackDecoderDynamicTable { public: HpackDecoderDynamicTable(); ~HpackDecoderDynamicTable(); @@ -144,7 +144,7 @@ DISALLOW_COPY_AND_ASSIGN(HpackDecoderDynamicTable); }; -class NET_EXPORT_PRIVATE HpackDecoderTables { +class HTTP2_EXPORT_PRIVATE HpackDecoderTables { public: HpackDecoderTables(); ~HpackDecoderTables();
diff --git a/net/http2/hpack/decoder/hpack_entry_decoder.h b/net/http2/hpack/decoder/hpack_entry_decoder.h index 9b5f696..4ade5d6 100644 --- a/net/http2/hpack/decoder/hpack_entry_decoder.h +++ b/net/http2/hpack/decoder/hpack_entry_decoder.h
@@ -13,17 +13,17 @@ #include <string> #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/hpack/decoder/hpack_entry_decoder_listener.h" #include "net/http2/hpack/decoder/hpack_entry_type_decoder.h" #include "net/http2/hpack/decoder/hpack_string_decoder.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackEntryDecoder { +class HTTP2_EXPORT_PRIVATE HpackEntryDecoder { public: enum class EntryDecoderState { // Have started decoding the type/varint, but didn't finish on the previous @@ -106,9 +106,9 @@ EntryDecoderState state_ = EntryDecoderState(); }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackEntryDecoder& v); -NET_EXPORT_PRIVATE std::ostream& operator<<( +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackEntryDecoder& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<( std::ostream& out, HpackEntryDecoder::EntryDecoderState state);
diff --git a/net/http2/hpack/decoder/hpack_entry_decoder_listener.h b/net/http2/hpack/decoder/hpack_entry_decoder_listener.h index 09fbd54..8d1c918 100644 --- a/net/http2/hpack/decoder/hpack_entry_decoder_listener.h +++ b/net/http2/hpack/decoder/hpack_entry_decoder_listener.h
@@ -11,12 +11,12 @@ #include <stddef.h> -#include "net/base/net_export.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackEntryDecoderListener { +class HTTP2_EXPORT_PRIVATE HpackEntryDecoderListener { public: virtual ~HpackEntryDecoderListener() {} @@ -64,7 +64,7 @@ virtual void OnDynamicTableSizeUpdate(size_t size) = 0; }; -class NET_EXPORT_PRIVATE HpackEntryDecoderVLoggingListener +class HTTP2_EXPORT_PRIVATE HpackEntryDecoderVLoggingListener : public HpackEntryDecoderListener { public: HpackEntryDecoderVLoggingListener() : wrapped_(nullptr) {} @@ -88,7 +88,7 @@ }; // A no-op implementation of HpackEntryDecoderListener. -class NET_EXPORT_PRIVATE HpackEntryDecoderNoOpListener +class HTTP2_EXPORT_PRIVATE HpackEntryDecoderNoOpListener : public HpackEntryDecoderListener { public: ~HpackEntryDecoderNoOpListener() override {}
diff --git a/net/http2/hpack/decoder/hpack_entry_type_decoder.h b/net/http2/hpack/decoder/hpack_entry_type_decoder.h index d2c1f54..1dd5149 100644 --- a/net/http2/hpack/decoder/hpack_entry_type_decoder.h +++ b/net/http2/hpack/decoder/hpack_entry_type_decoder.h
@@ -13,15 +13,15 @@ #include <string> #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/hpack/decoder/hpack_varint_decoder.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackEntryTypeDecoder { +class HTTP2_EXPORT_PRIVATE HpackEntryTypeDecoder { public: // Only call when the decode buffer has data (i.e. HpackEntryDecoder must // not call until there is data). @@ -49,8 +49,8 @@ HpackEntryType entry_type_ = HpackEntryType::kIndexedHeader; }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackEntryTypeDecoder& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackEntryTypeDecoder& v); } // namespace net #endif // NET_HTTP2_HPACK_DECODER_HPACK_ENTRY_TYPE_DECODER_H_
diff --git a/net/http2/hpack/decoder/hpack_string_decoder.h b/net/http2/hpack/decoder/hpack_string_decoder.h index baea422..144d230 100644 --- a/net/http2/hpack/decoder/hpack_string_decoder.h +++ b/net/http2/hpack/decoder/hpack_string_decoder.h
@@ -16,10 +16,10 @@ #include "base/logging.h" #include "base/macros.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" #include "net/http2/hpack/decoder/hpack_varint_decoder.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -37,7 +37,7 @@ // experiment. Perflab experiments show it is generally fastest to call // StartSpecialCaseShort rather than StartOnly (~9% slower) or // StartAndDecodeLength (~10% slower). -class NET_EXPORT_PRIVATE HpackStringDecoder { +class HTTP2_EXPORT_PRIVATE HpackStringDecoder { public: enum StringDecoderState { kStartDecodingLength, @@ -229,8 +229,8 @@ bool huffman_encoded_ = false; }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackStringDecoder& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackStringDecoder& v); } // namespace net #endif // NET_HTTP2_HPACK_DECODER_HPACK_STRING_DECODER_H_
diff --git a/net/http2/hpack/decoder/hpack_string_decoder_listener.h b/net/http2/hpack/decoder/hpack_string_decoder_listener.h index fbeeeb4..cced830 100644 --- a/net/http2/hpack/decoder/hpack_string_decoder_listener.h +++ b/net/http2/hpack/decoder/hpack_string_decoder_listener.h
@@ -12,7 +12,7 @@ #include <stddef.h> -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { @@ -20,7 +20,7 @@ // HpackStringDecoder methods require a listener that implements the methods // below, but it is NOT necessary to extend this class because the methods // are templates. -class NET_EXPORT_PRIVATE HpackStringDecoderListener { +class HTTP2_EXPORT_PRIVATE HpackStringDecoderListener { public: virtual ~HpackStringDecoderListener() {} @@ -39,7 +39,7 @@ virtual void OnStringEnd() = 0; }; -class NET_EXPORT_PRIVATE HpackStringDecoderVLoggingListener +class HTTP2_EXPORT_PRIVATE HpackStringDecoderVLoggingListener : public HpackStringDecoderListener { public: HpackStringDecoderVLoggingListener() : wrapped_(nullptr) {}
diff --git a/net/http2/hpack/decoder/hpack_varint_decoder.h b/net/http2/hpack/decoder/hpack_varint_decoder.h index 21d23037..0ce9a9d 100644 --- a/net/http2/hpack/decoder/hpack_varint_decoder.h +++ b/net/http2/hpack/decoder/hpack_varint_decoder.h
@@ -30,9 +30,9 @@ #include <string> #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/decoder/decode_status.h" +#include "net/http2/platform/api/http2_export.h" namespace net { // Decodes an HPACK variable length unsigned integer, in a resumable fashion @@ -45,7 +45,7 @@ // needed. Start and StartExtended handles the initialization of member // variables. This is necessary in order for HpackVarintDecoder to be part // of a union. -class NET_EXPORT_PRIVATE HpackVarintDecoder { +class HTTP2_EXPORT_PRIVATE HpackVarintDecoder { public: // |prefix_value| is the first byte of the encoded varint. // |prefix_mask| is the mask of the valid bits, i.e. without the top 1 to 4
diff --git a/net/http2/hpack/decoder/hpack_whole_entry_buffer.h b/net/http2/hpack/decoder/hpack_whole_entry_buffer.h index d7f7e84..ede16a59 100644 --- a/net/http2/hpack/decoder/hpack_whole_entry_buffer.h +++ b/net/http2/hpack/decoder/hpack_whole_entry_buffer.h
@@ -14,17 +14,17 @@ #include "base/macros.h" #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/hpack/decoder/hpack_decoder_string_buffer.h" #include "net/http2/hpack/decoder/hpack_entry_decoder_listener.h" #include "net/http2/hpack/decoder/hpack_whole_entry_listener.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { // TODO(jamessynge): Consider renaming HpackEntryDecoderListener to // HpackEntryPartsListener or HpackEntryFragmentsListener. -class NET_EXPORT_PRIVATE HpackWholeEntryBuffer +class HTTP2_EXPORT_PRIVATE HpackWholeEntryBuffer : public HpackEntryDecoderListener { public: // max_string_size specifies the maximum size of an on-the-wire string (name
diff --git a/net/http2/hpack/decoder/hpack_whole_entry_listener.h b/net/http2/hpack/decoder/hpack_whole_entry_listener.h index af1457ed..9a53573 100644 --- a/net/http2/hpack/decoder/hpack_whole_entry_listener.h +++ b/net/http2/hpack/decoder/hpack_whole_entry_listener.h
@@ -12,13 +12,13 @@ #include <stddef.h> #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/hpack/decoder/hpack_decoder_string_buffer.h" #include "net/http2/hpack/http2_hpack_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackWholeEntryListener { +class HTTP2_EXPORT_PRIVATE HpackWholeEntryListener { public: virtual ~HpackWholeEntryListener();
diff --git a/net/http2/hpack/decoder/http2_hpack_decoder.h b/net/http2/hpack/decoder/http2_hpack_decoder.h index d053c3a..421135bb 100644 --- a/net/http2/hpack/decoder/http2_hpack_decoder.h +++ b/net/http2/hpack/decoder/http2_hpack_decoder.h
@@ -24,20 +24,20 @@ #include "base/macros.h" #include "base/strings/string_piece.h" -#include "net/base/net_export.h" #include "net/http2/decoder/decode_buffer.h" #include "net/http2/hpack/decoder/hpack_block_decoder.h" #include "net/http2/hpack/decoder/hpack_decoder_listener.h" #include "net/http2/hpack/decoder/hpack_decoder_state.h" #include "net/http2/hpack/decoder/hpack_decoder_tables.h" #include "net/http2/hpack/decoder/hpack_whole_entry_buffer.h" +#include "net/http2/platform/api/http2_export.h" namespace net { namespace test { class Http2HpackDecoderPeer; } // namespace test -class NET_EXPORT_PRIVATE Http2HpackDecoder { +class HTTP2_EXPORT_PRIVATE Http2HpackDecoder { public: Http2HpackDecoder(HpackDecoderListener* listener, size_t max_string_size); virtual ~Http2HpackDecoder();
diff --git a/net/http2/hpack/hpack_string.h b/net/http2/hpack/hpack_string.h index 04b95a95..ac9ecf9 100644 --- a/net/http2/hpack/hpack_string.h +++ b/net/http2/hpack/hpack_string.h
@@ -16,11 +16,11 @@ #include <string> #include "base/strings/string_piece.h" -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -class NET_EXPORT_PRIVATE HpackString { +class HTTP2_EXPORT_PRIVATE HpackString { public: explicit HpackString(const char* data); explicit HpackString(base::StringPiece str); @@ -46,14 +46,15 @@ std::string str_; }; -NET_EXPORT_PRIVATE bool operator==(base::StringPiece a, const HpackString& b); -NET_EXPORT_PRIVATE bool operator!=(base::StringPiece a, const HpackString& b); -NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, const HpackString& b); -NET_EXPORT_PRIVATE bool operator!=(const HpackString& a, base::StringPiece b); -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const HpackString& v); +HTTP2_EXPORT_PRIVATE bool operator==(base::StringPiece a, const HpackString& b); +HTTP2_EXPORT_PRIVATE bool operator!=(base::StringPiece a, const HpackString& b); +HTTP2_EXPORT_PRIVATE bool operator!=(const HpackString& a, + const HpackString& b); +HTTP2_EXPORT_PRIVATE bool operator!=(const HpackString& a, base::StringPiece b); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const HpackString& v); -struct NET_EXPORT_PRIVATE HpackStringPair { +struct HTTP2_EXPORT_PRIVATE HpackStringPair { HpackStringPair(const HpackString& name, const HpackString& value); HpackStringPair(base::StringPiece name, base::StringPiece value); ~HpackStringPair(); @@ -68,8 +69,8 @@ HpackString value; }; -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, - const HpackStringPair& p); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, + const HpackStringPair& p); } // namespace net
diff --git a/net/http2/hpack/http2_hpack_constants.h b/net/http2/hpack/http2_hpack_constants.h index b9883a0..f771fc7 100644 --- a/net/http2/hpack/http2_hpack_constants.h +++ b/net/http2/hpack/http2_hpack_constants.h
@@ -13,7 +13,7 @@ #include <ostream> #include <string> -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -50,11 +50,11 @@ }; // Returns the name of the enum member. -NET_EXPORT_PRIVATE std::string HpackEntryTypeToString(HpackEntryType v); +HTTP2_EXPORT_PRIVATE std::string HpackEntryTypeToString(HpackEntryType v); // Inserts the name of the enum member into |out|. -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - HpackEntryType v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + HpackEntryType v); } // namespace net
diff --git a/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h b/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h index 7b8edd10..b0ab0e11 100644 --- a/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h +++ b/net/http2/hpack/huffman/http2_hpack_huffman_decoder.h
@@ -18,7 +18,7 @@ #include <string> #include "base/strings/string_piece.h" -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -37,7 +37,7 @@ // HuffmanBitBuffer stores the leading edge of bits to be decoded. The high // order bit of accumulator_ is the next bit to be decoded. -class NET_EXPORT_PRIVATE HuffmanBitBuffer { +class HTTP2_EXPORT_PRIVATE HuffmanBitBuffer { public: HuffmanBitBuffer(); @@ -84,7 +84,7 @@ return out << v.DebugString(); } -class NET_EXPORT_PRIVATE HpackHuffmanDecoder { +class HTTP2_EXPORT_PRIVATE HpackHuffmanDecoder { public: HpackHuffmanDecoder(); ~HpackHuffmanDecoder();
diff --git a/net/http2/http2_constants.h b/net/http2/http2_constants.h index 3b9c3c3c..c948584fc 100644 --- a/net/http2/http2_constants.h +++ b/net/http2/http2_constants.h
@@ -13,7 +13,7 @@ #include <ostream> #include <string> -#include "net/base/net_export.h" +#include "net/http2/platform/api/http2_export.h" namespace net { @@ -57,10 +57,10 @@ // each unsupported value. Since these are just used for debugging/error // messages, that isn't a cost to we need to worry about. // The same applies to the functions later in this file. -NET_EXPORT_PRIVATE std::string Http2FrameTypeToString(Http2FrameType v); -NET_EXPORT_PRIVATE std::string Http2FrameTypeToString(uint8_t v); -NET_EXPORT_PRIVATE inline std::ostream& operator<<(std::ostream& out, - Http2FrameType v) { +HTTP2_EXPORT_PRIVATE std::string Http2FrameTypeToString(Http2FrameType v); +HTTP2_EXPORT_PRIVATE std::string Http2FrameTypeToString(uint8_t v); +HTTP2_EXPORT_PRIVATE inline std::ostream& operator<<(std::ostream& out, + Http2FrameType v) { return out << Http2FrameTypeToString(v); } @@ -78,10 +78,10 @@ // Formats zero or more flags for the specified type of frame. Returns an // empty string if flags==0. -NET_EXPORT_PRIVATE std::string Http2FrameFlagsToString(Http2FrameType type, - uint8_t flags); -NET_EXPORT_PRIVATE std::string Http2FrameFlagsToString(uint8_t type, - uint8_t flags); +HTTP2_EXPORT_PRIVATE std::string Http2FrameFlagsToString(Http2FrameType type, + uint8_t flags); +HTTP2_EXPORT_PRIVATE std::string Http2FrameFlagsToString(uint8_t type, + uint8_t flags); // Error codes for GOAWAY and RST_STREAM frames. enum class Http2ErrorCode : uint32_t { @@ -145,10 +145,10 @@ } // Format the specified error code. -NET_EXPORT_PRIVATE std::string Http2ErrorCodeToString(uint32_t v); -NET_EXPORT_PRIVATE std::string Http2ErrorCodeToString(Http2ErrorCode v); -NET_EXPORT_PRIVATE inline std::ostream& operator<<(std::ostream& out, - Http2ErrorCode v) { +HTTP2_EXPORT_PRIVATE std::string Http2ErrorCodeToString(uint32_t v); +HTTP2_EXPORT_PRIVATE std::string Http2ErrorCodeToString(Http2ErrorCode v); +HTTP2_EXPORT_PRIVATE inline std::ostream& operator<<(std::ostream& out, + Http2ErrorCode v) { return out << Http2ErrorCodeToString(v); } @@ -226,8 +226,8 @@ } // Format the specified settings parameter. -NET_EXPORT_PRIVATE std::string Http2SettingsParameterToString(uint32_t v); -NET_EXPORT_PRIVATE std::string Http2SettingsParameterToString( +HTTP2_EXPORT_PRIVATE std::string Http2SettingsParameterToString(uint32_t v); +HTTP2_EXPORT_PRIVATE std::string Http2SettingsParameterToString( Http2SettingsParameter v); inline std::ostream& operator<<(std::ostream& out, Http2SettingsParameter v) { return out << Http2SettingsParameterToString(v);
diff --git a/net/http2/http2_structures.h b/net/http2/http2_structures.h index d5abc91..1e18677b 100644 --- a/net/http2/http2_structures.h +++ b/net/http2/http2_structures.h
@@ -32,12 +32,12 @@ #include <string> #include "base/logging.h" -#include "net/base/net_export.h" #include "net/http2/http2_constants.h" +#include "net/http2/platform/api/http2_export.h" namespace net { -struct NET_EXPORT_PRIVATE Http2FrameHeader { +struct HTTP2_EXPORT_PRIVATE Http2FrameHeader { Http2FrameHeader() {} Http2FrameHeader(uint32_t payload_length, Http2FrameType type, @@ -128,18 +128,18 @@ Http2FrameFlag flags; }; -NET_EXPORT_PRIVATE bool operator==(const Http2FrameHeader& a, - const Http2FrameHeader& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2FrameHeader& a, - const Http2FrameHeader& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2FrameHeader& a, + const Http2FrameHeader& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2FrameHeader& a, + const Http2FrameHeader& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2FrameHeader& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2FrameHeader& v); // Http2PriorityFields: -struct NET_EXPORT_PRIVATE Http2PriorityFields { +struct HTTP2_EXPORT_PRIVATE Http2PriorityFields { Http2PriorityFields() {} Http2PriorityFields(uint32_t stream_dependency, uint32_t weight, @@ -172,14 +172,14 @@ bool is_exclusive; }; -NET_EXPORT_PRIVATE bool operator==(const Http2PriorityFields& a, - const Http2PriorityFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2PriorityFields& a, - const Http2PriorityFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2PriorityFields& a, + const Http2PriorityFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2PriorityFields& a, + const Http2PriorityFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2PriorityFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2PriorityFields& v); // Http2RstStreamFields: @@ -192,14 +192,14 @@ Http2ErrorCode error_code; }; -NET_EXPORT_PRIVATE bool operator==(const Http2RstStreamFields& a, - const Http2RstStreamFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2RstStreamFields& a, - const Http2RstStreamFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2RstStreamFields& a, + const Http2RstStreamFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2RstStreamFields& a, + const Http2RstStreamFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2RstStreamFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2RstStreamFields& v); // Http2SettingFields: @@ -216,14 +216,14 @@ uint32_t value; }; -NET_EXPORT_PRIVATE bool operator==(const Http2SettingFields& a, - const Http2SettingFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2SettingFields& a, - const Http2SettingFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2SettingFields& a, + const Http2SettingFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2SettingFields& a, + const Http2SettingFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2SettingFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2SettingFields& v); // Http2PushPromiseFields: @@ -233,14 +233,14 @@ uint32_t promised_stream_id; }; -NET_EXPORT_PRIVATE bool operator==(const Http2PushPromiseFields& a, - const Http2PushPromiseFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2PushPromiseFields& a, - const Http2PushPromiseFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2PushPromiseFields& a, + const Http2PushPromiseFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2PushPromiseFields& a, + const Http2PushPromiseFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2PushPromiseFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2PushPromiseFields& v); // Http2PingFields: @@ -251,14 +251,14 @@ uint8_t opaque_data[8]; }; -NET_EXPORT_PRIVATE bool operator==(const Http2PingFields& a, - const Http2PingFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2PingFields& a, - const Http2PingFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2PingFields& a, + const Http2PingFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2PingFields& a, + const Http2PingFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2PingFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2PingFields& v); // Http2GoAwayFields: @@ -275,14 +275,14 @@ Http2ErrorCode error_code; }; -NET_EXPORT_PRIVATE bool operator==(const Http2GoAwayFields& a, - const Http2GoAwayFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2GoAwayFields& a, - const Http2GoAwayFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2GoAwayFields& a, + const Http2GoAwayFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2GoAwayFields& a, + const Http2GoAwayFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2GoAwayFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2GoAwayFields& v); // Http2WindowUpdateFields: @@ -294,14 +294,14 @@ uint32_t window_size_increment; }; -NET_EXPORT_PRIVATE bool operator==(const Http2WindowUpdateFields& a, - const Http2WindowUpdateFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2WindowUpdateFields& a, - const Http2WindowUpdateFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2WindowUpdateFields& a, + const Http2WindowUpdateFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2WindowUpdateFields& a, + const Http2WindowUpdateFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2WindowUpdateFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2WindowUpdateFields& v); // Http2AltSvcFields: @@ -312,14 +312,14 @@ uint16_t origin_length; }; -NET_EXPORT_PRIVATE bool operator==(const Http2AltSvcFields& a, - const Http2AltSvcFields& b); -NET_EXPORT_PRIVATE inline bool operator!=(const Http2AltSvcFields& a, - const Http2AltSvcFields& b) { +HTTP2_EXPORT_PRIVATE bool operator==(const Http2AltSvcFields& a, + const Http2AltSvcFields& b); +HTTP2_EXPORT_PRIVATE inline bool operator!=(const Http2AltSvcFields& a, + const Http2AltSvcFields& b) { return !(a == b); } -NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, - const Http2AltSvcFields& v); +HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, + const Http2AltSvcFields& v); } // namespace net
diff --git a/net/http2/platform/api/http2_export.h b/net/http2/platform/api/http2_export.h new file mode 100644 index 0000000..5d022c01 --- /dev/null +++ b/net/http2/platform/api/http2_export.h
@@ -0,0 +1,10 @@ +// Copyright 2017 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 NET_HTTP2_PLATFORM_API_HTTP2_EXPORT_H_ +#define NET_HTTP2_PLATFORM_API_HTTP2_EXPORT_H_ + +#include "net/http2/platform/impl/http2_export_impl.h" + +#endif // NET_HTTP2_PLATFORM_API_HTTP2_EXPORT_H_
diff --git a/net/http2/platform/impl/http2_export_impl.h b/net/http2/platform/impl/http2_export_impl.h new file mode 100644 index 0000000..f2321c6 --- /dev/null +++ b/net/http2/platform/impl/http2_export_impl.h
@@ -0,0 +1,13 @@ +// Copyright 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_ +#define NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_ + +#include "net/base/net_export.h" + +#define HTTP2_EXPORT NET_EXPORT +#define HTTP2_EXPORT_PRIVATE NET_EXPORT_PRIVATE + +#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_
diff --git a/net/spdy/core/spdy_protocol.cc b/net/spdy/core/spdy_protocol.cc index c95fc0f..336659fc 100644 --- a/net/spdy/core/spdy_protocol.cc +++ b/net/spdy/core/spdy_protocol.cc
@@ -291,10 +291,18 @@ const char* const kHttp2Npn = "h2"; +bool SpdyFrameIR::fin() const { + return false; +} + int SpdyFrameIR::flow_control_window_consumed() const { return 0; } +bool SpdyFrameWithFinIR::fin() const { + return fin_; +} + SpdyFrameWithHeaderBlockIR::SpdyFrameWithHeaderBlockIR( SpdyStreamId stream_id, SpdyHeaderBlock header_block)
diff --git a/net/spdy/core/spdy_protocol.h b/net/spdy/core/spdy_protocol.h index 12fe4151..af3c1f1 100644 --- a/net/spdy/core/spdy_protocol.h +++ b/net/spdy/core/spdy_protocol.h
@@ -408,6 +408,7 @@ virtual void Visit(SpdyFrameVisitor* visitor) const = 0; virtual SpdyFrameType frame_type() const = 0; SpdyStreamId stream_id() const { return stream_id_; } + virtual bool fin() const; // Returns the number of bytes of flow control window that would be consumed // by this frame if written to the wire. @@ -428,7 +429,7 @@ class SPDY_EXPORT_PRIVATE SpdyFrameWithFinIR : public SpdyFrameIR { public: ~SpdyFrameWithFinIR() override {} - bool fin() const { return fin_; } + bool fin() const override; void set_fin(bool fin) { fin_ = fin; } protected:
diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index fe282925..b3b53d1 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc
@@ -38,8 +38,6 @@ #include "net/net_features.h" #include "net/nqe/network_quality_estimator.h" #include "net/quic/chromium/quic_stream_factory.h" -#include "net/reporting/reporting_policy.h" -#include "net/reporting/reporting_service.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/default_channel_id_store.h" #include "net/ssl/ssl_config_service_defaults.h" @@ -62,6 +60,11 @@ #include "net/url_request/ftp_protocol_handler.h" // nogncheck #endif +#if BUILDFLAG(ENABLE_REPORTING) +#include "net/reporting/reporting_policy.h" +#include "net/reporting/reporting_service.h" +#endif // BUILDFLAG(ENABLE_REPORTING) + namespace net { namespace { @@ -146,9 +149,11 @@ ContainerURLRequestContext() : storage_(this) {} ~ContainerURLRequestContext() override { +#if BUILDFLAG(ENABLE_REPORTING) // Destroy the ReportingService before the rest of the URLRequestContext, so // it cancels any pending requests it may have. storage_.set_reporting_service(nullptr); +#endif // BUILDFLAG(ENABLE_REPORTING) // Shut down the ProxyService, as it may have pending URLRequests using this // context. Since this cancels requests, it's not safe to subclass this, as @@ -258,10 +263,12 @@ cert_verifier_ = std::move(cert_verifier); } +#if BUILDFLAG(ENABLE_REPORTING) void URLRequestContextBuilder::set_reporting_policy( std::unique_ptr<net::ReportingPolicy> reporting_policy) { reporting_policy_ = std::move(reporting_policy); } +#endif // BUILDFLAG(ENABLE_REPORTING) void URLRequestContextBuilder::SetInterceptors( std::vector<std::unique_ptr<URLRequestInterceptor>> @@ -509,10 +516,12 @@ } storage->set_job_factory(std::move(top_job_factory)); +#if BUILDFLAG(ENABLE_REPORTING) if (reporting_policy_) { storage->set_reporting_service( ReportingService::Create(*reporting_policy_, context.get())); } +#endif // BUILDFLAG(ENABLE_REPORTING) return std::move(context); }
diff --git a/net/url_request/url_request_context_builder.h b/net/url_request/url_request_context_builder.h index e4c77c6..c38dea98 100644 --- a/net/url_request/url_request_context_builder.h +++ b/net/url_request/url_request_context_builder.h
@@ -28,6 +28,7 @@ #include "base/memory/ref_counted.h" #include "base/task_scheduler/task_traits.h" #include "build/build_config.h" +#include "build/buildflag.h" #include "net/base/net_export.h" #include "net/base/network_delegate.h" #include "net/base/proxy_delegate.h" @@ -307,10 +308,10 @@ void SetCertVerifier(std::unique_ptr<CertVerifier> cert_verifier); - // Sets the reporting policy of the created request context. If not set, or - // set to nullptr, reporting is disabled. +#if BUILDFLAG(ENABLE_REPORTING) void set_reporting_policy( std::unique_ptr<net::ReportingPolicy> reporting_policy); +#endif // BUILDFLAG(ENABLE_REPORTING) void SetInterceptors(std::vector<std::unique_ptr<URLRequestInterceptor>> url_request_interceptors); @@ -411,7 +412,9 @@ std::unique_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; std::unique_ptr<CertVerifier> cert_verifier_; std::unique_ptr<CTVerifier> ct_verifier_; +#if BUILDFLAG(ENABLE_REPORTING) std::unique_ptr<net::ReportingPolicy> reporting_policy_; +#endif // BUILDFLAG(ENABLE_REPORTING) std::vector<std::unique_ptr<URLRequestInterceptor>> url_request_interceptors_; std::unique_ptr<HttpServerProperties> http_server_properties_; std::map<std::string, std::unique_ptr<URLRequestJobFactory::ProtocolHandler>>
diff --git a/net/url_request/url_request_context_storage.cc b/net/url_request/url_request_context_storage.cc index 7003bb9..226b7e8 100644 --- a/net/url_request/url_request_context_storage.cc +++ b/net/url_request/url_request_context_storage.cc
@@ -20,13 +20,16 @@ #include "net/http/http_transaction_factory.h" #include "net/log/net_log.h" #include "net/proxy/proxy_service.h" -#include "net/reporting/reporting_service.h" #include "net/ssl/channel_id_service.h" #include "net/url_request/http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job_factory.h" #include "net/url_request/url_request_throttler_manager.h" +#if BUILDFLAG(ENABLE_REPORTING) +#include "net/reporting/reporting_service.h" +#endif // BUILDFLAG(ENABLE_REPORTING) + namespace net { URLRequestContextStorage::URLRequestContextStorage(URLRequestContext* context) @@ -153,10 +156,12 @@ sdch_manager_ = std::move(sdch_manager); } +#if BUILDFLAG(ENABLE_REPORTING) void URLRequestContextStorage::set_reporting_service( std::unique_ptr<ReportingService> reporting_service) { context_->set_reporting_service(reporting_service.get()); reporting_service_ = std::move(reporting_service); } +#endif // BUILDFLAG(ENABLE_REPORTING) } // namespace net
diff --git a/net/url_request/url_request_context_storage.h b/net/url_request/url_request_context_storage.h index 3f46e47..9384bea3 100644 --- a/net/url_request/url_request_context_storage.h +++ b/net/url_request/url_request_context_storage.h
@@ -9,7 +9,9 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "build/buildflag.h" #include "net/base/net_export.h" +#include "net/net_features.h" namespace net { @@ -79,8 +81,11 @@ void set_http_user_agent_settings( std::unique_ptr<HttpUserAgentSettings> http_user_agent_settings); void set_sdch_manager(std::unique_ptr<SdchManager> sdch_manager); + +#if BUILDFLAG(ENABLE_REPORTING) void set_reporting_service( std::unique_ptr<ReportingService> reporting_service); +#endif // BUILDFLAG(ENABLE_REPORTING) // Everything else can be access through the URLRequestContext, but this // cannot. Having an accessor for it makes usage a little cleaner. @@ -119,7 +124,9 @@ std::unique_ptr<URLRequestJobFactory> job_factory_; std::unique_ptr<URLRequestThrottlerManager> throttler_manager_; std::unique_ptr<SdchManager> sdch_manager_; +#if BUILDFLAG(ENABLE_REPORTING) std::unique_ptr<ReportingService> reporting_service_; +#endif // BUILDFLAG(ENABLE_REPORTING) DISALLOW_COPY_AND_ASSIGN(URLRequestContextStorage); };
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index ca79261..823f557 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc
@@ -24,6 +24,7 @@ #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "base/values.h" +#include "build/buildflag.h" #include "net/base/host_port_pair.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" @@ -51,11 +52,11 @@ #include "net/http/http_util.h" #include "net/log/net_log_event_type.h" #include "net/log/net_log_with_source.h" +#include "net/net_features.h" #include "net/nqe/network_quality_estimator.h" #include "net/proxy/proxy_info.h" #include "net/proxy/proxy_retry_info.h" #include "net/proxy/proxy_service.h" -#include "net/reporting/reporting_service.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_config_service.h" @@ -73,6 +74,10 @@ #include "net/android/network_library.h" #endif +#if BUILDFLAG(ENABLE_REPORTING) +#include "net/reporting/reporting_service.h" +#endif // BUILDFLAG(ENABLE_REPORTING) + static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; namespace { @@ -852,6 +857,7 @@ void URLRequestHttpJob::ProcessReportToHeader() { DCHECK(response_info_); +#if BUILDFLAG(ENABLE_REPORTING) ReportingService* service = request_->context()->reporting_service(); if (!service) return; @@ -869,6 +875,7 @@ return; service->ProcessHeader(request_info_.url.GetOrigin(), value); +#endif // BUILDFLAG(ENABLE_REPORTING) } void URLRequestHttpJob::OnStartCompleted(int result) {
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 055f081..09b9c28 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc
@@ -5,8 +5,7 @@ #include <memory> #include <utility> -#include "base/memory/ptr_util.h" -#include "base/run_loop.h" +// This must be before Windows headers #include "build/build_config.h" #if defined(OS_WIN) @@ -47,6 +46,7 @@ #include "base/test/histogram_tester.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" +#include "build/buildflag.h" #include "net/base/chunked_upload_data_stream.h" #include "net/base/directory_listing.h" #include "net/base/elements_upload_data_stream.h" @@ -93,7 +93,6 @@ #include "net/proxy/proxy_service.h" #include "net/quic/chromium/mock_crypto_client_stream_factory.h" #include "net/quic/chromium/quic_server_info.h" -#include "net/reporting/reporting_service.h" #include "net/socket/socket_test_util.h" #include "net/socket/ssl_client_socket.h" #include "net/ssl/channel_id_service.h" @@ -141,6 +140,10 @@ #include "base/win/scoped_comptr.h" #endif +#if BUILDFLAG(ENABLE_REPORTING) +#include "net/reporting/reporting_service.h" +#endif // BUILDFLAG(ENABLE_REPORTING) + using net::test::IsError; using net::test::IsOk; @@ -6799,7 +6802,9 @@ EXPECT_EQ(1u, reporter.num_failures()); } +#endif // !defined(OS_IOS) +#if BUILDFLAG(ENABLE_REPORTING) namespace { class TestReportingService : public ReportingService { @@ -6936,8 +6941,7 @@ EXPECT_TRUE(IsCertStatusError(request->ssl_info().cert_status)); EXPECT_TRUE(reporting_service.headers().empty()); } - -#endif // !defined(OS_IOS) +#endif // BUILDFLAG(ENABLE_REPORTING) TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) { ASSERT_TRUE(http_test_server()->Start());
diff --git a/remoting/android/BUILD.gn b/remoting/android/BUILD.gn index 07cbe53..248c1ea0 100644 --- a/remoting/android/BUILD.gn +++ b/remoting/android/BUILD.gn
@@ -20,16 +20,6 @@ jni_package = "remoting" } -generate_jni_registration("remoting_jni_registration") { - target = ":remoting_apk" - output = "$root_gen_dir/remoting/client/${target_name}.h" - exception_files = [ - "//base/android/java/src/org/chromium/base/library_loader/LegacyLinker.java", - "//base/android/java/src/org/chromium/base/library_loader/Linker.java", - "//base/android/java/src/org/chromium/base/library_loader/ModernLinker.java", - ] -} - _raw_resources_base_dir = "$target_gen_dir/credits_resources_raw/res" # The target is named this way, instead of "..._raw_resources", specifically
diff --git a/remoting/client/jni/BUILD.gn b/remoting/client/jni/BUILD.gn index 6f10926..f0f8082 100644 --- a/remoting/client/jni/BUILD.gn +++ b/remoting/client/jni/BUILD.gn
@@ -19,7 +19,6 @@ shared_library("remoting_client_jni") { deps = [ "//remoting/android:jni_headers", - "//remoting/android:remoting_jni_registration", "//remoting/base", "//remoting/client", "//remoting/client/display",
diff --git a/remoting/client/jni/remoting_jni_onload.cc b/remoting/client/jni/remoting_jni_onload.cc index dd1a283d..9db79a8 100644 --- a/remoting/client/jni/remoting_jni_onload.cc +++ b/remoting/client/jni/remoting_jni_onload.cc
@@ -11,7 +11,6 @@ #include "base/macros.h" #include "net/android/net_jni_registrar.h" #include "remoting/client/jni/remoting_jni_registrar.h" -#include "remoting/client/remoting_jni_registration.h" #include "ui/gfx/android/gfx_jni_registrar.h" namespace { @@ -33,12 +32,6 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!RegisterMainDexNatives(env) || !RegisterNonMainDexNatives(env)) { - return -1; - } - - // TODO(agrieve): Delete this block, this is a no-op now. - // https://crbug.com/683256. if (!RegisterJNI(env) || !base::android::OnJNIOnLoadInit()) { return -1; }
diff --git a/services/service_manager/embedder/BUILD.gn b/services/service_manager/embedder/BUILD.gn index 88ca634..ff47b778 100644 --- a/services/service_manager/embedder/BUILD.gn +++ b/services/service_manager/embedder/BUILD.gn
@@ -12,6 +12,8 @@ "main.h", "main_delegate.cc", "main_delegate.h", + "manifest_utils.cc", + "manifest_utils.h", "process_type.h", "service_manager_embedder_export.h", "set_process_title.cc", @@ -52,3 +54,17 @@ defines = [ "SERVICE_MANAGER_EMBEDDER_IMPL" ] } + +source_set("unittests") { + testonly = true + + sources = [ + "manifest_utils_unittest.cc", + ] + + deps = [ + ":embedder", + "//base", + "//testing/gtest", + ] +}
diff --git a/content/browser/service_manager/merge_dictionary.cc b/services/service_manager/embedder/manifest_utils.cc similarity index 61% rename from content/browser/service_manager/merge_dictionary.cc rename to services/service_manager/embedder/manifest_utils.cc index b50ee5d..25903b0 100644 --- a/content/browser/service_manager/merge_dictionary.cc +++ b/services/service_manager/embedder/manifest_utils.cc
@@ -2,12 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/service_manager/merge_dictionary.h" +#include "services/service_manager/embedder/manifest_utils.h" #include "base/memory/ptr_util.h" -namespace content { +namespace service_manager { +namespace { + +// Similar to base::DictionaryValue::MergeDictionary(), except concatenates +// ListValue contents. +// This is explicitly not part of base::DictionaryValue at brettw's request. void MergeDictionary(base::DictionaryValue* target, const base::DictionaryValue* source) { for (base::DictionaryValue::Iterator it(*source); !it.IsAtEnd(); @@ -17,9 +22,8 @@ if (merge_value->IsType(base::Value::Type::DICTIONARY)) { base::DictionaryValue* sub_dict; if (target->GetDictionaryWithoutPathExpansion(it.key(), &sub_dict)) { - MergeDictionary( - sub_dict, - static_cast<const base::DictionaryValue*>(merge_value)); + MergeDictionary(sub_dict, + static_cast<const base::DictionaryValue*>(merge_value)); continue; } } @@ -43,4 +47,19 @@ } } -} // namespace content +} // namespace + +void MergeManifestWithOverlay(base::Value* manifest, base::Value* overlay) { + if (!overlay) + return; + + base::DictionaryValue* manifest_dictionary = nullptr; + bool result = manifest->GetAsDictionary(&manifest_dictionary); + DCHECK(result); + base::DictionaryValue* overlay_dictionary = nullptr; + result = overlay->GetAsDictionary(&overlay_dictionary); + DCHECK(result); + MergeDictionary(manifest_dictionary, overlay_dictionary); +} + +} // namespace service_manager
diff --git a/services/service_manager/embedder/manifest_utils.h b/services/service_manager/embedder/manifest_utils.h new file mode 100644 index 0000000..69119cc --- /dev/null +++ b/services/service_manager/embedder/manifest_utils.h
@@ -0,0 +1,20 @@ +// Copyright 2016 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 SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_ +#define SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_ + +#include "base/values.h" +#include "services/service_manager/embedder/service_manager_embedder_export.h" + +namespace service_manager { + +// Merges |overlay| (if not null) into |manifest|. +// Uses a strategy similar to base::DictionaryValue::MergeDictionary(), except +// concatenates ListValue contents. +void SERVICE_MANAGER_EMBEDDER_EXPORT +MergeManifestWithOverlay(base::Value* manifest, base::Value* overlay); +} // namespace service_manager + +#endif // SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_
diff --git a/content/browser/service_manager/merge_dictionary_unittest.cc b/services/service_manager/embedder/manifest_utils_unittest.cc similarity index 66% rename from content/browser/service_manager/merge_dictionary_unittest.cc rename to services/service_manager/embedder/manifest_utils_unittest.cc index 17c2cfe6..8a0baee 100644 --- a/content/browser/service_manager/merge_dictionary_unittest.cc +++ b/services/service_manager/embedder/manifest_utils_unittest.cc
@@ -2,51 +2,49 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "services/service_manager/embedder/manifest_utils.h" #include "base/memory/ptr_util.h" -#include "content/browser/service_manager/merge_dictionary.h" #include "testing/gtest/include/gtest/gtest.h" -namespace content { +namespace service_manager { -using MergeDictionaryTest = testing::Test; - -TEST(MergeDictionaryTest, Merge) { - // |source| & |target| have three properties, "string", "list" and +TEST(MergeManifestWithOverlayTest, Merge) { + // |manifest| & |overlay| have three properties, "string", "list" and // "dictionary", which are then merged. - base::DictionaryValue target; - target.SetString("string", "Hello, "); + base::DictionaryValue manifest; + manifest.SetString("string", "Hello, "); std::unique_ptr<base::DictionaryValue> dict_value_original( base::MakeUnique<base::DictionaryValue>()); dict_value_original->SetString("key1", "original"); dict_value_original->SetString("key3", "original"); - target.Set("dictionary", std::move(dict_value_original)); + manifest.Set("dictionary", std::move(dict_value_original)); std::unique_ptr<base::ListValue> list(base::MakeUnique<base::ListValue>()); list->AppendString("A"); list->AppendString("B"); - target.Set("list", std::move(list)); + manifest.Set("list", std::move(list)); - base::DictionaryValue source; - source.SetString("string", "World!"); + base::DictionaryValue overlay; + overlay.SetString("string", "World!"); std::unique_ptr<base::DictionaryValue> dict_value_replacement( base::MakeUnique<base::DictionaryValue>()); dict_value_replacement->SetString("key1", "new"); dict_value_replacement->SetString("key2", "new"); - source.Set("dictionary", std::move(dict_value_replacement)); + overlay.Set("dictionary", std::move(dict_value_replacement)); list = base::MakeUnique<base::ListValue>(); list->AppendString("C"); - source.Set("list", std::move(list)); + overlay.Set("list", std::move(list)); - MergeDictionary(&target, &source); + MergeManifestWithOverlay(&manifest, &overlay); // Simple string value should have been clobbered. std::string out_string; - EXPECT_TRUE(target.GetString("string", &out_string)); + EXPECT_TRUE(manifest.GetString("string", &out_string)); EXPECT_EQ(out_string, "World!"); // Dictionary should have been merged, with key1 being clobbered, key2 added // and key3 preserved. base::DictionaryValue* out_dictionary = nullptr; - EXPECT_TRUE(target.GetDictionary("dictionary", &out_dictionary)); + EXPECT_TRUE(manifest.GetDictionary("dictionary", &out_dictionary)); EXPECT_EQ(3u, out_dictionary->size()); std::string value1, value2, value3; EXPECT_TRUE(out_dictionary->GetString("key1", &value1)); @@ -56,10 +54,10 @@ EXPECT_EQ(value2, "new"); EXPECT_EQ(value3, "original"); - // List should have been merged, with the items from source appended to the - // items from target. + // List should have been merged, with the items from overlay appended to the + // items from manifest. base::ListValue* out_list = nullptr; - EXPECT_TRUE(target.GetList("list", &out_list)); + EXPECT_TRUE(manifest.GetList("list", &out_list)); EXPECT_EQ(3u, out_list->GetSize()); std::string a, b, c; EXPECT_TRUE(out_list->GetString(0, &a)); @@ -70,4 +68,4 @@ EXPECT_EQ("C", c); } -} // namespace content +} // namespace service_manager
diff --git a/services/service_manager/tests/BUILD.gn b/services/service_manager/tests/BUILD.gn index 9b1e735..ebd0dcdc 100644 --- a/services/service_manager/tests/BUILD.gn +++ b/services/service_manager/tests/BUILD.gn
@@ -30,6 +30,7 @@ "//services/service_manager", "//services/service_manager/background:lib", "//services/service_manager/background/tests:unittests", + "//services/service_manager/embedder:unittests", "//services/service_manager/public/cpp", "//services/service_manager/public/interfaces", "//services/service_manager/runner/host:unittests",
diff --git a/testing/buildbot/filters/fuchsia.base_unittests.filter b/testing/buildbot/filters/fuchsia.base_unittests.filter index ad08a10..6c558a9 100644 --- a/testing/buildbot/filters/fuchsia.base_unittests.filter +++ b/testing/buildbot/filters/fuchsia.base_unittests.filter
@@ -1,32 +1,12 @@ # TODO(fuchsia): Being ported, see https://crbug.com/706592. --ActivityTrackerTest.BasicTest -ActivityTrackerTest.CreateWithFileTest -ActivityTrackerTest.ProcessDeathTest -ActivityTrackerTest.ThreadDeathTest --CrashLoggingTest.ChunkValue --CrashLoggingTest.InitSize --CrashLoggingTest.ScopedCrashKey --CrashLoggingTest.SetChunked --CrashLoggingTest.SetClearSingle --DirReaderPosixUnittest.Read --DiscardableSharedMemoryTest.Close --DiscardableSharedMemoryTest.CreateAndMap --DiscardableSharedMemoryTest.CreateFromHandle --DiscardableSharedMemoryTest.LastUsed --DiscardableSharedMemoryTest.LockAndUnlock --DiscardableSharedMemoryTest.LockAndUnlockRange --DiscardableSharedMemoryTest.LockShouldAlwaysFailAfterSuccessfulPurge --DiscardableSharedMemoryTest.MappedSize --DiscardableSharedMemoryTest.Purge --DiscardableSharedMemoryTest.ZeroSize --FeatureListTest.StoreAndRetrieveAssociatedFeaturesFromSharedMemory --FeatureListTest.StoreAndRetrieveFeaturesFromSharedMemory -FileLockingTest.LockAndUnlock -FileLockingTest.UnlockOnClose -FileLockingTest.UnlockOnExit -FileLockingTest.UnlockOnTerminate --FilePathTest.FromUTF8Unsafe_And_AsUTF8Unsafe -FilePathWatcherTest.DeleteAndRecreate -FilePathWatcherTest.DeleteDuringNotify -FilePathWatcherTest.DeletedFile @@ -77,16 +57,6 @@ -MessageLoopTestTypeDefault.PostDelayedTask_Basic -NativeLibraryTest.LoadLibrary -NativeLibraryTest.LoadLibraryPreferOwnSymbols --ObserverListThreadSafeTest.AddObserverFromNotificationNotifyAll --ObserverListThreadSafeTest.CrossThreadNotifications --ObserverListThreadSafeTest.Existing --ObserverListThreadSafeTest.NotificationOnValidSequence --ObserverListThreadSafeTest.OutlivesMessageLoop --ObserverListThreadSafeTest.RemoveWhileNotificationIsRunning --OptionalTest.CopyConstructor --OptionalTest.DefaultConstructor --OptionalTest.MoveConstructor --OptionalTest.ValueConstructor -PartitionAllocTest.Basic -PartitionAllocTest.DumpMemoryStats -PartitionAllocTest.FreeCache @@ -113,12 +83,6 @@ -PersistentHistogramAllocatorTest.CreateWithFile -PersistentHistogramAllocatorTest.RangesDeDuplication -PersistentHistogramAllocatorTest.StatisticsRecorderMerge --PersistentMemoryAllocatorTest.AllocateAndIterate --PersistentMemoryAllocatorTest.IteratorParallelismTest --PersistentMemoryAllocatorTest.PageTest --PersistentMemoryAllocatorTest.ParallelismTest --PersistentSampleMapTest.AccumulateTest --PersistentSampleMapTest.Accumulate_LargeValuesDontOverflow -PlatformThreadTest.ThreadPriorityCurrentThread -ProcessMemoryDumpTest.CountResidentBytes -ProcessMemoryDumpTest.TakeAllDumpsFrom @@ -149,10 +113,6 @@ -RedirectionToTaskScheduler/SequencedWorkerPoolTest.ShutsDownCleanWithContinueOnShutdown/0 -RedirectionToTaskScheduler/SequencedWorkerPoolTest.SkipOnShutdown/0 -RedirectionToTaskScheduler/SequencedWorkerPoolTest.SpuriousWorkSignal/0 --SafeNumerics.SignedIntegerMath --SharedPersistentMemoryAllocatorTest.CreationTest --SyncSocket.ClonedSendReceivePeek --SyncSocket.NormalSendReceivePeek -SysInfoTest.AmountOfFreeDiskSpace -SysInfoTest.AmountOfMem -SysInfoTest.AmountOfTotalDiskSpace @@ -166,7 +126,6 @@ -TaskSchedulerWorkerPoolStandbyPolicyTest.InitLazy -TaskSchedulerWorkerPoolStandbyPolicyTest.InitOne -TrackedObjectsTest.ReuseRetiredThreadData --TrackedTimeTest.TrackedTimerDuration -VerifyPathControlledByUserTest.BadPaths -VerifyPathControlledByUserTest.GroupWriteTest -VerifyPathControlledByUserTest.OwnershipChecks
diff --git a/testing/libfuzzer/fuzzers/libsrtp_fuzzer.cc b/testing/libfuzzer/fuzzers/libsrtp_fuzzer.cc index c2cf7eb..b3f7e4b 100644 --- a/testing/libfuzzer/fuzzers/libsrtp_fuzzer.cc +++ b/testing/libfuzzer/fuzzers/libsrtp_fuzzer.cc
@@ -9,9 +9,9 @@ #include <algorithm> #include <vector> -#include "third_party/libsrtp/include/rtp.h" -#include "third_party/libsrtp/include/rtp_priv.h" #include "third_party/libsrtp/include/srtp.h" +#include "third_party/libsrtp/include/srtp_priv.h" +#include "third_party/libsrtp/test/rtp.h" // TODO(katrielc) Also test the authenticated path, which is what // WebRTC uses. This is nontrivial because you need to bypass the MAC
diff --git a/testing/test.gni b/testing/test.gni index 64619b3..36e0d91 100644 --- a/testing/test.gni +++ b/testing/test.gni
@@ -63,7 +63,7 @@ # the default shared_library configs rather than executable configs. configs -= [ "//build/config:shared_library_config", - "//build/config/android:hide_all_but_jni", + "//build/config/android:hide_all_but_jni_onload", ] configs += [ "//build/config:executable_config" ] @@ -321,8 +321,6 @@ set_defaults("test") { if (is_android) { configs = default_shared_library_configs - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - configs += [ "//build/config/android:hide_all_but_jni" ] } else { configs = default_executable_configs }
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index 60f2dcd1..a7ce4e88 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -2950,6 +2950,8 @@ crbug.com/v8/6529 inspector/console/console-dir.html [ NeedsManualRebaseline ] crbug.com/v8/6529 inspector/console/console-format.html [ NeedsManualRebaseline ] +crbug.com/737959 http/tests/misc/video-poster-image-load-outlives-gc-without-crashing.html [ Failure Pass Crash ] + # These tests are failing on Mac-10.12 when using an Intel GPU. crbug.com/736177 [ Mac ] css2.1/t1202-counter-04-b.html [ Failure Pass ] crbug.com/736177 [ Mac ] css2.1/t1202-counters-04-b.html [ Failure Pass ]
diff --git a/third_party/WebKit/LayoutTests/plugins/type-case.html b/third_party/WebKit/LayoutTests/plugins/type-case.html new file mode 100644 index 0000000..4d7ee38 --- /dev/null +++ b/third_party/WebKit/LayoutTests/plugins/type-case.html
@@ -0,0 +1,11 @@ +<!DOCYPE html> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<embed id="p1" src="resources/test.blinktestplugin" type="application/x-blinK-test-plugin"> +<object id="p2" src="resources/test.blinktestplugin" type="application/x-blinK-test-plugin"> +<script> +test(() => { + assert_equals(document.querySelector('#p1').postMessage, undefined); + assert_equals(document.querySelector('#p2').postMessage, undefined); +}, 'MIME type matching should be ASCII case-insensitive.'); +</script>
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp index 876c9a6..7ed0c47 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
@@ -12,6 +12,25 @@ namespace blink { +const char* ScriptModuleStateToString(ScriptModuleState state) { + switch (state) { + case ScriptModuleState::kUninstantiated: + return "uninstantiated"; + case ScriptModuleState::kInstantiating: + return "instatinating"; + case ScriptModuleState::kInstantiated: + return "instantiated"; + case ScriptModuleState::kEvaluating: + return "evaluating"; + case ScriptModuleState::kEvaluated: + return "evaluated"; + case ScriptModuleState::kErrored: + return "errored"; + } + NOTREACHED(); + return ""; +} + ScriptModule::ScriptModule() { // We ensure module-related code is not executed without the flag. // https://crbug.com/715376 @@ -151,6 +170,13 @@ return ret; } +ScriptModuleState ScriptModule::Status(ScriptState* script_state) { + DCHECK(!IsNull()); + + v8::Local<v8::Module> module = module_->NewLocal(script_state->GetIsolate()); + return module->GetStatus(); +} + v8::MaybeLocal<v8::Module> ScriptModule::ResolveModuleCallback( v8::Local<v8::Context> context, v8::Local<v8::String> specifier,
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h index e05cfc9..fa37d90 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h
@@ -19,6 +19,12 @@ class ExceptionState; +// Correspond to TC39 ModuleRecord.[[Status]] +// TODO(kouhei): Add URL after https://github.com/tc39/ecma262/pull/916 is +// merged. +using ScriptModuleState = v8::Module::Status; +const char* ScriptModuleStateToString(ScriptModuleState); + // ScriptModule wraps a handle to a v8::Module for use in core. // // Using ScriptModules needs a ScriptState and its scope to operate in. You @@ -53,6 +59,7 @@ Vector<String> ModuleRequests(ScriptState*); Vector<TextPosition> ModuleRequestPositions(ScriptState*); + ScriptModuleState Status(ScriptState*); bool IsHashTableDeletedValue() const { return module_.IsHashTableDeletedValue();
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp index c5c0e9e..3cd82cb 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModuleTest.cpp
@@ -84,6 +84,8 @@ kSharableCrossOrigin, TextPosition::MinimumPosition(), ASSERT_NO_EXCEPTION); ASSERT_FALSE(module.IsNull()); + EXPECT_EQ(ScriptModuleState::kUninstantiated, + module.Status(scope.GetScriptState())); } TEST(ScriptModuleTest, compileFail) { @@ -201,6 +203,12 @@ ASSERT_FALSE(module.IsNull()); ScriptValue exception = module.Instantiate(scope.GetScriptState()); ASSERT_TRUE(exception.IsEmpty()); + EXPECT_EQ(ScriptModuleState::kInstantiated, + module_a.Status(scope.GetScriptState())); + EXPECT_EQ(ScriptModuleState::kInstantiated, + module_b.Status(scope.GetScriptState())); + EXPECT_EQ(ScriptModuleState::kInstantiated, + module.Status(scope.GetScriptState())); ASSERT_EQ(2u, resolver->ResolveCount()); EXPECT_EQ("a", resolver->Specifiers()[0]); @@ -228,6 +236,8 @@ ScriptSourceCode("window.foo")); ASSERT_TRUE(value->IsString()); EXPECT_EQ("bar", ToCoreString(v8::Local<v8::String>::Cast(value))); + EXPECT_EQ(ScriptModuleState::kEvaluated, + module.Status(scope.GetScriptState())); } } // namespace
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp index 39c76f3..f0a5ea2 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
@@ -3391,7 +3391,6 @@ SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); paint_artifact_compositor_->Update(paint_controller_->GetPaintArtifact(), - is_storing_composited_layer_debug_info_, composited_element_ids); }
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.h b/third_party/WebKit/Source/core/frame/LocalFrameView.h index 494ecb2..50b4077 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.h +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.h
@@ -381,10 +381,6 @@ static void SetInitialTracksPaintInvalidationsForTesting(bool); - void SetIsStoringCompositedLayerDebugInfo(bool val) { - is_storing_composited_layer_debug_info_ = val; - } - // These methods are for testing. void SetTracksPaintInvalidations(bool); bool IsTrackingPaintInvalidations() const { @@ -1223,7 +1219,6 @@ std::unique_ptr<PaintController> paint_controller_; std::unique_ptr<PaintArtifactCompositor> paint_artifact_compositor_; - bool is_storing_composited_layer_debug_info_; MainThreadScrollingReasons main_thread_scrolling_reasons_; // TODO(kenrb): Remove these when https://crbug.com/680606 is resolved.
diff --git a/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp b/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp index 6882e0f4d..16aef7b 100644 --- a/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp
@@ -97,7 +97,7 @@ void HTMLEmbedElement::ParseAttribute( const AttributeModificationParams& params) { if (params.name == typeAttr) { - service_type_ = params.new_value.DeprecatedLower(); + service_type_ = params.new_value.LowerASCII(); size_t pos = service_type_.Find(";"); if (pos != kNotFound) service_type_ = service_type_.Left(pos);
diff --git a/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp b/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp index 0d25746..e857502 100644 --- a/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLObjectElement.cpp
@@ -99,7 +99,7 @@ if (name == formAttr) { FormAttributeChanged(); } else if (name == typeAttr) { - service_type_ = params.new_value.DeprecatedLower(); + service_type_ = params.new_value.LowerASCII(); size_t pos = service_type_.Find(";"); if (pos != kNotFound) service_type_ = service_type_.Left(pos);
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilder.cpp b/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilder.cpp index d4254bd..97acc6c 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLTreeBuilder.cpp
@@ -445,12 +445,14 @@ for (size_t i = 0; i < length; ++i) { const QualifiedName& name = *names[i]; const AtomicString& local_name = name.LocalName(); - AtomicString lowered_local_name = local_name.DeprecatedLower(); + AtomicString lowered_local_name = local_name.LowerASCII(); if (lowered_local_name != local_name) map->insert(lowered_local_name, name); } } +// "Any other start tag" bullet in +// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign static void AdjustSVGTagNameCase(AtomicHTMLToken* token) { static PrefixedNameToQualifiedNameMap* case_map = 0; if (!case_map) { @@ -482,10 +484,12 @@ } } +// https://html.spec.whatwg.org/multipage/parsing.html#adjust-svg-attributes static void AdjustSVGAttributes(AtomicHTMLToken* token) { AdjustAttributes<SVGNames::getSVGAttrs, SVGNames::SVGAttrsCount>(token); } +// https://html.spec.whatwg.org/multipage/parsing.html#adjust-mathml-attributes static void AdjustMathMLAttributes(AtomicHTMLToken* token) { AdjustAttributes<MathMLNames::getMathMLAttrs, MathMLNames::MathMLAttrsCount>( token);
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp index a67646e..466b6b5 100644 --- a/third_party/WebKit/Source/core/testing/Internals.cpp +++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -2504,36 +2504,6 @@ ->GetReferencedFilePaths(); } -void Internals::startStoringCompositedLayerDebugInfo( - Document* document, - ExceptionState& exception_state) { - DCHECK(document); - if (!document->View()) { - exception_state.ThrowDOMException(kInvalidAccessError, - "The document provided is invalid."); - return; - } - - LocalFrameView* frame_view = document->View(); - frame_view->SetIsStoringCompositedLayerDebugInfo(true); - frame_view->UpdateAllLifecyclePhases(); -} - -void Internals::stopStoringCompositedLayerDebugInfo( - Document* document, - ExceptionState& exception_state) { - DCHECK(document); - if (!document->View()) { - exception_state.ThrowDOMException(kInvalidAccessError, - "The document provided is invalid."); - return; - } - - LocalFrameView* frame_view = document->View(); - frame_view->SetIsStoringCompositedLayerDebugInfo(false); - frame_view->UpdateAllLifecyclePhases(); -} - void Internals::startTrackingRepaints(Document* document, ExceptionState& exception_state) { DCHECK(document);
diff --git a/third_party/WebKit/Source/core/testing/Internals.h b/third_party/WebKit/Source/core/testing/Internals.h index caa0183..9fa1309 100644 --- a/third_party/WebKit/Source/core/testing/Internals.h +++ b/third_party/WebKit/Source/core/testing/Internals.h
@@ -400,9 +400,6 @@ Vector<String> getReferencedFilePaths() const; - void startStoringCompositedLayerDebugInfo(Document*, ExceptionState&); - void stopStoringCompositedLayerDebugInfo(Document*, ExceptionState&); - void startTrackingRepaints(Document*, ExceptionState&); void stopTrackingRepaints(Document*, ExceptionState&); void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(
diff --git a/third_party/WebKit/Source/core/testing/Internals.idl b/third_party/WebKit/Source/core/testing/Internals.idl index 91856ac..3d36620 100644 --- a/third_party/WebKit/Source/core/testing/Internals.idl +++ b/third_party/WebKit/Source/core/testing/Internals.idl
@@ -246,9 +246,6 @@ sequence<DOMString> getReferencedFilePaths(); - [RaisesException] void startStoringCompositedLayerDebugInfo(Document document); - [RaisesException] void stopStoringCompositedLayerDebugInfo(Document document); - // These functions both reset the tracked repaint rects. They are intended to be used in the following order: // startTrackingRepaints(), repaintRectsAsText(), stopTrackingRepaints(). [RaisesException] void startTrackingRepaints(Document document);
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp index 034040c..3e626c9d 100644 --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.cpp
@@ -417,12 +417,7 @@ void PaintArtifactCompositor::Update( const PaintArtifact& paint_artifact, - bool store_debug_info, CompositorElementIdSet& composited_element_ids) { -#ifndef NDEBUG - store_debug_info = true; -#endif - DCHECK(root_layer_); // The tree will be null after detaching and this update can be ignored. @@ -457,6 +452,12 @@ Vector<std::unique_ptr<ContentLayerClientImpl>> new_content_layer_clients; new_content_layer_clients.ReserveCapacity(pending_layers.size()); + + bool store_debug_info = false; +#ifndef NDEBUG + store_debug_info = true; +#endif + for (const PendingLayer& pending_layer : pending_layers) { gfx::Vector2dF layer_offset; scoped_refptr<cc::Layer> layer = CompositedLayerForPendingLayer(
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h index f64f580..ca321112 100644 --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h
@@ -58,7 +58,6 @@ // the layers that will be output as part of a call to layersAsJSON // (if LayerTreeIncludesDebugInfo is specified). void Update(const PaintArtifact&, - bool store_debug_info, CompositorElementIdSet& composited_element_ids); // The root layer of the tree managed by this object.
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp index 153cb71a..2d721e29 100644 --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
@@ -132,7 +132,7 @@ void Update(const PaintArtifact& artifact, CompositorElementIdSet& element_ids) { - paint_artifact_compositor_->Update(artifact, false, element_ids); + paint_artifact_compositor_->Update(artifact, element_ids); web_layer_tree_view_->GetLayerTreeHost()->LayoutAndUpdateLayers(); }
diff --git a/third_party/WebKit/Source/platform/loader/fetch/Resource.cpp b/third_party/WebKit/Source/platform/loader/fetch/Resource.cpp index 1a32242..8f905a78 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/Resource.cpp +++ b/third_party/WebKit/Source/platform/loader/fetch/Resource.cpp
@@ -877,22 +877,20 @@ options_.cors_handling_by_resource_fetcher == kDisableCORSHandlingByResourceFetcher; - bool new_is_with_cors_mode = - new_request.GetFetchRequestMode() == WebURLRequest::kFetchRequestModeCORS; - bool existing_was_with_cors_mode = resource_request_.GetFetchRequestMode() == - WebURLRequest::kFetchRequestModeCORS; + auto new_mode = new_request.GetFetchRequestMode(); + auto existing_mode = resource_request_.GetFetchRequestMode(); if (new_is_with_fetcher_cors_suppressed) { if (existing_was_with_fetcher_cors_suppressed) return true; - return !existing_was_with_cors_mode; + return existing_mode != WebURLRequest::kFetchRequestModeCORS; } if (existing_was_with_fetcher_cors_suppressed) - return !new_is_with_cors_mode; + return new_mode != WebURLRequest::kFetchRequestModeCORS; - return new_is_with_cors_mode == existing_was_with_cors_mode; + return existing_mode == new_mode; } void Resource::Prune() {
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common.py index a3f476f9..5d772ffd 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common.py
@@ -4,6 +4,7 @@ """Utility functions used both when importing and exporting.""" +import json import logging from webkitpy.w3c.chromium_commit import ChromiumCommit @@ -101,3 +102,18 @@ if pull_request and pull_request.state == 'closed': return False return True + + +def read_credentials(host, credentials_json): + """Extracts credentials from a JSON file.""" + if not credentials_json: + return {} + if not host.filesystem.exists(credentials_json): + _log.warning('Credentials JSON file not found at %s.', credentials_json) + return {} + credentials = {} + contents = json.loads(host.filesystem.read_text_file(credentials_json)) + for key in ('GH_USER', 'GH_TOKEN', 'GERRIT_USER', 'GERRIT_TOKEN'): + if key in contents: + credentials[key] = contents[key] + return credentials
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common_unittest.py index e67c8e96..de0b97a 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common_unittest.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/common_unittest.py
@@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import json import unittest from webkitpy.common.host_mock import MockHost @@ -9,6 +10,7 @@ from webkitpy.w3c.chromium_commit import ChromiumCommit from webkitpy.w3c.chromium_commit_mock import MockChromiumCommit from webkitpy.w3c.common import _exportable_commits_since +from webkitpy.w3c.common import read_credentials from webkitpy.w3c.common import is_exportable from webkitpy.w3c.wpt_github import PullRequest from webkitpy.w3c.wpt_github_mock import MockWPTGitHub @@ -87,3 +89,30 @@ PullRequest('PR2', 2, 'body\nChange-Id: I00decade', 'closed'), ]) self.assertFalse(is_exportable(commit, MockLocalWPT(), github)) + + def test_get_credentials_empty(self): + host = MockHost() + host.filesystem.write_text_file('/tmp/credentials.json', '{}') + self.assertEqual(read_credentials(host, '/tmp/credentials.json'), {}) + + def test_get_credentials_none(self): + self.assertEqual(read_credentials(MockHost(), None), {}) + + def test_get_credentials_gets_values_from_file(self): + host = MockHost() + host.filesystem.write_text_file( + '/tmp/credentials.json', + json.dumps({ + 'GH_USER': 'user-github', + 'GH_TOKEN': 'pass-github', + 'GERRIT_USER': 'user-gerrit', + 'GERRIT_TOKEN': 'pass-gerrit', + })) + self.assertEqual( + read_credentials(host, '/tmp/credentials.json'), + { + 'GH_USER': 'user-github', + 'GH_TOKEN': 'pass-github', + 'GERRIT_USER': 'user-gerrit', + 'GERRIT_TOKEN': 'pass-gerrit', + })
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py index b0e1d9a..3a39a70 100644 --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py
@@ -19,7 +19,7 @@ from webkitpy.common.path_finder import PathFinder from webkitpy.layout_tests.models.test_expectations import TestExpectations, TestExpectationParser from webkitpy.layout_tests.port.base import Port -from webkitpy.w3c.common import WPT_REPO_URL, WPT_DEST_NAME, exportable_commits_over_last_n_commits +from webkitpy.w3c.common import WPT_REPO_URL, WPT_DEST_NAME, read_credentials, exportable_commits_over_last_n_commits from webkitpy.w3c.directory_owners_extractor import DirectoryOwnersExtractor from webkitpy.w3c.local_wpt import LocalWPT from webkitpy.w3c.wpt_github import WPTGitHub @@ -43,10 +43,16 @@ self.finder = PathFinder(self.fs) self.verbose = False self.git_cl = None - self.wpt_github = wpt_github or WPTGitHub(self.host) + self.wpt_github = wpt_github def main(self, argv=None): options = self.parse_args(argv) + + credentials = read_credentials(self.host, options.credentials_json) + if self.wpt_github is None: + self.wpt_github = WPTGitHub( + self.host, credentials.get('GH_USER'), credentials.get('GH_TOKEN')) + self.verbose = options.verbose log_level = logging.DEBUG if self.verbose else logging.INFO logging.basicConfig(level=log_level, format='%(message)s') @@ -123,8 +129,12 @@ help='authentication refresh token JSON file, ' 'used for authentication for try jobs, ' 'generally not necessary on developer machines') + parser.add_argument('--credentials-json', + help='A JSON file with an object containing zero or more of the ' + 'following keys: GH_USER, GH_TOKEN') parser.add_argument('--ignore-exportable-commits', action='store_true', help='Continue even if there are exportable commits that may be overwritten.') + return parser.parse_args(argv) def checkout_is_okay(self, allow_local_commits):
diff --git a/third_party/WebKit/Tools/Scripts/wpt-export b/third_party/WebKit/Tools/Scripts/wpt-export index 53e94c4..6a94ac1 100755 --- a/third_party/WebKit/Tools/Scripts/wpt-export +++ b/third_party/WebKit/Tools/Scripts/wpt-export
@@ -19,6 +19,7 @@ from webkitpy.common.host import Host from webkitpy.w3c.test_exporter import TestExporter +from webkitpy.w3c.common import get_credentials _log = logging.getLogger(__name__) @@ -33,47 +34,14 @@ help='See what would be done without actually creating or merging ' 'any pull requests.') parser.add_argument( - '--gh-user', - help='GitHub user name. Can also be provided using the GH_USER ' - 'environment variable.') - parser.add_argument( - '--gh-token', - help='GitHub token or password. Can also be provided using the GH_TOKEN ' - 'environment variable.') - parser.add_argument('--gerrit-user', default=None, - help='Gerrit username (found on settings page or in .gitcookies).') - parser.add_argument('--gerrit-token', default=None, - help='Gerrit API key (found on settings page or in .gitcookies).') - - # TODO(jeffcarp): Remove this after SSHing into wpt-exporter and updating file - parser.add_argument( - '--github-credentials-json', - help='Deprecated. Use --credentials-json.') - - parser.add_argument( '--credentials-json', - help='A JSON file with an object containing zero or more of the following ' - 'keys that can override command line flags: ' + help='A JSON file with an object containing zero or more of the + following keys: ' 'GH_USER, GH_TOKEN, GERRIT_USER, GERRIT_TOKEN') args = parser.parse_args() + host = Host() - credentials = { - 'GH_USER': args.gh_user, - 'GH_TOKEN': args.gh_token, - } - credentials_json = None - - if args.github_credentials_json: - credentials_json = args.github_credentials_json - if args.credentials_json: - credentials_json = args.credentials_json - - if credentials_json: - with open(credentials_json, 'r') as f: - contents = json.load(f) - for key in ('GH_USER', 'GH_TOKEN', 'GERRIT_USER', 'GERRIT_TOKEN'): - if key in contents: - credentials[key] = contents[key] + credentials = get_credentials(host, args) if not (credentials['GH_USER'] and credentials['GH_TOKEN']): parser.error('Must provide both gh_user and gh_token for GitHub.')
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index b5de931..89cb5203 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -1676,7 +1676,7 @@ 'cronet': { 'gn_args': ('disable_file_support=true disable_ftp_support=true ' 'enable_websockets=false use_platform_icu_alternatives=true ' - 'use_partition_alloc=false'), + 'use_partition_alloc=false enable_reporting=false'), }, 'cros_chrome_sdk': {
diff --git a/tools/perf/page_sets/system_health/expectations.py b/tools/perf/page_sets/system_health/expectations.py index fd16b9e6..cf751d5 100644 --- a/tools/perf/page_sets/system_health/expectations.py +++ b/tools/perf/page_sets/system_health/expectations.py
@@ -143,36 +143,11 @@ # Should only include browse:*:* stories. class V8BrowsingDesktopExpecations(expectations.StoryExpectations): def SetExpectations(self): - self.DisableStory('browse:media:imgur', - [expectations.ALL_LINUX, expectations.ALL_WIN], - 'crbug.com/673775') - self.DisableStory('browse:media:pinterest', - [expectations.ALL_LINUX], - 'crbug.com/735173') - self.DisableStory('browse:media:youtube', - [expectations.ALL_LINUX], - 'crbug.com/735173') - self.DisableStory('browse:news:cnn', - [expectations.ALL_DESKTOP], - 'crbug.com/735173') - self.DisableStory('browse:news:flipboard', - [expectations.ALL_DESKTOP], - 'crbug.com/735173') self.DisableStory('browse:news:hackernews', - [expectations.ALL_DESKTOP], - 'crbug.com/735173') - self.DisableStory('browse:news:nytimes', - [expectations.ALL_LINUX, expectations.ALL_WIN], - 'crbug.com/735173') - self.DisableStory('browse:news:reddit', - [expectations.ALL_LINUX, expectations.ALL_WIN], - 'crbug.com/735173') - self.DisableStory('browse:search:google', - [expectations.ALL_LINUX, expectations.ALL_WIN], - 'crbug.com/735173') - self.DisableStory('browse:search:google_india', - [expectations.ALL_LINUX], - 'crbug.com/735173') + [expectations.ALL_WIN, expectations.ALL_MAC], + 'crbug.com/676336') + self.DisableStory('browse:search:google', [expectations.ALL_WIN], + 'crbug.com/673775') self.DisableStory('browse:tools:maps', [expectations.ALL], 'crbug.com/712694') self.DisableStory('browse:tools:earth', [expectations.ALL], @@ -180,12 +155,8 @@ self.DisableStory('browse:tech:discourse_infinite_scroll', [expectations.ALL_WIN, expectations.ALL_LINUX], 'crbug.com/728152') - self.DisableStory('browse:social:facebook_infinite_scroll', - [expectations.ALL_LINUX], - 'crbug.com/735173') - self.DisableStory('browse:social:twitter', - [expectations.ALL_LINUX], - 'crbug.com/735173') + self.DisableStory('browse:news:cnn', + [expectations.ALL_MAC], 'crbug.com/728576') self.DisableStory('browse:social:twitter_infinite_scroll', [expectations.ALL], 'crbug.com/728464') self.DisableStory('browse:media:flickr_infinite_scroll',
diff --git a/ui/arc/notification/arc_notification_content_view.cc b/ui/arc/notification/arc_notification_content_view.cc index 0b465916b..1e0a86d 100644 --- a/ui/arc/notification/arc_notification_content_view.cc +++ b/ui/arc/notification/arc_notification_content_view.cc
@@ -14,21 +14,16 @@ #include "ui/arc/notification/arc_notification_surface.h" #include "ui/arc/notification/arc_notification_view.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/events/event_handler.h" -#include "ui/gfx/animation/linear_animation.h" -#include "ui/gfx/animation/tween.h" #include "ui/gfx/canvas.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/transform.h" #include "ui/message_center/message_center_style.h" +#include "ui/message_center/views/notification_control_buttons_view.h" #include "ui/message_center/views/toast_contents_view.h" #include "ui/strings/grit/ui_strings.h" -#include "ui/views/background.h" #include "ui/views/focus/focus_manager.h" -#include "ui/views/layout/box_layout.h" -#include "ui/views/painter.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget.h" #include "ui/wm/core/window_util.h" @@ -37,10 +32,6 @@ namespace { -// This value should be the same as the duration of reveal animation of -// the settings view of an Android notification. -constexpr int kBackgroundColorChangeDuration = 360; - SkColor GetControlButtonBackgroundColor( const mojom::ArcNotificationShownContents& shown_contents) { if (shown_contents == mojom::ArcNotificationShownContents::CONTENTS_SHOWN) @@ -191,14 +182,14 @@ : owner_(owner) {} bool IsCloseButtonFocused() const override { - if (!owner_->close_button_) + if (!owner_->control_buttons_view_) return false; - return owner_->close_button_->HasFocus(); + return owner_->control_buttons_view_->IsCloseButtonFocused(); } void RequestFocusOnCloseButton() override { - if (owner_->close_button_) - owner_->close_button_->RequestFocus(); + if (owner_->control_buttons_view_) + owner_->control_buttons_view_->RequestFocusOnCloseButton(); owner_->UpdateControlButtonsVisibility(); } @@ -217,28 +208,6 @@ DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); }; -ArcNotificationContentView::ControlButton::ControlButton( - ArcNotificationContentView* owner) - : message_center::PaddedButton(owner), owner_(owner) { - if (owner_->item_) { - SetBackground(views::CreateSolidBackground( - GetControlButtonBackgroundColor(owner_->item_->GetShownContents()))); - } else { - SetBackground(views::CreateSolidBackground( - message_center::kControlButtonBackgroundColor)); - } -} - -void ArcNotificationContentView::ControlButton::OnFocus() { - message_center::PaddedButton::OnFocus(); - owner_->UpdateControlButtonsVisibility(); -} - -void ArcNotificationContentView::ControlButton::OnBlur() { - message_center::PaddedButton::OnBlur(); - owner_->UpdateControlButtonsVisibility(); -} - // static, for ArcNotificationContentView::GetClassName(). const char ArcNotificationContentView::kViewClassName[] = "ArcNotificationContentView"; @@ -291,35 +260,6 @@ this); } -void ArcNotificationContentView::CreateCloseButton() { - DCHECK(control_buttons_view_); - DCHECK(item_); - - close_button_ = base::MakeUnique<ControlButton>(this); - close_button_->SetImage(views::CustomButton::STATE_NORMAL, - message_center::GetCloseIcon()); - close_button_->SetAccessibleName(l10n_util::GetStringUTF16( - IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); - close_button_->SetTooltipText(l10n_util::GetStringUTF16( - IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); - close_button_->set_owned_by_client(); - control_buttons_view_->AddChildView(close_button_.get()); -} - -void ArcNotificationContentView::CreateSettingsButton() { - DCHECK(control_buttons_view_); - DCHECK(item_); - - settings_button_ = new ControlButton(this); - settings_button_->SetImage(views::CustomButton::STATE_NORMAL, - message_center::GetSettingsIcon()); - settings_button_->SetAccessibleName(l10n_util::GetStringUTF16( - IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); - settings_button_->SetTooltipText(l10n_util::GetStringUTF16( - IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); - control_buttons_view_->AddChildView(settings_button_); -} - void ArcNotificationContentView::MaybeCreateFloatingControlButtons() { // Floating close button is a transient child of |surface_| and also part // of the hosting widget's focus chain. It could only be created when both @@ -328,16 +268,24 @@ if (!surface_ || !GetWidget() || !item_) return; + DCHECK(!control_buttons_view_); + DCHECK(!floating_control_buttons_widget_); + + CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName()); + auto* notification_view = static_cast<ArcNotificationView*>(parent()); + // Creates the control_buttons_view_, which collects all control buttons into // a horizontal box. - control_buttons_view_ = new views::View(); - control_buttons_view_->SetLayoutManager( - new views::BoxLayout(views::BoxLayout::kHorizontal)); + control_buttons_view_ = + new message_center::NotificationControlButtonsView(notification_view); + control_buttons_view_->SetPaintToLayer(ui::LAYER_TEXTURED); + control_buttons_view_->layer()->SetFillsBoundsOpaquely(false); - if (item_->IsOpeningSettingsSupported()) - CreateSettingsButton(); - if (!item_->GetPinned()) - CreateCloseButton(); + control_buttons_view_->SetBackgroundColor( + GetControlButtonBackgroundColor(item_->GetShownContents())); + control_buttons_view_->ShowSettingsButton( + item_->IsOpeningSettingsSupported()); + control_buttons_view_->ShowCloseButton(!item_->GetPinned()); views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; @@ -363,8 +311,6 @@ // Reset |floating_control_buttons_widget_| when |surface_| is changed. floating_control_buttons_widget_.reset(); control_buttons_view_ = nullptr; - settings_button_ = nullptr; - close_button_.reset(); if (surface_ && surface_->GetWindow()) { surface_->GetWindow()->RemoveObserver(this); @@ -406,12 +352,15 @@ } void ArcNotificationContentView::UpdateControlButtonsVisibility() { - if (!floating_control_buttons_widget_) + if (!control_buttons_view_) return; + DCHECK(floating_control_buttons_widget_); + const bool target_visiblity = - IsMouseHovered() || (close_button_ && close_button_->HasFocus()) || - (settings_button_ && settings_button_->HasFocus()); + IsMouseHovered() || (control_buttons_view_->IsCloseButtonFocused()) || + (control_buttons_view_->IsSettingsButtonFocused()); + if (target_visiblity == floating_control_buttons_widget_->IsVisible()) return; @@ -429,14 +378,8 @@ if (!control_buttons_view_) return; - if (item_->GetPinned() && close_button_) { - control_buttons_view_->RemoveChildView(close_button_.get()); - close_button_.reset(); - Layout(); - } else if (!item_->GetPinned() && !close_button_) { - CreateCloseButton(); - Layout(); - } + control_buttons_view_->ShowCloseButton(!item_->GetPinned()); + Layout(); } void ArcNotificationContentView::UpdateSnapshot() { @@ -472,30 +415,6 @@ MaybeCreateFloatingControlButtons(); } -void ArcNotificationContentView::StartControlButtonsColorAnimation() { - if (control_button_color_animation_) - control_button_color_animation_->End(); - control_button_color_animation_.reset(new gfx::LinearAnimation(this)); - control_button_color_animation_->SetDuration(kBackgroundColorChangeDuration); - control_button_color_animation_->Start(); -} - -bool ArcNotificationContentView::ShouldUpdateControlButtonsColor() const { - // Don't update the control button color when we are about to be destroyed. - if (!item_) - return false; - - if (settings_button_ && - settings_button_->background()->get_color() != - GetControlButtonBackgroundColor(item_->GetShownContents())) - return true; - if (close_button_ && - close_button_->background()->get_color() != - GetControlButtonBackgroundColor(item_->GetShownContents())) - return true; - return false; -} - void ArcNotificationContentView::UpdateAccessibleName() { // Don't update the accessible name when we are about to be destroyed. if (!item_) @@ -555,27 +474,21 @@ // be positioned without the need to consider the transform. surface_->GetContentWindow()->SetTransform(transform); - if (!floating_control_buttons_widget_) - return; + if (control_buttons_view_) { + DCHECK(floating_control_buttons_widget_); + gfx::Rect control_buttons_bounds(contents_bounds); + int buttons_width = control_buttons_view_->GetPreferredSize().width(); + int buttons_height = control_buttons_view_->GetPreferredSize().height(); - gfx::Rect control_buttons_bounds(contents_bounds); - int buttons_width = 0; - int buttons_height = 0; - if (close_button_) { - buttons_width += close_button_->GetPreferredSize().width(); - buttons_height = close_button_->GetPreferredSize().height(); + control_buttons_bounds.set_x(control_buttons_bounds.right() - + buttons_width - + message_center::kControlButtonPadding); + control_buttons_bounds.set_y(control_buttons_bounds.y() + + message_center::kControlButtonPadding); + control_buttons_bounds.set_width(buttons_width); + control_buttons_bounds.set_height(buttons_height); + floating_control_buttons_widget_->SetBounds(control_buttons_bounds); } - if (settings_button_) { - buttons_width += settings_button_->GetPreferredSize().width(); - buttons_height = settings_button_->GetPreferredSize().height(); - } - control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - - message_center::kControlButtonPadding); - control_buttons_bounds.set_y(control_buttons_bounds.y() + - message_center::kControlButtonPadding); - control_buttons_bounds.set_width(buttons_width); - control_buttons_bounds.set_height(buttons_height); - floating_control_buttons_widget_->SetBounds(control_buttons_bounds); UpdateControlButtonsVisibility(); @@ -656,17 +569,6 @@ node_data->SetName(accessible_name_); } -void ArcNotificationContentView::ButtonPressed(views::Button* sender, - const ui::Event& event) { - if (item_ && !item_->GetPinned() && sender == close_button_.get()) { - CHECK_EQ(ArcNotificationView::kViewClassName, parent()->GetClassName()); - static_cast<ArcNotificationView*>(parent())->OnCloseButtonPressed(); - } - if (item_ && settings_button_ && sender == settings_button_) { - item_->OpenSettings(); - } -} - void ArcNotificationContentView::OnWindowBoundsChanged( aura::Window* window, const gfx::Rect& old_bounds, @@ -695,8 +597,11 @@ UpdateAccessibleName(); UpdatePinnedState(); UpdateSnapshot(); - if (ShouldUpdateControlButtonsColor()) - StartControlButtonsColorAnimation(); + if (control_buttons_view_) { + DCHECK(floating_control_buttons_widget_); + control_buttons_view_->SetBackgroundColor( + GetControlButtonBackgroundColor(item_->GetShownContents())); + } } void ArcNotificationContentView::OnNotificationSurfaceAdded( @@ -715,35 +620,4 @@ SetSurface(nullptr); } -void ArcNotificationContentView::AnimationEnded( - const gfx::Animation* animation) { - DCHECK_EQ(animation, control_button_color_animation_.get()); - control_button_color_animation_.reset(); -} - -void ArcNotificationContentView::AnimationProgressed( - const gfx::Animation* animation) { - DCHECK_EQ(animation, control_button_color_animation_.get()); - - if (item_) { - const SkColor target = - GetControlButtonBackgroundColor(item_->GetShownContents()); - const SkColor start = - target == message_center::kControlButtonBackgroundColor - ? SK_ColorTRANSPARENT - : message_center::kControlButtonBackgroundColor; - const SkColor current_color = gfx::Tween::ColorValueBetween( - animation->GetCurrentValue(), start, target); - if (settings_button_) { - settings_button_->SetBackground( - views::CreateSolidBackground(current_color)); - settings_button_->SchedulePaint(); - } - if (close_button_) { - close_button_->SetBackground(views::CreateSolidBackground(current_color)); - close_button_->SchedulePaint(); - } - } -} - } // namespace arc
diff --git a/ui/arc/notification/arc_notification_content_view.h b/ui/arc/notification/arc_notification_content_view.h index 324f5d4..2d9ef0ad 100644 --- a/ui/arc/notification/arc_notification_content_view.h +++ b/ui/arc/notification/arc_notification_content_view.h
@@ -13,13 +13,10 @@ #include "ui/arc/notification/arc_notification_item.h" #include "ui/arc/notification/arc_notification_surface_manager.h" #include "ui/aura/window_observer.h" -#include "ui/gfx/animation/animation_delegate.h" -#include "ui/message_center/views/padded_button.h" -#include "ui/views/controls/button/button.h" #include "ui/views/controls/native/native_view_host.h" -namespace gfx { -class LinearAnimation; +namespace message_center { +class NotificationControlButtonsView; } namespace ui { @@ -39,11 +36,9 @@ // content in itself. This is implemented as a child of ArcNotificationView. class ArcNotificationContentView : public views::NativeViewHost, - public views::ButtonListener, public aura::WindowObserver, public ArcNotificationItem::Observer, - public ArcNotificationSurfaceManager::Observer, - public gfx::AnimationDelegate { + public ArcNotificationSurfaceManager::Observer { public: static const char kViewClassName[]; @@ -64,21 +59,6 @@ class SettingsButton; class SlideHelper; - // A image button class used for the settings button and the close button. - // We can't use forward declaration for this class due to std::unique_ptr<> - // requires size of this class. - class ControlButton : public message_center::PaddedButton { - public: - explicit ControlButton(ArcNotificationContentView* owner); - void OnFocus() override; - void OnBlur() override; - - private: - ArcNotificationContentView* const owner_; - - DISALLOW_COPY_AND_ASSIGN(ControlButton); - }; - void CreateCloseButton(); void CreateSettingsButton(); void MaybeCreateFloatingControlButtons(); @@ -89,8 +69,6 @@ void UpdateSnapshot(); void AttachSurface(); void ActivateToast(); - void StartControlButtonsColorAnimation(); - bool ShouldUpdateControlButtonsColor() const; void UpdateAccessibleName(); // views::NativeViewHost @@ -106,9 +84,6 @@ bool HandleAccessibleAction(const ui::AXActionData& action) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override; - // views::ButtonListener - void ButtonPressed(views::Button* sender, const ui::Event& event) override; - // aura::WindowObserver void OnWindowBoundsChanged(aura::Window* window, const gfx::Rect& old_bounds, @@ -123,10 +98,6 @@ void OnNotificationSurfaceAdded(ArcNotificationSurface* surface) override; void OnNotificationSurfaceRemoved(ArcNotificationSurface* surface) override; - // AnimationDelegate - void AnimationEnded(const gfx::Animation* animation) override; - void AnimationProgressed(const gfx::Animation* animation) override; - // If |item_| is null, we may be about to be destroyed. In this case, // we have to be careful about what we do. ArcNotificationItem* item_ = nullptr; @@ -151,15 +122,12 @@ // it. std::unique_ptr<views::Widget> floating_control_buttons_widget_; - views::View* control_buttons_view_ = nullptr; - std::unique_ptr<ControlButton> close_button_; - ControlButton* settings_button_ = nullptr; + message_center::NotificationControlButtonsView* control_buttons_view_ = + nullptr; // Protects from call loops between Layout and OnWindowBoundsChanged. bool in_layout_ = false; - std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_; - base::string16 accessible_name_; DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView);
diff --git a/ui/arc/notification/arc_notification_content_view_unittest.cc b/ui/arc/notification/arc_notification_content_view_unittest.cc index 1ef1e28f..6caeba3 100644 --- a/ui/arc/notification/arc_notification_content_view_unittest.cc +++ b/ui/arc/notification/arc_notification_content_view_unittest.cc
@@ -19,7 +19,8 @@ #include "ui/message_center/notification.h" #include "ui/message_center/views/message_center_controller.h" #include "ui/message_center/views/message_view_factory.h" -#include "ui/views/controls/button/image_button.h" +#include "ui/message_center/views/notification_control_buttons_view.h" +#include "ui/message_center/views/padded_button.h" #include "ui/views/test/views_test_base.h" namespace arc { @@ -241,10 +242,12 @@ void PressCloseButton() { DummyEvent dummy_event; - views::ImageButton* close_button = - GetArcNotificationContentView()->close_button_.get(); + auto* control_buttons_view = + GetArcNotificationContentView()->control_buttons_view_; + message_center::PaddedButton* close_button = + control_buttons_view->close_button_for_testing(); ASSERT_NE(nullptr, close_button); - GetArcNotificationContentView()->ButtonPressed(close_button, dummy_event); + control_buttons_view->ButtonPressed(close_button, dummy_event); } void CreateAndShowNotificationView(
diff --git a/ui/arc/notification/arc_notification_delegate.cc b/ui/arc/notification/arc_notification_delegate.cc index 8035e61..fae1302 100644 --- a/ui/arc/notification/arc_notification_delegate.cc +++ b/ui/arc/notification/arc_notification_delegate.cc
@@ -45,4 +45,10 @@ item_->Click(); } +bool ArcNotificationDelegate::SettingsClick() { + DCHECK(item_); + item_->OpenSettings(); + return true; +} + } // namespace arc
diff --git a/ui/arc/notification/arc_notification_delegate.h b/ui/arc/notification/arc_notification_delegate.h index d992273..9241fcec 100644 --- a/ui/arc/notification/arc_notification_delegate.h +++ b/ui/arc/notification/arc_notification_delegate.h
@@ -32,6 +32,7 @@ const message_center::Notification& notification) override; void Close(bool by_user) override; void Click() override; + bool SettingsClick() override; private: // The destructor is private since this class is ref-counted.
diff --git a/ui/message_center/BUILD.gn b/ui/message_center/BUILD.gn index 161038a..377026c 100644 --- a/ui/message_center/BUILD.gn +++ b/ui/message_center/BUILD.gn
@@ -143,6 +143,8 @@ "views/message_view_factory.h", "views/notification_button.cc", "views/notification_button.h", + "views/notification_control_buttons_view.cc", + "views/notification_control_buttons_view.h", "views/notification_header_view.cc", "views/notification_header_view.h", "views/notification_view.cc",
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc index ed06b3f..340d9bc 100644 --- a/ui/message_center/views/message_view.cc +++ b/ui/message_center/views/message_view.cc
@@ -235,6 +235,10 @@ controller_->RemoveNotification(notification_id_, true); // By user. } +void MessageView::OnSettingsButtonPressed() { + controller_->ClickOnSettingsButton(notification_id_); +} + void MessageView::SetDrawBackgroundAsActive(bool active) { background_view_->background()-> SetNativeControlColor(active ? kHoveredButtonBackgroundColor :
diff --git a/ui/message_center/views/message_view.h b/ui/message_center/views/message_view.h index b55a934..61ddf740 100644 --- a/ui/message_center/views/message_view.h +++ b/ui/message_center/views/message_view.h
@@ -60,6 +60,7 @@ virtual void UpdateControlButtonsVisibility() = 0; void OnCloseButtonPressed(); + void OnSettingsButtonPressed(); // views::View void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
diff --git a/ui/message_center/views/notification_control_buttons_view.cc b/ui/message_center/views/notification_control_buttons_view.cc new file mode 100644 index 0000000..5d71a10 --- /dev/null +++ b/ui/message_center/views/notification_control_buttons_view.cc
@@ -0,0 +1,156 @@ +// Copyright 2017 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 "ui/message_center/views/notification_control_buttons_view.h" + +#include "ui/base/l10n/l10n_util.h" +#include "ui/compositor/layer.h" +#include "ui/events/event.h" +#include "ui/gfx/animation/linear_animation.h" +#include "ui/message_center/message_center_style.h" +#include "ui/message_center/views/message_view.h" +#include "ui/message_center/views/padded_button.h" +#include "ui/strings/grit/ui_strings.h" +#include "ui/views/background.h" +#include "ui/views/layout/box_layout.h" + +namespace { + +// This value should be the same as the duration of reveal animation of +// the settings view of an Android notification. +constexpr int kBackgroundColorChangeDuration = 360; + +// The initial background color of the view. +constexpr SkColor kInitialBackgroundColor = + message_center::kControlButtonBackgroundColor; + +} // anonymous namespace + +namespace message_center { + +const char NotificationControlButtonsView::kViewClassName[] = + "NotificationControlButtonsView"; + +NotificationControlButtonsView::NotificationControlButtonsView( + MessageView* message_view) + : message_view_(message_view), + bgcolor_origin_(kInitialBackgroundColor), + bgcolor_target_(kInitialBackgroundColor) { + DCHECK(message_view); + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal)); + SetBackground(views::CreateSolidBackground(kInitialBackgroundColor)); +} + +NotificationControlButtonsView::~NotificationControlButtonsView() = default; + +void NotificationControlButtonsView::ShowCloseButton(bool show) { + if (show && !close_button_) { + close_button_ = new message_center::PaddedButton(this); + close_button_->SetImage(views::CustomButton::STATE_NORMAL, + message_center::GetCloseIcon()); + close_button_->SetAccessibleName(l10n_util::GetStringUTF16( + IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); + close_button_->SetTooltipText(l10n_util::GetStringUTF16( + IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP)); + close_button_->SetBackground( + views::CreateSolidBackground(SK_ColorTRANSPARENT)); + + // Add the button at the last. + DCHECK_LE(child_count(), 1); + AddChildView(close_button_); + } else if (!show && close_button_) { + RemoveChildView(close_button_); + close_button_ = nullptr; + } +} + +void NotificationControlButtonsView::ShowSettingsButton(bool show) { + if (show && !settings_button_) { + settings_button_ = new message_center::PaddedButton(this); + settings_button_->SetImage(views::CustomButton::STATE_NORMAL, + message_center::GetSettingsIcon()); + settings_button_->SetAccessibleName(l10n_util::GetStringUTF16( + IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); + settings_button_->SetTooltipText(l10n_util::GetStringUTF16( + IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); + settings_button_->SetBackground( + views::CreateSolidBackground(SK_ColorTRANSPARENT)); + + // Add the button at the first. + DCHECK_LE(child_count(), 1); + AddChildViewAt(settings_button_, 0); + } else if (!show && close_button_) { + RemoveChildView(settings_button_); + settings_button_ = nullptr; + } +} + +void NotificationControlButtonsView::SetBackgroundColor( + const SkColor& target_bgcolor) { + if (background()->get_color() != target_bgcolor) { + bgcolor_origin_ = background()->get_color(); + bgcolor_target_ = target_bgcolor; + + if (bgcolor_animation_) + bgcolor_animation_->End(); + bgcolor_animation_.reset(new gfx::LinearAnimation(this)); + bgcolor_animation_->SetDuration(kBackgroundColorChangeDuration); + bgcolor_animation_->Start(); + } +} + +void NotificationControlButtonsView::RequestFocusOnCloseButton() { + if (close_button_) + close_button_->RequestFocus(); +} + +bool NotificationControlButtonsView::IsCloseButtonFocused() const { + return close_button_ && close_button_->HasFocus(); +} + +bool NotificationControlButtonsView::IsSettingsButtonFocused() const { + return settings_button_ && settings_button_->HasFocus(); +} + +const char* NotificationControlButtonsView::GetClassName() const { + return kViewClassName; +} + +void NotificationControlButtonsView::ButtonPressed(views::Button* sender, + const ui::Event& event) { + if (close_button_ && sender == close_button_) { + message_view_->OnCloseButtonPressed(); + } else if (settings_button_ && sender == settings_button_) { + message_view_->OnSettingsButtonPressed(); + } +} + +void NotificationControlButtonsView::AnimationProgressed( + const gfx::Animation* animation) { + DCHECK_EQ(animation, bgcolor_animation_.get()); + + const SkColor color = gfx::Tween::ColorValueBetween( + animation->GetCurrentValue(), bgcolor_origin_, bgcolor_target_); + SetBackground(views::CreateSolidBackground(color)); + SchedulePaint(); +} + +void NotificationControlButtonsView::AnimationEnded( + const gfx::Animation* animation) { + DCHECK_EQ(animation, bgcolor_animation_.get()); + bgcolor_animation_.reset(); + bgcolor_origin_ = bgcolor_target_; +} + +void NotificationControlButtonsView::AnimationCanceled( + const gfx::Animation* animation) { + // The animation is never cancelled explicitly. + NOTREACHED(); + + bgcolor_origin_ = bgcolor_target_; + SetBackground(views::CreateSolidBackground(bgcolor_target_)); + SchedulePaint(); +} + +} // namespace message_center
diff --git a/ui/message_center/views/notification_control_buttons_view.h b/ui/message_center/views/notification_control_buttons_view.h new file mode 100644 index 0000000..ee9faab --- /dev/null +++ b/ui/message_center/views/notification_control_buttons_view.h
@@ -0,0 +1,85 @@ +// Copyright 2017 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 "base/macros.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/gfx/animation/animation_delegate.h" +#include "ui/message_center/message_center_export.h" +#include "ui/views/controls/button/button.h" +#include "ui/views/view.h" + +namespace ui { +class Event; +} + +namespace gfx { +class LinearAnimation; +} + +namespace message_center { + +class MessageView; +class PaddedButton; + +class MESSAGE_CENTER_EXPORT NotificationControlButtonsView + : public views::View, + public views::ButtonListener, + public gfx::AnimationDelegate { + public: + // String to be returned by GetClassName() method. + static const char kViewClassName[]; + + explicit NotificationControlButtonsView(MessageView* message_view); + ~NotificationControlButtonsView() override; + + // Change the visibility of the close button. True to show, false to hide. + void ShowCloseButton(bool show); + // Change the visibility of the settings button. True to show, false to hide. + void ShowSettingsButton(bool show); + + // Set the background color of the view. + void SetBackgroundColor(const SkColor& target_bgcolor); + + // Request the focus on the close button. + void RequestFocusOnCloseButton(); + + // Return the focus status of the close button. True if the focus is on the + // close button, false otherwise. + bool IsCloseButtonFocused() const; + // Return the focus status of the settings button. True if the focus is on the + // close button, false otherwise. + bool IsSettingsButtonFocused() const; + + message_center::PaddedButton* close_button_for_testing() const { + return close_button_; + } + message_center::PaddedButton* settings_button_for_testing() const { + return settings_button_; + } + + // views::View + const char* GetClassName() const override; + + // views::ButtonListener + void ButtonPressed(views::Button* sender, const ui::Event& event) override; + + // gfx::AnimationDelegate + void AnimationEnded(const gfx::Animation* animation) override; + void AnimationProgressed(const gfx::Animation* animation) override; + void AnimationCanceled(const gfx::Animation* animation) override; + + private: + MessageView* message_view_; + + message_center::PaddedButton* close_button_ = nullptr; + message_center::PaddedButton* settings_button_ = nullptr; + + std::unique_ptr<gfx::LinearAnimation> bgcolor_animation_; + SkColor bgcolor_origin_; + SkColor bgcolor_target_; + + DISALLOW_COPY_AND_ASSIGN(NotificationControlButtonsView); +}; + +} // namespace message_center
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc index 029eeef7..0b15a6a 100644 --- a/ui/message_center/views/notification_view.cc +++ b/ui/message_center/views/notification_view.cc
@@ -388,7 +388,7 @@ } if (sender == settings_button_view_) { - controller()->ClickOnSettingsButton(id); + OnSettingsButtonPressed(); return; }