diff --git a/DEPS b/DEPS index 51ecb09..30e40ade 100644 --- a/DEPS +++ b/DEPS
@@ -79,11 +79,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': '67f62b1a61016ad07b44ae5a0bbf79d97adc9ba9', + 'skia_revision': 'c25e2693ab00cfe7691b68b7d47f2159640d783a', # 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': '10c5b8fc3b4b29a50d79ffba9b9ed0bc72bdc782', + 'v8_revision': '21cb7e30e4995fe0602963da903bdc84de78a82a', # 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. @@ -91,7 +91,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '203d6365c567f33ebf2c26b8580dd0a5905c4bd1', + 'angle_revision': '64e5ed2abd8a4cc77d3647e4b245db57a8c42ae5', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling build tools # and whatever else without interference from each other. @@ -135,7 +135,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '6eaec901b9866f7831296a6047a1ce2f8db020eb', + 'catapult_revision': 'c6434b02c577499932bf7ec31a9d6872c481dca2', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -316,7 +316,7 @@ # Build tools for Chrome OS. Note: This depends on third_party/pyelftools. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '7ed5549cfa7b9f147049a16eb0e9b23d50ebba03', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '3b75c9d82ebf1fc38f6bba91156e626bf9cfae46', 'condition': 'checkout_linux', }, @@ -341,7 +341,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '44048672dcd7f444eec5449388078ffd43e397a7', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'f4c2703a6dedd8aed2d00fd7b57a6adf579271d9', 'src/third_party/devtools-node-modules': Var('chromium_git') + '/external/github.com/ChromeDevTools/devtools-node-modules' + '@' + Var('devtools_node_modules_revision'), @@ -657,7 +657,7 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '3c1cb0203b6cfc10389e85a350b2ea6ca29d01ce', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '3e77afd0d29bdfcd0e522ebcc46f160d38538fa2', # commit position 21742 + Var('webrtc_git') + '/src.git' + '@' + '207a75d8f3fae1dc47aa20dda0636e88f6b8d2b3', # commit position 21742 'src/third_party/xdg-utils': { 'url': Var('chromium_git') + '/chromium/deps/xdg-utils.git' + '@' + 'd80274d5869b17b8c9067a1022e4416ee7ed5e0d',
diff --git a/ash/app_list/app_list_presenter_delegate.cc b/ash/app_list/app_list_presenter_delegate.cc index 2b2285e..f10d1b5 100644 --- a/ash/app_list/app_list_presenter_delegate.cc +++ b/ash/app_list/app_list_presenter_delegate.cc
@@ -196,7 +196,7 @@ } aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); - if (!window->Contains(target) && + if (!window->Contains(target) && !presenter_->Back() && !app_list::switches::ShouldNotDismissOnBlur()) { presenter_->Dismiss(); }
diff --git a/ash/app_list/app_list_presenter_delegate_unittest.cc b/ash/app_list/app_list_presenter_delegate_unittest.cc index fff53ea..10bbd2c 100644 --- a/ash/app_list/app_list_presenter_delegate_unittest.cc +++ b/ash/app_list/app_list_presenter_delegate_unittest.cc
@@ -719,7 +719,8 @@ GetAppListTestHelper()->CheckVisibility(false); } -// Tests that the half app list closes if the user taps outside its bounds. +// Tests that the half app list transitions to peeking state and then closes +// itself if the user taps outside its bounds. TEST_P(AppListPresenterDelegateTest, TapAndClickOutsideClosesHalfAppList) { // TODO(newcomer): Investigate mash failures crbug.com/726838 GetAppListTestHelper()->ShowAndRunLoop(GetPrimaryDisplayId()); @@ -730,12 +731,26 @@ GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckState(app_list::AppListViewState::HALF); - // Clicking/tapping outside the bounds closes the app list. + // A point outside the bounds of launcher. + gfx::Point to_point( + 0, GetAppListView()->GetWidget()->GetWindowBoundsInScreen().y() - 1); + + // Clicking/tapping outside the bounds closes the search results page. if (TestMouseEventParam()) { - generator.MoveMouseTo(gfx::Point(10, 10)); + generator.MoveMouseTo(to_point); generator.ClickLeftButton(); } else { - generator.GestureTapAt(gfx::Point(10, 10)); + generator.GestureTapAt(to_point); + } + GetAppListTestHelper()->WaitUntilIdle(); + GetAppListTestHelper()->CheckState(app_list::AppListViewState::PEEKING); + + // Clicking/tapping outside the bounds closes the app list. + if (TestMouseEventParam()) { + generator.MoveMouseTo(to_point); + generator.ClickLeftButton(); + } else { + generator.GestureTapAt(to_point); } GetAppListTestHelper()->WaitUntilIdle(); GetAppListTestHelper()->CheckVisibility(false);
diff --git a/ash/app_list/app_list_presenter_impl.cc b/ash/app_list/app_list_presenter_impl.cc index 4bb1d0a3..587d601 100644 --- a/ash/app_list/app_list_presenter_impl.cc +++ b/ash/app_list/app_list_presenter_impl.cc
@@ -16,7 +16,9 @@ #include "ui/app_list/app_list_switches.h" #include "ui/app_list/app_list_view_delegate.h" #include "ui/app_list/pagination_model.h" +#include "ui/app_list/views/app_list_main_view.h" #include "ui/app_list/views/app_list_view.h" +#include "ui/app_list/views/contents_view.h" #include "ui/aura/client/focus_client.h" #include "ui/aura/window.h" #include "ui/compositor/layer.h" @@ -126,6 +128,16 @@ base::RecordAction(base::UserMetricsAction("Launcher_Dismiss")); } +bool AppListPresenterImpl::Back() { + if (!is_visible_) + return false; + + // If the app list is currently visible, there should be an existing view. + DCHECK(view_); + + return view_->app_list_main_view()->contents_view()->Back(); +} + void AppListPresenterImpl::ToggleAppList(int64_t display_id) { if (IsVisible()) { Dismiss();
diff --git a/ash/app_list/app_list_presenter_impl.h b/ash/app_list/app_list_presenter_impl.h index c927535..78bfcc2 100644 --- a/ash/app_list/app_list_presenter_impl.h +++ b/ash/app_list/app_list_presenter_impl.h
@@ -68,6 +68,10 @@ // Hide the open app list window. This may leave the view open but hidden. void Dismiss(); + // Performs the 'back' action for the active page. Returns whether the action + // was handled. + bool Back(); + // Show the app list if it is visible, hide it if it is hidden. void ToggleAppList(int64_t display_id);
diff --git a/build/android/gyp/extract_unwind_tables.py b/build/android/gyp/extract_unwind_tables.py new file mode 100755 index 0000000..de8daccc --- /dev/null +++ b/build/android/gyp/extract_unwind_tables.py
@@ -0,0 +1,190 @@ +#!/usr/bin/env python +# Copyright 2018 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. + +"""Extracts the unwind tables in from breakpad symbol files + +Runs dump_syms on the given binary file and extracts the CFI data into the +given output file. +The output file is a binary file containing CFI rows ordered based on function +address. The output file only contains rows that match the most popular rule +type in CFI table, to reduce the output size and specify data in compact format. +See doc https://github.com/google/breakpad/blob/master/docs/symbol_files.md. +1. The CFA rules should be of postfix form "SP <val> +". +2. The RA rules should be of postfix form "CFA <val> + ^". +Note: breakpad represents dereferencing address with '^' operator. + +The output rows are all 64 bits. We have 2 types of rows, FUNCTION and CFI. +Each function with CFI info has a single FUNCTION row, followed by one or more +CFI rows. All the addresses of the CFI rows will be within the function. +1. FUNCTION. Bits in order of high to low represent: + 31 bits: specifies function address, without the last bit (always 0). + 1 bit : always 1. Specifies the row type is FUNCTION. + 32 bits: length of the current function. + +2. CFI. Bits in order of high to low represent: + 31 bits: instruction address in the current function. + 1 bit : always 0. Specifies teh row type is CFI. + 30 bits: CFA offset / 4. + 2 bits: RA offset / 4. + +Usage: + extract_unwind_tables.py --input_path [root path to unstripped chrome.so] + --output_path [output path] --dump_syms_path [path to dump_syms binary] +""" + +import argparse +import re +import struct +import subprocess +import sys +import tempfile + + +_CFA_REG = '.cfa' +_RA_REG = '.ra' + +_ADDR_ENTRY = 0 +_LENGTH_ENTRY = 1 + + +def _Write4Bytes(output_file, val): + """Writes a 32 bit unsigned integer to the given output file.""" + output_file.write(struct.pack('<L', val)); + + +def _FindRuleForRegister(cfi_row, reg): + """Returns the postfix expression as string for a given register. + + Breakpad CFI row format specifies rules for unwinding each register in postfix + expression form separated by space. Each rule starts with register name and a + colon. Eg: "CFI R1: <rule> R2: <rule>". + """ + out = [] + found_register = False + for part in cfi_row: + if found_register: + if part[-1] == ':': + break + out.append(part) + elif part == reg + ':': + found_register = True + return ' '.join(out) + + +def _GetCfaAndRaOffset(cfi_row): + """Returns a tuple with 2 numbers (cfa_offset, ra_offset). + + Returns right values if rule matches the predefined criteria. Returns (0, 0) + otherwise. The criteria for CFA rule is postfix form "SP <val> +" and RA rule + is postfix form "CFA -<val> + ^". + """ + cfa_offset = 0 + ra_offset = 0 + cfa_rule = _FindRuleForRegister(cfi_row, _CFA_REG) + ra_rule = _FindRuleForRegister(cfi_row, _RA_REG) + if cfa_rule and re.match(r'sp [0-9]+ \+', cfa_rule): + cfa_offset = int(cfa_rule.split()[1], 10) + if ra_rule: + if not re.match(r'.cfa -[0-9]+ \+ \^', ra_rule): + return (0, 0) + ra_offset = -1 * int(ra_rule.split()[1], 10) + return (cfa_offset, ra_offset) + + +def _GetAllCfiRows(symbol_file): + """Returns parsed CFI data from given symbol_file. + + Each entry in the cfi data dictionary returned is a map from function start + address to array of function rows, starting with FUNCTION type, followed by + one or more CFI rows. + """ + cfi_data = {} + current_func = [] + for line in symbol_file: + if 'STACK CFI' not in line: + continue + + parts = line.split() + data = {} + if parts[2] == 'INIT': + # Add the previous function to the output + if len(current_func) > 1: + cfi_data[current_func[0][_ADDR_ENTRY]] = current_func + current_func = [] + + # The function line is of format "STACK CFI INIT <addr> <length> ..." + data[_ADDR_ENTRY] = int(parts[3], 16) + data[_LENGTH_ENTRY] = int(parts[4], 16) + if data[_LENGTH_ENTRY] == 0: + continue # Skip the current function. + else: + # The current function is skipped. + if len(current_func) == 0: + continue + + # The CFI row is of format "STACK CFI <addr> .cfa: <expr> .ra: <expr> ..." + data[_ADDR_ENTRY] = int(parts[2], 16) + (data[_CFA_REG], data[_RA_REG]) = _GetCfaAndRaOffset(parts) + if (data[_CFA_REG]) == 0 or data[_RA_REG] >= 16: + current_func = [] + continue + assert data[_CFA_REG] % 4 == 0 + + if data[_ADDR_ENTRY] == 0: + # Skip current function, delete all previous entries. + current_func = [] + continue + assert data[_ADDR_ENTRY] % 2 == 0 + current_func.append(data) + + if len(current_func) > 1: + cfi_data[current_func[0][_ADDR_ENTRY]] = current_func + return cfi_data + + +def _WriteCfiData(cfi_data, out_file): + """Writes the CFI data in defined format to out_file.""" + for addr, function in sorted(cfi_data.iteritems()): + assert len(function) > 1 + _Write4Bytes(out_file, addr | 1) + _Write4Bytes(out_file, function[0][_LENGTH_ENTRY]) + for row in function[1:]: + _Write4Bytes(out_file, row[_ADDR_ENTRY]) + _Write4Bytes(out_file, (row[_CFA_REG]) | (row[_RA_REG] / 4)) + + +def _ParseCfiData(sym_file, output_path): + with open(sym_file, 'r') as f: + cfi_data = _GetAllCfiRows(f) + + with open(output_path, 'wb') as out_file: + _WriteCfiData(cfi_data, out_file) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--input_path', required=True, + help='The input path of the unstripped binary') + parser.add_argument( + '--output_path', required=True, + help='The path of the output file') + parser.add_argument( + '--dump_syms_path', required=True, + help='The path of the dump_syms binary') + + args = parser.parse_args() + + sym_file = tempfile.NamedTemporaryFile() + with tempfile.NamedTemporaryFile() as sym_file: + out = subprocess.call( + ['./' +args.dump_syms_path, args.input_path], stdout=sym_file) + assert not out + sym_file.flush() + _ParseCfiData(sym_file.name, args.output_path) + return 0 + +if __name__ == '__main__': + sys.exit(main())
diff --git a/build/android/gyp/extract_unwind_tables_tests.py b/build/android/gyp/extract_unwind_tables_tests.py new file mode 100755 index 0000000..60e04c4 --- /dev/null +++ b/build/android/gyp/extract_unwind_tables_tests.py
@@ -0,0 +1,90 @@ +#!/usr/bin/env python +# Copyright 2018 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. + +"""Tests for extract_unwind_tables.py + +This test suite contains various tests for extracting CFI tables from breakpad +symbol files. +""" + +import optparse +import os +import struct +import sys +import tempfile +import unittest + +import extract_unwind_tables + +sys.path.append(os.path.join(os.path.dirname(__file__), "gyp")) +from util import build_utils + + +class TestExtractUnwindTables(unittest.TestCase): + def testExtractCfi(self): + with tempfile.NamedTemporaryFile() as input_file, \ + tempfile.NamedTemporaryFile() as output_file: + input_file.write(""" +MODULE Linux arm CDE12FE1DF2B37A9C6560B4CBEE056420 lib_chrome.so +INFO CODE_ID E12FE1CD2BDFA937C6560B4CBEE05642 +FILE 0 ../../base/allocator/allocator_check.cc +FILE 1 ../../base/allocator/allocator_extension.cc +FILE 2 ../../base/allocator/allocator_shim.cc +FUNC 1adcb60 54 0 i2d_name_canon +1adcb60 1a 509 17054 +3b94c70 2 69 40 +PUBLIC e17001 0 assist_ranker::(anonymous namespace)::FakePredict::Initialize() +PUBLIC e17005 0 (anonymous namespace)::FileDeleter(base::File) +STACK CFI INIT e17000 4 .cfa: sp 0 + .ra: lr +STACK CFI INIT 0 4 .cfa: sp 0 + .ra: lr +STACK CFI 2 .cfa: sp 4 + +STACK CFI 4 .cfa: sp 12 + .ra: .cfa -8 + ^ r7: .cfa -12 + ^ +STACK CFI 6 .cfa: sp 16 + +STACK CFI INIT e1a96e 20 .cfa: sp 0 + .ra: lr +STACK CFI e1a970 .cfa: sp 4 + +STACK CFI e1a972 .cfa: sp 12 + .ra: .cfa -8 + ^ r7: .cfa -12 + ^ +STACK CFI e1a974 .cfa: sp 16 + +STACK CFI INIT e1a1e4 b0 .cfa: sp 0 + .ra: lr +STACK CFI e1a1e6 .cfa: sp 16 + .ra: .cfa -4 + ^ r4: .cfa -16 + ^ r5: .cfa -12 + +STACK CFI e1a1e8 .cfa: sp 80 + +STACK CFI INIT 0 4 .cfa: sp 0 + .ra: lr +STACK CFI INIT 3b92e24 3c .cfa: sp 0 + .ra: lr +STACK CFI 3b92e4c .cfa: sp 16 + .ra: .cfa -12 + ^ +STACK CFI INIT e17004 0 .cfa: sp 0 + .ra: lr +STACK CFI e17004 2 .cfa: sp 0 + .ra: lr +STACK CFI INIT 3b92e70 38 .cfa: sp 0 + .ra: lr +STACK CFI 3b92e74 .cfa: sp 8 + .ra: .cfa -4 + ^ r4: .cfa -8 + ^ +STACK CFI 3b92e90 .cfa: sp 0 + .ra: .ra r4: r4 +STACK CFI INIT 3b93114 6c .cfa: sp 0 + .ra: lr +STACK CFI 3b93118 .cfa: r7 16 + .ra: .cfa -4 + ^ +""") + input_file.flush() + extract_unwind_tables._ParseCfiData(input_file.name, output_file.name) + + expected_output_rows = [ + 0xe1a1e4 | 1, 0xb0, + 0xe1a1e6 , 16 + 4 / 4, + 0xe1a1e8 , 80 + 0, + + 0xe1a96e | 1, 0x20, + 0xe1a970 , 4 + 0, + 0xe1a972 , 12 + 8 / 4, + 0xe1a974 , 16 + 0, + + 0x3b92e24 | 1, 0x3c, + 0x3b92e4c , 16 + 12 / 4 + ] + actual_output = [] + with open(output_file.name, 'rb') as f: + while True: + read = f.read(4) + if not read: + break + actual_output.append(struct.unpack('i', read)[0]) + self.assertEqual(expected_output_rows, actual_output) + + +if __name__ == '__main__': + unittest.main()
diff --git a/build/android/pylib/constants/__init__.py b/build/android/pylib/constants/__init__.py index f100211b..f3aa4ec3 100644 --- a/build/android/pylib/constants/__init__.py +++ b/build/android/pylib/constants/__init__.py
@@ -141,6 +141,7 @@ 'test_modules': [ 'java_cpp_enum_tests', 'java_google_api_keys_tests', + 'extract_unwind_tables_tests', ] }, }
diff --git a/build/config/allocator.gni b/build/config/allocator.gni index 92a2f341..03892a888 100644 --- a/build/config/allocator.gni +++ b/build/config/allocator.gni
@@ -5,9 +5,9 @@ import("//build/config/sanitizers/sanitizers.gni") # Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors. -if (is_android || current_cpu == "mipsel" || is_mac || is_ios || - is_asan || is_lsan || is_tsan || is_msan || is_win || is_syzyasan || - is_fuchsia || (is_linux && target_cpu == "arm64")) { +if (is_android || is_mac || is_ios || is_asan || is_lsan || is_tsan || + is_msan || is_win || is_syzyasan || is_fuchsia || + (is_linux && target_cpu == "arm64")) { _default_allocator = "none" } else { _default_allocator = "tcmalloc"
diff --git a/build/config/android/extract_unwind_tables.gni b/build/config/android/extract_unwind_tables.gni new file mode 100644 index 0000000..c3d5d2b --- /dev/null +++ b/build/config/android/extract_unwind_tables.gni
@@ -0,0 +1,45 @@ +# Copyright 2018 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("//build/config/android/rules.gni") + +template("unwind_table_asset") { + _unwind_action = "${target_name}__extract" + _asset_path = "${target_gen_dir}/${target_name}/unwind_cfi" + action(_unwind_action) { + if (defined(invoker.testonly)) { + testonly = invoker.testonly + } + script = "//build/android/gyp/extract_unwind_tables.py" + outputs = [ + _asset_path, + ] + args = [ + "--input_path", + rebase_path( + "$root_out_dir/lib.unstripped/$shlib_prefix${invoker.library_target}$shlib_extension", + root_build_dir), + "--output_path", + rebase_path(_asset_path, root_build_dir), + "--dump_syms_path", + rebase_path("$root_out_dir/dump_syms", root_build_dir), + ] + deps = [ + ":${invoker.library_target}", + "//third_party/breakpad:dump_syms", + ] + } + android_assets(target_name) { + if (defined(invoker.testonly)) { + testonly = invoker.testonly + } + sources = [ + _asset_path, + ] + disable_compression = true + deps = [ + ":$_unwind_action", + ] + } +}
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni index c06c164..c9b987b 100644 --- a/build/config/android/rules.gni +++ b/build/config/android/rules.gni
@@ -2830,7 +2830,6 @@ android_apk(target_name) { data_deps = [] - deps = [] forward_variables_from(invoker, "*") testonly = true create_apk_script = false
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java b/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java index 381b7b6..796a90ab 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java
@@ -360,6 +360,23 @@ provider.sendStringMessage(routeId, message, callbackId); } + /** + * Gets a media controller to be used by native. + * @param routeId The route ID tied to the CastSession for which we want a media controller. + * @return A MediaControllerBridge if it can be obtained from |routeId|, null otherwise. + */ + @Nullable + @CalledByNative + public MediaControllerBridge getMediaControllerBridge(String routeId) { + MediaRouteProvider provider = mRouteIdsToProviders.get(routeId); + if (provider == null) return null; + + MediaController controller = provider.getMediaController(routeId); + if (controller == null) return null; + + return new MediaControllerBridge(controller); + } + @VisibleForTesting protected ChromeMediaRouter(long nativeMediaRouterAndroidBridge) { mNativeMediaRouterAndroidBridge = nativeMediaRouterAndroidBridge;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/router/MediaControllerBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/media/router/MediaControllerBridge.java new file mode 100644 index 0000000..3abcd92 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/media/router/MediaControllerBridge.java
@@ -0,0 +1,47 @@ +// Copyright 2018 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. + +package org.chromium.chrome.browser.media.router; + +import org.chromium.base.annotations.CalledByNative; +import org.chromium.base.annotations.JNINamespace; + +/** + * A wrapper around a MediaController that allows the native code to use it. + * See chrome/browser/media/android/remote/media_controller_bridge.h for the corresponding native + * code. + */ +@JNINamespace("media_router") +public class MediaControllerBridge { + private final MediaController mMediaController; + + public MediaControllerBridge(MediaController mediaController) { + mMediaController = mediaController; + } + + @CalledByNative + public void play() { + mMediaController.play(); + } + + @CalledByNative + public void pause() { + mMediaController.pause(); + } + + @CalledByNative + public void setMute(boolean mute) { + mMediaController.setMute(mute); + } + + @CalledByNative + public void setVolume(float volume) { + mMediaController.setVolume(volume); + } + + @CalledByNative + public void seek(long positionInMs) { + mMediaController.seek(positionInMs); + } +}
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index 2783aba..7ffee48 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni
@@ -594,6 +594,7 @@ "java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterDialogController.java", "java/src/org/chromium/chrome/browser/media/router/DiscoveryDelegate.java", "java/src/org/chromium/chrome/browser/media/router/MediaController.java", + "java/src/org/chromium/chrome/browser/media/router/MediaControllerBridge.java", "java/src/org/chromium/chrome/browser/media/router/MediaRoute.java", "java/src/org/chromium/chrome/browser/media/router/MediaRouteChooserDialogManager.java", "java/src/org/chromium/chrome/browser/media/router/MediaRouteControllerDialogManager.java",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 3e6c354..88709f8 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -2231,6 +2231,8 @@ "media/android/cdm/media_drm_license_manager.h", "media/android/cdm/media_drm_storage_factory.cc", "media/android/cdm/media_drm_storage_factory.h", + "media/android/remote/media_controller_bridge.cc", + "media/android/remote/media_controller_bridge.h", "media/android/remote/record_cast_action.cc", "media/android/remote/remote_media_player_bridge.cc", "media/android/remote/remote_media_player_bridge.h", @@ -4294,6 +4296,7 @@ "../android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerBridge.java", "../android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouter.java", "../android/java/src/org/chromium/chrome/browser/media/router/ChromeMediaRouterDialogController.java", + "../android/java/src/org/chromium/chrome/browser/media/router/MediaControllerBridge.java", "../android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java", "../android/java/src/org/chromium/chrome/browser/metrics/PageLoadMetrics.java", "../android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 8b0736e..f910049d 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -1533,6 +1533,10 @@ flag_descriptions::kVideoPlayerChromecastSupportDescription, kOsCrOS, SINGLE_VALUE_TYPE( chromeos::switches::kEnableVideoPlayerChromecastSupport)}, + {"hide-non-open-apps-from-shelf", + flag_descriptions::kHideNonActiveAppsFromShelfName, + flag_descriptions::kHideNonActiveAppsFromShelfDescription, kOsCrOS, + SINGLE_VALUE_TYPE(chromeos::switches::kHideNonActiveAppsFromShelf)}, {"instant-tethering", flag_descriptions::kTetherName, flag_descriptions::kTetherDescription, kOsCrOS, FEATURE_VALUE_TYPE(features::kInstantTethering)},
diff --git a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc index bd4c870..1f6c3a2 100644 --- a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc +++ b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc
@@ -34,6 +34,7 @@ #include "components/browser_sync/profile_sync_service.h" #include "components/history/core/browser/history_service.h" #include "components/omnibox/browser/autocomplete_classifier.h" +#include "components/omnibox/browser/autocomplete_match.h" #include "components/prefs/pref_service.h" #include "components/signin/core/browser/signin_manager.h" #include "components/sync/driver/sync_service_utils.h" @@ -363,7 +364,9 @@ } // TODO(crbug.com/46623): Maintain a map of URL->WebContents for fast look-up. -bool ChromeAutocompleteProviderClient::IsTabOpenWithURL(const GURL& url) { +bool ChromeAutocompleteProviderClient::IsTabOpenWithURL( + const GURL& url, + const AutocompleteInput* input) { #if !defined(OS_ANDROID) Browser* active_browser = BrowserList::GetInstance()->GetLastActive(); content::WebContents* active_tab = nullptr; @@ -376,7 +379,9 @@ for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { content::WebContents* web_contents = browser->tab_strip_model()->GetWebContentsAt(i); - if (web_contents != active_tab && web_contents->GetVisibleURL() == url) + if (web_contents != active_tab && + StrippedURLsAreEqual(web_contents->GetLastCommittedURL(), url, + input)) return true; } } @@ -384,3 +389,18 @@ #endif // !defined(OS_ANDROID) return false; } + +bool ChromeAutocompleteProviderClient::StrippedURLsAreEqual( + const GURL& url1, + const GURL& url2, + const AutocompleteInput* input) { + AutocompleteInput empty_input; + if (!input) + input = &empty_input; + TemplateURLService* template_url_service = GetTemplateURLService(); + return AutocompleteMatch::GURLToStrippedGURL(url1, AutocompleteInput(), + template_url_service, + base::string16()) == + AutocompleteMatch::GURLToStrippedGURL( + url2, *input, template_url_service, base::string16()); +}
diff --git a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.h b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.h index 1766fbe..9465c0d 100644 --- a/chrome/browser/autocomplete/chrome_autocomplete_provider_client.h +++ b/chrome/browser/autocomplete/chrome_autocomplete_provider_client.h
@@ -66,13 +66,18 @@ void StartServiceWorker(const GURL& destination_url) override; void OnAutocompleteControllerResultReady( AutocompleteController* controller) override; - bool IsTabOpenWithURL(const GURL& url) override; + bool IsTabOpenWithURL(const GURL& url, + const AutocompleteInput* input) override; // For testing. void set_storage_partition(content::StoragePartition* storage_partition) { storage_partition_ = storage_partition; } + bool StrippedURLsAreEqual(const GURL& url1, + const GURL& url2, + const AutocompleteInput* input); + private: Profile* profile_; ChromeAutocompleteSchemeClassifier scheme_classifier_;
diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index 9345d1b..b49df1e 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
@@ -1621,8 +1621,16 @@ // Test forms with multiple email addresses are filled properly. // Entire form should be filled with one user gesture. +// Tests using PopulateForm() are flaky on CrOS; see https://crbug.com/516052. +#if defined(OS_CHROMEOS) +#define MAYBE_MultipleEmailFilledByOneUserGesture \ + DISABLED_MultipleEmailFilledByOneUserGesture +#else +#define MAYBE_MultipleEmailFilledByOneUserGesture \ + MultipleEmailFilledByOneUserGesture +#endif IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, - MultipleEmailFilledByOneUserGesture) { + MAYBE_MultipleEmailFilledByOneUserGesture) { std::string email("bsmith@gmail.com"); AutofillProfile profile;
diff --git a/chrome/browser/banners/app_banner_infobar_delegate_android.cc b/chrome/browser/banners/app_banner_infobar_delegate_android.cc index 074ae4c1..2d6ec207 100644 --- a/chrome/browser/banners/app_banner_infobar_delegate_android.cc +++ b/chrome/browser/banners/app_banner_infobar_delegate_android.cc
@@ -26,6 +26,7 @@ } AppBannerInfoBarDelegateAndroid::~AppBannerInfoBarDelegateAndroid() { + ui_delegate_.reset(); Java_AppBannerInfoBarDelegateAndroid_destroy( base::android::AttachCurrentThread(), java_delegate_); java_delegate_.Reset();
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 77a43c5..096d612f6 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -1431,13 +1431,13 @@ "power/ml/real_boot_clock.h", "power/ml/recent_events_counter.cc", "power/ml/recent_events_counter.h", - "power/ml/user_activity_logger.cc", - "power/ml/user_activity_logger.h", - "power/ml/user_activity_logger_delegate.h", - "power/ml/user_activity_logger_delegate_ukm.cc", - "power/ml/user_activity_logger_delegate_ukm.h", - "power/ml/user_activity_logging_controller.cc", - "power/ml/user_activity_logging_controller.h", + "power/ml/user_activity_controller.cc", + "power/ml/user_activity_controller.h", + "power/ml/user_activity_manager.cc", + "power/ml/user_activity_manager.h", + "power/ml/user_activity_ukm_logger.h", + "power/ml/user_activity_ukm_logger_impl.cc", + "power/ml/user_activity_ukm_logger_impl.h", "power/power_data_collector.cc", "power/power_data_collector.h", "power/power_metrics_reporter.cc", @@ -1542,6 +1542,8 @@ "smb_client/discovery/host_locator.h", "smb_client/discovery/in_memory_host_locator.cc", "smb_client/discovery/in_memory_host_locator.h", + "smb_client/discovery/network_scanner.cc", + "smb_client/discovery/network_scanner.h", "smb_client/smb_file_system.cc", "smb_client/smb_file_system.h", "smb_client/smb_provider.cc", @@ -2010,8 +2012,8 @@ "power/ml/idle_event_notifier_unittest.cc", "power/ml/real_boot_clock_unittest.cc", "power/ml/recent_events_counter_unittest.cc", - "power/ml/user_activity_logger_delegate_ukm_unittest.cc", - "power/ml/user_activity_logger_unittest.cc", + "power/ml/user_activity_manager_unittest.cc", + "power/ml/user_activity_ukm_logger_unittest.cc", "power/power_data_collector_unittest.cc", "power/power_metrics_reporter_unittest.cc", "power/power_prefs_unittest.cc", @@ -2038,6 +2040,7 @@ "settings/shutdown_policy_handler_unittest.cc", "settings/stub_cros_settings_provider_unittest.cc", "smb_client/discovery/in_memory_host_locator_unittest.cc", + "smb_client/discovery/network_scanner_unittest.cc", "smb_client/smb_service_unittest.cc", "smb_client/temp_file_manager_unittest.cc", "system/automatic_reboot_manager_unittest.cc",
diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc index b587083..d66a241 100644 --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc
@@ -339,11 +339,18 @@ mojom::AccessibilityEventData* event_data) { tree_map_.clear(); parent_map_.clear(); + cached_computed_bounds_.clear(); root_id_ = -1; window_id_ = event_data->window_id; is_notification_ = event_data->notification_key.has_value(); + // The following loops perform caching to prepare for AXTreeSerializer. + // First, we need to cache parent links, which are implied by a node's child + // ids. + // Next, we cache the nodes by id. During this process, we can detect the root + // node based upon the parent links we cached above. + // Finally, we cache each node's computed bounds, based on its descendants. for (size_t i = 0; i < event_data->node_data.size(); ++i) { if (!event_data->node_data[i]->int_list_properties) continue; @@ -357,18 +364,27 @@ for (size_t i = 0; i < event_data->node_data.size(); ++i) { int32_t id = event_data->node_data[i]->id; - tree_map_[id] = event_data->node_data[i].get(); + mojom::AccessibilityNodeInfoData* node = event_data->node_data[i].get(); + tree_map_[id] = node; if (parent_map_.find(id) == parent_map_.end()) { CHECK_EQ(-1, root_id_) << "Duplicated root"; root_id_ = id; } - if (GetBooleanProperty(event_data->node_data[i].get(), + if (GetBooleanProperty(node, arc::mojom::AccessibilityBooleanProperty::FOCUSED)) { focused_node_id_ = id; } } + // Assuming |nodeData| is in pre-order, compute cached bounds in post-order to + // avoid an O(n^2) amount of work as the computed bounds uses descendant + // bounds. + for (int i = event_data->node_data.size() - 1; i >= 0; --i) { + mojom::AccessibilityNodeInfoData* node = event_data->node_data[i].get(); + cached_computed_bounds_[node] = ComputeEnclosingBounds(node); + } + ExtensionMsg_AccessibilityEventParams params; params.event_type = ToAXEvent(event_data->event_type); @@ -484,7 +500,8 @@ if (width_difference != 0) return width_difference > 0; - return true; + // The rects are equal. + return false; }); } @@ -696,6 +713,12 @@ void AXTreeSourceArc::ComputeEnclosingBoundsInternal( mojom::AccessibilityNodeInfoData* node, gfx::Rect& computed_bounds) const { + auto cached_bounds = cached_computed_bounds_.find(node); + if (cached_bounds != cached_computed_bounds_.end()) { + computed_bounds.Union(cached_bounds->second); + return; + } + // Only consider nodes that can possibly be accessibility focused. In Chrome, // this amounts to nodes with a non-generic container role. ui::AXNodeData data; @@ -731,6 +754,7 @@ void AXTreeSourceArc::Reset() { tree_map_.clear(); parent_map_.clear(); + cached_computed_bounds_.clear(); current_tree_serializer_.reset(new AXTreeArcSerializer(this)); root_id_ = -1; focused_node_id_ = -1;
diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h index 9d55f09..df1ead3 100644 --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h
@@ -119,6 +119,8 @@ const Delegate* const delegate_; std::unique_ptr<FocusStealer> focus_stealer_; std::string package_name_; + std::map<mojom::AccessibilityNodeInfoData*, gfx::Rect> + cached_computed_bounds_; DISALLOW_COPY_AND_ASSIGN(AXTreeSourceArc); };
diff --git a/chrome/browser/chromeos/arc/arc_service_launcher.cc b/chrome/browser/chromeos/arc/arc_service_launcher.cc index 5df484a12..667b8e2f 100644 --- a/chrome/browser/chromeos/arc/arc_service_launcher.cc +++ b/chrome/browser/chromeos/arc/arc_service_launcher.cc
@@ -59,6 +59,7 @@ #include "components/arc/timer/arc_timer_bridge.h" #include "components/arc/usb/usb_host_bridge.h" #include "components/arc/volume_mounter/arc_volume_mounter_bridge.h" +#include "components/arc/wake_lock/arc_wake_lock_bridge.h" #include "components/prefs/pref_member.h" #include "ui/arc/notification/arc_notification_manager.h" @@ -176,6 +177,7 @@ ArcVoiceInteractionArcHomeService::GetForBrowserContext(profile); ArcVoiceInteractionFrameworkService::GetForBrowserContext(profile); ArcVolumeMounterBridge::GetForBrowserContext(profile); + ArcWakeLockBridge::GetForBrowserContext(profile); ArcWallpaperService::GetForBrowserContext(profile); GpuArcVideoServiceHost::GetForBrowserContext(profile);
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 09e2d6f4..8bf3eae 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -83,7 +83,7 @@ #include "chrome/browser/chromeos/policy/device_local_account.h" #include "chrome/browser/chromeos/power/freezer_cgroup_process_manager.h" #include "chrome/browser/chromeos/power/idle_action_warning_observer.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logging_controller.h" +#include "chrome/browser/chromeos/power/ml/user_activity_controller.h" #include "chrome/browser/chromeos/power/power_data_collector.h" #include "chrome/browser/chromeos/power/power_metrics_reporter.h" #include "chrome/browser/chromeos/power/power_prefs.h" @@ -1045,8 +1045,8 @@ shutdown_policy_forwarder_ = std::make_unique<ShutdownPolicyForwarder>(); if (base::FeatureList::IsEnabled(features::kUserActivityEventLogging)) { - user_activity_logging_controller_ = - std::make_unique<power::ml::UserActivityLoggingController>(); + user_activity_controller_ = + std::make_unique<power::ml::UserActivityController>(); } ChromeBrowserMainPartsLinux::PostBrowserStart(); @@ -1102,7 +1102,7 @@ ScreenLocker::ShutDownClass(); keyboard_event_rewriters_.reset(); low_disk_notification_.reset(); - user_activity_logging_controller_.reset(); + user_activity_controller_.reset(); // Detach D-Bus clients before DBusThreadManager is shut down. idle_action_warning_observer_.reset();
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h index 44d0c00..b7b7fe6a 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
@@ -53,7 +53,7 @@ namespace power { namespace ml { -class UserActivityLoggingController; +class UserActivityController; } // namespace ml } // namespace power @@ -126,8 +126,7 @@ // send notifier settings information to Ash. std::unique_ptr<NotificationPlatformBridge> notification_client_; - std::unique_ptr<power::ml::UserActivityLoggingController> - user_activity_logging_controller_; + std::unique_ptr<power::ml::UserActivityController> user_activity_controller_; DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainPartsChromeos); };
diff --git a/chrome/browser/chromeos/first_run/first_run.cc b/chrome/browser/chromeos/first_run/first_run.cc index 9804e6c..7c547fca 100644 --- a/chrome/browser/chromeos/first_run/first_run.cc +++ b/chrome/browser/chromeos/first_run/first_run.cc
@@ -140,8 +140,13 @@ auto* service = arc::ArcVoiceInteractionFrameworkService::GetForBrowserContext( profile_); - if (service) + if (service) { service->StartVoiceInteractionOobe(); + } else { + // Try launching the tutorial in case the voice interaction framework + // service is unavailable. See https://crbug.com/809756. + TryLaunchFirstRunDialog(profile_); + } } else { TryLaunchFirstRunDialog(profile_); }
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logging_controller.cc b/chrome/browser/chromeos/power/ml/user_activity_controller.cc similarity index 82% rename from chrome/browser/chromeos/power/ml/user_activity_logging_controller.cc rename to chrome/browser/chromeos/power/ml/user_activity_controller.cc index 1d0e0a45..898a5cf 100644 --- a/chrome/browser/chromeos/power/ml/user_activity_logging_controller.cc +++ b/chrome/browser/chromeos/power/ml/user_activity_controller.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/power/ml/user_activity_logging_controller.h" +#include "chrome/browser/chromeos/power/ml/user_activity_controller.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -17,7 +17,7 @@ namespace power { namespace ml { -UserActivityLoggingController::UserActivityLoggingController() { +UserActivityController::UserActivityController() { if (chromeos::GetDeviceType() != chromeos::DeviceType::kChromebook) return; @@ -30,7 +30,7 @@ session_manager::SessionManager::Get(); DCHECK(session_manager); - // TODO(jiameng): both IdleEventNotifier and UserActivityLogger implement + // TODO(jiameng): both IdleEventNotifier and UserActivityManager implement // viz::mojom::VideoDetectorObserver. We should refactor the code to create // one shared video detector observer class. viz::mojom::VideoDetectorObserverPtr video_observer_idle_notifier; @@ -43,8 +43,8 @@ ->AddVideoDetectorObserver(std::move(video_observer_idle_notifier)); viz::mojom::VideoDetectorObserverPtr video_observer_user_logger; - user_activity_logger_ = std::make_unique<UserActivityLogger>( - &user_activity_logger_delegate_, idle_event_notifier_.get(), detector, + user_activity_manager_ = std::make_unique<UserActivityManager>( + &user_activity_ukm_logger_, idle_event_notifier_.get(), detector, power_manager_client, session_manager, mojo::MakeRequest(&video_observer_user_logger), chromeos::ChromeUserManager::Get()); @@ -54,7 +54,7 @@ ->AddVideoDetectorObserver(std::move(video_observer_user_logger)); } -UserActivityLoggingController::~UserActivityLoggingController() = default; +UserActivityController::~UserActivityController() = default; } // namespace ml } // namespace power
diff --git a/chrome/browser/chromeos/power/ml/user_activity_controller.h b/chrome/browser/chromeos/power/ml/user_activity_controller.h new file mode 100644 index 0000000..807408b --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_controller.h
@@ -0,0 +1,38 @@ +// 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 CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_CONTROLLER_H_ +#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_CONTROLLER_H_ + +#include <memory> + +#include "chrome/browser/chromeos/power/ml/idle_event_notifier.h" +#include "chrome/browser/chromeos/power/ml/user_activity_manager.h" +#include "chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h" + +namespace chromeos { +namespace power { +namespace ml { + +// This controller class sets up and destroys all the components associated with +// user activity logging (IdleEventNotifier, UserActivityUkmLogger and +// UserActivityManager). +class UserActivityController { + public: + UserActivityController(); + ~UserActivityController(); + + private: + std::unique_ptr<IdleEventNotifier> idle_event_notifier_; + UserActivityUkmLoggerImpl user_activity_ukm_logger_; + std::unique_ptr<UserActivityManager> user_activity_manager_; + + DISALLOW_COPY_AND_ASSIGN(UserActivityController); +}; + +} // namespace ml +} // namespace power +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_CONTROLLER_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h b/chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h deleted file mode 100644 index fb68d1b..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h +++ /dev/null
@@ -1,32 +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. - -#ifndef CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_H_ -#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_H_ - -namespace chromeos { -namespace power { -namespace ml { - -class UserActivityEvent; - -// Interface to log UserActivityEvent to UKM. -class UserActivityLoggerDelegate { - public: - virtual ~UserActivityLoggerDelegate() = default; - - // Get source IDs of all open tabs' URLs. This method should be called when - // user activity logger runs feature extraction to collect source IDs of all - // open tabs' URLs. - virtual void UpdateOpenTabsURLs() = 0; - - // Log user activity event. - virtual void LogActivity(const UserActivityEvent& event) = 0; -}; - -} // namespace ml -} // namespace power -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.cc b/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.cc deleted file mode 100644 index 870fb8c4..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.cc +++ /dev/null
@@ -1,241 +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 <cmath> - -#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h" -#include "chrome/browser/resource_coordinator/tab_metrics_logger.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "components/ukm/content/source_url_recorder.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/page_importance_signals.h" -#include "services/metrics/public/cpp/ukm_builders.h" -#include "ui/aura/window.h" -#include "ui/gfx/native_widget_types.h" - -namespace chromeos { -namespace power { -namespace ml { - -namespace { - -constexpr UserActivityLoggerDelegateUkm::Bucket kBatteryPercentBuckets[] = { - {100, 5}}; - -constexpr UserActivityLoggerDelegateUkm::Bucket kEventLogDurationBuckets[] = { - {60, 1}, - {300, 10}, - {600, 20}}; - -constexpr UserActivityLoggerDelegateUkm::Bucket kUserInputEventBuckets[] = { - {100, 1}, - {1000, 100}, - {10000, 1000}}; - -constexpr UserActivityLoggerDelegateUkm::Bucket - kRecentVideoPlayingTimeBuckets[] = {{60, 1}, - {1200, 300}, - {3600, 600}, - {18000, 1800}}; - -constexpr UserActivityLoggerDelegateUkm::Bucket - kTimeSinceLastVideoEndedBuckets[] = {{60, 1}, - {600, 60}, - {1200, 300}, - {3600, 600}, - {18000, 1800}}; - -} // namespace - -int UserActivityLoggerDelegateUkm::Bucketize(int original_value, - const Bucket* buckets, - size_t num_buckets) { - DCHECK_GE(original_value, 0); - DCHECK(buckets); - for (size_t i = 0; i < num_buckets; ++i) { - const Bucket& bucket = buckets[i]; - if (original_value < bucket.boundary_end) { - return bucket.rounding * (original_value / bucket.rounding); - } - } - return buckets[num_buckets - 1].boundary_end; -} - -UserActivityLoggerDelegateUkm::UserActivityLoggerDelegateUkm() - : ukm_recorder_(ukm::UkmRecorder::Get()) {} - -UserActivityLoggerDelegateUkm::~UserActivityLoggerDelegateUkm() = default; - -void UserActivityLoggerDelegateUkm::UpdateOpenTabsURLs() { - if (!ukm_recorder_) - return; - - source_ids_.clear(); - bool topmost_browser_found = false; - BrowserList* browser_list = BrowserList::GetInstance(); - DCHECK(browser_list); - - // Go through all browsers starting from last active ones. - for (auto browser_iterator = browser_list->begin_last_active(); - browser_iterator != browser_list->end_last_active(); - ++browser_iterator) { - Browser* browser = *browser_iterator; - - const bool is_browser_focused = browser->window()->IsActive(); - const bool is_browser_visible = - browser->window()->GetNativeWindow()->IsVisible(); - - bool is_topmost_browser = false; - if (is_browser_visible && !topmost_browser_found) { - is_topmost_browser = true; - topmost_browser_found = true; - } - - if (browser->profile()->IsOffTheRecord()) - continue; - - const TabStripModel* const tab_strip_model = browser->tab_strip_model(); - DCHECK(tab_strip_model); - - const int active_tab_index = tab_strip_model->active_index(); - - for (int i = 0; i < tab_strip_model->count(); ++i) { - content::WebContents* contents = tab_strip_model->GetWebContentsAt(i); - DCHECK(contents); - ukm::SourceId source_id = - ukm::GetSourceIdForWebContentsDocument(contents); - if (source_id == ukm::kInvalidSourceId) - continue; - - const TabProperty tab_property = { - i == active_tab_index, - is_browser_focused, - is_browser_visible, - is_topmost_browser, - TabMetricsLogger::GetSiteEngagementScore(contents), - TabMetricsLogger::GetContentTypeFromMimeType( - contents->GetContentsMimeType()), - contents->GetPageImportanceSignals().had_form_interaction}; - - source_ids_.insert( - std::pair<ukm::SourceId, TabProperty>(source_id, tab_property)); - } - } -} - -void UserActivityLoggerDelegateUkm::LogActivity( - const UserActivityEvent& event) { - if (!ukm_recorder_) - return; - - ukm::SourceId source_id = ukm_recorder_->GetNewSourceID(); - ukm::builders::UserActivity user_activity(source_id); - user_activity.SetSequenceId(next_sequence_id_++) - .SetDeviceMode(event.features().device_mode()) - .SetDeviceType(event.features().device_type()) - .SetEventLogDuration(Bucketize(event.event().log_duration_sec(), - kEventLogDurationBuckets, - arraysize(kEventLogDurationBuckets))) - .SetEventReason(event.event().reason()) - .SetEventType(event.event().type()) - .SetLastActivityDay(event.features().last_activity_day()) - .SetLastActivityTime( - std::floor(event.features().last_activity_time_sec() / 3600)) - .SetRecentTimeActive(event.features().recent_time_active_sec()) - .SetRecentVideoPlayingTime( - Bucketize(event.features().video_playing_time_sec(), - kRecentVideoPlayingTimeBuckets, - arraysize(kRecentVideoPlayingTimeBuckets))); - - if (event.features().has_on_to_dim_sec()) { - user_activity.SetScreenDimDelay(event.features().on_to_dim_sec()); - } - if (event.features().has_dim_to_screen_off_sec()) { - user_activity.SetScreenDimToOffDelay( - event.features().dim_to_screen_off_sec()); - } - - if (event.features().has_last_user_activity_time_sec()) { - user_activity.SetLastUserActivityTime( - std::floor(event.features().last_user_activity_time_sec() / 3600)); - } - if (event.features().has_time_since_last_key_sec()) { - user_activity.SetTimeSinceLastKey( - event.features().time_since_last_key_sec()); - } - if (event.features().has_time_since_last_mouse_sec()) { - user_activity.SetTimeSinceLastMouse( - event.features().time_since_last_mouse_sec()); - } - if (event.features().has_time_since_last_touch_sec()) { - user_activity.SetTimeSinceLastTouch( - event.features().time_since_last_touch_sec()); - } - - if (event.features().has_on_battery()) { - user_activity.SetOnBattery(event.features().on_battery()); - } - - if (event.features().has_battery_percent()) { - user_activity.SetBatteryPercent( - Bucketize(std::floor(event.features().battery_percent()), - kBatteryPercentBuckets, arraysize(kBatteryPercentBuckets))); - } - - if (event.features().has_device_management()) { - user_activity.SetDeviceManagement(event.features().device_management()); - } - - if (event.features().has_time_since_video_ended_sec()) { - user_activity.SetTimeSinceLastVideoEnded( - Bucketize(event.features().time_since_video_ended_sec(), - kTimeSinceLastVideoEndedBuckets, - arraysize(kTimeSinceLastVideoEndedBuckets))); - } - - if (event.features().has_key_events_in_last_hour()) { - user_activity.SetKeyEventsInLastHour( - Bucketize(event.features().key_events_in_last_hour(), - kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); - } - - if (event.features().has_mouse_events_in_last_hour()) { - user_activity.SetMouseEventsInLastHour( - Bucketize(event.features().mouse_events_in_last_hour(), - kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); - } - - if (event.features().has_touch_events_in_last_hour()) { - user_activity.SetTouchEventsInLastHour( - Bucketize(event.features().touch_events_in_last_hour(), - kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); - } - - user_activity.Record(ukm_recorder_); - - for (const std::pair<ukm::SourceId, TabProperty>& kv : source_ids_) { - const ukm::SourceId& id = kv.first; - const TabProperty& tab_property = kv.second; - ukm::builders::UserActivityId user_activity_id(id); - user_activity_id.SetActivityId(source_id) - .SetContentType(tab_property.content_type) - .SetHasFormEntry(tab_property.has_form_entry) - .SetIsActive(tab_property.is_active) - .SetIsBrowserFocused(tab_property.is_browser_focused) - .SetIsBrowserVisible(tab_property.is_browser_visible) - .SetIsTopmostBrowser(tab_property.is_topmost_browser); - if (tab_property.engagement_score >= 0) { - user_activity_id.SetSiteEngagementScore(tab_property.engagement_score); - } - user_activity_id.Record(ukm_recorder_); - } -} - -} // namespace ml -} // namespace power -} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h b/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h deleted file mode 100644 index 4377707..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h +++ /dev/null
@@ -1,81 +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. - -#ifndef CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_UKM_H_ -#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_UKM_H_ - -#include "base/macros.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h" -#include "chrome/browser/resource_coordinator/tab_metrics_event.pb.h" -#include "services/metrics/public/cpp/ukm_recorder.h" - -namespace chromeos { -namespace power { -namespace ml { - -class UserActivityEvent; - -class UserActivityLoggerDelegateUkm : public UserActivityLoggerDelegate { - public: - // Both |boundary_end| and |rounding| must be positive. - struct Bucket { - int boundary_end; - int rounding; - }; - - // Bucketize |original_value| using given |buckets|, which is an array of - // Bucket and must be sorted in ascending order of |boundary_end|. - // |original_value| must be non-negative. An example of |buckets| is - // {{60, 1}, {300, 10}, {600, 20}}. This function looks for the first - // |boundary_end| > |original_value| and bucket it to the nearest |rounding|. - // If |original_value| is greater than all |boundary_end|, the function - // returns the largest |boundary_end|. Using the above |buckets| example, the - // function will return 30 if |original_value| = 30, and 290 if - // |original_value| = 299. - static int Bucketize(int original_value, - const Bucket* buckets, - size_t num_buckets); - - UserActivityLoggerDelegateUkm(); - ~UserActivityLoggerDelegateUkm() override; - - // chromeos::power::ml::UserActivityLoggerDelegate overrides: - void UpdateOpenTabsURLs() override; - void LogActivity(const UserActivityEvent& event) override; - - private: - ukm::UkmRecorder* ukm_recorder_; // not owned - - struct TabProperty { - // Whether the tab is the selected one in its containing browser. - bool is_active; - // Whether the containing browser is in focus. - bool is_browser_focused; - // Whether the containing browser is visible. - bool is_browser_visible; - // Whether the containing browser is the topmost one on the screen. - bool is_topmost_browser; - // Tab URL's engagement score. -1 if engagement service is disabled. - int engagement_score; - // Tab content type. - metrics::TabMetricsEvent::ContentType content_type; - // Whether user has form entry, i.e. text input. - bool has_form_entry; - }; - - // Source IDs of open tabs' URLs. - std::map<ukm::SourceId, TabProperty> source_ids_; - - // This ID is incremented each time a UserActivity is logged to UKM. - // Event index starts from 1, and resets when a new session starts. - int next_sequence_id_ = 1; - - DISALLOW_COPY_AND_ASSIGN(UserActivityLoggerDelegateUkm); -}; - -} // namespace ml -} // namespace power -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_DELEGATE_UKM_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm_unittest.cc b/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm_unittest.cc deleted file mode 100644 index d10e190..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm_unittest.cc +++ /dev/null
@@ -1,447 +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 "chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h" - -#include <memory> -#include <vector> - -#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" -#include "chrome/browser/engagement/site_engagement_service.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tabs/tab_activity_simulator.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/tabs/tab_ukm_test_helper.h" -#include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "chrome/test/base/test_browser_window_aura.h" -#include "chrome/test/base/testing_profile.h" -#include "content/public/browser/web_contents.h" -#include "content/public/test/web_contents_tester.h" -#include "services/metrics/public/cpp/ukm_builders.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace chromeos { -namespace power { -namespace ml { - -using ukm::builders::UserActivity; -using ukm::builders::UserActivityId; -using content::WebContentsTester; - -class UserActivityLoggerDelegateUkmTest - : public ChromeRenderViewHostTestHarness { - public: - UserActivityLoggerDelegateUkmTest() { - // These values are arbitrary but must correspond with the values - // in |user_activity_values_|. - UserActivityEvent::Event* event = user_activity_event_.mutable_event(); - event->set_log_duration_sec(395); - event->set_reason(UserActivityEvent::Event::USER_ACTIVITY); - event->set_type(UserActivityEvent::Event::REACTIVATE); - - // In the order of metrics names in ukm. - UserActivityEvent::Features* features = - user_activity_event_.mutable_features(); - features->set_battery_percent(96.0); - features->set_device_management(UserActivityEvent::Features::UNMANAGED); - features->set_device_mode(UserActivityEvent::Features::CLAMSHELL); - features->set_device_type(UserActivityEvent::Features::CHROMEBOOK); - features->set_last_activity_day(UserActivityEvent::Features::MON); - features->set_last_activity_time_sec(7300); - features->set_last_user_activity_time_sec(3800); - features->set_key_events_in_last_hour(20000); - features->set_recent_time_active_sec(10); - features->set_video_playing_time_sec(800); - features->set_on_to_dim_sec(100); - features->set_dim_to_screen_off_sec(200); - features->set_time_since_last_mouse_sec(100); - features->set_time_since_last_touch_sec(311); - features->set_time_since_video_ended_sec(400); - features->set_mouse_events_in_last_hour(89); - features->set_touch_events_in_last_hour(1890); - } - - void UpdateOpenTabsURLs() { - user_activity_logger_delegate_ukm_.UpdateOpenTabsURLs(); - } - - void LogActivity(const UserActivityEvent& event) { - user_activity_logger_delegate_ukm_.LogActivity(event); - } - - // Creates a test browser window and sets its visibility, activity and - // incognito status. - std::unique_ptr<Browser> CreateTestBrowser(bool is_visible, - bool is_focused, - bool is_incognito = false) { - Profile* const original_profile = profile(); - Profile* const used_profile = - is_incognito ? original_profile->GetOffTheRecordProfile() - : original_profile; - Browser::CreateParams params(used_profile, true); - - std::unique_ptr<aura::Window> dummy_window(new aura::Window(nullptr)); - dummy_window->Init(ui::LAYER_SOLID_COLOR); - root_window()->AddChild(dummy_window.get()); - dummy_window->SetBounds(gfx::Rect(root_window()->bounds().size())); - if (is_visible) { - dummy_window->Show(); - } else { - dummy_window->Hide(); - } - - std::unique_ptr<Browser> browser = - chrome::CreateBrowserWithAuraTestWindowForParams( - std::move(dummy_window), ¶ms); - if (is_focused) { - browser->window()->Activate(); - } else { - browser->window()->Deactivate(); - } - return browser; - } - - // Adds a tab with specified url to the tab strip model. Also optionally sets - // the tab to be the active one in the tab strip model. - // If |mime_type| is an empty string, the content has a default text type. - // TODO(jiameng): there doesn't seem to be a way to set form entry (via - // page importance signal). Check if there's some other way to set it. - void CreateTestWebContents(TabStripModel* const tab_strip_model, - const GURL& url, - bool is_active, - const std::string& mime_type = "") { - DCHECK(tab_strip_model); - DCHECK(!url.is_empty()); - content::WebContents* contents = - tab_activity_simulator_.AddWebContentsAndNavigate(tab_strip_model, url); - if (is_active) { - tab_strip_model->ActivateTabAt(tab_strip_model->count() - 1, false); - } - if (!mime_type.empty()) - WebContentsTester::For(contents)->SetMainFrameMimeType(mime_type); - - WebContentsTester::For(contents)->TestSetIsLoading(false); - } - - protected: - UserActivityEvent user_activity_event_; - UkmEntryChecker ukm_entry_checker_; - TabActivitySimulator tab_activity_simulator_; - - const GURL url1_ = GURL("https://example1.com/"); - const GURL url2_ = GURL("https://example2.com/"); - const GURL url3_ = GURL("https://example3.com/"); - const GURL url4_ = GURL("https://example4.com/"); - - const UkmMetricMap user_activity_values_ = { - {UserActivity::kEventLogDurationName, 380}, - {UserActivity::kEventReasonName, UserActivityEvent::Event::USER_ACTIVITY}, - {UserActivity::kEventTypeName, UserActivityEvent::Event::REACTIVATE}, - {UserActivity::kBatteryPercentName, 95}, - {UserActivity::kDeviceManagementName, - UserActivityEvent::Features::UNMANAGED}, - {UserActivity::kDeviceModeName, UserActivityEvent::Features::CLAMSHELL}, - {UserActivity::kDeviceTypeName, UserActivityEvent::Features::CHROMEBOOK}, - {UserActivity::kLastActivityDayName, UserActivityEvent::Features::MON}, - {UserActivity::kKeyEventsInLastHourName, 10000}, - {UserActivity::kLastActivityTimeName, 2}, - {UserActivity::kLastUserActivityTimeName, 1}, - {UserActivity::kMouseEventsInLastHourName, 89}, - {UserActivity::kOnBatteryName, base::nullopt}, - {UserActivity::kRecentTimeActiveName, 10}, - {UserActivity::kRecentVideoPlayingTimeName, 600}, - {UserActivity::kScreenDimDelayName, 100}, - {UserActivity::kScreenDimToOffDelayName, 200}, - {UserActivity::kSequenceIdName, 1}, - {UserActivity::kTimeSinceLastKeyName, base::nullopt}, - {UserActivity::kTimeSinceLastMouseName, 100}, - {UserActivity::kTimeSinceLastTouchName, 311}, - {UserActivity::kTimeSinceLastVideoEndedName, 360}, - {UserActivity::kTouchEventsInLastHourName, 1000}}; - - private: - UserActivityLoggerDelegateUkm user_activity_logger_delegate_ukm_; - DISALLOW_COPY_AND_ASSIGN(UserActivityLoggerDelegateUkmTest); -}; - -TEST_F(UserActivityLoggerDelegateUkmTest, BucketEveryFivePercents) { - const std::vector<int> original_values = {0, 14, 15, 100}; - const std::vector<int> results = {0, 10, 15, 100}; - constexpr UserActivityLoggerDelegateUkm::Bucket buckets[] = {{100, 5}}; - - for (size_t i = 0; i < original_values.size(); ++i) { - EXPECT_EQ(results[i], UserActivityLoggerDelegateUkm::Bucketize( - original_values[i], buckets, arraysize(buckets))); - } -} - -TEST_F(UserActivityLoggerDelegateUkmTest, Bucketize) { - const std::vector<int> original_values = {0, 18, 59, 60, 62, 69, 72, - 299, 300, 306, 316, 599, 600, 602}; - constexpr UserActivityLoggerDelegateUkm::Bucket buckets[] = { - {60, 1}, {300, 10}, {600, 20}}; - const std::vector<int> results = {0, 18, 59, 60, 60, 60, 70, - 290, 300, 300, 300, 580, 600, 600}; - for (size_t i = 0; i < original_values.size(); ++i) { - EXPECT_EQ(results[i], UserActivityLoggerDelegateUkm::Bucketize( - original_values[i], buckets, arraysize(buckets))); - } -} - -TEST_F(UserActivityLoggerDelegateUkmTest, Basic) { - std::unique_ptr<Browser> browser = - CreateTestBrowser(true /* is_visible */, true /* is_focused */); - BrowserList::GetInstance()->SetLastActive(browser.get()); - TabStripModel* tab_strip_model = browser->tab_strip_model(); - - CreateTestWebContents(tab_strip_model, url1_, true /* is_active */, - "application/pdf"); - - // Set engagement score to 95, which will be rounded down to 90 when it's - // logged to UKM. - SiteEngagementService::Get(profile())->ResetBaseScoreForURL(url1_, 95); - - const ukm::SourceId source_id1 = ukm_entry_checker_.GetSourceIdForUrl(url1_); - - CreateTestWebContents(tab_strip_model, url2_, false /* is_active */); - const ukm::SourceId source_id2 = ukm_entry_checker_.GetSourceIdForUrl(url2_); - - UpdateOpenTabsURLs(); - LogActivity(user_activity_event_); - - EXPECT_EQ(1, - ukm_entry_checker_.NumNewEntriesRecorded(UserActivity::kEntryName)); - EXPECT_EQ( - 2, ukm_entry_checker_.NumNewEntriesRecorded(UserActivityId::kEntryName)); - - ukm_entry_checker_.ExpectNewEntries(UserActivity::kEntryName, - {user_activity_values_}); - - const ukm::mojom::UkmEntry* last_activity_entry = - ukm_entry_checker_.LastUkmEntry(UserActivity::kEntryName); - - const ukm::SourceId kSourceId = last_activity_entry->source_id; - - const UkmMetricMap kUserActivityIdValues1( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 1}, - {UserActivityId::kIsBrowserFocusedName, 1}, - {UserActivityId::kIsBrowserVisibleName, 1}, - {UserActivityId::kIsTopmostBrowserName, 1}, - {UserActivityId::kSiteEngagementScoreName, 90}, - {UserActivityId::kContentTypeName, - metrics::TabMetricsEvent::CONTENT_TYPE_APPLICATION}, - {UserActivityId::kHasFormEntryName, 0}}); - - const UkmMetricMap kUserActivityIdValues2( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 0}, - {UserActivityId::kIsBrowserFocusedName, 1}, - {UserActivityId::kIsBrowserVisibleName, 1}, - {UserActivityId::kIsTopmostBrowserName, 1}, - {UserActivityId::kSiteEngagementScoreName, 0}, - {UserActivityId::kContentTypeName, - metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML}, - {UserActivityId::kHasFormEntryName, 0}}); - - const std::map<ukm::SourceId, std::pair<GURL, UkmMetricMap>> expected_data({ - {source_id1, std::make_pair(url1_, kUserActivityIdValues1)}, - {source_id2, std::make_pair(url2_, kUserActivityIdValues2)}, - }); - - ukm_entry_checker_.ExpectNewEntriesBySource(UserActivityId::kEntryName, - expected_data); - - tab_strip_model->CloseAllTabs(); -} - -TEST_F(UserActivityLoggerDelegateUkmTest, MultiBrowsersAndTabs) { - // Simulates three browsers: - // - browser1 is the last active but minimized and so not visible. - // - browser2 and browser3 are both visible but browser2 is the topmost. - std::unique_ptr<Browser> browser1 = - CreateTestBrowser(false /* is_visible */, false /* is_focused */); - std::unique_ptr<Browser> browser2 = - CreateTestBrowser(true /* is_visible */, true /* is_focused */); - std::unique_ptr<Browser> browser3 = - CreateTestBrowser(true /* is_visible */, false /* is_focused */); - - BrowserList::GetInstance()->SetLastActive(browser3.get()); - BrowserList::GetInstance()->SetLastActive(browser2.get()); - BrowserList::GetInstance()->SetLastActive(browser1.get()); - - TabStripModel* tab_strip_model1 = browser1->tab_strip_model(); - CreateTestWebContents(tab_strip_model1, url1_, false /* is_active */); - CreateTestWebContents(tab_strip_model1, url2_, true /* is_active */); - const ukm::SourceId source_id1 = ukm_entry_checker_.GetSourceIdForUrl(url1_); - const ukm::SourceId source_id2 = ukm_entry_checker_.GetSourceIdForUrl(url2_); - - TabStripModel* tab_strip_model2 = browser2->tab_strip_model(); - CreateTestWebContents(tab_strip_model2, url3_, true /* is_active */); - const ukm::SourceId source_id3 = ukm_entry_checker_.GetSourceIdForUrl(url3_); - - TabStripModel* tab_strip_model3 = browser3->tab_strip_model(); - CreateTestWebContents(tab_strip_model3, url4_, true /* is_active */); - const ukm::SourceId source_id4 = ukm_entry_checker_.GetSourceIdForUrl(url4_); - - UpdateOpenTabsURLs(); - LogActivity(user_activity_event_); - - EXPECT_EQ(1, - ukm_entry_checker_.NumNewEntriesRecorded(UserActivity::kEntryName)); - EXPECT_EQ( - 4, ukm_entry_checker_.NumNewEntriesRecorded(UserActivityId::kEntryName)); - - ukm_entry_checker_.ExpectNewEntries(UserActivity::kEntryName, - {user_activity_values_}); - - const ukm::mojom::UkmEntry* last_activity_entry = - ukm_entry_checker_.LastUkmEntry(UserActivity::kEntryName); - - const ukm::SourceId kSourceId = last_activity_entry->source_id; - - const UkmMetricMap kUserActivityIdValues1( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 0}, - {UserActivityId::kIsBrowserFocusedName, 0}, - {UserActivityId::kIsBrowserVisibleName, 0}, - {UserActivityId::kIsTopmostBrowserName, 0}}); - - const UkmMetricMap kUserActivityIdValues2( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 1}, - {UserActivityId::kIsBrowserFocusedName, 0}, - {UserActivityId::kIsBrowserVisibleName, 0}, - {UserActivityId::kIsTopmostBrowserName, 0}}); - - const UkmMetricMap kUserActivityIdValues3( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 1}, - {UserActivityId::kIsBrowserFocusedName, 1}, - {UserActivityId::kIsBrowserVisibleName, 1}, - {UserActivityId::kIsTopmostBrowserName, 1}}); - - const UkmMetricMap kUserActivityIdValues4( - {{UserActivityId::kActivityIdName, kSourceId}, - {UserActivityId::kIsActiveName, 1}, - {UserActivityId::kIsBrowserFocusedName, 0}, - {UserActivityId::kIsBrowserVisibleName, 1}, - {UserActivityId::kIsTopmostBrowserName, 0}}); - - const std::map<ukm::SourceId, std::pair<GURL, UkmMetricMap>> expected_data({ - {source_id1, std::make_pair(url1_, kUserActivityIdValues1)}, - {source_id2, std::make_pair(url2_, kUserActivityIdValues2)}, - {source_id3, std::make_pair(url3_, kUserActivityIdValues3)}, - {source_id4, std::make_pair(url4_, kUserActivityIdValues4)}, - }); - - ukm_entry_checker_.ExpectNewEntriesBySource(UserActivityId::kEntryName, - expected_data); - - tab_strip_model1->CloseAllTabs(); - tab_strip_model2->CloseAllTabs(); - tab_strip_model3->CloseAllTabs(); -} - -TEST_F(UserActivityLoggerDelegateUkmTest, Incognito) { - std::unique_ptr<Browser> browser = CreateTestBrowser( - true /* is_visible */, true /* is_focused */, true /* is_incognito */); - BrowserList::GetInstance()->SetLastActive(browser.get()); - - TabStripModel* tab_strip_model = browser->tab_strip_model(); - CreateTestWebContents(tab_strip_model, url1_, true /* is_active */); - CreateTestWebContents(tab_strip_model, url2_, false /* is_active */); - - UpdateOpenTabsURLs(); - LogActivity(user_activity_event_); - - EXPECT_EQ(1, - ukm_entry_checker_.NumNewEntriesRecorded(UserActivity::kEntryName)); - EXPECT_EQ( - 0, ukm_entry_checker_.NumNewEntriesRecorded(UserActivityId::kEntryName)); - - ukm_entry_checker_.ExpectNewEntries(UserActivity::kEntryName, - {user_activity_values_}); - - tab_strip_model->CloseAllTabs(); -} - -TEST_F(UserActivityLoggerDelegateUkmTest, NoOpenTabs) { - std::unique_ptr<Browser> browser = - CreateTestBrowser(true /* is_visible */, true /* is_focused */); - - UpdateOpenTabsURLs(); - LogActivity(user_activity_event_); - - EXPECT_EQ(1, - ukm_entry_checker_.NumNewEntriesRecorded(UserActivity::kEntryName)); - EXPECT_EQ( - 0, ukm_entry_checker_.NumNewEntriesRecorded(UserActivityId::kEntryName)); - - ukm_entry_checker_.ExpectNewEntries(UserActivity::kEntryName, - {user_activity_values_}); -} - -TEST_F(UserActivityLoggerDelegateUkmTest, TwoUserActivityEvents) { - std::unique_ptr<Browser> browser = - CreateTestBrowser(true /* is_visible */, true /* is_focused */); - - // A second event will be logged. - UserActivityEvent user_activity_event2; - UserActivityEvent::Event* event = user_activity_event2.mutable_event(); - event->set_log_duration_sec(35); - event->set_reason(UserActivityEvent::Event::IDLE_SLEEP); - event->set_type(UserActivityEvent::Event::TIMEOUT); - - UserActivityEvent::Features* features = - user_activity_event2.mutable_features(); - features->set_battery_percent(86.0); - features->set_device_management(UserActivityEvent::Features::MANAGED); - features->set_device_mode(UserActivityEvent::Features::CLAMSHELL); - features->set_device_type(UserActivityEvent::Features::CHROMEBOOK); - features->set_last_activity_day(UserActivityEvent::Features::TUE); - features->set_last_activity_time_sec(7300); - features->set_last_user_activity_time_sec(3800); - features->set_recent_time_active_sec(20); - features->set_on_to_dim_sec(10); - features->set_dim_to_screen_off_sec(20); - features->set_time_since_last_mouse_sec(200); - - const UkmMetricMap user_activity_values2 = { - {UserActivity::kEventLogDurationName, 35}, - {UserActivity::kEventTypeName, UserActivityEvent::Event::TIMEOUT}, - {UserActivity::kEventReasonName, UserActivityEvent::Event::IDLE_SLEEP}, - {UserActivity::kBatteryPercentName, 85}, - {UserActivity::kDeviceManagementName, - UserActivityEvent::Features::MANAGED}, - {UserActivity::kDeviceModeName, UserActivityEvent::Features::CLAMSHELL}, - {UserActivity::kDeviceTypeName, UserActivityEvent::Features::CHROMEBOOK}, - {UserActivity::kLastActivityDayName, UserActivityEvent::Features::TUE}, - {UserActivity::kLastActivityTimeName, 2}, - {UserActivity::kLastUserActivityTimeName, 1}, - {UserActivity::kOnBatteryName, base::nullopt}, - {UserActivity::kRecentTimeActiveName, 20}, - {UserActivity::kScreenDimDelayName, 10}, - {UserActivity::kScreenDimToOffDelayName, 20}, - {UserActivity::kSequenceIdName, 2}, - {UserActivity::kTimeSinceLastKeyName, base::nullopt}, - {UserActivity::kTimeSinceLastMouseName, 200}}; - - UpdateOpenTabsURLs(); - LogActivity(user_activity_event_); - LogActivity(user_activity_event2); - - EXPECT_EQ(2, - ukm_entry_checker_.NumNewEntriesRecorded(UserActivity::kEntryName)); - EXPECT_EQ( - 0, ukm_entry_checker_.NumNewEntriesRecorded(UserActivityId::kEntryName)); - - ukm_entry_checker_.ExpectNewEntries( - UserActivity::kEntryName, {user_activity_values_, user_activity_values2}); -} - -} // namespace ml -} // namespace power -} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger_unittest.cc b/chrome/browser/chromeos/power/ml/user_activity_logger_unittest.cc deleted file mode 100644 index 25e9d7b..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logger_unittest.cc +++ /dev/null
@@ -1,560 +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 "chrome/browser/chromeos/power/ml/user_activity_logger.h" - -#include <memory> -#include <vector> - -#include "base/test/test_mock_time_task_runner.h" -#include "base/time/clock.h" -#include "base/timer/timer.h" -#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" -#include "chrome/browser/chromeos/power/ml/fake_boot_clock.h" -#include "chrome/browser/chromeos/power/ml/idle_event_notifier.h" -#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h" -#include "chromeos/dbus/fake_power_manager_client.h" -#include "chromeos/dbus/power_manager/idle.pb.h" -#include "chromeos/dbus/power_manager/power_supply_properties.pb.h" -#include "chromeos/dbus/power_manager_client.h" -#include "components/session_manager/session_manager_types.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/user_activity/user_activity_detector.h" - -namespace chromeos { -namespace power { -namespace ml { - -void EqualEvent(const UserActivityEvent::Event& expected_event, - const UserActivityEvent::Event& result_event) { - EXPECT_EQ(expected_event.type(), result_event.type()); - EXPECT_EQ(expected_event.reason(), result_event.reason()); - EXPECT_EQ(expected_event.log_duration_sec(), result_event.log_duration_sec()); -} - -// Testing logger delegate. -class TestingUserActivityLoggerDelegate : public UserActivityLoggerDelegate { - public: - TestingUserActivityLoggerDelegate() = default; - ~TestingUserActivityLoggerDelegate() override = default; - - const std::vector<UserActivityEvent>& events() const { return events_; } - - int num_update_open_tabs_urls_calls() const { - return num_update_open_tabs_urls_calls_; - } - - // UserActivityLoggerDelegate overrides: - void LogActivity(const UserActivityEvent& event) override { - events_.push_back(event); - } - void UpdateOpenTabsURLs() override { ++num_update_open_tabs_urls_calls_; } - - private: - std::vector<UserActivityEvent> events_; - int num_update_open_tabs_urls_calls_ = 0; - - DISALLOW_COPY_AND_ASSIGN(TestingUserActivityLoggerDelegate); -}; - -class UserActivityLoggerTest : public testing::Test { - public: - UserActivityLoggerTest() - : task_runner_(base::MakeRefCounted<base::TestMockTimeTaskRunner>( - base::TestMockTimeTaskRunner::Type::kBoundToThread)), - scoped_context_(task_runner_.get()) { - fake_power_manager_client_.Init(nullptr); - viz::mojom::VideoDetectorObserverPtr observer; - idle_event_notifier_ = std::make_unique<IdleEventNotifier>( - &fake_power_manager_client_, &user_activity_detector_, - mojo::MakeRequest(&observer)); - activity_logger_ = std::make_unique<UserActivityLogger>( - &delegate_, idle_event_notifier_.get(), &user_activity_detector_, - &fake_power_manager_client_, &session_manager_, - mojo::MakeRequest(&observer), &fake_user_manager_); - activity_logger_->SetTaskRunnerForTesting( - task_runner_, std::make_unique<FakeBootClock>( - task_runner_, base::TimeDelta::FromSeconds(10))); - } - - ~UserActivityLoggerTest() override = default; - - protected: - void ReportUserActivity(const ui::Event* event) { - activity_logger_->OnUserActivity(event); - } - - void ReportIdleEvent(const IdleEventNotifier::ActivityData& data) { - activity_logger_->OnIdleEventObserved(data); - } - - void ReportLidEvent(chromeos::PowerManagerClient::LidState state) { - fake_power_manager_client_.SetLidState(state, base::TimeTicks::UnixEpoch()); - } - - void ReportPowerChangeEvent( - power_manager::PowerSupplyProperties::ExternalPower power, - float battery_percent) { - power_manager::PowerSupplyProperties proto; - proto.set_external_power(power); - proto.set_battery_percent(battery_percent); - fake_power_manager_client_.UpdatePowerProperties(proto); - } - - void ReportTabletModeEvent(chromeos::PowerManagerClient::TabletMode mode) { - fake_power_manager_client_.SetTabletMode(mode, - base::TimeTicks::UnixEpoch()); - } - - void ReportVideoStart() { activity_logger_->OnVideoActivityStarted(); } - - void ReportScreenIdle() { - power_manager::ScreenIdleState proto; - proto.set_off(true); - fake_power_manager_client_.SendScreenIdleStateChanged(proto); - } - - void ReportScreenLocked() { - session_manager_.SetSessionState(session_manager::SessionState::LOCKED); - } - - void ReportSuspend(power_manager::SuspendImminent::Reason reason, - base::TimeDelta sleep_duration) { - fake_power_manager_client_.SendSuspendImminent(reason); - fake_power_manager_client_.SendSuspendDone(sleep_duration); - } - - void ReportInactivityDelays(base::TimeDelta screen_dim_delay, - base::TimeDelta screen_off_delay) { - power_manager::PowerManagementPolicy::Delays proto; - proto.set_screen_dim_ms(screen_dim_delay.InMilliseconds()); - proto.set_screen_off_ms(screen_off_delay.InMilliseconds()); - fake_power_manager_client_.SetInactivityDelays(proto); - } - - const scoped_refptr<base::TestMockTimeTaskRunner>& GetTaskRunner() { - return task_runner_; - } - - TestingUserActivityLoggerDelegate delegate_; - chromeos::FakeChromeUserManager fake_user_manager_; - - private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - const base::TestMockTimeTaskRunner::ScopedContext scoped_context_; - - ui::UserActivityDetector user_activity_detector_; - std::unique_ptr<IdleEventNotifier> idle_event_notifier_; - chromeos::FakePowerManagerClient fake_power_manager_client_; - session_manager::SessionManager session_manager_; - std::unique_ptr<UserActivityLogger> activity_logger_; -}; - -// After an idle event, we have a ui::Event, we should expect one -// UserActivityEvent. -TEST_F(UserActivityLoggerTest, LogAfterIdleEvent) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); - ReportUserActivity(nullptr); - - const std::vector<UserActivityEvent>& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - expected_event.set_log_duration_sec(2); - EqualEvent(expected_event, events[0].event()); -} - -// Get a user event before an idle event, we should not log it. -TEST_F(UserActivityLoggerTest, LogBeforeIdleEvent) { - ReportUserActivity(nullptr); - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - EXPECT_EQ(0U, delegate_.events().size()); -} - -// Get a user event, then an idle event, then another user event, -// we should log the last one. -TEST_F(UserActivityLoggerTest, LogSecondEvent) { - ReportUserActivity(nullptr); - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - // Another user event. - ReportUserActivity(nullptr); - - const std::vector<UserActivityEvent>& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - expected_event.set_log_duration_sec(0); - EqualEvent(expected_event, events[0].event()); -} - -// Log multiple events. -TEST_F(UserActivityLoggerTest, LogMultipleEvents) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - // First user event. - ReportUserActivity(nullptr); - - // Trigger an idle event. - ReportIdleEvent(data); - // Second user event. - GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); - ReportUserActivity(nullptr); - - const std::vector<UserActivityEvent>& events = delegate_.events(); - ASSERT_EQ(2U, events.size()); - - UserActivityEvent::Event expected_event1; - expected_event1.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event1.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - expected_event1.set_log_duration_sec(0); - - UserActivityEvent::Event expected_event2; - expected_event2.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event2.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - expected_event2.set_log_duration_sec(2); - - EqualEvent(expected_event1, events[0].event()); - EqualEvent(expected_event2, events[1].event()); -} - -TEST_F(UserActivityLoggerTest, UserCloseLid) { - ReportLidEvent(chromeos::PowerManagerClient::LidState::OPEN); - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); - ReportLidEvent(chromeos::PowerManagerClient::LidState::CLOSED); - const auto& events = delegate_.events(); - EXPECT_TRUE(events.empty()); -} - -TEST_F(UserActivityLoggerTest, PowerChangeActivity) { - ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 23.0f); - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - // We don't care about battery percentage change, but only power source. - ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 25.0f); - ReportPowerChangeEvent(power_manager::PowerSupplyProperties::DISCONNECTED, - 28.0f); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::POWER_CHANGED); - expected_event.set_log_duration_sec(0); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, VideoActivity) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportVideoStart(); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::VIDEO_ACTIVITY); - expected_event.set_log_duration_sec(0); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SystemIdle) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportScreenIdle(); - GetTaskRunner()->FastForwardUntilNoTasksRemain(); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::TIMEOUT); - expected_event.set_reason(UserActivityEvent::Event::SCREEN_OFF); - expected_event.set_log_duration_sec( - UserActivityLogger::kIdleDelay.InSeconds()); - EqualEvent(expected_event, events[0].event()); -} - -// Test system idle interrupt by user activity. -// We should only observe user activity. -TEST_F(UserActivityLoggerTest, SystemIdleInterrupted) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportScreenIdle(); - // User interruptted after 1 second. - GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(1)); - ReportUserActivity(nullptr); - GetTaskRunner()->FastForwardUntilNoTasksRemain(); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - expected_event.set_log_duration_sec(1); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, ScreenLock) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportScreenLocked(); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::OFF); - expected_event.set_reason(UserActivityEvent::Event::SCREEN_LOCK); - expected_event.set_log_duration_sec(0); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendIdle) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_IDLE, - 2 * UserActivityLogger::kMinSuspendDuration); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::TIMEOUT); - expected_event.set_reason(UserActivityEvent::Event::IDLE_SLEEP); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendIdleCancelled) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_IDLE, - UserActivityLogger::kMinSuspendDuration - - base::TimeDelta::FromSeconds(2)); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendLidClosed) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_LID_CLOSED, - 2 * UserActivityLogger::kMinSuspendDuration); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::OFF); - expected_event.set_reason(UserActivityEvent::Event::LID_CLOSED); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendLidClosedCancelled) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_LID_CLOSED, - UserActivityLogger::kMinSuspendDuration - - base::TimeDelta::FromSeconds(2)); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendOther) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_OTHER, - UserActivityLogger::kMinSuspendDuration); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::OFF); - expected_event.set_reason(UserActivityEvent::Event::MANUAL_SLEEP); - EqualEvent(expected_event, events[0].event()); -} - -TEST_F(UserActivityLoggerTest, SuspendOtherCancelled) { - // Trigger an idle event. - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - - ReportSuspend(power_manager::SuspendImminent_Reason_OTHER, - UserActivityLogger::kMinSuspendDuration - - base::TimeDelta::FromSeconds(2)); - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - UserActivityEvent::Event expected_event; - expected_event.set_type(UserActivityEvent::Event::REACTIVATE); - expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); - EqualEvent(expected_event, events[0].event()); -} - -// Test feature extraction. -TEST_F(UserActivityLoggerTest, FeatureExtraction) { - ReportLidEvent(chromeos::PowerManagerClient::LidState::OPEN); - ReportTabletModeEvent(chromeos::PowerManagerClient::TabletMode::UNSUPPORTED); - ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 23.0f); - - IdleEventNotifier::ActivityData data; - data.last_activity_day = UserActivityEvent_Features_DayOfWeek_MON; - data.last_activity_time_of_day = base::TimeDelta::FromSeconds(100); - data.recent_time_active = base::TimeDelta::FromSeconds(10); - data.time_since_last_mouse = base::TimeDelta::FromSeconds(20); - data.time_since_last_touch = base::TimeDelta::FromSeconds(30); - data.video_playing_time = base::TimeDelta::FromSeconds(90); - data.time_since_video_ended = base::TimeDelta::FromSeconds(2); - data.key_events_in_last_hour = 0; - data.mouse_events_in_last_hour = 10; - data.touch_events_in_last_hour = 20; - - ReportIdleEvent(data); - ReportUserActivity(nullptr); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - const UserActivityEvent::Features& features = events[0].features(); - EXPECT_EQ(UserActivityEvent::Features::CLAMSHELL, features.device_mode()); - EXPECT_EQ(23.0f, features.battery_percent()); - EXPECT_FALSE(features.on_battery()); - EXPECT_EQ(UserActivityEvent::Features::UNMANAGED, - features.device_management()); - EXPECT_EQ(UserActivityEvent_Features_DayOfWeek_MON, - features.last_activity_day()); - EXPECT_EQ(100, features.last_activity_time_sec()); - EXPECT_EQ(10, features.recent_time_active_sec()); - EXPECT_EQ(20, features.time_since_last_mouse_sec()); - EXPECT_EQ(30, features.time_since_last_touch_sec()); - EXPECT_EQ(90, features.video_playing_time_sec()); - EXPECT_EQ(2, features.time_since_video_ended_sec()); - EXPECT_EQ(0, features.key_events_in_last_hour()); - EXPECT_EQ(10, features.mouse_events_in_last_hour()); - EXPECT_EQ(20, features.touch_events_in_last_hour()); - EXPECT_FALSE(features.has_last_user_activity_time_sec()); - EXPECT_FALSE(features.has_time_since_last_key_sec()); -} - -TEST_F(UserActivityLoggerTest, ManagedDevice) { - fake_user_manager_.set_is_enterprise_managed(true); - - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - ReportUserActivity(nullptr); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - const UserActivityEvent::Features& features = events[0].features(); - EXPECT_EQ(UserActivityEvent::Features::MANAGED, features.device_management()); -} - -TEST_F(UserActivityLoggerTest, UpdateOpenTabsURLsCalledTimes) { - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - ReportUserActivity(nullptr); - EXPECT_EQ(1, delegate_.num_update_open_tabs_urls_calls()); - - ReportIdleEvent({}); - ReportUserActivity(nullptr); - EXPECT_EQ(2, delegate_.num_update_open_tabs_urls_calls()); -} - -TEST_F(UserActivityLoggerTest, DimAndOffDelays) { - ReportInactivityDelays( - base::TimeDelta::FromMilliseconds(2000) /* screen_dim_delay */, - base::TimeDelta::FromMilliseconds(3000) /* screen_off_delay */); - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - ReportUserActivity(nullptr); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - const UserActivityEvent::Features& features = events[0].features(); - EXPECT_EQ(2, features.on_to_dim_sec()); - EXPECT_EQ(1, features.dim_to_screen_off_sec()); -} - -TEST_F(UserActivityLoggerTest, DimDelays) { - ReportInactivityDelays( - base::TimeDelta::FromMilliseconds(2000) /* screen_dim_delay */, - base::TimeDelta() /* screen_off_delay */); - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - ReportUserActivity(nullptr); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - const UserActivityEvent::Features& features = events[0].features(); - EXPECT_EQ(2, features.on_to_dim_sec()); - EXPECT_TRUE(!features.has_dim_to_screen_off_sec()); -} - -TEST_F(UserActivityLoggerTest, OffDelays) { - ReportInactivityDelays( - base::TimeDelta() /* screen_dim_delay */, - base::TimeDelta::FromMilliseconds(4000) /* screen_off_delay */); - const IdleEventNotifier::ActivityData data; - ReportIdleEvent(data); - ReportUserActivity(nullptr); - - const auto& events = delegate_.events(); - ASSERT_EQ(1U, events.size()); - - const UserActivityEvent::Features& features = events[0].features(); - EXPECT_EQ(4, features.dim_to_screen_off_sec()); - EXPECT_TRUE(!features.has_on_to_dim_sec()); -} - -} // namespace ml -} // namespace power -} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logging_controller.h b/chrome/browser/chromeos/power/ml/user_activity_logging_controller.h deleted file mode 100644 index 37a5f1c..0000000 --- a/chrome/browser/chromeos/power/ml/user_activity_logging_controller.h +++ /dev/null
@@ -1,38 +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. - -#ifndef CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGING_CONTROLLER_H_ -#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGING_CONTROLLER_H_ - -#include <memory> - -#include "chrome/browser/chromeos/power/ml/idle_event_notifier.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger_delegate_ukm.h" - -namespace chromeos { -namespace power { -namespace ml { - -// This controller class sets up and destroys all the components associated with -// user activity logging (IdleEventNotifier, UserActivityLoggerDelegate and -// UserActivityLogger). -class UserActivityLoggingController { - public: - UserActivityLoggingController(); - ~UserActivityLoggingController(); - - private: - std::unique_ptr<IdleEventNotifier> idle_event_notifier_; - UserActivityLoggerDelegateUkm user_activity_logger_delegate_; - std::unique_ptr<UserActivityLogger> user_activity_logger_; - - DISALLOW_COPY_AND_ASSIGN(UserActivityLoggingController); -}; - -} // namespace ml -} // namespace power -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGING_CONTROLLER_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger.cc b/chrome/browser/chromeos/power/ml/user_activity_manager.cc similarity index 72% rename from chrome/browser/chromeos/power/ml/user_activity_logger.cc rename to chrome/browser/chromeos/power/ml/user_activity_manager.cc index 2883e55..ffff22a 100644 --- a/chrome/browser/chromeos/power/ml/user_activity_logger.cc +++ b/chrome/browser/chromeos/power/ml/user_activity_manager.cc
@@ -2,21 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/power/ml/user_activity_logger.h" +#include "chrome/browser/chromeos/power/ml/user_activity_manager.h" #include <cmath> #include "base/timer/timer.h" #include "chrome/browser/chromeos/power/ml/real_boot_clock.h" +#include "chrome/browser/resource_coordinator/tab_metrics_logger.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" #include "chromeos/system/devicetype.h" +#include "components/ukm/content/source_url_recorder.h" +#include "content/public/common/page_importance_signals.h" namespace chromeos { namespace power { namespace ml { -UserActivityLogger::UserActivityLogger( - UserActivityLoggerDelegate* delegate, +UserActivityManager::UserActivityManager( + UserActivityUkmLogger* ukm_logger, IdleEventNotifier* idle_event_notifier, ui::UserActivityDetector* detector, chromeos::PowerManagerClient* power_manager_client, @@ -24,7 +31,7 @@ viz::mojom::VideoDetectorObserverRequest request, const chromeos::ChromeUserManager* user_manager) : boot_clock_(std::make_unique<RealBootClock>()), - logger_delegate_(delegate), + ukm_logger_(ukm_logger), idle_event_observer_(this), user_activity_observer_(this), power_manager_client_observer_(this), @@ -33,7 +40,7 @@ binding_(this, std::move(request)), user_manager_(user_manager), weak_ptr_factory_(this) { - DCHECK(logger_delegate_); + DCHECK(ukm_logger_); DCHECK(idle_event_notifier); idle_event_observer_.Add(idle_event_notifier); @@ -44,10 +51,10 @@ power_manager_client_observer_.Add(power_manager_client); power_manager_client->RequestStatusUpdate(); power_manager_client->GetSwitchStates( - base::BindOnce(&UserActivityLogger::OnReceiveSwitchStates, + base::BindOnce(&UserActivityManager::OnReceiveSwitchStates, weak_ptr_factory_.GetWeakPtr())); power_manager_client->GetInactivityDelays( - base::BindOnce(&UserActivityLogger::OnReceiveInactivityDelays, + base::BindOnce(&UserActivityManager::OnReceiveInactivityDelays, weak_ptr_factory_.GetWeakPtr())); DCHECK(session_manager); @@ -60,20 +67,20 @@ } } -UserActivityLogger::~UserActivityLogger() = default; +UserActivityManager::~UserActivityManager() = default; -void UserActivityLogger::OnUserActivity(const ui::Event* /* event */) { +void UserActivityManager::OnUserActivity(const ui::Event* /* event */) { MaybeLogEvent(UserActivityEvent::Event::REACTIVATE, UserActivityEvent::Event::USER_ACTIVITY); } -void UserActivityLogger::LidEventReceived( +void UserActivityManager::LidEventReceived( chromeos::PowerManagerClient::LidState state, const base::TimeTicks& /* timestamp */) { lid_state_ = state; } -void UserActivityLogger::PowerChanged( +void UserActivityManager::PowerChanged( const power_manager::PowerSupplyProperties& proto) { if (external_power_.has_value()) { bool power_source_changed = (*external_power_ != proto.external_power()); @@ -91,29 +98,29 @@ } } -void UserActivityLogger::TabletModeEventReceived( +void UserActivityManager::TabletModeEventReceived( chromeos::PowerManagerClient::TabletMode mode, const base::TimeTicks& /* timestamp */) { tablet_mode_ = mode; } -void UserActivityLogger::ScreenIdleStateChanged( +void UserActivityManager::ScreenIdleStateChanged( const power_manager::ScreenIdleState& proto) { if (proto.off()) { screen_idle_timer_.Start( FROM_HERE, kIdleDelay, - base::Bind(&UserActivityLogger::MaybeLogEvent, base::Unretained(this), + base::Bind(&UserActivityManager::MaybeLogEvent, base::Unretained(this), UserActivityEvent::Event::TIMEOUT, UserActivityEvent::Event::SCREEN_OFF)); } } -void UserActivityLogger::SuspendImminent( +void UserActivityManager::SuspendImminent( power_manager::SuspendImminent::Reason reason) { suspend_reason_ = reason; } -void UserActivityLogger::SuspendDone(const base::TimeDelta& sleep_duration) { +void UserActivityManager::SuspendDone(const base::TimeDelta& sleep_duration) { if (!suspend_reason_) return; @@ -154,23 +161,23 @@ suspend_reason_ = base::nullopt; } -void UserActivityLogger::InactivityDelaysChanged( +void UserActivityManager::InactivityDelaysChanged( const power_manager::PowerManagementPolicy::Delays& delays) { OnReceiveInactivityDelays(delays); } -void UserActivityLogger::OnVideoActivityStarted() { +void UserActivityManager::OnVideoActivityStarted() { MaybeLogEvent(UserActivityEvent::Event::REACTIVATE, UserActivityEvent::Event::VIDEO_ACTIVITY); } -void UserActivityLogger::OnIdleEventObserved( +void UserActivityManager::OnIdleEventObserved( const IdleEventNotifier::ActivityData& activity_data) { idle_event_start_since_boot_ = boot_clock_->GetTimeSinceBoot(); ExtractFeatures(activity_data); } -void UserActivityLogger::OnSessionStateChanged() { +void UserActivityManager::OnSessionStateChanged() { DCHECK(session_manager_); const bool was_locked = screen_is_locked_; screen_is_locked_ = session_manager_->IsScreenLocked(); @@ -181,12 +188,12 @@ } // static -constexpr base::TimeDelta UserActivityLogger::kIdleDelay; +constexpr base::TimeDelta UserActivityManager::kIdleDelay; // static -constexpr base::TimeDelta UserActivityLogger::kMinSuspendDuration; +constexpr base::TimeDelta UserActivityManager::kMinSuspendDuration; -void UserActivityLogger::OnReceiveSwitchStates( +void UserActivityManager::OnReceiveSwitchStates( base::Optional<chromeos::PowerManagerClient::SwitchStates> switch_states) { if (switch_states.has_value()) { lid_state_ = switch_states->lid_state; @@ -194,7 +201,7 @@ } } -void UserActivityLogger::OnReceiveInactivityDelays( +void UserActivityManager::OnReceiveInactivityDelays( base::Optional<power_manager::PowerManagementPolicy::Delays> delays) { if (delays.has_value()) { screen_dim_delay_ = @@ -204,7 +211,7 @@ } } -void UserActivityLogger::ExtractFeatures( +void UserActivityManager::ExtractFeatures( const IdleEventNotifier::ActivityData& activity_data) { features_.Clear(); @@ -292,10 +299,64 @@ UserActivityEvent::Features::UNKNOWN_MANAGEMENT); } - logger_delegate_->UpdateOpenTabsURLs(); + UpdateOpenTabsURLs(); } -void UserActivityLogger::MaybeLogEvent( +void UserActivityManager::UpdateOpenTabsURLs() { + open_tabs_.clear(); + bool topmost_browser_found = false; + BrowserList* browser_list = BrowserList::GetInstance(); + DCHECK(browser_list); + + // Go through all browsers starting from last active ones. + for (auto browser_iterator = browser_list->begin_last_active(); + browser_iterator != browser_list->end_last_active(); + ++browser_iterator) { + Browser* browser = *browser_iterator; + + const bool is_browser_focused = browser->window()->IsActive(); + const bool is_browser_visible = + browser->window()->GetNativeWindow()->IsVisible(); + + bool is_topmost_browser = false; + if (is_browser_visible && !topmost_browser_found) { + is_topmost_browser = true; + topmost_browser_found = true; + } + + if (browser->profile()->IsOffTheRecord()) + continue; + + const TabStripModel* const tab_strip_model = browser->tab_strip_model(); + DCHECK(tab_strip_model); + + const int active_tab_index = tab_strip_model->active_index(); + + for (int i = 0; i < tab_strip_model->count(); ++i) { + content::WebContents* contents = tab_strip_model->GetWebContentsAt(i); + DCHECK(contents); + ukm::SourceId source_id = + ukm::GetSourceIdForWebContentsDocument(contents); + if (source_id == ukm::kInvalidSourceId) + continue; + + const TabProperty tab_property = { + i == active_tab_index, + is_browser_focused, + is_browser_visible, + is_topmost_browser, + TabMetricsLogger::GetSiteEngagementScore(contents), + TabMetricsLogger::GetContentTypeFromMimeType( + contents->GetContentsMimeType()), + contents->GetPageImportanceSignals().had_form_interaction}; + + open_tabs_.insert( + std::pair<ukm::SourceId, TabProperty>(source_id, tab_property)); + } + } +} + +void UserActivityManager::MaybeLogEvent( UserActivityEvent::Event::Type type, UserActivityEvent::Event::Reason reason) { if (!idle_event_start_since_boot_) @@ -313,11 +374,11 @@ *activity_event.mutable_features() = features_; // Log to metrics. - logger_delegate_->LogActivity(activity_event); + ukm_logger_->LogActivity(activity_event, open_tabs_); idle_event_start_since_boot_ = base::nullopt; } -void UserActivityLogger::SetTaskRunnerForTesting( +void UserActivityManager::SetTaskRunnerForTesting( scoped_refptr<base::SequencedTaskRunner> task_runner, std::unique_ptr<BootClock> test_boot_clock) { screen_idle_timer_.SetTaskRunner(task_runner);
diff --git a/chrome/browser/chromeos/power/ml/user_activity_logger.h b/chrome/browser/chromeos/power/ml/user_activity_manager.h similarity index 72% rename from chrome/browser/chromeos/power/ml/user_activity_logger.h rename to chrome/browser/chromeos/power/ml/user_activity_manager.h index fa9dcc6..bcc6d47 100644 --- a/chrome/browser/chromeos/power/ml/user_activity_logger.h +++ b/chrome/browser/chromeos/power/ml/user_activity_manager.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_H_ -#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_H_ +#ifndef CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_MANAGER_H_ +#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_MANAGER_H_ #include "base/macros.h" #include "base/optional.h" @@ -14,14 +14,17 @@ #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" #include "chrome/browser/chromeos/power/ml/idle_event_notifier.h" #include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" -#include "chrome/browser/chromeos/power/ml/user_activity_logger_delegate.h" +#include "chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h" +#include "chrome/browser/resource_coordinator/tab_metrics_event.pb.h" #include "chromeos/dbus/power_manager/idle.pb.h" #include "chromeos/dbus/power_manager/policy.pb.h" #include "chromeos/dbus/power_manager/suspend.pb.h" #include "chromeos/dbus/power_manager_client.h" #include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager_observer.h" +#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/viz/public/interfaces/compositing/video_detector_observer.mojom.h" +#include "ui/aura/window.h" #include "ui/base/user_activity/user_activity_detector.h" #include "ui/base/user_activity/user_activity_observer.h" @@ -31,13 +34,30 @@ class BootClock; +struct TabProperty { + // Whether the tab is the selected one in its containing browser. + bool is_active; + // Whether the containing browser is in focus. + bool is_browser_focused; + // Whether the containing browser is visible. + bool is_browser_visible; + // Whether the containing browser is the topmost one on the screen. + bool is_topmost_browser; + // Tab URL's engagement score. -1 if engagement service is disabled. + int engagement_score; + // Tab content type. + metrics::TabMetricsEvent::ContentType content_type; + // Whether user has form entry, i.e. text input. + bool has_form_entry; +}; + // Logs user activity after an idle event is observed. // TODO(renjieliu): Add power-related activity as well. -class UserActivityLogger : public ui::UserActivityObserver, - public IdleEventNotifier::Observer, - public PowerManagerClient::Observer, - public viz::mojom::VideoDetectorObserver, - public session_manager::SessionManagerObserver { +class UserActivityManager : public ui::UserActivityObserver, + public IdleEventNotifier::Observer, + public PowerManagerClient::Observer, + public viz::mojom::VideoDetectorObserver, + public session_manager::SessionManagerObserver { public: // Delay after screen idle event, used to trigger TIMEOUT for user activity // logging. @@ -49,14 +69,14 @@ static constexpr base::TimeDelta kMinSuspendDuration = base::TimeDelta::FromSeconds(10); - UserActivityLogger(UserActivityLoggerDelegate* delegate, - IdleEventNotifier* idle_event_notifier, - ui::UserActivityDetector* detector, - chromeos::PowerManagerClient* power_manager_client, - session_manager::SessionManager* session_manager, - viz::mojom::VideoDetectorObserverRequest request, - const chromeos::ChromeUserManager* user_manager); - ~UserActivityLogger() override; + UserActivityManager(UserActivityUkmLogger* ukm_logger, + IdleEventNotifier* idle_event_notifier, + ui::UserActivityDetector* detector, + chromeos::PowerManagerClient* power_manager_client, + session_manager::SessionManager* session_manager, + viz::mojom::VideoDetectorObserverRequest request, + const chromeos::ChromeUserManager* user_manager); + ~UserActivityManager() override; // ui::UserActivityObserver overrides. void OnUserActivity(const ui::Event* event) override; @@ -86,7 +106,7 @@ void OnSessionStateChanged() override; private: - friend class UserActivityLoggerTest; + friend class UserActivityManagerTest; // Updates lid state and tablet mode from received switch states. void OnReceiveSwitchStates( @@ -95,6 +115,9 @@ void OnReceiveInactivityDelays( base::Optional<power_manager::PowerManagementPolicy::Delays> delays); + // Updates |open_tabs_| to hold current information about all open tabs. + void UpdateOpenTabsURLs(); + // Extracts features from last known activity data and from device states. void ExtractFeatures(const IdleEventNotifier::ActivityData& activity_data); @@ -107,6 +130,9 @@ scoped_refptr<base::SequencedTaskRunner> task_runner, std::unique_ptr<BootClock> test_boot_clock); + // Open tab properties, indexed by the source IDs of their URLs. + std::map<ukm::SourceId, TabProperty> open_tabs_; + // Time when an idle event is received and we start logging. Null if an idle // event hasn't been observed. base::Optional<base::TimeDelta> idle_event_start_since_boot_; @@ -139,7 +165,7 @@ // It is RealBootClock, but will be set to FakeBootClock for tests. std::unique_ptr<BootClock> boot_clock_; - UserActivityLoggerDelegate* const logger_delegate_; + UserActivityUkmLogger* const ukm_logger_; ScopedObserver<IdleEventNotifier, IdleEventNotifier::Observer> idle_event_observer_; @@ -165,13 +191,13 @@ base::TimeDelta screen_dim_delay_; base::TimeDelta screen_off_delay_; - base::WeakPtrFactory<UserActivityLogger> weak_ptr_factory_; + base::WeakPtrFactory<UserActivityManager> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(UserActivityLogger); + DISALLOW_COPY_AND_ASSIGN(UserActivityManager); }; } // namespace ml } // namespace power } // namespace chromeos -#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_LOGGER_H_ +#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_MANAGER_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc b/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc new file mode 100644 index 0000000..2b3c68c6f3 --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_manager_unittest.cc
@@ -0,0 +1,808 @@ +// 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 "chrome/browser/chromeos/power/ml/user_activity_manager.h" + +#include <memory> +#include <vector> + +#include "base/test/test_mock_time_task_runner.h" +#include "base/time/clock.h" +#include "base/timer/timer.h" +#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" +#include "chrome/browser/chromeos/power/ml/fake_boot_clock.h" +#include "chrome/browser/chromeos/power/ml/idle_event_notifier.h" +#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" +#include "chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h" +#include "chrome/browser/engagement/site_engagement_service.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/tabs/tab_activity_simulator.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" +#include "chrome/test/base/test_browser_window_aura.h" +#include "chrome/test/base/testing_profile.h" +#include "chromeos/dbus/fake_power_manager_client.h" +#include "chromeos/dbus/power_manager/idle.pb.h" +#include "chromeos/dbus/power_manager/power_supply_properties.pb.h" +#include "chromeos/dbus/power_manager_client.h" +#include "components/session_manager/session_manager_types.h" +#include "components/ukm/test_ukm_recorder.h" +#include "components/ukm/ukm_source.h" +#include "content/public/browser/web_contents.h" +#include "content/public/test/web_contents_tester.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/user_activity/user_activity_detector.h" + +namespace chromeos { +namespace power { +namespace ml { + +using content::WebContentsTester; + +void EqualEvent(const UserActivityEvent::Event& expected_event, + const UserActivityEvent::Event& result_event) { + EXPECT_EQ(expected_event.type(), result_event.type()); + EXPECT_EQ(expected_event.reason(), result_event.reason()); + EXPECT_EQ(expected_event.log_duration_sec(), result_event.log_duration_sec()); +} + +// Testing UKM logger. +class TestingUserActivityUkmLogger : public UserActivityUkmLogger { + public: + TestingUserActivityUkmLogger() = default; + ~TestingUserActivityUkmLogger() override = default; + + const std::vector<UserActivityEvent>& events() const { return events_; } + + // UserActivityUkmLogger overrides: + void LogActivity( + const UserActivityEvent& event, + const std::map<ukm::SourceId, TabProperty>& source_ids) override { + events_.push_back(event); + } + + private: + std::vector<UserActivityEvent> events_; + + DISALLOW_COPY_AND_ASSIGN(TestingUserActivityUkmLogger); +}; + +class UserActivityManagerTest : public ChromeRenderViewHostTestHarness { + public: + UserActivityManagerTest() + : task_runner_(base::MakeRefCounted<base::TestMockTimeTaskRunner>()) { + fake_power_manager_client_.Init(nullptr); + viz::mojom::VideoDetectorObserverPtr observer; + idle_event_notifier_ = std::make_unique<IdleEventNotifier>( + &fake_power_manager_client_, &user_activity_detector_, + mojo::MakeRequest(&observer)); + activity_logger_ = std::make_unique<UserActivityManager>( + &delegate_, idle_event_notifier_.get(), &user_activity_detector_, + &fake_power_manager_client_, &session_manager_, + mojo::MakeRequest(&observer), &fake_user_manager_); + activity_logger_->SetTaskRunnerForTesting( + task_runner_, std::make_unique<FakeBootClock>( + task_runner_, base::TimeDelta::FromSeconds(10))); + } + + ~UserActivityManagerTest() override = default; + + protected: + void ReportUserActivity(const ui::Event* event) { + activity_logger_->OnUserActivity(event); + } + + void ReportIdleEvent(const IdleEventNotifier::ActivityData& data) { + activity_logger_->OnIdleEventObserved(data); + } + + void ReportLidEvent(chromeos::PowerManagerClient::LidState state) { + fake_power_manager_client_.SetLidState(state, base::TimeTicks::UnixEpoch()); + } + + void ReportPowerChangeEvent( + power_manager::PowerSupplyProperties::ExternalPower power, + float battery_percent) { + power_manager::PowerSupplyProperties proto; + proto.set_external_power(power); + proto.set_battery_percent(battery_percent); + fake_power_manager_client_.UpdatePowerProperties(proto); + } + + void ReportTabletModeEvent(chromeos::PowerManagerClient::TabletMode mode) { + fake_power_manager_client_.SetTabletMode(mode, + base::TimeTicks::UnixEpoch()); + } + + void ReportVideoStart() { activity_logger_->OnVideoActivityStarted(); } + + void ReportScreenIdle() { + power_manager::ScreenIdleState proto; + proto.set_off(true); + fake_power_manager_client_.SendScreenIdleStateChanged(proto); + } + + void ReportScreenLocked() { + session_manager_.SetSessionState(session_manager::SessionState::LOCKED); + } + + void ReportSuspend(power_manager::SuspendImminent::Reason reason, + base::TimeDelta sleep_duration) { + fake_power_manager_client_.SendSuspendImminent(reason); + fake_power_manager_client_.SendSuspendDone(sleep_duration); + } + + void ReportInactivityDelays(base::TimeDelta screen_dim_delay, + base::TimeDelta screen_off_delay) { + power_manager::PowerManagementPolicy::Delays proto; + proto.set_screen_dim_ms(screen_dim_delay.InMilliseconds()); + proto.set_screen_off_ms(screen_off_delay.InMilliseconds()); + fake_power_manager_client_.SetInactivityDelays(proto); + } + + void UpdateOpenTabsURLs() { activity_logger_->UpdateOpenTabsURLs(); } + + // Creates a test browser window and sets its visibility, activity and + // incognito status. + std::unique_ptr<Browser> CreateTestBrowser(bool is_visible, + bool is_focused, + bool is_incognito = false) { + Profile* const original_profile = profile(); + Profile* const used_profile = + is_incognito ? original_profile->GetOffTheRecordProfile() + : original_profile; + Browser::CreateParams params(used_profile, true); + + auto dummy_window = std::make_unique<aura::Window>(nullptr); + dummy_window->Init(ui::LAYER_SOLID_COLOR); + root_window()->AddChild(dummy_window.get()); + dummy_window->SetBounds(gfx::Rect(root_window()->bounds().size())); + if (is_visible) { + dummy_window->Show(); + } else { + dummy_window->Hide(); + } + + std::unique_ptr<Browser> browser = + chrome::CreateBrowserWithAuraTestWindowForParams( + std::move(dummy_window), ¶ms); + if (is_focused) { + browser->window()->Activate(); + } else { + browser->window()->Deactivate(); + } + return browser; + } + + // Adds a tab with specified url to the tab strip model. Also optionally sets + // the tab to be the active one in the tab strip model. + // If |mime_type| is an empty string, the content has a default text type. + // TODO(jiameng): there doesn't seem to be a way to set form entry (via + // page importance signal). Check if there's some other way to set it. + void CreateTestWebContents(TabStripModel* const tab_strip_model, + const GURL& url, + bool is_active, + const std::string& mime_type = "") { + DCHECK(tab_strip_model); + DCHECK(!url.is_empty()); + content::WebContents* contents = + tab_activity_simulator_.AddWebContentsAndNavigate(tab_strip_model, url); + if (is_active) { + tab_strip_model->ActivateTabAt(tab_strip_model->count() - 1, false); + } + if (!mime_type.empty()) + WebContentsTester::For(contents)->SetMainFrameMimeType(mime_type); + + WebContentsTester::For(contents)->TestSetIsLoading(false); + } + + ukm::SourceId GetSourceIdForUrl(const GURL& url) { + const ukm::UkmSource* source = ukm_recorder_.GetSourceForUrl(url); + DCHECK(source); + return source->id(); + } + + void CheckTabsProperties( + const std::map<ukm::SourceId, TabProperty>& expected_map) { + // Does not just use std::equal to give a better sense of where they fail + // when debugging. + const auto& actual_map = activity_logger_->open_tabs_; + EXPECT_EQ(expected_map.size(), actual_map.size()); + for (const auto& expected_value : expected_map) { + const auto& it = actual_map.find(expected_value.first); + ASSERT_TRUE(it != actual_map.end()) + << "Failed to find a match for " << expected_value.first; + const TabProperty& actual = it->second; + const TabProperty& expected = expected_value.second; + EXPECT_EQ(expected.is_active, actual.is_active) << expected_value.first; + EXPECT_EQ(expected.is_browser_focused, actual.is_browser_focused) + << expected_value.first; + EXPECT_EQ(expected.is_browser_visible, actual.is_browser_visible) + << expected_value.first; + EXPECT_EQ(expected.is_topmost_browser, actual.is_topmost_browser) + << expected_value.first; + EXPECT_EQ(expected.engagement_score, actual.engagement_score) + << expected_value.first; + EXPECT_EQ(expected.content_type, actual.content_type) + << expected_value.first; + EXPECT_EQ(expected.has_form_entry, actual.has_form_entry) + << expected_value.first; + } + } + + const scoped_refptr<base::TestMockTimeTaskRunner>& GetTaskRunner() { + return task_runner_; + } + + TestingUserActivityUkmLogger delegate_; + chromeos::FakeChromeUserManager fake_user_manager_; + // Only used to get SourceIds for URLs. + ukm::TestAutoSetUkmRecorder ukm_recorder_; + TabActivitySimulator tab_activity_simulator_; + + const GURL url1_ = GURL("https://example1.com/"); + const GURL url2_ = GURL("https://example2.com/"); + const GURL url3_ = GURL("https://example3.com/"); + const GURL url4_ = GURL("https://example4.com/"); + + private: + scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; + + ui::UserActivityDetector user_activity_detector_; + std::unique_ptr<IdleEventNotifier> idle_event_notifier_; + chromeos::FakePowerManagerClient fake_power_manager_client_; + session_manager::SessionManager session_manager_; + std::unique_ptr<UserActivityManager> activity_logger_; + + DISALLOW_COPY_AND_ASSIGN(UserActivityManagerTest); +}; + +// After an idle event, we have a ui::Event, we should expect one +// UserActivityEvent. +TEST_F(UserActivityManagerTest, LogAfterIdleEvent) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); + ReportUserActivity(nullptr); + + const std::vector<UserActivityEvent>& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event.set_log_duration_sec(2); + EqualEvent(expected_event, events[0].event()); +} + +// Get a user event before an idle event, we should not log it. +TEST_F(UserActivityManagerTest, LogBeforeIdleEvent) { + ReportUserActivity(nullptr); + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + EXPECT_EQ(0U, delegate_.events().size()); +} + +// Get a user event, then an idle event, then another user event, +// we should log the last one. +TEST_F(UserActivityManagerTest, LogSecondEvent) { + ReportUserActivity(nullptr); + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + // Another user event. + ReportUserActivity(nullptr); + + const std::vector<UserActivityEvent>& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event.set_log_duration_sec(0); + EqualEvent(expected_event, events[0].event()); +} + +// Log multiple events. +TEST_F(UserActivityManagerTest, LogMultipleEvents) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + // First user event. + ReportUserActivity(nullptr); + + // Trigger an idle event. + ReportIdleEvent(data); + // Second user event. + GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); + ReportUserActivity(nullptr); + + const std::vector<UserActivityEvent>& events = delegate_.events(); + ASSERT_EQ(2U, events.size()); + + UserActivityEvent::Event expected_event1; + expected_event1.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event1.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event1.set_log_duration_sec(0); + + UserActivityEvent::Event expected_event2; + expected_event2.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event2.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event2.set_log_duration_sec(2); + + EqualEvent(expected_event1, events[0].event()); + EqualEvent(expected_event2, events[1].event()); +} + +TEST_F(UserActivityManagerTest, UserCloseLid) { + ReportLidEvent(chromeos::PowerManagerClient::LidState::OPEN); + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(2)); + ReportLidEvent(chromeos::PowerManagerClient::LidState::CLOSED); + const auto& events = delegate_.events(); + EXPECT_TRUE(events.empty()); +} + +TEST_F(UserActivityManagerTest, PowerChangeActivity) { + ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 23.0f); + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + // We don't care about battery percentage change, but only power source. + ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 25.0f); + ReportPowerChangeEvent(power_manager::PowerSupplyProperties::DISCONNECTED, + 28.0f); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::POWER_CHANGED); + expected_event.set_log_duration_sec(0); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, VideoActivity) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportVideoStart(); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::VIDEO_ACTIVITY); + expected_event.set_log_duration_sec(0); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SystemIdle) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportScreenIdle(); + GetTaskRunner()->FastForwardUntilNoTasksRemain(); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::TIMEOUT); + expected_event.set_reason(UserActivityEvent::Event::SCREEN_OFF); + expected_event.set_log_duration_sec( + UserActivityManager::kIdleDelay.InSeconds()); + EqualEvent(expected_event, events[0].event()); +} + +// Test system idle interrupt by user activity. +// We should only observe user activity. +TEST_F(UserActivityManagerTest, SystemIdleInterrupted) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportScreenIdle(); + // User interruptted after 1 second. + GetTaskRunner()->FastForwardBy(base::TimeDelta::FromSeconds(1)); + ReportUserActivity(nullptr); + GetTaskRunner()->FastForwardUntilNoTasksRemain(); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + expected_event.set_log_duration_sec(1); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, ScreenLock) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportScreenLocked(); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::OFF); + expected_event.set_reason(UserActivityEvent::Event::SCREEN_LOCK); + expected_event.set_log_duration_sec(0); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendIdle) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_IDLE, + 2 * UserActivityManager::kMinSuspendDuration); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::TIMEOUT); + expected_event.set_reason(UserActivityEvent::Event::IDLE_SLEEP); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendIdleCancelled) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_IDLE, + UserActivityManager::kMinSuspendDuration - + base::TimeDelta::FromSeconds(2)); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendLidClosed) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_LID_CLOSED, + 2 * UserActivityManager::kMinSuspendDuration); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::OFF); + expected_event.set_reason(UserActivityEvent::Event::LID_CLOSED); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendLidClosedCancelled) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_LID_CLOSED, + UserActivityManager::kMinSuspendDuration - + base::TimeDelta::FromSeconds(2)); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendOther) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_OTHER, + UserActivityManager::kMinSuspendDuration); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::OFF); + expected_event.set_reason(UserActivityEvent::Event::MANUAL_SLEEP); + EqualEvent(expected_event, events[0].event()); +} + +TEST_F(UserActivityManagerTest, SuspendOtherCancelled) { + // Trigger an idle event. + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + + ReportSuspend(power_manager::SuspendImminent_Reason_OTHER, + UserActivityManager::kMinSuspendDuration - + base::TimeDelta::FromSeconds(2)); + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + UserActivityEvent::Event expected_event; + expected_event.set_type(UserActivityEvent::Event::REACTIVATE); + expected_event.set_reason(UserActivityEvent::Event::USER_ACTIVITY); + EqualEvent(expected_event, events[0].event()); +} + +// Test feature extraction. +TEST_F(UserActivityManagerTest, FeatureExtraction) { + ReportLidEvent(chromeos::PowerManagerClient::LidState::OPEN); + ReportTabletModeEvent(chromeos::PowerManagerClient::TabletMode::UNSUPPORTED); + ReportPowerChangeEvent(power_manager::PowerSupplyProperties::AC, 23.0f); + + IdleEventNotifier::ActivityData data; + data.last_activity_day = UserActivityEvent_Features_DayOfWeek_MON; + data.last_activity_time_of_day = base::TimeDelta::FromSeconds(100); + data.recent_time_active = base::TimeDelta::FromSeconds(10); + data.time_since_last_mouse = base::TimeDelta::FromSeconds(20); + data.time_since_last_touch = base::TimeDelta::FromSeconds(30); + data.video_playing_time = base::TimeDelta::FromSeconds(90); + data.time_since_video_ended = base::TimeDelta::FromSeconds(2); + data.key_events_in_last_hour = 0; + data.mouse_events_in_last_hour = 10; + data.touch_events_in_last_hour = 20; + + ReportIdleEvent(data); + ReportUserActivity(nullptr); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + const UserActivityEvent::Features& features = events[0].features(); + EXPECT_EQ(UserActivityEvent::Features::CLAMSHELL, features.device_mode()); + EXPECT_EQ(23.0f, features.battery_percent()); + EXPECT_FALSE(features.on_battery()); + EXPECT_EQ(UserActivityEvent::Features::UNMANAGED, + features.device_management()); + EXPECT_EQ(UserActivityEvent_Features_DayOfWeek_MON, + features.last_activity_day()); + EXPECT_EQ(100, features.last_activity_time_sec()); + EXPECT_EQ(10, features.recent_time_active_sec()); + EXPECT_EQ(20, features.time_since_last_mouse_sec()); + EXPECT_EQ(30, features.time_since_last_touch_sec()); + EXPECT_EQ(90, features.video_playing_time_sec()); + EXPECT_EQ(2, features.time_since_video_ended_sec()); + EXPECT_EQ(0, features.key_events_in_last_hour()); + EXPECT_EQ(10, features.mouse_events_in_last_hour()); + EXPECT_EQ(20, features.touch_events_in_last_hour()); + EXPECT_FALSE(features.has_last_user_activity_time_sec()); + EXPECT_FALSE(features.has_time_since_last_key_sec()); +} + +TEST_F(UserActivityManagerTest, ManagedDevice) { + fake_user_manager_.set_is_enterprise_managed(true); + + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + ReportUserActivity(nullptr); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + const UserActivityEvent::Features& features = events[0].features(); + EXPECT_EQ(UserActivityEvent::Features::MANAGED, features.device_management()); +} + +TEST_F(UserActivityManagerTest, DimAndOffDelays) { + ReportInactivityDelays( + base::TimeDelta::FromMilliseconds(2000) /* screen_dim_delay */, + base::TimeDelta::FromMilliseconds(3000) /* screen_off_delay */); + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + ReportUserActivity(nullptr); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + const UserActivityEvent::Features& features = events[0].features(); + EXPECT_EQ(2, features.on_to_dim_sec()); + EXPECT_EQ(1, features.dim_to_screen_off_sec()); +} + +TEST_F(UserActivityManagerTest, DimDelays) { + ReportInactivityDelays( + base::TimeDelta::FromMilliseconds(2000) /* screen_dim_delay */, + base::TimeDelta() /* screen_off_delay */); + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + ReportUserActivity(nullptr); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + const UserActivityEvent::Features& features = events[0].features(); + EXPECT_EQ(2, features.on_to_dim_sec()); + EXPECT_TRUE(!features.has_dim_to_screen_off_sec()); +} + +TEST_F(UserActivityManagerTest, OffDelays) { + ReportInactivityDelays( + base::TimeDelta() /* screen_dim_delay */, + base::TimeDelta::FromMilliseconds(4000) /* screen_off_delay */); + const IdleEventNotifier::ActivityData data; + ReportIdleEvent(data); + ReportUserActivity(nullptr); + + const auto& events = delegate_.events(); + ASSERT_EQ(1U, events.size()); + + const UserActivityEvent::Features& features = events[0].features(); + EXPECT_EQ(4, features.dim_to_screen_off_sec()); + EXPECT_TRUE(!features.has_on_to_dim_sec()); +} + +TEST_F(UserActivityManagerTest, BasicTabs) { + std::unique_ptr<Browser> browser = + CreateTestBrowser(true /* is_visible */, true /* is_focused */); + BrowserList::GetInstance()->SetLastActive(browser.get()); + TabStripModel* tab_strip_model = browser->tab_strip_model(); + CreateTestWebContents(tab_strip_model, url1_, true /* is_active */, + "application/pdf"); + SiteEngagementService::Get(profile())->ResetBaseScoreForURL(url1_, 95); + const ukm::SourceId source_id1 = GetSourceIdForUrl(url1_); + + CreateTestWebContents(tab_strip_model, url2_, false /* is_active */); + const ukm::SourceId source_id2 = GetSourceIdForUrl(url2_); + + UpdateOpenTabsURLs(); + + TabProperty expected_property1; + expected_property1.is_active = true; + expected_property1.is_browser_focused = true; + expected_property1.is_browser_visible = true; + expected_property1.is_topmost_browser = true; + expected_property1.engagement_score = 90; + expected_property1.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_APPLICATION; + expected_property1.has_form_entry = false; + + TabProperty expected_property2; + expected_property2.is_active = false; + expected_property2.is_browser_focused = true; + expected_property2.is_browser_visible = true; + expected_property2.is_topmost_browser = true; + expected_property2.engagement_score = 0; + expected_property2.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + expected_property2.has_form_entry = false; + + const std::map<ukm::SourceId, TabProperty> expected_sources( + {{source_id1, expected_property1}, {source_id2, expected_property2}}); + CheckTabsProperties(expected_sources); + + tab_strip_model->CloseAllTabs(); +} + +TEST_F(UserActivityManagerTest, MultiBrowsersAndTabs) { + // Simulates three browsers: + // - browser1 is the last active but minimized and so not visible. + // - browser2 and browser3 are both visible but browser2 is the topmost. + std::unique_ptr<Browser> browser1 = + CreateTestBrowser(false /* is_visible */, false /* is_focused */); + std::unique_ptr<Browser> browser2 = + CreateTestBrowser(true /* is_visible */, true /* is_focused */); + std::unique_ptr<Browser> browser3 = + CreateTestBrowser(true /* is_visible */, false /* is_focused */); + + BrowserList::GetInstance()->SetLastActive(browser3.get()); + BrowserList::GetInstance()->SetLastActive(browser2.get()); + BrowserList::GetInstance()->SetLastActive(browser1.get()); + + TabStripModel* tab_strip_model1 = browser1->tab_strip_model(); + CreateTestWebContents(tab_strip_model1, url1_, false /* is_active */); + CreateTestWebContents(tab_strip_model1, url2_, true /* is_active */); + const ukm::SourceId source_id1 = GetSourceIdForUrl(url1_); + const ukm::SourceId source_id2 = GetSourceIdForUrl(url2_); + + TabStripModel* tab_strip_model2 = browser2->tab_strip_model(); + CreateTestWebContents(tab_strip_model2, url3_, true /* is_active */); + const ukm::SourceId source_id3 = GetSourceIdForUrl(url3_); + + TabStripModel* tab_strip_model3 = browser3->tab_strip_model(); + CreateTestWebContents(tab_strip_model3, url4_, true /* is_active */); + const ukm::SourceId source_id4 = GetSourceIdForUrl(url4_); + + UpdateOpenTabsURLs(); + + TabProperty expected_property1; + expected_property1.is_active = false; + expected_property1.is_browser_focused = false; + expected_property1.is_browser_visible = false; + expected_property1.is_topmost_browser = false; + expected_property1.engagement_score = 0; + expected_property1.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + expected_property1.has_form_entry = false; + + TabProperty expected_property2; + expected_property2.is_active = true; + expected_property2.is_browser_focused = false; + expected_property2.is_browser_visible = false; + expected_property2.is_topmost_browser = false; + expected_property2.engagement_score = 0; + expected_property2.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + expected_property2.has_form_entry = false; + + TabProperty expected_property3; + expected_property3.is_active = true; + expected_property3.is_browser_focused = true; + expected_property3.is_browser_visible = true; + expected_property3.is_topmost_browser = true; + expected_property3.engagement_score = 0; + expected_property3.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + expected_property3.has_form_entry = false; + + TabProperty expected_property4; + expected_property4.is_active = true; + expected_property4.is_browser_focused = false; + expected_property4.is_browser_visible = true; + expected_property4.is_topmost_browser = false; + expected_property4.engagement_score = 0; + expected_property4.content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + expected_property4.has_form_entry = false; + + const std::map<ukm::SourceId, TabProperty> expected_properties( + {{source_id1, expected_property1}, + {source_id2, expected_property2}, + {source_id3, expected_property3}, + {source_id4, expected_property4}}); + CheckTabsProperties(expected_properties); + + tab_strip_model1->CloseAllTabs(); + tab_strip_model2->CloseAllTabs(); + tab_strip_model3->CloseAllTabs(); +} + +TEST_F(UserActivityManagerTest, Incognito) { + std::unique_ptr<Browser> browser = CreateTestBrowser( + true /* is_visible */, true /* is_focused */, true /* is_incognito */); + BrowserList::GetInstance()->SetLastActive(browser.get()); + + TabStripModel* tab_strip_model = browser->tab_strip_model(); + CreateTestWebContents(tab_strip_model, url1_, true /* is_active */); + CreateTestWebContents(tab_strip_model, url2_, false /* is_active */); + + UpdateOpenTabsURLs(); + + const std::map<ukm::SourceId, TabProperty> empty_map; + CheckTabsProperties(empty_map); + + tab_strip_model->CloseAllTabs(); +} + +TEST_F(UserActivityManagerTest, NoOpenTabs) { + std::unique_ptr<Browser> browser = + CreateTestBrowser(true /* is_visible */, true /* is_focused */); + + UpdateOpenTabsURLs(); + + const std::map<ukm::SourceId, TabProperty> empty_map; + CheckTabsProperties(empty_map); +} + +} // namespace ml +} // namespace power +} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h new file mode 100644 index 0000000..4e758a01 --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h
@@ -0,0 +1,34 @@ +// 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 CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_H_ +#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_H_ + +#include <map> + +#include "services/metrics/public/cpp/ukm_source_id.h" + +namespace chromeos { +namespace power { +namespace ml { + +struct TabProperty; +class UserActivityEvent; + +// Interface to log UserActivityEvent to UKM. +class UserActivityUkmLogger { + public: + virtual ~UserActivityUkmLogger() = default; + + // Log user activity event using URL data. + virtual void LogActivity( + const UserActivityEvent& event, + const std::map<ukm::SourceId, TabProperty>& open_tabs) = 0; +}; + +} // namespace ml +} // namespace power +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.cc b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.cc new file mode 100644 index 0000000..7a314cd --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.cc
@@ -0,0 +1,172 @@ +// 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 <cmath> + +#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" +#include "chrome/browser/chromeos/power/ml/user_activity_manager.h" +#include "chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h" +#include "content/public/browser/web_contents.h" +#include "services/metrics/public/cpp/ukm_builders.h" +#include "ui/gfx/native_widget_types.h" + +namespace chromeos { +namespace power { +namespace ml { + +namespace { + +constexpr UserActivityUkmLoggerImpl::Bucket kBatteryPercentBuckets[] = { + {100, 5}}; + +constexpr UserActivityUkmLoggerImpl::Bucket kEventLogDurationBuckets[] = { + {60, 1}, + {300, 10}, + {600, 20}}; + +constexpr UserActivityUkmLoggerImpl::Bucket kUserInputEventBuckets[] = { + {100, 1}, + {1000, 100}, + {10000, 1000}}; + +constexpr UserActivityUkmLoggerImpl::Bucket kRecentVideoPlayingTimeBuckets[] = { + {60, 1}, + {1200, 300}, + {3600, 600}, + {18000, 1800}}; + +constexpr UserActivityUkmLoggerImpl::Bucket kTimeSinceLastVideoEndedBuckets[] = + {{60, 1}, {600, 60}, {1200, 300}, {3600, 600}, {18000, 1800}}; + +} // namespace + +int UserActivityUkmLoggerImpl::Bucketize(int original_value, + const Bucket* buckets, + size_t num_buckets) { + DCHECK_GE(original_value, 0); + DCHECK(buckets); + for (size_t i = 0; i < num_buckets; ++i) { + const Bucket& bucket = buckets[i]; + if (original_value < bucket.boundary_end) { + return bucket.rounding * (original_value / bucket.rounding); + } + } + return buckets[num_buckets - 1].boundary_end; +} + +UserActivityUkmLoggerImpl::UserActivityUkmLoggerImpl() + : ukm_recorder_(ukm::UkmRecorder::Get()) {} + +UserActivityUkmLoggerImpl::~UserActivityUkmLoggerImpl() = default; + +void UserActivityUkmLoggerImpl::LogActivity( + const UserActivityEvent& event, + const std::map<ukm::SourceId, TabProperty>& open_tabs) { + DCHECK(ukm_recorder_); + ukm::SourceId source_id = ukm_recorder_->GetNewSourceID(); + ukm::builders::UserActivity user_activity(source_id); + user_activity.SetSequenceId(next_sequence_id_++) + .SetDeviceMode(event.features().device_mode()) + .SetDeviceType(event.features().device_type()) + .SetEventLogDuration(Bucketize(event.event().log_duration_sec(), + kEventLogDurationBuckets, + arraysize(kEventLogDurationBuckets))) + .SetEventReason(event.event().reason()) + .SetEventType(event.event().type()) + .SetLastActivityDay(event.features().last_activity_day()) + .SetLastActivityTime( + std::floor(event.features().last_activity_time_sec() / 3600)) + .SetRecentTimeActive(event.features().recent_time_active_sec()) + .SetRecentVideoPlayingTime( + Bucketize(event.features().video_playing_time_sec(), + kRecentVideoPlayingTimeBuckets, + arraysize(kRecentVideoPlayingTimeBuckets))); + + if (event.features().has_on_to_dim_sec()) { + user_activity.SetScreenDimDelay(event.features().on_to_dim_sec()); + } + if (event.features().has_dim_to_screen_off_sec()) { + user_activity.SetScreenDimToOffDelay( + event.features().dim_to_screen_off_sec()); + } + + if (event.features().has_last_user_activity_time_sec()) { + user_activity.SetLastUserActivityTime( + std::floor(event.features().last_user_activity_time_sec() / 3600)); + } + if (event.features().has_time_since_last_key_sec()) { + user_activity.SetTimeSinceLastKey( + event.features().time_since_last_key_sec()); + } + if (event.features().has_time_since_last_mouse_sec()) { + user_activity.SetTimeSinceLastMouse( + event.features().time_since_last_mouse_sec()); + } + if (event.features().has_time_since_last_touch_sec()) { + user_activity.SetTimeSinceLastTouch( + event.features().time_since_last_touch_sec()); + } + + if (event.features().has_on_battery()) { + user_activity.SetOnBattery(event.features().on_battery()); + } + + if (event.features().has_battery_percent()) { + user_activity.SetBatteryPercent( + Bucketize(std::floor(event.features().battery_percent()), + kBatteryPercentBuckets, arraysize(kBatteryPercentBuckets))); + } + + if (event.features().has_device_management()) { + user_activity.SetDeviceManagement(event.features().device_management()); + } + + if (event.features().has_time_since_video_ended_sec()) { + user_activity.SetTimeSinceLastVideoEnded( + Bucketize(event.features().time_since_video_ended_sec(), + kTimeSinceLastVideoEndedBuckets, + arraysize(kTimeSinceLastVideoEndedBuckets))); + } + + if (event.features().has_key_events_in_last_hour()) { + user_activity.SetKeyEventsInLastHour( + Bucketize(event.features().key_events_in_last_hour(), + kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); + } + + if (event.features().has_mouse_events_in_last_hour()) { + user_activity.SetMouseEventsInLastHour( + Bucketize(event.features().mouse_events_in_last_hour(), + kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); + } + + if (event.features().has_touch_events_in_last_hour()) { + user_activity.SetTouchEventsInLastHour( + Bucketize(event.features().touch_events_in_last_hour(), + kUserInputEventBuckets, arraysize(kUserInputEventBuckets))); + } + + user_activity.Record(ukm_recorder_); + + for (const std::pair<ukm::SourceId, TabProperty>& kv : open_tabs) { + const ukm::SourceId& id = kv.first; + const TabProperty& tab_property = kv.second; + ukm::builders::UserActivityId user_activity_id(id); + user_activity_id.SetActivityId(source_id) + .SetContentType(tab_property.content_type) + .SetHasFormEntry(tab_property.has_form_entry) + .SetIsActive(tab_property.is_active) + .SetIsBrowserFocused(tab_property.is_browser_focused) + .SetIsBrowserVisible(tab_property.is_browser_visible) + .SetIsTopmostBrowser(tab_property.is_topmost_browser); + if (tab_property.engagement_score >= 0) { + user_activity_id.SetSiteEngagementScore(tab_property.engagement_score); + } + user_activity_id.Record(ukm_recorder_); + } +} + +} // namespace ml +} // namespace power +} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h new file mode 100644 index 0000000..10239e5 --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h
@@ -0,0 +1,64 @@ +// 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 CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_IMPL_H_ +#define CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_IMPL_H_ + +#include "base/macros.h" +#include "chrome/browser/chromeos/power/ml/user_activity_ukm_logger.h" +#include "chrome/browser/resource_coordinator/tab_metrics_event.pb.h" +#include "services/metrics/public/cpp/ukm_recorder.h" + +namespace chromeos { +namespace power { +namespace ml { + +class UserActivityEvent; + +class UserActivityUkmLoggerImpl : public UserActivityUkmLogger { + public: + // Both |boundary_end| and |rounding| must be positive. + struct Bucket { + int boundary_end; + int rounding; + }; + + // Bucketize |original_value| using given |buckets|, which is an array of + // Bucket and must be sorted in ascending order of |boundary_end|. + // |original_value| must be non-negative. An example of |buckets| is + // {{60, 1}, {300, 10}, {600, 20}}. This function looks for the first + // |boundary_end| > |original_value| and bucket it to the nearest |rounding|. + // If |original_value| is greater than all |boundary_end|, the function + // returns the largest |boundary_end|. Using the above |buckets| example, the + // function will return 30 if |original_value| = 30, and 290 if + // |original_value| = 299. + static int Bucketize(int original_value, + const Bucket* buckets, + size_t num_buckets); + + UserActivityUkmLoggerImpl(); + ~UserActivityUkmLoggerImpl() override; + + // chromeos::power::ml::UserActivityUkmLogger overrides: + void LogActivity( + const UserActivityEvent& event, + const std::map<ukm::SourceId, TabProperty>& open_tabs) override; + + private: + friend class UserActivityUkmLoggerTest; + + ukm::UkmRecorder* ukm_recorder_; // not owned + + // This ID is incremented each time a UserActivity is logged to UKM. + // Event index starts from 1, and resets when a new session starts. + int next_sequence_id_ = 1; + + DISALLOW_COPY_AND_ASSIGN(UserActivityUkmLoggerImpl); +}; + +} // namespace ml +} // namespace power +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_POWER_ML_USER_ACTIVITY_UKM_LOGGER_IMPL_H_
diff --git a/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_unittest.cc b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_unittest.cc new file mode 100644 index 0000000..963b42e --- /dev/null +++ b/chrome/browser/chromeos/power/ml/user_activity_ukm_logger_unittest.cc
@@ -0,0 +1,287 @@ +// 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 "chrome/browser/chromeos/power/ml/user_activity_ukm_logger_impl.h" + +#include <memory> +#include <vector> + +#include "chrome/browser/chromeos/power/ml/user_activity_event.pb.h" +#include "chrome/browser/chromeos/power/ml/user_activity_manager.h" +#include "components/ukm/test_ukm_recorder.h" +#include "services/metrics/public/cpp/ukm_builders.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { +namespace power { +namespace ml { + +using ukm::builders::UserActivity; +using ukm::builders::UserActivityId; + +class UserActivityUkmLoggerTest : public testing::Test { + public: + UserActivityUkmLoggerTest() { + // These values are arbitrary but must correspond with the values + // in CheckUserActivityValues. + UserActivityEvent::Event* event = user_activity_event_.mutable_event(); + event->set_log_duration_sec(395); + event->set_reason(UserActivityEvent::Event::USER_ACTIVITY); + event->set_type(UserActivityEvent::Event::REACTIVATE); + + // In the order of metrics names in ukm. + UserActivityEvent::Features* features = + user_activity_event_.mutable_features(); + features->set_battery_percent(96.0); + features->set_device_management(UserActivityEvent::Features::UNMANAGED); + features->set_device_mode(UserActivityEvent::Features::CLAMSHELL); + features->set_device_type(UserActivityEvent::Features::CHROMEBOOK); + features->set_last_activity_day(UserActivityEvent::Features::MON); + features->set_last_activity_time_sec(7300); + features->set_last_user_activity_time_sec(3800); + features->set_key_events_in_last_hour(20000); + features->set_recent_time_active_sec(10); + features->set_video_playing_time_sec(800); + features->set_on_to_dim_sec(100); + features->set_dim_to_screen_off_sec(200); + features->set_time_since_last_mouse_sec(100); + features->set_time_since_last_touch_sec(311); + features->set_time_since_video_ended_sec(400); + features->set_mouse_events_in_last_hour(89); + features->set_touch_events_in_last_hour(1890); + + user_activity_logger_delegate_ukm_.ukm_recorder_ = &recorder_; + } + + protected: + void LogActivity(const UserActivityEvent& event, + const std::map<ukm::SourceId, TabProperty>& open_tabs) { + user_activity_logger_delegate_ukm_.LogActivity(event, open_tabs); + } + + void CheckUserActivityValues(const ukm::mojom::UkmEntry* entry) { + recorder_.ExpectEntryMetric(entry, UserActivity::kEventLogDurationName, + 380); + recorder_.ExpectEntryMetric(entry, UserActivity::kEventReasonName, + UserActivityEvent::Event::USER_ACTIVITY); + recorder_.ExpectEntryMetric(entry, UserActivity::kEventTypeName, + UserActivityEvent::Event::REACTIVATE); + recorder_.ExpectEntryMetric(entry, UserActivity::kBatteryPercentName, 95); + recorder_.ExpectEntryMetric(entry, UserActivity::kDeviceManagementName, + UserActivityEvent::Features::UNMANAGED); + recorder_.ExpectEntryMetric(entry, UserActivity::kDeviceModeName, + UserActivityEvent::Features::CLAMSHELL); + recorder_.ExpectEntryMetric(entry, UserActivity::kDeviceTypeName, + UserActivityEvent::Features::CHROMEBOOK); + recorder_.ExpectEntryMetric(entry, UserActivity::kLastActivityDayName, + UserActivityEvent::Features::MON); + recorder_.ExpectEntryMetric(entry, UserActivity::kKeyEventsInLastHourName, + 10000); + recorder_.ExpectEntryMetric(entry, UserActivity::kLastActivityTimeName, 2); + recorder_.ExpectEntryMetric(entry, UserActivity::kLastUserActivityTimeName, + 1); + recorder_.ExpectEntryMetric(entry, UserActivity::kMouseEventsInLastHourName, + 89); + EXPECT_FALSE(recorder_.EntryHasMetric(entry, UserActivity::kOnBatteryName)); + recorder_.ExpectEntryMetric(entry, UserActivity::kRecentTimeActiveName, 10); + recorder_.ExpectEntryMetric(entry, + UserActivity::kRecentVideoPlayingTimeName, 600); + recorder_.ExpectEntryMetric(entry, UserActivity::kScreenDimDelayName, 100); + recorder_.ExpectEntryMetric(entry, UserActivity::kScreenDimToOffDelayName, + 200); + recorder_.ExpectEntryMetric(entry, UserActivity::kSequenceIdName, 1); + EXPECT_FALSE( + recorder_.EntryHasMetric(entry, UserActivity::kTimeSinceLastKeyName)); + recorder_.ExpectEntryMetric(entry, UserActivity::kTimeSinceLastMouseName, + 100); + recorder_.ExpectEntryMetric(entry, UserActivity::kTimeSinceLastTouchName, + 311); + recorder_.ExpectEntryMetric( + entry, UserActivity::kTimeSinceLastVideoEndedName, 360); + recorder_.ExpectEntryMetric(entry, UserActivity::kTouchEventsInLastHourName, + 1000); + } + + UserActivityEvent user_activity_event_; + ukm::TestUkmRecorder recorder_; + + private: + UserActivityUkmLoggerImpl user_activity_logger_delegate_ukm_; + DISALLOW_COPY_AND_ASSIGN(UserActivityUkmLoggerTest); +}; + +TEST_F(UserActivityUkmLoggerTest, BucketEveryFivePercents) { + const std::vector<int> original_values = {0, 14, 15, 100}; + const std::vector<int> results = {0, 10, 15, 100}; + constexpr UserActivityUkmLoggerImpl::Bucket buckets[] = {{100, 5}}; + + for (size_t i = 0; i < original_values.size(); ++i) { + EXPECT_EQ(results[i], UserActivityUkmLoggerImpl::Bucketize( + original_values[i], buckets, arraysize(buckets))); + } +} + +TEST_F(UserActivityUkmLoggerTest, Bucketize) { + const std::vector<int> original_values = {0, 18, 59, 60, 62, 69, 72, + 299, 300, 306, 316, 599, 600, 602}; + constexpr UserActivityUkmLoggerImpl::Bucket buckets[] = { + {60, 1}, {300, 10}, {600, 20}}; + const std::vector<int> results = {0, 18, 59, 60, 60, 60, 70, + 290, 300, 300, 300, 580, 600, 600}; + for (size_t i = 0; i < original_values.size(); ++i) { + EXPECT_EQ(results[i], UserActivityUkmLoggerImpl::Bucketize( + original_values[i], buckets, arraysize(buckets))); + } +} + +TEST_F(UserActivityUkmLoggerTest, BasicLogging) { + TabProperty properties[2]; + + properties[0].is_active = true; + properties[0].is_browser_focused = false; + properties[0].is_browser_visible = true; + properties[0].is_topmost_browser = false; + properties[0].engagement_score = 90; + properties[0].content_type = + metrics::TabMetricsEvent::CONTENT_TYPE_APPLICATION; + properties[0].has_form_entry = false; + + properties[1].is_active = false; + properties[1].is_browser_focused = true; + properties[1].is_browser_visible = false; + properties[1].is_topmost_browser = true; + properties[1].engagement_score = 0; + properties[1].content_type = metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML; + properties[1].has_form_entry = true; + + ukm::SourceId source_ids[2]; + for (int i = 0; i < 2; ++i) + source_ids[i] = recorder_.GetNewSourceID(); + std::map<ukm::SourceId, TabProperty> source_properties( + {{source_ids[0], properties[0]}, {source_ids[1], properties[1]}}); + LogActivity(user_activity_event_, source_properties); + + const auto& activity_entries = + recorder_.GetEntriesByName(UserActivity::kEntryName); + EXPECT_EQ(1u, activity_entries.size()); + const ukm::mojom::UkmEntry* activity_entry = activity_entries[0]; + CheckUserActivityValues(activity_entry); + + const ukm::SourceId kSourceId = activity_entry->source_id; + const auto& activity_id_entries = + recorder_.GetEntriesByName(UserActivityId::kEntryName); + EXPECT_EQ(2u, activity_id_entries.size()); + + const ukm::mojom::UkmEntry* entry0 = activity_id_entries[0]; + recorder_.ExpectEntryMetric(entry0, UserActivityId::kActivityIdName, + kSourceId); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kIsActiveName, 1); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kIsBrowserFocusedName, 0); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kIsBrowserVisibleName, 1); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kIsTopmostBrowserName, 0); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kSiteEngagementScoreName, + 90); + recorder_.ExpectEntryMetric( + entry0, UserActivityId::kContentTypeName, + metrics::TabMetricsEvent::CONTENT_TYPE_APPLICATION); + recorder_.ExpectEntryMetric(entry0, UserActivityId::kHasFormEntryName, 0); + + const ukm::mojom::UkmEntry* entry1 = activity_id_entries[1]; + recorder_.ExpectEntryMetric(entry1, UserActivityId::kActivityIdName, + kSourceId); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kIsActiveName, 0); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kIsBrowserFocusedName, 1); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kIsBrowserVisibleName, 0); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kIsTopmostBrowserName, 1); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kSiteEngagementScoreName, + 0); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kContentTypeName, + metrics::TabMetricsEvent::CONTENT_TYPE_TEXT_HTML); + recorder_.ExpectEntryMetric(entry1, UserActivityId::kHasFormEntryName, 1); +} + +// Tests what would be logged in Incognito: when source IDs are not provided. +TEST_F(UserActivityUkmLoggerTest, EmptySources) { + std::map<ukm::SourceId, TabProperty> empty_source_properties; + LogActivity(user_activity_event_, empty_source_properties); + + const auto& activity_entries = + recorder_.GetEntriesByName(UserActivity::kEntryName); + EXPECT_EQ(1u, activity_entries.size()); + const ukm::mojom::UkmEntry* activity_entry = activity_entries[0]; + + CheckUserActivityValues(activity_entry); + + EXPECT_EQ(0u, recorder_.GetEntriesByName(UserActivityId::kEntryName).size()); +} + +TEST_F(UserActivityUkmLoggerTest, TwoUserActivityEvents) { + // A second event will be logged. Values correspond with the checks below. + UserActivityEvent user_activity_event2; + UserActivityEvent::Event* event = user_activity_event2.mutable_event(); + event->set_log_duration_sec(35); + event->set_reason(UserActivityEvent::Event::IDLE_SLEEP); + event->set_type(UserActivityEvent::Event::TIMEOUT); + + UserActivityEvent::Features* features = + user_activity_event2.mutable_features(); + features->set_battery_percent(86.0); + features->set_device_management(UserActivityEvent::Features::MANAGED); + features->set_device_mode(UserActivityEvent::Features::CLAMSHELL); + features->set_device_type(UserActivityEvent::Features::CHROMEBOOK); + features->set_last_activity_day(UserActivityEvent::Features::TUE); + features->set_last_activity_time_sec(7300); + features->set_last_user_activity_time_sec(3800); + features->set_recent_time_active_sec(20); + features->set_on_to_dim_sec(10); + features->set_dim_to_screen_off_sec(20); + features->set_time_since_last_mouse_sec(200); + + std::map<ukm::SourceId, TabProperty> empty_source_properties; + LogActivity(user_activity_event_, empty_source_properties); + LogActivity(user_activity_event2, empty_source_properties); + + const auto& activity_entries = + recorder_.GetEntriesByName(UserActivity::kEntryName); + EXPECT_EQ(2u, activity_entries.size()); + + // Check the first user activity values. + CheckUserActivityValues(activity_entries[0]); + + // Check the second user activity values. + const ukm::mojom::UkmEntry* entry1 = activity_entries[1]; + recorder_.ExpectEntryMetric(entry1, UserActivity::kEventLogDurationName, 35); + recorder_.ExpectEntryMetric(entry1, UserActivity::kEventReasonName, + UserActivityEvent::Event::IDLE_SLEEP); + recorder_.ExpectEntryMetric(entry1, UserActivity::kEventTypeName, + UserActivityEvent::Event::TIMEOUT); + recorder_.ExpectEntryMetric(entry1, UserActivity::kBatteryPercentName, 85); + recorder_.ExpectEntryMetric(entry1, UserActivity::kDeviceManagementName, + UserActivityEvent::Features::MANAGED); + recorder_.ExpectEntryMetric(entry1, UserActivity::kDeviceModeName, + UserActivityEvent::Features::CLAMSHELL); + recorder_.ExpectEntryMetric(entry1, UserActivity::kDeviceTypeName, + UserActivityEvent::Features::CHROMEBOOK); + recorder_.ExpectEntryMetric(entry1, UserActivity::kLastActivityDayName, + UserActivityEvent::Features::TUE); + recorder_.ExpectEntryMetric(entry1, UserActivity::kLastActivityTimeName, 2); + recorder_.ExpectEntryMetric(entry1, UserActivity::kLastUserActivityTimeName, + 1); + EXPECT_FALSE(recorder_.EntryHasMetric(entry1, UserActivity::kOnBatteryName)); + recorder_.ExpectEntryMetric(entry1, UserActivity::kRecentTimeActiveName, 20); + recorder_.ExpectEntryMetric(entry1, UserActivity::kScreenDimDelayName, 10); + recorder_.ExpectEntryMetric(entry1, UserActivity::kScreenDimToOffDelayName, + 20); + recorder_.ExpectEntryMetric(entry1, UserActivity::kSequenceIdName, 2); + EXPECT_FALSE( + recorder_.EntryHasMetric(entry1, UserActivity::kTimeSinceLastKeyName)); + recorder_.ExpectEntryMetric(entry1, UserActivity::kTimeSinceLastMouseName, + 200); + + EXPECT_EQ(0u, recorder_.GetEntriesByName(UserActivityId::kEntryName).size()); +} + +} // namespace ml +} // namespace power +} // namespace chromeos
diff --git a/chrome/browser/chromeos/smb_client/discovery/network_scanner.cc b/chrome/browser/chromeos/smb_client/discovery/network_scanner.cc new file mode 100644 index 0000000..ff6f538 --- /dev/null +++ b/chrome/browser/chromeos/smb_client/discovery/network_scanner.cc
@@ -0,0 +1,106 @@ +// Copyright 2018 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 "chrome/browser/chromeos/smb_client/discovery/network_scanner.h" + +#include <map> +#include <vector> + +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "chrome/browser/chromeos/smb_client/discovery/host_locator.h" + +namespace chromeos { +namespace smb_client { + +namespace { + +// Returns true if the host with |host_name| already exists in |host_map|. +bool HostExists(const HostMap& host_map, const Hostname& host_name) { + return host_map.count(host_name); +} + +} // namespace + +RequestInfo::RequestInfo(uint32_t remaining_requests, + FindHostsCallback callback) + : remaining_requests(remaining_requests), callback(std::move(callback)) {} + +RequestInfo::RequestInfo(RequestInfo&& other) = default; + +RequestInfo::~RequestInfo() = default; + +NetworkScanner::NetworkScanner() = default; + +NetworkScanner::~NetworkScanner() = default; + +void NetworkScanner::FindHostsInNetwork(FindHostsCallback callback) { + if (locators_.empty()) { + // Fire the callback immediately if there are no registered HostLocators. + std::move(callback).Run(HostMap()); + return; + } + + const uint32_t request_id = AddNewRequest(std::move(callback)); + for (const auto& locator : locators_) { + locator->FindHosts( + base::BindOnce(&NetworkScanner::OnHostsFound, AsWeakPtr(), request_id)); + } +} + +void NetworkScanner::RegisterHostLocator(std::unique_ptr<HostLocator> locator) { + locators_.push_back(std::move(locator)); +} + +void NetworkScanner::OnHostsFound(uint32_t request_id, + const HostMap& host_map) { + DCHECK_GT(requests_.count(request_id), 0u); + + AddHostsToResults(request_id, host_map); + FireCallbackIfFinished(request_id); +} + +void NetworkScanner::AddHostsToResults(uint32_t request_id, + const HostMap& new_hosts) { + auto request_iter = requests_.find(request_id); + DCHECK(request_iter != requests_.end()); + + HostMap& existing_hosts = request_iter->second.hosts_found; + for (const auto& new_host : new_hosts) { + const Hostname& new_hostname = new_host.first; + const Address& new_ip = new_host.second; + + if (!HostExists(existing_hosts, new_hostname)) { + existing_hosts.insert(new_host); + } else if (existing_hosts[new_hostname] != new_ip) { + LOG(WARNING) << "Different addresses found for host: " << new_hostname; + LOG(WARNING) << existing_hosts[new_hostname] << ":" << new_ip; + } + } +} + +uint32_t NetworkScanner::AddNewRequest(FindHostsCallback callback) { + const uint32_t request_id = next_request_id_++; + requests_.emplace(request_id, + RequestInfo(locators_.size(), std::move(callback))); + return request_id; +} + +void NetworkScanner::FireCallbackIfFinished(uint32_t request_id) { + auto request_iter = requests_.find(request_id); + DCHECK(request_iter != requests_.end()); + + uint32_t& remaining_requests = request_iter->second.remaining_requests; + DCHECK_GT(remaining_requests, 0u); + + if (--remaining_requests == 0) { + RequestInfo info = std::move(request_iter->second); + requests_.erase(request_iter); + + std::move(info.callback).Run(info.hosts_found); + } +} + +} // namespace smb_client +} // namespace chromeos
diff --git a/chrome/browser/chromeos/smb_client/discovery/network_scanner.h b/chrome/browser/chromeos/smb_client/discovery/network_scanner.h new file mode 100644 index 0000000..4a3511b6 --- /dev/null +++ b/chrome/browser/chromeos/smb_client/discovery/network_scanner.h
@@ -0,0 +1,81 @@ +// Copyright 2018 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 CHROME_BROWSER_CHROMEOS_SMB_CLIENT_DISCOVERY_NETWORK_SCANNER_H_ +#define CHROME_BROWSER_CHROMEOS_SMB_CLIENT_DISCOVERY_NETWORK_SCANNER_H_ + +#include <map> +#include <vector> + +#include "base/callback.h" +#include "base/memory/weak_ptr.h" +#include "chrome/browser/chromeos/smb_client/discovery/host_locator.h" + +namespace chromeos { +namespace smb_client { + +// Holds the number of in-flight requests and the callback to call once all the +// HostLocators are finished. Also holds the hosts found from the HostLocators +// that have already returned. +struct RequestInfo { + uint32_t remaining_requests; + FindHostsCallback callback; + HostMap hosts_found; + + RequestInfo(uint32_t remaining_requests, FindHostsCallback callback); + RequestInfo(RequestInfo&& other); + ~RequestInfo(); + + DISALLOW_COPY_AND_ASSIGN(RequestInfo); +}; + +// NetworkScanner discovers SMB hosts in the local network by querying +// registered HostLocators and aggregating their results. +class NetworkScanner : public base::SupportsWeakPtr<NetworkScanner> { + public: + NetworkScanner(); + ~NetworkScanner(); + + // Query the registered HostLocators and return all the hosts found. + // |callback| is called once all the HostLocators have responded with their + // results. If there are no locators, the callback is fired immediately with + // an empty result. + void FindHostsInNetwork(FindHostsCallback callback); + + // Registeres a |locator| to be queried when FindHostsInNetwork() is called. + void RegisterHostLocator(std::unique_ptr<HostLocator> locator); + + private: + // Callback handler for HostLocator::FindHosts(). + void OnHostsFound(uint32_t request_id, const HostMap& host_map); + + // Adds |host_map| hosts to current results. The host will not be added if the + // hostname already exists in results, and if the IP address does not match, + // it will be logged. + void AddHostsToResults(uint32_t request_id, const HostMap& host_map); + + // Adds a new request to track and saves |callback| to be called when the + // request is finished. Returns the request id. + uint32_t AddNewRequest(FindHostsCallback callback); + + // Called after a HostLocator returns with results and decrements the count of + // requests in RequestInfo for |request_id|. Fires the callback for if + // there are no more requests and deletes the corresponding RequestInfo. + void FireCallbackIfFinished(uint32_t request_id); + + std::vector<std::unique_ptr<HostLocator>> locators_; + + // Used for tracking in-flight requests to HostLocators. The key is the + // request id, and the value is the RequestInfo struct. + std::map<uint32_t, RequestInfo> requests_; + + uint32_t next_request_id_ = 0; + + DISALLOW_COPY_AND_ASSIGN(NetworkScanner); +}; + +} // namespace smb_client +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SMB_CLIENT_DISCOVERY_NETWORK_SCANNER_H_
diff --git a/chrome/browser/chromeos/smb_client/discovery/network_scanner_unittest.cc b/chrome/browser/chromeos/smb_client/discovery/network_scanner_unittest.cc new file mode 100644 index 0000000..4992951 --- /dev/null +++ b/chrome/browser/chromeos/smb_client/discovery/network_scanner_unittest.cc
@@ -0,0 +1,127 @@ +// Copyright 2018 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 "chrome/browser/chromeos/smb_client/discovery/network_scanner.h" + +#include <map> +#include <string> +#include <utility> + +#include "base/bind.h" +#include "chrome/browser/chromeos/smb_client/discovery/in_memory_host_locator.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace chromeos { +namespace smb_client { + +namespace { + +// Expects |actual_hosts| to equal |expected_hosts|. +void ExpectMapEntriesEqual(const HostMap& expected_hosts, + const HostMap& actual_hosts) { + EXPECT_EQ(expected_hosts, actual_hosts); +} + +} // namespace + +class NetworkScannerTest : public testing::Test { + public: + NetworkScannerTest() = default; + ~NetworkScannerTest() override = default; + + protected: + void RegisterHostLocatorWithHosts(const HostMap& hosts) { + std::unique_ptr<InMemoryHostLocator> host_locator = + std::make_unique<InMemoryHostLocator>(); + host_locator->AddHosts(hosts); + scanner_.RegisterHostLocator(std::move(host_locator)); + } + + void ExpectHostMapEqual(const HostMap& expected_hosts) { + scanner_.FindHostsInNetwork( + base::BindOnce(&ExpectMapEntriesEqual, expected_hosts)); + } + + private: + NetworkScanner scanner_; + + DISALLOW_COPY_AND_ASSIGN(NetworkScannerTest); +}; + +TEST_F(NetworkScannerTest, ShouldFindNoHostsWithNoLocator) { + ExpectHostMapEqual(HostMap()); +} + +TEST_F(NetworkScannerTest, ShouldFindNoHostsWithOneLocator) { + RegisterHostLocatorWithHosts(HostMap()); + + ExpectHostMapEqual(HostMap()); +} + +TEST_F(NetworkScannerTest, ShouldFindNoHostsWithMultipleLocators) { + RegisterHostLocatorWithHosts(HostMap()); + RegisterHostLocatorWithHosts(HostMap()); + + ExpectHostMapEqual(HostMap()); +} + +TEST_F(NetworkScannerTest, ShouldFindOneHostWithOneLocator) { + HostMap hosts; + hosts["share1"] = "1.2.3.4"; + RegisterHostLocatorWithHosts(hosts); + + ExpectHostMapEqual(hosts); +} + +TEST_F(NetworkScannerTest, ShouldFindMultipleHostsWithOneLocator) { + HostMap hosts; + hosts["share1"] = "1.2.3.4"; + hosts["share2"] = "5.6.7.8"; + RegisterHostLocatorWithHosts(hosts); + + ExpectHostMapEqual(hosts); +} + +TEST_F(NetworkScannerTest, ShouldFindMultipleHostsWithMultipleLocators) { + HostMap hosts1; + hosts1["share1"] = "1.2.3.4"; + hosts1["share2"] = "5.6.7.8"; + RegisterHostLocatorWithHosts(hosts1); + + HostMap hosts2; + hosts2["share3"] = "11.12.13.14"; + hosts2["share4"] = "15.16.17.18"; + RegisterHostLocatorWithHosts(hosts2); + + HostMap expected; + expected["share1"] = "1.2.3.4"; + expected["share2"] = "5.6.7.8"; + expected["share3"] = "11.12.13.14"; + expected["share4"] = "15.16.17.18"; + + ExpectHostMapEqual(expected); +} + +TEST_F(NetworkScannerTest, ShouldResolveMultipleHostsWithSameAddress) { + HostMap hosts1; + hosts1["share1"] = "1.2.3.4"; + hosts1["share2"] = "5.6.7.8"; + RegisterHostLocatorWithHosts(hosts1); + + HostMap hosts2; + hosts2["share2"] = "11.12.13.14"; + hosts2["share3"] = "15.16.17.18"; + RegisterHostLocatorWithHosts(hosts2); + + // share2 should have the value from host1 since it is found first. + HostMap expected; + expected["share1"] = "1.2.3.4"; + expected["share2"] = "5.6.7.8"; + expected["share3"] = "15.16.17.18"; + + ExpectHostMapEqual(expected); +} + +} // namespace smb_client +} // namespace chromeos
diff --git a/chrome/browser/component_updater/widevine_cdm_component_installer.cc b/chrome/browser/component_updater/widevine_cdm_component_installer.cc index 0331571..69e50b8 100644 --- a/chrome/browser/component_updater/widevine_cdm_component_installer.cc +++ b/chrome/browser/component_updater/widevine_cdm_component_installer.cc
@@ -20,7 +20,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/native_library.h" -#include "base/path_service.h" #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" @@ -29,16 +28,12 @@ #include "base/task_scheduler/post_task.h" #include "base/values.h" #include "build/build_config.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/common/widevine_cdm_constants.h" #include "components/component_updater/component_installer.h" #include "components/component_updater/component_updater_service.h" #include "components/version_info/version_info.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cdm_registry.h" -#include "content/public/browser/plugin_service.h" #include "content/public/common/cdm_info.h" -#include "content/public/common/pepper_plugin_info.h" #include "crypto/sha2.h" #include "media/base/video_codecs.h" #include "media/cdm/supported_cdm_versions.h" @@ -48,7 +43,6 @@ using content::BrowserThread; using content::CdmRegistry; -using content::PluginService; namespace component_updater { @@ -64,10 +58,6 @@ static_assert(arraysize(kWidevineSha2Hash) == crypto::kSHA256Length, "Wrong hash length"); -// File name of the Widevine CDM adapter version file. The CDM adapter shares -// the same version number with Chromium version. -const char kCdmAdapterVersionName[] = "CdmAdapterVersion"; - // Name of the Widevine CDM OS in the component manifest. const char kWidevineCdmPlatform[] = #if defined(OS_MACOSX) @@ -119,10 +109,6 @@ const char kCdmSupportedCodecAvc1[] = "avc1"; #endif -// TODO(xhwang): Move this to a common place if needed. -const base::FilePath::CharType kSignatureFileExtension[] = - FILE_PATH_LITERAL(".sig"); - // Widevine CDM is packaged as a multi-CRX. Widevine CDM binaries are located in // _platform_specific/<platform_arch> folder in the package. This function // returns the platform-specific subdirectory that is part of that multi-CRX. @@ -133,39 +119,6 @@ return base_path.AppendASCII("_platform_specific").AppendASCII(platform_arch); } -bool MakeWidevineCdmPluginInfo(const base::Version& version, - const base::FilePath& cdm_install_dir, - const std::string& codecs, - bool supports_persistent_license, - content::PepperPluginInfo* plugin_info) { - if (!version.IsValid() || - version.components().size() != - static_cast<size_t>(kWidevineCdmVersionNumComponents)) { - DVLOG(1) << "Invalid version."; - return false; - } - - plugin_info->is_internal = false; - // Widevine CDM must run out of process. - plugin_info->is_out_of_process = true; - plugin_info->path = GetPlatformDirectory(cdm_install_dir) - .AppendASCII(kWidevineCdmAdapterFileName); - plugin_info->name = kWidevineCdmDisplayName; - plugin_info->description = kWidevineCdmDescription + - std::string(" (version: ") + version.GetString() + - ")"; - plugin_info->version = version.GetString(); - content::WebPluginMimeType widevine_cdm_mime_type( - kWidevineCdmPluginMimeType, - kWidevineCdmPluginExtension, - kWidevineCdmPluginMimeTypeDescription); - - plugin_info->mime_types.push_back(widevine_cdm_mime_type); - plugin_info->permissions = kWidevineCdmPluginPermissions; - - return true; -} - typedef bool (*VersionCheckFunc)(int version); bool CheckForCompatibleVersion(const base::DictionaryValue& manifest, @@ -255,23 +208,8 @@ const std::string codecs = GetCodecs(*manifest); bool supports_persistent_license = GetPersistentLicenseSupport(*manifest); - content::PepperPluginInfo plugin_info; - if (!MakeWidevineCdmPluginInfo(cdm_version, cdm_install_dir, codecs, - supports_persistent_license, &plugin_info)) { - return; - } - VLOG(1) << "Register Widevine CDM with Chrome"; - // true = Add to beginning of list to override any existing registrations. - PluginService::GetInstance()->RegisterInternalPlugin( - plugin_info.ToWebPluginInfo(), true); - // Tell the browser to refresh the plugin list. Then tell all renderers to - // update their plugin list caches. - PluginService::GetInstance()->RefreshPlugins(); - PluginService::GetInstance()->PurgePluginListCache(NULL, false); - - // Also register Widevine with the CdmRegistry. const base::FilePath cdm_path = GetPlatformDirectory(cdm_install_dir) .AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName)); @@ -311,14 +249,10 @@ update_client::InstallerAttributes GetInstallerAttributes() const override; std::vector<std::string> GetMimeTypes() const override; - // Checks and updates CDM adapter if necessary to make sure the latest CDM - // adapter is always used. - // Note: The component is ready when CDM is present, but the CDM won't be - // registered until the adapter is copied by this function (see - // VerifyInstallation). - void UpdateCdmAdapter(const base::Version& cdm_version, - const base::FilePath& cdm_install_dir, - std::unique_ptr<base::DictionaryValue> manifest); + // Updates CDM path if necessary. + void UpdateCdmPath(const base::Version& cdm_version, + const base::FilePath& cdm_install_dir, + std::unique_ptr<base::DictionaryValue> manifest); DISALLOW_COPY_AND_ASSIGN(WidevineCdmComponentInstallerPolicy); }; @@ -343,7 +277,7 @@ void WidevineCdmComponentInstallerPolicy::OnCustomUninstall() {} -// Once the CDM is ready, check the CDM adapter. +// Once the CDM is ready, update the CDM path. void WidevineCdmComponentInstallerPolicy::ComponentReady( const base::Version& version, const base::FilePath& path, @@ -355,7 +289,7 @@ base::PostTaskWithTraits( FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, - base::BindOnce(&WidevineCdmComponentInstallerPolicy::UpdateCdmAdapter, + base::BindOnce(&WidevineCdmComponentInstallerPolicy::UpdateCdmPath, base::Unretained(this), version, path, base::Passed(&manifest))); } @@ -396,23 +330,13 @@ return std::vector<std::string>(); } -static bool HasValidAdapter(const base::FilePath& adapter_version_path, - const base::FilePath& adapter_install_path, - const std::string& chrome_version) { - std::string adapter_version; - return base::ReadFileToString(adapter_version_path, &adapter_version) && - adapter_version == chrome_version && - base::PathExists(adapter_install_path); -} - -void WidevineCdmComponentInstallerPolicy::UpdateCdmAdapter( +void WidevineCdmComponentInstallerPolicy::UpdateCdmPath( const base::Version& cdm_version, const base::FilePath& cdm_install_dir, std::unique_ptr<base::DictionaryValue> manifest) { - // On some platforms (e.g. Mac) we use symlinks for paths. Since we are - // comparing paths below, convert paths to absolute paths to avoid unexpected - // failure. base::MakeAbsoluteFilePath() requires IO so it can only be done - // in this function. + // On some platforms (e.g. Mac) we use symlinks for paths. Convert paths to + // absolute paths to avoid unexpected failure. base::MakeAbsoluteFilePath() + // requires IO so it can only be done in this function. const base::FilePath absolute_cdm_install_dir = base::MakeAbsoluteFilePath(cdm_install_dir); if (absolute_cdm_install_dir.empty()) { @@ -420,57 +344,6 @@ return; } - const base::FilePath adapter_version_path = - GetPlatformDirectory(absolute_cdm_install_dir) - .AppendASCII(kCdmAdapterVersionName); - const base::FilePath adapter_install_path = - GetPlatformDirectory(absolute_cdm_install_dir) - .AppendASCII(kWidevineCdmAdapterFileName); - - VLOG(1) << "UpdateCdmAdapter: version" << cdm_version.GetString(); - VLOG(1) << " - adapter_install_path=" << adapter_install_path.AsUTF8Unsafe(); - VLOG(1) << " - adapter_version_path=" << adapter_version_path.AsUTF8Unsafe(); - - base::FilePath adapter_source_path; - PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); - adapter_source_path = base::MakeAbsoluteFilePath(adapter_source_path); - if (adapter_source_path.empty()) { - PLOG(WARNING) << "Failed to get absolute adapter source path."; - return; - } - - const std::string chrome_version = version_info::GetVersionNumber(); - DCHECK(!chrome_version.empty()); - - // If we are not using bundled CDM and we don't have a valid adapter, create - // the version file, copy the CDM adapter signature file, and copy the CDM - // adapter. - if (adapter_install_path != adapter_source_path && - !HasValidAdapter(adapter_version_path, adapter_install_path, - chrome_version)) { - if (!base::CopyFile(adapter_source_path, adapter_install_path)) { - PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; - return; - } - - // Generate the version file. - int bytes_written = base::WriteFile( - adapter_version_path, chrome_version.data(), chrome_version.size()); - if (bytes_written < 0 || - static_cast<size_t>(bytes_written) != chrome_version.size()) { - PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; - // Ignore version file writing failure. - } - - // Copy Widevine CDM adapter signature file. - if (!base::CopyFile( - adapter_source_path.AddExtension(kSignatureFileExtension), - adapter_install_path.AddExtension(kSignatureFileExtension))) { - PLOG(WARNING) << "Failed to copy Widevine CDM adapter signature file."; - // The sig file may be missing or the copy failed. Ignore the failure. - } - } - content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI) ->PostTask( FROM_HERE, @@ -482,11 +355,6 @@ void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) - base::FilePath adapter_source_path; - PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path); - if (!base::PathExists(adapter_source_path)) - return; - auto installer = base::MakeRefCounted<ComponentInstaller>( std::make_unique<WidevineCdmComponentInstallerPolicy>()); installer->Register(cus, base::OnceClosure());
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index 559447a6..88059c0 100644 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -41,24 +41,17 @@ #include "content/public/test/browser_test_utils.h" #include "content/public/test/ppapi_test_utils.h" #include "content/public/test/test_utils.h" -#include "media/cdm/cdm_paths.h" -#include "media/media_features.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/url_request/url_request_mock_http_job.h" #include "ppapi/features/features.h" #include "ppapi/shared_impl/ppapi_switches.h" #include "testing/gmock/include/gmock/gmock.h" -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. #if defined(OS_MACOSX) #include "base/mac/scoped_nsautorelease_pool.h" #endif -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) -#include "chrome/browser/media/library_cdm_test_helper.h" -#endif - using content::BrowserThread; using net::URLRequestMockHTTPJob; @@ -497,21 +490,6 @@ // The following tests verify that Pepper plugins that use JavaScript settings // instead of Plugins settings still work when Plugins are blocked. -// TODO(crbug.com/403462): Remove after pepper CDM is deprecated. -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && \ - !defined(OS_CHROMEOS) -IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, - WidevineCdm) { - // Check that Widevine CDM is available and registered. - base::FilePath adapter_path = - GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); - EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); - EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); - RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); -} -#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && - // !defined(OS_CHROMEOS) - #if BUILDFLAG(ENABLE_NACL) IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, NaCl) { @@ -528,19 +506,6 @@ RunJavaScriptBlockedTest("/load_flash_no_js.html", false); } -// TODO(crbug.com/403462): Remove after pepper CDM is deprecated. -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) -IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, - WidevineCdm) { - // Check that Widevine CDM is available and registered. - base::FilePath adapter_path = - GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); - EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); - EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); - RunJavaScriptBlockedTest("/load_widevine_no_js.html", true); -} -#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) - #if BUILDFLAG(ENABLE_NACL) IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, NaCl) {
diff --git a/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc b/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc index 2b8ec87..6f37575 100644 --- a/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc +++ b/chrome/browser/devtools/global_confirm_info_bar_browsertest.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/in_process_browser_test.h" #include "components/infobars/core/infobar.h" +#include "components/infobars/core/infobars_switches.h" #include "content/public/test/test_utils.h" namespace { @@ -54,6 +55,22 @@ DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBarTest); }; +// Subclass for tests that require infobars to be disabled. +class GlobalConfirmInfoBarWithInfoBarDisabledTest + : public GlobalConfirmInfoBarTest { + public: + GlobalConfirmInfoBarWithInfoBarDisabledTest() = default; + ~GlobalConfirmInfoBarWithInfoBarDisabledTest() override = default; + + protected: + void SetUpCommandLine(base::CommandLine* command_line) override { + command_line->AppendSwitch(infobars::switches::kDisableInfoBars); + } + + private: + DISALLOW_COPY_AND_ASSIGN(GlobalConfirmInfoBarWithInfoBarDisabledTest); +}; + } // namespace // Creates a global confirm info bar on a browser with 2 tabs and closes it. @@ -129,3 +146,17 @@ for (int i = 0; i < tab_strip_model->count(); i++) EXPECT_EQ(0u, GetInfoBarServiceFromTabIndex(i)->infobar_count()); } + +IN_PROC_BROWSER_TEST_F(GlobalConfirmInfoBarWithInfoBarDisabledTest, + InfoBarsDisabled) { + ASSERT_EQ(1, browser()->tab_strip_model()->count()); + + auto delegate = std::make_unique<TestConfirmInfoBarDelegate>(); + base::WeakPtr<GlobalConfirmInfoBar> global_confirm_info_bar = + GlobalConfirmInfoBar::Show(std::move(delegate)); + + // In this case, the deletion is done asynchronously. + content::RunAllPendingInMessageLoop(); + + ASSERT_FALSE(global_confirm_info_bar); +}
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index 5e70f755..3854393 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -332,11 +332,11 @@ // The contents of the file at |path| may have changed since a previous // request, in which case the associated icon may also have changed. // Therefore, always call LoadIcon instead of attempting a LookupIcon. - im->LoadIcon(path, - icon_size, - base::Bind(&DownloadFileIconExtractorImpl::OnIconLoadComplete, - base::Unretained(this), scale, callback), - &cancelable_task_tracker_); + im->LoadIcon( + path, icon_size, + base::BindOnce(&DownloadFileIconExtractorImpl::OnIconLoadComplete, + base::Unretained(this), scale, callback), + &cancelable_task_tracker_); return true; }
diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc index 7024cdc..c83fcd8 100644 --- a/chrome/browser/extensions/api/history/history_api.cc +++ b/chrome/browser/extensions/api/history/history_api.cc
@@ -270,8 +270,8 @@ GetProfile(), ServiceAccessType::EXPLICIT_ACCESS); hs->QueryURL(url, true, // Retrieve full history of a URL. - base::Bind(&HistoryGetVisitsFunction::QueryComplete, - base::Unretained(this)), + base::BindOnce(&HistoryGetVisitsFunction::QueryComplete, + base::Unretained(this)), &task_tracker_); AddRef(); // Balanced in QueryComplete(). return RespondLater(); // QueryComplete() will be called asynchronously.
diff --git a/chrome/browser/extensions/api/identity/identity_get_accounts_function.cc b/chrome/browser/extensions/api/identity/identity_get_accounts_function.cc index 00eb591..bc4e0341 100644 --- a/chrome/browser/extensions/api/identity/identity_get_accounts_function.cc +++ b/chrome/browser/extensions/api/identity/identity_get_accounts_function.cc
@@ -32,7 +32,7 @@ mojo::MakeRequest(&identity_manager_)); identity_manager_->GetAccounts( - base::Bind(&IdentityGetAccountsFunction::OnGotAccounts, this)); + base::BindOnce(&IdentityGetAccountsFunction::OnGotAccounts, this)); return RespondLater(); }
diff --git a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc index ad7069a0..fe4b773 100644 --- a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc +++ b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc
@@ -293,8 +293,8 @@ // Start listening for the primary account being available and display a // login prompt. GetIdentityManager()->GetPrimaryAccountWhenAvailable( - base::Bind(&IdentityGetAuthTokenFunction::OnPrimaryAccountAvailable, - base::Unretained(this))); + base::BindOnce(&IdentityGetAuthTokenFunction::OnPrimaryAccountAvailable, + base::Unretained(this))); ShowLoginPopup(); }
diff --git a/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc b/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc index 28854cf..4ffdedb 100644 --- a/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc +++ b/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc
@@ -62,7 +62,7 @@ EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); - operation->PostTask(base::Bind(&Operation::Start, operation)); + operation->PostTask(base::BindOnce(&Operation::Start, operation)); content::RunAllTasksUntilIdle(); }
diff --git a/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc b/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc index 8510dfd..6b286c1 100644 --- a/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc +++ b/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.cc
@@ -164,7 +164,7 @@ connector_->BindInterface(chrome::mojom::kRemovableStorageWriterServiceName, mojo::MakeRequest(&removable_storage_writer_)); removable_storage_writer_.set_connection_error_handler( - base::Bind(&ImageWriterUtilityClient::OnConnectionError, this)); + base::BindOnce(&ImageWriterUtilityClient::OnConnectionError, this)); } void ImageWriterUtilityClient::OnConnectionError() {
diff --git a/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client_browsertest.cc b/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client_browsertest.cc index 5c0a2ce..ab1999a5 100644 --- a/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client_browsertest.cc +++ b/chrome/browser/extensions/api/image_writer_private/image_writer_utility_client_browsertest.cc
@@ -44,7 +44,8 @@ base::RunLoop run_loop; base::PostTaskWithTraitsAndReply( FROM_HERE, {base::MayBlock()}, - base::Bind(&ImageWriterUtilityClientTest::FillFile, image_, pattern), + base::BindOnce(&ImageWriterUtilityClientTest::FillFile, image_, + pattern), run_loop.QuitClosure()); run_loop.Run(); @@ -56,7 +57,8 @@ base::RunLoop run_loop; base::PostTaskWithTraitsAndReply( FROM_HERE, {base::MayBlock()}, - base::Bind(&ImageWriterUtilityClientTest::FillFile, device_, pattern), + base::BindOnce(&ImageWriterUtilityClientTest::FillFile, device_, + pattern), run_loop.QuitClosure()); run_loop.Run(); @@ -72,8 +74,8 @@ cancel_ = (option == CANCEL); CreateTaskRunner()->PostTask( - FROM_HERE, base::Bind(&ImageWriterUtilityClientTest::StartWriteTest, - base::Unretained(this))); + FROM_HERE, base::BindOnce(&ImageWriterUtilityClientTest::StartWriteTest, + base::Unretained(this))); run_loop.Run(); EXPECT_TRUE(quit_called_); @@ -148,8 +150,8 @@ } GetTaskRunner()->PostTask( - FROM_HERE, base::Bind(&ImageWriterUtilityClientTest::Shutdown, - base::Unretained(this))); + FROM_HERE, base::BindOnce(&ImageWriterUtilityClientTest::Shutdown, + base::Unretained(this))); } void StartVerifyTest() { @@ -179,8 +181,8 @@ error_ = error; GetTaskRunner()->PostTask( - FROM_HERE, base::Bind(&ImageWriterUtilityClientTest::Shutdown, - base::Unretained(this))); + FROM_HERE, base::BindOnce(&ImageWriterUtilityClientTest::Shutdown, + base::Unretained(this))); } void Verified() { @@ -191,8 +193,8 @@ success_ = !cancel_; GetTaskRunner()->PostTask( - FROM_HERE, base::Bind(&ImageWriterUtilityClientTest::Shutdown, - base::Unretained(this))); + FROM_HERE, base::BindOnce(&ImageWriterUtilityClientTest::Shutdown, + base::Unretained(this))); } void Cancelled() {
diff --git a/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc b/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc index 45ae891..bd4fce2 100644 --- a/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc +++ b/chrome/browser/extensions/api/image_writer_private/operation_manager_unittest.cc
@@ -71,11 +71,10 @@ TestOperationManager manager(&test_profile_); manager.StartWriteFromFile( - kDummyExtensionId, - test_utils_.GetImagePath(), + kDummyExtensionId, test_utils_.GetImagePath(), test_utils_.GetDevicePath().AsUTF8Unsafe(), - base::Bind(&ImageWriterOperationManagerTest::StartCallback, - base::Unretained(this))); + base::BindOnce(&ImageWriterOperationManagerTest::StartCallback, + base::Unretained(this))); EXPECT_TRUE(started_); EXPECT_TRUE(start_success_); @@ -83,8 +82,8 @@ manager.CancelWrite( kDummyExtensionId, - base::Bind(&ImageWriterOperationManagerTest::CancelCallback, - base::Unretained(this))); + base::BindOnce(&ImageWriterOperationManagerTest::CancelCallback, + base::Unretained(this))); EXPECT_TRUE(cancelled_); EXPECT_TRUE(cancel_success_); @@ -97,10 +96,9 @@ TestOperationManager manager(&test_profile_); manager.DestroyPartitions( - kDummyExtensionId, - test_utils_.GetDevicePath().AsUTF8Unsafe(), - base::Bind(&ImageWriterOperationManagerTest::StartCallback, - base::Unretained(this))); + kDummyExtensionId, test_utils_.GetDevicePath().AsUTF8Unsafe(), + base::BindOnce(&ImageWriterOperationManagerTest::StartCallback, + base::Unretained(this))); EXPECT_TRUE(started_); EXPECT_TRUE(start_success_); @@ -108,8 +106,8 @@ manager.CancelWrite( kDummyExtensionId, - base::Bind(&ImageWriterOperationManagerTest::CancelCallback, - base::Unretained(this))); + base::BindOnce(&ImageWriterOperationManagerTest::CancelCallback, + base::Unretained(this))); EXPECT_TRUE(cancelled_); EXPECT_TRUE(cancel_success_);
diff --git a/chrome/browser/extensions/api/image_writer_private/unzip_helper.cc b/chrome/browser/extensions/api/image_writer_private/unzip_helper.cc index e6c03d00..dbca44a 100644 --- a/chrome/browser/extensions/api/image_writer_private/unzip_helper.cc +++ b/chrome/browser/extensions/api/image_writer_private/unzip_helper.cc
@@ -35,8 +35,8 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner = base::CreateSingleThreadTaskRunnerWithTraits( {base::MayBlock(), base::TaskPriority::USER_VISIBLE}); - task_runner->PostTask(FROM_HERE, base::Bind(&UnzipHelper::UnzipImpl, this, - image_path, temp_dir_path)); + task_runner->PostTask(FROM_HERE, base::BindOnce(&UnzipHelper::UnzipImpl, this, + image_path, temp_dir_path)); } void UnzipHelper::UnzipImpl(const base::FilePath& image_path, @@ -72,12 +72,13 @@ } void UnzipHelper::OnError(const std::string& error) { - owner_task_runner_->PostTask(FROM_HERE, base::Bind(failure_callback_, error)); + owner_task_runner_->PostTask(FROM_HERE, + base::BindOnce(failure_callback_, error)); } void UnzipHelper::OnOpenSuccess(const base::FilePath& image_path) { owner_task_runner_->PostTask(FROM_HERE, - base::Bind(open_callback_, image_path)); + base::BindOnce(open_callback_, image_path)); } void UnzipHelper::OnComplete() { @@ -86,7 +87,7 @@ void UnzipHelper::OnProgress(int64_t total_bytes, int64_t curr_bytes) { owner_task_runner_->PostTask( - FROM_HERE, base::Bind(progress_callback_, total_bytes, curr_bytes)); + FROM_HERE, base::BindOnce(progress_callback_, total_bytes, curr_bytes)); } } // namespace image_writer
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc index f672a28..be00ae6 100644 --- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc +++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -713,10 +713,10 @@ metadata::AttachedImage* first_image = &attached_images->front(); content::BrowserContext::CreateMemoryBackedBlob( GetProfile(), first_image->data.c_str(), first_image->data.size(), "", - base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, this, - base::Passed(&result_dictionary), - base::Passed(&attached_images), - base::Passed(base::WrapUnique(new std::vector<std::string>)))); + base::BindOnce(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, + this, std::move(result_dictionary), + std::move(attached_images), + base::WrapUnique(new std::vector<std::string>))); } void MediaGalleriesGetMetadataFunction::ConstructNextBlob( @@ -768,9 +768,9 @@ &(*attached_images)[blob_uuids->size()]; content::BrowserContext::CreateMemoryBackedBlob( GetProfile(), next_image->data.c_str(), next_image->data.size(), "", - base::Bind(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, this, - base::Passed(&result_dictionary), - base::Passed(&attached_images), base::Passed(&blob_uuids))); + base::BindOnce(&MediaGalleriesGetMetadataFunction::ConstructNextBlob, + this, std::move(result_dictionary), + std::move(attached_images), std::move(blob_uuids))); return; }
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host.cc b/chrome/browser/extensions/api/messaging/native_message_process_host.cc index e4ab4bf..09b93a4 100644 --- a/chrome/browser/extensions/api/messaging/native_message_process_host.cc +++ b/chrome/browser/extensions/api/messaging/native_message_process_host.cc
@@ -226,8 +226,8 @@ read_buffer_ = new net::IOBuffer(kReadBufferSize); int result = read_stream_->Read(read_buffer_.get(), kReadBufferSize, - base::Bind(&NativeMessageProcessHost::OnRead, - weak_factory_.GetWeakPtr())); + base::BindOnce(&NativeMessageProcessHost::OnRead, + weak_factory_.GetWeakPtr())); HandleReadResult(result); } } @@ -303,11 +303,10 @@ write_queue_.pop(); } - int result = - write_stream_->Write(current_write_buffer_.get(), - current_write_buffer_->BytesRemaining(), - base::Bind(&NativeMessageProcessHost::OnWritten, - weak_factory_.GetWeakPtr())); + int result = write_stream_->Write( + current_write_buffer_.get(), current_write_buffer_->BytesRemaining(), + base::BindOnce(&NativeMessageProcessHost::OnWritten, + weak_factory_.GetWeakPtr())); HandleWriteResult(result); } }
diff --git a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc b/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc index eb1b11a..64ba95c 100644 --- a/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc +++ b/chrome/browser/extensions/api/storage/policy_value_store_unittest.cc
@@ -114,8 +114,8 @@ void SetCurrentPolicy(const policy::PolicyMap& policies) { GetBackendTaskRunner()->PostTask( FROM_HERE, - base::Bind(&PolicyValueStoreTest::SetCurrentPolicyOnBackendSequence, - base::Unretained(this), base::Passed(policies.DeepCopy()))); + base::BindOnce(&PolicyValueStoreTest::SetCurrentPolicyOnBackendSequence, + base::Unretained(this), policies.DeepCopy())); content::RunAllTasksUntilIdle(); }
diff --git a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc index 8f135ec3..ecf261f 100644 --- a/chrome/browser/extensions/api/storage/settings_sync_unittest.cc +++ b/chrome/browser/extensions/api/storage/settings_sync_unittest.cc
@@ -258,7 +258,8 @@ void PostOnBackendSequenceAndWait(const base::Location& from_here, Func func) { GetBackendTaskRunner()->PostTask( - from_here, base::Bind(&ExtensionSettingsSyncTest::RunFunc<Func>, func)); + from_here, + base::BindOnce(&ExtensionSettingsSyncTest::RunFunc<Func>, func)); content::RunAllTasksUntilIdle(); }
diff --git a/chrome/browser/extensions/app_data_migrator_unittest.cc b/chrome/browser/extensions/app_data_migrator_unittest.cc index 4dc482a2..1f804ee 100644 --- a/chrome/browser/extensions/app_data_migrator_unittest.cc +++ b/chrome/browser/extensions/app_data_migrator_unittest.cc
@@ -132,11 +132,11 @@ GURL extension_url) { fs_context->OpenFileSystem(extension_url, storage::kFileSystemTypeTemporary, storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, - base::Bind(&DidOpenFileSystem)); + base::BindOnce(&DidOpenFileSystem)); fs_context->OpenFileSystem(extension_url, storage::kFileSystemTypePersistent, storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, - base::Bind(&DidOpenFileSystem)); + base::BindOnce(&DidOpenFileSystem)); content::RunAllTasksUntilIdle(); }
diff --git a/chrome/browser/extensions/bookmark_app_helper.cc b/chrome/browser/extensions/bookmark_app_helper.cc index eb591d4..726c354 100644 --- a/chrome/browser/extensions/bookmark_app_helper.cc +++ b/chrome/browser/extensions/bookmark_app_helper.cc
@@ -716,13 +716,13 @@ web_app_info_.open_as_window = true; chrome::ShowPWAInstallDialog( contents_, web_app_info_, - base::Bind(&BookmarkAppHelper::OnBubbleCompleted, - weak_factory_.GetWeakPtr())); + base::BindOnce(&BookmarkAppHelper::OnBubbleCompleted, + weak_factory_.GetWeakPtr())); } else { chrome::ShowBookmarkAppDialog( contents_, web_app_info_, - base::Bind(&BookmarkAppHelper::OnBubbleCompleted, - weak_factory_.GetWeakPtr())); + base::BindOnce(&BookmarkAppHelper::OnBubbleCompleted, + weak_factory_.GetWeakPtr())); } }
diff --git a/chrome/browser/extensions/chrome_app_icon_service.cc b/chrome/browser/extensions/chrome_app_icon_service.cc index 0173a878..1de01c2 100644 --- a/chrome/browser/extensions/chrome_app_icon_service.cc +++ b/chrome/browser/extensions/chrome_app_icon_service.cc
@@ -90,8 +90,9 @@ it->second.erase(icon); if (it->second.empty()) { base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&ChromeAppIconService::MaybeCleanupIconSet, - weak_ptr_factory_.GetWeakPtr(), icon->app_id())); + FROM_HERE, + base::BindOnce(&ChromeAppIconService::MaybeCleanupIconSet, + weak_ptr_factory_.GetWeakPtr(), icon->app_id())); } }
diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc index 825c3f4..9b48e12 100644 --- a/chrome/browser/extensions/extension_disabled_ui.cc +++ b/chrome/browser/extensions/extension_disabled_ui.cc
@@ -298,11 +298,11 @@ // Delay showing the uninstall dialog, so that this function returns // immediately, to close the bubble properly. See crbug.com/121544. base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, - base::Bind(&ExtensionUninstallDialog::ConfirmUninstall, - uninstall_dialog_->AsWeakPtr(), base::RetainedRef(extension_), - UNINSTALL_REASON_EXTENSION_DISABLED, - UNINSTALL_SOURCE_PERMISSIONS_INCREASE)); + FROM_HERE, base::BindOnce(&ExtensionUninstallDialog::ConfirmUninstall, + uninstall_dialog_->AsWeakPtr(), + base::RetainedRef(extension_), + UNINSTALL_REASON_EXTENSION_DISABLED, + UNINSTALL_SOURCE_PERMISSIONS_INCREASE)); } bool ExtensionDisabledGlobalError::ShouldCloseOnDeactivate() const {
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index 6b9346b..f9d7a3d 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -4892,16 +4892,15 @@ ASSERT_TRUE(cookie_store); net::CookieOptions options; cookie_store->SetCookieWithOptionsAsync( - ext_url, "dummy=value", options, - base::Bind(&ExtensionCookieCallback::SetCookieCallback, - base::Unretained(&callback))); + ext_url, "dummy=value", options, + base::BindOnce(&ExtensionCookieCallback::SetCookieCallback, + base::Unretained(&callback))); content::RunAllTasksUntilIdle(); EXPECT_TRUE(callback.result_); cookie_store->GetAllCookiesForURLAsync( - ext_url, - base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, - base::Unretained(&callback))); + ext_url, base::BindOnce(&ExtensionCookieCallback::GetAllCookiesCallback, + base::Unretained(&callback))); content::RunAllTasksUntilIdle(); EXPECT_EQ(1U, callback.list_.size()); @@ -4947,9 +4946,8 @@ // Check that the cookie is gone. cookie_store->GetAllCookiesForURLAsync( - ext_url, - base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback, - base::Unretained(&callback))); + ext_url, base::BindOnce(&ExtensionCookieCallback::GetAllCookiesCallback, + base::Unretained(&callback))); content::RunAllTasksUntilIdle(); EXPECT_EQ(0U, callback.list_.size());
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc index 26486ea..f7691554 100644 --- a/chrome/browser/extensions/extension_tab_util.cc +++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -723,7 +723,7 @@ // options page to close a page that might be open to extension content. // However, if the options page opens inside the chrome://extensions page, we // can override an existing page. - // Note: default ref behavior is IGNORE_REF, which is correct. + // Note: ref behavior is to ignore. params.path_behavior = open_in_tab ? NavigateParams::RESPECT : NavigateParams::IGNORE_AND_NAVIGATE; params.url = url_to_navigate;
diff --git a/chrome/browser/extensions/navigation_observer_browsertest.cc b/chrome/browser/extensions/navigation_observer_browsertest.cc index e0b8240..07503b2 100644 --- a/chrome/browser/extensions/navigation_observer_browsertest.cc +++ b/chrome/browser/extensions/navigation_observer_browsertest.cc
@@ -21,7 +21,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PromptToReEnableExtensionsOnNavigation) { NavigationObserver::SetAllowedRepeatedPromptingForTesting(true); - base::ScopedClosureRunner reset_repeated_prompting(base::Bind([]() { + base::ScopedClosureRunner reset_repeated_prompting(base::BindOnce([]() { NavigationObserver::SetAllowedRepeatedPromptingForTesting(false); })); scoped_refptr<const Extension> extension =
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index 9634f01..9b28b25 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -783,6 +783,11 @@ "Enable cross-platform HarfBuzz layout engine for UI text. Doesn't affect " "web content."; +const char kHideNonActiveAppsFromShelfName[] = + "Hide apps that are not running from the shelf"; +const char kHideNonActiveAppsFromShelfDescription[] = + "Save space in the shelf by hiding apps that are not running."; + const char kHistoryRequiresUserGestureName[] = "New history entries require a user gesture."; const char kHistoryRequiresUserGestureDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 2d7582e..20cab74 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -493,6 +493,9 @@ extern const char kHarfbuzzRendertextName[]; extern const char kHarfbuzzRendertextDescription[]; +extern const char kHideNonActiveAppsFromShelfName[]; +extern const char kHideNonActiveAppsFromShelfDescription[]; + extern const char kHistoryRequiresUserGestureName[]; extern const char kHistoryRequiresUserGestureDescription[]; extern const char kHyperlinkAuditingName[];
diff --git a/chrome/browser/load_library_perf_test.cc b/chrome/browser/load_library_perf_test.cc index 551a6187..8a40db3e 100644 --- a/chrome/browser/load_library_perf_test.cc +++ b/chrome/browser/load_library_perf_test.cc
@@ -74,17 +74,13 @@ } // namespace #if BUILDFLAG(ENABLE_LIBRARY_CDMS) + #if defined(WIDEVINE_CDM_AVAILABLE) TEST(LoadCDMPerfTest, Widevine) { MeasureSizeAndTimeToLoadCdm( kWidevineCdmBaseDirectory, base::GetNativeLibraryName(kWidevineCdmLibraryName)); } - -TEST(LoadCDMPerfTest, WidevineAdapter) { - MeasureSizeAndTimeToLoadCdm(kWidevineCdmBaseDirectory, - kWidevineCdmAdapterFileName); -} #endif // defined(WIDEVINE_CDM_AVAILABLE) TEST(LoadCDMPerfTest, ExternalClearKey) { @@ -93,8 +89,4 @@ base::GetNativeLibraryName(media::kClearKeyCdmLibraryName)); } -TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { - MeasureSizeAndTimeToLoadCdm(media::kClearKeyCdmBaseDirectory, - media::kClearKeyCdmAdapterFileName); -} #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
diff --git a/chrome/browser/media/android/remote/media_controller_bridge.cc b/chrome/browser/media/android/remote/media_controller_bridge.cc new file mode 100644 index 0000000..7f42cb7 --- /dev/null +++ b/chrome/browser/media/android/remote/media_controller_bridge.cc
@@ -0,0 +1,53 @@ +// Copyright 2018 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 "chrome/browser/media/android/remote/media_controller_bridge.h" + +#include "jni/MediaControllerBridge_jni.h" + +namespace media_router { + +MediaControllerBridge::MediaControllerBridge( + base::android::ScopedJavaGlobalRef<jobject> controller) + : j_media_controller_bridge_(controller) {} + +MediaControllerBridge::~MediaControllerBridge() = default; + +void MediaControllerBridge::Play() { + JNIEnv* env = base::android::AttachCurrentThread(); + DCHECK(env); + + Java_MediaControllerBridge_play(env, j_media_controller_bridge_); +} + +void MediaControllerBridge::Pause() { + JNIEnv* env = base::android::AttachCurrentThread(); + DCHECK(env); + + Java_MediaControllerBridge_pause(env, j_media_controller_bridge_); +} + +void MediaControllerBridge::SetMute(bool mute) { + JNIEnv* env = base::android::AttachCurrentThread(); + DCHECK(env); + + Java_MediaControllerBridge_setMute(env, j_media_controller_bridge_, mute); +} + +void MediaControllerBridge::SetVolume(float volume) { + JNIEnv* env = base::android::AttachCurrentThread(); + DCHECK(env); + + Java_MediaControllerBridge_setVolume(env, j_media_controller_bridge_, volume); +} + +void MediaControllerBridge::Seek(base::TimeDelta time) { + JNIEnv* env = base::android::AttachCurrentThread(); + DCHECK(env); + + Java_MediaControllerBridge_seek(env, j_media_controller_bridge_, + time.InMilliseconds()); +} + +} // namespace media_router
diff --git a/chrome/browser/media/android/remote/media_controller_bridge.h b/chrome/browser/media/android/remote/media_controller_bridge.h new file mode 100644 index 0000000..c1e46e99 --- /dev/null +++ b/chrome/browser/media/android/remote/media_controller_bridge.h
@@ -0,0 +1,37 @@ +// Copyright 2018 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 CHROME_BROWSER_MEDIA_ANDROID_REMOTE_MEDIA_CONTROLLER_BRIDGE_H_ +#define CHROME_BROWSER_MEDIA_ANDROID_REMOTE_MEDIA_CONTROLLER_BRIDGE_H_ + +#include "base/android/scoped_java_ref.h" +#include "base/time/time.h" +#include "content/public/browser/media_controller.h" + +namespace media_router { + +// Allows native code to call into a Java MediaController. +class MediaControllerBridge : public content::MediaController { + public: + explicit MediaControllerBridge( + base::android::ScopedJavaGlobalRef<jobject> controller); + ~MediaControllerBridge() override; + + // MediaController implementation. + void Play() override; + void Pause() override; + void SetMute(bool mute) override; + void SetVolume(float volume) override; + void Seek(base::TimeDelta time) override; + + private: + // Java MediaControllerBridge instance. + base::android::ScopedJavaGlobalRef<jobject> j_media_controller_bridge_; + + DISALLOW_COPY_AND_ASSIGN(MediaControllerBridge); +}; + +} // namespace media_router + +#endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_MEDIA_CONTROLLER_BRIDGE_H_
diff --git a/chrome/browser/media/android/router/media_router_android.cc b/chrome/browser/media/android/router/media_router_android.cc index 0135ccd..6ae561f 100644 --- a/chrome/browser/media/android/router/media_router_android.cc +++ b/chrome/browser/media/android/router/media_router_android.cc
@@ -311,4 +311,9 @@ observer.OnRoutesUpdated(active_routes_, std::vector<MediaRoute::Id>()); } +std::unique_ptr<content::MediaController> +MediaRouterAndroid::GetMediaController(const MediaRoute::Id& route_id) { + return bridge_->GetMediaController(route_id); +} + } // namespace media_router
diff --git a/chrome/browser/media/android/router/media_router_android.h b/chrome/browser/media/android/router/media_router_android.h index e42b854..9e0a8789 100644 --- a/chrome/browser/media/android/router/media_router_android.h +++ b/chrome/browser/media/android/router/media_router_android.h
@@ -65,6 +65,8 @@ const std::string& search_input, const std::string& domain, MediaSinkSearchResponseCallback sink_callback) override; + std::unique_ptr<content::MediaController> GetMediaController( + const MediaRoute::Id& route_id) override; // The methods called by the Java bridge. // Notifies the media router that information about sinks is received for
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 4e86648..4ea41fe 100644 --- a/chrome/browser/media/android/router/media_router_android_bridge.cc +++ b/chrome/browser/media/android/router/media_router_android_bridge.cc
@@ -6,12 +6,15 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/browser/media/android/remote/media_controller_bridge.h" #include "chrome/browser/media/android/router/media_router_android.h" +#include "content/public/browser/media_controller.h" #include "jni/ChromeMediaRouter_jni.h" using base::android::ConvertUTF8ToJavaString; using base::android::ConvertJavaStringToUTF8; using base::android::JavaRef; +using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaLocalRef; using base::android::AttachCurrentThread; @@ -117,6 +120,23 @@ jsource_id); } +std::unique_ptr<content::MediaController> +MediaRouterAndroidBridge::GetMediaController(const MediaRoute::Id& route_id) { + JNIEnv* env = base::android::AttachCurrentThread(); + ScopedJavaLocalRef<jstring> jroute_id = + base::android::ConvertUTF8ToJavaString(env, route_id); + + ScopedJavaGlobalRef<jobject> media_controller; + + media_controller.Reset(Java_ChromeMediaRouter_getMediaControllerBridge( + env, java_media_router_, jroute_id)); + + if (media_controller.is_null()) + return nullptr; + + return std::make_unique<MediaControllerBridge>(media_controller); +} + void MediaRouterAndroidBridge::OnSinksReceived( JNIEnv* env, const JavaRef<jobject>& obj,
diff --git a/chrome/browser/media/android/router/media_router_android_bridge.h b/chrome/browser/media/android/router/media_router_android_bridge.h index e3c140a..14b10c1 100644 --- a/chrome/browser/media/android/router/media_router_android_bridge.h +++ b/chrome/browser/media/android/router/media_router_android_bridge.h
@@ -10,6 +10,7 @@ #include "chrome/common/media_router/media_route.h" #include "chrome/common/media_router/media_sink.h" #include "chrome/common/media_router/media_source.h" +#include "content/public/browser/media_controller.h" #include "url/origin.h" namespace media_router { @@ -43,6 +44,8 @@ virtual void DetachRoute(const MediaRoute::Id& route_id); virtual bool StartObservingMediaSinks(const MediaSource::Id& source_id); virtual void StopObservingMediaSinks(const MediaSource::Id& source_id); + virtual std::unique_ptr<content::MediaController> GetMediaController( + const MediaRoute::Id& route_id); // Methods called by the Java counterpart. void OnSinksReceived(JNIEnv* env,
diff --git a/chrome/browser/media/library_cdm_test_helper.cc b/chrome/browser/media/library_cdm_test_helper.cc index f01a772..8a3fc6d 100644 --- a/chrome/browser/media/library_cdm_test_helper.cc +++ b/chrome/browser/media/library_cdm_test_helper.cc
@@ -5,16 +5,10 @@ #include "chrome/browser/media/library_cdm_test_helper.h" #include "base/command_line.h" -#include "base/files/file_util.h" #include "base/native_library.h" #include "base/path_service.h" -#include "base/strings/utf_string_conversions.h" -#include "build/build_config.h" #include "content/public/browser/cdm_registry.h" -#include "content/public/browser/plugin_service.h" #include "content/public/common/cdm_info.h" -#include "content/public/common/content_switches.h" -#include "content/public/common/webplugininfo.h" #include "media/base/media_switches.h" #include "media/cdm/cdm_paths.h" @@ -32,14 +26,6 @@ // Append the switch to register the Clear Key CDM path. command_line->AppendSwitchNative(switches::kClearKeyCdmPathForTesting, cdm_path.value()); - - // Also register the pepper plugin. No need to use the wrong cdm path here as - // the key system will not be supported, and we will never load the CDM. - // TODO(crbug.com/772160) Remove this when pepper CDM support removed. - RegisterPepperCdm(command_line, media::kClearKeyCdmBaseDirectory, - media::kClearKeyCdmAdapterFileName, - media::kClearKeyCdmDisplayName, - media::kClearKeyCdmPepperMimeType); } bool IsLibraryCdmRegistered(const std::string& cdm_guid) { @@ -55,68 +41,3 @@ return false; } - -base::FilePath GetPepperCdmPath(const std::string& adapter_base_dir, - const std::string& adapter_file_name) { - base::FilePath adapter_path; - PathService::Get(base::DIR_MODULE, &adapter_path); - adapter_path = adapter_path.Append( - media::GetPlatformSpecificDirectory(adapter_base_dir)); - adapter_path = adapter_path.AppendASCII(adapter_file_name); - return adapter_path; -} - -base::FilePath::StringType BuildPepperCdmRegistration( - const std::string& adapter_base_dir, - const std::string& adapter_file_name, - const std::string& display_name, - const std::string& mime_type, - bool expect_adapter_exists) { - base::FilePath adapter_path = - GetPepperCdmPath(adapter_base_dir, adapter_file_name); - DCHECK_EQ(expect_adapter_exists, base::PathExists(adapter_path)) - << adapter_path.MaybeAsASCII(); - - base::FilePath::StringType pepper_cdm_registration = adapter_path.value(); - - std::string string_to_append = "#"; - string_to_append.append(display_name); - string_to_append.append("#CDM#0.1.0.0;"); - string_to_append.append(mime_type); - -#if defined(OS_WIN) - pepper_cdm_registration.append(base::ASCIIToUTF16(string_to_append)); -#else - pepper_cdm_registration.append(string_to_append); -#endif - - return pepper_cdm_registration; -} - -void RegisterPepperCdm(base::CommandLine* command_line, - const std::string& adapter_base_dir, - const std::string& adapter_file_name, - const std::string& display_name, - const std::string& mime_type, - bool expect_adapter_exists) { - base::FilePath::StringType pepper_cdm_registration = - BuildPepperCdmRegistration(adapter_base_dir, adapter_file_name, - display_name, mime_type, - expect_adapter_exists); - - // Append the switch to register the CDM Adapter. - command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, - pepper_cdm_registration); -} - -bool IsPepperCdmRegistered(const std::string& mime_type) { - std::vector<content::WebPluginInfo> plugins; - content::PluginService::GetInstance()->GetInternalPlugins(&plugins); - for (const auto& plugin : plugins) { - for (const auto& plugin_mime_type : plugin.mime_types) { - if (plugin_mime_type.mime_type == mime_type) - return true; - } - } - return false; -}
diff --git a/chrome/browser/media/library_cdm_test_helper.h b/chrome/browser/media/library_cdm_test_helper.h index 9ee67e84..837ad4e 100644 --- a/chrome/browser/media/library_cdm_test_helper.h +++ b/chrome/browser/media/library_cdm_test_helper.h
@@ -19,32 +19,4 @@ bool IsLibraryCdmRegistered(const std::string& cdm_guid); -// TODO(crbug.com/403462): Remove the following after pepper CDM is deprecated. - -// Returns the path a pepper CDM adapter. -base::FilePath GetPepperCdmPath(const std::string& adapter_base_dir, - const std::string& adapter_file_name); - -// Builds the string to pass to kRegisterPepperPlugins for a single -// CDM using the provided parameters and a dummy version. -// Multiple results may be passed to kRegisterPepperPlugins, separated by ",". -// The CDM adapter should be located in DIR_MODULE. -base::FilePath::StringType BuildPepperCdmRegistration( - const std::string& adapter_base_dir, - const std::string& adapter_file_name, - const std::string& display_name, - const std::string& mime_type, - bool expect_adapter_exists = true); - -// Registers pepper CDM in |command_line|. -void RegisterPepperCdm(base::CommandLine* command_line, - const std::string& adapter_base_dir, - const std::string& adapter_file_name, - const std::string& display_name, - const std::string& mime_type, - bool expect_adapter_exists = true); - -// Returns whether a pepper CDM with |mime_type| is registered. -bool IsPepperCdmRegistered(const std::string& mime_type); - #endif // CHROME_BROWSER_MEDIA_LIBRARY_CDM_TEST_HELPER_H_
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc index 77a2f6d..fada978 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc
@@ -62,10 +62,6 @@ std::string friendly_name = service_data["fn"]; if (friendly_name.empty()) return ErrorType::MISSING_FRIENDLY_NAME; - std::string processed_uuid = MediaSinkInternal::ProcessDeviceUUID(unique_id); - std::string sink_id = base::StringPrintf("cast:<%s>", processed_uuid.c_str()); - MediaSink sink(sink_id, friendly_name, SinkIconType::CAST, - MediaRouteProviderId::CAST); CastSinkExtraData extra_data; extra_data.ip_endpoint = @@ -77,6 +73,13 @@ if (base::StringToUint(service_data["ca"], &capacities)) extra_data.capabilities = capacities; + std::string processed_uuid = MediaSinkInternal::ProcessDeviceUUID(unique_id); + std::string sink_id = base::StringPrintf("cast:<%s>", processed_uuid.c_str()); + MediaSink sink( + sink_id, friendly_name, + CastMediaSinkServiceImpl::GetCastSinkIconType(extra_data.capabilities), + MediaRouteProviderId::CAST); + cast_sink->set_sink(sink); cast_sink->set_cast_data(extra_data);
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.cc b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.cc index 7c733e0..6507292 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.cc +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.cc
@@ -32,6 +32,9 @@ // Replace the "dial:" prefix with "cast:". std::string sink_id = "cast:" + dial_sink_id.substr(5); + + // Note that the real sink icon will be determined later using information + // from the opened cast channel. MediaSink sink(sink_id, friendly_name, SinkIconType::CAST, MediaRouteProviderId::CAST); @@ -162,6 +165,17 @@ // static constexpr int CastMediaSinkServiceImpl::kMaxDialSinkFailureCount; +// static +SinkIconType CastMediaSinkServiceImpl::GetCastSinkIconType( + uint8_t capabilities) { + if (capabilities & cast_channel::CastDeviceCapability::VIDEO_OUT) + return SinkIconType::CAST; + + return capabilities & cast_channel::CastDeviceCapability::MULTIZONE_GROUP + ? SinkIconType::CAST_AUDIO_GROUP + : SinkIconType::CAST_AUDIO; +} + CastMediaSinkServiceImpl::CastMediaSinkServiceImpl( const OnSinksDiscoveredCallback& callback, Observer* observer, @@ -532,7 +546,12 @@ extra_data.capabilities = cast_channel::CastDeviceCapability::AUDIO_OUT; if (!socket->audio_only()) extra_data.capabilities |= cast_channel::CastDeviceCapability::VIDEO_OUT; + + // We can now set the proper icon type now that capabilities is determined. + cast_sink.sink().set_icon_type( + GetCastSinkIconType(extra_data.capabilities)); } + extra_data.cast_channel_id = socket->id(); cast_sink.set_cast_data(extra_data);
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h index 92c7bcd..adb0a09 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h
@@ -61,6 +61,10 @@ // before we can say confidently that it is unlikely to be a Cast device. static constexpr int kMaxDialSinkFailureCount = 10; + // Returns the icon type to use according to |capabilities|. |capabilities| is + // a bit set of cast_channel::CastDeviceCapabilities in CastSinkExtraData. + static SinkIconType GetCastSinkIconType(uint8_t capabilities); + // |callback|: Callback passed to MediaSinkServiceBase. // |observer|: Observer to invoke on sink updates. Can be nullptr. // |cast_socket_service|: CastSocketService to use to open Cast channels to
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl_unittest.cc b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl_unittest.cc index c00d68e..5970f77 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl_unittest.cc +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl_unittest.cc
@@ -477,6 +477,7 @@ cast_channel::MockCastSocket socket2; socket1.set_id(1); socket2.set_id(2); + socket2.SetAudioOnly(true); // Channel 1, 2 opened. EXPECT_CALL(*mock_cast_socket_service_, @@ -498,7 +499,16 @@ media_sink_service_impl_.OnDialSinkAdded(dial_sink2); base::RunLoop().RunUntilIdle(); // Verify sink content. - EXPECT_EQ(2u, media_sink_service_impl_.current_sinks_map_.size()); + const auto& sinks_map = media_sink_service_impl_.current_sinks_map_; + EXPECT_EQ(2u, sinks_map.size()); + + auto sink_it = sinks_map.find(ip_endpoint1); + ASSERT_TRUE(sink_it != sinks_map.end()); + EXPECT_EQ(SinkIconType::CAST, sink_it->second.sink().icon_type()); + + sink_it = sinks_map.find(ip_endpoint2); + ASSERT_TRUE(sink_it != sinks_map.end()); + EXPECT_EQ(SinkIconType::CAST_AUDIO, sink_it->second.sink().icon_type()); } TEST_F(CastMediaSinkServiceImplTest, TestOnDialSinkAddedSkipsIfNonCastDevice) {
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_unittest.cc b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_unittest.cc index 02646b5..2fc2646 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_unittest.cc +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service_unittest.cc
@@ -22,6 +22,7 @@ using ::testing::Return; using ::testing::SaveArg; using ::testing::_; +using cast_channel::CastDeviceCapability; namespace { @@ -32,7 +33,7 @@ return net::IPEndPoint(ip_address, 8009 + num); } -media_router::DnsSdService CreateDnsService(int num) { +media_router::DnsSdService CreateDnsService(int num, int capabilities) { net::IPEndPoint ip_endpoint = CreateIPEndPoint(num); media_router::DnsSdService service; service.service_name = @@ -44,6 +45,7 @@ service.service_data.push_back( base::StringPrintf("fn=friendly name %d", num)); service.service_data.push_back(base::StringPrintf("md=model name %d", num)); + service.service_data.push_back(base::StringPrintf("ca=%d", capabilities)); return service; } @@ -165,11 +167,14 @@ } TEST_F(CastMediaSinkServiceTest, TestOnDnsSdEvent) { - DnsSdService service1 = CreateDnsService(1); - DnsSdService service2 = CreateDnsService(2); + DnsSdService service1 = CreateDnsService( + 1, CastDeviceCapability::VIDEO_OUT | CastDeviceCapability::AUDIO_OUT); + DnsSdService service2 = + CreateDnsService(2, CastDeviceCapability::MULTIZONE_GROUP); + DnsSdService service3 = CreateDnsService(3, CastDeviceCapability::NONE); // Add dns services. - DnsSdRegistry::DnsSdServiceList service_list{service1, service2}; + DnsSdRegistry::DnsSdServiceList service_list{service1, service2, service3}; // Invoke CastSocketService::OpenSocket on the IO thread. media_sink_service_->OnDnsSdEvent(CastMediaSinkService::kCastServiceType, @@ -181,7 +186,10 @@ // Invoke OpenChannels on |task_runner_|. task_runner_->RunUntilIdle(); // Verify sink content - EXPECT_EQ(2u, sinks.size()); + ASSERT_EQ(3u, sinks.size()); + EXPECT_EQ(SinkIconType::CAST, sinks[0].sink().icon_type()); + EXPECT_EQ(SinkIconType::CAST_AUDIO_GROUP, sinks[1].sink().icon_type()); + EXPECT_EQ(SinkIconType::CAST_AUDIO, sinks[2].sink().icon_type()); } } // namespace media_router
diff --git a/chrome/browser/media/router/media_router.h b/chrome/browser/media/router/media_router.h index 49b9621..7413fd2a 100644 --- a/chrome/browser/media/router/media_router.h +++ b/chrome/browser/media/router/media_router.h
@@ -17,11 +17,11 @@ #include "build/build_config.h" #include "chrome/browser/media/cast_remoting_connector.h" #include "chrome/browser/media/router/route_message_observer.h" -#include "chrome/common/media_router/discovery/media_sink_internal.h" #include "chrome/common/media_router/media_route.h" #include "chrome/common/media_router/media_sink.h" #include "chrome/common/media_router/media_source.h" #include "components/keyed_service/core/keyed_service.h" +#include "content/public/browser/media_controller.h" #include "content/public/browser/presentation_service_delegate.h" namespace content { @@ -189,6 +189,11 @@ // there is a change to the media routes, subclass MediaRoutesObserver. virtual std::vector<MediaRoute> GetCurrentRoutes() const = 0; + // Returns a controller that directly sends commands to media within a route. + // Returns a nullptr if no controller can be be found from |route_id|. + virtual std::unique_ptr<content::MediaController> GetMediaController( + const MediaRoute::Id& route_id) = 0; + #if !defined(OS_ANDROID) // Returns a controller for sending media commands to a route. Returns a // nullptr if no MediaRoute exists for the given |route_id|.
diff --git a/chrome/browser/media/router/media_router_base.cc b/chrome/browser/media/router/media_router_base.cc index e107da1c..66554a0ef 100644 --- a/chrome/browser/media/router/media_router_base.cc +++ b/chrome/browser/media/router/media_router_base.cc
@@ -84,6 +84,11 @@ return internal_routes_observer_->current_routes; } +std::unique_ptr<content::MediaController> MediaRouterBase::GetMediaController( + const MediaRoute::Id& route_id) { + return nullptr; +} + #if !defined(OS_ANDROID) scoped_refptr<MediaRouteController> MediaRouterBase::GetRouteController( const MediaRoute::Id& route_id) {
diff --git a/chrome/browser/media/router/media_router_base.h b/chrome/browser/media/router/media_router_base.h index 7da9c90..9827a37 100644 --- a/chrome/browser/media/router/media_router_base.h +++ b/chrome/browser/media/router/media_router_base.h
@@ -17,6 +17,7 @@ #include "chrome/browser/media/router/media_router.h" #include "chrome/browser/media/router/media_routes_observer.h" #include "chrome/common/media_router/media_route.h" +#include "content/public/browser/media_controller.h" namespace media_router { @@ -33,6 +34,8 @@ void OnIncognitoProfileShutdown() override; IssueManager* GetIssueManager() final; std::vector<MediaRoute> GetCurrentRoutes() const override; + std::unique_ptr<content::MediaController> GetMediaController( + const MediaRoute::Id& route_id) override; #if !defined(OS_ANDROID) scoped_refptr<MediaRouteController> GetRouteController( const MediaRoute::Id& route_id) override;
diff --git a/chrome/browser/media/router/presentation/presentation_service_delegate_impl.cc b/chrome/browser/media/router/presentation/presentation_service_delegate_impl.cc index 18a177fa..51cc0b5 100644 --- a/chrome/browser/media/router/presentation/presentation_service_delegate_impl.cc +++ b/chrome/browser/media/router/presentation/presentation_service_delegate_impl.cc
@@ -673,6 +673,20 @@ observer.OnDefaultPresentationRemoved(); } +std::unique_ptr<content::MediaController> +PresentationServiceDelegateImpl::GetMediaController( + int render_process_id, + int render_frame_id, + const std::string& presentation_id) { + const RenderFrameHostId rfh_id(render_process_id, render_frame_id); + MediaRoute::Id route_id = GetRouteId(rfh_id, presentation_id); + + if (route_id.empty()) + return nullptr; + + return router_->GetMediaController(route_id); +} + MediaRoute::Id PresentationServiceDelegateImpl::GetRouteId( const RenderFrameHostId& render_frame_host_id, const std::string& presentation_id) const {
diff --git a/chrome/browser/media/router/presentation/presentation_service_delegate_impl.h b/chrome/browser/media/router/presentation/presentation_service_delegate_impl.h index dfaead3..6954fca 100644 --- a/chrome/browser/media/router/presentation/presentation_service_delegate_impl.h +++ b/chrome/browser/media/router/presentation/presentation_service_delegate_impl.h
@@ -21,6 +21,7 @@ #include "chrome/browser/media/router/presentation/presentation_service_delegate_observers.h" #include "chrome/browser/media/router/presentation/render_frame_host_id.h" #include "chrome/common/media_router/media_source.h" +#include "content/public/browser/media_controller.h" #include "content/public/browser/presentation_request.h" #include "content/public/browser/presentation_service_delegate.h" #include "content/public/browser/web_contents_observer.h" @@ -110,6 +111,10 @@ void Terminate(int render_process_id, int render_frame_id, const std::string& presentation_id) override; + std::unique_ptr<content::MediaController> GetMediaController( + int render_process_id, + int render_frame_id, + const std::string& presentation_id) override; void ListenForConnectionStateChange( int render_process_id, int render_frame_id,
diff --git a/chrome/browser/media/router/test/mock_media_router.h b/chrome/browser/media/router/test/mock_media_router.h index 505593b..09fb002 100644 --- a/chrome/browser/media/router/test/mock_media_router.h +++ b/chrome/browser/media/router/test/mock_media_router.h
@@ -136,8 +136,6 @@ const std::string& domain, MediaSinkSearchResponseCallback& sink_callback)); - MOCK_METHOD2(ProvideSinks, - void(const std::string&, std::vector<MediaSinkInternal>)); MOCK_METHOD1(OnPresentationSessionDetached, void(const MediaRoute::Id& route_id)); std::unique_ptr<PresentationConnectionStateSubscription>
diff --git a/chrome/browser/media/router/test/test_helper.h b/chrome/browser/media/router/test/test_helper.h index 9b0ed735..f7692e0 100644 --- a/chrome/browser/media/router/test/test_helper.h +++ b/chrome/browser/media/router/test/test_helper.h
@@ -17,7 +17,6 @@ #include "chrome/browser/media/router/issues_observer.h" #include "chrome/browser/media/router/media_routes_observer.h" #include "chrome/browser/media/router/media_sinks_observer.h" -#include "chrome/common/media_router/discovery/media_sink_internal.h" #include "content/public/browser/presentation_service_delegate.h" #include "content/public/common/presentation_connection_message.h" #include "testing/gmock/include/gmock/gmock.h" @@ -27,6 +26,7 @@ #include "chrome/browser/media/router/discovery/dial/dial_url_fetcher.h" #include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service.h" #include "chrome/browser/media/router/discovery/mdns/cast_media_sink_service_impl.h" +#include "chrome/common/media_router/discovery/media_sink_internal.h" #include "net/base/ip_endpoint.h" #include "services/network/test/test_url_loader_factory.h" #endif // !defined(OS_ANDROID)
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc index bef2eac7..a4079b1 100644 --- a/chrome/browser/pdf/pdf_extension_test.cc +++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -55,6 +55,7 @@ #include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/content_features.h" #include "content/public/common/context_menu_params.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_navigation_observer.h" @@ -198,6 +199,15 @@ return pdf_extension_test_util::EnsurePDFHasLoaded(web_contents); } + // Same as LoadPDF(), but loads into a new tab. + bool LoadPdfInNewTab(const GURL& url) { + ui_test_utils::NavigateToURLWithDisposition( + browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + WebContents* web_contents = GetActiveWebContents(); + return pdf_extension_test_util::EnsurePDFHasLoaded(web_contents); + } + // Same as LoadPdf(), but also returns a pointer to the guest WebContents for // the loaded PDF. Returns nullptr if the load fails. WebContents* LoadPdfGetGuestContents(const GURL& url) { @@ -887,6 +897,42 @@ EXPECT_EQ(base::ASCIIToUTF16("test.pdf"), GetActiveWebContents()->GetTitle()); } +IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MultipleDomains) { + for (const auto& url : + {embedded_test_server()->GetURL("a.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("b.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("c.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("d.com", "/pdf/test.pdf")}) { + ASSERT_TRUE(LoadPdfInNewTab(url)); + } + EXPECT_EQ(1, CountPDFProcesses()); +} + +class PDFIsolatedExtensionTest : public PDFExtensionTest { + public: + PDFIsolatedExtensionTest() {} + ~PDFIsolatedExtensionTest() override {} + + void SetUp() override { + features_.InitAndEnableFeature(features::kPdfIsolation); + PDFExtensionTest::SetUp(); + } + + private: + base::test::ScopedFeatureList features_; +}; + +IN_PROC_BROWSER_TEST_F(PDFIsolatedExtensionTest, MultipleDomains) { + for (const auto& url : + {embedded_test_server()->GetURL("a.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("b.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("c.com", "/pdf/test.pdf"), + embedded_test_server()->GetURL("d.com", "/pdf/test.pdf")}) { + ASSERT_TRUE(LoadPdfInNewTab(url)); + } + EXPECT_EQ(4, CountPDFProcesses()); +} + class PDFExtensionLinkClickTest : public PDFExtensionTest { public: PDFExtensionLinkClickTest() : guest_contents_(nullptr) {}
diff --git a/chrome/browser/resources/PRESUBMIT.py b/chrome/browser/resources/PRESUBMIT.py index e2a39c26..6767998 100644 --- a/chrome/browser/resources/PRESUBMIT.py +++ b/chrome/browser/resources/PRESUBMIT.py
@@ -8,6 +8,7 @@ for more details about the presubmit API built into depot_tools. """ +import os ACTION_XML_PATH = '../../../tools/metrics/actions/actions.xml' @@ -96,7 +97,7 @@ def RunOptimizeWebUiTests(input_api, output_api): presubmit_path = input_api.PresubmitLocalPath() - sources = ['optimize_webui_test.py', 'unpack_pak.py'] + sources = ['optimize_webui_test.py', 'unpack_pak_test.py'] tests = [input_api.os_path.join(presubmit_path, s) for s in sources] return input_api.canned_checks.RunUnitTests(input_api, output_api, tests) @@ -122,7 +123,10 @@ affected = input_api.AffectedFiles() if any(f for f in affected if f.LocalPath().endswith('.html')): results += CheckHtml(input_api, output_api) - if any(f for f in affected if f.LocalPath().endswith('optimize_webui.py')): + + webui_sources = set(['optimize_webui.py', 'unpack_pak.py']) + affected_filenames = set([os.path.basename(f.LocalPath()) for f in affected]) + if webui_sources.intersection(affected_filenames): results += RunOptimizeWebUiTests(input_api, output_api) results += _CheckWebDevStyle(input_api, output_api) results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api,
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 747ace0..22fdd21 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -254,11 +254,19 @@ const GURL& url, Browser* browser, WindowOpenDisposition disposition) { + content::WindowedNotificationObserver observer( + content::NOTIFICATION_LOAD_STOP, + content::NotificationService::AllSources()); + NavigateParams params(MakeNavigateParams(browser)); params.disposition = disposition; params.url = url; params.window_action = NavigateParams::SHOW_WINDOW; Navigate(¶ms); + + if (params.disposition != WindowOpenDisposition::SWITCH_TO_TAB) + observer.Wait(); + return params.browser; } @@ -320,56 +328,6 @@ } IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, - Disposition_SingletonTabRespectingRef) { - GURL singleton_ref_url1("http://maps.google.com/#a"); - GURL singleton_ref_url2("http://maps.google.com/#b"); - GURL singleton_ref_url3("http://maps.google.com/"); - - chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, - ui::PAGE_TRANSITION_LINK); - - // We should have one browser with 2 tabs, 2nd selected. - EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); - EXPECT_EQ(2, browser()->tab_strip_model()->count()); - EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); - - // Navigate to singleton_url2. - NavigateParams params(MakeNavigateParams()); - params.disposition = WindowOpenDisposition::SINGLETON_TAB; - params.url = singleton_ref_url2; - Navigate(¶ms); - - // We should now have 2 tabs, the 2nd one selected. - EXPECT_EQ(browser(), params.browser); - EXPECT_EQ(2, browser()->tab_strip_model()->count()); - EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); - - // Navigate to singleton_url2, but with respect ref set. - params = MakeNavigateParams(); - params.disposition = WindowOpenDisposition::SINGLETON_TAB; - params.url = singleton_ref_url2; - params.ref_behavior = NavigateParams::RESPECT_REF; - Navigate(¶ms); - - // We should now have 3 tabs, the 3th one selected. - EXPECT_EQ(browser(), params.browser); - EXPECT_EQ(3, browser()->tab_strip_model()->count()); - EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); - - // Navigate to singleton_url3. - params = MakeNavigateParams(); - params.disposition = WindowOpenDisposition::SINGLETON_TAB; - params.url = singleton_ref_url3; - params.ref_behavior = NavigateParams::RESPECT_REF; - Navigate(¶ms); - - // We should now have 4 tabs, the 4th one selected. - EXPECT_EQ(browser(), params.browser); - EXPECT_EQ(4, browser()->tab_strip_model()->count()); - EXPECT_EQ(3, browser()->tab_strip_model()->active_index()); -} - -IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_SingletonTabNoneExisting) { GURL singleton_url1("http://maps.google.com/"); @@ -692,6 +650,31 @@ WindowOpenDisposition::SWITCH_TO_TAB); } +// This test verifies that IsTabOpenWithURL() and GetIndexOfExistingTab() +// will not discriminate between http and https. +IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, SchemeMismatchTabSwitchTest) { + GURL navigate_url("https://maps.google.com/"); + GURL search_url("http://maps.google.com/"); + + // Generate history so the tab isn't closed. + NavigateHelper(GURL("chrome://dino/"), browser(), + WindowOpenDisposition::CURRENT_TAB); + + NavigateHelper(navigate_url, browser(), + WindowOpenDisposition::NEW_BACKGROUND_TAB); + + // We must be on another tab than the target for it to be found and + // switched to. + EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); + + ChromeAutocompleteProviderClient client(browser()->profile()); + EXPECT_TRUE(client.IsTabOpenWithURL(search_url, nullptr)); + + NavigateHelper(search_url, browser(), WindowOpenDisposition::SWITCH_TO_TAB); + + EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); +} + // This test verifies that we're picking the correct browser and tab to // switch to. It verifies that we don't recommend the active tab, and that, // when switching, we don't mistakenly pick the current browser. @@ -713,7 +696,7 @@ // actively avoid it (because the user almost certainly doesn't want to // switch to the tab they're already on). While we are not on the target // tab, make sure the provider client recommends our other window. - EXPECT_TRUE(client.IsTabOpenWithURL(singleton_url)); + EXPECT_TRUE(client.IsTabOpenWithURL(singleton_url, nullptr)); // Navigate to the singleton again. Browser* test_browser = NavigateHelper(singleton_url, middle_browser, @@ -724,7 +707,7 @@ EXPECT_EQ(orig_browser, test_browser); // Now that we're on the tab, make sure the provider client doesn't // recommend it. - EXPECT_FALSE(client.IsTabOpenWithURL(singleton_url)); + EXPECT_FALSE(client.IsTabOpenWithURL(singleton_url, nullptr)); } // This test verifies that "switch to tab" prefers the latest used browser, @@ -1126,39 +1109,6 @@ } // This test verifies that constructing params with disposition = SINGLETON_TAB -// and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus -// the path). -IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, - Disposition_SingletonTabExistingSubPath_IgnorePath2) { - GURL singleton_url1(GetContentSettingsURL()); - chrome::AddSelectedTabWithURL(browser(), singleton_url1, - ui::PAGE_TRANSITION_LINK); - chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), - ui::PAGE_TRANSITION_LINK); - - // We should have one browser with 3 tabs, the 3rd selected. - EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); - EXPECT_EQ(3, browser()->tab_strip_model()->count()); - EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); - - // Navigate to singleton_url1. - NavigateParams params(MakeNavigateParams()); - params.disposition = WindowOpenDisposition::SINGLETON_TAB; - params.url = GetClearBrowsingDataURL(); - params.window_action = NavigateParams::SHOW_WINDOW; - params.path_behavior = NavigateParams::IGNORE_AND_STAY_PUT; - Navigate(¶ms); - - // The middle tab should now be selected. - EXPECT_EQ(browser(), params.browser); - EXPECT_EQ(3, browser()->tab_strip_model()->count()); - EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); - EXPECT_EQ(singleton_url1, - ShortenUberURL(browser()->tab_strip_model()-> - GetActiveWebContents()->GetURL())); -} - -// This test verifies that constructing params with disposition = SINGLETON_TAB // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently // selected tab is a match but has a different path. IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
diff --git a/chrome/browser/ui/browser_navigator_params.h b/chrome/browser/ui/browser_navigator_params.h index a4f945c8..6bd393b 100644 --- a/chrome/browser/ui/browser_navigator_params.h +++ b/chrome/browser/ui/browser_navigator_params.h
@@ -197,20 +197,9 @@ RESPECT, // Ignore path when finding existing tab, navigate to new URL. IGNORE_AND_NAVIGATE, - // Ignore path when finding existing tab, don't navigate tab. - IGNORE_AND_STAY_PUT, }; PathBehavior path_behavior = RESPECT; - // What to do with the ref component of the URL for singleton navigations. - enum RefBehavior { - // Two URLs with differing refs are same. - IGNORE_REF, - // Two URLs with differing refs are different. - RESPECT_REF, - }; - RefBehavior ref_behavior = IGNORE_REF; - #if !defined(OS_ANDROID) // [in] Specifies a Browser object where the navigation could occur or the // tab could be added. Navigate() is not obliged to use this Browser if
diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc index ca08535..eb3e50819 100644 --- a/chrome/browser/ui/chrome_pages.cc +++ b/chrome/browser/ui/chrome_pages.cc
@@ -201,7 +201,7 @@ base::RecordAction(UserMetricsAction("ShowBookmarkManager")); NavigateParams params( GetSingletonTabNavigateParams(browser, GURL(kChromeUIBookmarksURL))); - params.path_behavior = NavigateParams::IGNORE_AND_STAY_PUT; + params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; ShowSingletonTabOverwritingNTP(browser, params); }
diff --git a/chrome/browser/ui/singleton_tabs.cc b/chrome/browser/ui/singleton_tabs.cc index 6019fb0..aefcb095 100644 --- a/chrome/browser/ui/singleton_tabs.cc +++ b/chrome/browser/ui/singleton_tabs.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/singleton_tabs.h" +#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/search.h" #include "chrome/browser/ui/browser.h" @@ -19,13 +20,11 @@ // Returns true if two URLs are equal after taking |replacements| into account. bool CompareURLsWithReplacements(const GURL& url, const GURL& other, - const url::Replacements<char>& replacements) { - if (url == other) - return true; - + const url::Replacements<char>& replacements, + ChromeAutocompleteProviderClient* client) { GURL url_replaced = url.ReplaceComponents(replacements); GURL other_replaced = other.ReplaceComponents(replacements); - return url_replaced == other_replaced; + return client->StrippedURLsAreEqual(url_replaced, other_replaced, nullptr); } } // namespace @@ -37,7 +36,6 @@ void ShowSingletonTabRespectRef(Browser* browser, const GURL& url) { NavigateParams params(GetSingletonTabNavigateParams(browser, url)); - params.ref_behavior = NavigateParams::RESPECT_REF; Navigate(¶ms); } @@ -89,6 +87,7 @@ content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( &rewritten_url, browser->profile(), &reverse_on_redirect); + ChromeAutocompleteProviderClient client(browser->profile()); // If there are several matches: prefer the active tab by starting there. int start_index = std::max(0, browser->tab_strip_model()->active_index()); int tab_count = browser->tab_strip_model()->count(); @@ -109,17 +108,16 @@ &rewritten_tab_url, browser->profile(), &reverse_on_redirect); url::Replacements<char> replacements; - if (params.ref_behavior == NavigateParams::IGNORE_REF) - replacements.ClearRef(); - if (params.path_behavior == NavigateParams::IGNORE_AND_NAVIGATE || - params.path_behavior == NavigateParams::IGNORE_AND_STAY_PUT) { + replacements.ClearRef(); + if (params.path_behavior == NavigateParams::IGNORE_AND_NAVIGATE) { replacements.ClearPath(); replacements.ClearQuery(); } - if (CompareURLsWithReplacements(tab_url, params.url, replacements) || + if (CompareURLsWithReplacements(tab_url, params.url, replacements, + &client) || CompareURLsWithReplacements(rewritten_tab_url, rewritten_url, - replacements)) { + replacements, &client)) { return tab_index; } }
diff --git a/chrome/browser/ui/tabs/tab_ukm_test_helper.cc b/chrome/browser/ui/tabs/tab_ukm_test_helper.cc index a1a79be..b8e590b 100644 --- a/chrome/browser/ui/tabs/tab_ukm_test_helper.cc +++ b/chrome/browser/ui/tabs/tab_ukm_test_helper.cc
@@ -192,9 +192,3 @@ CHECK(!entries.empty()); return entries.back(); } - -ukm::SourceId UkmEntryChecker::GetSourceIdForUrl(const GURL& source_url) const { - const ukm::UkmSource* source = ukm_recorder_.GetSourceForUrl(source_url); - CHECK(source); - return source->id(); -}
diff --git a/chrome/browser/ui/tabs/tab_ukm_test_helper.h b/chrome/browser/ui/tabs/tab_ukm_test_helper.h index 890b580..7217282 100644 --- a/chrome/browser/ui/tabs/tab_ukm_test_helper.h +++ b/chrome/browser/ui/tabs/tab_ukm_test_helper.h
@@ -64,8 +64,6 @@ // Returns the last recorded entry for |entry_name|. const ukm::mojom::UkmEntry* LastUkmEntry(const std::string& entry_name) const; - ukm::SourceId GetSourceIdForUrl(const GURL& source_url) const; - private: ukm::TestAutoSetUkmRecorder ukm_recorder_;
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 7424f18..28bfd2c 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -48,6 +48,7 @@ #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" +#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_metrics.h" @@ -124,9 +125,6 @@ // Maximum size of buttons on the bookmark bar. static const int kMaxButtonWidth = 150; -// Corner radius for masking the ink drop effects on buttons. -static const int kInkDropCornerRadius = 2; - // Number of pixels the attached bookmark bar overlaps with the toolbar. static const int kToolbarAttachedBookmarkBarOverlap = 3; @@ -167,13 +165,62 @@ return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); } -constexpr int kInkDropVerticalInsetPx = 1; +bool IsTouchOptimized() { + return ui::MaterialDesignController::IsTouchOptimizedUiEnabled(); +} -// Ink drop ripple/highlight for bookmark buttons should be inset 1px vertically -// so that they do not touch the bookmark bar borders. -// TODO(estade): currently this is used as DIP rather than pixels. This should -// be fixed: see crbug.com/706228 -constexpr gfx::Insets kInkDropInsets(kInkDropVerticalInsetPx, 0); +int GetInkDropCornerRadius() { + return IsTouchOptimized() ? 4 : 2; +} + +gfx::Insets GetInkDropInsets() { + // Ink drop ripple/highlight for bookmark buttons should be inset 1px + // vertically so that they do not touch the bookmark bar borders. + // TODO(estade): currently this is used as DIP rather than pixels. This + // should be fixed: see https://crbug.com/706228 + return IsTouchOptimized() ? gfx::Insets(3, 3) : gfx::Insets(1, 0); +} + +SkColor GetBookmarkButtonInkDropBaseColor(const ui::ThemeProvider* tp) { + if (IsTouchOptimized()) { + return color_utils::BlendTowardOppositeLuma( + tp->GetColor(ThemeProperties::COLOR_TOOLBAR), SK_AlphaOPAQUE); + } + return tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); +} + +std::unique_ptr<views::InkDrop> CreateBookmarkButtonInkDrop( + std::unique_ptr<views::InkDropImpl> ink_drop) { + ink_drop->SetShowHighlightOnFocus(true); + return std::move(ink_drop); +} + +std::unique_ptr<views::InkDropRipple> CreateBookmarkButtonInkDropRipple( + const views::InkDropHostView* host_view, + const gfx::Point& center_point) { + return std::make_unique<views::FloodFillInkDropRipple>( + host_view->size(), GetInkDropInsets(), center_point, + GetBookmarkButtonInkDropBaseColor(host_view->GetThemeProvider()), + host_view->ink_drop_visible_opacity()); +} + +std::unique_ptr<views::InkDropMask> CreateBookmarkButtonInkDropMask( + const views::InkDropHostView* host_view) { + return std::make_unique<views::RoundRectInkDropMask>( + host_view->size(), GetInkDropInsets(), GetInkDropCornerRadius()); +} + +std::unique_ptr<views::InkDropHighlight> CreateBookmarkButtonInkDropHighlight( + const views::InkDropHostView* host_view) { + std::unique_ptr<views::InkDropHighlight> highlight( + new views::InkDropHighlight( + host_view->size(), GetInkDropCornerRadius(), + gfx::RectF(gfx::Rect(host_view->size())).CenterPoint(), + GetBookmarkButtonInkDropBaseColor(host_view->GetThemeProvider()))); + if (IsTouchOptimized()) + highlight->set_visible_opacity(kTouchToolbarHighlightVisibleOpacity); + return highlight; +} // BookmarkButtonBase ----------------------------------------------- @@ -189,6 +236,8 @@ SetElideBehavior(kElideBehavior); SetInkDropMode(InkDropMode::ON); set_has_ink_drop_action_on_click(true); + if (IsTouchOptimized()) + set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); SetFocusPainter(nullptr); show_animation_.reset(new gfx::SlideAnimation(this)); if (!animations_enabled) { @@ -213,37 +262,21 @@ // LabelButton: std::unique_ptr<views::InkDrop> CreateInkDrop() override { - std::unique_ptr<views::InkDropImpl> ink_drop = - CreateDefaultFloodFillInkDropImpl(); - ink_drop->SetShowHighlightOnFocus(true); - return std::move(ink_drop); + return CreateBookmarkButtonInkDrop(CreateDefaultFloodFillInkDropImpl()); } std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { - return std::make_unique<views::FloodFillInkDropRipple>( - size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), - GetInkDropBaseColor(), ink_drop_visible_opacity()); + return CreateBookmarkButtonInkDropRipple( + this, GetInkDropCenterBasedOnLastEvent()); } std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() const override { - gfx::RectF bounds((gfx::Rect(size()))); - bounds.Inset(gfx::InsetsF( - kInkDropVerticalInsetPx / - GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), - 0)); - return std::make_unique<views::InkDropHighlight>( - bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); + return CreateBookmarkButtonInkDropHighlight(this); } std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { - return std::make_unique<views::RoundRectInkDropMask>(size(), kInkDropInsets, - kInkDropCornerRadius); - } - - SkColor GetInkDropBaseColor() const override { - return GetThemeProvider()->GetColor( - ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); + return CreateBookmarkButtonInkDropMask(this); } private: @@ -340,42 +373,28 @@ SetImageLabelSpacing(ChromeLayoutProvider::Get()->GetDistanceMetric( DISTANCE_RELATED_LABEL_HORIZONTAL_LIST)); SetInkDropMode(InkDropMode::ON); + if (IsTouchOptimized()) + set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); SetFocusPainter(nullptr); } // MenuButton: std::unique_ptr<views::InkDrop> CreateInkDrop() override { - std::unique_ptr<views::InkDropImpl> ink_drop = - CreateDefaultFloodFillInkDropImpl(); - ink_drop->SetShowHighlightOnFocus(true); - return std::move(ink_drop); + return CreateBookmarkButtonInkDrop(CreateDefaultFloodFillInkDropImpl()); } std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override { - return std::make_unique<views::FloodFillInkDropRipple>( - size(), kInkDropInsets, GetInkDropCenterBasedOnLastEvent(), - GetInkDropBaseColor(), ink_drop_visible_opacity()); + return CreateBookmarkButtonInkDropRipple( + this, GetInkDropCenterBasedOnLastEvent()); } std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() const override { - gfx::RectF bounds((gfx::Rect(size()))); - bounds.Inset(gfx::InsetsF( - kInkDropVerticalInsetPx / - GetWidget()->GetLayer()->GetCompositor()->device_scale_factor(), - 0)); - return std::make_unique<views::InkDropHighlight>( - bounds.size(), 0, bounds.CenterPoint(), GetInkDropBaseColor()); + return CreateBookmarkButtonInkDropHighlight(this); } std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override { - return std::make_unique<views::RoundRectInkDropMask>(size(), kInkDropInsets, - kInkDropCornerRadius); - } - - SkColor GetInkDropBaseColor() const override { - return GetThemeProvider()->GetColor( - ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); + return CreateBookmarkButtonInkDropMask(this); } private: @@ -1720,8 +1739,7 @@ bool themify_icon = node->url().SchemeIs(content::kChromeUIScheme); gfx::ImageSkia favicon = model_->GetFavicon(node).AsImageSkia(); if (favicon.isNull()) { - if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled() && - GetThemeProvider()) { + if (IsTouchOptimized() && GetThemeProvider()) { // This favicon currently does not match the default favicon icon used // elsewhere in the codebase. // See https://crbug/814447 @@ -2047,11 +2065,9 @@ const SkColor overflow_color = theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); - const bool is_touch_optimized = - ui::MaterialDesignController::IsTouchOptimizedUiEnabled(); overflow_button_->SetImage( views::Button::STATE_NORMAL, - gfx::CreateVectorIcon(is_touch_optimized ? kBookmarkbarTouchOverflowIcon + gfx::CreateVectorIcon(IsTouchOptimized() ? kBookmarkbarTouchOverflowIcon : kOverflowChevronIcon, overflow_color));
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc index 2d31b0c3..d322329 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -1699,7 +1699,8 @@ BookmarkContextMenuNotificationObserver observer_; }; -VIEW_TEST(BookmarkBarViewTest17, ContextMenus3) +// Flaky. See http://crbug.com/820435. +VIEW_TEST(BookmarkBarViewTest17, DISABLED_ContextMenus3) // Verifies sibling menus works. Clicks on the 'other bookmarks' folder, then // moves the mouse over the first item on the bookmark bar and makes sure the
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 014fd07b..707ed6b 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1107,6 +1107,13 @@ } void BrowserView::RotatePaneFocus(bool forwards) { + // If an inactive bubble is showing this intentionally focuses that dialog to + // provide an easy access method to these dialogs without requring additional + // keyboard shortcuts or commands. To get back out to pane cycling the dialog + // needs to be accepted or dismissed. + if (GetLocationBarView()->ActivateFirstInactiveBubbleForAccessibility()) + return; + GetFocusManager()->RotatePaneFocus( forwards ? views::FocusManager::kForward : views::FocusManager::kBackward,
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 06921e8..01d7b65 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -142,6 +142,16 @@ return OmniboxTint::LIGHT; } +// Returns the color of the security chip if the security level is secure. +SkColor SecurityChipSecureColor(bool in_dark_mode) { + return in_dark_mode ? SK_ColorWHITE : gfx::kGoogleGreen700; +} + +// Returns the color of the security chip if the security level is dangerous. +SkColor SecurityChipDangerousColor(bool in_dark_mode) { + return in_dark_mode ? SK_ColorWHITE : gfx::kGoogleRed700; +} + } // namespace // LocationBarView ----------------------------------------------------------- @@ -326,7 +336,7 @@ return color_utils::AlphaBlend(GetColor(TEXT), GetColor(BACKGROUND), 128); case SECURITY_CHIP_TEXT: - return GetSecureTextColor(GetToolbarModel()->GetSecurityLevel(false)); + return GetSecurityChipColor(GetToolbarModel()->GetSecurityLevel(false)); } NOTREACHED(); return gfx::kPlaceholderColor; @@ -338,22 +348,22 @@ ThemeProperties::COLOR_TOOLBAR, incognito)); } -SkColor LocationBarView::GetSecureTextColor( +SkColor LocationBarView::GetSecurityChipColor( security_state::SecurityLevel security_level) const { - if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) { + // Only used in ChromeOS. + if (security_level == security_state::SECURE_WITH_POLICY_INSTALLED_CERT) return GetColor(DEEMPHASIZED_TEXT); + + SkColor chip_color = color_utils::DeriveDefaultIconColor(GetColor(TEXT)); + bool is_dark = color_utils::IsDark(GetColor(BACKGROUND)); + if (security_level == security_state::EV_SECURE || + security_level == security_state::SECURE) { + chip_color = SecurityChipSecureColor(is_dark); + } else if (security_level == security_state::DANGEROUS) { + chip_color = SecurityChipDangerousColor(is_dark); } - SkColor text_color = GetColor(TEXT); - if (!color_utils::IsDark(GetColor(BACKGROUND))) { - if ((security_level == security_state::EV_SECURE) || - (security_level == security_state::SECURE)) { - text_color = gfx::kGoogleGreen700; - } else if (security_level == security_state::DANGEROUS) { - text_color = gfx::kGoogleRed700; - } - } - return color_utils::GetReadableColor(text_color, GetColor(BACKGROUND)); + return color_utils::GetReadableColor(chip_color, GetColor(BACKGROUND)); } void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { @@ -767,13 +777,9 @@ security_state::SecurityLevel security_level = GetToolbarModel()->GetSecurityLevel(false); - SkColor icon_color = (security_level == security_state::NONE || - security_level == security_state::HTTP_SHOW_WARNING) - ? color_utils::DeriveDefaultIconColor(GetColor(TEXT)) - : GetSecureTextColor(security_level); location_icon_view_->SetImage(gfx::CreateVectorIcon( omnibox_view_->GetVectorIcon(), GetLayoutConstant(LOCATION_BAR_ICON_SIZE), - icon_color)); + GetSecurityChipColor(security_level))); location_icon_view_->Update(); }
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h index aff087b..19e2de9 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -126,9 +126,9 @@ // It's guaranteed to be opaque. SkColor GetOpaqueBorderColor(bool incognito) const; - // Returns the color to be used for security text in the context of + // Returns the color to be used for the security chip in the context of // |security_level|. - SkColor GetSecureTextColor( + SkColor GetSecurityChipColor( security_state::SecurityLevel security_level) const; // Returns the theme color tint for the location bar and results.
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index f049721b..fe34b2cd 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -652,7 +652,7 @@ if (security_level_ == security_state::NONE || security_level_ == security_state::HTTP_SHOW_WARNING) return; - ApplyColor(location_bar_view_->GetSecureTextColor(security_level_), range); + ApplyColor(location_bar_view_->GetSecurityChipColor(security_level_), range); if (security_level_ == security_state::DANGEROUS) ApplyStyle(gfx::STRIKE, true, range); }
diff --git a/chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h b/chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h index c44b2d7..77609a6c 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h +++ b/chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h
@@ -29,6 +29,7 @@ } // namespace constexpr float kTouchToolbarInkDropVisibleOpacity = 0.06f; +constexpr float kTouchToolbarHighlightVisibleOpacity = 0.08f; // The below utility functions are templated since we have two different types // of buttons on the toolbar (ToolbarButton and AppMenuButton) which don't share @@ -87,7 +88,7 @@ auto highlight = std::make_unique<views::InkDropHighlight>( kTouchInkDropHighlightSize, kTouchInkDropCornerRadius, gfx::PointF(center_point), host_view->GetInkDropBaseColor()); - highlight->set_visible_opacity(0.08f); + highlight->set_visible_opacity(kTouchToolbarHighlightVisibleOpacity); return highlight; }
diff --git a/chrome/browser/vr/elements/vector_icon.cc b/chrome/browser/vr/elements/vector_icon.cc index 9f42f24..f05c136 100644 --- a/chrome/browser/vr/elements/vector_icon.cc +++ b/chrome/browser/vr/elements/vector_icon.cc
@@ -23,8 +23,7 @@ SkColor GetColor() const { return color_; } void SetIcon(const gfx::VectorIcon& icon) { - SetAndDirty(&icon_no_1x_.path, icon.path); - SetAndDirty(&icon_no_1x_.path_size, icon.path_size); + SetAndDirty(&icon_no_1x_.rep, icon.rep); } private: @@ -90,7 +89,7 @@ // 1x version if device scale factor isn't set. See crbug.com/749146. If all // icons end up being drawn via VectorIcon instances, this will not be // required (the 1x version is automatically elided by this class). - gfx::VectorIcon icon_no_1x{icon.path, icon.path_size}; + gfx::VectorIcon icon_no_1x{icon.rep}; PaintVectorIcon(canvas, icon_no_1x, size_px, color); }
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index 15645d63..665e5fe 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn
@@ -475,13 +475,6 @@ "pepper_permission_util.h", ] } - if (enable_library_cdms) { - sources += [ - "widevine_cdm_constants.cc", - "widevine_cdm_constants.h", - ] - public_deps += [ "//media/cdm:cdm_paths" ] - } if (!enable_webrtc) { sources -= [ "media/webrtc_logging_messages.h" ] }
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index 20afadb..6f7b8a3 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc
@@ -93,7 +93,6 @@ #include "media/cdm/cdm_paths.h" // nogncheck #if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) #define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT -#include "chrome/common/widevine_cdm_constants.h" #endif #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) @@ -128,8 +127,7 @@ #endif #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) -bool IsWidevineAvailable(base::FilePath* adapter_path, - base::FilePath* cdm_path, +bool IsWidevineAvailable(base::FilePath* cdm_path, std::vector<media::VideoCodec>* codecs_supported, bool* supports_persistent_license) { static enum { @@ -137,17 +135,11 @@ FOUND, NOT_FOUND, } widevine_cdm_file_check = NOT_CHECKED; - // TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that - // to locate the CDM and the CDM adapter. - if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) { - *cdm_path = adapter_path->DirName().AppendASCII( - base::GetNativeLibraryName(kWidevineCdmLibraryName)); - if (widevine_cdm_file_check == NOT_CHECKED) { - widevine_cdm_file_check = - (base::PathExists(*adapter_path) && base::PathExists(*cdm_path)) - ? FOUND - : NOT_FOUND; - } + + if (PathService::Get(chrome::FILE_WIDEVINE_CDM, cdm_path)) { + if (widevine_cdm_file_check == NOT_CHECKED) + widevine_cdm_file_check = base::PathExists(*cdm_path) ? FOUND : NOT_FOUND; + if (widevine_cdm_file_check == FOUND) { // Add the supported codecs as if they came from the component manifest. // This list must match the CDM that is being bundled with Chrome. @@ -226,32 +218,6 @@ plugins->push_back(nacl); } #endif // BUILDFLAG(ENABLE_NACL) - -#if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) - base::FilePath adapter_path; - base::FilePath cdm_path; - std::vector<media::VideoCodec> video_codecs_supported; - bool supports_persistent_license; - if (IsWidevineAvailable(&adapter_path, &cdm_path, &video_codecs_supported, - &supports_persistent_license)) { - content::PepperPluginInfo info; - info.is_out_of_process = true; - info.path = adapter_path; - info.name = kWidevineCdmDisplayName; - info.description = - base::StringPrintf("%s (version: " WIDEVINE_CDM_VERSION_STRING ")", - kWidevineCdmDescription); - info.version = WIDEVINE_CDM_VERSION_STRING; - info.permissions = kWidevineCdmPluginPermissions; - - content::WebPluginMimeType mime_type(kWidevineCdmPluginMimeType, - kWidevineCdmPluginExtension, - kWidevineCdmPluginMimeTypeDescription); - info.mime_types.push_back(mime_type); - - plugins->push_back(info); - } -#endif // defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) } // Creates a PepperPluginInfo for the specified plugin. @@ -553,19 +519,12 @@ std::vector<content::CdmInfo>* cdms, std::vector<media::CdmHostFilePath>* cdm_host_file_paths) { if (cdms) { -// TODO(jrummell): Need to have a better flag to indicate systems Widevine -// is available on. For now we continue to use ENABLE_LIBRARY_CDMS so that -// we can experiment between pepper and mojo. #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) - base::FilePath adapter_path; base::FilePath cdm_path; std::vector<media::VideoCodec> video_codecs_supported; - bool supports_persistent_license; - if (IsWidevineAvailable(&adapter_path, &cdm_path, &video_codecs_supported, + bool supports_persistent_license = false; + if (IsWidevineAvailable(&cdm_path, &video_codecs_supported, &supports_persistent_license)) { - // CdmInfo needs |path| to be the actual Widevine library, - // not the adapter, so adjust as necessary. It will be in the - // same directory as the installed adapter. const base::Version version(WIDEVINE_CDM_VERSION_STRING); DCHECK(version.IsValid());
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index f8489a9..e5c64bd 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc
@@ -7,6 +7,7 @@ #include "base/files/file_util.h" #include "base/lazy_instance.h" #include "base/logging.h" +#include "base/native_library.h" #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/sys_info.h" @@ -375,15 +376,15 @@ cur = cur.Append(FILE_PATH_LITERAL("pnacl")); break; #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) - // TODO(xhwang): FILE_WIDEVINE_CDM_ADAPTER has different meanings. - // In the component case, this is the source adapter. Otherwise, it is the - // actual Pepper module that gets loaded. - case chrome::FILE_WIDEVINE_CDM_ADAPTER: + // TODO(crbug.com/663554): Remove this after component updated CDM is + // supported on Linux and ChromeOS. + case chrome::FILE_WIDEVINE_CDM: if (!GetComponentDirectory(&cur)) return false; - cur = cur.Append( - media::GetPlatformSpecificDirectory(kWidevineCdmBaseDirectory)); - cur = cur.AppendASCII(kWidevineCdmAdapterFileName); + cur = + cur.Append( + media::GetPlatformSpecificDirectory(kWidevineCdmBaseDirectory)) + .AppendASCII(base::GetNativeLibraryName(kWidevineCdmLibraryName)); break; #endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) case chrome::FILE_RESOURCES_PACK:
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h index a5bfc4f6..c9c3a3f 100644 --- a/chrome/common/chrome_paths.h +++ b/chrome/common/chrome_paths.h
@@ -93,7 +93,7 @@ DIR_PNACL_BASE, // Full path to the base dir for PNaCl. DIR_PNACL_COMPONENT, // Full path to the latest PNaCl version // (subdir of DIR_PNACL_BASE). - FILE_WIDEVINE_CDM_ADAPTER, // Full path to the Widevine CDM adapter file. + FILE_WIDEVINE_CDM, // Full path to the Widevine CDM. FILE_RESOURCES_PACK, // Full path to the .pak file containing // binary data (e.g., html files and images // used by internal pages).
diff --git a/chrome/common/extensions/docs/templates/intros/storage.html b/chrome/common/extensions/docs/templates/intros/storage.html index 39601a4d..a34496aa 100644 --- a/chrome/common/extensions/docs/templates/intros/storage.html +++ b/chrome/common/extensions/docs/templates/intros/storage.html
@@ -46,8 +46,35 @@ <p> To store user data for your {{platform}}, you can use either -<code>storage.sync</code> or -<code>storage.local</code>. +<code>storage.sync</code>: +</p> + +<pre> + chrome.storage.sync.set({key: value}, function() { + console.log('Value is set to ' + value); + }); + + chrome.storage.sync.get(['key'], function(result) { + console.log('Value currently is ' + result.key); + }); +</pre> + +<p> +or +<code>storage.local</code>: +</p> + +<pre> + chrome.storage.local.set({key: value}, function() { + console.log('Value is set to ' + value); + }); + + chrome.storage.local.get(['key'], function(result) { + console.log('Value currently is ' + result.key); + }); +</pre> + +<p> When using <code>storage.sync</code>, the stored data will automatically be synced to any Chrome browser that the user is logged into,
diff --git a/chrome/common/extensions/docs/templates/json/intro_tables.json b/chrome/common/extensions/docs/templates/json/intro_tables.json index f56da2a..11e63c7 100644 --- a/chrome/common/extensions/docs/templates/json/intro_tables.json +++ b/chrome/common/extensions/docs/templates/json/intro_tables.json
@@ -247,11 +247,11 @@ "storage": { "Learn More": [ { - "link": "https://developers.google.com/live/shows/7320022/", + "link": "https://youtu.be/tmzxMO9lrF0", "text": "Chrome Apps Office Hours: Chrome Storage APIs" }, { - "link": "https://developers.google.com/live/shows/7320022-1/", + "link": "https://youtu.be/4cIFRn0rp5s", "text": "Chrome Apps Office Hours: Storage API Deep Dive" } ]
diff --git a/chrome/common/media_router/BUILD.gn b/chrome/common/media_router/BUILD.gn index c9937c1..2973167 100644 --- a/chrome/common/media_router/BUILD.gn +++ b/chrome/common/media_router/BUILD.gn
@@ -12,12 +12,11 @@ ] sources = [ + # media_sink_internal needs to be included with Android due to typemapping. + # Ideally, Android shouldn't be the case since it does not use Mojo for + # Media Router. "discovery/media_sink_internal.cc", "discovery/media_sink_internal.h", - "discovery/media_sink_service_base.cc", - "discovery/media_sink_service_base.h", - "discovery/media_sink_service_util.cc", - "discovery/media_sink_service_util.h", "issue.cc", "issue.h", "media_route.cc", @@ -40,6 +39,10 @@ if (!is_android) { sources += [ + "discovery/media_sink_service_base.cc", + "discovery/media_sink_service_base.h", + "discovery/media_sink_service_util.cc", + "discovery/media_sink_service_util.h", "providers/cast/cast_media_source.cc", "providers/cast/cast_media_source.h", ]
diff --git a/chrome/common/media_router/discovery/DEPS b/chrome/common/media_router/discovery/DEPS new file mode 100644 index 0000000..f57b34b --- /dev/null +++ b/chrome/common/media_router/discovery/DEPS
@@ -0,0 +1,3 @@ +include_rules = [ + "+components/cast_channel" +]
diff --git a/chrome/common/widevine_cdm_constants.cc b/chrome/common/widevine_cdm_constants.cc deleted file mode 100644 index f59563c..0000000 --- a/chrome/common/widevine_cdm_constants.cc +++ /dev/null
@@ -1,13 +0,0 @@ -// Copyright (c) 2013 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 "chrome/common/widevine_cdm_constants.h" - -#include "build/build_config.h" -#include "ppapi/shared_impl/ppapi_permissions.h" - -const char kWidevineCdmPluginExtension[] = ""; - -const int32_t kWidevineCdmPluginPermissions = - ppapi::PERMISSION_DEV | ppapi::PERMISSION_PRIVATE;
diff --git a/chrome/common/widevine_cdm_constants.h b/chrome/common/widevine_cdm_constants.h deleted file mode 100644 index 60761bd..0000000 --- a/chrome/common/widevine_cdm_constants.h +++ /dev/null
@@ -1,17 +0,0 @@ -// Copyright (c) 2013 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 CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_ -#define CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_ - -#include <stdint.h> - -#include "base/files/file_path.h" - -extern const char kWidevineCdmPluginExtension[]; - -// Permission bits for Widevine CDM plugin. -extern const int32_t kWidevineCdmPluginPermissions; - -#endif // CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 3874615c..301d6a6 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1372,6 +1372,12 @@ return module_name == "Native Client"; } +bool ChromeContentRendererClient::IsOriginIsolatedPepperPlugin( + const base::FilePath& plugin_path) { + return plugin_path == + base::FilePath::FromUTF8Unsafe(ChromeContentClient::kPDFPluginPath); +} + #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) bool ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted( const GURL& url,
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h index d3bdf1b..1b30fe68 100644 --- a/chrome/renderer/chrome_content_renderer_client.h +++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -169,6 +169,7 @@ const content::RenderFrame* render_frame, blink::mojom::PageVisibilityState* override_state) override; bool IsExternalPepperPlugin(const std::string& module_name) override; + bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override; std::unique_ptr<blink::WebSocketHandshakeThrottle> CreateWebSocketHandshakeThrottle() override; std::unique_ptr<blink::WebSpeechSynthesizer> OverrideSpeechSynthesizer(
diff --git a/chrome/renderer/pepper/pepper_uma_host.cc b/chrome/renderer/pepper/pepper_uma_host.cc index 5499b29..94477d3 100644 --- a/chrome/renderer/pepper/pepper_uma_host.cc +++ b/chrome/renderer/pepper/pepper_uma_host.cc
@@ -27,8 +27,6 @@ #include "ppapi/host/ppapi_host.h" #include "ppapi/proxy/ppapi_messages.h" -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - #if BUILDFLAG(ENABLE_EXTENSIONS) #include "extensions/common/constants.h" #include "extensions/common/extension.h" @@ -54,10 +52,6 @@ }; const char* const kWhitelistedPluginBaseNames[] = { -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) - kWidevineCdmAdapterFileName, // see http://crbug.com/368743 - // and http://crbug.com/410630 -#endif ChromeContentClient::kPDFPluginPath, };
diff --git a/chrome/renderer/plugins/plugin_uma.cc b/chrome/renderer/plugins/plugin_uma.cc index 9a282c2..467e9ab 100644 --- a/chrome/renderer/plugins/plugin_uma.cc +++ b/chrome/renderer/plugins/plugin_uma.cc
@@ -11,8 +11,6 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/string_util.h" #include "content/public/common/content_constants.h" -#include "media/media_features.h" -#include "third_party/widevine/cdm/widevine_cdm_common.h" namespace { @@ -180,10 +178,5 @@ return SHOCKWAVE_FLASH; } -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) - if (mime_type == kWidevineCdmPluginMimeType) - return WIDEVINE_CDM; -#endif - return UNSUPPORTED_MIMETYPE; }
diff --git a/chrome/renderer/plugins/plugin_uma.h b/chrome/renderer/plugins/plugin_uma.h index 3a18492..d21498ad 100644 --- a/chrome/renderer/plugins/plugin_uma.h +++ b/chrome/renderer/plugins/plugin_uma.h
@@ -39,7 +39,7 @@ // NOTE: Add new unsupported types only immediately above this line. BROWSER_PLUGIN = 10, SHOCKWAVE_FLASH, - WIDEVINE_CDM, + WIDEVINE_CDM = 12, // Obsolete March 2018 // NOTE: Add new plugin types only immediately above this line. PLUGIN_TYPE_MAX };
diff --git a/chrome/renderer/plugins/plugin_uma_unittest.cc b/chrome/renderer/plugins/plugin_uma_unittest.cc index f1627de..f1769f2b 100644 --- a/chrome/renderer/plugins/plugin_uma_unittest.cc +++ b/chrome/renderer/plugins/plugin_uma_unittest.cc
@@ -104,22 +104,6 @@ GURL("some url")); } -TEST_F(PluginUMATest, WidevineCdm) { -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) - ExpectPluginType(PluginUMAReporter::WIDEVINE_CDM, -#else - ExpectPluginType(PluginUMAReporter::UNSUPPORTED_MIMETYPE, -#endif - "application/x-ppapi-widevine-cdm", - GURL("some url")); - ExpectPluginType(PluginUMAReporter::UNSUPPORTED_MIMETYPE, - "application/x-ppapi-widevine-cdm-sufix", - GURL("some url")); - ExpectPluginType(PluginUMAReporter::UNSUPPORTED_MIMETYPE, - "prefix-application/x-ppapi-widevine-cdm", - GURL("some url")); -} - TEST_F(PluginUMATest, BySrcExtension) { ExpectPluginType( PluginUMAReporter::QUICKTIME, std::string(), GURL("file://file.mov"));
diff --git a/chrome/test/data/load_widevine_no_js.html b/chrome/test/data/load_widevine_no_js.html deleted file mode 100644 index 911b7d4..0000000 --- a/chrome/test/data/load_widevine_no_js.html +++ /dev/null
@@ -1,10 +0,0 @@ -<html> -<head> -<title>Initial Title</title> -</head> -<body> -<object type='application/x-ppapi-widevine-cdm' border=1> -<b>You should not see this text!</b> -</object> -</body> -</html>
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index c0362fa9..b20cb41 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc
@@ -443,6 +443,8 @@ // that only use external keyboards. const char kHasChromeOSKeyboard[] = "has-chromeos-keyboard"; +const char kHideNonActiveAppsFromShelf[] = "hide-non-active-apps-from-shelf"; + // Defines user homedir. This defaults to primary user homedir. const char kHomedir[] = "homedir";
diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 48fe201d..9e743b10 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h
@@ -127,6 +127,7 @@ CHROMEOS_EXPORT extern const char kGuestWallpaperSmall[]; CHROMEOS_EXPORT extern const char kHasChromeOSDiamondKey[]; CHROMEOS_EXPORT extern const char kHasChromeOSKeyboard[]; +CHROMEOS_EXPORT extern const char kHideNonActiveAppsFromShelf[]; CHROMEOS_EXPORT extern const char kHomedir[]; CHROMEOS_EXPORT extern const char kHostPairingOobe[]; CHROMEOS_EXPORT extern const char kIgnoreUserProfileMappingForTests[];
diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn index 87e09f06..ebc57b2 100644 --- a/components/arc/BUILD.gn +++ b/components/arc/BUILD.gn
@@ -61,6 +61,8 @@ "usb/usb_host_ui_delegate.h", "volume_mounter/arc_volume_mounter_bridge.cc", "volume_mounter/arc_volume_mounter_bridge.h", + "wake_lock/arc_wake_lock_bridge.cc", + "wake_lock/arc_wake_lock_bridge.h", ] public_deps = [ @@ -202,6 +204,8 @@ "test/fake_timer_instance.h", "test/fake_voice_interaction_framework_instance.cc", "test/fake_voice_interaction_framework_instance.h", + "test/fake_wake_lock_instance.cc", + "test/fake_wake_lock_instance.h", "test/fake_wallpaper_instance.cc", "test/fake_wallpaper_instance.h", "test/test_browser_context.cc", @@ -242,6 +246,7 @@ "metrics/arc_metrics_service_unittest.cc", "power/arc_power_bridge_unittest.cc", "timer/arc_timer_bridge_unittest.cc", + "wake_lock/arc_wake_lock_bridge_unittest.cc", ] deps = [
diff --git a/components/arc/arc_bridge_host_impl.cc b/components/arc/arc_bridge_host_impl.cc index 6e2dfc0..5b42f0a1 100644 --- a/components/arc/arc_bridge_host_impl.cc +++ b/components/arc/arc_bridge_host_impl.cc
@@ -287,6 +287,11 @@ std::move(volume_mounter_ptr)); } +void ArcBridgeHostImpl::OnWakeLockInstanceReady( + mojom::WakeLockInstancePtr wakelock_ptr) { + OnInstanceReady(arc_bridge_service_->wake_lock(), std::move(wakelock_ptr)); +} + void ArcBridgeHostImpl::OnWallpaperInstanceReady( mojom::WallpaperInstancePtr wallpaper_ptr) { OnInstanceReady(arc_bridge_service_->wallpaper(), std::move(wallpaper_ptr));
diff --git a/components/arc/arc_bridge_host_impl.h b/components/arc/arc_bridge_host_impl.h index ccb7a559..2738a94 100644 --- a/components/arc/arc_bridge_host_impl.h +++ b/components/arc/arc_bridge_host_impl.h
@@ -97,6 +97,8 @@ mojom::VoiceInteractionFrameworkInstancePtr framework_ptr) override; void OnVolumeMounterInstanceReady( mojom::VolumeMounterInstancePtr volume_mounter_ptr) override; + void OnWakeLockInstanceReady( + mojom::WakeLockInstancePtr wake_lock_ptr) override; void OnWallpaperInstanceReady( mojom::WallpaperInstancePtr wallpaper_ptr) override;
diff --git a/components/arc/arc_bridge_service.h b/components/arc/arc_bridge_service.h index 5f42329..d7cd395 100644 --- a/components/arc/arc_bridge_service.h +++ b/components/arc/arc_bridge_service.h
@@ -83,6 +83,8 @@ class VoiceInteractionFrameworkInstance; class VolumeMounterHost; class VolumeMounterInstance; +class WakeLockHost; +class WakeLockInstance; class WallpaperHost; class WallpaperInstance; @@ -218,6 +220,9 @@ volume_mounter() { return &volume_mounter_; } + ConnectionHolder<mojom::WakeLockInstance, mojom::WakeLockHost>* wake_lock() { + return &wake_lock_; + } ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost>* wallpaper() { return &wallpaper_; @@ -278,6 +283,7 @@ voice_interaction_framework_; ConnectionHolder<mojom::VolumeMounterInstance, mojom::VolumeMounterHost> volume_mounter_; + ConnectionHolder<mojom::WakeLockInstance, mojom::WakeLockHost> wake_lock_; ConnectionHolder<mojom::WallpaperInstance, mojom::WallpaperHost> wallpaper_; DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
diff --git a/components/arc/common/BUILD.gn b/components/arc/common/BUILD.gn index 3c42f01..9d7223f 100644 --- a/components/arc/common/BUILD.gn +++ b/components/arc/common/BUILD.gn
@@ -52,6 +52,7 @@ "voice_interaction_arc_home.mojom", "voice_interaction_framework.mojom", "volume_mounter.mojom", + "wake_lock.mojom", "wallpaper.mojom", ]
diff --git a/components/arc/common/arc_bridge.mojom b/components/arc/common/arc_bridge.mojom index a3db806..778c73d 100644 --- a/components/arc/common/arc_bridge.mojom +++ b/components/arc/common/arc_bridge.mojom
@@ -42,11 +42,12 @@ import "components/arc/common/voice_interaction_arc_home.mojom"; import "components/arc/common/voice_interaction_framework.mojom"; import "components/arc/common/volume_mounter.mojom"; +import "components/arc/common/wake_lock.mojom"; import "components/arc/common/wallpaper.mojom"; -// Next MinVersion: 37 +// Next MinVersion: 38 // Deprecated method IDs: 101, 105 -// Next method ID: 142 +// Next method ID: 143 interface ArcBridgeHost { // Keep the entries alphabetical. In order to do so without breaking // compatibility with the ARC instance, explicitly assign each interface a @@ -176,6 +177,9 @@ // Notifies Chrome that the VolumeMounter interface is ready. [MinVersion=25] OnVolumeMounterInstanceReady@131(VolumeMounterInstance instance_ptr); + // Notifies Chrome that the WakeLockInstance interface is ready. + [MinVersion=37] OnWakeLockInstanceReady@142(WakeLockInstance instance_ptr); + // Notifies Chrome that the WallpaperInstance interface is ready. [MinVersion=18] OnWallpaperInstanceReady@124(WallpaperInstance instance_ptr); };
diff --git a/components/arc/common/wake_lock.mojom b/components/arc/common/wake_lock.mojom new file mode 100644 index 0000000..4421754 --- /dev/null +++ b/components/arc/common/wake_lock.mojom
@@ -0,0 +1,29 @@ +// Copyright 2018 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. + +// Next MinVersion: 1 + +module arc.mojom; + +// Interface for the mojo service to acquire and release wake locks on behalf of +// the instance. On a connection error, all wake locks are released. +// +// Next method ID: 2 +interface WakeLockHost { + // Increases the reference count for the CPU wake lock on the host. Acquires + // the CPU wake lock when reference count is incremented to one. Returns true + // in all cases. + AcquirePartialWakeLock@0() => (bool result); + + // Decreases the reference count for the CPU wake lock on the host. Releases + // the wake lock when reference count is decremented to zero. Does nothing + // if reference count is zero at the time of call. Returns true in all cases. + ReleasePartialWakeLock@1() => (bool result); +}; + +// Next method ID: 1 +interface WakeLockInstance { + // Establishes full-duplex communication with the host. + Init@0(WakeLockHost host_ptr) => (); +};
diff --git a/components/arc/test/fake_arc_bridge_host.cc b/components/arc/test/fake_arc_bridge_host.cc index 77aac41..c871786 100644 --- a/components/arc/test/fake_arc_bridge_host.cc +++ b/components/arc/test/fake_arc_bridge_host.cc
@@ -119,6 +119,9 @@ void FakeArcBridgeHost::OnVolumeMounterInstanceReady( mojom::VolumeMounterInstancePtr volume_mounter_ptr) {} +void FakeArcBridgeHost::OnWakeLockInstanceReady( + mojom::WakeLockInstancePtr wakelock_ptr) {} + void FakeArcBridgeHost::OnWallpaperInstanceReady( mojom::WallpaperInstancePtr wallpaper_ptr) {}
diff --git a/components/arc/test/fake_arc_bridge_host.h b/components/arc/test/fake_arc_bridge_host.h index 330c204f..2be57ce 100644 --- a/components/arc/test/fake_arc_bridge_host.h +++ b/components/arc/test/fake_arc_bridge_host.h
@@ -75,6 +75,8 @@ mojom::VoiceInteractionFrameworkInstancePtr framework_ptr) override; void OnVolumeMounterInstanceReady( mojom::VolumeMounterInstancePtr volume_mounter_ptr) override; + void OnWakeLockInstanceReady( + mojom::WakeLockInstancePtr wakelock_ptr) override; void OnWallpaperInstanceReady( mojom::WallpaperInstancePtr wallpaper_ptr) override;
diff --git a/components/arc/test/fake_wake_lock_instance.cc b/components/arc/test/fake_wake_lock_instance.cc new file mode 100644 index 0000000..2de88dc --- /dev/null +++ b/components/arc/test/fake_wake_lock_instance.cc
@@ -0,0 +1,21 @@ +// Copyright 2018 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 <utility> + +#include "components/arc/test/fake_wake_lock_instance.h" + +namespace arc { + +FakeWakeLockInstance::FakeWakeLockInstance() = default; + +FakeWakeLockInstance::~FakeWakeLockInstance() = default; + +void FakeWakeLockInstance::Init(mojom::WakeLockHostPtr host_ptr, + InitCallback callback) { + host_ptr_ = std::move(host_ptr); + std::move(callback).Run(); +} + +} // namespace arc
diff --git a/components/arc/test/fake_wake_lock_instance.h b/components/arc/test/fake_wake_lock_instance.h new file mode 100644 index 0000000..4f828ef --- /dev/null +++ b/components/arc/test/fake_wake_lock_instance.h
@@ -0,0 +1,29 @@ +// Copyright 2018 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 COMPONENTS_ARC_TEST_FAKE_WAKE_LOCK_INSTANCE_H_ +#define COMPONENTS_ARC_TEST_FAKE_WAKE_LOCK_INSTANCE_H_ + +#include "base/macros.h" +#include "components/arc/common/wake_lock.mojom.h" + +namespace arc { + +class FakeWakeLockInstance : public mojom::WakeLockInstance { + public: + FakeWakeLockInstance(); + ~FakeWakeLockInstance() override; + + // mojom::WakeLockInstance overrides: + void Init(mojom::WakeLockHostPtr host_ptr, InitCallback callback) override; + + private: + mojom::WakeLockHostPtr host_ptr_; + + DISALLOW_COPY_AND_ASSIGN(FakeWakeLockInstance); +}; + +} // namespace arc + +#endif // COMPONENTS_ARC_TEST_FAKE_WAKE_LOCK_INSTANCE_H_
diff --git a/components/arc/wake_lock/DEPS b/components/arc/wake_lock/DEPS new file mode 100644 index 0000000..bc4a98b --- /dev/null +++ b/components/arc/wake_lock/DEPS
@@ -0,0 +1,5 @@ +include_rules = [ + "+content/public/common/service_manager_connection.h", + "+services/device/public", + "+services/service_manager/public/cpp", +]
diff --git a/components/arc/wake_lock/arc_wake_lock_bridge.cc b/components/arc/wake_lock/arc_wake_lock_bridge.cc new file mode 100644 index 0000000..bea34b2f --- /dev/null +++ b/components/arc/wake_lock/arc_wake_lock_bridge.cc
@@ -0,0 +1,197 @@ +// Copyright 2018 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 <memory> +#include <utility> + +#include "base/logging.h" +#include "base/memory/singleton.h" +#include "chromeos/dbus/power_policy_controller.h" +#include "components/arc/arc_bridge_service.h" +#include "components/arc/arc_browser_context_keyed_service_factory_base.h" +#include "components/arc/arc_service_manager.h" +#include "components/arc/wake_lock/arc_wake_lock_bridge.h" +#include "mojo/public/cpp/bindings/interface_request.h" +#include "services/device/public/mojom/constants.mojom.h" +#include "services/device/public/mojom/wake_lock_provider.mojom.h" +#include "services/service_manager/public/cpp/connector.h" + +namespace arc { + +namespace { + +constexpr char kWakeLockReason[] = "ARC"; + +// Singleton factory for ArcWakeLockBridge. +class ArcWakeLockBridgeFactory + : public internal::ArcBrowserContextKeyedServiceFactoryBase< + ArcWakeLockBridge, + ArcWakeLockBridgeFactory> { + public: + // Factory name used by ArcBrowserContextKeyedServiceFactoryBase. + static constexpr const char* kName = "ArcWakeLockBridgeFactory"; + + static ArcWakeLockBridgeFactory* GetInstance() { + return base::Singleton<ArcWakeLockBridgeFactory>::get(); + } + + private: + friend base::DefaultSingletonTraits<ArcWakeLockBridgeFactory>; + ArcWakeLockBridgeFactory() = default; + ~ArcWakeLockBridgeFactory() override = default; +}; + +} // namespace + +// WakeLockRequester requests a wake lock from the device service in response +// to wake lock requests of a given type from Android. A count is kept of +// outstanding Android requests so that only a single actual wake lock is used. +class ArcWakeLockBridge::WakeLockRequester { + public: + WakeLockRequester(device::mojom::WakeLockType type, + service_manager::Connector* connector) + : type_(type), connector_(connector) {} + ~WakeLockRequester() = default; + + // Increments the number of outstanding requests from Android and requests a + // wake lock from the device service if this is the only request. + void AddRequest() { + DCHECK_GE(wake_lock_count_, 0); + wake_lock_count_++; + if (wake_lock_count_ > 1) { + DVLOG(1) << "Partial wake lock acquire. Count: " << wake_lock_count_; + return; + } + + // Initialize |wake_lock_| if this is the first time we're using it. + DVLOG(1) << "Partial wake lock new acquire. Count: " << wake_lock_count_; + if (!wake_lock_) { + device::mojom::WakeLockProviderPtr provider; + connector_->BindInterface(device::mojom::kServiceName, + mojo::MakeRequest(&provider)); + provider->GetWakeLockWithoutContext( + type_, device::mojom::WakeLockReason::kOther, kWakeLockReason, + mojo::MakeRequest(&wake_lock_)); + } + + wake_lock_->RequestWakeLock(); + } + + // Decrements the number of outstanding Android requests. Cancels the device + // service wake lock when the request count hits zero. + void RemoveRequest() { + DCHECK_GE(wake_lock_count_, 0); + if (wake_lock_count_ == 0) { + LOG(WARNING) << "Release without acquire. Count: " << wake_lock_count_; + return; + } + + wake_lock_count_--; + if (wake_lock_count_ >= 1) { + DVLOG(1) << "Partial wake release. Count: " << wake_lock_count_; + return; + } + + DCHECK(wake_lock_); + DVLOG(1) << "Partial wake force release. Count: " << wake_lock_count_; + wake_lock_->CancelWakeLock(); + } + + // Runs the message loop until replies have been received for all pending + // requests on |wake_lock_|. + void FlushForTesting() { + if (wake_lock_) + wake_lock_.FlushForTesting(); + } + + private: + // Type of wake lock to request. + device::mojom::WakeLockType type_; + + // Used to get services. Not owned. + service_manager::Connector* const connector_ = nullptr; + + // Number of outstanding Android requests. + int64_t wake_lock_count_ = 0; + + // Lazily initialized in response to first request. + device::mojom::WakeLockPtr wake_lock_; + + DISALLOW_COPY_AND_ASSIGN(WakeLockRequester); +}; + +// static +BrowserContextKeyedServiceFactory* ArcWakeLockBridge::GetFactory() { + return ArcWakeLockBridgeFactory::GetInstance(); +} + +// static +ArcWakeLockBridge* ArcWakeLockBridge::GetForBrowserContext( + content::BrowserContext* context) { + return ArcWakeLockBridgeFactory::GetForBrowserContext(context); +} + +// static +ArcWakeLockBridge* ArcWakeLockBridge::GetForBrowserContextForTesting( + content::BrowserContext* context) { + return ArcWakeLockBridgeFactory::GetForBrowserContextForTesting(context); +} + +ArcWakeLockBridge::ArcWakeLockBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service) + : arc_bridge_service_(bridge_service), + binding_(this), + weak_ptr_factory_(this) { + arc_bridge_service_->wake_lock()->SetHost(this); + arc_bridge_service_->wake_lock()->AddObserver(this); +} + +ArcWakeLockBridge::~ArcWakeLockBridge() { + arc_bridge_service_->wake_lock()->RemoveObserver(this); + arc_bridge_service_->wake_lock()->SetHost(nullptr); +} + +void ArcWakeLockBridge::OnConnectionClosed() { + DVLOG(1) << "OnConnectionClosed"; + wake_lock_requesters_.clear(); +} + +void ArcWakeLockBridge::FlushWakeLocksForTesting() { + for (const auto& it : wake_lock_requesters_) + it.second->FlushForTesting(); +} + +void ArcWakeLockBridge::AcquirePartialWakeLock( + AcquirePartialWakeLockCallback callback) { + GetWakeLockRequester(device::mojom::WakeLockType::kPreventAppSuspension) + ->AddRequest(); + std::move(callback).Run(true); +} + +void ArcWakeLockBridge::ReleasePartialWakeLock( + ReleasePartialWakeLockCallback callback) { + GetWakeLockRequester(device::mojom::WakeLockType::kPreventAppSuspension) + ->RemoveRequest(); + std::move(callback).Run(true); +} + +ArcWakeLockBridge::WakeLockRequester* ArcWakeLockBridge::GetWakeLockRequester( + device::mojom::WakeLockType type) { + auto it = wake_lock_requesters_.find(type); + if (it != wake_lock_requesters_.end()) + return it->second.get(); + + service_manager::Connector* connector = + connector_for_test_ + ? connector_for_test_ + : content::ServiceManagerConnection::GetForProcess()->GetConnector(); + DCHECK(connector); + + it = wake_lock_requesters_ + .emplace(type, std::make_unique<WakeLockRequester>(type, connector)) + .first; + return it->second.get(); +} + +} // namespace arc
diff --git a/components/arc/wake_lock/arc_wake_lock_bridge.h b/components/arc/wake_lock/arc_wake_lock_bridge.h new file mode 100644 index 0000000..67ce3ee --- /dev/null +++ b/components/arc/wake_lock/arc_wake_lock_bridge.h
@@ -0,0 +1,90 @@ +// Copyright 2018 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 COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ +#define COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_ + +#include <map> +#include <memory> + +#include "base/macros.h" +#include "base/memory/weak_ptr.h" +#include "components/arc/common/wake_lock.mojom.h" +#include "components/arc/connection_observer.h" +#include "components/keyed_service/core/keyed_service.h" +#include "content/public/common/service_manager_connection.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "services/device/public/mojom/wake_lock.mojom.h" + +class BrowserContextKeyedServiceFactory; + +namespace content { +class BrowserContext; +} // namespace content + +namespace arc { + +class ArcBridgeService; + +// Sets wake up timers / alarms based on calls from the instance. +class ArcWakeLockBridge : public KeyedService, + public ConnectionObserver<mojom::WakeLockInstance>, + public mojom::WakeLockHost { + public: + // Returns the factory instance for this class. + static BrowserContextKeyedServiceFactory* GetFactory(); + + // Returns singleton instance for the given BrowserContext, + // or nullptr if the browser |context| is not allowed to use ARC. + static ArcWakeLockBridge* GetForBrowserContext( + content::BrowserContext* context); + + static ArcWakeLockBridge* GetForBrowserContextForTesting( + content::BrowserContext* context); + + ArcWakeLockBridge(content::BrowserContext* context, + ArcBridgeService* bridge_service); + ~ArcWakeLockBridge() override; + + void set_connector_for_testing(service_manager::Connector* connector) { + connector_for_test_ = connector; + } + + // ConnectionObserver<mojom::WakeLockInstance>::Observer overrides. + void OnConnectionClosed() override; + + // Runs the message loop until replies have been received for all pending + // device service requests in |wake_lock_requesters_|. + void FlushWakeLocksForTesting(); + + // mojom::WakeLockHost overrides. + void AcquirePartialWakeLock(AcquirePartialWakeLockCallback callback) override; + void ReleasePartialWakeLock(ReleasePartialWakeLockCallback callback) override; + + private: + class WakeLockRequester; + + // Returns the WakeLockRequester for |type|, creating one if needed. + WakeLockRequester* GetWakeLockRequester(device::mojom::WakeLockType type); + + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. + + // If non-null, used instead of the process-wide connector to fetch services. + service_manager::Connector* connector_for_test_ = nullptr; + + // Used to track Android wake lock requests and acquire and release device + // service wake locks as needed. + std::map<device::mojom::WakeLockType, std::unique_ptr<WakeLockRequester>> + wake_lock_requesters_; + + mojo::Binding<mojom::WakeLockHost> binding_; + + base::WeakPtrFactory<ArcWakeLockBridge> weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(ArcWakeLockBridge); +}; + +} // namespace arc + +#endif // COMPONENTS_ARC_WAKE_LOCK_ARC_WAKE_LOCK_BRIDGE_H_
diff --git a/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc b/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc new file mode 100644 index 0000000..7a2c46e --- /dev/null +++ b/components/arc/wake_lock/arc_wake_lock_bridge_unittest.cc
@@ -0,0 +1,158 @@ +// Copyright 2018 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 "components/arc/wake_lock/arc_wake_lock_bridge.h" + +#include <memory> +#include <utility> + +#include "base/run_loop.h" +#include "base/test/scoped_task_environment.h" +#include "components/arc/arc_bridge_service.h" +#include "components/arc/common/power.mojom.h" +#include "components/arc/test/connection_holder_util.h" +#include "components/arc/test/fake_power_instance.h" +#include "components/arc/test/fake_wake_lock_instance.h" +#include "services/device/public/cpp/test/test_wake_lock_provider.h" +#include "services/service_manager/public/cpp/test/test_connector_factory.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace arc { + +using device::mojom::WakeLockType; + +class ArcWakeLockBridgeTest : public testing::Test { + public: + ArcWakeLockBridgeTest() { + auto wake_lock_provider_ptr = + std::make_unique<device::TestWakeLockProvider>(); + wake_lock_provider_ = wake_lock_provider_ptr.get(); + + connector_factory_ = + service_manager::TestConnectorFactory::CreateForUniqueService( + std::move(wake_lock_provider_ptr)); + connector_ = connector_factory_->CreateConnector(); + + bridge_service_ = std::make_unique<ArcBridgeService>(); + wake_lock_bridge_ = + std::make_unique<ArcWakeLockBridge>(nullptr, bridge_service_.get()); + wake_lock_bridge_->set_connector_for_testing(connector_.get()); + CreateWakeLockInstance(); + } + + ~ArcWakeLockBridgeTest() override { DestroyWakeLockInstance(); } + + protected: + // Returns true iff there is no failure acquiring a system wake lock. + bool AcquirePartialWakeLock() { + base::RunLoop loop; + bool result = false; + wake_lock_bridge_->AcquirePartialWakeLock(base::BindOnce( + [](bool* result_out, bool result) { *result_out = result; }, &result)); + loop.RunUntilIdle(); + wake_lock_bridge_->FlushWakeLocksForTesting(); + return result; + } + + // Returns true iff there is no failure releasing a system wake lock. + bool ReleasePartialWakeLock() { + base::RunLoop loop; + bool result = false; + wake_lock_bridge_->ReleasePartialWakeLock(base::BindOnce( + [](bool* result_out, bool result) { *result_out = result; }, &result)); + loop.RunUntilIdle(); + wake_lock_bridge_->FlushWakeLocksForTesting(); + return result; + } + + // Creates a FakeWakeLockInstance for |bridge_service_|. This results in + // ArcWakeLockBridge::OnInstanceReady() being called. + void CreateWakeLockInstance() { + instance_ = std::make_unique<FakeWakeLockInstance>(); + bridge_service_->wake_lock()->SetInstance(instance_.get()); + WaitForInstanceReady(bridge_service_->wake_lock()); + } + + // Destroys the FakeWakeLockInstance. This results in + // ArcWakeLockBridge::OnInstanceClosed() being called. + void DestroyWakeLockInstance() { + if (!instance_) + return; + bridge_service_->wake_lock()->CloseInstance(instance_.get()); + instance_.reset(); + } + + device::TestWakeLockProvider* GetWakeLockProvider() { + return wake_lock_provider_; + } + + private: + base::test::ScopedTaskEnvironment scoped_task_environment_; + + std::unique_ptr<service_manager::TestConnectorFactory> connector_factory_; + std::unique_ptr<service_manager::Connector> connector_; + device::TestWakeLockProvider* wake_lock_provider_; + + std::unique_ptr<ArcBridgeService> bridge_service_; + std::unique_ptr<FakeWakeLockInstance> instance_; + std::unique_ptr<ArcWakeLockBridge> wake_lock_bridge_; + + DISALLOW_COPY_AND_ASSIGN(ArcWakeLockBridgeTest); +}; + +TEST_F(ArcWakeLockBridgeTest, AcquireAndReleaseSinglePartialWakeLock) { + EXPECT_TRUE(AcquirePartialWakeLock()); + EXPECT_EQ(1, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); + + EXPECT_TRUE(ReleasePartialWakeLock()); + EXPECT_EQ(0, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); +} + +TEST_F(ArcWakeLockBridgeTest, AcquireAndReleaseMultiplePartialWakeLocks) { + // Taking multiple wake locks should result in only one active wake lock. + EXPECT_TRUE(AcquirePartialWakeLock()); + EXPECT_TRUE(AcquirePartialWakeLock()); + EXPECT_TRUE(AcquirePartialWakeLock()); + EXPECT_EQ(1, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); + + // Releasing two wake locks after acquiring three should not result in + // releasing a wake lock. + EXPECT_TRUE(ReleasePartialWakeLock()); + EXPECT_TRUE(ReleasePartialWakeLock()); + EXPECT_EQ(1, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); + + // Releasing the remaining wake lock should result in the release of the wake + // lock. + EXPECT_TRUE(ReleasePartialWakeLock()); + EXPECT_EQ(0, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); +} + +TEST_F(ArcWakeLockBridgeTest, ReleaseWakeLockOnInstanceClosed) { + EXPECT_TRUE(AcquirePartialWakeLock()); + ASSERT_EQ(1, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); + + // If the instance is closed, all wake locks should be released. + base::RunLoop run_loop; + GetWakeLockProvider()->set_wake_lock_canceled_callback( + run_loop.QuitClosure()); + DestroyWakeLockInstance(); + run_loop.Run(); + EXPECT_EQ(0, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventDisplaySleep)); + + // Check that wake locks can be requested after the instance becomes ready + // again. + CreateWakeLockInstance(); + EXPECT_TRUE(AcquirePartialWakeLock()); + EXPECT_EQ(1, GetWakeLockProvider()->GetActiveWakeLocksOfType( + WakeLockType::kPreventAppSuspension)); +} + +} // namespace arc
diff --git a/components/infobars/core/BUILD.gn b/components/infobars/core/BUILD.gn index acb9374..103e359 100644 --- a/components/infobars/core/BUILD.gn +++ b/components/infobars/core/BUILD.gn
@@ -21,6 +21,8 @@ "infobar_delegate.h", "infobar_manager.cc", "infobar_manager.h", + "infobars_switches.cc", + "infobars_switches.h", "simple_alert_infobar_delegate.cc", "simple_alert_infobar_delegate.h", ]
diff --git a/components/infobars/core/infobar_manager.cc b/components/infobars/core/infobar_manager.cc index 7005855..7f6a4c9 100644 --- a/components/infobars/core/infobar_manager.cc +++ b/components/infobars/core/infobar_manager.cc
@@ -8,6 +8,7 @@ #include "base/command_line.h" #include "components/infobars/core/infobar.h" +#include "components/infobars/core/infobars_switches.h" namespace infobars { @@ -37,6 +38,9 @@ InfoBar* InfoBarManager::AddInfoBar(std::unique_ptr<InfoBar> infobar, bool replace_existing) { DCHECK(infobar); + if (!infobars_enabled_) + return nullptr; + for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end(); ++i) { if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) { @@ -67,6 +71,8 @@ InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar, std::unique_ptr<InfoBar> new_infobar) { DCHECK(old_infobar); + if (!infobars_enabled_) + return AddInfoBar(std::move(new_infobar)); // Deletes the infobar. DCHECK(new_infobar); InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), @@ -97,6 +103,9 @@ } InfoBarManager::InfoBarManager() { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableInfoBars)) + infobars_enabled_ = false; } InfoBarManager::~InfoBarManager() {} @@ -133,6 +142,11 @@ void InfoBarManager::RemoveInfoBarInternal(InfoBar* infobar, bool animate) { DCHECK(infobar); + if (!infobars_enabled_) { + DCHECK(infobars_.empty()); + return; + } + InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), infobar)); DCHECK(i != infobars_.end());
diff --git a/components/infobars/core/infobar_manager.h b/components/infobars/core/infobar_manager.h index 9ae6c06..2d44965 100644 --- a/components/infobars/core/infobar_manager.h +++ b/components/infobars/core/infobar_manager.h
@@ -132,6 +132,7 @@ void RemoveInfoBarInternal(InfoBar* infobar, bool animate); InfoBars infobars_; + bool infobars_enabled_ = true; bool animations_enabled_ = true; base::ObserverList<Observer, true> observer_list_;
diff --git a/components/infobars/core/infobars_switches.cc b/components/infobars/core/infobars_switches.cc new file mode 100644 index 0000000..deb21a76 --- /dev/null +++ b/components/infobars/core/infobars_switches.cc
@@ -0,0 +1,14 @@ +// 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. + +#include "components/infobars/core/infobars_switches.h" + +namespace infobars { +namespace switches { + +// Prevent infobars from appearing. +const char kDisableInfoBars[] = "disable-infobars"; + +} // namespace switches +} // namespace infobars
diff --git a/components/infobars/core/infobars_switches.h b/components/infobars/core/infobars_switches.h new file mode 100644 index 0000000..d24a09a4 --- /dev/null +++ b/components/infobars/core/infobars_switches.h
@@ -0,0 +1,16 @@ +// 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. + +#ifndef COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_ +#define COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_ + +namespace infobars { +namespace switches { + +extern const char kDisableInfoBars[]; + +} // namespace switches +} // namespace infobars + +#endif // COMPONENTS_INFOBARS_CORE_INFOBARS_SWITCHES_H_
diff --git a/components/nacl/loader/nacl_main_platform_delegate_mac.mm b/components/nacl/loader/nacl_main_platform_delegate_mac.mm index 55bbd90e..6fa50f0 100644 --- a/components/nacl/loader/nacl_main_platform_delegate_mac.mm +++ b/components/nacl/loader/nacl_main_platform_delegate_mac.mm
@@ -6,7 +6,6 @@ #import <Cocoa/Cocoa.h> -#include "base/files/file_path.h" #include "base/logging.h" #include "components/nacl/common/nacl_switches.h" #include "content/public/common/sandbox_init.h" @@ -14,7 +13,6 @@ void NaClMainPlatformDelegate::EnableSandbox( const content::MainFunctionParams& parameters) { - CHECK(content::InitializeSandbox(service_manager::SANDBOX_TYPE_NACL_LOADER, - base::FilePath())) + CHECK(content::InitializeSandbox(service_manager::SANDBOX_TYPE_NACL_LOADER)) << "Error initializing sandbox for " << switches::kNaClLoaderProcess; }
diff --git a/components/offline_pages/core/BUILD.gn b/components/offline_pages/core/BUILD.gn index 9523eff3..f224641f 100644 --- a/components/offline_pages/core/BUILD.gn +++ b/components/offline_pages/core/BUILD.gn
@@ -96,6 +96,8 @@ static_library("test_support") { testonly = true sources = [ + "model/model_task_test_base.cc", + "model/model_task_test_base.h", "model/offline_page_item_generator.cc", "model/offline_page_item_generator.h", "model/offline_page_test_utils.cc",
diff --git a/components/offline_pages/core/model/add_page_task_unittest.cc b/components/offline_pages/core/model/add_page_task_unittest.cc index 4747082b..3e305e0 100644 --- a/components/offline_pages/core/model/add_page_task_unittest.cc +++ b/components/offline_pages/core/model/add_page_task_unittest.cc
@@ -5,24 +5,19 @@ #include "components/offline_pages/core/model/add_page_task.h" #include <stdint.h> - #include <memory> #include <string> #include <vector> #include "base/bind.h" #include "base/files/file_path.h" -#include "base/files/scoped_temp_dir.h" #include "base/memory/weak_ptr.h" #include "base/strings/utf_string_conversions.h" -#include "base/test/test_mock_time_task_runner.h" #include "base/threading/thread_task_runner_handle.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_item.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" #include "components/offline_pages/core/offline_page_types.h" #include "components/offline_pages/core/offline_store_types.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -44,15 +39,8 @@ } // namespace -class AddPageTaskTest : public testing::Test, - public base::SupportsWeakPtr<AddPageTaskTest> { +class AddPageTaskTest : public ModelTaskTestBase { public: - AddPageTaskTest(); - ~AddPageTaskTest() override; - - void SetUp() override; - void TearDown() override; - void ResetResults(); void OnAddPageDone(AddPageResult result); AddPageTask::AddPageTaskCallback add_page_callback(); @@ -60,42 +48,12 @@ void AddPage(const OfflinePageItem& page); bool CheckPageStored(const OfflinePageItem& page); - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - AddPageResult last_add_page_result() { return last_add_page_result_; } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - - AddPageResult last_add_page_result_; + AddPageResult last_add_page_result_ = AddPageResult::RESULT_COUNT; }; -AddPageTaskTest::AddPageTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - last_add_page_result_(AddPageResult::RESULT_COUNT) {} - -AddPageTaskTest::~AddPageTaskTest() {} - -void AddPageTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); -} - -void AddPageTaskTest::TearDown() { - store_test_util_.DeleteStore(); -} - void AddPageTaskTest::ResetResults() { last_add_page_result_ = AddPageResult::RESULT_COUNT; } @@ -105,12 +63,12 @@ } AddPageTask::AddPageTaskCallback AddPageTaskTest::add_page_callback() { - return base::Bind(&AddPageTaskTest::OnAddPageDone, AsWeakPtr()); + return base::BindOnce(&AddPageTaskTest::OnAddPageDone, base::AsWeakPtr(this)); } void AddPageTaskTest::AddPage(const OfflinePageItem& page) { auto task = std::make_unique<AddPageTask>(store(), page, add_page_callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); } bool AddPageTaskTest::CheckPageStored(const OfflinePageItem& page) { @@ -189,7 +147,7 @@ generator()->SetNamespace(kTestNamespace); OfflinePageItem page = generator()->CreateItem(); auto task = std::make_unique<AddPageTask>(nullptr, page, add_page_callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); // Start checking if the page is added into the store. EXPECT_FALSE(CheckPageStored(page));
diff --git a/components/offline_pages/core/model/add_page_to_download_manager_task_unittest.cc b/components/offline_pages/core/model/add_page_to_download_manager_task_unittest.cc index 63677b2..a8a583f 100644 --- a/components/offline_pages/core/model/add_page_to_download_manager_task_unittest.cc +++ b/components/offline_pages/core/model/add_page_to_download_manager_task_unittest.cc
@@ -6,13 +6,8 @@ #include <memory> -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/system_download_manager_stub.h" -#include "components/offline_pages/core/task.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace { @@ -29,89 +24,31 @@ namespace offline_pages { -class AddPageToDownloadManagerTaskTest : public testing::Test { +class AddPageToDownloadManagerTaskTest : public ModelTaskTestBase { public: AddPageToDownloadManagerTaskTest(); ~AddPageToDownloadManagerTaskTest() override; - void SetUp() override; - void TearDown() override; - - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - - OfflinePageItemGenerator* generator() { return &generator_; } - - scoped_refptr<base::TestMockTimeTaskRunner> task_runner() { - return task_runner_.get(); - } - SystemDownloadManagerStub* download_manager() { return download_manager_.get(); } - void AddTaskDone(Task* task) { add_task_done_ = true; } - - bool add_task_done() { return add_task_done_; } - - void PumpLoop(); - - void SetTaskCompletionCallbackForTesting(Task* task); - private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; std::unique_ptr<SystemDownloadManagerStub> download_manager_; - bool add_task_done_; }; AddPageToDownloadManagerTaskTest::AddPageToDownloadManagerTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - download_manager_(new SystemDownloadManagerStub(kTestDownloadId, true)), - add_task_done_(false) {} + : download_manager_(new SystemDownloadManagerStub(kTestDownloadId, true)) {} AddPageToDownloadManagerTaskTest::~AddPageToDownloadManagerTaskTest() {} -void AddPageToDownloadManagerTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); -} - -void AddPageToDownloadManagerTaskTest::TearDown() { - store_test_util_.DeleteStore(); -} - -void AddPageToDownloadManagerTaskTest::PumpLoop() { - task_runner_->RunUntilIdle(); -} - -void AddPageToDownloadManagerTaskTest::SetTaskCompletionCallbackForTesting( - Task* task) { - task->SetTaskCompletionCallbackForTesting( - task_runner_.get(), - base::BindRepeating(&AddPageToDownloadManagerTaskTest::AddTaskDone, - base::Unretained(this))); -} - TEST_F(AddPageToDownloadManagerTaskTest, AddSimpleId) { OfflinePageItem page = generator()->CreateItem(); store_test_util()->InsertItem(page); - auto task = std::make_unique<AddPageToDownloadManagerTask>( + RunTask(std::make_unique<AddPageToDownloadManagerTask>( store(), download_manager(), page.offline_id, kTitle, kDescription, kPath, - kTestLength, kUri, kReferer); - SetTaskCompletionCallbackForTesting(task.get()); - task->Run(); - PumpLoop(); - - // Check that task finished running. - ASSERT_TRUE(add_task_done()); + kTestLength, kUri, kReferer)); // Check the download ID got set in the offline page item in the database. auto offline_page = store_test_util()->GetPageByOfflineId(page.offline_id); @@ -134,15 +71,9 @@ OfflinePageItem page = generator()->CreateItem(); store_test_util()->InsertItem(page); - auto task = std::make_unique<AddPageToDownloadManagerTask>( + RunTask(std::make_unique<AddPageToDownloadManagerTask>( store(), download_manager(), page.offline_id, kTitle, kDescription, kPath, - kTestLength, kUri, kReferer); - SetTaskCompletionCallbackForTesting(task.get()); - task->Run(); - PumpLoop(); - - // Check that task finished running. - ASSERT_TRUE(add_task_done()); + kTestLength, kUri, kReferer)); // Check the download ID did not get set in the offline page item in the // database. @@ -158,15 +89,9 @@ page.system_download_id = kDefaultDownloadId; store_test_util()->InsertItem(page); - auto task = std::make_unique<AddPageToDownloadManagerTask>( + RunTask(std::make_unique<AddPageToDownloadManagerTask>( store(), download_manager(), page.offline_id, kTitle, kDescription, kPath, - kTestLength, kUri, kReferer); - SetTaskCompletionCallbackForTesting(task.get()); - task->Run(); - PumpLoop(); - - // Check that task finished running. - ASSERT_TRUE(add_task_done()); + kTestLength, kUri, kReferer)); // Check the download ID did not get set in the offline page item in the // database.
diff --git a/components/offline_pages/core/model/clear_digest_task_unittest.cc b/components/offline_pages/core/model/clear_digest_task_unittest.cc index 9b2fb33..e17249f 100644 --- a/components/offline_pages/core/model/clear_digest_task_unittest.cc +++ b/components/offline_pages/core/model/clear_digest_task_unittest.cc
@@ -4,13 +4,7 @@ #include "components/offline_pages/core/model/clear_digest_task.h" -#include <memory> - -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -19,44 +13,7 @@ const char kTestDigest[] = "ktesTDIgest=="; } // namespace -class ClearDigestTaskTest : public testing::Test { - public: - ClearDigestTaskTest(); - ~ClearDigestTaskTest() override; - - void SetUp() override; - void TearDown() override; - - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - - private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; -}; - -ClearDigestTaskTest::ClearDigestTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_) {} - -ClearDigestTaskTest::~ClearDigestTaskTest() {} - -void ClearDigestTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); -} - -void ClearDigestTaskTest::TearDown() { - store_test_util_.DeleteStore(); -} +class ClearDigestTaskTest : public ModelTaskTestBase {}; TEST_F(ClearDigestTaskTest, ClearDigest) { OfflinePageItem page = generator()->CreateItem(); @@ -64,7 +21,7 @@ store_test_util()->InsertItem(page); auto task = std::make_unique<ClearDigestTask>(store(), page.offline_id); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); // Check the digest of the page is cleared. auto offline_page = store_test_util()->GetPageByOfflineId(page.offline_id);
diff --git a/components/offline_pages/core/model/clear_legacy_temporary_pages_task_unittest.cc b/components/offline_pages/core/model/clear_legacy_temporary_pages_task_unittest.cc index 410a78a4..b1c344e4 100644 --- a/components/offline_pages/core/model/clear_legacy_temporary_pages_task_unittest.cc +++ b/components/offline_pages/core/model/clear_legacy_temporary_pages_task_unittest.cc
@@ -9,86 +9,26 @@ #include "base/bind.h" #include "base/files/file_enumerator.h" #include "base/files/file_util.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_test_utils.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { -class ClearLegacyTemporaryPagesTaskTest : public testing::Test { +class ClearLegacyTemporaryPagesTaskTest : public ModelTaskTestBase { public: - ClearLegacyTemporaryPagesTaskTest(); - ~ClearLegacyTemporaryPagesTaskTest() override; + ~ClearLegacyTemporaryPagesTaskTest() override {} - void SetUp() override; - void TearDown() override; - - OfflinePageItem AddPage(const std::string& name_space, - const base::FilePath& archive_dir); - - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; + OfflinePageItem AddPage(const std::string& name_space) { + generator()->SetNamespace(name_space); + OfflinePageItem page = generator()->CreateItemWithTempFile(); + store_test_util()->InsertItem(page); + return page; } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - ClientPolicyController* policy_controller() { - return policy_controller_.get(); - } - - const base::FilePath& legacy_archives_dir() { - return legacy_archives_dir_.GetPath(); - } - - private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - std::unique_ptr<ClientPolicyController> policy_controller_; - - base::ScopedTempDir legacy_archives_dir_; }; -ClearLegacyTemporaryPagesTaskTest::ClearLegacyTemporaryPagesTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_) {} - -ClearLegacyTemporaryPagesTaskTest::~ClearLegacyTemporaryPagesTaskTest() {} - -void ClearLegacyTemporaryPagesTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - ASSERT_TRUE(legacy_archives_dir_.CreateUniqueTempDir()); - policy_controller_ = std::make_unique<ClientPolicyController>(); -} - -void ClearLegacyTemporaryPagesTaskTest::TearDown() { - store_test_util_.DeleteStore(); - if (!legacy_archives_dir_.Delete()) - DVLOG(1) << "ScopedTempDir deletion failed."; -} - -OfflinePageItem ClearLegacyTemporaryPagesTaskTest::AddPage( - const std::string& name_space, - const base::FilePath& archive_dir) { - generator()->SetNamespace(name_space); - generator()->SetArchiveDirectory(archive_dir); - OfflinePageItem page = generator()->CreateItemWithTempFile(); - store_test_util()->InsertItem(page); - return page; -} - // This test is affected by https://crbug.com/725685, which only affects windows // platform. #if defined(OS_WIN) @@ -100,18 +40,18 @@ #endif TEST_F(ClearLegacyTemporaryPagesTaskTest, MAYBE_TestDeletePageInLegacyArchivesDir) { - OfflinePageItem page1 = AddPage(kLastNNamespace, legacy_archives_dir()); - OfflinePageItem page2 = AddPage(kDownloadNamespace, legacy_archives_dir()); + OfflinePageItem page1 = AddPage(kLastNNamespace); + OfflinePageItem page2 = AddPage(kDownloadNamespace); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(legacy_archives_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<ClearLegacyTemporaryPagesTask>( - store(), policy_controller(), legacy_archives_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(legacy_archives_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(store_test_util()->GetPageByOfflineId(page1.offline_id)); }
diff --git a/components/offline_pages/core/model/clear_storage_task_unittest.cc b/components/offline_pages/core/model/clear_storage_task_unittest.cc index c412c86..86c353b 100644 --- a/components/offline_pages/core/model/clear_storage_task_unittest.cc +++ b/components/offline_pages/core/model/clear_storage_task_unittest.cc
@@ -8,18 +8,12 @@ #include "base/bind.h" #include "base/files/file_enumerator.h" -#include "base/files/file_util.h" #include "base/test/histogram_tester.h" #include "base/test/simple_test_clock.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_test_utils.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -65,15 +59,12 @@ } // namespace -class ClearStorageTaskTest - : public testing::Test, - public base::SupportsWeakPtr<ClearStorageTaskTest> { +class ClearStorageTaskTest : public ModelTaskTestBase { public: ClearStorageTaskTest(); ~ClearStorageTaskTest() override; void SetUp() override; - void TearDown() override; void Initialize(const std::vector<PageSettings>& settings, TestOptions options = TestOptions::DEFAULT); @@ -85,17 +76,7 @@ archive_manager_->SetFreeSpace(free_space); } - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - ClientPolicyController* policy_controller() { - return policy_controller_.get(); - } ArchiveManager* archive_manager() { return archive_manager_.get(); } - const base::FilePath& temp_dir_path() { return temp_dir_.GetPath(); } base::SimpleTestClock* clock() { return &clock_; } size_t last_cleared_page_count() { return last_cleared_page_count_; } int total_cleared_times() { return total_cleared_times_; } @@ -105,15 +86,7 @@ base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - - std::unique_ptr<ClientPolicyController> policy_controller_; std::unique_ptr<TestArchiveManager> archive_manager_; - base::ScopedTempDir temp_dir_; base::SimpleTestClock clock_; size_t last_cleared_page_count_; @@ -123,34 +96,19 @@ }; ClearStorageTaskTest::ClearStorageTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - last_cleared_page_count_(0), + : last_cleared_page_count_(0), total_cleared_times_(0), last_clear_storage_result_(ClearStorageResult::SUCCESS) {} ClearStorageTaskTest::~ClearStorageTaskTest() {} void ClearStorageTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + ModelTaskTestBase::SetUp(); // Setting up policies for testing. - policy_controller_ = std::make_unique<ClientPolicyController>(); clock_.SetNow(base::Time::Now()); histogram_tester_ = std::make_unique<base::HistogramTester>(); } -void ClearStorageTaskTest::TearDown() { - store_test_util_.DeleteStore(); - if (temp_dir_.IsValid()) { - if (!temp_dir_.Delete()) - DVLOG(1) << "temp_dir_ not created"; - } - task_runner_->RunUntilIdle(); -} - void ClearStorageTaskTest::Initialize( const std::vector<PageSettings>& page_settings, TestOptions options) { @@ -177,29 +135,28 @@ // during each test. generator()->SetCreationTime(clock()->Now()); generator()->SetNamespace(setting.name_space); - generator()->SetArchiveDirectory(temp_dir_path()); for (int i = 0; i < setting.fresh_page_count; ++i) { generator()->SetLastAccessTime(clock_.Now()); - OfflinePageItem page = generator()->CreateItemWithTempFile(); - store_test_util()->InsertItem(page); + AddPage(); } for (int i = 0; i < setting.expired_page_count; ++i) { // Make the pages expired. - generator()->SetLastAccessTime( - clock_.Now() - policy_controller_->GetPolicy(setting.name_space) - .lifetime_policy.expiration_period); - OfflinePageItem page = generator()->CreateItemWithTempFile(); - store_test_util()->InsertItem(page); + generator()->SetLastAccessTime(clock_.Now() - + policy_controller() + ->GetPolicy(setting.name_space) + .lifetime_policy.expiration_period); + AddPage(); } } void ClearStorageTaskTest::RunClearStorageTask(const base::Time& start_time) { auto task = std::make_unique<ClearStorageTask>( store(), archive_manager(), policy_controller(), start_time, - base::Bind(&ClearStorageTaskTest::OnClearStorageDone, AsWeakPtr())); + base::BindOnce(&ClearStorageTaskTest::OnClearStorageDone, + base::AsWeakPtr(this))); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); } TEST_F(ClearStorageTaskTest, ClearPagesLessThanLimit) { @@ -215,7 +172,7 @@ EXPECT_EQ(1, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectUniqueSample( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 5, 2); } @@ -233,7 +190,7 @@ EXPECT_EQ(1, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(130LL, store_test_util()->GetPageCount()); - EXPECT_EQ(130UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(130UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectUniqueSample( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 5, 1); } @@ -250,7 +207,7 @@ EXPECT_EQ(1, total_cleared_times()); EXPECT_EQ(ClearStorageResult::UNNECESSARY, last_clear_storage_result()); EXPECT_EQ(20LL, store_test_util()->GetPageCount()); - EXPECT_EQ(20UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(20UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectTotalCount( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 0); } @@ -269,7 +226,7 @@ EXPECT_EQ(1, total_cleared_times()); EXPECT_EQ(ClearStorageResult::UNNECESSARY, last_clear_storage_result()); EXPECT_EQ(20LL, store_test_util()->GetPageCount()); - EXPECT_EQ(20UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(20UL, test_utils::GetFileCountInDirectory(TemporaryDir())); } TEST_F(ClearStorageTaskTest, ClearMultipleTimes) { @@ -306,7 +263,7 @@ EXPECT_EQ(1, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(90LL, store_test_util()->GetPageCount()); - EXPECT_EQ(90UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(90UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectUniqueSample( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 30, 1); @@ -321,7 +278,7 @@ EXPECT_EQ(2, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(70LL, store_test_util()->GetPageCount()); - EXPECT_EQ(70UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(70UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectTotalCount( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 21); histogram_tester()->ExpectBucketCount( @@ -338,7 +295,7 @@ EXPECT_EQ(3, total_cleared_times()); EXPECT_EQ(ClearStorageResult::UNNECESSARY, last_clear_storage_result()); EXPECT_EQ(70LL, store_test_util()->GetPageCount()); - EXPECT_EQ(70UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(70UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectTotalCount( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 21); @@ -360,7 +317,7 @@ EXPECT_EQ(4, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(107LL, store_test_util()->GetPageCount()); - EXPECT_EQ(107UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(107UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectTotalCount( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 184); // The 30 original ones last_n pages are cleared (and they fall into the same @@ -382,7 +339,7 @@ EXPECT_EQ(5, total_cleared_times()); EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); EXPECT_EQ(40LL, store_test_util()->GetPageCount()); - EXPECT_EQ(40UL, test_utils::GetFileCountInDirectory(temp_dir_path())); + EXPECT_EQ(40UL, test_utils::GetFileCountInDirectory(TemporaryDir())); histogram_tester()->ExpectTotalCount( "OfflinePages.ClearTemporaryPages.TimeSinceCreation", 251); histogram_tester()->ExpectBucketCount(
diff --git a/components/offline_pages/core/model/complete_offline_page_upgrade_task_unittest.cc b/components/offline_pages/core/model/complete_offline_page_upgrade_task_unittest.cc index b407b427..4e00e48 100644 --- a/components/offline_pages/core/model/complete_offline_page_upgrade_task_unittest.cc +++ b/components/offline_pages/core/model/complete_offline_page_upgrade_task_unittest.cc
@@ -7,12 +7,7 @@ #include <memory> #include "base/files/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -35,31 +30,22 @@ } // namespace -class CompleteOfflinePageUpgradeTaskTest : public testing::Test { +class CompleteOfflinePageUpgradeTaskTest : public ModelTaskTestBase { public: CompleteOfflinePageUpgradeTaskTest(); ~CompleteOfflinePageUpgradeTaskTest() override; void SetUp() override; - void TearDown() override; OfflinePageItem CreateOfflinePage(); void CompleteUpgradeDone(CompleteUpgradeStatus result); - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - CompleteUpgradeCallback callback() { return base::BindOnce( &CompleteOfflinePageUpgradeTaskTest::CompleteUpgradeDone, base::Unretained(this)); } - const base::FilePath& temp_dir_path() const { return temp_dir_.GetPath(); } const base::FilePath& temporary_file_path() const { return temporary_file_path_; } @@ -68,37 +54,21 @@ CompleteUpgradeStatus last_status() const { return last_status_; } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; CompleteUpgradeStatus last_status_; - base::ScopedTempDir temp_dir_; base::FilePath temporary_file_path_; base::FilePath target_file_path_; }; CompleteOfflinePageUpgradeTaskTest::CompleteOfflinePageUpgradeTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - last_status_(CompleteUpgradeStatus::DB_ERROR) {} + : last_status_(CompleteUpgradeStatus::DB_ERROR) {} CompleteOfflinePageUpgradeTaskTest::~CompleteOfflinePageUpgradeTaskTest() {} void CompleteOfflinePageUpgradeTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - generator()->SetArchiveDirectory(temp_dir_path()); + ModelTaskTestBase::SetUp(); - temporary_file_path_ = PrepareTemporaryFile(temp_dir_path()); - target_file_path_ = temp_dir_path().AppendASCII(kTargetFileName); -} - -void CompleteOfflinePageUpgradeTaskTest::TearDown() { - store_test_util_.DeleteStore(); + temporary_file_path_ = PrepareTemporaryFile(TemporaryDir()); + target_file_path_ = TemporaryDir().AppendASCII(kTargetFileName); } OfflinePageItem CompleteOfflinePageUpgradeTaskTest::CreateOfflinePage() { @@ -120,7 +90,7 @@ store(), original_page.offline_id, temporary_file_path(), target_file_path(), kDummyDigest, sizeof(kContentsOfTempFile), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(CompleteUpgradeStatus::SUCCESS, last_status()); @@ -142,7 +112,7 @@ auto task = std::make_unique<CompleteOfflinePageUpgradeTask>( store(), 42, temporary_file_path(), target_file_path(), kDummyDigest, sizeof(kContentsOfTempFile), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(CompleteUpgradeStatus::ITEM_MISSING, last_status()); @@ -160,7 +130,7 @@ store(), original_page.offline_id, temporary_file_path(), target_file_path(), kDummyDigest, sizeof(kContentsOfTempFile), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(CompleteUpgradeStatus::TEMPORARY_FILE_MISSING, last_status()); @@ -184,7 +154,7 @@ store(), original_page.offline_id, temporary_file_path(), target_file_path(), kDummyDigest, sizeof(kContentsOfTempFile), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(CompleteUpgradeStatus::TARGET_FILE_NAME_IN_USE, last_status());
diff --git a/components/offline_pages/core/model/delete_page_task_unittest.cc b/components/offline_pages/core/model/delete_page_task_unittest.cc index 4e9102c..e18804e 100644 --- a/components/offline_pages/core/model/delete_page_task_unittest.cc +++ b/components/offline_pages/core/model/delete_page_task_unittest.cc
@@ -8,24 +8,15 @@ #include <vector> #include "base/bind.h" -#include "base/files/file_path.h" #include "base/files/file_util.h" -#include "base/files/scoped_temp_dir.h" #include "base/memory/weak_ptr.h" #include "base/strings/utf_string_conversions.h" #include "base/test/histogram_tester.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_model_utils.h" -#include "components/offline_pages/core/offline_page_item.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/offline_page_model.h" #include "components/offline_pages/core/offline_page_types.h" #include "components/offline_pages/core/offline_store_types.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -43,16 +34,13 @@ } // namespace -class DeletePageTaskTest : public testing::Test, - public base::SupportsWeakPtr<DeletePageTaskTest> { +class DeletePageTaskTest : public ModelTaskTestBase { public: DeletePageTaskTest(); ~DeletePageTaskTest() override; void SetUp() override; - void TearDown() override; - void PumpLoop(); void ResetResults(); void OnDeletePageDone(DeletePageResult result, @@ -60,15 +48,6 @@ bool CheckPageDeleted(const OfflinePageItem& page); DeletePageTask::DeletePageTaskCallback delete_page_callback(); - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - ClientPolicyController* policy_controller() { - return policy_controller_.get(); - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } DeletePageResult last_delete_page_result() { return last_delete_page_result_; @@ -76,52 +55,24 @@ const std::vector<DeletedPageInfo>& last_deleted_page_infos() { return last_deleted_page_infos_; } - const base::FilePath& temp_dir() { return temp_dir_.GetPath(); } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - std::unique_ptr<ClientPolicyController> policy_controller_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; std::unique_ptr<base::HistogramTester> histogram_tester_; - base::ScopedTempDir temp_dir_; DeletePageResult last_delete_page_result_; std::vector<DeletedPageInfo> last_deleted_page_infos_; }; DeletePageTaskTest::DeletePageTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - last_delete_page_result_(DeletePageResult::RESULT_COUNT) {} + : last_delete_page_result_(DeletePageResult::RESULT_COUNT) {} DeletePageTaskTest::~DeletePageTaskTest() {} void DeletePageTaskTest::SetUp() { - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - store_test_util_.BuildStoreInMemory(); - policy_controller_ = std::make_unique<ClientPolicyController>(); - generator()->SetArchiveDirectory(temp_dir()); + ModelTaskTestBase::SetUp(); histogram_tester_ = std::make_unique<base::HistogramTester>(); } -void DeletePageTaskTest::TearDown() { - store_test_util_.DeleteStore(); - if (temp_dir_.IsValid()) { - if (!temp_dir_.Delete()) - DLOG(ERROR) << "temp_dir_ not created"; - } - PumpLoop(); -} - -void DeletePageTaskTest::PumpLoop() { - task_runner_->RunUntilIdle(); -} - void DeletePageTaskTest::OnDeletePageDone( DeletePageResult result, const std::vector<DeletedPageInfo>& deleted_page_infos) { @@ -131,7 +82,8 @@ DeletePageTask::DeletePageTaskCallback DeletePageTaskTest::delete_page_callback() { - return base::BindOnce(&DeletePageTaskTest::OnDeletePageDone, AsWeakPtr()); + return base::BindOnce(&DeletePageTaskTest::OnDeletePageDone, + base::AsWeakPtr(this)); } bool DeletePageTaskTest::CheckPageDeleted(const OfflinePageItem& page) { @@ -161,7 +113,7 @@ std::vector<int64_t> offline_ids({page1.offline_id, page3.offline_id}); auto task = DeletePageTask::CreateTaskMatchingOfflineIds( store(), delete_page_callback(), offline_ids); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(2UL, last_deleted_page_infos().size()); @@ -206,7 +158,7 @@ std::vector<int64_t> offline_ids({kTestOfflineIdNoMatch}); auto task = DeletePageTask::CreateTaskMatchingOfflineIds( store(), delete_page_callback(), offline_ids); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(0UL, last_deleted_page_infos().size()); @@ -243,7 +195,7 @@ std::vector<ClientId> client_ids({page1.client_id, page3.client_id}); auto task = DeletePageTask::CreateTaskMatchingClientIds( store(), delete_page_callback(), client_ids); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(2UL, last_deleted_page_infos().size()); @@ -286,7 +238,7 @@ std::vector<ClientId> client_ids({kTestClientIdNoMatch}); auto task = DeletePageTask::CreateTaskMatchingClientIds( store(), delete_page_callback(), client_ids); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(0UL, last_deleted_page_infos().size()); @@ -320,7 +272,7 @@ std::vector<ClientId> client_ids({page1.client_id, page2.client_id}); auto task = DeletePageTask::CreateTaskMatchingClientIdsAndOrigin( store(), delete_page_callback(), client_ids, "abc.xyz"); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(2UL, last_deleted_page_infos().size()); @@ -357,7 +309,7 @@ {page1.client_id, page2.client_id, page3.client_id}); auto task = DeletePageTask::CreateTaskMatchingClientIdsAndOrigin( store(), delete_page_callback(), client_ids, "abc.xyz"); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(0UL, last_deleted_page_infos().size()); @@ -398,7 +350,7 @@ auto task = DeletePageTask::CreateTaskMatchingUrlPredicateForCachedPages( store(), delete_page_callback(), policy_controller(), predicate); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(2UL, last_deleted_page_infos().size()); @@ -447,7 +399,7 @@ auto task = DeletePageTask::CreateTaskMatchingUrlPredicateForCachedPages( store(), delete_page_callback(), policy_controller(), predicate); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(0UL, last_deleted_page_infos().size()); @@ -489,7 +441,7 @@ auto task = DeletePageTask::CreateTaskDeletingForPageLimit( store(), delete_page_callback(), policy_controller(), page); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_page_result()); EXPECT_EQ(1UL, last_deleted_page_infos().size()); @@ -527,7 +479,7 @@ auto task = DeletePageTask::CreateTaskDeletingForPageLimit( store(), delete_page_callback(), policy_controller(), page); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); // Since there's no limit for page per url of Download Namespace, the result // should be success with no page deleted. @@ -543,9 +495,4 @@ 0); } -// This test is disabled since it's lacking the ability of mocking store failure -// in store_test_utils. https://crbug.com/781023 -// TODO(romax): reenable the test once the above issue is resolved. -TEST_F(DeletePageTaskTest, DISABLED_DeletePageStoreFailureOnRemove) {} - } // namespace offline_pages
diff --git a/components/offline_pages/core/model/get_pages_task_unittest.cc b/components/offline_pages/core/model/get_pages_task_unittest.cc index 4fc775e..966a9ad 100644 --- a/components/offline_pages/core/model/get_pages_task_unittest.cc +++ b/components/offline_pages/core/model/get_pages_task_unittest.cc
@@ -8,17 +8,9 @@ #include <utility> -#include "base/files/scoped_temp_dir.h" -#include "base/memory/ref_counted.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_metadata_store_sql.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/offline_page_types.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -29,28 +21,14 @@ } // namespace -class GetPagesTaskTest : public testing::Test { +class GetPagesTaskTest : public ModelTaskTestBase { public: - GetPagesTaskTest(); - ~GetPagesTaskTest() override; - - void SetUp() override; - void TearDown() override; - void OnGetPagesDone(const std::vector<OfflinePageItem>& pages); void OnGetPageDone(const OfflinePageItem* page); MultipleOfflinePageItemCallback get_pages_callback(); SingleOfflinePageItemCallback get_single_page_callback(); - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - - OfflinePageMetadataStoreTestUtil* store_util() { return &store_test_util_; } - - OfflinePageItemGenerator* generator() { return &generator_; } - - TestTaskRunner* runner() { return &runner_; } - const std::vector<OfflinePageItem>& read_result() const { return read_result_; } @@ -60,34 +38,10 @@ } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - std::vector<OfflinePageItem> read_result_; OfflinePageItem single_page_result_; }; -GetPagesTaskTest::GetPagesTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_) {} - -GetPagesTaskTest::~GetPagesTaskTest() {} - -void GetPagesTaskTest::SetUp() { - testing::Test::SetUp(); - store_test_util_.BuildStoreInMemory(); -} - -void GetPagesTaskTest::TearDown() { - store_test_util_.DeleteStore(); - testing::Test::TearDown(); -} - void GetPagesTaskTest::OnGetPagesDone( const std::vector<OfflinePageItem>& result) { read_result_.clear(); @@ -112,13 +66,13 @@ TEST_F(GetPagesTaskTest, GetAllPages) { generator()->SetNamespace(kTestNamespace); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); - runner()->RunTask( + RunTask( GetPagesTask::CreateTaskMatchingAllPages(store(), get_pages_callback())); std::set<OfflinePageItem> result_set; @@ -132,11 +86,11 @@ TEST_F(GetPagesTaskTest, GetPagesForSingleClientId) { generator()->SetNamespace(kTestNamespace); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); std::vector<ClientId> client_ids = {item_1.client_id}; - runner()->RunTask(GetPagesTask::CreateTaskMatchingClientIds( + RunTask(GetPagesTask::CreateTaskMatchingClientIds( store(), get_pages_callback(), client_ids)); EXPECT_EQ(1UL, read_result().size()); @@ -146,15 +100,15 @@ TEST_F(GetPagesTaskTest, GetPagesForMultipleClientIds) { generator()->SetNamespace(kTestNamespace); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); std::vector<ClientId> client_ids{item_1.client_id, item_2.client_id}; - runner()->RunTask(GetPagesTask::CreateTaskMatchingClientIds( + RunTask(GetPagesTask::CreateTaskMatchingClientIds( store(), get_pages_callback(), client_ids)); std::set<OfflinePageItem> result_set; @@ -168,14 +122,14 @@ static const char kOtherNamespace[] = "other_namespace"; generator()->SetNamespace(kTestNamespace); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); generator()->SetNamespace(kOtherNamespace); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); - runner()->RunTask(GetPagesTask::CreateTaskMatchingNamespace( + RunTask(GetPagesTask::CreateTaskMatchingNamespace( store(), get_pages_callback(), kTestNamespace)); std::set<OfflinePageItem> result_set; @@ -191,14 +145,14 @@ generator()->SetNamespace(kTestNamespace); generator()->SetRequestOrigin(kRequestOrigin1); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); generator()->SetRequestOrigin(kRequestOrigin2); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); - runner()->RunTask(GetPagesTask::CreateTaskMatchingRequestOrigin( + RunTask(GetPagesTask::CreateTaskMatchingRequestOrigin( store(), get_pages_callback(), kRequestOrigin1)); std::set<OfflinePageItem> result_set; @@ -215,29 +169,29 @@ generator()->SetNamespace(kTestNamespace); generator()->SetUrl(kUrl1); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); generator()->SetUrl(kUrl1Frag); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); generator()->SetUrl(kUrl2); generator()->SetOriginalUrl(kUrl1); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); generator()->SetUrl(kUrl2); generator()->SetOriginalUrl(kUrl1Frag); OfflinePageItem item_4 = generator()->CreateItem(); - store_util()->InsertItem(item_4); + store_test_util()->InsertItem(item_4); generator()->SetUrl(kUrl2); generator()->SetOriginalUrl(kUrl2); OfflinePageItem item_5 = generator()->CreateItem(); - store_util()->InsertItem(item_5); + store_test_util()->InsertItem(item_5); - runner()->RunTask(GetPagesTask::CreateTaskMatchingUrl( - store(), get_pages_callback(), kUrl1)); + RunTask(GetPagesTask::CreateTaskMatchingUrl(store(), get_pages_callback(), + kUrl1)); std::set<OfflinePageItem> result_set; result_set.insert(read_result().begin(), read_result().end()); @@ -251,13 +205,13 @@ TEST_F(GetPagesTaskTest, GetPageByOfflineId) { generator()->SetNamespace(kTestNamespace); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); - runner()->RunTask(GetPagesTask::CreateTaskMatchingOfflineId( + RunTask(GetPagesTask::CreateTaskMatchingOfflineId( store(), get_single_page_callback(), item_1.offline_id)); EXPECT_EQ(item_1, single_page_result()); @@ -271,40 +225,39 @@ generator()->SetFileSize(kFileSize1); generator()->SetDigest(kDigest1); OfflinePageItem item_1 = generator()->CreateItem(); - store_util()->InsertItem(item_1); + store_test_util()->InsertItem(item_1); generator()->SetDigest(kDigest2); OfflinePageItem item_2 = generator()->CreateItem(); - store_util()->InsertItem(item_2); + store_test_util()->InsertItem(item_2); generator()->SetFileSize(kFileSize2); OfflinePageItem item_3 = generator()->CreateItem(); - store_util()->InsertItem(item_3); + store_test_util()->InsertItem(item_3); - runner()->RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( + RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( store(), get_single_page_callback(), kFileSize1, "mismatched digest")); EXPECT_EQ(OfflinePageItem(), single_page_result()); - runner()->RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( + RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( store(), get_single_page_callback(), 0LL, kDigest1)); EXPECT_EQ(OfflinePageItem(), single_page_result()); - runner()->RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( + RunTask(GetPagesTask::CreateTaskMatchingSizeAndDigest( store(), get_single_page_callback(), kFileSize2, kDigest2)); EXPECT_EQ(item_3, single_page_result()); } TEST_F(GetPagesTaskTest, GetPagesSupportedByDownloads) { - ClientPolicyController policy_controller; generator()->SetNamespace(kCCTNamespace); - store_util()->InsertItem(generator()->CreateItem()); + store_test_util()->InsertItem(generator()->CreateItem()); generator()->SetNamespace(kDownloadNamespace); OfflinePageItem download_item = generator()->CreateItem(); - store_util()->InsertItem(download_item); + store_test_util()->InsertItem(download_item); generator()->SetNamespace(kNTPSuggestionsNamespace); OfflinePageItem ntp_suggestion_item = generator()->CreateItem(); - store_util()->InsertItem(ntp_suggestion_item); + store_test_util()->InsertItem(ntp_suggestion_item); - runner()->RunTask(GetPagesTask::CreateTaskMatchingPagesSupportedByDownloads( - store(), get_pages_callback(), &policy_controller)); + RunTask(GetPagesTask::CreateTaskMatchingPagesSupportedByDownloads( + store(), get_pages_callback(), policy_controller())); std::set<OfflinePageItem> result_set; result_set.insert(read_result().begin(), read_result().end()); @@ -314,17 +267,16 @@ } TEST_F(GetPagesTaskTest, GetPagesRemovedOnCacheReset) { - ClientPolicyController policy_controller; generator()->SetNamespace(kCCTNamespace); OfflinePageItem cct_item = generator()->CreateItem(); - store_util()->InsertItem(cct_item); + store_test_util()->InsertItem(cct_item); generator()->SetNamespace(kDownloadNamespace); - store_util()->InsertItem(generator()->CreateItem()); + store_test_util()->InsertItem(generator()->CreateItem()); generator()->SetNamespace(kNTPSuggestionsNamespace); - store_util()->InsertItem(generator()->CreateItem()); + store_test_util()->InsertItem(generator()->CreateItem()); - runner()->RunTask(GetPagesTask::CreateTaskMatchingPagesRemovedOnCacheReset( - store(), get_pages_callback(), &policy_controller)); + RunTask(GetPagesTask::CreateTaskMatchingPagesRemovedOnCacheReset( + store(), get_pages_callback(), policy_controller())); std::set<OfflinePageItem> result_set; result_set.insert(read_result().begin(), read_result().end()); @@ -346,7 +298,7 @@ OfflinePageItem selected_item = generator()->CreateItem(); selected_item.upgrade_attempt = remaining_attempts[i]; selected_item.creation_time = creation_times[i]; - store_util()->InsertItem(selected_item); + store_test_util()->InsertItem(selected_item); // This selected_item is expected in return and in this position. expected_items.push_back(selected_item); @@ -354,10 +306,10 @@ OfflinePageItem non_selected_item = generator()->CreateItem(); non_selected_item.upgrade_attempt = 0; non_selected_item.creation_time = creation_times[i]; - store_util()->InsertItem(non_selected_item); + store_test_util()->InsertItem(non_selected_item); } - runner()->RunTask(GetPagesTask::CreateTaskSelectingItemsMarkedForUpgrade( + RunTask(GetPagesTask::CreateTaskSelectingItemsMarkedForUpgrade( store(), get_pages_callback())); ASSERT_TRUE(expected_items.size() == read_result().size());
diff --git a/components/offline_pages/core/model/mark_page_accessed_task_unittest.cc b/components/offline_pages/core/model/mark_page_accessed_task_unittest.cc index 8caa7ff9..a432190 100644 --- a/components/offline_pages/core/model/mark_page_accessed_task_unittest.cc +++ b/components/offline_pages/core/model/mark_page_accessed_task_unittest.cc
@@ -5,16 +5,11 @@ #include "components/offline_pages/core/model/mark_page_accessed_task.h" #include <memory> -#include <vector> -#include "base/memory/ref_counted.h" #include "base/test/histogram_tester.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_model_utils.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -28,46 +23,14 @@ const int64_t kTestFileSize = 876543LL; } // namespace -class MarkPageAccessedTaskTest : public testing::Test { +class MarkPageAccessedTaskTest : public ModelTaskTestBase { public: - MarkPageAccessedTaskTest(); - ~MarkPageAccessedTaskTest() override; - - void SetUp() override; - void TearDown() override; - - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - TestTaskRunner* runner() { return &runner_; } - base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } + base::HistogramTester* histogram_tester() { return &histogram_tester_; } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - TestTaskRunner runner_; - std::unique_ptr<base::HistogramTester> histogram_tester_; + base::HistogramTester histogram_tester_; }; -MarkPageAccessedTaskTest::MarkPageAccessedTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_) {} - -MarkPageAccessedTaskTest::~MarkPageAccessedTaskTest() {} - -void MarkPageAccessedTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - histogram_tester_ = std::make_unique<base::HistogramTester>(); -} - -void MarkPageAccessedTaskTest::TearDown() { - store_test_util_.DeleteStore(); -} - TEST_F(MarkPageAccessedTaskTest, MarkPageAccessed) { OfflinePageItem page(kTestUrl, kTestOfflineId, kTestClientId, kTestFilePath, kTestFileSize); @@ -76,7 +39,7 @@ base::Time current_time = base::Time::Now(); auto task = std::make_unique<MarkPageAccessedTask>(store(), kTestOfflineId, current_time); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); auto offline_page = store_test_util()->GetPageByOfflineId(kTestOfflineId); EXPECT_EQ(kTestUrl, offline_page->url); @@ -102,7 +65,7 @@ base::Time current_time = base::Time::Now(); auto task = std::make_unique<MarkPageAccessedTask>(store(), kTestOfflineId, current_time); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); auto offline_page = store_test_util()->GetPageByOfflineId(kTestOfflineId); EXPECT_EQ(kTestOfflineId, offline_page->offline_id); @@ -123,7 +86,7 @@ base::Time second_time = base::Time::Now(); task = std::make_unique<MarkPageAccessedTask>(store(), kTestOfflineId, second_time); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); offline_page = store_test_util()->GetPageByOfflineId(kTestOfflineId); EXPECT_EQ(kTestOfflineId, offline_page->offline_id);
diff --git a/components/offline_pages/core/model/model_task_test_base.cc b/components/offline_pages/core/model/model_task_test_base.cc new file mode 100644 index 0000000..c27d0ff --- /dev/null +++ b/components/offline_pages/core/model/model_task_test_base.cc
@@ -0,0 +1,43 @@ +// Copyright 2018 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 "components/offline_pages/core/model/model_task_test_base.h" + +#include "base/files/file_util.h" +#include "base/logging.h" + +namespace offline_pages { +ModelTaskTestBase::ModelTaskTestBase() : store_test_util_(task_runner()) {} +ModelTaskTestBase::~ModelTaskTestBase() {} + +void ModelTaskTestBase::SetUp() { + TaskTestBase::SetUp(); + ASSERT_TRUE(temporary_dir_.CreateUniqueTempDir()); + generator()->SetArchiveDirectory(TemporaryDir()); + store_test_util_.BuildStoreInMemory(); +} + +void ModelTaskTestBase::TearDown() { + store_test_util_.DeleteStore(); + TaskTestBase::TearDown(); +} + +OfflinePageItem ModelTaskTestBase::AddPage() { + OfflinePageItem page = generator_.CreateItemWithTempFile(); + store_test_util_.InsertItem(page); + return page; +} + +OfflinePageItem ModelTaskTestBase::AddPageWithoutFile() { + OfflinePageItem page = generator_.CreateItemWithTempFile(); + EXPECT_TRUE(base::DeleteFile(page.file_path, false)); + store_test_util_.InsertItem(page); + return page; +} + +const base::FilePath& ModelTaskTestBase::TemporaryDir() { + return temporary_dir_.GetPath(); +} + +} // namespace offline_pages
diff --git a/components/offline_pages/core/model/model_task_test_base.h b/components/offline_pages/core/model/model_task_test_base.h new file mode 100644 index 0000000..7cbe008a --- /dev/null +++ b/components/offline_pages/core/model/model_task_test_base.h
@@ -0,0 +1,55 @@ +// Copyright 2018 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 COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_ +#define COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_ + +#include "base/files/scoped_temp_dir.h" +#include "base/memory/weak_ptr.h" +#include "base/test/test_mock_time_task_runner.h" +#include "base/threading/thread_task_runner_handle.h" +#include "components/offline_pages/core/client_policy_controller.h" +#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/offline_page_item.h" +#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" +#include "components/offline_pages/core/offline_page_types.h" +#include "components/offline_pages/core/offline_store_types.h" +#include "components/offline_pages/core/task_test_base.h" + +namespace offline_pages { +class ModelTaskTestBase : public TaskTestBase, + public base::SupportsWeakPtr<ModelTaskTestBase> { + public: + ModelTaskTestBase(); + ~ModelTaskTestBase() override; + + void SetUp() override; + void TearDown() override; + + const base::FilePath& TemporaryDir(); + + // Calls generator()->CreateItemWithTempFile() and inserts the item into the + // database. + OfflinePageItem AddPage(); + + // Calls generator()->CreateItem() and inserts the item into the database. + OfflinePageItem AddPageWithoutFile(); + + OfflinePageMetadataStoreTestUtil* store_test_util() { + return &store_test_util_; + } + OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } + OfflinePageItemGenerator* generator() { return &generator_; } + ClientPolicyController* policy_controller() { return &policy_controller_; } + + private: + OfflinePageMetadataStoreTestUtil store_test_util_; + OfflinePageItemGenerator generator_; + base::ScopedTempDir temporary_dir_; + ClientPolicyController policy_controller_; +}; + +} // namespace offline_pages + +#endif // COMPONENTS_OFFLINE_PAGES_CORE_MODEL_MODEL_TASK_TEST_BASE_H_
diff --git a/components/offline_pages/core/model/offline_page_model_taskified_unittest.cc b/components/offline_pages/core/model/offline_page_model_taskified_unittest.cc index a086994..7b6dbd2 100644 --- a/components/offline_pages/core/model/offline_page_model_taskified_unittest.cc +++ b/components/offline_pages/core/model/offline_page_model_taskified_unittest.cc
@@ -69,11 +69,9 @@ } // namespace -class OfflinePageModelTaskifiedTest - : public testing::Test, - public OfflinePageModel::Observer, - public OfflinePageTestArchiver::Observer, - public base::SupportsWeakPtr<OfflinePageModelTaskifiedTest> { +class OfflinePageModelTaskifiedTest : public testing::Test, + public OfflinePageModel::Observer, + public OfflinePageTestArchiver::Observer { public: OfflinePageModelTaskifiedTest(); ~OfflinePageModelTaskifiedTest() override;
diff --git a/components/offline_pages/core/model/persistent_pages_consistency_check_task_unittest.cc b/components/offline_pages/core/model/persistent_pages_consistency_check_task_unittest.cc index 7f34d30d..fa25f6e 100644 --- a/components/offline_pages/core/model/persistent_pages_consistency_check_task_unittest.cc +++ b/components/offline_pages/core/model/persistent_pages_consistency_check_task_unittest.cc
@@ -10,109 +10,41 @@ #include "base/files/file_enumerator.h" #include "base/files/file_util.h" #include "base/test/histogram_tester.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_test_utils.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { -class PersistentPagesConsistencyCheckTaskTest : public testing::Test { +class PersistentPagesConsistencyCheckTaskTest : public ModelTaskTestBase { public: PersistentPagesConsistencyCheckTaskTest(); ~PersistentPagesConsistencyCheckTaskTest() override; void SetUp() override; - void TearDown() override; - OfflinePageItem AddPage(const std::string& name_space, - const base::FilePath& archive_dir); - void SetShouldCreateDbEntry(bool should_create_db_entry); - void SetShouldCreateFile(bool should_create_file); bool IsPageRemovedFromBothPlaces(const OfflinePageItem& page); - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - ClientPolicyController* policy_controller() { - return policy_controller_.get(); - } base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } - const base::FilePath& persistent_dir() { return persistent_dir_.GetPath(); } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - std::unique_ptr<ClientPolicyController> policy_controller_; std::unique_ptr<base::HistogramTester> histogram_tester_; - - base::ScopedTempDir persistent_dir_; - bool should_create_db_entry_; - bool should_create_file_; }; PersistentPagesConsistencyCheckTaskTest:: - PersistentPagesConsistencyCheckTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - should_create_db_entry_(false), - should_create_file_(false) {} + PersistentPagesConsistencyCheckTaskTest() {} PersistentPagesConsistencyCheckTaskTest:: ~PersistentPagesConsistencyCheckTaskTest() {} void PersistentPagesConsistencyCheckTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - ASSERT_TRUE(persistent_dir_.CreateUniqueTempDir()); - policy_controller_ = std::make_unique<ClientPolicyController>(); + ModelTaskTestBase::SetUp(); + generator()->SetNamespace(kDownloadNamespace); histogram_tester_ = std::make_unique<base::HistogramTester>(); } -void PersistentPagesConsistencyCheckTaskTest::TearDown() { - store_test_util_.DeleteStore(); - if (!persistent_dir_.Delete()) - DVLOG(1) << "ScopedTempDir deletion failed."; - task_runner_->RunUntilIdle(); -} - -OfflinePageItem PersistentPagesConsistencyCheckTaskTest::AddPage( - const std::string& name_space, - const base::FilePath& archive_dir) { - generator()->SetNamespace(name_space); - generator()->SetArchiveDirectory(archive_dir); - OfflinePageItem page = generator()->CreateItemWithTempFile(); - if (should_create_db_entry_) - store_test_util()->InsertItem(page); - if (!should_create_file_) - EXPECT_TRUE(base::DeleteFile(page.file_path, false)); - return page; -} - -void PersistentPagesConsistencyCheckTaskTest::SetShouldCreateDbEntry( - bool should_create_db_entry) { - should_create_db_entry_ = should_create_db_entry; -} - -void PersistentPagesConsistencyCheckTaskTest::SetShouldCreateFile( - bool should_create_file) { - should_create_file_ = should_create_file; -} - bool PersistentPagesConsistencyCheckTaskTest::IsPageRemovedFromBothPlaces( const OfflinePageItem& page) { return !base::PathExists(page.file_path) && @@ -130,22 +62,18 @@ MAYBE_TestDeleteFileWithoutDbEntry) { // Only the files without DB entry and in persistent archive directory will // be deleted. - SetShouldCreateFile(true); - - SetShouldCreateDbEntry(true); - OfflinePageItem page1 = AddPage(kDownloadNamespace, persistent_dir()); - SetShouldCreateDbEntry(false); - OfflinePageItem page2 = AddPage(kDownloadNamespace, persistent_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = generator()->CreateItemWithTempFile(); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<PersistentPagesConsistencyCheckTask>( - store(), policy_controller(), persistent_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); histogram_tester()->ExpectTotalCount( @@ -170,22 +98,18 @@ MAYBE_TestDeleteDbEntryWithoutFile) { // The persistent pages will be deleted from DB if their DB entries exist but // files are missing. - SetShouldCreateDbEntry(true); - - SetShouldCreateFile(true); - OfflinePageItem page1 = AddPage(kDownloadNamespace, persistent_dir()); - SetShouldCreateFile(false); - OfflinePageItem page2 = AddPage(kDownloadNamespace, persistent_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = AddPageWithoutFile(); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<PersistentPagesConsistencyCheckTask>( - store(), policy_controller(), persistent_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); histogram_tester()->ExpectTotalCount( @@ -208,25 +132,19 @@ TEST_F(PersistentPagesConsistencyCheckTaskTest, MAYBE_CombinedTest) { // Adding a bunch of pages with different setups. // After the consistency check, only page1 will exist. - SetShouldCreateDbEntry(true); - SetShouldCreateFile(true); - OfflinePageItem page1 = AddPage(kDownloadNamespace, persistent_dir()); - SetShouldCreateDbEntry(false); - SetShouldCreateFile(true); - OfflinePageItem page2 = AddPage(kDownloadNamespace, persistent_dir()); - SetShouldCreateDbEntry(true); - SetShouldCreateFile(false); - OfflinePageItem page3 = AddPage(kDownloadNamespace, persistent_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = generator()->CreateItemWithTempFile(); + OfflinePageItem page3 = AddPageWithoutFile(); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<PersistentPagesConsistencyCheckTask>( - store(), policy_controller(), persistent_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page3)); @@ -243,24 +161,22 @@ TEST_F(PersistentPagesConsistencyCheckTaskTest, TestKeepingNonMhtmlFile) { // Create an offline page with mhtml extension but has no DB entry. - SetShouldCreateDbEntry(false); - SetShouldCreateFile(true); - OfflinePageItem page1 = AddPage(kDownloadNamespace, persistent_dir()); + OfflinePageItem page1 = generator()->CreateItemWithTempFile(); // Create a file with non-mhtml extension. base::FilePath path; - base::CreateTemporaryFileInDir(persistent_dir(), &path); + base::CreateTemporaryFileInDir(TemporaryDir(), &path); base::FilePath mp3_path = path.AddExtension(FILE_PATH_LITERAL("mp3")); EXPECT_TRUE(base::Move(path, mp3_path)); EXPECT_EQ(0LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<PersistentPagesConsistencyCheckTask>( - store(), policy_controller(), persistent_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(0LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(persistent_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page1)); histogram_tester()->ExpectTotalCount( "OfflinePages.ConsistencyCheck.Persistent.PagesMissingArchiveFileCount",
diff --git a/components/offline_pages/core/model/start_offline_page_upgrade_task_unittest.cc b/components/offline_pages/core/model/start_offline_page_upgrade_task_unittest.cc index 6a87c36..f903e1e 100644 --- a/components/offline_pages/core/model/start_offline_page_upgrade_task_unittest.cc +++ b/components/offline_pages/core/model/start_offline_page_upgrade_task_unittest.cc
@@ -6,12 +6,7 @@ #include <memory> -#include "base/files/scoped_temp_dir.h" -#include "base/test/test_mock_time_task_runner.h" -#include "base/threading/thread_task_runner_handle.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { @@ -20,23 +15,13 @@ const char kTestDigest[] = "TestDigest=="; } // namespace -class StartOfflinePageUpgradeTaskTest : public testing::Test { +class StartOfflinePageUpgradeTaskTest : public ModelTaskTestBase { public: StartOfflinePageUpgradeTaskTest(); ~StartOfflinePageUpgradeTaskTest() override; - void SetUp() override; - void TearDown() override; - void StartUpgradeDone(StartUpgradeResult result); - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - StartUpgradeCallback callback() { return base::BindOnce(&StartOfflinePageUpgradeTaskTest::StartUpgradeDone, base::Unretained(this)); @@ -45,49 +30,28 @@ StartUpgradeResult* last_result() { return &last_result_; } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; StartUpgradeResult last_result_; }; StartOfflinePageUpgradeTaskTest::StartOfflinePageUpgradeTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - last_result_(StartUpgradeStatus::DB_ERROR) {} + : last_result_(StartUpgradeStatus::DB_ERROR) {} StartOfflinePageUpgradeTaskTest::~StartOfflinePageUpgradeTaskTest() {} -void StartOfflinePageUpgradeTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); -} - -void StartOfflinePageUpgradeTaskTest::TearDown() { - store_test_util_.DeleteStore(); -} - void StartOfflinePageUpgradeTaskTest::StartUpgradeDone( StartUpgradeResult result) { last_result_ = std::move(result); } TEST_F(StartOfflinePageUpgradeTaskTest, StartUpgradeSuccess) { - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - generator()->SetArchiveDirectory(temp_dir.GetPath()); - OfflinePageItem original_page = generator()->CreateItemWithTempFile(); original_page.upgrade_attempt = 3; original_page.digest = kTestDigest; store_test_util()->InsertItem(original_page); auto task = std::make_unique<StartOfflinePageUpgradeTask>( - store(), original_page.offline_id, temp_dir.GetPath(), callback()); - runner()->RunTask(std::move(task)); + store(), original_page.offline_id, TemporaryDir(), callback()); + RunTask(std::move(task)); EXPECT_EQ(StartUpgradeStatus::SUCCESS, last_result()->status); EXPECT_EQ(kTestDigest, last_result()->digest); @@ -102,7 +66,7 @@ TEST_F(StartOfflinePageUpgradeTaskTest, StartUpgradeItemMissing) { auto task = std::make_unique<StartOfflinePageUpgradeTask>( store(), 42, base::FilePath(), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(StartUpgradeStatus::ITEM_MISSING, last_result()->status); EXPECT_TRUE(last_result()->digest.empty()); @@ -116,7 +80,7 @@ auto task = std::make_unique<StartOfflinePageUpgradeTask>( store(), original_page.offline_id, base::FilePath(), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(StartUpgradeStatus::FILE_MISSING, last_result()->status); EXPECT_TRUE(last_result()->digest.empty()); @@ -129,17 +93,13 @@ } TEST_F(StartOfflinePageUpgradeTaskTest, StartUpgradeNotEnoughSpace) { - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - generator()->SetArchiveDirectory(temp_dir.GetPath()); - OfflinePageItem original_page = generator()->CreateItemWithTempFile(); original_page.upgrade_attempt = 3; store_test_util()->InsertItem(original_page); auto task = std::make_unique<StartOfflinePageUpgradeTask>( store(), original_page.offline_id, base::FilePath(), callback()); - runner()->RunTask(std::move(task)); + RunTask(std::move(task)); EXPECT_EQ(StartUpgradeStatus::NOT_ENOUGH_STORAGE, last_result()->status); EXPECT_TRUE(last_result()->digest.empty());
diff --git a/components/offline_pages/core/model/temporary_pages_consistency_check_task_unittest.cc b/components/offline_pages/core/model/temporary_pages_consistency_check_task_unittest.cc index 321201b..7646a54ce 100644 --- a/components/offline_pages/core/model/temporary_pages_consistency_check_task_unittest.cc +++ b/components/offline_pages/core/model/temporary_pages_consistency_check_task_unittest.cc
@@ -14,104 +14,32 @@ #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "components/offline_pages/core/client_namespace_constants.h" -#include "components/offline_pages/core/client_policy_controller.h" -#include "components/offline_pages/core/model/offline_page_item_generator.h" +#include "components/offline_pages/core/model/model_task_test_base.h" #include "components/offline_pages/core/model/offline_page_test_utils.h" -#include "components/offline_pages/core/offline_page_metadata_store_test_util.h" -#include "components/offline_pages/core/test_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace offline_pages { -class TemporaryPagesConsistencyCheckTaskTest : public testing::Test { +class TemporaryPagesConsistencyCheckTaskTest : public ModelTaskTestBase { public: - TemporaryPagesConsistencyCheckTaskTest(); - ~TemporaryPagesConsistencyCheckTaskTest() override; + ~TemporaryPagesConsistencyCheckTaskTest() override {} void SetUp() override; - void TearDown() override; - OfflinePageItem AddPage(const std::string& name_space, - const base::FilePath& archive_dir); - void SetShouldCreateDbEntry(bool should_create_db_entry); - void SetShouldCreateFile(bool should_create_file); bool IsPageRemovedFromBothPlaces(const OfflinePageItem& page); - OfflinePageMetadataStoreSQL* store() { return store_test_util_.store(); } - OfflinePageMetadataStoreTestUtil* store_test_util() { - return &store_test_util_; - } - OfflinePageItemGenerator* generator() { return &generator_; } - TestTaskRunner* runner() { return &runner_; } - ClientPolicyController* policy_controller() { - return policy_controller_.get(); - } base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } - const base::FilePath& temporary_dir() { return temporary_dir_.GetPath(); } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - - OfflinePageMetadataStoreTestUtil store_test_util_; - OfflinePageItemGenerator generator_; - TestTaskRunner runner_; - std::unique_ptr<ClientPolicyController> policy_controller_; std::unique_ptr<base::HistogramTester> histogram_tester_; - - base::ScopedTempDir temporary_dir_; - bool should_create_db_entry_; - bool should_create_file_; }; -TemporaryPagesConsistencyCheckTaskTest::TemporaryPagesConsistencyCheckTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner()), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_), - runner_(task_runner_), - should_create_db_entry_(false), - should_create_file_(false) {} - -TemporaryPagesConsistencyCheckTaskTest:: - ~TemporaryPagesConsistencyCheckTaskTest() {} - void TemporaryPagesConsistencyCheckTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - ASSERT_TRUE(temporary_dir_.CreateUniqueTempDir()); - policy_controller_ = std::make_unique<ClientPolicyController>(); + ModelTaskTestBase::SetUp(); + generator()->SetNamespace(kLastNNamespace); histogram_tester_ = std::make_unique<base::HistogramTester>(); } -void TemporaryPagesConsistencyCheckTaskTest::TearDown() { - store_test_util_.DeleteStore(); - if (!temporary_dir_.Delete()) - DVLOG(1) << "ScopedTempDir deletion failed."; - task_runner_->RunUntilIdle(); -} - -OfflinePageItem TemporaryPagesConsistencyCheckTaskTest::AddPage( - const std::string& name_space, - const base::FilePath& archive_dir) { - generator()->SetNamespace(name_space); - generator()->SetArchiveDirectory(archive_dir); - OfflinePageItem page = generator()->CreateItemWithTempFile(); - if (should_create_db_entry_) - store_test_util()->InsertItem(page); - if (!should_create_file_) - EXPECT_TRUE(base::DeleteFile(page.file_path, false)); - return page; -} - -void TemporaryPagesConsistencyCheckTaskTest::SetShouldCreateDbEntry( - bool should_create_db_entry) { - should_create_db_entry_ = should_create_db_entry; -} - -void TemporaryPagesConsistencyCheckTaskTest::SetShouldCreateFile( - bool should_create_file) { - should_create_file_ = should_create_file; -} - bool TemporaryPagesConsistencyCheckTaskTest::IsPageRemovedFromBothPlaces( const OfflinePageItem& page) { return !base::PathExists(page.file_path) && @@ -128,22 +56,19 @@ TEST_F(TemporaryPagesConsistencyCheckTaskTest, MAYBE_TestDeleteFileWithoutDbEntry) { // Only the file without DB entry and in temporary directory will be deleted. - SetShouldCreateFile(true); - SetShouldCreateDbEntry(true); - OfflinePageItem page1 = AddPage(kLastNNamespace, temporary_dir()); - SetShouldCreateDbEntry(false); - OfflinePageItem page2 = AddPage(kLastNNamespace, temporary_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = generator()->CreateItemWithTempFile(); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<TemporaryPagesConsistencyCheckTask>( - store(), policy_controller(), temporary_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); histogram_tester()->ExpectTotalCount( @@ -167,22 +92,19 @@ MAYBE_TestDeleteDbEntryWithoutFile) { // The temporary pages will be deleted from DB if their DB entries exist but // files are missing. - SetShouldCreateDbEntry(true); - SetShouldCreateFile(true); - OfflinePageItem page1 = AddPage(kLastNNamespace, temporary_dir()); - SetShouldCreateFile(false); - OfflinePageItem page2 = AddPage(kLastNNamespace, temporary_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = AddPageWithoutFile(); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<TemporaryPagesConsistencyCheckTask>( - store(), policy_controller(), temporary_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); histogram_tester()->ExpectTotalCount( @@ -205,25 +127,19 @@ TEST_F(TemporaryPagesConsistencyCheckTaskTest, MAYBE_CombinedTest) { // Adding a bunch of pages with different setups. // After the consistency check, only page1 will exist. - SetShouldCreateDbEntry(true); - SetShouldCreateFile(true); - OfflinePageItem page1 = AddPage(kLastNNamespace, temporary_dir()); - SetShouldCreateDbEntry(false); - SetShouldCreateFile(true); - OfflinePageItem page2 = AddPage(kLastNNamespace, temporary_dir()); - SetShouldCreateDbEntry(true); - SetShouldCreateFile(false); - OfflinePageItem page3 = AddPage(kLastNNamespace, temporary_dir()); + OfflinePageItem page1 = AddPage(); + OfflinePageItem page2 = generator()->CreateItemWithTempFile(); + OfflinePageItem page3 = AddPageWithoutFile(); EXPECT_EQ(2LL, store_test_util()->GetPageCount()); - EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(2UL, test_utils::GetFileCountInDirectory(TemporaryDir())); auto task = std::make_unique<TemporaryPagesConsistencyCheckTask>( - store(), policy_controller(), temporary_dir()); - runner()->RunTask(std::move(task)); + store(), policy_controller(), TemporaryDir()); + RunTask(std::move(task)); EXPECT_EQ(1LL, store_test_util()->GetPageCount()); - EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(temporary_dir())); + EXPECT_EQ(1UL, test_utils::GetFileCountInDirectory(TemporaryDir())); EXPECT_FALSE(IsPageRemovedFromBothPlaces(page1)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page2)); EXPECT_TRUE(IsPageRemovedFromBothPlaces(page3));
diff --git a/components/offline_pages/core/prefetch/add_unique_urls_task_unittest.cc b/components/offline_pages/core/prefetch/add_unique_urls_task_unittest.cc index 9e6fc3f..14a843d9 100644 --- a/components/offline_pages/core/prefetch/add_unique_urls_task_unittest.cc +++ b/components/offline_pages/core/prefetch/add_unique_urls_task_unittest.cc
@@ -66,20 +66,16 @@ TEST_F(AddUniqueUrlsTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - AddUniqueUrlsTask task(dispatcher(), store(), kTestNamespace, {}); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>( + dispatcher(), store(), kTestNamespace, std::vector<PrefetchURL>())); } TEST_F(AddUniqueUrlsTaskTest, AddTaskInEmptyStore) { std::vector<PrefetchURL> urls; urls.push_back(PrefetchURL{kClientId1, kTestURL1, kTestTitle1}); urls.push_back(PrefetchURL{kClientId2, kTestURL2, kTestTitle2}); - AddUniqueUrlsTask task(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); std::map<std::string, PrefetchItem> items = GetAllItems(); ASSERT_EQ(2u, items.size()); @@ -100,24 +96,18 @@ TEST_F(AddUniqueUrlsTaskTest, SingleDuplicateUrlNotAdded) { std::vector<PrefetchURL> urls; urls.push_back(PrefetchURL{kClientId1, kTestURL1, kTestTitle1}); - AddUniqueUrlsTask task1(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task1); - task1.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); EXPECT_EQ(1, dispatcher()->task_schedule_count); // AddUniqueUrlsTask with no URLs should not increment task schedule count. - AddUniqueUrlsTask task2(dispatcher(), store(), kTestNamespace, {}); - ExpectTaskCompletes(&task2); - task2.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>( + dispatcher(), store(), kTestNamespace, std::vector<PrefetchURL>())); // The task schedule count should not have changed with no new URLs. EXPECT_EQ(1, dispatcher()->task_schedule_count); - AddUniqueUrlsTask task3(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task3); - task3.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); // The task schedule count should not have changed with no new URLs. EXPECT_EQ(1, dispatcher()->task_schedule_count); } @@ -126,10 +116,8 @@ std::vector<PrefetchURL> urls; urls.push_back(PrefetchURL{kClientId1, kTestURL1, kTestTitle1}); urls.push_back(PrefetchURL{kClientId2, kTestURL2, kTestTitle2}); - AddUniqueUrlsTask task1(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task1); - task1.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); EXPECT_EQ(1, dispatcher()->task_schedule_count); urls.clear(); @@ -137,10 +125,8 @@ urls.push_back(PrefetchURL{kClientId4, kTestURL1, kTestTitle4}); urls.push_back(PrefetchURL{kClientId3, kTestURL3, kTestTitle3}); - AddUniqueUrlsTask task2(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task2); - task2.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); EXPECT_EQ(2, dispatcher()->task_schedule_count); std::map<std::string, PrefetchItem> items = GetAllItems(); @@ -164,10 +150,8 @@ urls.push_back(PrefetchURL{kClientId1, kTestURL1, kTestTitle1}); urls.push_back(PrefetchURL{kClientId2, kTestURL2, kTestTitle2}); urls.push_back(PrefetchURL{kClientId3, kTestURL3, kTestTitle3}); - AddUniqueUrlsTask task1(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task1); - task1.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); EXPECT_EQ(1, dispatcher()->task_schedule_count); // ZombifyPrefetchItem returns the number of affected items. @@ -182,10 +166,8 @@ // ID-2 is expected to be removed, because it is in zombie state. // ID-3 is still requested, so it is ignored. // ID-4 is added. - AddUniqueUrlsTask task2(dispatcher(), store(), kTestNamespace, urls); - ExpectTaskCompletes(&task2); - task2.Run(); - RunUntilIdle(); + RunTask(std::make_unique<AddUniqueUrlsTask>(dispatcher(), store(), + kTestNamespace, urls)); EXPECT_EQ(2, dispatcher()->task_schedule_count); std::map<std::string, PrefetchItem> items = GetAllItems();
diff --git a/components/offline_pages/core/prefetch/download_archives_task_unittest.cc b/components/offline_pages/core/prefetch/download_archives_task_unittest.cc index b7d884d..3e324a79 100644 --- a/components/offline_pages/core/prefetch/download_archives_task_unittest.cc +++ b/components/offline_pages/core/prefetch/download_archives_task_unittest.cc
@@ -74,10 +74,8 @@ TEST_F(DownloadArchivesTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - DownloadArchivesTask task(store(), prefetch_downloader()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); } TEST_F(DownloadArchivesTaskTest, NoArchivesToDownload) { @@ -89,11 +87,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(10U, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(10U, store_util()->GetAllItems(&items_after_run)); @@ -111,11 +107,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(2U, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(2U, store_util()->GetAllItems(&items_after_run)); @@ -161,11 +155,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(3U, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(3U, store_util()->GetAllItems(&items_after_run)); @@ -214,11 +206,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(3U, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(3U, store_util()->GetAllItems(&items_after_run)); @@ -267,11 +257,9 @@ EXPECT_EQ(static_cast<size_t>(total_items), store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(static_cast<size_t>(total_items), @@ -338,11 +326,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(total_items, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(total_items, store_util()->GetAllItems(&items_after_run)); @@ -392,11 +378,9 @@ std::set<PrefetchItem> items_before_run; EXPECT_EQ(1U, store_util()->GetAllItems(&items_before_run)); - DownloadArchivesTask task(store(), prefetch_downloader()); base::HistogramTester histogram_tester; - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask( + std::make_unique<DownloadArchivesTask>(store(), prefetch_downloader())); std::set<PrefetchItem> items_after_run; EXPECT_EQ(1U, store_util()->GetAllItems(&items_after_run));
diff --git a/components/offline_pages/core/prefetch/download_cleanup_task_unittest.cc b/components/offline_pages/core/prefetch/download_cleanup_task_unittest.cc index 0c0d2db..344e1f3 100644 --- a/components/offline_pages/core/prefetch/download_cleanup_task_unittest.cc +++ b/components/offline_pages/core/prefetch/download_cleanup_task_unittest.cc
@@ -39,11 +39,8 @@ std::make_pair(kTestFilePath, kTestFileSize)); } - DownloadCleanupTask task(&dispatcher_, store(), outstanding_download_ids, - success_downloads); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<DownloadCleanupTask>( + &dispatcher_, store(), outstanding_download_ids, success_downloads)); } private:
diff --git a/components/offline_pages/core/prefetch/download_completed_task_unittest.cc b/components/offline_pages/core/prefetch/download_completed_task_unittest.cc index 317cc1fe..d7e3931 100644 --- a/components/offline_pages/core/prefetch/download_completed_task_unittest.cc +++ b/components/offline_pages/core/prefetch/download_completed_task_unittest.cc
@@ -12,6 +12,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "components/offline_pages/core/prefetch/prefetch_item.h" +#include "components/offline_pages/core/prefetch/prefetch_task_test_base.h" #include "components/offline_pages/core/prefetch/prefetch_types.h" #include "components/offline_pages/core/prefetch/store/prefetch_store.h" #include "components/offline_pages/core/prefetch/store/prefetch_store_test_util.h" @@ -32,46 +33,29 @@ const int64_t kTestFileSize = 88888; } // namespace -// TODO(carlosk, jianli): Update this test to extend and use the functionality -// provided by TaskTestBase. -class DownloadCompletedTaskTest : public testing::Test { +class DownloadCompletedTaskTest : public PrefetchTaskTestBase { public: - DownloadCompletedTaskTest(); ~DownloadCompletedTaskTest() override = default; void SetUp() override; - void TearDown() override; - void PumpLoop(); - - PrefetchStore* store() { return store_test_util_.store(); } TestPrefetchDispatcher* dispatcher() { return &dispatcher_; } - PrefetchStoreTestUtil* store_util() { return &store_test_util_; } base::HistogramTester* histogram_tester() { return histogram_tester_.get(); } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; TestPrefetchDispatcher dispatcher_; - PrefetchStoreTestUtil store_test_util_; std::unique_ptr<base::HistogramTester> histogram_tester_; }; -DownloadCompletedTaskTest::DownloadCompletedTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_) {} - void DownloadCompletedTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - + PrefetchTaskTestBase::SetUp(); PrefetchItem item; item.offline_id = kTestOfflineID; item.guid = kTestGUID; item.state = PrefetchItemState::DOWNLOADING; item.creation_time = base::Time::Now(); item.freshness_time = item.creation_time; - EXPECT_TRUE(store_test_util_.InsertPrefetchItem(item)); + EXPECT_TRUE(store_util()->InsertPrefetchItem(item)); PrefetchItem item2; item2.offline_id = kTestOfflineID2; @@ -79,36 +63,25 @@ item2.state = PrefetchItemState::NEW_REQUEST; item2.creation_time = base::Time::Now(); item2.freshness_time = item.creation_time; - EXPECT_TRUE(store_test_util_.InsertPrefetchItem(item2)); + EXPECT_TRUE(store_util()->InsertPrefetchItem(item2)); histogram_tester_.reset(new base::HistogramTester()); } -void DownloadCompletedTaskTest::TearDown() { - store_test_util_.DeleteStore(); - PumpLoop(); -} - -void DownloadCompletedTaskTest::PumpLoop() { - task_runner_->RunUntilIdle(); -} - TEST_F(DownloadCompletedTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); PrefetchDownloadResult download_result(kTestGUID, kTestFilePath, kTestFileSize); - DownloadCompletedTask task(dispatcher(), store(), download_result); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<DownloadCompletedTask>(dispatcher(), store(), + download_result)); } TEST_F(DownloadCompletedTaskTest, UpdateItemOnDownloadSuccess) { PrefetchDownloadResult download_result(kTestGUID, kTestFilePath, kTestFileSize); - DownloadCompletedTask task(dispatcher(), store(), download_result); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<DownloadCompletedTask>(dispatcher(), store(), + download_result)); std::unique_ptr<PrefetchItem> item = store_util()->GetPrefetchItem(kTestOfflineID); @@ -129,9 +102,8 @@ PrefetchDownloadResult download_result; download_result.download_id = kTestGUID; download_result.success = false; - DownloadCompletedTask task(dispatcher(), store(), download_result); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<DownloadCompletedTask>(dispatcher(), store(), + download_result)); std::unique_ptr<PrefetchItem> item = store_util()->GetPrefetchItem(kTestOfflineID); @@ -152,9 +124,8 @@ TEST_F(DownloadCompletedTaskTest, NoUpdateOnMismatchedDownloadSuccess) { PrefetchDownloadResult download_result(kTestGUID2, kTestFilePath, kTestFileSize); - DownloadCompletedTask task(dispatcher(), store(), download_result); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<DownloadCompletedTask>(dispatcher(), store(), + download_result)); // Item will only be updated when both offline_id and state match. std::unique_ptr<PrefetchItem> item = @@ -178,9 +149,8 @@ PrefetchDownloadResult download_result; download_result.download_id = kTestGUID2; download_result.success = false; - DownloadCompletedTask task(dispatcher(), store(), download_result); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<DownloadCompletedTask>(dispatcher(), store(), + download_result)); // Item will only be updated when both offline_id and state match. std::unique_ptr<PrefetchItem> item =
diff --git a/components/offline_pages/core/prefetch/finalize_dismissed_url_suggestion_task_unittest.cc b/components/offline_pages/core/prefetch/finalize_dismissed_url_suggestion_task_unittest.cc index 3734f2d..bc4e384 100644 --- a/components/offline_pages/core/prefetch/finalize_dismissed_url_suggestion_task_unittest.cc +++ b/components/offline_pages/core/prefetch/finalize_dismissed_url_suggestion_task_unittest.cc
@@ -36,18 +36,14 @@ PrefetchItem item = AddItem(PrefetchItemState::RECEIVED_BUNDLE); store_util()->SimulateInitializationError(); - FinalizeDismissedUrlSuggestionTask task(store(), item.client_id); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<FinalizeDismissedUrlSuggestionTask>(store(), + item.client_id)); } TEST_F(FinalizeDismissedUrlSuggestionTaskTest, NotFound) { PrefetchItem item = AddItem(PrefetchItemState::RECEIVED_BUNDLE); - FinalizeDismissedUrlSuggestionTask task(store(), ClientId("abc", "123")); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<FinalizeDismissedUrlSuggestionTask>( + store(), ClientId("abc", "123"))); EXPECT_EQ(1, store_util()->CountPrefetchItems()); } @@ -63,10 +59,8 @@ want_items.insert(item); } for (const PrefetchItem& item : items) { - FinalizeDismissedUrlSuggestionTask task(store(), item.client_id); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<FinalizeDismissedUrlSuggestionTask>( + store(), item.client_id)); } std::set<PrefetchItem> final_items; @@ -83,10 +77,8 @@ } for (const PrefetchItem& item : items) { - FinalizeDismissedUrlSuggestionTask task(store(), item.client_id); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<FinalizeDismissedUrlSuggestionTask>( + store(), item.client_id)); } std::set<PrefetchItem> final_items;
diff --git a/components/offline_pages/core/prefetch/generate_page_bundle_reconcile_task_unittest.cc b/components/offline_pages/core/prefetch/generate_page_bundle_reconcile_task_unittest.cc index 21697ead..c0b038c 100644 --- a/components/offline_pages/core/prefetch/generate_page_bundle_reconcile_task_unittest.cc +++ b/components/offline_pages/core/prefetch/generate_page_bundle_reconcile_task_unittest.cc
@@ -87,10 +87,8 @@ TEST_F(GeneratePageBundleReconcileTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); } TEST_F(GeneratePageBundleReconcileTaskTest, Retry) { @@ -100,10 +98,8 @@ GeneratePageBundleReconcileTask::kMaxGenerateBundleAttempts - 1; ASSERT_TRUE(store_util()->InsertPrefetchItem(item)); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -122,10 +118,8 @@ request_factory()->AddRequestedUrl(item.url.spec()); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -139,10 +133,8 @@ GeneratePageBundleReconcileTask::kMaxGenerateBundleAttempts; ASSERT_TRUE(store_util()->InsertPrefetchItem(item)); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -165,10 +157,8 @@ request_factory()->AddRequestedUrl(item.url.spec()); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -184,10 +174,8 @@ for (const auto& state : all_other_states) items.insert(InsertItem(state, attempts_count)); - GeneratePageBundleReconcileTask task(store(), request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleReconcileTask>(store(), + request_factory())); std::set<PrefetchItem> store_items; store_util()->GetAllItems(&store_items);
diff --git a/components/offline_pages/core/prefetch/generate_page_bundle_task_unittest.cc b/components/offline_pages/core/prefetch/generate_page_bundle_task_unittest.cc index e7abde7..d43de1f 100644 --- a/components/offline_pages/core/prefetch/generate_page_bundle_task_unittest.cc +++ b/components/offline_pages/core/prefetch/generate_page_bundle_task_unittest.cc
@@ -43,21 +43,14 @@ store_util()->SimulateInitializationError(); base::MockCallback<PrefetchRequestFinishedCallback> callback; - GeneratePageBundleTask task(store(), gcm_handler(), - prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleTask>( + store(), gcm_handler(), prefetch_request_factory(), callback.Get())); } TEST_F(GeneratePageBundleTaskTest, EmptyTask) { base::MockCallback<PrefetchRequestFinishedCallback> callback; - GeneratePageBundleTask task(store(), gcm_handler(), - prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GeneratePageBundleTask>( + store(), gcm_handler(), prefetch_request_factory(), callback.Get())); EXPECT_FALSE(prefetch_request_factory()->HasOutstandingRequests()); auto requested_urls = prefetch_request_factory()->GetAllUrlsRequested(); @@ -98,9 +91,7 @@ prefetch_request_factory(), request_callback.Get()); task.SetClockForTesting(base::WrapUnique(clock)); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); auto requested_urls = prefetch_request_factory()->GetAllUrlsRequested(); EXPECT_THAT(*requested_urls, Contains(item1.url.spec()));
diff --git a/components/offline_pages/core/prefetch/get_operation_task_unittest.cc b/components/offline_pages/core/prefetch/get_operation_task_unittest.cc index 4f7e7911..9ae5e1af 100644 --- a/components/offline_pages/core/prefetch/get_operation_task_unittest.cc +++ b/components/offline_pages/core/prefetch/get_operation_task_unittest.cc
@@ -38,10 +38,8 @@ store_util()->SimulateInitializationError(); base::MockCallback<PrefetchRequestFinishedCallback> callback; - GetOperationTask task(store(), prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GetOperationTask>( + store(), prefetch_request_factory(), callback.Get())); } TEST_F(GetOperationTaskTest, NormalOperationTask) { @@ -50,10 +48,8 @@ kOperationName, PrefetchItemState::RECEIVED_GCM); ASSERT_NE(nullptr, store_util()->GetPrefetchItem(id)); - GetOperationTask task(store(), prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GetOperationTask>( + store(), prefetch_request_factory(), callback.Get())); EXPECT_NE(nullptr, prefetch_request_factory()->FindGetOperationRequestByName( kOperationName)); @@ -76,10 +72,8 @@ InsertPrefetchItemInStateWithOperation(kOperationName, state)); } - GetOperationTask task(store(), prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GetOperationTask>( + store(), prefetch_request_factory(), callback.Get())); EXPECT_EQ(nullptr, prefetch_request_factory()->FindGetOperationRequestByName( kOperationName)); @@ -103,10 +97,8 @@ int64_t unused_item = InsertPrefetchItemInStateWithOperation( kOperationShouldNotBeRequested, PrefetchItemState::SENT_GET_OPERATION); - GetOperationTask task(store(), prefetch_request_factory(), callback.Get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<GetOperationTask>( + store(), prefetch_request_factory(), callback.Get())); EXPECT_NE(nullptr, prefetch_request_factory()->FindGetOperationRequestByName( kOperationName));
diff --git a/components/offline_pages/core/prefetch/import_archives_task_unittest.cc b/components/offline_pages/core/prefetch/import_archives_task_unittest.cc index 405fb15..5983c15 100644 --- a/components/offline_pages/core/prefetch/import_archives_task_unittest.cc +++ b/components/offline_pages/core/prefetch/import_archives_task_unittest.cc
@@ -13,6 +13,7 @@ #include "base/time/time.h" #include "components/offline_pages/core/prefetch/prefetch_importer.h" #include "components/offline_pages/core/prefetch/prefetch_item.h" +#include "components/offline_pages/core/prefetch/prefetch_task_test_base.h" #include "components/offline_pages/core/prefetch/prefetch_types.h" #include "components/offline_pages/core/prefetch/store/prefetch_store.h" #include "components/offline_pages/core/prefetch/store/prefetch_store_test_util.h" @@ -64,37 +65,20 @@ } // namespace -// TODO(carlosk, jianli): Update this test to extend and use the functionality -// provided by TaskTestBase. -class ImportArchivesTaskTest : public testing::Test { +class ImportArchivesTaskTest : public PrefetchTaskTestBase { public: - ImportArchivesTaskTest(); ~ImportArchivesTaskTest() override = default; void SetUp() override; - void TearDown() override; - void PumpLoop(); - - PrefetchStore* store() { return store_test_util_.store(); } - PrefetchStoreTestUtil* store_util() { return &store_test_util_; } TestPrefetchImporter* importer() { return &test_importer_; } private: - scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; - base::ThreadTaskRunnerHandle task_runner_handle_; - PrefetchStoreTestUtil store_test_util_; TestPrefetchImporter test_importer_; }; -ImportArchivesTaskTest::ImportArchivesTaskTest() - : task_runner_(new base::TestMockTimeTaskRunner), - task_runner_handle_(task_runner_), - store_test_util_(task_runner_) {} - void ImportArchivesTaskTest::SetUp() { - store_test_util_.BuildStoreInMemory(); - + PrefetchTaskTestBase::SetUp(); PrefetchItem item; item.offline_id = kTestOfflineID; item.state = PrefetchItemState::DOWNLOADED; @@ -107,7 +91,7 @@ item.file_size = kTestFileSize; item.creation_time = base::Time::Now(); item.freshness_time = item.creation_time; - EXPECT_TRUE(store_test_util_.InsertPrefetchItem(item)); + EXPECT_TRUE(store_util()->InsertPrefetchItem(item)); PrefetchItem item2; item2.offline_id = kTestOfflineID2; @@ -121,36 +105,23 @@ item2.file_size = kTestFileSize2; item2.creation_time = base::Time::Now(); item2.freshness_time = item.creation_time; - EXPECT_TRUE(store_test_util_.InsertPrefetchItem(item2)); + EXPECT_TRUE(store_util()->InsertPrefetchItem(item2)); PrefetchItem item3; item3.offline_id = kTestOfflineID3; item3.state = PrefetchItemState::NEW_REQUEST; item3.creation_time = base::Time::Now(); item3.freshness_time = item.creation_time; - EXPECT_TRUE(store_test_util_.InsertPrefetchItem(item3)); -} - -void ImportArchivesTaskTest::TearDown() { - store_test_util_.DeleteStore(); - PumpLoop(); -} - -void ImportArchivesTaskTest::PumpLoop() { - task_runner_->RunUntilIdle(); + EXPECT_TRUE(store_util()->InsertPrefetchItem(item3)); } TEST_F(ImportArchivesTaskTest, NullConnection) { store_util()->SimulateInitializationError(); - ImportArchivesTask task(store(), importer()); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<ImportArchivesTask>(store(), importer())); } TEST_F(ImportArchivesTaskTest, Importing) { - ImportArchivesTask task(store(), importer()); - task.Run(); - PumpLoop(); + RunTask(std::make_unique<ImportArchivesTask>(store(), importer())); // Two items are updated. std::unique_ptr<PrefetchItem> item =
diff --git a/components/offline_pages/core/prefetch/import_cleanup_task_unittest.cc b/components/offline_pages/core/prefetch/import_cleanup_task_unittest.cc index f4758d4..b79d660 100644 --- a/components/offline_pages/core/prefetch/import_cleanup_task_unittest.cc +++ b/components/offline_pages/core/prefetch/import_cleanup_task_unittest.cc
@@ -52,9 +52,7 @@ TEST_F(ImportCleanupTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - ImportCleanupTask task(store(), importer()); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCleanupTask>(store(), importer())); } TEST_F(ImportCleanupTaskTest, DoCleanup) { @@ -74,9 +72,7 @@ EXPECT_TRUE(store_util()->InsertPrefetchItem(item3)); // Clean up the imports. - ImportCleanupTask task(store(), importer()); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCleanupTask>(store(), importer())); // Item 1 is cleaned up. std::unique_ptr<PrefetchItem> store_item1 = @@ -127,9 +123,7 @@ importer()->ImportArchive(archive_info3); // Clean up the imports. - ImportCleanupTask task(store(), importer()); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCleanupTask>(store(), importer())); // Item 1 is intact since it is in the outstanding list. std::unique_ptr<PrefetchItem> store_item1 = @@ -154,9 +148,7 @@ importer()->MarkImportCompleted(item1.offline_id); // Trigger another import cleanup. - ImportCleanupTask task2(store(), importer()); - task2.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCleanupTask>(store(), importer())); // Item 1 should now be cleaned up. store_item1 = store_util()->GetPrefetchItem(item1.offline_id);
diff --git a/components/offline_pages/core/prefetch/import_completed_task_unittest.cc b/components/offline_pages/core/prefetch/import_completed_task_unittest.cc index ce2d3da..fe8d791 100644 --- a/components/offline_pages/core/prefetch/import_completed_task_unittest.cc +++ b/components/offline_pages/core/prefetch/import_completed_task_unittest.cc
@@ -29,10 +29,8 @@ TEST_F(ImportCompletedTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - ImportCompletedTask task(dispatcher(), store(), importer(), 1, true); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCompletedTask>(dispatcher(), store(), + importer(), 1, true)); } TEST_F(ImportCompletedTaskTest, ImportSuccess) { @@ -40,11 +38,9 @@ item_generator()->CreateItem(PrefetchItemState::IMPORTING); EXPECT_TRUE(store_util()->InsertPrefetchItem(item)); - ImportCompletedTask task(dispatcher(), store(), importer(), item.offline_id, - /*success*/ true); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCompletedTask>(dispatcher(), store(), + importer(), item.offline_id, + /*success*/ true)); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -62,11 +58,9 @@ item_generator()->CreateItem(PrefetchItemState::IMPORTING); EXPECT_TRUE(store_util()->InsertPrefetchItem(item)); - ImportCompletedTask task(dispatcher(), store(), importer(), item.offline_id, - /*success*/ false); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCompletedTask>(dispatcher(), store(), + importer(), item.offline_id, + /*success*/ false)); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -88,11 +82,9 @@ EXPECT_TRUE(store_util()->InsertPrefetchItem(item2)); // Trigger an import sucecss task. - ImportCompletedTask task(dispatcher(), store(), importer(), item2.offline_id, - /*success*/ true); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCompletedTask>(dispatcher(), store(), + importer(), item2.offline_id, + /*success*/ true)); // Item will only be updated when both guid and state match. std::unique_ptr<PrefetchItem> store_item = @@ -110,11 +102,9 @@ EXPECT_EQ(item2.offline_id, importer()->latest_completed_offline_id.back()); // Trigger an import error task. - ImportCompletedTask task2(dispatcher(), store(), importer(), item2.offline_id, - /*success*/ false); - ExpectTaskCompletes(&task2); - task2.Run(); - RunUntilIdle(); + RunTask(std::make_unique<ImportCompletedTask>(dispatcher(), store(), + importer(), item2.offline_id, + /*success*/ false)); // Item will only be updated when both guid and state match. store_item = store_util()->GetPrefetchItem(item.offline_id);
diff --git a/components/offline_pages/core/prefetch/mark_operation_done_task_unittest.cc b/components/offline_pages/core/prefetch/mark_operation_done_task_unittest.cc index 75594194..6566c742f 100644 --- a/components/offline_pages/core/prefetch/mark_operation_done_task_unittest.cc +++ b/components/offline_pages/core/prefetch/mark_operation_done_task_unittest.cc
@@ -65,29 +65,20 @@ TEST_F(MarkOperationDoneTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); - MarkOperationDoneTask task(dispatcher(), store(), kOperationName); - ExpectTaskCompletes(&task); - - task.Run(); - RunUntilIdle(); + RunTask(std::make_unique<MarkOperationDoneTask>(dispatcher(), store(), + kOperationName)); } TEST_F(MarkOperationDoneTaskTest, NoOpTask) { MarkOperationDoneTask task(dispatcher(), store(), kOperationName); - ExpectTaskCompletes(&task); - - task.Run(); - RunUntilIdle(); + RunTask(&task); ExpectStoreChangeCount(&task, 0); } TEST_F(MarkOperationDoneTaskTest, SingleMatchingURL) { int64_t id = InsertAwaitingGCMOperation(kOperationName); MarkOperationDoneTask task(dispatcher(), store(), kOperationName); - - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); ExpectStoreChangeCount(&task, 1); EXPECT_EQ(1, store_util()->CountPrefetchItems()); @@ -102,10 +93,7 @@ // Start a task for an unrelated operation name. MarkOperationDoneTask task(dispatcher(), store(), kOtherOperationName); - - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); ExpectStoreChangeCount(&task, 0); ASSERT_TRUE(store_util()->GetPrefetchItem(id1)); @@ -127,10 +115,7 @@ // Start a task for the first operation name. MarkOperationDoneTask task(dispatcher(), store(), kOperationName); - - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); ExpectStoreChangeCount(&task, ids.size()); // The items should be in the new state. @@ -159,10 +144,7 @@ // Start a task for the operation name. MarkOperationDoneTask task(dispatcher(), store(), kOperationName); - - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); ExpectStoreChangeCount(&task, 0); // No item should have been changed.
diff --git a/components/offline_pages/core/prefetch/metrics_finalization_task_unittest.cc b/components/offline_pages/core/prefetch/metrics_finalization_task_unittest.cc index bba2a6d..f62e433a 100644 --- a/components/offline_pages/core/prefetch/metrics_finalization_task_unittest.cc +++ b/components/offline_pages/core/prefetch/metrics_finalization_task_unittest.cc
@@ -44,9 +44,7 @@ store_util()->SimulateInitializationError(); // Execute the metrics task. - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); } // Tests that the task works correctly with an empty database. @@ -54,9 +52,7 @@ EXPECT_EQ(0, store_util()->CountPrefetchItems()); // Execute the metrics task. - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); EXPECT_EQ(0, store_util()->CountPrefetchItems()); } @@ -74,9 +70,7 @@ EXPECT_EQ(10U, store_util()->GetAllItems(&all_inserted_items)); // Execute the task. - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); std::set<PrefetchItem> all_items_after_task; EXPECT_EQ(10U, store_util()->GetAllItems(&all_items_after_task)); @@ -98,9 +92,7 @@ ASSERT_TRUE(store_util()->InsertPrefetchItem(unfinished_item)); // Execute the metrics task. - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); std::set<PrefetchItem> all_items; // The finished ones should be zombies and the new request should be @@ -134,9 +126,7 @@ // Execute the metrics task. base::HistogramTester histogram_tester; - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); std::set<PrefetchItem> all_items; EXPECT_EQ(3U, store_util()->GetAllItems(&all_items)); @@ -219,9 +209,7 @@ // Execute the metrics task. base::HistogramTester histogram_tester; - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); std::set<PrefetchItem> all_items; EXPECT_EQ(5U, store_util()->GetAllItems(&all_items)); @@ -261,9 +249,7 @@ // Execute the task. base::HistogramTester histogram_tester; - ExpectTaskCompletes(metrics_finalization_task_.get()); - metrics_finalization_task_->Run(); - RunUntilIdle(); + RunTask(metrics_finalization_task_.get()); histogram_tester.ExpectTotalCount("OfflinePages.Prefetching.StateCounts", 66);
diff --git a/components/offline_pages/core/prefetch/page_bundle_update_task_unittest.cc b/components/offline_pages/core/prefetch/page_bundle_update_task_unittest.cc index f250763..2c7a8da 100644 --- a/components/offline_pages/core/prefetch/page_bundle_update_task_unittest.cc +++ b/components/offline_pages/core/prefetch/page_bundle_update_task_unittest.cc
@@ -63,18 +63,12 @@ TEST_F(PageBundleUpdateTaskTest, StoreFailure) { store_util()->SimulateInitializationError(); PageBundleUpdateTask task(store(), &dispatcher, "operation", {}); - ExpectTaskCompletes(&task); - - task.Run(); - RunUntilIdle(); + RunTask(&task); } TEST_F(PageBundleUpdateTaskTest, EmptyTask) { PageBundleUpdateTask task(store(), &dispatcher, "operation", {}); - ExpectTaskCompletes(&task); - - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(0, dispatcher.processing_schedule_count); } @@ -99,9 +93,7 @@ RenderedPageInfoForPrefetchItem(item1), RenderedPageInfoForPrefetchItem(item2), }); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); // The matching entry has been updated. EXPECT_EQ(PrefetchItemState::RECEIVED_BUNDLE, @@ -128,9 +120,7 @@ { RenderedPageInfoForPrefetchItem(item1), }); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); // The matching entry has been updated. EXPECT_EQ(store_util()->GetPrefetchItem(item1.offline_id)->state, @@ -159,9 +149,7 @@ { RenderedPageInfoForPrefetchItem(item2), }); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(item, *(store_util()->GetPrefetchItem(item.offline_id))); EXPECT_EQ(0, dispatcher.processing_schedule_count); } @@ -178,9 +166,7 @@ { PendingPageInfoForPrefetchItem(item), }); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(PrefetchItemState::AWAITING_GCM, store_util()->GetPrefetchItem(item.offline_id)->state); @@ -206,9 +192,7 @@ item2_render_info.status = RenderStatus::EXCEEDED_LIMIT; PageBundleUpdateTask task(store(), &dispatcher, "operation", {item2_render_info, item1_render_info}); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(PrefetchItemState::FINISHED, store_util()->GetPrefetchItem(item1.offline_id)->state); @@ -243,9 +227,7 @@ PageBundleUpdateTask task( store(), &dispatcher, "operation", {item3_render_info, item2_render_info, item1_render_info}); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(PrefetchItemState::AWAITING_GCM, store_util()->GetPrefetchItem(item1.offline_id)->state);
diff --git a/components/offline_pages/core/prefetch/prefetch_task_test_base.h b/components/offline_pages/core/prefetch/prefetch_task_test_base.h index 9eab2b3f..860187d 100644 --- a/components/offline_pages/core/prefetch/prefetch_task_test_base.h +++ b/components/offline_pages/core/prefetch/prefetch_task_test_base.h
@@ -7,9 +7,7 @@ #include <memory> #include <set> -#include <vector> -#include "base/memory/ref_counted.h" #include "components/offline_pages/core/prefetch/mock_prefetch_item_generator.h" #include "components/offline_pages/core/prefetch/prefetch_types.h" #include "components/offline_pages/core/prefetch/store/prefetch_store_test_util.h" @@ -20,7 +18,6 @@ namespace offline_pages { struct PrefetchItem; class PrefetchStore; -class Task; // Base class for testing prefetch requests with simulated responses. class PrefetchTaskTestBase : public TaskTestBase { @@ -74,9 +71,6 @@ TestPrefetchNetworkRequestFactory prefetch_request_factory_; PrefetchStoreTestUtil store_test_util_; MockPrefetchItemGenerator item_generator_; - - std::vector<std::unique_ptr<base::MockCallback<Task::TaskCompletionCallback>>> - completion_callbacks_; }; } // namespace offline_pages
diff --git a/components/offline_pages/core/prefetch/sent_get_operation_cleanup_task_unittest.cc b/components/offline_pages/core/prefetch/sent_get_operation_cleanup_task_unittest.cc index eb53989..e886d64 100644 --- a/components/offline_pages/core/prefetch/sent_get_operation_cleanup_task_unittest.cc +++ b/components/offline_pages/core/prefetch/sent_get_operation_cleanup_task_unittest.cc
@@ -69,9 +69,7 @@ store_util()->SimulateInitializationError(); SentGetOperationCleanupTask task(store(), prefetch_request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); } TEST_F(SentGetOperationCleanupTaskTest, Retry) { @@ -82,9 +80,7 @@ ASSERT_TRUE(store_util()->InsertPrefetchItem(item)); SentGetOperationCleanupTask task(store(), prefetch_request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -105,9 +101,7 @@ request_factory->AddOngoingOperation(item.operation_name); SentGetOperationCleanupTask task(store(), request_factory.get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -123,9 +117,7 @@ ASSERT_TRUE(store_util()->InsertPrefetchItem(item)); SentGetOperationCleanupTask task(store(), prefetch_request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -148,9 +140,7 @@ request_factory->AddOngoingOperation(item.operation_name); SentGetOperationCleanupTask task(store(), request_factory.get()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); std::unique_ptr<PrefetchItem> store_item = store_util()->GetPrefetchItem(item.offline_id); @@ -171,9 +161,7 @@ } SentGetOperationCleanupTask task(store(), prefetch_request_factory()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); std::set<PrefetchItem> store_items; store_util()->GetAllItems(&store_items);
diff --git a/components/offline_pages/core/prefetch/stale_entry_finalizer_task_unittest.cc b/components/offline_pages/core/prefetch/stale_entry_finalizer_task_unittest.cc index 39392c3f..0986425 100644 --- a/components/offline_pages/core/prefetch/stale_entry_finalizer_task_unittest.cc +++ b/components/offline_pages/core/prefetch/stale_entry_finalizer_task_unittest.cc
@@ -83,9 +83,7 @@ store_util()->SimulateInitializationError(); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); } // Tests that the task works correctly with an empty database. @@ -94,9 +92,7 @@ EXPECT_EQ(0U, store_util()->GetAllItems(&no_items)); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::NO_MORE_WORK, stale_finalizer_task_->final_status()); EXPECT_EQ(0U, store_util()->GetAllItems(&no_items)); } @@ -142,9 +138,7 @@ EXPECT_EQ(initial_items, all_inserted_items); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::MORE_WORK_NEEDED, stale_finalizer_task_->final_status()); // Create the expected finished version of each stale item. @@ -191,9 +185,7 @@ EXPECT_EQ(11, store_util()->CountPrefetchItems()); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::MORE_WORK_NEEDED, stale_finalizer_task_->final_status()); // Checks item counts for states expected to still exist. @@ -215,9 +207,7 @@ CreateAndInsertItem(PrefetchItemState::AWAITING_GCM, 0); CreateAndInsertItem(PrefetchItemState::ZOMBIE, 0); - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::NO_MORE_WORK, stale_finalizer_task_->final_status()); EXPECT_EQ(0, dispatcher()->task_schedule_count); } @@ -238,9 +228,7 @@ << "Failed inserting item with state " << static_cast<int>(state); StaleEntryFinalizerTask task(dispatcher(), store()); - ExpectTaskCompletes(&task); - task.Run(); - RunUntilIdle(); + RunTask(&task); EXPECT_EQ(Result::MORE_WORK_NEEDED, task.final_status()); EXPECT_EQ(1, dispatcher()->task_schedule_count); } @@ -291,9 +279,7 @@ EXPECT_EQ(initial_items, all_inserted_items); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::MORE_WORK_NEEDED, stale_finalizer_task_->final_status()); // Create the expected finished version of each stale item. @@ -349,9 +335,7 @@ EXPECT_EQ(11, store_util()->CountPrefetchItems()); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::MORE_WORK_NEEDED, stale_finalizer_task_->final_status()); // Checks item counts for states expected to still exist. @@ -384,9 +368,7 @@ EXPECT_EQ(initial_items, all_inserted_items); // Execute the expiration task. - ExpectTaskCompletes(stale_finalizer_task_.get()); - stale_finalizer_task_->Run(); - RunUntilIdle(); + RunTask(stale_finalizer_task_.get()); EXPECT_EQ(Result::MORE_WORK_NEEDED, stale_finalizer_task_->final_status()); // Check that the proper UMA was reported for the stale item, but not the
diff --git a/components/offline_pages/core/task_test_base.cc b/components/offline_pages/core/task_test_base.cc index ec3623c..f6c0a3c 100644 --- a/components/offline_pages/core/task_test_base.cc +++ b/components/offline_pages/core/task_test_base.cc
@@ -14,7 +14,8 @@ TaskTestBase::TaskTestBase() : task_runner_(new base::TestMockTimeTaskRunner), - task_runner_handle_(task_runner_) {} + task_runner_handle_(task_runner_), + test_task_runner_(task_runner_) {} TaskTestBase::~TaskTestBase() = default; @@ -31,13 +32,12 @@ task_runner_->RunUntilIdle(); } -void TaskTestBase::ExpectTaskCompletes(Task* task) { - completion_callbacks_.push_back( - std::make_unique<base::MockCallback<Task::TaskCompletionCallback>>()); - EXPECT_CALL(*completion_callbacks_.back(), Run(_)); +void TaskTestBase::RunTask(std::unique_ptr<Task> task) { + test_task_runner_.RunTask(std::move(task)); +} - task->SetTaskCompletionCallbackForTesting( - task_runner_.get(), completion_callbacks_.back()->Get()); +void TaskTestBase::RunTask(Task* task) { + test_task_runner_.RunTask(task); } } // namespace offline_pages
diff --git a/components/offline_pages/core/task_test_base.h b/components/offline_pages/core/task_test_base.h index da47a07f..d672473 100644 --- a/components/offline_pages/core/task_test_base.h +++ b/components/offline_pages/core/task_test_base.h
@@ -5,15 +5,12 @@ #ifndef COMPONENTS_OFFLINE_PAGES_CORE_TASK_TEST_BASE_H_ #define COMPONENTS_OFFLINE_PAGES_CORE_TASK_TEST_BASE_H_ -#include <memory> -#include <set> -#include <vector> +#include "testing/gtest/include/gtest/gtest.h" -#include "base/memory/ref_counted.h" -#include "base/test/mock_callback.h" #include "base/test/test_mock_time_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "components/offline_pages/core/task.h" +#include "components/offline_pages/core/test_task_runner.h" namespace offline_pages { @@ -26,8 +23,13 @@ void SetUp() override; void TearDown() override; + // Runs task with expectation that it correctly completes. + // Task is also cleaned up after completing. + void RunTask(std::unique_ptr<Task> task); + // Runs task with expectation that it correctly completes. + // Task is not cleaned up after completing. + void RunTask(Task* task); void RunUntilIdle(); - void ExpectTaskCompletes(Task* task); scoped_refptr<base::TestMockTimeTaskRunner> task_runner() { return task_runner_; @@ -36,9 +38,7 @@ private: scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; base::ThreadTaskRunnerHandle task_runner_handle_; - - std::vector<std::unique_ptr<base::MockCallback<Task::TaskCompletionCallback>>> - completion_callbacks_; + TestTaskRunner test_task_runner_; }; } // namespace offline_pages
diff --git a/components/offline_pages/core/test_task_runner.cc b/components/offline_pages/core/test_task_runner.cc index fda2263..f0d50dd 100644 --- a/components/offline_pages/core/test_task_runner.cc +++ b/components/offline_pages/core/test_task_runner.cc
@@ -17,7 +17,11 @@ TestTaskRunner::~TestTaskRunner() {} void TestTaskRunner::RunTask(std::unique_ptr<Task> task) { - DCHECK(task.get()); + RunTask(task.get()); +} + +void TestTaskRunner::RunTask(Task* task) { + DCHECK(task); Task* completed_task = nullptr; task->SetTaskCompletionCallbackForTesting( task_runner_.get(), @@ -26,7 +30,7 @@ &completed_task)); task->Run(); task_runner_->RunUntilIdle(); - EXPECT_EQ(task.get(), completed_task); + EXPECT_EQ(task, completed_task); } } // namespace offline_pages
diff --git a/components/offline_pages/core/test_task_runner.h b/components/offline_pages/core/test_task_runner.h index a117844..c4475a96 100644 --- a/components/offline_pages/core/test_task_runner.h +++ b/components/offline_pages/core/test_task_runner.h
@@ -23,6 +23,9 @@ // Runs task with expectation that it correctly completes. // Task is also cleaned up after completing. void RunTask(std::unique_ptr<Task> task); + // Runs task with expectation that it correctly completes. + // Task is not cleaned up after completing. + void RunTask(Task* task); private: // Certainly confusing, but internal task runner, is simply a test version of
diff --git a/components/omnibox/browser/autocomplete_provider_client.h b/components/omnibox/browser/autocomplete_provider_client.h index 131b488..638a8e2 100644 --- a/components/omnibox/browser/autocomplete_provider_client.h +++ b/components/omnibox/browser/autocomplete_provider_client.h
@@ -142,9 +142,11 @@ // configure the provider if desired. virtual void ConfigureKeywordProvider(KeywordProvider* keyword_provider) {} - // Called to find out if there is an open tab with the given URL within - // the current profile. - virtual bool IsTabOpenWithURL(const GURL& url) = 0; + // Called to find out if there is an open tab with the given URL within the + // current profile. |input| can be null; match is more precise (e.g. scheme + // presence) if provided. + virtual bool IsTabOpenWithURL(const GURL& url, + const AutocompleteInput* input) = 0; }; #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_PROVIDER_CLIENT_H_
diff --git a/components/omnibox/browser/fake_autocomplete_provider_client.cc b/components/omnibox/browser/fake_autocomplete_provider_client.cc index 6d14963..1158745 100644 --- a/components/omnibox/browser/fake_autocomplete_provider_client.cc +++ b/components/omnibox/browser/fake_autocomplete_provider_client.cc
@@ -81,6 +81,8 @@ return shortcuts_backend_; } -bool FakeAutocompleteProviderClient::IsTabOpenWithURL(const GURL& url) { +bool FakeAutocompleteProviderClient::IsTabOpenWithURL( + const GURL& url, + const AutocompleteInput* input) { return is_tab_open_with_url_; }
diff --git a/components/omnibox/browser/fake_autocomplete_provider_client.h b/components/omnibox/browser/fake_autocomplete_provider_client.h index b0f30be..e6b6fb4 100644 --- a/components/omnibox/browser/fake_autocomplete_provider_client.h +++ b/components/omnibox/browser/fake_autocomplete_provider_client.h
@@ -49,7 +49,8 @@ in_memory_url_index_ = std::move(index); } - bool IsTabOpenWithURL(const GURL& url) override; + bool IsTabOpenWithURL(const GURL& url, + const AutocompleteInput* input) override; void set_is_tab_open_with_url(bool is_open) { is_tab_open_with_url_ = is_open; }
diff --git a/components/omnibox/browser/history_provider.cc b/components/omnibox/browser/history_provider.cc index 13280bc..63d0abc 100644 --- a/components/omnibox/browser/history_provider.cc +++ b/components/omnibox/browser/history_provider.cc
@@ -106,10 +106,10 @@ return spans; } -void HistoryProvider::ConvertOpenTabMatches() { +void HistoryProvider::ConvertOpenTabMatches(const AutocompleteInput* input) { for (auto& match : matches_) { // If url is in a tab, change type, update classification. - if (client()->IsTabOpenWithURL(match.destination_url)) { + if (client()->IsTabOpenWithURL(match.destination_url, input)) { match.type = AutocompleteMatchType::TAB_SEARCH; if (OmniboxFieldTrial::InTabSwitchSuggestionWithButtonTrial()) continue;
diff --git a/components/omnibox/browser/history_provider.h b/components/omnibox/browser/history_provider.h index 2527ac1..fbd6762 100644 --- a/components/omnibox/browser/history_provider.h +++ b/components/omnibox/browser/history_provider.h
@@ -46,8 +46,9 @@ AutocompleteProviderClient* client() { return client_; } // Converts matches whose URL matches a tab's URL to TAB_SEARCH matches. - // Fixes up description as well. - void ConvertOpenTabMatches(); + // Fixes up description as well. |input| can be null; if provided, + // the match can be more precise (e.g. scheme presence). + void ConvertOpenTabMatches(const AutocompleteInput* input); private: FRIEND_TEST_ALL_PREFIXES(HistoryProviderTest, ConvertsOpenTabsCorrectly);
diff --git a/components/omnibox/browser/history_provider_unittest.cc b/components/omnibox/browser/history_provider_unittest.cc index bfed8fcc..35e3ac3 100644 --- a/components/omnibox/browser/history_provider_unittest.cc +++ b/components/omnibox/browser/history_provider_unittest.cc
@@ -73,7 +73,7 @@ // Have IsTabOpenWithURL() return true. client()->set_is_tab_open_with_url(true); - provider()->ConvertOpenTabMatches(); + provider()->ConvertOpenTabMatches(nullptr); EXPECT_EQ(base::UTF8ToUTF16("Switch to tab"), provider()->matches_[0].description);
diff --git a/components/omnibox/browser/history_quick_provider.cc b/components/omnibox/browser/history_quick_provider.cc index d61e821..b7db1a7 100644 --- a/components/omnibox/browser/history_quick_provider.cc +++ b/components/omnibox/browser/history_quick_provider.cc
@@ -98,7 +98,7 @@ max_match_score--; } if (OmniboxFieldTrial::InTabSwitchSuggestionTrial()) - ConvertOpenTabMatches(); + ConvertOpenTabMatches(&autocomplete_input_); } int HistoryQuickProvider::FindMaxMatchScore(
diff --git a/components/omnibox/browser/history_url_provider.cc b/components/omnibox/browser/history_url_provider.cc index 9670d85..0de2cd6 100644 --- a/components/omnibox/browser/history_url_provider.cc +++ b/components/omnibox/browser/history_url_provider.cc
@@ -940,7 +940,7 @@ matches_.push_back(HistoryMatchToACMatch(*params, i, relevance)); } if (OmniboxFieldTrial::InTabSwitchSuggestionTrial()) - ConvertOpenTabMatches(); + ConvertOpenTabMatches(¶ms->input); } done_ = true;
diff --git a/components/omnibox/browser/mock_autocomplete_provider_client.h b/components/omnibox/browser/mock_autocomplete_provider_client.h index 372f498..3340a004 100644 --- a/components/omnibox/browser/mock_autocomplete_provider_client.h +++ b/components/omnibox/browser/mock_autocomplete_provider_client.h
@@ -90,7 +90,10 @@ void(history::KeywordID keyword_id, const base::string16& term)); MOCK_METHOD1(PrefetchImage, void(const GURL& url)); - bool IsTabOpenWithURL(const GURL& url) override { return false; } + bool IsTabOpenWithURL(const GURL& url, + const AutocompleteInput* input) override { + return false; + } void set_template_url_service(std::unique_ptr<TemplateURLService> service) { template_url_service_ = std::move(service);
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 4201c7b..892f7be2 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -11241,7 +11241,7 @@ 'caption': '''Password protection warning is triggered by password reuse on phishing page''', }, ], - 'supported_on': ['chrome.*:66-', 'chrome_os:66-'], + 'supported_on': ['chrome.*:67-', 'chrome_os:67-'], 'features': { 'dynamic_refresh': True, 'per_profile': True, @@ -11281,7 +11281,7 @@ 'caption': '''Password protection at-risk account flagging is triggered by password reuse on phishing page''', }, ], - 'supported_on': ['chrome.*:66-', 'chrome_os:66-'], + 'supported_on': ['chrome.*:67-', 'chrome_os:67-'], 'features': { 'dynamic_refresh': True, 'per_profile': True, @@ -11376,7 +11376,7 @@ 'type': 'array', 'items': { 'type': 'string' }, }, - 'supported_on': ['chrome.*:66-', 'chrome_os:66-'], + 'supported_on': ['chrome.*:67-', 'chrome_os:67-'], 'features': { 'dynamic_refresh': True, 'per_profile': True, @@ -11401,7 +11401,7 @@ 'type': 'array', 'items': { 'type': 'string' }, }, - 'supported_on': ['chrome.*:66-', 'chrome_os:66-'], + 'supported_on': ['chrome.*:67-', 'chrome_os:67-'], 'features': { 'dynamic_refresh': True, 'per_profile': True, @@ -11411,7 +11411,8 @@ 'caption': '''Configure the list of enterprise login URLs where password protection service should capture fingerprint of password.''', 'tags': [], 'desc': '''Configure the list of enterprise login URLs (HTTP and HTTPS schemes only). Fingerprint of password will be captured on these URLs and used for password reuse detection. - This setting should only be used by GSuite users using a SSO/SMAL system. + This setting should only be used by GSuite users using a SSO/SAML system. + In order for <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to correctly capture password fingerprints, please make sure your login pages follow the guidelines on https://www.chromium.org/developers/design-documents/create-amazing-password-forms. If this setting is enabled, then password protection service will capture fingerprint of password on these URLs for password reuse detection purpose. If this setting is disabled or not set, then password protection service will only capture password fingerprint on https://accounts.google.com. @@ -11421,7 +11422,7 @@ 'name': 'PasswordProtectionChangePasswordURL', 'type': 'string', 'schema': { 'type': 'string' }, - 'supported_on': ['chrome.*:66-', 'chrome_os:66-'], + 'supported_on': ['chrome.*:67-', 'chrome_os:67-'], 'features': { 'dynamic_refresh': True, 'per_profile': True, @@ -11431,7 +11432,8 @@ 'caption': '''Configure the change password URL.''', 'tags': [], 'desc': '''Configure the change password URL (HTTP and HTTPS schemes only). Password protection service will send users to this URL to change their passwords if they've been phished. - This setting should only be used by GSuite users using a SSO/SMAL system. + This setting should only be used by GSuite users using a SSO/SAML system. + In order for <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to correctly capture the new password fingerprint on this change password page, please make sure your change password page follows the guidelines on https://www.chromium.org/developers/design-documents/create-amazing-password-forms. If this setting is enabled, then password protection service will send users to this URL to change their passwords if they've been phished. If this setting is disabled or not set, then password protection service will send users to https://myaccounts.google.com to change their password.
diff --git a/components/vector_icons/aggregate_vector_icons.py b/components/vector_icons/aggregate_vector_icons.py index c48a349..f096a9e 100644 --- a/components/vector_icons/aggregate_vector_icons.py +++ b/components/vector_icons/aggregate_vector_icons.py
@@ -21,6 +21,18 @@ return 'k' + ''.join(words) + suffix +def GetPathName(name, append_1x = False): + return CamelCase(name, "Path1x" if append_1x else "Path"); + + +def GetRepName(name, append_1x = False): + return CamelCase(name, "Rep1x" if append_1x else "Rep"); + + +def GetIconName(name): + return CamelCase(name, "Icon"); + + def AggregateVectorIcons(working_directory, file_list, output_cc, output_h): """Compiles all .icon files in a directory into two C++ files. @@ -82,8 +94,8 @@ (icon_name, extension) = os.path.splitext( os.path.basename(path_map[icon])) (icon_name, scale_factor) = os.path.splitext(icon_name) - output_header.write( - "VECTOR_ICON_TEMPLATE_H({})\n".format(CamelCase(icon_name, "Icon"))) + output_header.write("VECTOR_ICON_TEMPLATE_H({})\n".format( + GetIconName(icon_name))) output_header.close() # Copy the vector icon drawing commands from the .icon and .1x.icon files @@ -110,8 +122,8 @@ icon_file = open(path_map[icon]) vector_commands = "".join(icon_file.readlines()) icon_file.close() - output_cc.write("PATH_ELEMENT_TEMPLATE({}, {})\n".format( - CamelCase(icon_name, "Path"), vector_commands)) + output_cc.write("VECTOR_ICON_REP_TEMPLATE({}, {}, {})\n".format( + GetPathName(icon_name), GetRepName(icon_name), vector_commands)) # Store the vector-drawing commands for foo_bar.1x.icon in the temporary # variable kFooBarPath1x, if the file exists. @@ -120,17 +132,18 @@ icon_file = open(path_map_1x[icon]) vector_commands_1x = "".join(icon_file.readlines()) icon_file.close() - output_cc.write("PATH_ELEMENT_TEMPLATE({}, {})\n".format( - CamelCase(icon_name, "Path1x"), vector_commands_1x)) + output_cc.write("VECTOR_ICON_REP_TEMPLATE({}, {}, {})\n".format( + GetPathName(icon_name, True), GetRepName(icon_name, True), + vector_commands_1x)) # Define the value of kFooBarIcon. if vector_commands_1x is None: - output_cc.write("VECTOR_ICON_TEMPLATE({}, {})\n".format(CamelCase( - icon_name, "Icon"), CamelCase(icon_name, "Path"))) + output_cc.write("VECTOR_ICON_TEMPLATE({}, {})\n".format( + GetIconName(icon_name), GetRepName(icon_name))) else: - output_cc.write("VECTOR_ICON_TEMPLATE2({}, {}, {})\n".format(CamelCase( - icon_name, "Icon"), CamelCase(icon_name, "Path"), CamelCase( - icon_name, "Path1x"))) + output_cc.write("VECTOR_ICON_TEMPLATE2({}, {}, {})\n".format( + GetIconName(icon_name), GetRepName(icon_name), + GetRepName(icon_name, True))) output_cc.close()
diff --git a/components/vector_icons/cc_macros.h b/components/vector_icons/cc_macros.h index 6ba0c245..eba40a59 100644 --- a/components/vector_icons/cc_macros.h +++ b/components/vector_icons/cc_macros.h
@@ -15,21 +15,19 @@ #define VECTOR_ICON_ID_PREFIX "" #endif -#define PATH_ELEMENT_TEMPLATE(path_name, ...) \ - static constexpr gfx::PathElement path_name[] = {__VA_ARGS__}; +#define VECTOR_ICON_REP_TEMPLATE(path_name, rep_name, ...) \ + static constexpr gfx::PathElement path_name[] = {__VA_ARGS__}; \ + constexpr gfx::VectorIconRep rep_name = {path_name, arraysize(path_name)}; // The VectorIcon will be called kMyIcon, and the identifier for the icon might // be "my_namespace::kMyIconId". -#define VECTOR_ICON_TEMPLATE(icon_name, path_name) \ - const char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name; \ - const gfx::VectorIcon icon_name = {path_name, arraysize(path_name), nullptr, \ - 0u, icon_name##Id}; +#define VECTOR_ICON_TEMPLATE(icon_name, rep_name) \ + const char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name; \ + const gfx::VectorIcon icon_name = {&rep_name, nullptr, icon_name##Id}; -#define VECTOR_ICON_TEMPLATE2(icon_name, path_name, path_name_1x) \ - const char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name; \ - const gfx::VectorIcon icon_name = {path_name, arraysize(path_name), \ - path_name_1x, arraysize(path_name_1x), \ - icon_name##Id}; +#define VECTOR_ICON_TEMPLATE2(icon_name, rep_name, rep_name_1x) \ + const char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name; \ + const gfx::VectorIcon icon_name = {&rep_name, &rep_name_1x, icon_name##Id}; #else // !COMPONENTS_VECTOR_ICONS_CC_MACROS_H_ #error This file should only be included once.
diff --git a/content/browser/frame_host/frame_tree_node.cc b/content/browser/frame_host/frame_tree_node.cc index f33998c..578fd45e 100644 --- a/content/browser/frame_host/frame_tree_node.cc +++ b/content/browser/frame_host/frame_tree_node.cc
@@ -313,7 +313,7 @@ } void FrameTreeNode::SetCurrentURL(const GURL& url) { - if (!has_committed_real_load_ && url != url::kAboutBlankURL) + if (!has_committed_real_load_ && !url.IsAboutBlank()) has_committed_real_load_ = true; current_frame_host()->SetLastCommittedUrl(url); blame_context_.TakeSnapshot();
diff --git a/content/browser/frame_host/render_frame_host_impl_browsertest.cc b/content/browser/frame_host/render_frame_host_impl_browsertest.cc index e304fb6f..cc4c5b6 100644 --- a/content/browser/frame_host/render_frame_host_impl_browsertest.cc +++ b/content/browser/frame_host/render_frame_host_impl_browsertest.cc
@@ -25,6 +25,7 @@ #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" +#include "content/public/test/test_frame_navigation_observer.h" #include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_utils.h" #include "content/shell/browser/shell.h" @@ -1229,4 +1230,73 @@ } } +// Regression test for https://crbug.com/821022. +// +// Test the edge case of the above, namely, where the following commits take +// place in a subframe embedded into a document at `http://foo.com/`: +// +// 1) the initial empty document (`about:blank`) +// 2) `about:blank#ref` +// 3) `http://foo.com` +// +// Here, (2) should classify as a same-document navigation, and (3) should be +// considered the first real load. Because the first real load is same-origin +// with the initial empty document, the latter's `window` global object +// asssociated with the initial empty document is re-used for document +// corresponding to the first real committed load. +IN_PROC_BROWSER_TEST_F( + RenderFrameHostImplBrowserTest, + InterfaceProviderRequestNotPresentForFirstRealLoadAfterAboutBlankWithRef) { + const GURL kMainFrameURL(embedded_test_server()->GetURL("/title1.html")); + const GURL kSubframeURLTwo("about:blank#ref"); + const GURL kSubframeURLThree(embedded_test_server()->GetURL("/title2.html")); + const auto kNavigateToOneThenTwoScript = base::StringPrintf( + "var f = document.createElement(\"iframe\");" + "f.src=\"%s\"; " + "document.body.append(f);", + kSubframeURLTwo.spec().c_str()); + const auto kNavigateToThreeScript = + base::StringPrintf("f.src=\"%s\";", kSubframeURLThree.spec().c_str()); + + ASSERT_TRUE(NavigateToURL(shell(), kMainFrameURL)); + + // Trigger navigation (1) by creating a new subframe, and then trigger + // navigation (2) by setting it's `src` attribute before adding it to the DOM. + // + // We must set 'src` before adding the iframe element to the DOM, otherwise it + // will load `about:blank` as the first real load instead of + // |kSubframeURLTwo|. See: https://crbug.com/778318. + // + // Note that the child frame will first cycle through loading the initial + // empty document regardless of when/how/if the `src` attribute is set. + + ASSERT_TRUE(ExecuteScript(shell(), kNavigateToOneThenTwoScript)); + WaitForLoadStop(shell()->web_contents()); + + FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) + ->GetFrameTree() + ->root(); + ASSERT_EQ(1u, root->child_count()); + FrameTreeNode* child = root->child_at(0u); + + EXPECT_FALSE(child->has_committed_real_load()); + EXPECT_EQ(kSubframeURLTwo, child->current_url()); + EXPECT_EQ(url::Origin::Create(kMainFrameURL), child->current_origin()); + + // Set the `src` attribute again to trigger navigation (3). + + TestFrameNavigationObserver commit_observer(child->current_frame_host()); + ScopedFakeInterfaceProviderRequestInjector injector(shell()->web_contents()); + injector.set_fake_request_for_next_commit(nullptr); + + ASSERT_TRUE(ExecuteScript(shell(), kNavigateToThreeScript)); + commit_observer.WaitForCommit(); + + EXPECT_FALSE(injector.original_request_of_last_commit().is_pending()); + + EXPECT_TRUE(child->has_committed_real_load()); + EXPECT_EQ(kSubframeURLThree, child->current_url()); + EXPECT_EQ(url::Origin::Create(kMainFrameURL), child->current_origin()); +} + } // namespace content
diff --git a/content/browser/loader/cross_site_document_resource_handler.cc b/content/browser/loader/cross_site_document_resource_handler.cc index ddeb86c0..4dd63340 100644 --- a/content/browser/loader/cross_site_document_resource_handler.cc +++ b/content/browser/loader/cross_site_document_resource_handler.cc
@@ -242,6 +242,10 @@ MimeType canonical_mime_type, int http_response_code, int64_t content_length) { + DCHECK(resource_request_info); + DCHECK_NE(network::CrossOriginReadBlocking::MimeType::kInvalid, + canonical_mime_type); + LogCrossSiteDocumentAction( needed_sniffing ? CrossSiteDocumentResourceHandler::Action::kBlockedAfterSniffing @@ -751,22 +755,6 @@ return false; } - // CORB should look directly at the Content-Type header if one has been - // received from the network. Ignoring |response->head.mime_type| helps avoid - // breaking legitimate websites (which might happen more often when blocking - // would be based on the mime type sniffed by MimeSniffingResourceHandler). - // - // TODO(nick): What if the mime type is omitted? Should that be treated the - // same as text/plain? https://crbug.com/795971 - std::string mime_type; - if (response->head.headers) - response->head.headers->GetMimeType(&mime_type); - // Canonicalize the MIME type. Note that even if it doesn't claim to be a - // blockable type (i.e., HTML, XML, JSON, or plain text), it may still fail - // the checks during the SniffForFetchOnlyResource() phase. - canonical_mime_type_ = - network::CrossOriginReadBlocking::GetCanonicalMimeType(mime_type); - // Treat a missing initiator as an empty origin to be safe, though we don't // expect this to happen. Unfortunately, this requires a copy. url::Origin initiator; @@ -858,6 +846,22 @@ response->head.headers->GetNormalizedHeader("content-range", &range_header); bool has_range_header = !range_header.empty(); + // CORB should look directly at the Content-Type header if one has been + // received from the network. Ignoring |response->head.mime_type| helps avoid + // breaking legitimate websites (which might happen more often when blocking + // would be based on the mime type sniffed by MimeSniffingResourceHandler). + // + // TODO(nick): What if the mime type is omitted? Should that be treated the + // same as text/plain? https://crbug.com/795971 + std::string mime_type; + if (response->head.headers) + response->head.headers->GetMimeType(&mime_type); + // Canonicalize the MIME type. Note that even if it doesn't claim to be a + // blockable type (i.e., HTML, XML, JSON, or plain text), it may still fail + // the checks during the SniffForFetchOnlyResource() phase. + canonical_mime_type_ = + network::CrossOriginReadBlocking::GetCanonicalMimeType(mime_type); + // If this is a partial response, sniffing is not possible, so allow the // response if it's not a protected mime type. if (has_range_header && canonical_mime_type_ == MimeType::kOthers) {
diff --git a/content/browser/loader/cross_site_document_resource_handler.h b/content/browser/loader/cross_site_document_resource_handler.h index c890923c..ba0c4d44 100644 --- a/content/browser/loader/cross_site_document_resource_handler.h +++ b/content/browser/loader/cross_site_document_resource_handler.h
@@ -172,7 +172,7 @@ // A canonicalization of the specified MIME type, to determine if blocking the // response is needed, as well as which type of sniffing to perform. network::CrossOriginReadBlocking::MimeType canonical_mime_type_ = - network::CrossOriginReadBlocking::MimeType::kOthers; + network::CrossOriginReadBlocking::MimeType::kInvalid; // Indicates whether this request was made by a plugin and was not using CORS. // Such requests are exempt from blocking, while other plugin requests must be
diff --git a/content/browser/loader/cross_site_document_resource_handler_unittest.cc b/content/browser/loader/cross_site_document_resource_handler_unittest.cc index 4f72b97..62fd3b6 100644 --- a/content/browser/loader/cross_site_document_resource_handler_unittest.cc +++ b/content/browser/loader/cross_site_document_resource_handler_unittest.cc
@@ -206,7 +206,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -221,7 +221,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {")]}',\n[true, true, false, \"user@chromium.org\"]"}, // packets @@ -236,7 +236,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/json", // response_mime_type - MimeType::kJson, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {")]}'\n[true, true, false, \"user@chromium.org\"]"}, // packets @@ -266,7 +266,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kInclude, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kAllowInitiatorOrigin, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -281,7 +281,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kInclude, // cors_request "application/rss+xml", // response_mime_type - MimeType::kXml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kAllowAny, // cors_response {"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"}, // packets @@ -296,7 +296,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kInclude, // cors_request "text/json", // response_mime_type - MimeType::kJson, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kAllowNull, // cors_response {"{\"x\" : 3}"}, // packets @@ -311,7 +311,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -326,7 +326,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -341,7 +341,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -356,7 +356,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kInclude, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kAllowInitiatorOrigin, // cors_response {"<html><head>this should sniff as HTML"}, // first_chunk @@ -371,7 +371,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kInclude, // cors_request "application/javascript", // response_mime_type - MimeType::kOthers, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type true, // include_no_sniff_header AccessControlAllowOriginHeader::kAllowAny, // cors_response {")]}'\n[true, false]"}, // packets @@ -600,7 +600,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -615,7 +615,7 @@ "http://www.a.com/", // initiator_origin OriginHeader::kOmit, // cors_request "text/html", // response_mime_type - MimeType::kHtml, // canonical_mime_type + MimeType::kInvalid, // canonical_mime_type false, // include_no_sniff_header AccessControlAllowOriginHeader::kOmit, // cors_response {"<html><head>this should sniff as HTML"}, // packets @@ -1423,8 +1423,11 @@ case MimeType::kOthers: bucket = "Others"; break; - default: - NOTREACHED(); + case MimeType::kInvalid: + DCHECK_EQ(Verdict::kAllow, scenario.verdict); + DCHECK_EQ(-1, scenario.verdict_packet); + bucket = "No blocking = no bucket"; + break; } int start_action = static_cast<int>( CrossSiteDocumentResourceHandler::Action::kResponseStarted);
diff --git a/content/browser/media/key_system_support_impl.cc b/content/browser/media/key_system_support_impl.cc index 52aebf43..0092ef7 100644 --- a/content/browser/media/key_system_support_impl.cc +++ b/content/browser/media/key_system_support_impl.cc
@@ -14,30 +14,10 @@ #include "media/base/key_systems.h" #include "mojo/public/cpp/bindings/strong_binding.h" -#if DCHECK_IS_ON() -#include "base/strings/utf_string_conversions.h" -#include "content/public/browser/plugin_service.h" -#include "content/public/common/webplugininfo.h" -#endif // DCHECK_IS_ON() - namespace content { namespace { -#if DCHECK_IS_ON() -// TODO(crbug.com/772160) Remove this when pepper CDM support removed. -bool IsPepperPluginRegistered(const std::string& plugin_name) { - std::vector<WebPluginInfo> plugins; - PluginService::GetInstance()->GetInternalPlugins(&plugins); - for (const auto& plugin : plugins) { - if (plugin.is_pepper_plugin() && - plugin.name == base::ASCIIToUTF16(plugin_name)) - return true; - } - return false; -} -#endif // DCHECK_IS_ON() - void SendCdmAvailableUMA(const std::string& key_system, bool available) { base::UmaHistogramBoolean("Media.EME." + media::GetKeySystemNameForUMA(key_system) + @@ -86,11 +66,6 @@ return; } -#if DCHECK_IS_ON() - DCHECK(IsPepperPluginRegistered(cdm->name)) - << "Pepper plugin for " << key_system << " should also be registered."; -#endif - SendCdmAvailableUMA(key_system, true); std::move(callback).Run(true, cdm->supported_video_codecs, cdm->supports_persistent_license);
diff --git a/content/browser/presentation/presentation_service_impl_unittest.cc b/content/browser/presentation/presentation_service_impl_unittest.cc index f335ea4..58ce913 100644 --- a/content/browser/presentation/presentation_service_impl_unittest.cc +++ b/content/browser/presentation/presentation_service_impl_unittest.cc
@@ -134,6 +134,11 @@ void(int render_process_id, int render_frame_id, const std::string& presentation_id)); + MOCK_METHOD3(GetMediaController, + std::unique_ptr<content::MediaController>( + int render_process_id, + int render_frame_id, + const std::string& presentation_id)); // PresentationConnectionMessage is move-only. // TODO(crbug.com/729950): Use MOCK_METHOD directly once GMock gets the
diff --git a/content/browser/renderer_host/direct_manipulation_browsertest.cc b/content/browser/renderer_host/direct_manipulation_browsertest.cc index 1af0260..7c8a4e7 100644 --- a/content/browser/renderer_host/direct_manipulation_browsertest.cc +++ b/content/browser/renderer_host/direct_manipulation_browsertest.cc
@@ -4,6 +4,8 @@ #include "ui/base/win/direct_manipulation.h" +#include <windows.h> + #include "base/macros.h" #include "base/test/scoped_feature_list.h" #include "base/win/windows_version.h" @@ -16,6 +18,9 @@ #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/base/ui_base_features.h" +#include "ui/base/win/window_event_target.h" +#include "ui/events/event_rewriter.h" +#include "ui/events/event_source.h" #include "url/gurl.h" namespace content { @@ -34,9 +39,20 @@ return rwhva->legacy_render_widget_host_HWND_; } + HWND GetSubWindowHWND() { + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + + return lrwhh->hwnd(); + } + + ui::WindowEventTarget* GetWindowEventTarget() { + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + + return lrwhh->GetWindowEventTarget(lrwhh->GetParent()); + } + void SimulatePointerHitTest() { LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); - ASSERT_TRUE(lrwhh); lrwhh->direct_manipulation_helper_->need_poll_events_ = true; lrwhh->CreateAnimationObserver(); @@ -44,7 +60,6 @@ void UpdateParent(HWND hwnd) { LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); - ASSERT_TRUE(lrwhh); lrwhh->UpdateParent(hwnd); } @@ -90,4 +105,98 @@ EXPECT_FALSE(HasCompositorAnimationObserver(lrwhh)); } +// EventLogger is to obserser the events sent from WindowEventTarget (the root +// window). +class EventLogger : public ui::EventRewriter { + public: + EventLogger() {} + ~EventLogger() override {} + + ui::Event* LastEvent() const { return last_event_.get(); } + + private: + // ui::EventRewriter + ui::EventRewriteStatus RewriteEvent( + const ui::Event& event, + std::unique_ptr<ui::Event>* new_event) override { + last_event_ = ui::Event::Clone(event); + return ui::EVENT_REWRITE_CONTINUE; + } + + // ui::EventRewriter + ui::EventRewriteStatus NextDispatchEvent( + const ui::Event& last_event, + std::unique_ptr<ui::Event>* new_event) override { + return ui::EVENT_REWRITE_CONTINUE; + } + + std::unique_ptr<ui::Event> last_event_ = nullptr; + + DISALLOW_COPY_AND_ASSIGN(EventLogger); +}; + +// Check DirectManipulation events convert to ui::event correctly. +IN_PROC_BROWSER_TEST_F(DirectManipulationBrowserTest, EventConvert) { + if (base::win::GetVersion() < base::win::VERSION_WIN10) + return; + + NavigateToURL(shell(), GURL(url::kAboutBlankURL)); + + LegacyRenderWidgetHostHWND* lrwhh = GetLegacyRenderWidgetHostHWND(); + ASSERT_TRUE(lrwhh); + + HWND hwnd = + shell()->window()->GetRootWindow()->GetHost()->GetAcceleratedWidget(); + + ui::EventSource* dwthw = static_cast<ui::EventSource*>( + aura::WindowTreeHost::GetForAcceleratedWidget(hwnd)); + EventLogger event_logger; + dwthw->AddEventRewriter(&event_logger); + + ui::WindowEventTarget* target = GetWindowEventTarget(); + + { + target->ApplyPanGestureScroll(1, 2); + ui::Event* event = event_logger.LastEvent(); + EXPECT_TRUE(event); + EXPECT_EQ(ui::ET_MOUSEWHEEL, event->type()); + ui::MouseWheelEvent* wheel_event = event->AsMouseWheelEvent(); + EXPECT_EQ(1, wheel_event->x_offset()); + EXPECT_EQ(2, wheel_event->y_offset()); + } + + { + target->ApplyPinchZoomBegin(); + ui::Event* event = event_logger.LastEvent(); + EXPECT_TRUE(event); + EXPECT_EQ(ui::ET_GESTURE_PINCH_BEGIN, event->type()); + ui::GestureEvent* gesture_event = event->AsGestureEvent(); + EXPECT_EQ(ui::GestureDeviceType::DEVICE_TOUCHPAD, + gesture_event->details().device_type()); + } + + { + target->ApplyPinchZoomScale(1.1f); + ui::Event* event = event_logger.LastEvent(); + EXPECT_TRUE(event); + EXPECT_EQ(ui::ET_GESTURE_PINCH_UPDATE, event->type()); + ui::GestureEvent* gesture_event = event->AsGestureEvent(); + EXPECT_EQ(ui::GestureDeviceType::DEVICE_TOUCHPAD, + gesture_event->details().device_type()); + EXPECT_EQ(1.1f, gesture_event->details().scale()); + } + + { + target->ApplyPinchZoomEnd(); + ui::Event* event = event_logger.LastEvent(); + EXPECT_TRUE(event); + EXPECT_EQ(ui::ET_GESTURE_PINCH_END, event->type()); + ui::GestureEvent* gesture_event = event->AsGestureEvent(); + EXPECT_EQ(ui::GestureDeviceType::DEVICE_TOUCHPAD, + gesture_event->details().device_type()); + } + + dwthw->RemoveEventRewriter(&event_logger); +} + } // namespace content
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc index f71e262..42df180 100644 --- a/content/browser/renderer_host/render_message_filter.cc +++ b/content/browser/renderer_host/render_message_filter.cc
@@ -216,9 +216,9 @@ } #endif +#if defined(OS_LINUX) void RenderMessageFilter::SetThreadPriority(int32_t ns_tid, base::ThreadPriority priority) { -#if defined(OS_LINUX) constexpr base::TaskTraits kTraits = { base::MayBlock(), base::TaskPriority::USER_BLOCKING, base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}; @@ -226,10 +226,8 @@ FROM_HERE, kTraits, base::BindOnce(&RenderMessageFilter::SetThreadPriorityOnFileThread, this, static_cast<base::PlatformThreadId>(ns_tid), priority)); -#else - mojo::ReportBadMessage("SetThreadPriority is only supported on OS_LINUX"); -#endif } +#endif void RenderMessageFilter::DidGenerateCacheableMetadata( const GURL& url,
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h index 62db50d..0984b90 100644 --- a/content/browser/renderer_host/render_message_filter.h +++ b/content/browser/renderer_host/render_message_filter.h
@@ -113,8 +113,10 @@ const url::Origin& cache_storage_origin, const std::string& cache_storage_cache_name) override; void HasGpuProcess(HasGpuProcessCallback callback) override; +#if defined(OS_LINUX) void SetThreadPriority(int32_t ns_tid, base::ThreadPriority priority) override; +#endif void OnResolveProxy(const GURL& url, IPC::Message* reply_msg);
diff --git a/content/browser/sandbox_parameters_mac.mm b/content/browser/sandbox_parameters_mac.mm index 36bf6e2da..a87788c 100644 --- a/content/browser/sandbox_parameters_mac.mm +++ b/content/browser/sandbox_parameters_mac.mm
@@ -134,17 +134,6 @@ void SetupUtilitySandboxParameters(sandbox::SeatbeltExecClient* client, const base::CommandLine& command_line) { SetupCommonSandboxParameters(client); - - base::FilePath permitted_dir = - command_line.GetSwitchValuePath(switches::kUtilityProcessAllowedDir); - - if (!permitted_dir.empty()) { - std::string permitted_dir_canonical = - service_manager::SandboxMac::GetCanonicalPath(permitted_dir).value(); - CHECK( - client->SetParameter(service_manager::SandboxMac::kSandboxPermittedDir, - permitted_dir_canonical)); - } } } // namespace content
diff --git a/content/browser/service_worker/service_worker_handle_unittest.cc b/content/browser/service_worker/service_worker_handle_unittest.cc index 884959f..18f49d5 100644 --- a/content/browser/service_worker/service_worker_handle_unittest.cc +++ b/content/browser/service_worker/service_worker_handle_unittest.cc
@@ -23,6 +23,7 @@ #include "content/public/test/mock_resource_context.h" #include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_thread_bundle.h" +#include "content/public/test/test_renderer_host.h" #include "content/public/test/web_contents_tester.h" #include "ipc/ipc_message.h" #include "ipc/ipc_test_sink.h" @@ -325,18 +326,17 @@ EXPECT_EQ(remaining_time, version_->remaining_timeout()); } -// Constantly fails on Android/Linux CFI builder. http://crbug.com/820620 -TEST_F(ServiceWorkerHandleTest, - DISABLED_DispatchExtendableMessageEvent_FromClient) { +TEST_F(ServiceWorkerHandleTest, DispatchExtendableMessageEvent_FromClient) { const int64_t kProviderId = 99; const GURL pattern("https://www.example.com/"); const GURL script_url("https://www.example.com/service_worker.js"); Initialize(std::make_unique<ExtendableMessageEventTestHelper>()); SetUpRegistration(pattern, script_url); - // Prepare a ServiceWorkerProviderHost for a window client. Use a real - // RenderFrameHost because it's needed to populate - // ExtendableMessageEvent#source. + // Prepare a ServiceWorkerProviderHost for a window client. A + // WebContents/RenderFrameHost must be created too because it's needed for + // DispatchExtendableMessageEvent to populate ExtendableMessageEvent#source. + RenderViewHostTestEnabler rvh_test_enabler; std::unique_ptr<WebContents> web_contents( WebContentsTester::CreateTestWebContents(helper_->browser_context(), nullptr)); @@ -383,17 +383,17 @@ events[0]->source_info_for_client->client_type); } -// Constantly fails on Android/Linux CFI builder. http://crbug.com/820620 -TEST_F(ServiceWorkerHandleTest, DISABLED_DispatchExtendableMessageEvent_Fail) { +TEST_F(ServiceWorkerHandleTest, DispatchExtendableMessageEvent_Fail) { const int64_t kProviderId = 99; const GURL pattern("https://www.example.com/"); const GURL script_url("https://www.example.com/service_worker.js"); Initialize(std::make_unique<FailToStartWorkerTestHelper>()); SetUpRegistration(pattern, script_url); - // Prepare a ServiceWorkerProviderHost for a window client. Use a real - // RenderFrameHost because it's needed to populate - // ExtendableMessageEvent#source. + // Prepare a ServiceWorkerProviderHost for a window client. A + // WebContents/RenderFrameHost must be created too because it's needed for + // DispatchExtendableMessageEvent to populate ExtendableMessageEvent#source. + RenderViewHostTestEnabler rvh_test_enabler; std::unique_ptr<WebContents> web_contents( WebContentsTester::CreateTestWebContents(helper_->browser_context(), nullptr));
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc index 229bcde..b77f9cc 100644 --- a/content/browser/utility_process_host_impl.cc +++ b/content/browser/utility_process_host_impl.cc
@@ -54,10 +54,9 @@ : public SandboxedProcessLauncherDelegate { public: UtilitySandboxedProcessLauncherDelegate( - const base::FilePath& exposed_dir, service_manager::SandboxType sandbox_type, const base::EnvironmentMap& env) - : exposed_dir_(exposed_dir), + : #if defined(OS_POSIX) env_(env), #endif @@ -88,29 +87,14 @@ } bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { - if (exposed_dir_.empty()) return true; - - sandbox::ResultCode result; - result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, - sandbox::TargetPolicy::FILES_ALLOW_ANY, - exposed_dir_.value().c_str()); - if (result != sandbox::SBOX_ALL_OK) - return false; - - base::FilePath exposed_files = exposed_dir_.AppendASCII("*"); - result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, - sandbox::TargetPolicy::FILES_ALLOW_ANY, - exposed_files.value().c_str()); - return result == sandbox::SBOX_ALL_OK; } #endif // OS_WIN #if BUILDFLAG(USE_ZYGOTE_HANDLE) ZygoteHandle GetZygote() override { if (service_manager::IsUnsandboxedSandboxType(sandbox_type_) || - sandbox_type_ == service_manager::SANDBOX_TYPE_NETWORK || - !exposed_dir_.empty()) { + sandbox_type_ == service_manager::SANDBOX_TYPE_NETWORK) { return nullptr; } return GetGenericZygote(); @@ -126,8 +110,6 @@ } private: - base::FilePath exposed_dir_; - #if defined(OS_POSIX) base::EnvironmentMap env_; #endif // OS_WIN @@ -180,10 +162,6 @@ return process_->Send(message); } -void UtilityProcessHostImpl::SetExposedDir(const base::FilePath& dir) { - exposed_dir_ = dir; -} - void UtilityProcessHostImpl::SetSandboxType( service_manager::SandboxType sandbox_type) { DCHECK(sandbox_type != service_manager::SANDBOX_TYPE_INVALID); @@ -330,11 +308,6 @@ switches::kUtilityCmdPrefix)); } - if (!exposed_dir_.empty()) { - cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, - exposed_dir_); - } - const bool is_service = service_identity_.has_value(); if (is_service) { GetContentClient()->browser()->AdjustUtilityServiceProcessCommandLine( @@ -342,7 +315,7 @@ } process_->Launch(std::make_unique<UtilitySandboxedProcessLauncherDelegate>( - exposed_dir_, sandbox_type_, env_), + sandbox_type_, env_), std::move(cmd_line), true); }
diff --git a/content/browser/utility_process_host_impl.h b/content/browser/utility_process_host_impl.h index a02ba19..49634c7c54 100644 --- a/content/browser/utility_process_host_impl.h +++ b/content/browser/utility_process_host_impl.h
@@ -18,7 +18,6 @@ #include "services/service_manager/public/cpp/identity.h" namespace base { -class FilePath; class SequencedTaskRunner; class Thread; } @@ -46,7 +45,6 @@ // UtilityProcessHost: base::WeakPtr<UtilityProcessHost> AsWeakPtr() override; bool Send(IPC::Message* message) override; - void SetExposedDir(const base::FilePath& dir) override; void SetSandboxType(service_manager::SandboxType sandbox_type) override; const ChildProcessData& GetData() override; #if defined(OS_POSIX) @@ -93,9 +91,6 @@ // Task runner used for posting progess notifications to |client_|. scoped_refptr<base::SequencedTaskRunner> client_task_runner_; - // Directory opened through the child process sandbox if needed. - base::FilePath exposed_dir_; - // Launch the child process with switches that will setup this sandbox type. service_manager::SandboxType sandbox_type_;
diff --git a/content/browser/utility_process_mojo_client_browsertest.cc b/content/browser/utility_process_mojo_client_browsertest.cc deleted file mode 100644 index 11d005512e..0000000 --- a/content/browser/utility_process_mojo_client_browsertest.cc +++ /dev/null
@@ -1,172 +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. - -#include "content/public/browser/utility_process_mojo_client.h" - -#include <memory> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/command_line.h" -#include "base/run_loop.h" -#include "base/strings/utf_string_conversions.h" -#include "content/public/common/content_switches.h" -#include "content/public/test/content_browser_test.h" -#include "content/public/test/test_service.mojom.h" - -namespace content { - -// Test fixture used to make different Mojo calls to the utility process. -class UtilityProcessMojoClientBrowserTest : public ContentBrowserTest { - public: - enum RunOption { - SANDBOXED, UNSANDBOXED, ELEVATED - }; - - void StartMojoService(RunOption option = SANDBOXED) { - mojo_client_.reset(new UtilityProcessMojoClient<mojom::TestService>( - base::ASCIIToUTF16("TestUtilityProcessMojoClient"))); - - mojo_client_->set_error_callback( - base::Bind(&UtilityProcessMojoClientBrowserTest::OnConnectionError, - base::Unretained(this))); - - // This test case needs to have the sandbox disabled. - if (option == UNSANDBOXED) - mojo_client_->set_disable_sandbox(); -#if defined(OS_WIN) - // This test case needs utility process UAC privilege elevation. - if (option == ELEVATED) - mojo_client_->set_run_elevated(); -#endif // defined(OS_WIN) - - mojo_client_->Start(); - } - - // Called when a response is received from a call to DoSomething() or - // DoTerminateProcess(). - void OnResponseReceived() { - response_received_ = true; - done_closure_.Run(); - } - - // Called when a connection error happen between the test and the utility - // process. - void OnConnectionError() { - error_happened_ = true; - done_closure_.Run(); - } - - // Called when a responsed is received from a call to CreateFolder(). - void OnCreateFolderFinished(bool succeeded) { - response_received_ = true; - sandbox_succeeded_ = succeeded; - done_closure_.Run(); - } - - protected: - std::unique_ptr<UtilityProcessMojoClient<mojom::TestService>> - mojo_client_; - base::Closure done_closure_; - - // The test result that is compared to the current test case. - bool response_received_ = false; - bool error_happened_ = false; - bool sandbox_succeeded_ = false; -}; - -// Successful call through the Mojo service with response back. -IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, CallService) { - base::RunLoop run_loop; - done_closure_ = run_loop.QuitClosure(); - - StartMojoService(); - - mojo_client_->service()->DoSomething( - base::BindOnce(&UtilityProcessMojoClientBrowserTest::OnResponseReceived, - base::Unretained(this))); - - run_loop.Run(); - EXPECT_TRUE(response_received_); - EXPECT_FALSE(error_happened_); -} - -// Call the Mojo service but the utility process terminates before getting -// the result back. -IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, ConnectionError) { - base::RunLoop run_loop; - done_closure_ = run_loop.QuitClosure(); - - StartMojoService(); - - mojo_client_->service()->DoTerminateProcess( - base::BindOnce(&UtilityProcessMojoClientBrowserTest::OnResponseReceived, - base::Unretained(this))); - - run_loop.Run(); - EXPECT_FALSE(response_received_); - EXPECT_TRUE(error_happened_); -} - -// Android doesn't support non-sandboxed utility processes. -#if !defined(OS_ANDROID) -// Call a function that fails because the sandbox is still enabled. -IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, SandboxFailure) { - base::RunLoop run_loop; - done_closure_ = run_loop.QuitClosure(); - - StartMojoService(); - - mojo_client_->service()->CreateFolder(base::BindOnce( - &UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished, - base::Unretained(this))); - - run_loop.Run(); - EXPECT_TRUE(response_received_); - // If the sandbox is disabled by the command line, this will succeed. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoSandbox)) - EXPECT_FALSE(sandbox_succeeded_); - EXPECT_FALSE(error_happened_); -} - -// Call a function that succeeds only when the sandbox is disabled. -IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, SandboxSuccess) { - base::RunLoop run_loop; - done_closure_ = run_loop.QuitClosure(); - - StartMojoService(UNSANDBOXED); - - mojo_client_->service()->CreateFolder(base::BindOnce( - &UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished, - base::Unretained(this))); - - run_loop.Run(); - EXPECT_TRUE(response_received_); - EXPECT_TRUE(sandbox_succeeded_); - EXPECT_FALSE(error_happened_); -} -#endif // !defined(OS_ANDROID) - -#if defined(OS_WIN) -// Call a function that succeeds with process elevation. Elevation is only -// available on WIN, and is used to permit UAC prompts for operations that -// need user approval before proceeding. -IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, ElevatedSuccess) { - base::RunLoop run_loop; - done_closure_ = run_loop.QuitClosure(); - - StartMojoService(ELEVATED); - - mojo_client_->service()->CreateFolder( - base::Bind(&UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished, - base::Unretained(this))); - - run_loop.Run(); - EXPECT_TRUE(response_received_); - EXPECT_TRUE(sandbox_succeeded_); - EXPECT_FALSE(error_happened_); -} -#endif // defined(OS_WIN) - -} // namespace content
diff --git a/content/browser/web_package/signed_exchange_handler.cc b/content/browser/web_package/signed_exchange_handler.cc index fddf582..cf439d7 100644 --- a/content/browser/web_package/signed_exchange_handler.cc +++ b/content/browser/web_package/signed_exchange_handler.cc
@@ -5,7 +5,6 @@ #include "content/browser/web_package/signed_exchange_handler.h" #include "base/feature_list.h" -#include "base/strings/string_number_conversions.h" #include "content/browser/loader/merkle_integrity_source_stream.h" #include "content/browser/web_package/signed_exchange_cert_fetcher.h" #include "content/browser/web_package/signed_exchange_consts.h" @@ -20,8 +19,6 @@ #include "net/cert/cert_verifier.h" #include "net/cert/x509_certificate.h" #include "net/filter/source_stream.h" -#include "net/http/http_response_headers.h" -#include "net/http/http_util.h" #include "net/ssl/ssl_config.h" #include "net/ssl/ssl_config_service.h" #include "net/url_request/url_request_context.h" @@ -169,44 +166,6 @@ return false; } - // TODO(https://crbug.com/803774): implement the following logic in - // SignedExchangeHeaderParser. - std::string fake_header_str("HTTP/1.1 "); - fake_header_str.append(base::NumberToString(header_->response_code())); - fake_header_str.append(" "); - fake_header_str.append(net::GetHttpReasonPhrase(header_->response_code())); - fake_header_str.append(" \r\n"); - for (const auto& it : header_->response_headers()) { - if (!net::HttpUtil::IsValidHeaderName(it.first)) { - DVLOG(1) << "Invalid header name"; - return false; - } - if (!net::HttpUtil::IsValidHeaderValue(it.second)) { - DVLOG(1) << "Invalid header value"; - return false; - } - fake_header_str.append(it.first); - fake_header_str.append(": "); - fake_header_str.append(it.second); - fake_header_str.append("\r\n"); - } - fake_header_str.append("\r\n"); - response_head_.headers = base::MakeRefCounted<net::HttpResponseHeaders>( - net::HttpUtil::AssembleRawHeaders(fake_header_str.c_str(), - fake_header_str.size())); - // TODO(https://crbug.com/803774): |mime_type| should be derived from - // "Content-Type" header. - response_head_.mime_type = "text/html"; - - std::string mi_header_value; - if (!response_head_.headers->EnumerateHeader(nullptr, kMiHeader, - &mi_header_value)) { - DVLOG(1) << "Signed exchange has no MI: header"; - return false; - } - mi_stream_ = std::make_unique<MerkleIntegritySourceStream>( - mi_header_value, std::move(source_)); - const GURL cert_url = header_->signature().cert_url; // TODO(https://crbug.com/819467): When we will support ed25519Key, |cert_url| // may be empty. @@ -287,6 +246,22 @@ return; } + network::ResourceResponseHead response_head; + response_head.headers = header_->BuildHttpResponseHeaders(); + // TODO(https://crbug.com/803774): |mime_type| should be derived from + // "Content-Type" header. + response_head.mime_type = "text/html"; + + std::string mi_header_value; + if (!response_head.headers->EnumerateHeader(nullptr, kMiHeader, + &mi_header_value)) { + DVLOG(1) << "Signed exchange has no MI: header"; + RunErrorCallback(net::ERR_FAILED); + return; + } + auto mi_stream = std::make_unique<MerkleIntegritySourceStream>( + mi_header_value, std::move(source_)); + net::SSLInfo ssl_info; ssl_info.cert = cert_verify_result_.verified_cert; ssl_info.unverified_cert = unverified_cert_; @@ -301,7 +276,7 @@ // TODO(https://crbug.com/815025): Verify the Certificate Transparency status. std::move(headers_callback_) .Run(net::OK, header_->request_url(), header_->request_method(), - response_head_, std::move(mi_stream_), ssl_info); + response_head, std::move(mi_stream), ssl_info); state_ = State::kHeadersCallbackCalled; }
diff --git a/content/browser/web_package/signed_exchange_handler.h b/content/browser/web_package/signed_exchange_handler.h index 5b9c38b..86fbbd9 100644 --- a/content/browser/web_package/signed_exchange_handler.h +++ b/content/browser/web_package/signed_exchange_handler.h
@@ -18,7 +18,6 @@ #include "net/cert/cert_verify_result.h" #include "net/log/net_log_with_source.h" #include "net/ssl/ssl_info.h" -#include "services/network/public/cpp/resource_response.h" #include "url/gurl.h" #include "url/origin.h" @@ -31,12 +30,15 @@ class X509Certificate; } // namespace net +namespace network { +struct ResourceResponseHead; +} + namespace content { class SharedURLLoaderFactory; class SignedExchangeCertFetcher; class URLLoaderThrottle; -class MerkleIntegritySourceStream; // IMPORTANT: Currenly SignedExchangeHandler partially implements the verifying // logic. @@ -95,9 +97,6 @@ scoped_refptr<net::X509Certificate> cert); void OnCertVerifyComplete(int result); - // Signed exchange contents. - network::ResourceResponseHead response_head_; - ExchangeHeadersCallback headers_callback_; std::unique_ptr<net::SourceStream> source_; @@ -109,7 +108,6 @@ size_t headers_length_ = 0; base::Optional<SignedExchangeHeader> header_; - std::unique_ptr<MerkleIntegritySourceStream> mi_stream_; // Used to create |cert_fetcher_|. url::Origin request_initiator_;
diff --git a/content/browser/web_package/signed_exchange_header.cc b/content/browser/web_package/signed_exchange_header.cc index e507448..c8c4c0f5 100644 --- a/content/browser/web_package/signed_exchange_header.cc +++ b/content/browser/web_package/signed_exchange_header.cc
@@ -10,6 +10,7 @@ #include "base/strings/string_piece.h" #include "components/cbor/cbor_reader.h" #include "content/browser/web_package/signed_exchange_consts.h" +#include "net/http/http_util.h" namespace content { @@ -77,8 +78,16 @@ base::StringPiece name_str = it.first.GetBytestringAsString(); if (name_str == kStatusKey) continue; + if (!net::HttpUtil::IsValidHeaderName(name_str)) { + DVLOG(1) << "Invalid header name"; + return false; + } base::StringPiece value_str = it.second.GetBytestringAsString(); + if (!net::HttpUtil::IsValidHeaderValue(value_str)) { + DVLOG(1) << "Invalid header value"; + return false; + } out->AddResponseHeader(name_str, value_str); } @@ -159,4 +168,23 @@ response_headers_[name_string] = value_string; } +scoped_refptr<net::HttpResponseHeaders> +SignedExchangeHeader::BuildHttpResponseHeaders() const { + std::string fake_header_str("HTTP/1.1 "); + fake_header_str.append(base::NumberToString(response_code())); + fake_header_str.append(" "); + fake_header_str.append(net::GetHttpReasonPhrase(response_code())); + fake_header_str.append(" \r\n"); + for (const auto& it : response_headers()) { + fake_header_str.append(it.first); + fake_header_str.append(": "); + fake_header_str.append(it.second); + fake_header_str.append("\r\n"); + } + fake_header_str.append("\r\n"); + return base::MakeRefCounted<net::HttpResponseHeaders>( + net::HttpUtil::AssembleRawHeaders(fake_header_str.c_str(), + fake_header_str.size())); +} + } // namespace content
diff --git a/content/browser/web_package/signed_exchange_header.h b/content/browser/web_package/signed_exchange_header.h index 99bc6ec..ebae277 100644 --- a/content/browser/web_package/signed_exchange_header.h +++ b/content/browser/web_package/signed_exchange_header.h
@@ -13,6 +13,7 @@ #include "base/strings/string_piece.h" #include "content/browser/web_package/signed_exchange_header_parser.h" #include "content/common/content_export.h" +#include "net/http/http_response_headers.h" #include "net/http/http_status_code.h" #include "url/gurl.h" @@ -54,6 +55,7 @@ ~SignedExchangeHeader(); void AddResponseHeader(base::StringPiece name, base::StringPiece value); + scoped_refptr<net::HttpResponseHeaders> BuildHttpResponseHeaders() const; const GURL& request_url() const { return request_url_; }; void set_request_url(GURL url) { request_url_ = std::move(url); }
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index 58ce5c5..6e4cdb8 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc
@@ -776,14 +776,14 @@ base::RunLoop::QuitCurrentWhenIdleDeprecated(); } -void ChildThreadImpl::SetIPCLoggingEnabled(bool enable) { #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) +void ChildThreadImpl::SetIPCLoggingEnabled(bool enable) { if (enable) IPC::Logging::GetInstance()->Enable(); else IPC::Logging::GetInstance()->Disable(); -#endif // IPC_MESSAGE_LOG_ENABLED } +#endif // IPC_MESSAGE_LOG_ENABLED void ChildThreadImpl::OnChildControlRequest( mojom::ChildControlRequest request) {
diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h index 62350f7d..01f1ced2 100644 --- a/content/child/child_thread_impl.h +++ b/content/child/child_thread_impl.h
@@ -158,7 +158,9 @@ // mojom::ChildControl void ProcessShutdown() override; +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) void SetIPCLoggingEnabled(bool enable) override; +#endif void OnChildControlRequest(mojom::ChildControlRequest); virtual bool OnControlMessageReceived(const IPC::Message& msg);
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 0e2e795c..322e8736 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn
@@ -6,6 +6,7 @@ import("//build/buildflag_header.gni") import("//build/config/features.gni") import("//build/config/ui.gni") +import("//ipc/features.gni") import("//media/media_options.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//ppapi/features/features.gni") @@ -596,6 +597,14 @@ sources += [ "font_loader_mac.mojom" ] } + enabled_features = [] + if (enable_ipc_logging) { + enabled_features += [ "ipc_logging" ] + } + if (is_linux || is_chromeos) { + enabled_features += [ "supports_thread_priorities" ] + } + import_dirs = [ "//mojo/services" ] public_deps = [
diff --git a/content/common/child_control.mojom b/content/common/child_control.mojom index a73a317a3..733c85c 100644 --- a/content/common/child_control.mojom +++ b/content/common/child_control.mojom
@@ -9,5 +9,6 @@ ProcessShutdown(); // Tell the child process to begin or end IPC message logging. + [EnableIf=ipc_logging] SetIPCLoggingEnabled(bool on); };
diff --git a/content/common/render_message_filter.mojom b/content/common/render_message_filter.mojom index 7da0969..695bacc 100644 --- a/content/common/render_message_filter.mojom +++ b/content/common/render_message_filter.mojom
@@ -41,7 +41,7 @@ [Sync] HasGpuProcess() => (bool has_gpu_process); // Asks the browser to change the priority of thread. - // (Linux only, NOP on other platforms.) + [EnableIf=supports_thread_priorities] SetThreadPriority(int32 platform_thread_id, mojo.common.mojom.ThreadPriority thread_priority); };
diff --git a/content/common/renderer.mojom b/content/common/renderer.mojom index 0410f53..e5691f1 100644 --- a/content/common/renderer.mojom +++ b/content/common/renderer.mojom
@@ -248,7 +248,6 @@ // Tells the renderer process to enter or leave background mode. - // TODO(crbug:676224) Make this conditional on IPC_MESSAGE_LOG_ENABLED. SetProcessBackgrounded(bool background); // Tells the scheduler about "keep-alive" state which can be due to:
diff --git a/content/common/sandbox_init_mac.cc b/content/common/sandbox_init_mac.cc index eaf4ffa..a9823f7 100644 --- a/content/common/sandbox_init_mac.cc +++ b/content/common/sandbox_init_mac.cc
@@ -70,23 +70,13 @@ base::Passed(std::move(original))); } -// Fill in |sandbox_type| and |allowed_dir| based on the command line, returns -// false if the current process type doesn't need to be sandboxed or if the -// sandbox was disabled from the command line. -bool GetSandboxInfoFromCommandLine(service_manager::SandboxType* sandbox_type, - base::FilePath* allowed_dir) { +// Fill in |sandbox_type| based on the command line. Returns false if the +// current process type doesn't need to be sandboxed or if the sandbox was +// disabled from the command line. +bool GetSandboxTypeFromCommandLine(service_manager::SandboxType* sandbox_type) { DCHECK(sandbox_type); - DCHECK(allowed_dir); - *allowed_dir = base::FilePath(); // Empty by default. auto* command_line = base::CommandLine::ForCurrentProcess(); - std::string process_type = - command_line->GetSwitchValueASCII(switches::kProcessType); - if (process_type == switches::kUtilityProcess) { - *allowed_dir = - command_line->GetSwitchValuePath(switches::kUtilityProcessAllowedDir); - } - *sandbox_type = service_manager::SandboxTypeFromCommandLine(*command_line); if (service_manager::IsUnsandboxedSandboxType(*sandbox_type)) return false; @@ -102,22 +92,19 @@ } // namespace -bool InitializeSandbox(service_manager::SandboxType sandbox_type, - const base::FilePath& allowed_dir) { +bool InitializeSandbox(service_manager::SandboxType sandbox_type) { return service_manager::Sandbox::Initialize( - sandbox_type, allowed_dir, + sandbox_type, MaybeWrapWithGPUSandboxHook(sandbox_type, base::OnceClosure())); } bool InitializeSandbox(base::OnceClosure post_warmup_hook) { service_manager::SandboxType sandbox_type = service_manager::SANDBOX_TYPE_INVALID; - base::FilePath allowed_dir; - return !GetSandboxInfoFromCommandLine(&sandbox_type, &allowed_dir) || + return !GetSandboxTypeFromCommandLine(&sandbox_type) || service_manager::Sandbox::Initialize( - sandbox_type, allowed_dir, - MaybeWrapWithGPUSandboxHook(sandbox_type, - std::move(post_warmup_hook))); + sandbox_type, MaybeWrapWithGPUSandboxHook( + sandbox_type, std::move(post_warmup_hook))); } bool InitializeSandbox() {
diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm index 999d96e..b1daac3 100644 --- a/content/common/sandbox_mac_unittest_helper.mm +++ b/content/common/sandbox_mac_unittest_helper.mm
@@ -11,7 +11,6 @@ #include <map> #include <memory> -#include "base/files/file_path.h" #include "base/logging.h" #include "base/process/kill.h" #include "content/test/test_content_client.h" @@ -157,7 +156,7 @@ } service_manager::SandboxMac::Warmup(sandbox_type); - if (!service_manager::SandboxMac::Enable(sandbox_type, base::FilePath())) { + if (!service_manager::SandboxMac::Enable(sandbox_type)) { LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type; return -1; }
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn index cd6941d..da57153f 100644 --- a/content/public/browser/BUILD.gn +++ b/content/public/browser/BUILD.gn
@@ -147,6 +147,7 @@ "manifest_icon_downloader.h", "manifest_icon_selector.h", "media_capture_devices.h", + "media_controller.h", "media_device_id.cc", "media_device_id.h", "media_request_state.h", @@ -268,7 +269,6 @@ "url_data_source.h", "utility_process_host.h", "utility_process_host_client.h", - "utility_process_mojo_client.h", "video_capture_device_launcher.h", "visibility.h", "vpn_service_proxy.h",
diff --git a/content/public/browser/media_controller.h b/content/public/browser/media_controller.h new file mode 100644 index 0000000..707a109e --- /dev/null +++ b/content/public/browser/media_controller.h
@@ -0,0 +1,44 @@ +// Copyright 2018 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_PUBLIC_BROWSER_MEDIA_CONTROLLER_H_ +#define CONTENT_PUBLIC_BROWSER_MEDIA_CONTROLLER_H_ + +#include "base/time/time.h" + +namespace content { + +// High level interface that allows a controller to issue simple media commands. +// Modeled after the media_router.mojom.MediaController interface. +// State changes will be signaled via the MediaStatusObserver interface. +// TODO(tguilbert): Add MediaStatusObserver interface. +class MediaController { + public: + virtual ~MediaController() = default; + + // Starts playing the media if it is paused. Is a no-op if not supported by + // the media or the media is already playing. + virtual void Play() = 0; + + // Pauses the media if it is playing. Is a no-op if not supported by the media + // or the media is already paused. + virtual void Pause() = 0; + + // Mutes the media if |mute| is true, and unmutes it if false. Is a no-op if + // not supported by the media. + virtual void SetMute(bool mute) = 0; + + // Changes the current volume of the media, with 1 being the highest and 0 + // being the lowest/no sound. Does not change the (un)muted state of the + // media. Is a no-op if not supported by the media. + virtual void SetVolume(float volume) = 0; + + // Sets the current playback position. |time| must be less than or equal to + // the duration of the media. Is a no-op if the media doesn't support seeking. + virtual void Seek(base::TimeDelta time) = 0; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_BROWSER_MEDIA_CONTROLLER_H_
diff --git a/content/public/browser/presentation_service_delegate.h b/content/public/browser/presentation_service_delegate.h index 7072c26..8e00e42 100644 --- a/content/public/browser/presentation_service_delegate.h +++ b/content/public/browser/presentation_service_delegate.h
@@ -12,6 +12,7 @@ #include "base/callback.h" #include "content/common/content_export.h" +#include "content/public/browser/media_controller.h" #include "content/public/common/presentation_connection_message.h" #include "content/public/common/presentation_info.h" #include "third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h" @@ -168,6 +169,15 @@ int render_frame_id, const std::string& presentation_id) = 0; + // Gets a MediaController for a given presentation ID. + // |render_process_id|, |render_frame_id|: ID of originating frame. + // |presentation_id|: The ID of the presentation for which we want a + // Controller. + virtual std::unique_ptr<MediaController> GetMediaController( + int render_process_id, + int render_frame_id, + const std::string& presentation_id) = 0; + // Continuously listen for state changes for a PresentationConnection in a // frame. // |render_process_id|, |render_frame_id|: ID of frame.
diff --git a/content/public/browser/utility_process_host.h b/content/public/browser/utility_process_host.h index 376a3c2..8530023e 100644 --- a/content/public/browser/utility_process_host.h +++ b/content/public/browser/utility_process_host.h
@@ -18,7 +18,6 @@ #include "services/service_manager/sandbox/sandbox_type.h" namespace base { -class FilePath; class SequencedTaskRunner; } @@ -54,10 +53,6 @@ virtual base::WeakPtr<UtilityProcessHost> AsWeakPtr() = 0; - // Allows a directory to be opened through the sandbox, in case it's needed by - // the operation. - virtual void SetExposedDir(const base::FilePath& dir) = 0; - // Make the process run with a specific sandbox type, or unsandboxed if // SANDBOX_TYPE_NO_SANDBOX is specified. virtual void SetSandboxType(service_manager::SandboxType sandbox_type) = 0;
diff --git a/content/public/browser/utility_process_mojo_client.h b/content/public/browser/utility_process_mojo_client.h deleted file mode 100644 index f38a1a66..0000000 --- a/content/public/browser/utility_process_mojo_client.h +++ /dev/null
@@ -1,185 +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_PUBLIC_BROWSER_UTILITY_PROCESS_MOJO_CLIENT_H_ -#define CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_MOJO_CLIENT_H_ - -#include <string> - -#include "base/callback.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/macros.h" -#include "base/strings/string16.h" -#include "base/threading/thread_checker.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/utility_process_host.h" -#include "content/public/browser/utility_process_host_client.h" -#include "mojo/public/cpp/bindings/interface_ptr.h" -#include "services/service_manager/public/cpp/interface_provider.h" - -namespace content { - -// Implements a client to a Mojo service running on a utility process. Takes -// care of starting the utility process and connecting to the remote Mojo -// service. The utility process is terminated in the destructor. -// Note: This class is not thread-safe. It is bound to the -// SingleThreadTaskRunner it is created on. -template <class MojoInterface> -class UtilityProcessMojoClient { - public: - explicit UtilityProcessMojoClient(const base::string16& process_name) { - helper_.reset(new Helper(process_name)); - } - - ~UtilityProcessMojoClient() { - BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, helper_.release()); - } - - // Sets the error callback. A valid callback must be set before calling - // Start(). - void set_error_callback(const base::Closure& error_callback) { - error_callback_ = error_callback; - } - - // Allows a directory to be opened through the utility process sandbox. - void set_exposed_directory(const base::FilePath& directory) { - DCHECK(!start_called_); - DCHECK(!directory.empty()); - helper_->set_exposed_directory(directory); - } - - // Disables the sandbox in the utility process. - void set_disable_sandbox() { - DCHECK(!start_called_); - helper_->set_disable_sandbox(); - } - -#if defined(OS_WIN) - // Allows the utility process to run with elevated privileges. - void set_run_elevated() { - DCHECK(!start_called_); - helper_->set_run_elevated(); - } -#endif // defined(OS_WIN) - - // Starts the utility process and connects to the remote Mojo service. - void Start() { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(error_callback_); - DCHECK(!start_called_); - - start_called_ = true; - - auto request = MakeRequest(&service_); - service_.set_connection_error_handler(error_callback_); - helper_->Start(MojoInterface::Name_, request.PassMessagePipe()); - } - - // Returns the Mojo service used to make calls to the utility process. - MojoInterface* service() WARN_UNUSED_RESULT { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(start_called_); - - return service_.get(); - } - - private: - // Helper class that takes care of managing the lifetime of the utility - // process on the IO thread. - class Helper { - public: - explicit Helper(const base::string16& process_name) - : process_name_(process_name) {} - - ~Helper() { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - // |utility_host_| manages its own lifetime but this forces the process to - // terminate if it's still alive. - delete utility_host_.get(); - } - - // Starts the utility process on the IO thread. - void Start(const std::string& mojo_interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&Helper::StartOnIOThread, base::Unretained(this), - mojo_interface_name, std::move(interface_pipe))); - } - - void set_exposed_directory(const base::FilePath& directory) { - exposed_directory_ = directory; - } - - void set_disable_sandbox() { disable_sandbox_ = true; } - -#if defined(OS_WIN) - void set_run_elevated() { - disable_sandbox_ = true; - run_elevated_ = true; - } -#endif // defined(OS_WIN) - - private: - // Starts the utility process and binds the specified interface. - void StartOnIOThread(const std::string& interface_name, - mojo::ScopedMessagePipeHandle interface_pipe) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - utility_host_ = UtilityProcessHost::Create(nullptr, nullptr)->AsWeakPtr(); - utility_host_->SetName(process_name_); - - if (!exposed_directory_.empty()) - utility_host_->SetExposedDir(exposed_directory_); - - if (disable_sandbox_) - utility_host_->SetSandboxType(service_manager::SANDBOX_TYPE_NO_SANDBOX); -#if defined(OS_WIN) - if (run_elevated_) { - DCHECK(disable_sandbox_); - utility_host_->SetSandboxType( - service_manager::SANDBOX_TYPE_NO_SANDBOX_AND_ELEVATED_PRIVILEGES); - } -#endif // defined(OS_WIN) - - utility_host_->Start(); - - utility_host_->BindInterface(interface_name, std::move(interface_pipe)); - } - - // Properties of the utility process. - base::string16 process_name_; - base::FilePath exposed_directory_; - bool disable_sandbox_ = false; -#if defined(OS_WIN) - bool run_elevated_ = false; -#endif // defined(OS_WIN) - - // Must only be accessed on the IO thread. - base::WeakPtr<UtilityProcessHost> utility_host_; - - DISALLOW_COPY_AND_ASSIGN(Helper); - }; - - std::unique_ptr<Helper> helper_; - - // Called when a connection error happens or if the process didn't start. - base::Closure error_callback_; - - mojo::InterfacePtr<MojoInterface> service_; - - // Enforce calling Start() before getting the service. - bool start_called_ = false; - - // Checks that this class is always accessed from the same thread. - SEQUENCE_CHECKER(sequence_checker_); - - DISALLOW_COPY_AND_ASSIGN(UtilityProcessMojoClient); -}; - -} // namespace content - -#endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_MOJO_CLIENT_H_
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc index cfb9809..bbf8311 100644 --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc
@@ -244,6 +244,10 @@ const base::Feature kPassiveEventListenersDueToFling{ "PassiveEventListenersDueToFling", base::FEATURE_ENABLED_BY_DEFAULT}; +// Whether PDF files should be rendered in diffent processes based on origin. +const base::Feature kPdfIsolation = {"PdfIsolation", + base::FEATURE_DISABLED_BY_DEFAULT}; + // If Pepper 3D Image Chromium is allowed, this feature controls whether it is // enabled. const base::Feature kPepper3DImageChromium {
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h index 0bcc842..f115485 100644 --- a/content/public/common/content_features.h +++ b/content/public/common/content_features.h
@@ -64,6 +64,7 @@ CONTENT_EXPORT extern const base::Feature kOriginTrials; CONTENT_EXPORT extern const base::Feature kPassiveDocumentEventListeners; CONTENT_EXPORT extern const base::Feature kPassiveEventListenersDueToFling; +CONTENT_EXPORT extern const base::Feature kPdfIsolation; CONTENT_EXPORT extern const base::Feature kPepper3DImageChromium; CONTENT_EXPORT extern const base::Feature kPurgeAndSuspend; CONTENT_EXPORT extern const base::Feature kPWAFullCodeCache;
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 4f1dc51..804d495 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc
@@ -827,10 +827,6 @@ // Causes the process to run as a utility subprocess. const char kUtilityProcess[] = "utility"; -// When utility process is sandboxed, there is still access to one directory. -// This flag specifies the directory that can be accessed. -const char kUtilityProcessAllowedDir[] = "utility-allowed-dir"; - // Causes the utility process to display a dialog on launch. const char kUtilityStartupDialog[] = "utility-startup-dialog";
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index b48a297..38b7b87 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h
@@ -229,7 +229,6 @@ CONTENT_EXPORT extern const char kUseMockCertVerifierForTesting[]; extern const char kUtilityCmdPrefix[]; CONTENT_EXPORT extern const char kUtilityProcess[]; -extern const char kUtilityProcessAllowedDir[]; CONTENT_EXPORT extern const char kUtilityStartupDialog[]; CONTENT_EXPORT extern const char kV8CacheOptions[]; CONTENT_EXPORT extern const char kValidateInputEventStream[];
diff --git a/content/public/common/sandbox_init.h b/content/public/common/sandbox_init.h index b05b033..55041eaa 100644 --- a/content/public/common/sandbox_init.h +++ b/content/public/common/sandbox_init.h
@@ -19,7 +19,6 @@ namespace base { class CommandLine; -class FilePath; } namespace sandbox { @@ -65,8 +64,8 @@ // Returns true if the sandbox was initialized succesfully, false if an error // occurred. If process_type isn't one that needs sandboxing, no action is // taken and true is always returned. -CONTENT_EXPORT bool InitializeSandbox(service_manager::SandboxType sandbox_type, - const base::FilePath& allowed_path); +CONTENT_EXPORT bool InitializeSandbox( + service_manager::SandboxType sandbox_type); // Initialize the sandbox for renderer, gpu, utility, worker, and plugin // processes, depending on the command line flags. For the browser process which
diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc index 4569941..4566c56 100644 --- a/content/public/renderer/content_renderer_client.cc +++ b/content/public/renderer/content_renderer_client.cc
@@ -173,6 +173,11 @@ return false; } +bool ContentRendererClient::IsOriginIsolatedPepperPlugin( + const base::FilePath& plugin_path) { + return false; +} + bool ContentRendererClient::AllowPepperMediaStreamAPI(const GURL& url) { return false; }
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index c5da6a40..f663393a 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h
@@ -13,6 +13,7 @@ #include <vector> #include "base/callback_forward.h" +#include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" #include "base/task_scheduler/task_scheduler.h" @@ -261,6 +262,12 @@ // startup steps). virtual bool IsExternalPepperPlugin(const std::string& module_name); + // Returns true if the given Pepper plugin should process content from + // different origins in different PPAPI processes. This is generally a + // worthwhile precaution when the plugin provides an active scripting + // language. + virtual bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path); + // Returns true if the page at |url| can use Pepper MediaStream APIs. virtual bool AllowPepperMediaStreamAPI(const GURL& url);
diff --git a/content/public/test/mock_render_thread.cc b/content/public/test/mock_render_thread.cc index 4781582..3f7750c 100644 --- a/content/public/test/mock_render_thread.cc +++ b/content/public/test/mock_render_thread.cc
@@ -86,8 +86,10 @@ std::move(callback).Run(false); } +#if defined(OS_LINUX) void SetThreadPriority(int32_t platform_thread_id, base::ThreadPriority thread_priority) override {} +#endif private: MockRenderThread* const thread_;
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 21ebba77..0fa5d23 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -2852,8 +2852,11 @@ this, delegate->GetWeakPtr()); } - // TODO(tsepez): extract origin to lock from WebPluginParams url. base::Optional<url::Origin> origin_lock; + if (base::FeatureList::IsEnabled(features::kPdfIsolation) && + GetContentClient()->renderer()->IsOriginIsolatedPepperPlugin(info.path)) { + origin_lock = url::Origin::Create(GURL(params.url)); + } bool pepper_plugin_was_registered = false; scoped_refptr<PluginModule> pepper_module(PluginModule::Create(
diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc index 3b3221a..6447347 100644 --- a/content/shell/browser/shell_devtools_frontend.cc +++ b/content/shell/browser/shell_devtools_frontend.cc
@@ -19,8 +19,8 @@ namespace { static GURL GetFrontendURL() { int port = ShellDevToolsManagerDelegate::GetHttpHandlerPort(); - return GURL( - base::StringPrintf("http://127.0.0.1:%d/devtools/inspector.html", port)); + return GURL(base::StringPrintf( + "http://127.0.0.1:%d/devtools/devtools_app.html", port)); } } // namespace
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 45360f9..61e1a95 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -820,7 +820,6 @@ "../browser/tracing/memory_tracing_browsertest.cc", "../browser/tracing/tracing_controller_browsertest.cc", "../browser/utility_process_host_impl_browsertest.cc", - "../browser/utility_process_mojo_client_browsertest.cc", "../browser/vibration_browsertest.cc", "../browser/wake_lock/wake_lock_browsertest.cc", "../browser/web_contents/opened_by_dom_browsertest.cc",
diff --git a/dbus/property.cc b/dbus/property.cc index 4197589..e1fb05a 100644 --- a/dbus/property.cc +++ b/dbus/property.cc
@@ -661,13 +661,13 @@ } // -// Property<std::unordered_map<std::string, std::vector<uint8_t>>> +// Property<std::map<std::string, std::vector<uint8_t>>> // specialization. // template <> -bool Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: - PopValueFromReader(MessageReader* reader) { +bool Property<std::map<std::string, std::vector<uint8_t>>>::PopValueFromReader( + MessageReader* reader) { MessageReader variant_reader(nullptr); MessageReader dict_reader(nullptr); if (!reader->PopVariant(&variant_reader) || @@ -697,7 +697,7 @@ } template <> -void Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: +void Property<std::map<std::string, std::vector<uint8_t>>>:: AppendSetValueToWriter(MessageWriter* writer) { MessageWriter variant_writer(nullptr); MessageWriter dict_writer(nullptr); @@ -725,13 +725,13 @@ } // -// Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> +// Property<std::map<uint16_t, std::vector<uint8_t>>> // specialization. // template <> -bool Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>:: - PopValueFromReader(MessageReader* reader) { +bool Property<std::map<uint16_t, std::vector<uint8_t>>>::PopValueFromReader( + MessageReader* reader) { MessageReader variant_reader(nullptr); MessageReader dict_reader(nullptr); if (!reader->PopVariant(&variant_reader) || @@ -761,8 +761,8 @@ } template <> -void Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>:: - AppendSetValueToWriter(MessageWriter* writer) { +void Property<std::map<uint16_t, std::vector<uint8_t>>>::AppendSetValueToWriter( + MessageWriter* writer) { MessageWriter variant_writer(nullptr); MessageWriter dict_writer(nullptr); @@ -804,7 +804,7 @@ template class Property<std::vector<uint8_t>>; template class Property<std::map<std::string, std::string>>; template class Property<std::vector<std::pair<std::vector<uint8_t>, uint16_t>>>; -template class Property<std::unordered_map<std::string, std::vector<uint8_t>>>; -template class Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>; +template class Property<std::map<std::string, std::vector<uint8_t>>>; +template class Property<std::map<uint16_t, std::vector<uint8_t>>>; } // namespace dbus
diff --git a/dbus/property.h b/dbus/property.h index 4d92a7f..41d6c241 100644 --- a/dbus/property.h +++ b/dbus/property.h
@@ -9,7 +9,6 @@ #include <map> #include <string> -#include <unordered_map> #include <utility> #include <vector> @@ -613,25 +612,25 @@ template <> CHROME_DBUS_EXPORT bool -Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: - PopValueFromReader(MessageReader* reader); +Property<std::map<std::string, std::vector<uint8_t>>>::PopValueFromReader( + MessageReader* reader); template <> CHROME_DBUS_EXPORT void -Property<std::unordered_map<std::string, std::vector<uint8_t>>>:: - AppendSetValueToWriter(MessageWriter* writer); +Property<std::map<std::string, std::vector<uint8_t>>>::AppendSetValueToWriter( + MessageWriter* writer); extern template class CHROME_DBUS_EXPORT - Property<std::unordered_map<std::string, std::vector<uint8_t>>>; + Property<std::map<std::string, std::vector<uint8_t>>>; template <> CHROME_DBUS_EXPORT bool -Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>:: - PopValueFromReader(MessageReader* reader); +Property<std::map<uint16_t, std::vector<uint8_t>>>::PopValueFromReader( + MessageReader* reader); template <> CHROME_DBUS_EXPORT void -Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>:: - AppendSetValueToWriter(MessageWriter* writer); +Property<std::map<uint16_t, std::vector<uint8_t>>>::AppendSetValueToWriter( + MessageWriter* writer); extern template class CHROME_DBUS_EXPORT - Property<std::unordered_map<uint16_t, std::vector<uint8_t>>>; + Property<std::map<uint16_t, std::vector<uint8_t>>>; #pragma GCC diagnostic pop
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc index 6c381bb..5b26edd 100644 --- a/dbus/property_unittest.cc +++ b/dbus/property_unittest.cc
@@ -461,7 +461,7 @@ writer.CloseContainer(&variant_writer); MessageReader reader(message.get()); - Property<std::unordered_map<std::string, std::vector<uint8_t>>> test_property; + Property<std::map<std::string, std::vector<uint8_t>>> test_property; EXPECT_TRUE(test_property.PopValueFromReader(&reader)); ASSERT_EQ(arraysize(keys), test_property.value().size()); @@ -470,7 +470,7 @@ } TEST(PropertyTestStatic, SerializeStringToByteVectorMap) { - std::unordered_map<std::string, std::vector<uint8_t>> test_map; + std::map<std::string, std::vector<uint8_t>> test_map; test_map["Hi"] = {1, 2, 3}; test_map["Map"] = {0xab, 0xcd}; test_map["Random"] = {0x0}; @@ -478,7 +478,7 @@ std::unique_ptr<Response> message(Response::CreateEmpty()); MessageWriter writer(message.get()); - Property<std::unordered_map<std::string, std::vector<uint8_t>>> test_property; + Property<std::map<std::string, std::vector<uint8_t>>> test_property; test_property.ReplaceSetValueForTesting(test_map); test_property.AppendSetValueToWriter(&writer); @@ -516,7 +516,7 @@ writer.CloseContainer(&variant_writer); MessageReader reader(message.get()); - Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> test_property; + Property<std::map<uint16_t, std::vector<uint8_t>>> test_property; EXPECT_TRUE(test_property.PopValueFromReader(&reader)); ASSERT_EQ(arraysize(keys), test_property.value().size()); @@ -525,7 +525,7 @@ } TEST(PropertyTestStatic, SerializeUInt16ToByteVectorMap) { - std::unordered_map<uint16_t, std::vector<uint8_t>> test_map; + std::map<uint16_t, std::vector<uint8_t>> test_map; test_map[11] = {1, 2, 3}; test_map[12] = {0xab, 0xcd}; test_map[13] = {0x0}; @@ -533,7 +533,7 @@ std::unique_ptr<Response> message(Response::CreateEmpty()); MessageWriter writer(message.get()); - Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> test_property; + Property<std::map<uint16_t, std::vector<uint8_t>>> test_property; test_property.ReplaceSetValueForTesting(test_map); test_property.AppendSetValueToWriter(&writer);
diff --git a/device/bluetooth/dbus/bluetooth_device_client.h b/device/bluetooth/dbus/bluetooth_device_client.h index 921c70c..a7313ba 100644 --- a/device/bluetooth/dbus/bluetooth_device_client.h +++ b/device/bluetooth/dbus/bluetooth_device_client.h
@@ -7,8 +7,8 @@ #include <stdint.h> +#include <map> #include <string> -#include <unordered_map> #include <vector> #include "base/callback.h" @@ -111,13 +111,11 @@ // Manufacturer specific advertisement data. Keys are 16 bits Manufacturer // ID followed by its byte array value. Read-only. - dbus::Property<std::unordered_map<uint16_t, std::vector<uint8_t>>> - manufacturer_data; + dbus::Property<std::map<uint16_t, std::vector<uint8_t>>> manufacturer_data; // Service advertisement data. Keys are the UUIDs in string format followed // by its byte array value. Read-only. - dbus::Property<std::unordered_map<std::string, std::vector<uint8_t>>> - service_data; + dbus::Property<std::map<std::string, std::vector<uint8_t>>> service_data; // Indicate whether or not service discovery has been resolved. Read-only. dbus::Property<bool> services_resolved;
diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.cc b/device/bluetooth/dbus/fake_bluetooth_device_client.cc index 3727d1d..5cdc4d0 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.cc +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.cc
@@ -1562,9 +1562,8 @@ void FakeBluetoothDeviceClient::UpdateServiceAndManufacturerData( const dbus::ObjectPath& object_path, const std::vector<std::string>& service_uuids, - const std::unordered_map<std::string, std::vector<uint8_t>>& service_data, - const std::unordered_map<uint16_t, std::vector<uint8_t>>& - manufacturer_data) { + const std::map<std::string, std::vector<uint8_t>>& service_data, + const std::map<uint16_t, std::vector<uint8_t>>& manufacturer_data) { PropertiesMap::const_iterator iter = properties_map_.find(object_path); if (iter == properties_map_.end()) { VLOG(2) << "Fake device does not exist: " << object_path.value(); @@ -1586,13 +1585,13 @@ properties->uuids.value().end()); properties->uuids.ReplaceValue(merged_uuids); - std::unordered_map<std::string, std::vector<uint8_t>> merged_service_data = + std::map<std::string, std::vector<uint8_t>> merged_service_data = service_data; merged_service_data.insert(properties->service_data.value().begin(), properties->service_data.value().end()); properties->service_data.ReplaceValue(merged_service_data); - std::unordered_map<uint16_t, std::vector<uint8_t>> merged_manufacturer_data = + std::map<uint16_t, std::vector<uint8_t>> merged_manufacturer_data = manufacturer_data; merged_manufacturer_data.insert(properties->manufacturer_data.value().begin(), properties->manufacturer_data.value().end()); @@ -1825,9 +1824,8 @@ const std::string device_address, const std::vector<std::string>& service_uuids, device::BluetoothTransport type, - const std::unordered_map<std::string, std::vector<uint8_t>>& service_data, - const std::unordered_map<uint16_t, std::vector<uint8_t>>& - manufacturer_data) { + const std::map<std::string, std::vector<uint8_t>>& service_data, + const std::map<uint16_t, std::vector<uint8_t>>& manufacturer_data) { // Create a random device path. dbus::ObjectPath device_path; std::string id;
diff --git a/device/bluetooth/dbus/fake_bluetooth_device_client.h b/device/bluetooth/dbus/fake_bluetooth_device_client.h index cdeaa65..c29b93a 100644 --- a/device/bluetooth/dbus/fake_bluetooth_device_client.h +++ b/device/bluetooth/dbus/fake_bluetooth_device_client.h
@@ -167,9 +167,8 @@ const std::string device_address, const std::vector<std::string>& service_uuids, device::BluetoothTransport type, - const std::unordered_map<std::string, std::vector<uint8_t>>& service_data, - const std::unordered_map<uint16_t, std::vector<uint8_t>>& - manufacturer_data); + const std::map<std::string, std::vector<uint8_t>>& service_data, + const std::map<uint16_t, std::vector<uint8_t>>& manufacturer_data); void set_delay_start_discovery(bool value) { delay_start_discovery_ = value; } @@ -184,9 +183,8 @@ void UpdateServiceAndManufacturerData( const dbus::ObjectPath& object_path, const std::vector<std::string>& service_uuids, - const std::unordered_map<std::string, std::vector<uint8_t>>& service_data, - const std::unordered_map<uint16_t, std::vector<uint8_t>>& - manufacturer_data); + const std::map<std::string, std::vector<uint8_t>>& service_data, + const std::map<uint16_t, std::vector<uint8_t>>& manufacturer_data); static const char kTestPinCode[]; static const int kTestPassKey;
diff --git a/device/bluetooth/test/bluetooth_test_bluez.cc b/device/bluetooth/test/bluetooth_test_bluez.cc index 923431e..42663f3 100644 --- a/device/bluetooth/test/bluetooth_test_bluez.cc +++ b/device/bluetooth/test/bluetooth_test_bluez.cc
@@ -122,8 +122,8 @@ std::string device_address = kTestDeviceAddress1; std::vector<std::string> service_uuids; BluetoothTransport device_type = BLUETOOTH_TRANSPORT_LE; - std::unordered_map<std::string, std::vector<uint8_t>> service_data; - std::unordered_map<uint16_t, std::vector<uint8_t>> manufacturer_data; + std::map<std::string, std::vector<uint8_t>> service_data; + std::map<uint16_t, std::vector<uint8_t>> manufacturer_data; switch (device_ordinal) { case 1: @@ -180,8 +180,8 @@ std::string device_name = kTestDeviceName; std::string device_address = kTestDeviceAddress3; std::vector<std::string> service_uuids; - std::unordered_map<std::string, std::vector<uint8_t>> service_data; - std::unordered_map<uint16_t, std::vector<uint8_t>> manufacturer_data; + std::map<std::string, std::vector<uint8_t>> service_data; + std::map<uint16_t, std::vector<uint8_t>> manufacturer_data; if (!adapter_->GetDevice(device_address)) { fake_bluetooth_device_client_->CreateTestDevice(
diff --git a/device/fido/BUILD.gn b/device/fido/BUILD.gn index 45b8b72..8f5bf66 100644 --- a/device/fido/BUILD.gn +++ b/device/fido/BUILD.gn
@@ -5,7 +5,7 @@ import("//build/config/features.gni") import("//testing/libfuzzer/fuzzer_test.gni") -source_set("fido") { +component("fido") { sources = [ "attestation_object.cc", "attestation_object.h", @@ -90,19 +90,23 @@ "u2f_transport_protocol.h", ] + defines = [ "IS_DEVICE_FIDO_IMPL" ] + deps = [ - "//base", "//components/cbor", "//crypto", "//device/base", - "//device/bluetooth", - "//net", - "//services/device/public/mojom", "//services/service_manager/public/cpp", "//services/service_manager/public/mojom", "//third_party/boringssl", ] + public_deps = [ + "//base", + "//device/bluetooth", + "//services/device/public/mojom", + ] + # HID is not supported on Android. if (!is_android) { sources += [ @@ -144,7 +148,6 @@ ] deps = [ ":fido", - "//net", ] libfuzzer_options = [ "max_len=65537" ] } @@ -166,7 +169,6 @@ ] deps = [ ":fido", - "//net", ] libfuzzer_options = [ "max_len=65535" ] } @@ -178,7 +180,6 @@ deps = [ ":fido", "//base", - "//net", ] seed_corpus = "response_data_fuzzer_corpus/" libfuzzer_options = [ "max_len=65537" ] @@ -190,7 +191,6 @@ ] deps = [ ":fido", - "//net", ] seed_corpus = "response_data_fuzzer_corpus/" @@ -215,6 +215,8 @@ source_set("test_support") { testonly = true sources = [ + "fake_u2f_device.cc", + "fake_u2f_device.h", "fake_u2f_discovery.cc", "fake_u2f_discovery.h", "test_callback_receiver.h",
diff --git a/device/fido/attestation_object.h b/device/fido/attestation_object.h index 90198e3..12b173c 100644 --- a/device/fido/attestation_object.h +++ b/device/fido/attestation_object.h
@@ -9,6 +9,7 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "device/fido/authenticator_data.h" @@ -19,7 +20,7 @@ // Object containing the authenticator-provided attestation every time // a credential is created, per // https://www.w3.org/TR/2017/WD-webauthn-20170505/#cred-attestation. -class AttestationObject { +class COMPONENT_EXPORT(DEVICE_FIDO) AttestationObject { public: AttestationObject(AuthenticatorData data, std::unique_ptr<AttestationStatement> statement);
diff --git a/device/fido/attestation_statement.h b/device/fido/attestation_statement.h index db7fc795..8593e911 100644 --- a/device/fido/attestation_statement.h +++ b/device/fido/attestation_statement.h
@@ -5,6 +5,9 @@ #ifndef DEVICE_FIDO_ATTESTATION_STATEMENT_H_ #define DEVICE_FIDO_ATTESTATION_STATEMENT_H_ +#include <string> + +#include "base/component_export.h" #include "base/macros.h" #include "components/cbor/cbor_values.h" @@ -17,7 +20,7 @@ // - The set of attestation types supported by the format. // - The syntax of an attestation statement produced in this format. // https://www.w3.org/TR/2017/WD-webauthn-20170505/#cred-attestation. -class AttestationStatement { +class COMPONENT_EXPORT(DEVICE_FIDO) AttestationStatement { public: virtual ~AttestationStatement(); @@ -42,7 +45,8 @@ // NoneAttestationStatement represents a “none” attestation, which is used when // attestation information will not be returned. See // https://w3c.github.io/webauthn/#none-attestation -class NoneAttestationStatement : public AttestationStatement { +class COMPONENT_EXPORT(DEVICE_FIDO) NoneAttestationStatement + : public AttestationStatement { public: NoneAttestationStatement();
diff --git a/device/fido/attested_credential_data.h b/device/fido/attested_credential_data.h index 63c7e4d5..cef4a9f 100644 --- a/device/fido/attested_credential_data.h +++ b/device/fido/attested_credential_data.h
@@ -9,6 +9,7 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" #include "base/macros.h" #include "base/optional.h" @@ -18,7 +19,7 @@ class PublicKey; // https://www.w3.org/TR/2017/WD-webauthn-20170505/#sec-attestation-data -class AttestedCredentialData { +class COMPONENT_EXPORT(DEVICE_FIDO) AttestedCredentialData { public: static base::Optional<AttestedCredentialData> CreateFromU2fRegisterResponse( base::span<const uint8_t> u2f_data,
diff --git a/device/fido/authenticator_data.h b/device/fido/authenticator_data.h index a4c5059..df94b56 100644 --- a/device/fido/authenticator_data.h +++ b/device/fido/authenticator_data.h
@@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "device/fido/attested_credential_data.h" @@ -16,7 +17,7 @@ namespace device { // https://www.w3.org/TR/2017/WD-webauthn-20170505/#sec-authenticator-data. -class AuthenticatorData { +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorData { public: enum class Flag : uint8_t { kTestOfUserPresence = 1u << 0,
diff --git a/device/fido/authenticator_get_assertion_response.h b/device/fido/authenticator_get_assertion_response.h index 30a979a..7ad1579b 100644 --- a/device/fido/authenticator_get_assertion_response.h +++ b/device/fido/authenticator_get_assertion_response.h
@@ -9,6 +9,7 @@ #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "device/fido/ctap_constants.h" @@ -20,7 +21,7 @@ // Represents response from authenticators for AuthenticatorGetAssertion and // AuthenticatorGetNextAssertion requests. // https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#authenticatorGetAssertion -class AuthenticatorGetAssertionResponse { +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetAssertionResponse { public: AuthenticatorGetAssertionResponse(CtapDeviceResponseCode response_code, std::vector<uint8_t> auth_data,
diff --git a/device/fido/authenticator_get_info_response.h b/device/fido/authenticator_get_info_response.h index 96169c0e..6943f82 100644 --- a/device/fido/authenticator_get_info_response.h +++ b/device/fido/authenticator_get_info_response.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "device/fido/authenticator_supported_options.h" @@ -21,7 +22,7 @@ // versions, options, AAGUID(Authenticator Attestation GUID), other // authenticator device information. // https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#authenticatorGetInfo -class AuthenticatorGetInfoResponse { +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetInfoResponse { public: AuthenticatorGetInfoResponse(CtapDeviceResponseCode response_code, std::vector<std::string> versions,
diff --git a/device/fido/authenticator_make_credential_response.h b/device/fido/authenticator_make_credential_response.h index 5d25fa3..7501d47 100644 --- a/device/fido/authenticator_make_credential_response.h +++ b/device/fido/authenticator_make_credential_response.h
@@ -9,6 +9,7 @@ #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "device/fido/ctap_constants.h" @@ -18,7 +19,7 @@ // data, and attestation statement returned by the authenticator as a response // to MakeCredential request. // https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html#authenticatorMakeCredential -class AuthenticatorMakeCredentialResponse { +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorMakeCredentialResponse { public: AuthenticatorMakeCredentialResponse(CtapDeviceResponseCode response_code, std::vector<uint8_t> attestation_object);
diff --git a/device/fido/authenticator_supported_options.h b/device/fido/authenticator_supported_options.h index 973742d..64eadb6 100644 --- a/device/fido/authenticator_supported_options.h +++ b/device/fido/authenticator_supported_options.h
@@ -5,6 +5,7 @@ #ifndef DEVICE_FIDO_AUTHENTICATOR_SUPPORTED_OPTIONS_H_ #define DEVICE_FIDO_AUTHENTICATOR_SUPPORTED_OPTIONS_H_ +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "components/cbor/cbor_values.h" @@ -13,7 +14,7 @@ // Represents CTAP device properties and capabilities received as a response to // AuthenticatorGetInfo command. -class AuthenticatorSupportedOptions { +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorSupportedOptions { public: AuthenticatorSupportedOptions(); AuthenticatorSupportedOptions(AuthenticatorSupportedOptions&& other);
diff --git a/device/fido/ctap_constants.h b/device/fido/ctap_constants.h index 9f7bcb9..d3767a9 100644 --- a/device/fido/ctap_constants.h +++ b/device/fido/ctap_constants.h
@@ -10,6 +10,8 @@ #include <array> #include <vector> +#include "base/component_export.h" + namespace device { // CTAP protocol device response code, as specified in @@ -164,21 +166,22 @@ // String key values for CTAP request optional parameters and // AuthenticatorGetInfo response. -extern const char kResidentKeyMapKey[]; -extern const char kUserVerificationMapKey[]; -extern const char kUserPresenceMapKey[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kResidentKeyMapKey[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kUserVerificationMapKey[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kUserPresenceMapKey[]; // HID transport specific constants. -extern const size_t kHidPacketSize; -extern const uint32_t kHidBroadcastChannel; -extern const size_t kHidInitPacketHeaderSize; -extern const size_t kHidContinuationPacketHeader; -extern const size_t kHidMaxPacketSize; -extern const size_t kHidInitPacketDataSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidPacketSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const uint32_t kHidBroadcastChannel; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidInitPacketHeaderSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidContinuationPacketHeader; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidMaxPacketSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidInitPacketDataSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidContinuationPacketDataSize; -extern const uint8_t kHidMaxLockSeconds; +COMPONENT_EXPORT(DEVICE_FIDO) extern const uint8_t kHidMaxLockSeconds; // Messages are limited to an initiation packet and 128 continuation packets. -extern const size_t kHidMaxMessageSize; +COMPONENT_EXPORT(DEVICE_FIDO) extern const size_t kHidMaxMessageSize; } // namespace device
diff --git a/device/fido/ctap_empty_authenticator_request.h b/device/fido/ctap_empty_authenticator_request.h index d7285fa..00c897f2 100644 --- a/device/fido/ctap_empty_authenticator_request.h +++ b/device/fido/ctap_empty_authenticator_request.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "device/fido/ctap_constants.h" namespace device { @@ -19,7 +20,7 @@ // Represents CTAP requests with empty parameters, including // AuthenticatorGetInfo, AuthenticatorCancel, AuthenticatorReset and // AuthenticatorGetNextAssertion commands. -class CtapEmptyAuthenticatorRequest { +class COMPONENT_EXPORT(DEVICE_FIDO) CtapEmptyAuthenticatorRequest { public: CtapRequestCommand cmd() const { return cmd_; } std::vector<uint8_t> Serialize() const; @@ -33,7 +34,7 @@ } // namespace internal -class AuthenticatorGetNextAssertionRequest +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetNextAssertionRequest : public internal::CtapEmptyAuthenticatorRequest { public: AuthenticatorGetNextAssertionRequest() @@ -41,7 +42,7 @@ CtapRequestCommand::kAuthenticatorGetNextAssertion) {} }; -class AuthenticatorGetInfoRequest +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetInfoRequest : public internal::CtapEmptyAuthenticatorRequest { public: AuthenticatorGetInfoRequest() @@ -49,7 +50,7 @@ CtapRequestCommand::kAuthenticatorGetInfo) {} }; -class AuthenticatorResetRequest +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorResetRequest : public internal::CtapEmptyAuthenticatorRequest { public: AuthenticatorResetRequest() @@ -57,7 +58,7 @@ } }; -class AuthenticatorCancelRequest +class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorCancelRequest : public internal::CtapEmptyAuthenticatorRequest { public: AuthenticatorCancelRequest()
diff --git a/device/fido/ctap_get_assertion_request.h b/device/fido/ctap_get_assertion_request.h index 84a6a57..382b364 100644 --- a/device/fido/ctap_get_assertion_request.h +++ b/device/fido/ctap_get_assertion_request.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "device/fido/public_key_credential_descriptor.h" @@ -19,7 +20,7 @@ // Object that encapsulates request parameters for AuthenticatorGetAssertion as // specified in the CTAP spec. // https://fidoalliance.org/specs/fido-v2.0-rd-20161004/fido-client-to-authenticator-protocol-v2.0-rd-20161004.html#authenticatorgetassertion -class CtapGetAssertionRequest { +class COMPONENT_EXPORT(DEVICE_FIDO) CtapGetAssertionRequest { public: CtapGetAssertionRequest(std::string rp_id, std::vector<uint8_t> client_data_hash);
diff --git a/device/fido/ctap_make_credential_request.h b/device/fido/ctap_make_credential_request.h index 28fa3e1..09bb87c 100644 --- a/device/fido/ctap_make_credential_request.h +++ b/device/fido/ctap_make_credential_request.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "device/fido/public_key_credential_descriptor.h" @@ -22,7 +23,7 @@ // Object containing request parameters for AuthenticatorMakeCredential command // as specified in // https://fidoalliance.org/specs/fido-v2.0-rd-20170927/fido-client-to-authenticator-protocol-v2.0-rd-20170927.html -class CtapMakeCredentialRequest { +class COMPONENT_EXPORT(DEVICE_FIDO) CtapMakeCredentialRequest { public: CtapMakeCredentialRequest( std::vector<uint8_t> client_data_hash,
diff --git a/device/fido/device_response_converter.h b/device/fido/device_response_converter.h index d1627c61..8f76445 100644 --- a/device/fido/device_response_converter.h +++ b/device/fido/device_response_converter.h
@@ -9,6 +9,7 @@ #include <vector> +#include "base/component_export.h" #include "base/optional.h" #include "device/fido/authenticator_get_assertion_response.h" #include "device/fido/authenticator_get_info_response.h" @@ -22,12 +23,14 @@ // Parses response code from response received from the authenticator. If // unknown response code value is received, then CTAP2_ERR_OTHER is returned. +COMPONENT_EXPORT(DEVICE_FIDO) CtapDeviceResponseCode GetResponseCode(const std::vector<uint8_t>& buffer); // De-serializes CBOR encoded response, checks for valid CBOR map formatting, // and converts response to AuthenticatorMakeCredentialResponse object with // CBOR map keys that conform to format of attestation object defined by the // WebAuthN spec : https://w3c.github.io/webauthn/#fig-attStructs +COMPONENT_EXPORT(DEVICE_FIDO) base::Optional<AuthenticatorMakeCredentialResponse> ReadCTAPMakeCredentialResponse(CtapDeviceResponseCode response_code, const std::vector<uint8_t>& buffer); @@ -35,12 +38,14 @@ // De-serializes CBOR encoded response to AuthenticatorGetAssertion / // AuthenticatorGetNextAssertion request to AuthenticatorGetAssertionResponse // object. +COMPONENT_EXPORT(DEVICE_FIDO) base::Optional<AuthenticatorGetAssertionResponse> ReadCTAPGetAssertionResponse( CtapDeviceResponseCode response_code, const std::vector<uint8_t>& buffer); // De-serializes CBOR encoded response to AuthenticatorGetInfo request to // AuthenticatorGetInfoResponse object. +COMPONENT_EXPORT(DEVICE_FIDO) base::Optional<AuthenticatorGetInfoResponse> ReadCTAPGetInfoResponse( CtapDeviceResponseCode response_code, const std::vector<uint8_t>& buffer);
diff --git a/device/fido/ec_public_key.h b/device/fido/ec_public_key.h index 39734fa..962032a 100644 --- a/device/fido/ec_public_key.h +++ b/device/fido/ec_public_key.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" #include "base/macros.h" #include "device/fido/public_key.h" @@ -19,7 +20,7 @@ // An uncompressed ECPublicKey consisting of 64 bytes: // - the 32-byte x coordinate // - the 32-byte y coordinate. -class ECPublicKey : public PublicKey { +class COMPONENT_EXPORT(DEVICE_FIDO) ECPublicKey : public PublicKey { public: static std::unique_ptr<ECPublicKey> ExtractFromU2fRegistrationResponse( std::string algorithm,
diff --git a/device/fido/fake_hid_impl_for_testing.h b/device/fido/fake_hid_impl_for_testing.h index f9832c0..40427f1b 100644 --- a/device/fido/fake_hid_impl_for_testing.h +++ b/device/fido/fake_hid_impl_for_testing.h
@@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/containers/span.h" +#include "base/macros.h" #include "base/memory/ptr_util.h" #include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/interface_ptr_set.h" @@ -56,6 +57,8 @@ device::mojom::HidDeviceInfoPtr device_; std::vector<uint8_t> nonce_; std::vector<uint8_t> connection_channel_id_; + + DISALLOW_COPY_AND_ASSIGN(MockHidConnection); }; class FakeHidConnection : public device::mojom::HidConnection { @@ -79,6 +82,8 @@ private: device::mojom::HidDeviceInfoPtr device_; + + DISALLOW_COPY_AND_ASSIGN(FakeHidConnection); }; class FakeHidManager : public device::mojom::HidManager { @@ -105,6 +110,8 @@ std::map<std::string, device::mojom::HidConnectionPtr> connections_; mojo::AssociatedInterfacePtrSet<device::mojom::HidManagerClient> clients_; mojo::BindingSet<device::mojom::HidManager> bindings_; + + DISALLOW_COPY_AND_ASSIGN(FakeHidManager); }; } // namespace device
diff --git a/device/fido/fake_u2f_device.cc b/device/fido/fake_u2f_device.cc new file mode 100644 index 0000000..67ece10 --- /dev/null +++ b/device/fido/fake_u2f_device.cc
@@ -0,0 +1,319 @@ +// Copyright 2018 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 "device/fido/fake_u2f_device.h" + +#include <utility> + +#include "crypto/ec_private_key.h" +#include "crypto/ec_signature_creator.h" +#include "crypto/sha2.h" +#include "device/fido/u2f_apdu_command.h" + +namespace device { +namespace test { + +namespace { + +// First byte of registration response is 0x05 for historical reasons +// not detailed in the spec. +constexpr uint8_t kU2fRegistrationResponseHeader = 0x05; + +// The example attestation private key from the U2F spec at +// https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#registration-example +// +// PKCS.8 encoded without encryption. +constexpr uint8_t kAttestationKey[]{ + 0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x03, 0x01, 0x07, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20, + 0xf3, 0xfc, 0xcc, 0x0d, 0x00, 0xd8, 0x03, 0x19, 0x54, 0xf9, 0x08, 0x64, + 0xd4, 0x3c, 0x24, 0x7f, 0x4b, 0xf5, 0xf0, 0x66, 0x5c, 0x6b, 0x50, 0xcc, + 0x17, 0x74, 0x9a, 0x27, 0xd1, 0xcf, 0x76, 0x64, 0xa1, 0x44, 0x03, 0x42, + 0x00, 0x04, 0x8d, 0x61, 0x7e, 0x65, 0xc9, 0x50, 0x8e, 0x64, 0xbc, 0xc5, + 0x67, 0x3a, 0xc8, 0x2a, 0x67, 0x99, 0xda, 0x3c, 0x14, 0x46, 0x68, 0x2c, + 0x25, 0x8c, 0x46, 0x3f, 0xff, 0xdf, 0x58, 0xdf, 0xd2, 0xfa, 0x3e, 0x6c, + 0x37, 0x8b, 0x53, 0xd7, 0x95, 0xc4, 0xa4, 0xdf, 0xfb, 0x41, 0x99, 0xed, + 0xd7, 0x86, 0x2f, 0x23, 0xab, 0xaf, 0x02, 0x03, 0xb4, 0xb8, 0x91, 0x1b, + 0xa0, 0x56, 0x99, 0x94, 0xe1, 0x01}; + +// The corresponding example attestation certificate from the spec. +constexpr uint8_t kAttestationCert[]{ + 0x30, 0x82, 0x01, 0x3c, 0x30, 0x81, 0xe4, 0xa0, 0x03, 0x02, 0x01, 0x02, + 0x02, 0x0a, 0x47, 0x90, 0x12, 0x80, 0x00, 0x11, 0x55, 0x95, 0x73, 0x52, + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, + 0x30, 0x17, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, + 0x0c, 0x47, 0x6e, 0x75, 0x62, 0x62, 0x79, 0x20, 0x50, 0x69, 0x6c, 0x6f, + 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x32, 0x30, 0x38, 0x31, 0x34, 0x31, + 0x38, 0x32, 0x39, 0x33, 0x32, 0x5a, 0x17, 0x0d, 0x31, 0x33, 0x30, 0x38, + 0x31, 0x34, 0x31, 0x38, 0x32, 0x39, 0x33, 0x32, 0x5a, 0x30, 0x31, 0x31, + 0x2f, 0x30, 0x2d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x26, 0x50, 0x69, + 0x6c, 0x6f, 0x74, 0x47, 0x6e, 0x75, 0x62, 0x62, 0x79, 0x2d, 0x30, 0x2e, + 0x34, 0x2e, 0x31, 0x2d, 0x34, 0x37, 0x39, 0x30, 0x31, 0x32, 0x38, 0x30, + 0x30, 0x30, 0x31, 0x31, 0x35, 0x35, 0x39, 0x35, 0x37, 0x33, 0x35, 0x32, + 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, + 0x42, 0x00, 0x04, 0x8d, 0x61, 0x7e, 0x65, 0xc9, 0x50, 0x8e, 0x64, 0xbc, + 0xc5, 0x67, 0x3a, 0xc8, 0x2a, 0x67, 0x99, 0xda, 0x3c, 0x14, 0x46, 0x68, + 0x2c, 0x25, 0x8c, 0x46, 0x3f, 0xff, 0xdf, 0x58, 0xdf, 0xd2, 0xfa, 0x3e, + 0x6c, 0x37, 0x8b, 0x53, 0xd7, 0x95, 0xc4, 0xa4, 0xdf, 0xfb, 0x41, 0x99, + 0xed, 0xd7, 0x86, 0x2f, 0x23, 0xab, 0xaf, 0x02, 0x03, 0xb4, 0xb8, 0x91, + 0x1b, 0xa0, 0x56, 0x99, 0x94, 0xe1, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, + 0x02, 0x20, 0x60, 0xcd, 0xb6, 0x06, 0x1e, 0x9c, 0x22, 0x26, 0x2d, 0x1a, + 0xac, 0x1d, 0x96, 0xd8, 0xc7, 0x08, 0x29, 0xb2, 0x36, 0x65, 0x31, 0xdd, + 0xa2, 0x68, 0x83, 0x2c, 0xb8, 0x36, 0xbc, 0xd3, 0x0d, 0xfa, 0x02, 0x20, + 0x63, 0x1b, 0x14, 0x59, 0xf0, 0x9e, 0x63, 0x30, 0x05, 0x57, 0x22, 0xc8, + 0xd8, 0x9b, 0x7f, 0x48, 0x88, 0x3b, 0x90, 0x89, 0xb8, 0x8d, 0x60, 0xd1, + 0xd9, 0x79, 0x59, 0x02, 0xb3, 0x04, 0x10, 0xdf}; + +std::vector<uint8_t> GetAttestationKey() { + return std::vector<uint8_t>(std::begin(kAttestationKey), + std::end(kAttestationKey)); +} + +// Small helper to make the code below more readable. +template <class T> +void AppendTo(std::vector<uint8_t>* dst, const T& src) { + dst->insert(dst->end(), std::begin(src), std::end(src)); +} + +} // namespace + +FakeU2fDevice::RegistrationData::RegistrationData() = default; + +FakeU2fDevice::RegistrationData::RegistrationData( + std::unique_ptr<crypto::ECPrivateKey> private_key, + std::vector<uint8_t> app_id_hash, + uint32_t counter) + : private_key(std::move(private_key)), + app_id_hash(std::move(app_id_hash)), + counter(counter) {} + +FakeU2fDevice::RegistrationData::RegistrationData(RegistrationData&& data) = + default; +FakeU2fDevice::RegistrationData& FakeU2fDevice::RegistrationData::operator=( + RegistrationData&& other) = default; +FakeU2fDevice::RegistrationData::~RegistrationData() = default; + +FakeU2fDevice::FakeU2fDevice() + : attestation_private_key_( + crypto::ECPrivateKey::CreateFromPrivateKeyInfo(GetAttestationKey())), + attestation_cert_(std::begin(kAttestationCert), + std::end(kAttestationCert)), + weak_factory_(this) { + DCHECK(attestation_private_key_); +} + +FakeU2fDevice::~FakeU2fDevice() = default; + +void FakeU2fDevice::TryWink(WinkCallback cb) { + std::move(cb).Run(); +} + +std::string FakeU2fDevice::GetId() const { + // Use our heap address to get a unique-ish number. (0xffe1 is a prime). + return "FakeU2fDevice-" + std::to_string((size_t)this % 0xffe1); +} + +void FakeU2fDevice::AddRegistration( + std::vector<uint8_t> key_handle, + std::unique_ptr<crypto::ECPrivateKey> private_key, + std::vector<uint8_t> app_id_hash, + uint32_t counter) { + registrations_[std::move(key_handle)] = + RegistrationData(std::move(private_key), std::move(app_id_hash), counter); +} + +void FakeU2fDevice::DeviceTransact(std::vector<uint8_t> command, + DeviceCallback cb) { + // Note, here we are using the code-under-test in this fake. + auto parsed_command = U2fApduCommand::CreateFromMessage(command); + switch (parsed_command->ins_) { + case U2fApduCommand::kInsU2fVersion: + break; + case U2fApduCommand::kInsU2fEnroll: + DoRegister(parsed_command->ins_, parsed_command->p1_, parsed_command->p2_, + parsed_command->data_, std::move(cb)); + break; + case U2fApduCommand::kInsU2fSign: + DoSign(parsed_command->ins_, parsed_command->p1_, parsed_command->p2_, + parsed_command->data_, std::move(cb)); + break; + default: + std::move(cb).Run(true, + std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_INS_NOT_SUPPORTED)); + } +} + +base::WeakPtr<U2fDevice> FakeU2fDevice::GetWeakPtr() { + return weak_factory_.GetWeakPtr(); +} + +void FakeU2fDevice::DoRegister(uint8_t ins, + uint8_t p1, + uint8_t p2, + base::span<const uint8_t> data, + DeviceCallback cb) { + if (data.size() != 64) { + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_LENGTH)); + return; + } + + // For now we ignore P1 here. Spec says it should always be 0, and TUP is + // implied for registration. However Chrome does send TUP (0x03) and sometimes + // adds in the propietary request for an individual attestation cert. + + auto challenge_param = data.first(32); + auto app_id_hash = data.last(32); + + // Create key to register. + // Note: Non-deterministic, you need to mock this out if you rely on + // deterministic behavior. + auto private_key = crypto::ECPrivateKey::Create(); + std::string public_key; + bool status = private_key->ExportRawPublicKey(&public_key); + DCHECK(status); + public_key.insert(0, 1, 0x04); + DCHECK_EQ(public_key.size(), 65ul); + + // Our key handles are simple hashes of the public key. + std::vector<uint8_t> key_handle(32); + crypto::SHA256HashString(public_key, key_handle.data(), key_handle.size()); + + // Data to be signed. + std::vector<uint8_t> sign_buffer; + sign_buffer.reserve(1 + app_id_hash.size() + challenge_param.size() + + key_handle.size() + public_key.size()); + sign_buffer.push_back(0x00); + AppendTo(&sign_buffer, app_id_hash); + AppendTo(&sign_buffer, challenge_param); + AppendTo(&sign_buffer, key_handle); + AppendTo(&sign_buffer, public_key); + + // Sign with attestation key. + // Note: Non-deterministic, you need to mock this out if you rely on + // deterministic behavior. + std::vector<uint8_t> sig; + auto signer = + crypto::ECSignatureCreator::Create(attestation_private_key_.get()); + status = signer->Sign(sign_buffer.data(), sign_buffer.size(), &sig); + DCHECK(status); + + // U2F response data. + std::vector<uint8_t> response; + response.reserve(1 + public_key.size() + 1 + key_handle.size() + + attestation_cert_.size() + sig.size()); + response.push_back(kU2fRegistrationResponseHeader); + AppendTo(&response, public_key); + response.push_back(key_handle.size()); + AppendTo(&response, key_handle); + AppendTo(&response, attestation_cert_); + AppendTo(&response, sig); + + // Store the registration. + AddRegistration(std::move(key_handle), std::move(private_key), + std::vector<uint8_t>(app_id_hash.begin(), app_id_hash.end()), + 1); + + std::move(cb).Run( + true, std::make_unique<U2fApduResponse>( + std::move(response), U2fApduResponse::Status::SW_NO_ERROR)); +} + +void FakeU2fDevice::DoSign(uint8_t ins, + uint8_t p1, + uint8_t p2, + base::span<const uint8_t> data, + DeviceCallback cb) { + if (!(p1 == U2fApduCommand::kP1CheckOnly || + p1 == U2fApduCommand::kP1TupRequiredConsumed || + p1 == U2fApduCommand::kP1IndividualAttestation) || + p2 != 0) { + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_DATA)); + return; + } + + auto challenge_param = data.first(32); + auto app_id_hash = data.subspan(32, 32); + size_t key_handle_length = data[64]; + if (key_handle_length != 32) { + // Our own keyhandles are always 32 bytes long, if the request has something + // else then we already know it is not ours. + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_DATA)); + return; + } + if (data.size() != 32 + 32 + 1 + key_handle_length) { + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_LENGTH)); + return; + } + auto key_handle = data.last(key_handle_length); + + // Check if this is our key_handle and it's for this appId. + auto it = registrations_.find( + std::vector<uint8_t>(key_handle.cbegin(), key_handle.cend())); + + if (it == registrations_.end()) { + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_DATA)); + return; + } + + base::span<const uint8_t> registered_app_id_hash = + base::make_span(it->second.app_id_hash); + if (app_id_hash != registered_app_id_hash) { + // It's important this error looks identical to the previous one, as + // tokens should not reveal the existence of keyHandles to unrelated appIds. + std::move(cb).Run(true, std::make_unique<U2fApduResponse>( + std::vector<uint8_t>(), + U2fApduResponse::Status::SW_WRONG_DATA)); + return; + } + + auto& registration = it->second; + ++registration.counter; + + // First create the part of the response that gets signed over. + std::vector<uint8_t> response; + response.push_back(0x01); // Always pretend we got a touch. + response.push_back(registration.counter >> 24); + response.push_back(registration.counter >> 16); + response.push_back(registration.counter >> 8); + response.push_back(registration.counter); + + std::vector<uint8_t> sign_buffer; + sign_buffer.reserve(app_id_hash.size() + response.size() + + challenge_param.size()); + AppendTo(&sign_buffer, app_id_hash); + AppendTo(&sign_buffer, response); + AppendTo(&sign_buffer, challenge_param); + + // Sign with credential key. + std::vector<uint8_t> sig; + auto signer = + crypto::ECSignatureCreator::Create(registration.private_key.get()); + bool status = signer->Sign(sign_buffer.data(), sign_buffer.size(), &sig); + DCHECK(status); + + // Add signature for full response. + AppendTo(&response, sig); + + std::move(cb).Run( + true, std::make_unique<U2fApduResponse>( + std::move(response), U2fApduResponse::Status::SW_NO_ERROR)); +} + +} // namespace test +} // namespace device
diff --git a/device/fido/fake_u2f_device.h b/device/fido/fake_u2f_device.h new file mode 100644 index 0000000..6c86d47ec --- /dev/null +++ b/device/fido/fake_u2f_device.h
@@ -0,0 +1,86 @@ +// Copyright 2018 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 DEVICE_FIDO_FAKE_U2F_DEVICE_H_ +#define DEVICE_FIDO_FAKE_U2F_DEVICE_H_ + +#include <stdint.h> + +#include <map> +#include <memory> +#include <string> +#include <vector> + +#include "base/containers/span.h" +#include "base/macros.h" +#include "device/fido/u2f_device.h" + +namespace crypto { +class ECPrivateKey; +} // namespace crypto + +namespace device { +namespace test { + +class FakeU2fDevice : public U2fDevice { + public: + FakeU2fDevice(); + ~FakeU2fDevice() override; + + void AddRegistration(std::vector<uint8_t> key_handle, + std::unique_ptr<crypto::ECPrivateKey> private_key, + std::vector<uint8_t> app_id_hash, + uint32_t counter); + + protected: + // U2fDevice: + void TryWink(WinkCallback cb) override; + std::string GetId() const override; + void DeviceTransact(std::vector<uint8_t> command, DeviceCallback cb) override; + base::WeakPtr<U2fDevice> GetWeakPtr() override; + + private: + struct RegistrationData { + RegistrationData(); + RegistrationData(std::unique_ptr<crypto::ECPrivateKey> private_key, + std::vector<uint8_t> app_id_hash, + uint32_t counter); + RegistrationData(RegistrationData&& data); + + RegistrationData& operator=(RegistrationData&& other); + ~RegistrationData(); + + std::unique_ptr<crypto::ECPrivateKey> private_key; + std::vector<uint8_t> app_id_hash; + uint32_t counter = 0; + + DISALLOW_COPY_AND_ASSIGN(RegistrationData); + }; + + void DoRegister(uint8_t ins, + uint8_t p1, + uint8_t p2, + base::span<const uint8_t> data, + DeviceCallback cb); + + void DoSign(uint8_t ins, + uint8_t p1, + uint8_t p2, + base::span<const uint8_t> data, + DeviceCallback cb); + + std::unique_ptr<crypto::ECPrivateKey> attestation_private_key_; + std::vector<uint8_t> attestation_cert_; + + // Keyed on appId/rpId hash (aka "applicationParam") + std::map<std::vector<uint8_t>, RegistrationData> registrations_; + base::WeakPtrFactory<U2fDevice> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(FakeU2fDevice); +}; + +} // namespace test +} // namespace device + +#endif // DEVICE_FIDO_FAKE_U2F_DEVICE_H_
diff --git a/device/fido/fido_attestation_statement.h b/device/fido/fido_attestation_statement.h index 55e4ab7e..a817b72b 100644 --- a/device/fido/fido_attestation_statement.h +++ b/device/fido/fido_attestation_statement.h
@@ -9,6 +9,7 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" #include "base/macros.h" #include "components/cbor/cbor_values.h" @@ -17,7 +18,8 @@ namespace device { // https://www.w3.org/TR/2017/WD-webauthn-20170505/#fido-u2f-attestation -class FidoAttestationStatement : public AttestationStatement { +class COMPONENT_EXPORT(DEVICE_FIDO) FidoAttestationStatement + : public AttestationStatement { public: static std::unique_ptr<FidoAttestationStatement> CreateFromU2fRegisterResponse(base::span<const uint8_t> u2f_data);
diff --git a/device/fido/fido_hid_message.h b/device/fido/fido_hid_message.h index cb182a3..25b25a5 100644 --- a/device/fido/fido_hid_message.h +++ b/device/fido/fido_hid_message.h
@@ -12,9 +12,11 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/containers/circular_deque.h" #include "base/containers/queue.h" #include "base/containers/span.h" +#include "base/macros.h" #include "device/fido/ctap_constants.h" #include "device/fido/fido_hid_packet.h" @@ -22,7 +24,7 @@ // Represents HID message format defined by the specification at // https://fidoalliance.org/specs/fido-v2.0-rd-20161004/fido-client-to-authenticator-protocol-v2.0-rd-20161004.html#message-and-packet-structure -class FidoHidMessage { +class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidMessage { public: // Static functions to create CTAP/U2F HID commands. static std::unique_ptr<FidoHidMessage> Create(uint32_t channel_id, @@ -61,6 +63,8 @@ CtapHidDeviceCommand cmd_ = CtapHidDeviceCommand::kCtapHidMsg; base::circular_deque<std::unique_ptr<FidoHidPacket>> packets_; size_t remaining_size_ = 0; + + DISALLOW_COPY_AND_ASSIGN(FidoHidMessage); }; } // namespace device
diff --git a/device/fido/fido_hid_packet.h b/device/fido/fido_hid_packet.h index c8d9d89..400d8bc 100644 --- a/device/fido/fido_hid_packet.h +++ b/device/fido/fido_hid_packet.h
@@ -11,7 +11,9 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" +#include "base/macros.h" #include "device/fido/ctap_constants.h" namespace device { @@ -22,7 +24,7 @@ // packets. HID Packets have header information and a payload. If a // FidoHidInitPacket cannot store the entire payload, further payload // information is stored in HidContinuationPackets. -class FidoHidPacket { +class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidPacket { public: FidoHidPacket(std::vector<uint8_t> data, uint32_t channel_id); virtual ~FidoHidPacket(); @@ -39,6 +41,8 @@ private: friend class HidMessage; + + DISALLOW_COPY_AND_ASSIGN(FidoHidPacket); }; // FidoHidInitPacket, based on the CTAP specification consists of a header with @@ -47,7 +51,7 @@ // determine the type of message the packet corresponds to. Payload length // is the length of the entire message payload, and the data is only the portion // of the payload that will fit into the HidInitPacket. -class FidoHidInitPacket : public FidoHidPacket { +class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidInitPacket : public FidoHidPacket { public: // Creates a packet from the serialized data of an initialization packet. As // this is the first packet, the payload length of the entire message will be @@ -70,6 +74,8 @@ private: CtapHidDeviceCommand command_; uint16_t payload_length_; + + DISALLOW_COPY_AND_ASSIGN(FidoHidInitPacket); }; // FidoHidContinuationPacket, based on the CTAP Specification consists of a @@ -77,7 +83,8 @@ // will be identical to the identifier in all other packets of the message. The // packet sequence will be the sequence number of this particular packet, from // 0x00 to 0x7f. -class FidoHidContinuationPacket : public FidoHidPacket { +class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidContinuationPacket + : public FidoHidPacket { public: // Creates a packet from the serialized data of a continuation packet. As an // HidInitPacket would have arrived earlier with the total payload size, @@ -97,6 +104,8 @@ private: uint8_t sequence_; + + DISALLOW_COPY_AND_ASSIGN(FidoHidContinuationPacket); }; } // namespace device
diff --git a/device/fido/mock_u2f_ble_connection.h b/device/fido/mock_u2f_ble_connection.h index 773d73d..7cc33c1 100644 --- a/device/fido/mock_u2f_ble_connection.h +++ b/device/fido/mock_u2f_ble_connection.h
@@ -8,6 +8,8 @@ #include <string> #include <vector> +#include "base/component_export.h" +#include "base/macros.h" #include "device/fido/u2f_ble_connection.h" #include "testing/gmock/include/gmock/gmock.h" @@ -45,6 +47,8 @@ private: ConnectionStatusCallback connection_status_callback_; ReadCallback read_callback_; + + DISALLOW_COPY_AND_ASSIGN(MockU2fBleConnection); }; } // namespace device
diff --git a/device/fido/mock_u2f_device.h b/device/fido/mock_u2f_device.h index fc2f802..418598a 100644 --- a/device/fido/mock_u2f_device.h +++ b/device/fido/mock_u2f_device.h
@@ -11,6 +11,8 @@ #include <string> #include <vector> +#include "base/component_export.h" +#include "base/macros.h" #include "device/fido/u2f_device.h" #include "testing/gmock/include/gmock/gmock.h" @@ -51,6 +53,8 @@ private: base::WeakPtrFactory<U2fDevice> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(MockU2fDevice); }; } // namespace device
diff --git a/device/fido/mock_u2f_discovery_observer.h b/device/fido/mock_u2f_discovery_observer.h index 2b9bfa1..5a2e08d 100644 --- a/device/fido/mock_u2f_discovery_observer.h +++ b/device/fido/mock_u2f_discovery_observer.h
@@ -5,6 +5,8 @@ #ifndef DEVICE_FIDO_MOCK_U2F_DISCOVERY_OBSERVER_H_ #define DEVICE_FIDO_MOCK_U2F_DISCOVERY_OBSERVER_H_ +#include "base/component_export.h" +#include "base/macros.h" #include "device/fido/u2f_discovery.h" #include "testing/gmock/include/gmock/gmock.h" @@ -21,6 +23,9 @@ MOCK_METHOD2(DiscoveryStopped, void(U2fDiscovery*, bool)); MOCK_METHOD2(DeviceAdded, void(U2fDiscovery*, U2fDevice*)); MOCK_METHOD2(DeviceRemoved, void(U2fDiscovery*, U2fDevice*)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockU2fDiscoveryObserver); }; } // namespace device
diff --git a/device/fido/public_key.cc b/device/fido/public_key.cc index 9616a9d5..756a24c 100644 --- a/device/fido/public_key.cc +++ b/device/fido/public_key.cc
@@ -6,8 +6,6 @@ #include <utility> -#include "base/macros.h" - namespace device { PublicKey::~PublicKey() = default;
diff --git a/device/fido/public_key.h b/device/fido/public_key.h index 9c0f087..70cdbc2 100644 --- a/device/fido/public_key.h +++ b/device/fido/public_key.h
@@ -9,12 +9,13 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" namespace device { // https://www.w3.org/TR/2017/WD-webauthn-20170505/#sec-attestation-data. -class PublicKey { +class COMPONENT_EXPORT(DEVICE_FIDO) PublicKey { public: virtual ~PublicKey();
diff --git a/device/fido/public_key_credential_descriptor.h b/device/fido/public_key_credential_descriptor.h index c2b40fe0..d8abac74 100644 --- a/device/fido/public_key_credential_descriptor.h +++ b/device/fido/public_key_credential_descriptor.h
@@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/optional.h" #include "components/cbor/cbor_values.h" @@ -18,7 +19,7 @@ // id (byte array) as specified in the CTAP spec. Used for exclude_list for // AuthenticatorMakeCredential command and allow_list parameter for // AuthenticatorGetAssertion command. -class PublicKeyCredentialDescriptor { +class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialDescriptor { public: static base::Optional<PublicKeyCredentialDescriptor> CreateFromCBORValue( const cbor::CBORValue& cbor);
diff --git a/device/fido/public_key_credential_params.h b/device/fido/public_key_credential_params.h index a1c97ec4..e59d106 100644 --- a/device/fido/public_key_credential_params.h +++ b/device/fido/public_key_credential_params.h
@@ -9,6 +9,7 @@ #include <tuple> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/numerics/safe_conversions.h" #include "components/cbor/cbor_values.h" @@ -19,7 +20,7 @@ // Data structure containing public key credential type(string) and // cryptographic algorithm(integer) as specified by the CTAP spec. Used as a // request parameter for AuthenticatorMakeCredential. -class PublicKeyCredentialParams { +class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialParams { public: struct CredentialInfo { std::string type;
diff --git a/device/fido/public_key_credential_rp_entity.h b/device/fido/public_key_credential_rp_entity.h index 4e44616..5cc004c 100644 --- a/device/fido/public_key_credential_rp_entity.h +++ b/device/fido/public_key_credential_rp_entity.h
@@ -8,6 +8,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/optional.h" #include "components/cbor/cbor_values.h" @@ -18,7 +19,7 @@ // Data structure containing information about relying party that invoked // WebAuth API. Includes a relying party id, an optional relying party name,, // and optional relying party display image url. -class PublicKeyCredentialRpEntity { +class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialRpEntity { public: explicit PublicKeyCredentialRpEntity(std::string rp_id); PublicKeyCredentialRpEntity(PublicKeyCredentialRpEntity&& other);
diff --git a/device/fido/public_key_credential_user_entity.h b/device/fido/public_key_credential_user_entity.h index 0456b1b..17b4c1d 100644 --- a/device/fido/public_key_credential_user_entity.h +++ b/device/fido/public_key_credential_user_entity.h
@@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/optional.h" #include "components/cbor/cbor_values.h" #include "url/gurl.h" @@ -19,7 +20,7 @@ // display image url, and an optional user display name as specified by the CTAP // spec. Used as required parameter type for AuthenticatorMakeCredential // request. -class PublicKeyCredentialUserEntity { +class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialUserEntity { public: static base::Optional<PublicKeyCredentialUserEntity> CreateFromCBORValue( const cbor::CBORValue& cbor);
diff --git a/device/fido/register_response_data.h b/device/fido/register_response_data.h index 8b3d445..664b773 100644 --- a/device/fido/register_response_data.h +++ b/device/fido/register_response_data.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" #include "base/macros.h" #include "base/optional.h" @@ -20,7 +21,7 @@ class AttestationObject; // See figure 2: https://goo.gl/rsgvXk -class RegisterResponseData : public ResponseData { +class COMPONENT_EXPORT(DEVICE_FIDO) RegisterResponseData : public ResponseData { public: static base::Optional<RegisterResponseData> CreateFromU2fRegisterResponse( const std::vector<uint8_t>& relying_party_id_hash,
diff --git a/device/fido/response_data.h b/device/fido/response_data.h index 60ce8651..910f055 100644 --- a/device/fido/response_data.h +++ b/device/fido/response_data.h
@@ -10,12 +10,13 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" namespace device { // Base class for RegisterResponseData and SignResponseData. -class ResponseData { +class COMPONENT_EXPORT(DEVICE_FIDO) ResponseData { public: std::string GetId() const; const std::vector<uint8_t>& raw_id() const { return raw_id_; }
diff --git a/device/fido/sign_response_data.h b/device/fido/sign_response_data.h index cc152c7..c296e911 100644 --- a/device/fido/sign_response_data.h +++ b/device/fido/sign_response_data.h
@@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "device/fido/authenticator_data.h" #include "device/fido/response_data.h" @@ -18,7 +19,7 @@ // Corresponds to a CTAP AuthenticatorGetAssertion response. // See mapping from a U2F response to a CTAP response // at https://goo.gl/eZTacx. -class SignResponseData : public ResponseData { +class COMPONENT_EXPORT(DEVICE_FIDO) SignResponseData : public ResponseData { public: static base::Optional<SignResponseData> CreateFromU2fSignResponse( const std::vector<uint8_t>& relying_party_id_hash,
diff --git a/device/fido/u2f_apdu_command.h b/device/fido/u2f_apdu_command.h index a51b59864..76973dca 100644 --- a/device/fido/u2f_apdu_command.h +++ b/device/fido/u2f_apdu_command.h
@@ -9,10 +9,15 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/gtest_prod_util.h" namespace device { +namespace test { +class FakeU2fDevice; +} + // APDU commands are defined as part of ISO 7816-4. Commands can be serialized // into either short length encodings, where the maximum data length is 256 // bytes, or an extended length encoding, where the maximum data length is 65536 @@ -21,7 +26,7 @@ // byte, denoting the instruction code, P1 and P2, each one byte denoting // instruction parameters, a length field (Lc), a data field of length Lc, and // a maximum expected response length (Le). -class U2fApduCommand { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fApduCommand { public: U2fApduCommand(); U2fApduCommand(uint8_t cla, @@ -72,6 +77,9 @@ FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestCreateVersion); FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestCreateLegacyVersion); + // Built-in software key for testing. + friend class test::FakeU2fDevice; + static constexpr size_t kApduMinHeader = 4; static constexpr size_t kApduMaxHeader = 7; // As defined in ISO7816-4, extended length APDU request data is limited to
diff --git a/device/fido/u2f_apdu_response.h b/device/fido/u2f_apdu_response.h index 8bb37f7..3645389 100644 --- a/device/fido/u2f_apdu_response.h +++ b/device/fido/u2f_apdu_response.h
@@ -8,6 +8,7 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/gtest_prod_util.h" #include "base/memory/ref_counted.h" @@ -16,7 +17,7 @@ // APDU responses are defined as part of ISO 7816-4. Serialized responses // consist of a data field of varying length, up to a maximum 65536, and a // two byte status field. -class U2fApduResponse { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fApduResponse { public: // Status bytes are specified in ISO 7816-4 enum class Status : uint16_t { @@ -24,6 +25,7 @@ SW_CONDITIONS_NOT_SATISFIED = 0x6985, SW_WRONG_DATA = 0x6A80, SW_WRONG_LENGTH = 0x6700, + SW_INS_NOT_SUPPORTED = 0x6d00, }; U2fApduResponse(std::vector<uint8_t> message, Status response_status); @@ -33,8 +35,8 @@ static std::unique_ptr<U2fApduResponse> CreateFromMessage( const std::vector<uint8_t>& data); std::vector<uint8_t> GetEncodedResponse() const; - const std::vector<uint8_t> data() const { return data_; }; - Status status() const { return response_status_; }; + const std::vector<uint8_t> data() const { return data_; } + Status status() const { return response_status_; } private: FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestDeserializeResponse);
diff --git a/device/fido/u2f_ble_connection.h b/device/fido/u2f_ble_connection.h index ac45a15a..6baca9f 100644 --- a/device/fido/u2f_ble_connection.h +++ b/device/fido/u2f_ble_connection.h
@@ -13,6 +13,7 @@ #include <vector> #include "base/callback_forward.h" +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -40,7 +41,8 @@ // // TODO(crbug.com/763303): Add support for pairing from within this class and // provide users with an option to manually specify a PIN code. -class U2fBleConnection : public BluetoothAdapter::Observer { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleConnection + : public BluetoothAdapter::Observer { public: enum class ServiceRevision { VERSION_1_0,
diff --git a/device/fido/u2f_ble_device.h b/device/fido/u2f_ble_device.h index d368cf4..a9409fc9 100644 --- a/device/fido/u2f_ble_device.h +++ b/device/fido/u2f_ble_device.h
@@ -10,6 +10,7 @@ #include <utility> #include <vector> +#include "base/component_export.h" #include "base/containers/queue.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" @@ -24,7 +25,7 @@ class U2fBleFrame; -class U2fBleDevice : public U2fDevice { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleDevice : public U2fDevice { public: using FrameCallback = U2fBleTransaction::FrameCallback; explicit U2fBleDevice(std::string address);
diff --git a/device/fido/u2f_ble_discovery.h b/device/fido/u2f_ble_discovery.h index 35b5340..1aab86f 100644 --- a/device/fido/u2f_ble_discovery.h +++ b/device/fido/u2f_ble_discovery.h
@@ -7,6 +7,8 @@ #include <memory> +#include "base/component_export.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "device/bluetooth/bluetooth_adapter.h" @@ -18,7 +20,9 @@ class BluetoothDiscoverySession; class BluetoothUUID; -class U2fBleDiscovery : public U2fDiscovery, BluetoothAdapter::Observer { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleDiscovery + : public U2fDiscovery, + BluetoothAdapter::Observer { public: U2fBleDiscovery(); ~U2fBleDiscovery() override;
diff --git a/device/fido/u2f_ble_frames.h b/device/fido/u2f_ble_frames.h index 445f40a..5667942 100644 --- a/device/fido/u2f_ble_frames.h +++ b/device/fido/u2f_ble_frames.h
@@ -10,6 +10,7 @@ #include <utility> #include <vector> +#include "base/component_export.h" #include "base/containers/queue.h" #include "base/containers/span.h" #include "base/macros.h" @@ -28,7 +29,7 @@ // https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-bt-protocol-v1.2-ps-20170411.html#h2_framing // // TODO(crbug/763303): Consider refactoring U2fMessage to support BLE frames. -class U2fBleFrame { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleFrame { public: // The values which can be carried in the |data| section of a KEEPALIVE // message sent from an authenticator. @@ -97,7 +98,7 @@ // https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-bt-protocol-v1.2-ps-20170411.html#h2_framing-fragmentation // // Note: This class and its subclasses don't own the |data|. -class U2fBleFrameFragment { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleFrameFragment { public: base::span<const uint8_t> fragment() const { return fragment_; } virtual size_t Serialize(std::vector<uint8_t>* buffer) const = 0; @@ -113,7 +114,8 @@ }; // An initialization fragment of a frame. -class U2fBleFrameInitializationFragment : public U2fBleFrameFragment { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleFrameInitializationFragment + : public U2fBleFrameFragment { public: static bool Parse(base::span<const uint8_t> data, U2fBleFrameInitializationFragment* fragment); @@ -137,7 +139,8 @@ }; // A continuation fragment of a frame. -class U2fBleFrameContinuationFragment : public U2fBleFrameFragment { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleFrameContinuationFragment + : public U2fBleFrameFragment { public: static bool Parse(base::span<const uint8_t> data, U2fBleFrameContinuationFragment* fragment); @@ -156,7 +159,7 @@ }; // The helper used to construct a U2fBleFrame from a sequence of its fragments. -class U2fBleFrameAssembler { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fBleFrameAssembler { public: explicit U2fBleFrameAssembler( const U2fBleFrameInitializationFragment& fragment);
diff --git a/device/fido/u2f_ble_transaction.h b/device/fido/u2f_ble_transaction.h index b0b016e..3f501e55 100644 --- a/device/fido/u2f_ble_transaction.h +++ b/device/fido/u2f_ble_transaction.h
@@ -9,6 +9,7 @@ #include <vector> #include "base/containers/queue.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/optional.h" #include "base/timer/timer.h" @@ -54,6 +55,8 @@ base::OneShotTimer timer_; base::WeakPtrFactory<U2fBleTransaction> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(U2fBleTransaction); }; } // namespace device
diff --git a/device/fido/u2f_ble_uuids.h b/device/fido/u2f_ble_uuids.h index 7beb33b5..919d617 100644 --- a/device/fido/u2f_ble_uuids.h +++ b/device/fido/u2f_ble_uuids.h
@@ -5,6 +5,8 @@ #ifndef DEVICE_FIDO_U2F_BLE_UUIDS_H_ #define DEVICE_FIDO_U2F_BLE_UUIDS_H_ +#include "base/component_export.h" + namespace device { // U2F GATT Service's UUIDs as defined by the standard: @@ -13,11 +15,12 @@ // For details on how the short UUIDs for U2F Service (0xFFFD) and U2F Service // Revision (0x2A28) were converted to the long canonical ones, see // https://www.bluetooth.com/specifications/assigned-numbers/service-discovery -extern const char kU2fServiceUUID[]; -extern const char kU2fControlPointUUID[]; -extern const char kU2fStatusUUID[]; -extern const char kU2fControlPointLengthUUID[]; -extern const char kU2fServiceRevisionUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fServiceUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fControlPointUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fStatusUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fControlPointLengthUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fServiceRevisionUUID[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kU2fServiceRevisionBitfieldUUID[]; } // namespace device
diff --git a/device/fido/u2f_device.h b/device/fido/u2f_device.h index 70eb0c0..bb0b84f 100644 --- a/device/fido/u2f_device.h +++ b/device/fido/u2f_device.h
@@ -10,6 +10,8 @@ #include <vector> #include "base/callback.h" +#include "base/component_export.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "device/fido/u2f_apdu_response.h" #include "device/fido/u2f_return_code.h" @@ -18,7 +20,7 @@ // Device abstraction for an individual U2F device. A U2F device defines the // standardized Register, Sign, and GetVersion methods. -class U2fDevice { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fDevice { public: enum class ProtocolVersion { U2F_V2,
diff --git a/device/fido/u2f_discovery.cc b/device/fido/u2f_discovery.cc index bea7ca4e..ad7bd4f 100644 --- a/device/fido/u2f_discovery.cc +++ b/device/fido/u2f_discovery.cc
@@ -45,6 +45,8 @@ } // namespace +U2fDiscovery::Observer::~Observer() = default; + // static U2fDiscovery::FactoryFuncPtr U2fDiscovery::g_factory_func_ = &CreateU2fDiscoveryImpl;
diff --git a/device/fido/u2f_discovery.h b/device/fido/u2f_discovery.h index bdde75f..a30a2b43 100644 --- a/device/fido/u2f_discovery.h +++ b/device/fido/u2f_discovery.h
@@ -11,6 +11,7 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" @@ -29,11 +30,11 @@ class ScopedU2fDiscoveryFactory; } -class U2fDiscovery { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fDiscovery { public: - class Observer { + class COMPONENT_EXPORT(DEVICE_FIDO) Observer { public: - virtual ~Observer() = default; + virtual ~Observer(); virtual void DiscoveryStarted(U2fDiscovery* discovery, bool success) = 0; virtual void DiscoveryStopped(U2fDiscovery* discovery, bool success) = 0; virtual void DeviceAdded(U2fDiscovery* discovery, U2fDevice* device) = 0; @@ -96,7 +97,7 @@ // While there is a subclass instance in scope, calls to the factory method will // be hijacked such that the derived class's CreateU2fDiscovery method will be // invoked instead. -class ScopedU2fDiscoveryFactory { +class COMPONENT_EXPORT(DEVICE_FIDO) ScopedU2fDiscoveryFactory { public: ScopedU2fDiscoveryFactory(); ~ScopedU2fDiscoveryFactory();
diff --git a/device/fido/u2f_hid_device.h b/device/fido/u2f_hid_device.h index 40ce28e..5bf2438 100644 --- a/device/fido/u2f_hid_device.h +++ b/device/fido/u2f_hid_device.h
@@ -12,6 +12,8 @@ #include <vector> #include "base/cancelable_callback.h" +#include "base/component_export.h" +#include "base/macros.h" #include "device/fido/u2f_device.h" #include "services/device/public/mojom/hid.mojom.h" @@ -19,7 +21,7 @@ class FidoHidMessage; -class U2fHidDevice : public U2fDevice { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fHidDevice : public U2fDevice { public: U2fHidDevice(device::mojom::HidDeviceInfoPtr device_info, device::mojom::HidManager* hid_manager);
diff --git a/device/fido/u2f_hid_discovery.h b/device/fido/u2f_hid_discovery.h index e092089b..48982eab 100644 --- a/device/fido/u2f_hid_discovery.h +++ b/device/fido/u2f_hid_discovery.h
@@ -8,6 +8,7 @@ #include <memory> #include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "device/fido/u2f_discovery.h" @@ -25,7 +26,9 @@ // servicification is unblocked, we'll move U2F back to //service/device/. // Then it will talk to HID via C++ as part of servicifying U2F. -class U2fHidDiscovery : public U2fDiscovery, device::mojom::HidManagerClient { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fHidDiscovery + : public U2fDiscovery, + device::mojom::HidManagerClient { public: explicit U2fHidDiscovery(::service_manager::Connector* connector); ~U2fHidDiscovery() override;
diff --git a/device/fido/u2f_parsing_utils.h b/device/fido/u2f_parsing_utils.h index beefa9b..6a02424 100644 --- a/device/fido/u2f_parsing_utils.h +++ b/device/fido/u2f_parsing_utils.h
@@ -9,19 +9,25 @@ #include <stdint.h> #include <vector> +#include "base/component_export.h" #include "base/containers/span.h" namespace device { namespace u2f_parsing_utils { + // U2FResponse offsets. The format of a U2F response is defined in // https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#registration-response-message-success +COMPONENT_EXPORT(DEVICE_FIDO) extern const uint32_t kU2fResponseKeyHandleLengthPos; +COMPONENT_EXPORT(DEVICE_FIDO) extern const uint32_t kU2fResponseKeyHandleStartPos; -extern const char kEs256[]; +COMPONENT_EXPORT(DEVICE_FIDO) extern const char kEs256[]; +COMPONENT_EXPORT(DEVICE_FIDO) void Append(std::vector<uint8_t>* target, base::span<const uint8_t> in_values); // Parses out a sub-vector after verifying no out-of-bound reads. +COMPONENT_EXPORT(DEVICE_FIDO) std::vector<uint8_t> Extract(base::span<const uint8_t> source, size_t pos, size_t length);
diff --git a/device/fido/u2f_register.h b/device/fido/u2f_register.h index 934c61c..3d7262e1 100644 --- a/device/fido/u2f_register.h +++ b/device/fido/u2f_register.h
@@ -10,7 +10,9 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/containers/flat_set.h" +#include "base/macros.h" #include "base/optional.h" #include "device/fido/u2f_request.h" #include "device/fido/u2f_transport_protocol.h" @@ -23,7 +25,7 @@ class RegisterResponseData; -class U2fRegister : public U2fRequest { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fRegister : public U2fRequest { public: using RegisterResponseCallback = base::OnceCallback<void( U2fReturnCode status_code, @@ -78,6 +80,8 @@ // exclude list. std::set<std::string> checked_device_id_list_; base::WeakPtrFactory<U2fRegister> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(U2fRegister); }; } // namespace device
diff --git a/device/fido/u2f_register_unittest.cc b/device/fido/u2f_register_unittest.cc index 3e4614a96..5355779 100644 --- a/device/fido/u2f_register_unittest.cc +++ b/device/fido/u2f_register_unittest.cc
@@ -14,6 +14,7 @@ #include "device/fido/attested_credential_data.h" #include "device/fido/authenticator_data.h" #include "device/fido/ec_public_key.h" +#include "device/fido/fake_u2f_device.h" #include "device/fido/fake_u2f_discovery.h" #include "device/fido/fido_attestation_statement.h" #include "device/fido/mock_u2f_device.h" @@ -397,6 +398,21 @@ register_callback_receiver().value()->raw_id()); } +TEST_F(U2fRegisterTest, TestRegisterSuccessWithFake) { + auto request = CreateRegisterRequest(); + request->Start(); + discovery()->WaitForCallToStartAndSimulateSuccess(); + + auto device = std::make_unique<test::FakeU2fDevice>(); + discovery()->AddDevice(std::move(device)); + + register_callback_receiver().WaitForCallback(); + EXPECT_EQ(U2fReturnCode::SUCCESS, register_callback_receiver().status()); + + // We don't verify the response from the fake, but do a quick sanity check. + EXPECT_EQ(32ul, register_callback_receiver().value()->raw_id().size()); +} + TEST_F(U2fRegisterTest, TestDelayedSuccess) { auto request = CreateRegisterRequest(); request->Start();
diff --git a/device/fido/u2f_request.h b/device/fido/u2f_request.h index 6a7c4d5d..0a6749b 100644 --- a/device/fido/u2f_request.h +++ b/device/fido/u2f_request.h
@@ -11,7 +11,9 @@ #include <vector> #include "base/cancelable_callback.h" +#include "base/component_export.h" #include "base/containers/flat_set.h" +#include "base/macros.h" #include "base/optional.h" #include "device/fido/u2f_apdu_command.h" #include "device/fido/u2f_device.h" @@ -24,7 +26,7 @@ namespace device { -class U2fRequest : public U2fDiscovery::Observer { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fRequest : public U2fDiscovery::Observer { public: // U2fRequest will create a discovery instance and register itself as an // observer for each passed in transport protocol. @@ -107,6 +109,8 @@ size_t started_count_ = 0; base::WeakPtrFactory<U2fRequest> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(U2fRequest); }; } // namespace device
diff --git a/device/fido/u2f_sign.h b/device/fido/u2f_sign.h index 183e86b..8d8a67d 100644 --- a/device/fido/u2f_sign.h +++ b/device/fido/u2f_sign.h
@@ -9,7 +9,9 @@ #include <string> #include <vector> +#include "base/component_export.h" #include "base/containers/flat_set.h" +#include "base/macros.h" #include "base/optional.h" #include "device/fido/sign_response_data.h" #include "device/fido/u2f_request.h" @@ -21,7 +23,7 @@ namespace device { -class U2fSign : public U2fRequest { +class COMPONENT_EXPORT(DEVICE_FIDO) U2fSign : public U2fRequest { public: using SignResponseCallback = base::OnceCallback<void(U2fReturnCode status_code, @@ -71,6 +73,8 @@ SignResponseCallback completion_callback_; base::WeakPtrFactory<U2fSign> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(U2fSign); }; } // namespace device
diff --git a/device/fido/u2f_sign_unittest.cc b/device/fido/u2f_sign_unittest.cc index d0522d3..7c32ade 100644 --- a/device/fido/u2f_sign_unittest.cc +++ b/device/fido/u2f_sign_unittest.cc
@@ -8,7 +8,10 @@ #include "base/run_loop.h" #include "base/test/scoped_task_environment.h" +#include "crypto/ec_private_key.h" +#include "crypto/sha2.h" #include "device/fido/authenticator_data.h" +#include "device/fido/fake_u2f_device.h" #include "device/fido/fake_u2f_discovery.h" #include "device/fido/mock_u2f_device.h" #include "device/fido/sign_response_data.h" @@ -68,6 +71,11 @@ // clang-format on }; +std::vector<uint8_t> GetTestRelyingPartyIdSHA256() { + return std::vector<uint8_t>(std::begin(kTestRelyingPartyIdSHA256), + std::end(kTestRelyingPartyIdSHA256)); +} + std::vector<uint8_t> GetTestCredentialRawIdBytes() { return std::vector<uint8_t>(std::begin(test_data::kTestCredentialRawIdBytes), std::end(test_data::kTestCredentialRawIdBytes)); @@ -127,8 +135,9 @@ nullptr /* connector */, base::flat_set<U2fTransportProtocol>( {U2fTransportProtocol::kUsbHumanInterfaceDevice}), - registered_keys, std::vector<uint8_t>(32), std::vector<uint8_t>(32), - base::nullopt, sign_callback_receiver_.callback()); + registered_keys, std::vector<uint8_t>(32), + GetTestRelyingPartyIdSHA256(), base::nullopt, + sign_callback_receiver_.callback()); } test::FakeU2fDiscovery* discovery() const { return discovery_; } @@ -232,6 +241,40 @@ EXPECT_EQ(signing_key_handle, sign_callback_receiver().value()->raw_id()); } +TEST_F(U2fSignTest, TestSignSuccessWithFake) { + auto private_key = crypto::ECPrivateKey::Create(); + std::string public_key; + private_key->ExportRawPublicKey(&public_key); + std::vector<uint8_t> key_handle(32); + crypto::SHA256HashString(public_key, key_handle.data(), key_handle.size()); + + std::vector<std::vector<uint8_t>> handles{key_handle}; + auto request = CreateSignRequestWithKeys(handles); + request->Start(); + discovery()->WaitForCallToStartAndSimulateSuccess(); + + auto device = std::make_unique<test::FakeU2fDevice>(); + device->AddRegistration(key_handle, std::move(private_key), + GetTestRelyingPartyIdSHA256(), 42); + discovery()->AddDevice(std::move(device)); + + sign_callback_receiver().WaitForCallback(); + EXPECT_EQ(U2fReturnCode::SUCCESS, sign_callback_receiver().status()); + + // Just a sanity check, we don't verify the actual signature. + ASSERT_GE( + (size_t)(32 + 1 + 4 + 8), // Minimal ECDSA signature is 8 bytes + sign_callback_receiver().value()->GetAuthenticatorDataBytes().size()); + EXPECT_EQ(0x01, + sign_callback_receiver() + .value() + ->GetAuthenticatorDataBytes()[32]); // UP flag + EXPECT_EQ(43, + sign_callback_receiver() + .value() + ->GetAuthenticatorDataBytes()[36]); // counter +} + TEST_F(U2fSignTest, TestDelayedSuccess) { const std::vector<uint8_t> signing_key_handle(32, 0x0A); auto request = CreateSignRequestWithKeys({signing_key_handle});
diff --git a/infra/config/global/cr-buildbucket.cfg b/infra/config/global/cr-buildbucket.cfg index 441bb7f3..9e32a6e9 100644 --- a/infra/config/global/cr-buildbucket.cfg +++ b/infra/config/global/cr-buildbucket.cfg
@@ -149,6 +149,7 @@ builder_mixins { name: "fyi-ci" + mixins: "cipd recipes" recipe { properties: "mastername:chromium.fyi" } @@ -317,6 +318,17 @@ execution_timeout_secs: 21600 # 2 x 3h for a double workload } +builder_mixins { + name: "cipd recipes" + recipe: { + # TODO(crbug.com/811974) Remove this when no longer setting repository in + # builder_defaults. + repository: "-" + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/master" + } +} + buckets { name: "luci.chromium.ci" acl_sets: "ci" @@ -424,21 +436,25 @@ builders { name: "Fuchsia ARM64" mixins: "linux-ci" + mixins: "cipd recipes" } builders { name: "Fuchsia ARM64 Cast Audio" mixins: "linux-ci" + mixins: "cipd recipes" } builders { name: "Fuchsia x64" mixins: "linux-ci" + mixins: "cipd recipes" } builders { name: "Fuchsia x64 Cast Audio" mixins: "linux-ci" + mixins: "cipd recipes" } # Linux bots. @@ -568,21 +584,6 @@ dimensions: "cores:8" } - builders { - name: "WebKit Mac Builder (dbg)" - mixins: "webkit-ci" - dimensions: "os:Mac-10.12" - dimensions: "cpu:x86-64" - dimensions: "cores:8" - } - builders { - name: "WebKit Mac10.11 (dbg)" - mixins: "webkit-ci" - dimensions: "os:Mac-10.11" - dimensions: "cpu:x86-64" - dimensions: "cores:8" - } - # chromium.gpu.fyi builders { name: "GPU FYI Mac Builder" @@ -907,7 +908,7 @@ } } builders { mixins: "linux-try" name: "closure_compilation" } - builders { mixins: "linux-try" name: "fuchsia" } + builders { mixins: "linux-try" mixins: "cipd recipes" name: "fuchsia" } builders { mixins: "linux-try" name: "linux_android_rel_ng" } builders { mixins: "linux-angle-try" name: "linux_angle_compile_dbg_ng" } builders { mixins: "linux-angle-try" name: "linux_angle_dbg_ng" }
diff --git a/infra/config/global/luci-milo.cfg b/infra/config/global/luci-milo.cfg index 0cb9c63..982ac03 100644 --- a/infra/config/global/luci-milo.cfg +++ b/infra/config/global/luci-milo.cfg
@@ -1560,28 +1560,6 @@ } builders: { - name: "buildbucket/luci.chromium.ci/WebKit Mac Builder (dbg)" - category: "webkit|mac|debug|builder" - short_name: "yay" - } - builders: { - name: "buildbot/chromium.webkit/WebKit Mac Builder (dbg)" - category: "webkit|mac|debug|builder" - short_name: "nay" - } - - builders: { - name: "buildbucket/luci.chromium.ci/WebKit Mac10.11 (dbg)" - category: "webkit|mac|debug|tester" - short_name: "yay" - } - builders: { - name: "buildbot/chromium.webkit/WebKit Mac10.11 (dbg)" - category: "webkit|mac|debug|tester" - short_name: "nay" - } - - builders: { name: "buildbucket/luci.chromium.ci/Win Builder" category: "win|release|builder|32" short_name: "ᕕ(ᐛ)ᕗ"
diff --git a/infra/config/global/luci-scheduler.cfg b/infra/config/global/luci-scheduler.cfg index 2d7f510..42cafbc3 100644 --- a/infra/config/global/luci-scheduler.cfg +++ b/infra/config/global/luci-scheduler.cfg
@@ -804,27 +804,6 @@ } } -job { - id: "WebKit Mac Builder (dbg)" - acl_sets: "default" - buildbucket: { - server: "cr-buildbucket.appspot.com" - bucket: "luci.chromium.ci" - builder: "WebKit Mac Builder (dbg)" - } -} - -job { - id: "WebKit Mac10.11 (dbg)" - # Triggered by "WebKit Mac Builder (dbg)". - acl_sets: "triggered-by-parent-builders" - buildbucket: { - server: "cr-buildbucket.appspot.com" - bucket: "luci.chromium.ci" - builder: "WebKit Mac10.11 (dbg)" - } -} - ################################################################################ # Windows Builders. Sorted alphabetically. ################################################################################
diff --git a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc index ebff168..c0038b97 100644 --- a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc +++ b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.cc
@@ -193,6 +193,8 @@ // iOS currently has no client for this event. } -bool AutocompleteProviderClientImpl::IsTabOpenWithURL(const GURL& url) { +bool AutocompleteProviderClientImpl::IsTabOpenWithURL( + const GURL& url, + const AutocompleteInput* input) { return false; }
diff --git a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h index 4d07b4e1..2633b17 100644 --- a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h +++ b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h
@@ -66,7 +66,8 @@ void PrefetchImage(const GURL& url) override; void OnAutocompleteControllerResultReady( AutocompleteController* controller) override; - bool IsTabOpenWithURL(const GURL& url) override; + bool IsTabOpenWithURL(const GURL& url, + const AutocompleteInput* input) override; private: ios::ChromeBrowserState* browser_state_;
diff --git a/ipc/BUILD.gn b/ipc/BUILD.gn index 81e7659..d2ca944 100644 --- a/ipc/BUILD.gn +++ b/ipc/BUILD.gn
@@ -4,16 +4,12 @@ import("//build/buildflag_header.gni") import("//build/config/nacl/config.gni") +import("//ipc/features.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//testing/test.gni") import("//tools/ipc_fuzzer/ipc_fuzzer.gni") import("//third_party/protobuf/proto_library.gni") -declare_args() { - # Enabling debug builds automatically sets enable_ipc_logging to true. - enable_ipc_logging = is_debug -} - buildflag_header("ipc_features") { header = "ipc_features.h"
diff --git a/ipc/features.gni b/ipc/features.gni new file mode 100644 index 0000000..4c3385b --- /dev/null +++ b/ipc/features.gni
@@ -0,0 +1,8 @@ +# Copyright 2018 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. + +declare_args() { + # Enabling debug builds automatically sets enable_ipc_logging to true. + enable_ipc_logging = is_debug +}
diff --git a/ipc/ipc_mojo_bootstrap_unittest.cc b/ipc/ipc_mojo_bootstrap_unittest.cc index 46dca0e..8528900 100644 --- a/ipc/ipc_mojo_bootstrap_unittest.cc +++ b/ipc/ipc_mojo_bootstrap_unittest.cc
@@ -55,7 +55,7 @@ enum class MessageExpectation { kNotExpected, kExpectedValid, - kExptectedInvalid + kExpectedInvalid }; PeerPidReceiver( @@ -65,7 +65,11 @@ : binding_(this, std::move(request)), on_peer_pid_set_(on_peer_pid_set), message_expectation_(message_expectation) {} - ~PeerPidReceiver() override {} + ~PeerPidReceiver() override { + bool expected_message = + message_expectation_ != MessageExpectation::kNotExpected; + EXPECT_EQ(expected_message, received_message_); + } // mojom::Channel: void SetPeerPid(int32_t pid) override { @@ -77,6 +81,7 @@ base::Optional<std::vector<mojo::native::SerializedHandlePtr>> handles) override { ASSERT_NE(MessageExpectation::kNotExpected, message_expectation_); + received_message_ = true; IPC::Message message(reinterpret_cast<const char*>(data.data()), static_cast<uint32_t>(data.size())); @@ -97,6 +102,8 @@ MessageExpectation message_expectation_; int32_t peer_pid_ = -1; + bool received_message_ = false; + DISALLOW_COPY_AND_ASSIGN(PeerPidReceiver); }; @@ -126,7 +133,8 @@ EXPECT_TRUE(helper_.WaitForChildTestShutdown()); } -TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) { +// TODO(https://crbug.com/821254): Fix this test and re-enable it. +TEST_F(IPCMojoBootstrapTest, DISABLED_ReceiveEmptyMessage) { base::MessageLoop message_loop; Connection connection( IPC::MojoBootstrap::Create( @@ -140,7 +148,7 @@ base::RunLoop run_loop; PeerPidReceiver impl(std::move(receiver), run_loop.QuitClosure(), - PeerPidReceiver::MessageExpectation::kExptectedInvalid); + PeerPidReceiver::MessageExpectation::kExpectedInvalid); run_loop.Run(); EXPECT_TRUE(helper_.WaitForChildTestShutdown());
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc index 916ebea..19e45512 100644 --- a/media/base/android/media_drm_bridge.cc +++ b/media/base/android/media_drm_bridge.cc
@@ -571,8 +571,7 @@ CdmContext* MediaDrmBridge::GetCdmContext() { DVLOG(2) << __func__; - - return &media_drm_bridge_cdm_context_; + return this; } void MediaDrmBridge::DeleteOnCorrectThread() const { @@ -586,6 +585,11 @@ } } +MediaDrmBridgeCdmContext* MediaDrmBridge::GetMediaDrmBridgeCdmContext() { + DVLOG(2) << __func__; + return &media_drm_bridge_cdm_context_; +} + int MediaDrmBridge::RegisterPlayer(const base::Closure& new_key_cb, const base::Closure& cdm_unset_cb) { // |player_tracker_| can be accessed from any thread.
diff --git a/media/base/android/media_drm_bridge.h b/media/base/android/media_drm_bridge.h index 8745c0c8..82869ab 100644 --- a/media/base/android/media_drm_bridge.h +++ b/media/base/android/media_drm_bridge.h
@@ -23,6 +23,7 @@ #include "media/base/android/media_drm_bridge_cdm_context_impl.h" #include "media/base/android/media_drm_storage.h" #include "media/base/android/media_drm_storage_bridge.h" +#include "media/base/cdm_context.h" #include "media/base/cdm_promise.h" #include "media/base/cdm_promise_adapter.h" #include "media/base/content_decryption_module.h" @@ -47,6 +48,7 @@ // SetMediaCryptoReadyCB(), which can be called on any thread. class MEDIA_EXPORT MediaDrmBridge : public ContentDecryptionModule, + public CdmContext, public PlayerTracker { public: // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 @@ -129,6 +131,9 @@ CdmContext* GetCdmContext() override; void DeleteOnCorrectThread() const override; + // CdmContext implementation. + MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext() override; + // Unprovision the origin bound with |this|. This will remove the cert for // current origin and leave the offline licenses in invalid state (offline // licenses can't be used anymore).
diff --git a/media/base/android/media_drm_bridge_cdm_context.h b/media/base/android/media_drm_bridge_cdm_context.h index a91a812..84a374e 100644 --- a/media/base/android/media_drm_bridge_cdm_context.h +++ b/media/base/android/media_drm_bridge_cdm_context.h
@@ -10,24 +10,20 @@ #include "base/callback.h" #include "base/macros.h" #include "media/base/android/android_util.h" -#include "media/base/cdm_context.h" #include "media/base/media_export.h" #include "media/base/player_tracker.h" namespace media { -// The CdmContext implementation for MediaDrmBridge. MediaDrmBridge supports -// neither Decryptor nor CDM ID, but uses MediaCrypto to connect to MediaCodec. -// MediaCodec-based decoders should cast the given CdmContext to this class to -// access APIs defined in this class. +// A class that provides MediaCrypto from MediaDrm to support decrypting and +// decoding of encrypted streams, typically by MediaCodec-based decoders. // -// Methods can be called on any thread. The registered callbacks will be fired +// Methods can be called on any thread. The registered callbacks can be fired // on any thread. The caller should make sure that the callbacks are posted to // the correct thread. // // TODO(xhwang): Remove PlayerTracker interface. -class MEDIA_EXPORT MediaDrmBridgeCdmContext : public CdmContext, - public PlayerTracker { +class MEDIA_EXPORT MediaDrmBridgeCdmContext : public PlayerTracker { public: // Notification called when MediaCrypto object is ready. // Parameters:
diff --git a/media/base/android/media_drm_bridge_cdm_context_impl.cc b/media/base/android/media_drm_bridge_cdm_context_impl.cc index 2c179582..9b45ba89 100644 --- a/media/base/android/media_drm_bridge_cdm_context_impl.cc +++ b/media/base/android/media_drm_bridge_cdm_context_impl.cc
@@ -16,14 +16,6 @@ MediaDrmBridgeCdmContextImpl::~MediaDrmBridgeCdmContextImpl() {} -Decryptor* MediaDrmBridgeCdmContextImpl::GetDecryptor() { - return nullptr; -} - -int MediaDrmBridgeCdmContextImpl::GetCdmId() const { - return kInvalidCdmId; -} - int MediaDrmBridgeCdmContextImpl::RegisterPlayer( const base::Closure& new_key_cb, const base::Closure& cdm_unset_cb) {
diff --git a/media/base/android/media_drm_bridge_cdm_context_impl.h b/media/base/android/media_drm_bridge_cdm_context_impl.h index 493ed2d..ab537d20 100644 --- a/media/base/android/media_drm_bridge_cdm_context_impl.h +++ b/media/base/android/media_drm_bridge_cdm_context_impl.h
@@ -30,10 +30,6 @@ ~MediaDrmBridgeCdmContextImpl() final; - // CdmContext implementation. - Decryptor* GetDecryptor() final; - int GetCdmId() const final; - // PlayerTracker implementation. // Methods can be called on any thread. The registered callbacks will be fired // on |task_runner_|. The caller should make sure that the callbacks are
diff --git a/media/base/android/mock_media_drm_bridge_cdm_context.cc b/media/base/android/mock_media_drm_bridge_cdm_context.cc index 8c3d150..479ff6c 100644 --- a/media/base/android/mock_media_drm_bridge_cdm_context.cc +++ b/media/base/android/mock_media_drm_bridge_cdm_context.cc
@@ -17,9 +17,8 @@ namespace media { -MockMediaDrmBridgeCdmContext::MockMediaDrmBridgeCdmContext(int cdm_id) { +MockMediaDrmBridgeCdmContext::MockMediaDrmBridgeCdmContext() { // Provide some sane defaults. - ON_CALL(*this, GetCdmId()).WillByDefault(Return(cdm_id)); ON_CALL(*this, RegisterPlayer(_, _)) .WillByDefault(DoAll(SaveArg<0>(&new_key_cb), SaveArg<1>(&cdm_unset_cb), Return(kRegistrationId))); @@ -33,4 +32,9 @@ MockMediaDrmBridgeCdmContext::~MockMediaDrmBridgeCdmContext() {} +MediaDrmBridgeCdmContext* +MockMediaDrmBridgeCdmContext::GetMediaDrmBridgeCdmContext() { + return this; +} + } // namespace media
diff --git a/media/base/android/mock_media_drm_bridge_cdm_context.h b/media/base/android/mock_media_drm_bridge_cdm_context.h index 483ee7365..b6a2c84 100644 --- a/media/base/android/mock_media_drm_bridge_cdm_context.h +++ b/media/base/android/mock_media_drm_bridge_cdm_context.h
@@ -9,26 +9,27 @@ #include "base/macros.h" #include "media/base/android/media_drm_bridge_cdm_context.h" +#include "media/base/cdm_context.h" #include "media/base/media_export.h" #include "testing/gmock/include/gmock/gmock.h" namespace media { class MEDIA_EXPORT MockMediaDrmBridgeCdmContext - : public testing::NiceMock<MediaDrmBridgeCdmContext> { + : public CdmContext, + public testing::NiceMock<MediaDrmBridgeCdmContext> { public: - explicit MockMediaDrmBridgeCdmContext(int cdm_id); - + MockMediaDrmBridgeCdmContext(); ~MockMediaDrmBridgeCdmContext() override; - MOCK_METHOD0(GetDecryptor, Decryptor*()); - MOCK_CONST_METHOD0(GetCdmId, int()); + // CdmContext implementation. + MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext() override; + + // MediaDrmBridgeCdmContext implementation. MOCK_METHOD2(RegisterPlayer, int(const base::Closure& new_key_cb, const base::Closure& cdm_unset_cb)); MOCK_METHOD1(UnregisterPlayer, void(int registration_id)); - - // MediaDrmBridgeCdmContext implementation. MOCK_METHOD1(SetMediaCryptoReadyCB, void(const MediaCryptoReadyCB& media_crypto_ready_cb));
diff --git a/media/base/cdm_context.cc b/media/base/cdm_context.cc index 073e23e..cd3e953 100644 --- a/media/base/cdm_context.cc +++ b/media/base/cdm_context.cc
@@ -10,8 +10,6 @@ CdmContext::~CdmContext() = default; -void IgnoreCdmAttached(bool /* success */) {} - Decryptor* CdmContext::GetDecryptor() { return nullptr; } @@ -26,8 +24,16 @@ } #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) +#if defined(OS_ANDROID) +MediaDrmBridgeCdmContext* CdmContext::GetMediaDrmBridgeCdmContext() { + return nullptr; +} +#endif + void* CdmContext::GetClassIdentifier() const { return nullptr; } +void IgnoreCdmAttached(bool /* success */) {} + } // namespace media
diff --git a/media/base/cdm_context.h b/media/base/cdm_context.h index 50593966..5db4375 100644 --- a/media/base/cdm_context.h +++ b/media/base/cdm_context.h
@@ -7,6 +7,7 @@ #include "base/callback.h" #include "base/macros.h" +#include "build/build_config.h" #include "media/base/media_export.h" #include "media/media_features.h" @@ -14,6 +15,7 @@ class CdmProxyContext; class Decryptor; +class MediaDrmBridgeCdmContext; // An interface representing the context that a media player needs from a // content decryption module (CDM) to decrypt (and decode) encrypted buffers. @@ -44,6 +46,13 @@ virtual CdmProxyContext* GetCdmProxyContext(); #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) +#if defined(OS_ANDROID) + // Returns a MediaDrmBridgeCdmContext that can be used by MediaCodec based + // decoders. The returned object is only guaranteed to be valid during the + // CDM's lifetime. + virtual MediaDrmBridgeCdmContext* GetMediaDrmBridgeCdmContext(); +#endif + // Returns a unique class identifier. Some subclasses override and use this // method to provide safe down-casting to their type. virtual void* GetClassIdentifier() const;
diff --git a/media/cast/net/udp_socket_client_unittest.cc b/media/cast/net/udp_socket_client_unittest.cc index c1b00df..5dacda40 100644 --- a/media/cast/net/udp_socket_client_unittest.cc +++ b/media/cast/net/udp_socket_client_unittest.cc
@@ -138,21 +138,8 @@ std::move(receiver)); OnUDPSocketCreated(); } - void CreateTCPServerSocket( - const net::IPEndPoint& local_addr, - uint32_t backlog, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - network::mojom::TCPServerSocketRequest request, - CreateTCPServerSocketCallback callback) override {} - void CreateTCPConnectedSocket( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - network::mojom::TCPConnectedSocketRequest request, - network::mojom::TCPConnectedSocketObserverPtr observer, - CreateTCPConnectedSocketCallback callback) override {} - MockUdpSocket* udp_socket() const { return udp_socket_.get(); } + MockUdpSocket* udp_socket() const { return udp_socket_.get(); }; private: mojo::Binding<network::mojom::NetworkContext> binding_;
diff --git a/media/filters/android/media_codec_audio_decoder.cc b/media/filters/android/media_codec_audio_decoder.cc index 4d906cf..1ea7ac20 100644 --- a/media/filters/android/media_codec_audio_decoder.cc +++ b/media/filters/android/media_codec_audio_decoder.cc
@@ -16,6 +16,7 @@ #include "media/base/android/media_codec_util.h" #include "media/base/audio_timestamp_helper.h" #include "media/base/bind_to_current_loop.h" +#include "media/base/cdm_context.h" #include "media/base/timestamp_constants.h" #include "media/formats/ac3/ac3_util.h" @@ -100,22 +101,25 @@ return; } - if (config.is_encrypted() && !cdm_context) { - NOTREACHED() << "The stream is encrypted but there is no CDM context"; - bound_init_cb.Run(false); - return; - } - config_ = config; output_cb_ = BindToCurrentLoop(output_cb); - SetInitialConfiguration(); if (config_.is_encrypted() && !media_crypto_) { + media_drm_bridge_cdm_context_ = + cdm_context ? cdm_context->GetMediaDrmBridgeCdmContext() : nullptr; + if (!media_drm_bridge_cdm_context_) { + LOG(ERROR) << "The stream is encrypted but there is no CdmContext or " + "MediaDrmBridgeCdmContext is not supported"; + SetState(STATE_ERROR); + bound_init_cb.Run(false); + return; + } + // Postpone initialization after MediaCrypto is available. // SetCdm uses init_cb in a method that's already bound to the current loop. SetState(STATE_WAITING_FOR_MEDIA_CRYPTO); - SetCdm(cdm_context, init_cb); + SetCdm(init_cb); return; } @@ -210,13 +214,8 @@ return config_.codec() == kCodecAAC; } -void MediaCodecAudioDecoder::SetCdm(CdmContext* cdm_context, - const InitCB& init_cb) { - DCHECK(cdm_context); - - // On Android platform the CdmContext must be a MediaDrmBridgeCdmContext. - media_drm_bridge_cdm_context_ = - static_cast<media::MediaDrmBridgeCdmContext*>(cdm_context); +void MediaCodecAudioDecoder::SetCdm(const InitCB& init_cb) { + DCHECK(media_drm_bridge_cdm_context_); // Register CDM callbacks. The callbacks registered will be posted back to // this thread via BindToCurrentLoop.
diff --git a/media/filters/android/media_codec_audio_decoder.h b/media/filters/android/media_codec_audio_decoder.h index 5c42402..e4e5ea1 100644 --- a/media/filters/android/media_codec_audio_decoder.h +++ b/media/filters/android/media_codec_audio_decoder.h
@@ -126,7 +126,7 @@ // A helper method to start CDM initialization. This must be called if and // only if we were constructed with |is_encrypted| set to true. - void SetCdm(CdmContext* cdm_context, const InitCB& init_cb); + void SetCdm(const InitCB& init_cb); // This callback is called after CDM obtained a MediaCrypto object. void OnMediaCryptoReady(const InitCB& init_cb,
diff --git a/media/gpu/android/android_video_decode_accelerator.cc b/media/gpu/android/android_video_decode_accelerator.cc index 3961cc6..0be0216 100644 --- a/media/gpu/android/android_video_decode_accelerator.cc +++ b/media/gpu/android/android_video_decode_accelerator.cc
@@ -1451,16 +1451,20 @@ #if !BUILDFLAG(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) NOTIMPLEMENTED(); NOTIFY_ERROR(PLATFORM_FAILURE, "Cdm support needs mojo in the gpu process"); + return; #else // Store the CDM to hold a reference to it. cdm_for_reference_holding_only_ = CdmManager::GetInstance()->GetCdm(config_.cdm_id); DCHECK(cdm_for_reference_holding_only_); - // On Android platform the CdmContext must be a MediaDrmBridgeCdmContext. - media_drm_bridge_cdm_context_ = static_cast<MediaDrmBridgeCdmContext*>( - cdm_for_reference_holding_only_->GetCdmContext()); - DCHECK(media_drm_bridge_cdm_context_); + auto* cdm_context = cdm_for_reference_holding_only_->GetCdmContext(); + media_drm_bridge_cdm_context_ = + cdm_context ? cdm_context->GetMediaDrmBridgeCdmContext() : nullptr; + if (!media_drm_bridge_cdm_context_) { + NOTIFY_ERROR(PLATFORM_FAILURE, "MediaDrmBridgeCdmContext not available."); + return; + } // Register CDM callbacks. The callbacks registered will be posted back to // this thread via BindToCurrentLoop.
diff --git a/media/gpu/android/media_codec_video_decoder.cc b/media/gpu/android/media_codec_video_decoder.cc index b8729dc..85591ec 100644 --- a/media/gpu/android/media_codec_video_decoder.cc +++ b/media/gpu/android/media_codec_video_decoder.cc
@@ -15,6 +15,7 @@ #include "media/base/android/media_codec_bridge_impl.h" #include "media/base/android/media_codec_util.h" #include "media/base/bind_to_current_loop.h" +#include "media/base/cdm_context.h" #include "media/base/decoder_buffer.h" #include "media/base/media_switches.h" #include "media/base/video_codecs.h" @@ -206,9 +207,13 @@ return; } - // On Android platform the CdmContext must be a MediaDrmBridgeCdmContext. - media_drm_bridge_cdm_context_ = - static_cast<media::MediaDrmBridgeCdmContext*>(cdm_context); + media_drm_bridge_cdm_context_ = cdm_context->GetMediaDrmBridgeCdmContext(); + if (!media_drm_bridge_cdm_context_) { + LOG(ERROR) << "MediaDrmBridgeCdmContext not supported"; + EnterTerminalState(State::kError); + init_cb.Run(false); + return; + } // Register CDM callbacks. The callbacks registered will be posted back to // this thread via BindToCurrentLoop.
diff --git a/media/gpu/android/media_codec_video_decoder_unittest.cc b/media/gpu/android/media_codec_video_decoder_unittest.cc index 8eeebf4..28fc401 100644 --- a/media/gpu/android/media_codec_video_decoder_unittest.cc +++ b/media/gpu/android/media_codec_video_decoder_unittest.cc
@@ -150,7 +150,7 @@ } void CreateCdm(bool require_secure_video_decoder) { - cdm_ = std::make_unique<MockMediaDrmBridgeCdmContext>(cdm_id_); + cdm_ = std::make_unique<MockMediaDrmBridgeCdmContext>(); require_secure_video_decoder_ = require_secure_video_decoder; // We need to send an object as the media crypto, but MCVD shouldn't @@ -246,7 +246,6 @@ bool restart_for_transitions_; gpu::GpuPreferences gpu_preferences_; - const int cdm_id_ = 123; // This is not an actual media crypto object. base::android::ScopedJavaGlobalRef<jobject> media_crypto_; bool require_secure_video_decoder_ = false;
diff --git a/mojo/edk/system/channel_unittest.cc b/mojo/edk/system/channel_unittest.cc index ac37bae..5683e4c 100644 --- a/mojo/edk/system/channel_unittest.cc +++ b/mojo/edk/system/channel_unittest.cc
@@ -203,7 +203,7 @@ // If |client_channel_| exists then close it and its thread. if (client_channel_) { // Write a fresh message, making our channel readable again. - Channel::MessagePtr message = std::make_unique<Channel::Message>(1, 0); + Channel::MessagePtr message = CreateDefaultMessage(false); client_thread_->task_runner()->PostTask( FROM_HERE, base::BindOnce(&Channel::Write, client_channel_, base::Passed(&message))); @@ -218,7 +218,7 @@ // Write a message to the channel, to verify whether this triggers an // OnChannelError callback before all messages were read. - Channel::MessagePtr message = std::make_unique<Channel::Message>(1, 0); + Channel::MessagePtr message = CreateDefaultMessage(false); channel_->Write(std::move(message)); } @@ -253,7 +253,7 @@ client_channel->Start(); // On the "client" IO thread, create and write a message. - Channel::MessagePtr message = std::make_unique<Channel::Message>(1, 0); + Channel::MessagePtr message = CreateDefaultMessage(false); client_thread->task_runner()->PostTask( FROM_HERE, base::BindOnce(&Channel::Write, client_channel, base::Passed(&message)));
diff --git a/net/http/transport_security_state_static.json b/net/http/transport_security_state_static.json index 2d8ac452..2e0ac1b 100644 --- a/net/http/transport_security_state_static.json +++ b/net/http/transport_security_state_static.json
@@ -2874,7 +2874,6 @@ { "name": "fteproxy.org", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "g2g.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "gambitprint.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, - { "name": "gamercredo.net", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "genuxation.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "getnikola.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "github.party", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, @@ -7633,7 +7632,6 @@ { "name": "theworldsend.eu", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "thezonders.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "tmitchell.io", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, - { "name": "tnrsca.jp", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "todobazar.es", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "tonsit.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "tonsit.org", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, @@ -25421,7 +25419,6 @@ { "name": "devisonline.ch", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "dezintranet.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "df1paw.de", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, - { "name": "dfnet.ml", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "dgx.io", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "dhlinux.org", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "diagnosia.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, @@ -27277,7 +27274,6 @@ { "name": "preexport.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "prefix.eu", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "preludes.org", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, - { "name": "prenger.co", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "prepare-job-hunting.com", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "prestige-car-location.ch", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "pretachique.com.br", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, @@ -32794,7 +32790,6 @@ { "name": "chuck.ovh", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "cloudlight.biz", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "coffeetocode.me", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, - { "name": "clubalfa.it", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "cinerama.com.br", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "cirurgicagervasio.com.br", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, { "name": "cidadedopoker.com.br", "policy": "bulk-18-weeks", "mode": "force-https", "include_subdomains": true }, @@ -46616,7 +46611,6 @@ { "name": "shyuka.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "sigmapramuka.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "silvobeat.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, - { "name": "simplegreen.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "sirchuk.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "sivale.mx", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "skatesins.ch", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, @@ -46771,6 +46765,818 @@ { "name": "zula.africa", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "zumazar.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, { "name": "zyger.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022367.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022379.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022391.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022501.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022503.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022507.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022561.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022571.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022601.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022609.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "022610.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "02327.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "02375.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "026122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "02638.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "03170317.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "0391315.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "0511315.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "0792112.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081752.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081763.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081769.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081783.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081925.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081927.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081957.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "081967.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082157.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082159.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082167.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082173.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082175.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082179.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082187.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082192.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082193.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082195.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "082359.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083903.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083905.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083907.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083912.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083957.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083960.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083962.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083965.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "083967.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "09892.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1001mv.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10430.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10435.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10436.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10438.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10439.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10453.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10495.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10774.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10840.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "10v2.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "124133.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "124633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "143533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "143633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "143733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "143933.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "145433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "145733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "146233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "146433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "146533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "146733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "149433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "149733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "152433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "154233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "154633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "154933.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "156433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1661237.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1811559.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1876996.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "18celebration.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "18celebration.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "192433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1f123.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "1montre.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "215dy.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "247exchange.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "2858958.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "2991236.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "3-dot-careapp1-146314.appspot.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "302422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "303422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "304122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "304322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "304622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "3056999.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "309422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "30yearmortgagerates.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "310422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "313422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "314922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "315422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "316433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "319422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "320281.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324133.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "324922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "325422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "326422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "326433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "329422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "340422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "340622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "340922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "341922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342033.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342133.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342733.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "342933.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "343022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "343622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "343722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "343922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346033.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "346922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "348233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "348433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "348533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "349022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "349033.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "349233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "349433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "349533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "350422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354133.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "354933.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "356433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "370422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "371422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "373422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "374933.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "375422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "380422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "390422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "392422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "393422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "394922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "396422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "4237.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "440hz.radio", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "4everproxy.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "504122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "504322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "504622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "504922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "506422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "514122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "514522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "514622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "514922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "515422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "516422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "51877.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "519422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "524022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "524622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "524922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "52ncp.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "531422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "534122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "534622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "534922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "536422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "540922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "541022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "541622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "541722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "541922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "545922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "576422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "579422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "583422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "585422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "586422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "591422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "592422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "5930593.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "594022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "594622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "595422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "596422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "5997891.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "602422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "604122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "604322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "604522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "604622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "605422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "606422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "609422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "614022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "614322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "614922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "61730123.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "621422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "624022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "624122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "624322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "624522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "624922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "626422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "630422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "631422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "634022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "634322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "634622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "634922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "635422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "636422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "639422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "640622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "640722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "640922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641522.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641822.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "641922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642822.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "642922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "643022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "643122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "643722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "643922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645822.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "645ds.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "646022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "646322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "646722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "649022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "649622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "649722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "649822.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "651422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "652422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "659422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "6652566.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "670422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "671422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "672422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "673422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "676422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "679422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "680422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "690422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "691422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "692422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "693422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "694322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "694622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "694922.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "6997896.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "704233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "704533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "704633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "712433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "713433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "714133.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "714533.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "714633.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "715433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "718433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "719433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "724233.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "726433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "728433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "729433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "730433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "731433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "732433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "735433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "736433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "738433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "739433.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "740833.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "741833.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "742833.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "743833.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "7885765.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "7891553.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "7891997.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "789zr.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "7proxies.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "804322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "809422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "80993.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "814022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "8189196.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "8maerz.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "903422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "905422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "912422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "913422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "914122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "919422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "924122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "924322.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "924622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "926422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "931422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "932422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "934122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "943022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "9454.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "946022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "946422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "949022.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "949122.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "949622.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "949722.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "95778.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "9679693.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "9681909.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "972422.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "9788876.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "9918883.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "aavienna.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "acgpiano.club", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "acheter-ethylotest.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "adftrasporti.it", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "adoucisseur.shop", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "advocoeurdehaan.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "advtran.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "aesthetx.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "agnesk.blog", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "agrafix.design", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ahtuxpk.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "aisi316l.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "akronet.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "akropol.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "albanboye.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "alco-united.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "aldred.cloud", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "alerbon.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "allontanamentovolatili.milano.it", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "allstakesupply.com.au", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "alphaetomega3d.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "andso.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "antarespc.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "aobogo.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "apparelfashionwiki.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ask1.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "asmood.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "audirsq3.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ausmwoid.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "badblock.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "balance7.jp", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "balenciaspa.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bc-personal.ch", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "benceskorka.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "birdandbranchnyc.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bischoff-mathey.family", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bitbank.cc", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bitclubfun.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "blackgate.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "boke112.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bondtofte.dk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "booksinthefridge.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bpa.gov", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "brackets-salad.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "brovelton.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "bueroshop24.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cafedupont.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cafedupont.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cafedupont.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "caiwenjian.xyz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "callumsilcock.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "callumsilcock.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "campus-discounts.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cemeteriat.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "christianjens.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "city-walks.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ckp.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "clien.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "clubdelzapato.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cncado.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cnsyear.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cocareonline.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "codersbistro.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "codetheworld.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "consec-systems.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "continuum.memorial", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "corona-renderer.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "course.rs", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cozitop.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "craftist.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "crunchrapps.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "crypto-navi.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cryptoparty.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "csfcloud.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "csrichter.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "cwbrtrust.ca", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dancingshiva.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dawena.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "deep.social", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dggm.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dggwp.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "diamondt.us", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "digitalexhale.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dingelbob-schuhcreme.gq", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "directwatertanks.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "disinfestazioni.rimini.it", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dixi.fi", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dmmkenya.co.ke", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dnsql.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dokipy.no", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "donpomodoro.com.co", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "drivya.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dropq.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dub.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "dynamo.city", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "e-traceur-france.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "e7fun.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ebonyporn.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ed4becky.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "eigenpul.se", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "eigenpulse.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "electicofficial.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "electricfencealberton.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "electricfencebenoni.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "electrician-umhlanga.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "electricianumhlangarocks.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "elfe.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "elixi.re", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "elnoorandelmohanad.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "emaging-productions.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "escort-fashion.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ethantskinner.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "etskinner.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "eurotravelstar.eu", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "evidentiasoftware.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "evodia-spirits.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "excesssecurity.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "expanddigital.media", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "expiscor.solutions", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "falegname-roma.it", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "falldennismarketing.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fantastici.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "farrelf.blog", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fassaden-selleng.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fastcash.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "feegg.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fhmkh.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fil.fi", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "filtr.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fishgen.no", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "foluomeng.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "francetraceur.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "freerealincest.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "freesoftlab.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fs257.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fsj4u.ch", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "fuantaishenhaimuli.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "funds.ddns.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gamereader.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "genoveve.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gesundes-im-napf.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "getdeveloper.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ghibli.studio", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "givip.eu", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "glicerina.online", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "griechische-pfoetchen.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "griyo.online", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gsaj114.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gubagoo.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gupfen.ch", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "gxmyqy.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "healthgames.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hg525.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hilltopcellar.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "himekomi.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hjkbm.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hjkhs.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hjtky.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hmcdj.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hoarding.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hoeveiligismijn.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "honey.is", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hoodiecrow.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "horecaapparatuurkobezuijen.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "huashan.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hubertmoszka.pl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "hydrazin.pw", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "idafauziyah.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "idealninajemce.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "illicitdigital.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "imediafly.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "imprimante-3d-store.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "incestporn.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "infocusvr.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "inku.ovh", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "innovum.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "invidio.us", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ioerror.us", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "iotfen.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ipv8.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ironpeak.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "isaacdgoodman.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "itn.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "iyuanbao.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jacobamunch.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jakebeardsley.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jamie.ie", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jamjestsimon.pl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jaysaw.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jfbst.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "johannesen.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "johnsanchez.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "johnyytb.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jong030.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jordanp.engineer", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "jvega.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kati0.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "keelove.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "keihin-chaplin.jp", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kelderwijnen.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kffs.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kimo.se", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kimtran.kim", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "kinos.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "lavoieducoeur.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "liam-is-a-nig.ga", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "lieberwirth.biz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "lightbox.co", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "listekdo.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "livinglocalnashville.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "lobosdomain.ddns.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "lode.li", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "logtalk.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "logtalk.pt", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "luckydog.pw", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "luoxingyu.ml", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "maintenance-traceur-hp.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "majkassab.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "manfredi.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mar-eco.no", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "marcelwiedemeier.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "marshmallow.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "matridiana.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mcinterface.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "medi.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "medienweite.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "melillaorienta.es", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mercier-auto.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mercier-cars.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "michele.ml", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mijndiad.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "milftube.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mobiletry.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "monkay.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "montredeal.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "moo.pet", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mruganiepodspacja.pl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mtrip.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "mulenvo.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "multisite.ovh", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "myammo.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "navienna.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "neflabs.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "netspeedia.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nexttv.co.il", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nginxconfig.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nhsolutions.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nightstand.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "njast.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "novinivo.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "np-edv.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nugetdependencies.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nutrieduca.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "nyhaoyuan.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "odosblog.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "office-discount.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "okashi.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "omeuanimal.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "openmetals.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ouglor.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "p-t.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "paintingindurban.co.za", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "parisprovincedemenagements.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pasportaservo.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "passendonderwijs.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pci-e.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "peinard.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pensionpilot.ca", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "philsown.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pilot.co", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pilotgrowth.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pix-geeks.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "playyou.be", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pmsfdev.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "pornoserver.eu", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "portablespeakersfinder.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "powaclub.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "premierjewelersjax.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "prmte.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "promesa.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "purplebricks.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "purplebricks.com.au", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "purplemet.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "qabalah.jp", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "qq52o.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "quantumpair.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "quintype.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "racesport.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "radiosendungen.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "raphaeladdile.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "realfamilyporn.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "realfamilysex.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "realfreedom.city", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "realincest.tv", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "realincestporn.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "really-simple-plugins.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "redporno.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ressos.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "rhevelo.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "robdavidson.network", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "romano.guru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "rootspersona.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "roundaboutweb.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ruquay.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "salvaalocombia.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "schmelle.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "scholz-kallies.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "scpslgame.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "securitysense.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "see.wtf", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sergeemond.ca", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "serkaneles.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sfcomercio.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shafou.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shalazine.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sharpe-practice.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shehaal.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shirtsdelivered.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shlmail.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "showroom.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "showroom.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "shrug.ml", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "silvobeat.blog", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "simark.ca", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sjv4u.ch", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "skifttiljutlanderbank.dk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "smmcab.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "smsk.email", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "smsk.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "smskmail.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "softw.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "somosnoticia.com.br", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "spanda.io", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "staklim-malang.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "steerty.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "stefanorossi.it", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "storytea.top", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "stuartmorris.id.au", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "stuartmorris.name", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "stuartmorris.tel", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sublocale.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "sugartownfarm.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "szymczak.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "taddiestales.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "takuhai12.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "taplemon.at", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "taplemon.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tatildukkani.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tcspartner.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "techbelife.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "teesypeesy.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "telefoon.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "terabyteharddrive.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "thallinger.me", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "theactuary.ninja", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "thebannerstore.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "theeighthbit.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tir-mauperthuis.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tonkayagran.ru", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "torontostarts.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "touhouwiki.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "transbike.es", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "transfers.mx", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tsukeawase.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tulenceria.es", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "tungstenroyce.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "uclip.club", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "uktw.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ulovdomov.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "unblocked.mx", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "unstockd.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "usuan.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "utazas-nyaralas.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "vase-eroticke-povidky.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "vbwinery.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "vcraftaudio.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "vdzwan.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "veggie-treff.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "versicherungen-werner-hahn.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "villesalonen.fi", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "virtualhealth.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "voidcore.org", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "votesandymurman.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wanquanojbk.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wealthformyhealth.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "webstijlen.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "welovecatsandkittens.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wentu.ml", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wesoco.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wewitro.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wgplatform.co.uk", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "whatsupdeco.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wingmin.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wjci.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wolfarth.info", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "workcheck.bz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wptomatic.de", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wrapit.hu", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "writeenglishright.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ww0512.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wwbsb.xyz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "wwjd.dynu.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xiaobude.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xice.cf", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xmtpro.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xn--80aejljbfwxn.xn--p1ai", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xn--dk8haaa.ws", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xn--lckwg.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xn--wq9h.ml", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy1919.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy6161.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy6262.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy6363.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy7171.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy7272.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "xy7373.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "ycherbonnel.fr", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "yh35.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "yigujin.cn", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "youareme.ca", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "younl.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "your-erotic-stories.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "yxt521.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zaagbaak.nl", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zenti.cloud", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zg-dyw.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zhangheda.cf", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zikinf.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zirtual.com", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zkzone.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zonadigital.co", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zonky.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zonkysetkani.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zooplankton.no", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zs-reporyje.cz", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zubora.co", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, + { "name": "zzekj.net", "policy": "bulk-1-year", "mode": "force-https", "include_subdomains": true }, // END OF 1-YEAR BULK HSTS ENTRIES // Only eTLD+1 domains can be submitted automatically to hstspreload.org,
diff --git a/notification_helper/README.md b/notification_helper/README.md index 981b99c3..73fca79 100644 --- a/notification_helper/README.md +++ b/notification_helper/README.md
@@ -3,12 +3,12 @@ This is a standalone executable. It launches Chrome using a certain command line. -This executable is invoked when a toast is activated from the Windows Action -Center. Once running, the process registers the NotificationActivator class -object to a COM module. This allows COM to create the object and call its -Activate() method to handle toast activation when required. Once COM finishes -the work, the NotificationActivator class is unregistered from the module. The -process then exits. +This executable is designed to be launched by COM only. It is launched when a +toast is activated from the Windows Action Center. Once running, the process +registers the NotificationActivator class object to a COM module. This allows +COM to create the object and call its Activate() method to handle toast +activation when required. Once COM finishes the work, the NotificationActivator +class is unregistered from the module. The process then exits. A NotificationActivator's CLSID depends on its Chrome channel, allowing different NotificationActivators to be created per Chrome channel.
diff --git a/notification_helper/notification_helper.cc b/notification_helper/notification_helper.cc index f6e88182..2c001bf 100644 --- a/notification_helper/notification_helper.cc +++ b/notification_helper/notification_helper.cc
@@ -20,14 +20,21 @@ HINSTANCE prev_instance, wchar_t* command_line, int show_command) { + // Initialize the CommandLine singleton from the environment. + base::CommandLine::Init(0, nullptr); + + // This process is designed to be launched by COM only, which appends the + // "-Embedding" flag to the command line. If this flag is not found, the + // process should exit immediately. + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms683844.aspx + if (!base::CommandLine::ForCurrentProcess()->HasSwitch("embedding")) + return 0; + install_static::InitializeProductDetailsForPrimaryModule(); // The exit manager is in charge of calling the dtors of singletons. base::AtExitManager exit_manager; - // Initialize the CommandLine singleton from the environment. - base::CommandLine::Init(0, nullptr); - // Use crashpad embedded in chrome.exe as the crash handler. base::FilePath chrome_exe_path = notification_helper::GetChromeExePath(); if (!chrome_exe_path.empty()) {
diff --git a/remoting/protocol/webrtc_frame_scheduler_simple.cc b/remoting/protocol/webrtc_frame_scheduler_simple.cc index 9d24cfc..be4b61f3 100644 --- a/remoting/protocol/webrtc_frame_scheduler_simple.cc +++ b/remoting/protocol/webrtc_frame_scheduler_simple.cc
@@ -6,6 +6,7 @@ #include <algorithm> +#include "base/time/default_tick_clock.h" #include "remoting/base/constants.h" #include "remoting/protocol/frame_stats.h" #include "remoting/protocol/webrtc_bandwidth_estimator.h" @@ -62,7 +63,8 @@ // TODO(zijiehe): Use |options| to select bandwidth estimator. WebrtcFrameSchedulerSimple::WebrtcFrameSchedulerSimple( const SessionOptions& options) - : pacing_bucket_(LeakyBucket::kUnlimitedDepth, 0), + : tick_clock_(base::DefaultTickClock::GetInstance()), + pacing_bucket_(LeakyBucket::kUnlimitedDepth, 0), updated_region_area_(kStatsWindow), bandwidth_estimator_(new WebrtcBandwidthEstimator()), weak_factory_(this) {} @@ -92,8 +94,8 @@ bandwidth_estimator_->OnBitrateEstimation(bandwidth_kbps); processing_time_estimator_.SetBandwidthKbps( bandwidth_estimator_->GetBitrateKbps()); - pacing_bucket_.UpdateRate( - bandwidth_estimator_->GetBitrateKbps() * 1000 / 8, Now()); + pacing_bucket_.UpdateRate(bandwidth_estimator_->GetBitrateKbps() * 1000 / 8, + tick_clock_->NowTicks()); ScheduleNextFrame(); } @@ -122,7 +124,7 @@ WebrtcVideoEncoder::FrameParams* params_out) { DCHECK(thread_checker_.CalledOnValidThread()); - base::TimeTicks now = Now(); + base::TimeTicks now = tick_clock_->NowTicks(); // Null |frame| indicates a capturer error. if (!frame) { @@ -204,7 +206,7 @@ DCHECK(frame_pending_); frame_pending_ = false; - base::TimeTicks now = Now(); + base::TimeTicks now = tick_clock_->NowTicks(); if (frame_stats) { // Calculate |send_pending_delay| before refilling |pacing_bucket_|. @@ -237,13 +239,14 @@ bandwidth_estimator_->OnSendingFrame(*encoded_frame); } -void WebrtcFrameSchedulerSimple::SetCurrentTimeForTest(base::TimeTicks now) { - fake_now_for_test_ = now; +void WebrtcFrameSchedulerSimple::SetTickClockForTest( + base::TickClock* tick_clock) { + tick_clock_ = tick_clock; } void WebrtcFrameSchedulerSimple::ScheduleNextFrame() { DCHECK(thread_checker_.CalledOnValidThread()); - base::TimeTicks now = Now(); + base::TimeTicks now = tick_clock_->NowTicks(); if (!encoder_ready_ || paused_ || pacing_bucket_.rate() == 0 || capture_callback_.is_null() || frame_pending_) { @@ -274,16 +277,11 @@ void WebrtcFrameSchedulerSimple::CaptureNextFrame() { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(!frame_pending_); - last_capture_started_time_ = Now(); + last_capture_started_time_ = tick_clock_->NowTicks(); processing_time_estimator_.StartFrame(); frame_pending_ = true; capture_callback_.Run(); } -base::TimeTicks WebrtcFrameSchedulerSimple::Now() { - return fake_now_for_test_.is_null() ? base::TimeTicks::Now() - : fake_now_for_test_; -} - } // namespace protocol } // namespace remoting
diff --git a/remoting/protocol/webrtc_frame_scheduler_simple.h b/remoting/protocol/webrtc_frame_scheduler_simple.h index e270ba8..fea084f 100644 --- a/remoting/protocol/webrtc_frame_scheduler_simple.h +++ b/remoting/protocol/webrtc_frame_scheduler_simple.h
@@ -11,6 +11,7 @@ #include "base/containers/queue.h" #include "base/threading/thread_checker.h" +#include "base/time/tick_clock.h" #include "base/timer/timer.h" #include "remoting/base/leaky_bucket.h" #include "remoting/base/running_samples.h" @@ -47,19 +48,16 @@ void OnFrameEncoded(const WebrtcVideoEncoder::EncodedFrame* encoded_frame, HostFrameStats* frame_stats) override; - // Allows unit-tests to fake the current time. - void SetCurrentTimeForTest(base::TimeTicks now); + // Allows unit-tests to provide a mock clock. + void SetTickClockForTest(base::TickClock* tick_clock); private: void ScheduleNextFrame(); void CaptureNextFrame(); - // Returns the current time according to base::TimeTicks::Now(), - // or a fake time provided by a unit-test. - base::TimeTicks Now(); - - // Non-null if a fake current time is set by unit-test. - base::TimeTicks fake_now_for_test_; + // A TimeTicks provider which defaults to using a real system clock, but can + // be replaced for unittests. + base::TickClock* tick_clock_; base::Closure capture_callback_; bool paused_ = false;
diff --git a/remoting/protocol/webrtc_frame_scheduler_unittest.cc b/remoting/protocol/webrtc_frame_scheduler_unittest.cc index adfd1c8..c00c712 100644 --- a/remoting/protocol/webrtc_frame_scheduler_unittest.cc +++ b/remoting/protocol/webrtc_frame_scheduler_unittest.cc
@@ -4,7 +4,7 @@ #include "remoting/protocol/webrtc_frame_scheduler.h" -#include "base/test/test_simple_task_runner.h" +#include "base/test/test_mock_time_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "remoting/base/session_options.h" #include "remoting/protocol/webrtc_dummy_video_encoder.h" @@ -22,35 +22,46 @@ class WebrtcFrameSchedulerTest : public ::testing::Test { public: WebrtcFrameSchedulerTest() - : task_runner_(new base::TestSimpleTaskRunner()), + : task_runner_( + // Default ctor starts clock with null TimeTicks, which confuses + // the scheduler, so use the current time as a baseline. + new base::TestMockTimeTaskRunner(base::Time::Now(), + base::TimeTicks::Now())), task_runner_handle_(task_runner_.get()), - now_(base::TimeTicks::Now()) { + frame_(DesktopSize(1, 1)) { video_encoder_factory_.reset(new WebrtcDummyVideoEncoderFactory()); scheduler_.reset(new WebrtcFrameSchedulerSimple(SessionOptions())); - scheduler_->SetCurrentTimeForTest(now_); + scheduler_->SetTickClockForTest(task_runner_->GetMockTickClock()); scheduler_->Start(video_encoder_factory_.get(), base::Bind(&WebrtcFrameSchedulerTest::CaptureCallback, base::Unretained(this))); } ~WebrtcFrameSchedulerTest() override = default; - void CaptureCallback() { capture_callback_called_ = true; } + void CaptureCallback() { + capture_callback_count_++; - void VerifyCaptureCallbackCalled() { - EXPECT_TRUE(capture_callback_called_); - capture_callback_called_ = false; + if (simulate_capture_) { + // Simulate a completed capture and encode. + WebrtcVideoEncoder::FrameParams out_params; + scheduler_->OnFrameCaptured(&frame_, &out_params); + WebrtcVideoEncoder::EncodedFrame encoded; + encoded.key_frame = out_params.key_frame; + encoded.data = 'X'; + scheduler_->OnFrameEncoded(&encoded, nullptr); + } } protected: - scoped_refptr<base::TestSimpleTaskRunner> task_runner_; + scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; base::ThreadTaskRunnerHandle task_runner_handle_; std::unique_ptr<WebrtcDummyVideoEncoderFactory> video_encoder_factory_; std::unique_ptr<WebrtcFrameSchedulerSimple> scheduler_; - bool capture_callback_called_ = false; - - base::TimeTicks now_; + int capture_callback_count_ = 0; + bool simulate_capture_ = false; + BasicDesktopFrame frame_; }; TEST_F(WebrtcFrameSchedulerTest, UpdateBitrateWhenPending) { @@ -61,9 +72,9 @@ video_channel_observer->OnTargetBitrateChanged(100); EXPECT_TRUE(task_runner_->HasPendingTask()); - task_runner_->RunPendingTasks(); + task_runner_->FastForwardUntilNoTasksRemain(); - VerifyCaptureCallbackCalled(); + EXPECT_EQ(1, capture_callback_count_); video_channel_observer->OnTargetBitrateChanged(1001); @@ -79,13 +90,13 @@ video_channel_observer->OnTargetBitrateChanged(100); WebrtcVideoEncoder::FrameParams out_params; - BasicDesktopFrame frame(DesktopSize(1, 1)); + // Initial capture, full frame. - frame.mutable_updated_region()->SetRect(DesktopRect::MakeWH(1, 1)); - scheduler_->OnFrameCaptured(&frame, &out_params); + frame_.mutable_updated_region()->SetRect(DesktopRect::MakeWH(1, 1)); + scheduler_->OnFrameCaptured(&frame_, &out_params); // Empty frame. - frame.mutable_updated_region()->Clear(); - bool result = scheduler_->OnFrameCaptured(&frame, &out_params); + frame_.mutable_updated_region()->Clear(); + bool result = scheduler_->OnFrameCaptured(&frame_, &out_params); // Should not be sent, because of throttling of empty frames. EXPECT_FALSE(result); @@ -99,22 +110,40 @@ video_channel_observer->OnTargetBitrateChanged(100); WebrtcVideoEncoder::FrameParams out_params; - BasicDesktopFrame frame(DesktopSize(1, 1)); + // Initial capture, full frame. - frame.mutable_updated_region()->SetRect(DesktopRect::MakeWH(1, 1)); - scheduler_->OnFrameCaptured(&frame, &out_params); + frame_.mutable_updated_region()->SetRect(DesktopRect::MakeWH(1, 1)); + scheduler_->OnFrameCaptured(&frame_, &out_params); // Wait more than 2000ms. - scheduler_->SetCurrentTimeForTest(now_ + - base::TimeDelta::FromMilliseconds(3000)); + task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(3000)); // Empty frame. - frame.mutable_updated_region()->Clear(); - bool result = scheduler_->OnFrameCaptured(&frame, &out_params); + frame_.mutable_updated_region()->Clear(); + bool result = scheduler_->OnFrameCaptured(&frame_, &out_params); // Empty frames should be sent at the throttled rate. EXPECT_TRUE(result); }; -// TODO(sergeyu): Add more unittests. +TEST_F(WebrtcFrameSchedulerTest, Capturer_RunsAt30Fps) { + simulate_capture_ = true; + + auto video_channel_observer = + video_encoder_factory_->get_video_channel_state_observer_for_tests(); + video_channel_observer->OnTargetBitrateChanged(100); + + // Have the capturer return non-empty frames each time. + frame_.mutable_updated_region()->SetRect(DesktopRect::MakeWH(1, 1)); + + // Ensure the encoder is ready, otherwise the scheduler will not trigger + // repeated captures. + video_channel_observer->OnKeyFrameRequested(); + + task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(1)); + + // There should be approximately 30 captures in 1 second. + EXPECT_LE(29, capture_callback_count_); + EXPECT_LE(capture_callback_count_, 31); +} } // namespace protocol } // namespace remoting
diff --git a/services/network/BUILD.gn b/services/network/BUILD.gn index a7cf45ba..66a45f78 100644 --- a/services/network/BUILD.gn +++ b/services/network/BUILD.gn
@@ -52,12 +52,6 @@ "resource_scheduler_client.h", "restricted_cookie_manager.cc", "restricted_cookie_manager.h", - "socket_factory.cc", - "socket_factory.h", - "tcp_connected_socket.cc", - "tcp_connected_socket.h", - "tcp_server_socket.cc", - "tcp_server_socket.h", "throttling/network_conditions.cc", "throttling/network_conditions.h", "throttling/throttling_controller.cc", @@ -72,6 +66,8 @@ "throttling/throttling_upload_data_stream.h", "udp_socket.cc", "udp_socket.h", + "udp_socket_factory.cc", + "udp_socket_factory.h", "upload_progress_tracker.cc", "upload_progress_tracker.h", "url_loader.cc", @@ -143,11 +139,11 @@ "proxy_resolving_client_socket_unittest.cc", "resource_scheduler_unittest.cc", "restricted_cookie_manager_unittest.cc", - "tcp_socket_unittest.cc", "test/test_url_loader_factory_unittest.cc", "test_chunked_data_pipe_getter.cc", "test_chunked_data_pipe_getter.h", "throttling/throttling_controller_unittest.cc", + "udp_socket_factory_unittest.cc", "udp_socket_unittest.cc", "upload_progress_tracker_unittest.cc", "url_loader_unittest.cc",
diff --git a/services/network/cross_origin_read_blocking.h b/services/network/cross_origin_read_blocking.h index a6eb63b7..48e3b9f 100644 --- a/services/network/cross_origin_read_blocking.h +++ b/services/network/cross_origin_read_blocking.h
@@ -30,7 +30,9 @@ kJson = 2, kPlain = 3, kOthers = 4, + kMax, + kInvalid = kMax, }; // Three conclusions are possible from sniffing a byte sequence:
diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 41fb0e7..60a07ff 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc
@@ -36,7 +36,6 @@ #include "net/reporting/reporting_policy.h" #include "net/ssl/channel_id_service.h" #include "net/ssl/default_channel_id_store.h" -#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_builder.h" #include "services/network/http_server_properties_pref_delegate.h" @@ -50,6 +49,7 @@ #include "services/network/throttling/network_conditions.h" #include "services/network/throttling/throttling_controller.h" #include "services/network/throttling/throttling_network_transaction_factory.h" +#include "services/network/udp_socket_factory.h" #include "services/network/url_loader.h" #include "services/network/url_loader_factory.h" #include "services/network/url_request_context_builder_mojo.h" @@ -92,8 +92,7 @@ mojom::NetworkContextParamsPtr params) : network_service_(network_service), params_(std::move(params)), - binding_(this, std::move(request)), - socket_factory_(network_service_->net_log()) { + binding_(this, std::move(request)) { url_request_context_owner_ = MakeURLRequestContext(params_.get()); url_request_context_getter_ = url_request_context_owner_.url_request_context_getter; @@ -116,8 +115,7 @@ std::unique_ptr<URLRequestContextBuilderMojo> builder) : network_service_(network_service), params_(std::move(params)), - binding_(this, std::move(request)), - socket_factory_(network_service_->net_log()) { + binding_(this, std::move(request)) { url_request_context_owner_ = ApplyContextParamsToBuilder( builder.get(), params_.get(), network_service->quic_disabled(), network_service->net_log()); @@ -138,9 +136,8 @@ url_request_context_getter_(std::move(url_request_context_getter)), binding_(this, std::move(request)), cookie_manager_(std::make_unique<CookieManager>( - url_request_context_getter_->GetURLRequestContext()->cookie_store())), - socket_factory_(network_service_ ? network_service_->net_log() - : nullptr) { + url_request_context_getter_->GetURLRequestContext() + ->cookie_store())) { // May be nullptr in tests. if (network_service_) network_service_->RegisterNetworkContext(this); @@ -225,10 +222,7 @@ } NetworkContext::NetworkContext(mojom::NetworkContextParamsPtr params) - : network_service_(nullptr), - params_(std::move(params)), - binding_(this), - socket_factory_(network_service_->net_log()) { + : network_service_(nullptr), params_(std::move(params)), binding_(this) { url_request_context_owner_ = MakeURLRequestContext(params_.get()); url_request_context_getter_ = url_request_context_owner_.url_request_context_getter; @@ -492,32 +486,9 @@ void NetworkContext::CreateUDPSocket(mojom::UDPSocketRequest request, mojom::UDPSocketReceiverPtr receiver) { - socket_factory_.CreateUDPSocket(std::move(request), std::move(receiver)); -} - -void NetworkContext::CreateTCPServerSocket( - const net::IPEndPoint& local_addr, - uint32_t backlog, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPServerSocketRequest request, - CreateTCPServerSocketCallback callback) { - socket_factory_.CreateTCPServerSocket( - local_addr, backlog, - static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation), - std::move(request), std::move(callback)); -} - -void NetworkContext::CreateTCPConnectedSocket( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPConnectedSocketRequest request, - mojom::TCPConnectedSocketObserverPtr observer, - CreateTCPConnectedSocketCallback callback) { - socket_factory_.CreateTCPConnectedSocket( - local_addr, remote_addr_list, - static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation), - std::move(request), std::move(observer), std::move(callback)); + if (!udp_socket_factory_) + udp_socket_factory_ = std::make_unique<UDPSocketFactory>(); + udp_socket_factory_->CreateUDPSocket(std::move(request), std::move(receiver)); } void NetworkContext::AddHSTSForTesting(const std::string& host,
diff --git a/services/network/network_context.h b/services/network/network_context.h index 0519c8a..0c558a5 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h
@@ -20,10 +20,8 @@ #include "services/network/cookie_manager.h" #include "services/network/http_cache_data_remover.h" #include "services/network/public/mojom/network_service.mojom.h" -#include "services/network/public/mojom/tcp_socket.mojom.h" #include "services/network/public/mojom/udp_socket.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" -#include "services/network/socket_factory.h" #include "services/network/url_request_context_owner.h" namespace net { @@ -35,6 +33,7 @@ class NetworkService; class ResourceScheduler; class ResourceSchedulerClient; +class UDPSocketFactory; class URLRequestContextBuilderMojo; // A NetworkContext creates and manages access to a URLRequestContext. @@ -113,19 +112,6 @@ mojom::NetworkConditionsPtr conditions) override; void CreateUDPSocket(mojom::UDPSocketRequest request, mojom::UDPSocketReceiverPtr receiver) override; - void CreateTCPServerSocket( - const net::IPEndPoint& local_addr, - uint32_t backlog, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPServerSocketRequest request, - CreateTCPServerSocketCallback callback) override; - void CreateTCPConnectedSocket( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPConnectedSocketRequest request, - mojom::TCPConnectedSocketObserverPtr observer, - CreateTCPConnectedSocketCallback callback) override; void AddHSTSForTesting(const std::string& host, base::Time expiry, bool include_subdomains, @@ -183,7 +169,7 @@ std::unique_ptr<CookieManager> cookie_manager_; - SocketFactory socket_factory_; + std::unique_ptr<UDPSocketFactory> udp_socket_factory_; std::vector<std::unique_ptr<HttpCacheDataRemover>> http_cache_data_removers_;
diff --git a/services/network/public/mojom/BUILD.gn b/services/network/public/mojom/BUILD.gn index e7003f2..606c72f 100644 --- a/services/network/public/mojom/BUILD.gn +++ b/services/network/public/mojom/BUILD.gn
@@ -70,7 +70,6 @@ "proxy_config_with_annotation.mojom", "request_context_frame_type.mojom", "restricted_cookie_manager.mojom", - "tcp_socket.mojom", "url_loader.mojom", "url_loader_factory.mojom", ]
diff --git a/services/network/public/mojom/network_service.mojom b/services/network/public/mojom/network_service.mojom index ff8d283..c939fc8 100644 --- a/services/network/public/mojom/network_service.mojom +++ b/services/network/public/mojom/network_service.mojom
@@ -6,15 +6,12 @@ import "mojo/common/file_path.mojom"; import "mojo/common/time.mojom"; -import "net/interfaces/address_list.mojom"; import "net/interfaces/ip_endpoint.mojom"; import "services/network/public/mojom/cookie_manager.mojom"; -import "services/network/public/mojom/mutable_network_traffic_annotation_tag.mojom"; import "services/network/public/mojom/network_change_manager.mojom"; import "services/network/public/mojom/proxy_config.mojom"; import "services/network/public/mojom/proxy_config_with_annotation.mojom"; import "services/network/public/mojom/restricted_cookie_manager.mojom"; -import "services/network/public/mojom/tcp_socket.mojom"; import "services/network/public/mojom/udp_socket.mojom"; import "services/network/public/mojom/url_loader.mojom"; import "services/network/public/mojom/url_loader_factory.mojom"; @@ -190,46 +187,8 @@ // is not interested in incoming data. // Any sockets that are created but are yet to be destroyed will be destroyed // when NetworkContext goes away. - CreateUDPSocket(UDPSocket& request, UDPSocketReceiver? receiver); - - // Creates a TCP server socket that listens on |local_addr|. The socket - // created can only be used for the purpose specified in |traffic_annotation|, - // and cannot be re-used for other purposes. Caller must specify an address - // family in |local_addr| to be either IPv4 or IPv6. If port in |local_addr| - // is 0, the OS will pick an available port. If address bytes are 0, the OS - // will pick a local address of the specified address family. |backlog| will - // be passed to the OS to set the size of accept queue. - // On success, the resulting local address will be written to |local_addr_out| - // and |result| is net::OK. On failure, |result| is a network error code. - // - // Any sockets that are created but are yet to be destroyed will be destroyed - // when NetworkContext goes away. - CreateTCPServerSocket(net.interfaces.IPEndPoint local_addr, - uint32 backlog, - MutableNetworkTrafficAnnotationTag traffic_annotation, - TCPServerSocket& socket) - => (int32 result, net.interfaces.IPEndPoint? local_addr_out); - - // Creates a TCP socket connected to |remote_addr|. |observer| will be used - // to listen for any network connection error on the newly established - // connection. The socket created can only be used for the purpose specified - // in |traffic_annotation|, and cannot be re-used for other purposes. - // |local_addr| should be set to null unless the caller wants to bind the - // socket to a specific address and port. On success, |result| is net::OK. - // Caller is to use |send_stream| to send data and |receive_stream| to receive - // data over the connection. On failure, |result| is a network error code. - // - // Any sockets that are created but are yet to be destroyed will be destroyed - // when NetworkContext goes away. - CreateTCPConnectedSocket( - net.interfaces.IPEndPoint? local_addr, - net.interfaces.AddressList remote_addr_list, - MutableNetworkTrafficAnnotationTag traffic_annotation, - TCPConnectedSocket& socket, - TCPConnectedSocketObserver observer) - => (int32 result, - handle<data_pipe_consumer>? receive_stream, - handle<data_pipe_producer>? send_stream); + CreateUDPSocket(network.mojom.UDPSocket& request, + network.mojom.UDPSocketReceiver? receiver); [Sync] // Adds explicitly-specified data as if it was processed from an
diff --git a/services/network/public/mojom/tcp_socket.mojom b/services/network/public/mojom/tcp_socket.mojom deleted file mode 100644 index 0367f3a..0000000 --- a/services/network/public/mojom/tcp_socket.mojom +++ /dev/null
@@ -1,53 +0,0 @@ -// Copyright 2018 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. - -module network.mojom; - -import "net/interfaces/ip_endpoint.mojom"; - -// Represents a connected TCP socket. Writes and Reads are through the data -// pipes supplied upon construction. Consumer should use -// TCPConnectedSocketObserver interface to get notified about any error occurred -// during reading or writing to data pipes. Consumer can close the socket by -// destroying the interface pointer. -interface TCPConnectedSocket { - // Gets the local address of this connected socket. On success, |net_error| is - // net::OK and |local_addr| contains the local address of the socket. On - // failure, |local_addr| is null and |net_error| is a net error code. - GetLocalAddress() => (int32 net_error, net.interfaces.IPEndPoint? local_addr); -}; - -// Interface to listen for network connection error on a TCPConnectedSocket. -// Because data pipe doesn't surface any network connection error, if a network -// error happens during a read or a write, consumer can find out about it by -// implementing this interface. -interface TCPConnectedSocketObserver { - // Called when an error occurs during reading from the network. The producer - // side of |receive_stream| will be closed. - OnReadError(int32 net_error); - - // Called when an error occurs during sending to the network. The consumer - // side of |send_stream| will be closed. - OnWriteError(int32 net_error); -}; - -// Represents a TCP server socket that has been successfully bound to a local -// address. Caller can close the socket by destroying the interface pointer. -interface TCPServerSocket { - // Waits for an incoming connection request. On success, returns net::OK, - // |remote_addr| represents the peer address, |connected_socket| is the new - // connection established. Caller uses |send_stream| to send data and - // |receive_stream| for receiving data over the new connection. On failure, - // |net_error| is a net error code and other fields are null. - // Up to |backlog| Accept()s can be pending at a time. |backlog| is a - // number that is specified when requesting TCPServerSocket. If more than - // |backlog| number of Accept()s are outstanding, - // net::ERR_INSUFFICIENT_RESOUCES will be returned. - Accept(TCPConnectedSocketObserver observer) - => (int32 net_error, - net.interfaces.IPEndPoint? remote_addr, - TCPConnectedSocket? connected_socket, - handle<data_pipe_consumer>? send_stream, - handle<data_pipe_producer>? receive_stream); -};
diff --git a/services/network/socket_factory.cc b/services/network/socket_factory.cc deleted file mode 100644 index b4dca59..0000000 --- a/services/network/socket_factory.cc +++ /dev/null
@@ -1,69 +0,0 @@ -// Copyright 2018 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 "services/network/socket_factory.h" - -#include <utility> - -#include "base/memory/ptr_util.h" -#include "base/optional.h" -#include "net/base/completion_once_callback.h" -#include "net/base/net_errors.h" -#include "net/log/net_log.h" -#include "services/network/tcp_connected_socket.h" -#include "services/network/udp_socket.h" - -namespace network { - -SocketFactory::SocketFactory(net::NetLog* net_log) : net_log_(net_log) {} - -SocketFactory::~SocketFactory() {} - -void SocketFactory::CreateUDPSocket(mojom::UDPSocketRequest request, - mojom::UDPSocketReceiverPtr receiver) { - udp_socket_bindings_.AddBinding( - std::make_unique<UDPSocket>(std::move(receiver), net_log_), - std::move(request)); -} - -void SocketFactory::CreateTCPServerSocket( - const net::IPEndPoint& local_addr, - int backlog, - const net::NetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPServerSocketRequest request, - mojom::NetworkContext::CreateTCPServerSocketCallback callback) { - auto socket = - std::make_unique<TCPServerSocket>(this, net_log_, traffic_annotation); - net::IPEndPoint local_addr_out; - int result = socket->Listen(local_addr, backlog, &local_addr_out); - if (result != net::OK) { - std::move(callback).Run(result, base::nullopt); - return; - } - tcp_server_socket_bindings_.AddBinding(std::move(socket), std::move(request)); - std::move(callback).Run(result, local_addr_out); -} - -void SocketFactory::CreateTCPConnectedSocket( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - const net::NetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPConnectedSocketRequest request, - mojom::TCPConnectedSocketObserverPtr observer, - mojom::NetworkContext::CreateTCPConnectedSocketCallback callback) { - auto socket = std::make_unique<TCPConnectedSocket>( - std::move(observer), net_log_, traffic_annotation); - TCPConnectedSocket* socket_raw = socket.get(); - tcp_connected_socket_bindings_.AddBinding(std::move(socket), - std::move(request)); - socket_raw->Connect(local_addr, remote_addr_list, std::move(callback)); -} - -void SocketFactory::OnAccept(std::unique_ptr<TCPConnectedSocket> socket, - mojom::TCPConnectedSocketRequest request) { - tcp_connected_socket_bindings_.AddBinding(std::move(socket), - std::move(request)); -} - -} // namespace network
diff --git a/services/network/socket_factory.h b/services/network/socket_factory.h deleted file mode 100644 index 59d1ac67..0000000 --- a/services/network/socket_factory.h +++ /dev/null
@@ -1,75 +0,0 @@ -// Copyright 2018 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_NETWORK_SOCKET_FACTORY_H_ -#define SERVICES_NETWORK_SOCKET_FACTORY_H_ - -#include <memory> -#include <vector> - -#include "base/component_export.h" -#include "base/macros.h" -#include "mojo/public/cpp/bindings/strong_binding_set.h" -#include "net/socket/tcp_socket.h" -#include "net/traffic_annotation/network_traffic_annotation.h" -#include "services/network/public/mojom/network_service.mojom.h" -#include "services/network/public/mojom/tcp_socket.mojom.h" -#include "services/network/public/mojom/udp_socket.mojom.h" -#include "services/network/tcp_server_socket.h" - -namespace net { -class NetLog; -} // namespace net - -namespace network { - -class UDPSocket; -class TCPConnectedSocket; - -// Helper class that handles UDPSocketRequest. It takes care of destroying the -// UDPSocket implementation instances when mojo pipes are broken. -class COMPONENT_EXPORT(NETWORK_SERVICE) SocketFactory - : public TCPServerSocket::Delegate { - public: - // Constructs a SocketFactory. If |net_log| is non-null, it is used to - // log NetLog events when logging is enabled. |net_log| used to must outlive - // |this|. - explicit SocketFactory(net::NetLog* net_log); - virtual ~SocketFactory(); - - void CreateUDPSocket(mojom::UDPSocketRequest request, - mojom::UDPSocketReceiverPtr receiver); - void CreateTCPServerSocket( - const net::IPEndPoint& local_addr, - int backlog, - const net::NetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPServerSocketRequest request, - mojom::NetworkContext::CreateTCPServerSocketCallback callback); - void CreateTCPConnectedSocket( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - const net::NetworkTrafficAnnotationTag& traffic_annotation, - mojom::TCPConnectedSocketRequest request, - mojom::TCPConnectedSocketObserverPtr observer, - mojom::NetworkContext::CreateTCPConnectedSocketCallback callback); - - private: - // TCPServerSocket::Delegate implementation: - void OnAccept(std::unique_ptr<TCPConnectedSocket> socket, - mojom::TCPConnectedSocketRequest request) override; - - void OnConnectCompleted(int result); - - net::NetLog* net_log_; - mojo::StrongBindingSet<mojom::UDPSocket> udp_socket_bindings_; - mojo::StrongBindingSet<mojom::TCPServerSocket> tcp_server_socket_bindings_; - mojo::StrongBindingSet<mojom::TCPConnectedSocket> - tcp_connected_socket_bindings_; - - DISALLOW_COPY_AND_ASSIGN(SocketFactory); -}; - -} // namespace network - -#endif // SERVICES_NETWORK_SOCKET_FACTORY_H_
diff --git a/services/network/tcp_connected_socket.cc b/services/network/tcp_connected_socket.cc deleted file mode 100644 index 2962c9cf..0000000 --- a/services/network/tcp_connected_socket.cc +++ /dev/null
@@ -1,250 +0,0 @@ -// Copyright 2018 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 "services/network/tcp_connected_socket.h" - -#include <utility> - -#include "base/logging.h" -#include "base/memory/ptr_util.h" -#include "base/numerics/safe_conversions.h" -#include "base/optional.h" -#include "net/base/io_buffer.h" -#include "net/base/net_errors.h" -#include "net/log/net_log.h" - -namespace network { - -TCPConnectedSocket::TCPConnectedSocket( - mojom::TCPConnectedSocketObserverPtr observer, - net::NetLog* net_log, - const net::NetworkTrafficAnnotationTag& traffic_annotation) - : observer_(std::move(observer)), - net_log_(net_log), - readable_handle_watcher_(FROM_HERE, - mojo::SimpleWatcher::ArmingPolicy::MANUAL), - writable_handle_watcher_(FROM_HERE, - mojo::SimpleWatcher::ArmingPolicy::MANUAL), - traffic_annotation_(traffic_annotation) { - // TODO(xunjieli): Consider supporting null |observer_|, if there are - // consumers who do not care about read/write errors. - DCHECK(observer_); -} - -TCPConnectedSocket::TCPConnectedSocket( - mojom::TCPConnectedSocketObserverPtr observer, - std::unique_ptr<net::StreamSocket> socket, - mojo::ScopedDataPipeProducerHandle receive_pipe_handle, - mojo::ScopedDataPipeConsumerHandle send_pipe_handle, - const net::NetworkTrafficAnnotationTag& traffic_annotation) - : observer_(std::move(observer)), - net_log_(nullptr), - socket_(std::move(socket)), - send_stream_(std::move(send_pipe_handle)), - readable_handle_watcher_(FROM_HERE, - mojo::SimpleWatcher::ArmingPolicy::MANUAL), - receive_stream_(std::move(receive_pipe_handle)), - writable_handle_watcher_(FROM_HERE, - mojo::SimpleWatcher::ArmingPolicy::MANUAL), - traffic_annotation_(traffic_annotation) { - StartWatching(); -} - -TCPConnectedSocket::~TCPConnectedSocket() {} - -void TCPConnectedSocket::Connect( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - mojom::NetworkContext::CreateTCPConnectedSocketCallback callback) { - DCHECK(!socket_); - DCHECK(callback); - - auto socket = std::make_unique<net::TCPClientSocket>( - remote_addr_list, nullptr /*socket_performance_watcher*/, net_log_, - net::NetLogSource()); - connect_callback_ = std::move(callback); - int result = net::OK; - if (local_addr) - result = socket->Bind(local_addr.value()); - if (result == net::OK) { - result = socket->Connect(base::BindRepeating( - &TCPConnectedSocket::OnConnectCompleted, base::Unretained(this))); - } - socket_ = std::move(socket); - if (result == net::ERR_IO_PENDING) - return; - OnConnectCompleted(result); -} - -void TCPConnectedSocket::GetLocalAddress(GetLocalAddressCallback callback) { - DCHECK(socket_); - - net::IPEndPoint local_addr; - int result = socket_->GetLocalAddress(&local_addr); - if (result != net::OK) { - std::move(callback).Run(result, base::nullopt); - return; - } - std::move(callback).Run(result, local_addr); -} - -void TCPConnectedSocket::OnConnectCompleted(int result) { - DCHECK(!connect_callback_.is_null()); - DCHECK(!receive_stream_.is_valid()); - DCHECK(!send_stream_.is_valid()); - - if (result != net::OK) { - std::move(connect_callback_) - .Run(result, mojo::ScopedDataPipeConsumerHandle(), - mojo::ScopedDataPipeProducerHandle()); - return; - } - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - receive_stream_ = std::move(receive_pipe.producer_handle); - send_stream_ = std::move(send_pipe.consumer_handle); - - StartWatching(); - std::move(connect_callback_) - .Run(net::OK, std::move(receive_pipe.consumer_handle), - std::move(send_pipe.producer_handle)); -} - -void TCPConnectedSocket::StartWatching() { - readable_handle_watcher_.Watch( - send_stream_.get(), - MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, - base::BindRepeating(&TCPConnectedSocket::OnSendStreamReadable, - base::Unretained(this))); - writable_handle_watcher_.Watch( - receive_stream_.get(), - MOJO_HANDLE_SIGNAL_WRITABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, - base::BindRepeating(&TCPConnectedSocket::OnReceiveStreamWritable, - base::Unretained(this))); - ReceiveMore(); - SendMore(); -} - -void TCPConnectedSocket::ReceiveMore() { - DCHECK(receive_stream_.is_valid()); - DCHECK(!pending_receive_); - - uint32_t num_bytes; - MojoResult result = NetToMojoPendingBuffer::BeginWrite( - &receive_stream_, &pending_receive_, &num_bytes); - if (result == MOJO_RESULT_SHOULD_WAIT) { - writable_handle_watcher_.ArmOrNotify(); - return; - } - if (result != MOJO_RESULT_OK) { - ShutdownReceive(); - return; - } - DCHECK_EQ(MOJO_RESULT_OK, result); - DCHECK(pending_receive_); - scoped_refptr<net::IOBuffer> buf( - new NetToMojoIOBuffer(pending_receive_.get())); - int read_result = socket_->Read( - buf.get(), base::saturated_cast<int>(num_bytes), - base::BindRepeating(&TCPConnectedSocket::OnNetworkReadCompleted, - base::Unretained(this))); - if (read_result == net::ERR_IO_PENDING) - return; - OnNetworkReadCompleted(read_result); -} - -void TCPConnectedSocket::OnReceiveStreamWritable(MojoResult result) { - if (result != MOJO_RESULT_OK) { - ShutdownReceive(); - return; - } - ReceiveMore(); -} - -void TCPConnectedSocket::OnNetworkReadCompleted(int bytes_read) { - DCHECK(pending_receive_); - - if (bytes_read < 0) - observer_->OnReadError(bytes_read); - - if (bytes_read <= 0) { - ShutdownReceive(); - return; - } - if (bytes_read > 0) { - receive_stream_ = pending_receive_->Complete(bytes_read); - pending_receive_ = nullptr; - ReceiveMore(); - } -} - -void TCPConnectedSocket::ShutdownReceive() { - writable_handle_watcher_.Cancel(); - pending_receive_ = nullptr; - receive_stream_.reset(); -} - -void TCPConnectedSocket::SendMore() { - DCHECK(send_stream_.is_valid()); - DCHECK(!pending_send_); - - uint32_t num_bytes = 0; - MojoResult result = MojoToNetPendingBuffer::BeginRead( - &send_stream_, &pending_send_, &num_bytes); - if (result == MOJO_RESULT_SHOULD_WAIT) { - readable_handle_watcher_.ArmOrNotify(); - return; - } - if (result != MOJO_RESULT_OK) { - ShutdownSend(); - return; - } - DCHECK_EQ(MOJO_RESULT_OK, result); - DCHECK(pending_send_); - scoped_refptr<net::IOBuffer> buf( - new net::WrappedIOBuffer(pending_send_->buffer())); - int write_result = socket_->Write( - buf.get(), static_cast<int>(num_bytes), - base::BindRepeating(&TCPConnectedSocket::OnNetworkWriteCompleted, - base::Unretained(this)), - traffic_annotation_); - if (write_result == net::ERR_IO_PENDING) - return; - OnNetworkWriteCompleted(write_result); -} - -void TCPConnectedSocket::OnSendStreamReadable(MojoResult result) { - if (result != MOJO_RESULT_OK) { - ShutdownSend(); - return; - } - SendMore(); -} - -void TCPConnectedSocket::OnNetworkWriteCompleted(int bytes_written) { - DCHECK(pending_send_); - - if (bytes_written < 0) - observer_->OnWriteError(bytes_written); - if (bytes_written <= 0) { - ShutdownSend(); - return; - } - - if (bytes_written > 0) { - // Partial write is possible. - pending_send_->CompleteRead(bytes_written); - send_stream_ = pending_send_->ReleaseHandle(); - pending_send_ = nullptr; - SendMore(); - } -} - -void TCPConnectedSocket::ShutdownSend() { - readable_handle_watcher_.Cancel(); - pending_send_ = nullptr; - send_stream_.reset(); -} - -} // namespace network
diff --git a/services/network/tcp_connected_socket.h b/services/network/tcp_connected_socket.h deleted file mode 100644 index 17665feb..0000000 --- a/services/network/tcp_connected_socket.h +++ /dev/null
@@ -1,106 +0,0 @@ -// Copyright 2018 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_NETWORK_TCP_CONNECTED_SOCKET_H_ -#define SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_ - -#include <memory> - -#include "base/component_export.h" -#include "base/containers/span.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "mojo/public/cpp/system/data_pipe.h" -#include "mojo/public/cpp/system/simple_watcher.h" -#include "net/base/address_family.h" -#include "net/base/completion_callback.h" -#include "net/base/ip_endpoint.h" -#include "net/interfaces/address_family.mojom.h" -#include "net/interfaces/ip_endpoint.mojom.h" -#include "net/socket/tcp_client_socket.h" -#include "net/traffic_annotation/network_traffic_annotation.h" -#include "services/network/public/cpp/net_adapters.h" -#include "services/network/public/mojom/network_service.mojom.h" -#include "services/network/public/mojom/tcp_socket.mojom.h" - -namespace net { -class NetLog; -class StreamSocket; -} // namespace net - -namespace network { - -class COMPONENT_EXPORT(NETWORK_SERVICE) TCPConnectedSocket - : public mojom::TCPConnectedSocket { - public: - TCPConnectedSocket( - mojom::TCPConnectedSocketObserverPtr observer, - net::NetLog* net_log, - const net::NetworkTrafficAnnotationTag& traffic_annotation); - TCPConnectedSocket( - mojom::TCPConnectedSocketObserverPtr observer, - std::unique_ptr<net::StreamSocket> socket, - mojo::ScopedDataPipeProducerHandle receive_pipe_handle, - mojo::ScopedDataPipeConsumerHandle send_pipe_handle, - const net::NetworkTrafficAnnotationTag& traffic_annotation); - ~TCPConnectedSocket() override; - void Connect( - const base::Optional<net::IPEndPoint>& local_addr, - const net::AddressList& remote_addr_list, - mojom::NetworkContext::CreateTCPConnectedSocketCallback callback); - - // mojom::TCPConnectedSocket implementation. - void GetLocalAddress(GetLocalAddressCallback callback) override; - - private: - // Invoked when net::TCPClientSocket::Connect() completes. - void OnConnectCompleted(int net_result); - - // Helper to start watching |send_stream_| and |receive_stream_|. - void StartWatching(); - - // "Receiving" in this context means reading from |socket_| and writing to - // the Mojo |receive_stream_|. - void ReceiveMore(); - void OnReceiveStreamWritable(MojoResult result); - void OnNetworkReadCompleted(int result); - void ShutdownReceive(); - - // "Writing" is reading from the Mojo |send_stream_| and writing to the - // |socket_|. - void SendMore(); - void OnSendStreamReadable(MojoResult result); - void OnNetworkWriteCompleted(int result); - void ShutdownSend(); - - mojom::TCPConnectedSocketObserverPtr observer_; - - net::NetLog* net_log_; - - std::unique_ptr<net::StreamSocket> socket_; - - mojom::NetworkContext::CreateTCPConnectedSocketCallback connect_callback_; - - // The *stream handles will be null while there is an in-progress transation - // between net and mojo. During this time, the handle will be owned by the - // *PendingBuffer. - - // For reading from the Mojo pipe and writing to the network. - mojo::ScopedDataPipeConsumerHandle send_stream_; - scoped_refptr<MojoToNetPendingBuffer> pending_send_; - mojo::SimpleWatcher readable_handle_watcher_; - - // For reading from the network and writing to Mojo pipe. - mojo::ScopedDataPipeProducerHandle receive_stream_; - scoped_refptr<NetToMojoPendingBuffer> pending_receive_; - mojo::SimpleWatcher writable_handle_watcher_; - - net::NetworkTrafficAnnotationTag traffic_annotation_; - - DISALLOW_COPY_AND_ASSIGN(TCPConnectedSocket); -}; - -} // namespace network - -#endif // SERVICES_NETWORK_TCP_CONNECTED_SOCKET_H_
diff --git a/services/network/tcp_server_socket.cc b/services/network/tcp_server_socket.cc deleted file mode 100644 index e8f53dc..0000000 --- a/services/network/tcp_server_socket.cc +++ /dev/null
@@ -1,123 +0,0 @@ -// Copyright 2018 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 "services/network/tcp_server_socket.h" - -#include <utility> - -#include "base/logging.h" -#include "base/memory/ptr_util.h" -#include "base/numerics/safe_conversions.h" -#include "base/optional.h" -#include "net/base/io_buffer.h" -#include "net/base/net_errors.h" -#include "net/log/net_log.h" -#include "net/socket/tcp_server_socket.h" -#include "services/network/tcp_connected_socket.h" - -namespace network { - -TCPServerSocket::TCPServerSocket( - Delegate* delegate, - net::NetLog* net_log, - const net::NetworkTrafficAnnotationTag& traffic_annotation) - : delegate_(delegate), - socket_( - std::make_unique<net::TCPServerSocket>(net_log, net::NetLogSource())), - backlog_(0), - traffic_annotation_(traffic_annotation), - weak_factory_(this) {} - -TCPServerSocket::~TCPServerSocket() {} - -int TCPServerSocket::Listen(const net::IPEndPoint& local_addr, - int backlog, - net::IPEndPoint* local_addr_out) { - if (backlog == 0) { - // SocketPosix::Listen and TCPSocketWin::Listen DCHECKs on backlog > 0. - return net::ERR_INVALID_ARGUMENT; - } - backlog_ = backlog; - int net_error = socket_->Listen(local_addr, backlog); - if (net_error == net::OK) - socket_->GetLocalAddress(local_addr_out); - return net_error; -} - -void TCPServerSocket::Accept(mojom::TCPConnectedSocketObserverPtr observer, - AcceptCallback callback) { - if (pending_accepts_queue_.size() >= static_cast<size_t>(backlog_)) { - std::move(callback).Run(net::ERR_INSUFFICIENT_RESOURCES, base::nullopt, - nullptr, mojo::ScopedDataPipeConsumerHandle(), - mojo::ScopedDataPipeProducerHandle()); - return; - } - - pending_accepts_queue_.push_back(std::make_unique<PendingAccept>( - std::move(callback), std::move(observer))); - if (pending_accepts_queue_.size() == 1) - ProcessNextAccept(); -} - -void TCPServerSocket::SetSocketForTest( - std::unique_ptr<net::ServerSocket> socket) { - socket_ = std::move(socket); -} - -TCPServerSocket::PendingAccept::PendingAccept( - AcceptCallback callback, - mojom::TCPConnectedSocketObserverPtr observer) - : callback(std::move(callback)), observer(std::move(observer)) {} - -TCPServerSocket::PendingAccept::~PendingAccept() {} - -void TCPServerSocket::OnAcceptCompleted(int result) { - DCHECK_NE(net::ERR_IO_PENDING, result); - DCHECK(!pending_accepts_queue_.empty()); - - auto pending_accept = std::move(pending_accepts_queue_.front()); - pending_accepts_queue_.erase(pending_accepts_queue_.begin()); - - net::IPEndPoint peer_addr; - if (result == net::OK) { - DCHECK(accepted_socket_); - result = accepted_socket_->GetPeerAddress(&peer_addr); - } - if (result == net::OK) { - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - mojom::TCPConnectedSocketPtr socket; - auto connected_socket = std::make_unique<TCPConnectedSocket>( - std::move(pending_accept->observer), - base::WrapUnique(accepted_socket_.release()), - std::move(receive_pipe.producer_handle), - std::move(send_pipe.consumer_handle), traffic_annotation_); - delegate_->OnAccept(std::move(connected_socket), - mojo::MakeRequest(&socket)); - std::move(pending_accept->callback) - .Run(result, peer_addr, std::move(socket), - std::move(receive_pipe.consumer_handle), - std::move(send_pipe.producer_handle)); - } else { - std::move(pending_accept->callback) - .Run(result, base::nullopt, nullptr, - mojo::ScopedDataPipeConsumerHandle(), - mojo::ScopedDataPipeProducerHandle()); - } - ProcessNextAccept(); -} - -void TCPServerSocket::ProcessNextAccept() { - if (pending_accepts_queue_.empty()) - return; - int result = - socket_->Accept(&accepted_socket_, - base::BindRepeating(&TCPServerSocket::OnAcceptCompleted, - base::Unretained(this))); - if (result == net::ERR_IO_PENDING) - return; - OnAcceptCompleted(result); -} - -} // namespace network
diff --git a/services/network/tcp_server_socket.h b/services/network/tcp_server_socket.h deleted file mode 100644 index 0b52d11d..0000000 --- a/services/network/tcp_server_socket.h +++ /dev/null
@@ -1,91 +0,0 @@ -// Copyright 2018 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_NETWORK_TCP_SERVER_SOCKET_H_ -#define SERVICES_NETWORK_TCP_SERVER_SOCKET_H_ - -#include <memory> -#include <vector> - -#include "base/component_export.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/memory/weak_ptr.h" -#include "mojo/public/cpp/bindings/interface_request.h" -#include "net/base/ip_endpoint.h" -#include "net/traffic_annotation/network_traffic_annotation.h" -#include "services/network/public/mojom/tcp_socket.mojom.h" - -namespace net { -class NetLog; -class ServerSocket; -class StreamSocket; -} // namespace net - -namespace network { -class TCPConnectedSocket; - -class COMPONENT_EXPORT(NETWORK_SERVICE) TCPServerSocket - : public mojom::TCPServerSocket { - public: - // A delegate interface that is notified when new connections are established. - class Delegate { - public: - Delegate() {} - ~Delegate() {} - - // Invoked when a new connection is accepted. The delegate should take - // ownership of |socket| and set up binding for |request|. - virtual void OnAccept(std::unique_ptr<TCPConnectedSocket> socket, - mojom::TCPConnectedSocketRequest request) = 0; - }; - - // Constructs a TCPServerSocket. |delegate| must outlive |this|. When a new - // connection is accepted, |delegate| will be notified to take ownership of - // the connection. - TCPServerSocket(Delegate* delegate, - net::NetLog* net_log, - const net::NetworkTrafficAnnotationTag& traffic_annotation); - ~TCPServerSocket() override; - - int Listen(const net::IPEndPoint& local_addr, - int backlog, - net::IPEndPoint* local_addr_out); - - // TCPServerSocket implementation. - void Accept(mojom::TCPConnectedSocketObserverPtr observer, - AcceptCallback callback) override; - - // Replaces the underlying socket implementation with |socket| in tests. - void SetSocketForTest(std::unique_ptr<net::ServerSocket> socket); - - private: - struct PendingAccept { - PendingAccept(AcceptCallback callback, - mojom::TCPConnectedSocketObserverPtr observer); - ~PendingAccept(); - - AcceptCallback callback; - mojom::TCPConnectedSocketObserverPtr observer; - }; - // Invoked when socket_->Accept() completes. - void OnAcceptCompleted(int result); - // Process the next Accept() from |pending_accepts_queue_|. - void ProcessNextAccept(); - - Delegate* delegate_; - std::unique_ptr<net::ServerSocket> socket_; - int backlog_; - std::vector<std::unique_ptr<PendingAccept>> pending_accepts_queue_; - std::unique_ptr<net::StreamSocket> accepted_socket_; - net::NetworkTrafficAnnotationTag traffic_annotation_; - - base::WeakPtrFactory<TCPServerSocket> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(TCPServerSocket); -}; - -} // namespace network - -#endif // SERVICES_NETWORK_TCP_SERVER_SOCKET_H_
diff --git a/services/network/tcp_socket_unittest.cc b/services/network/tcp_socket_unittest.cc deleted file mode 100644 index ad367404..0000000 --- a/services/network/tcp_socket_unittest.cc +++ /dev/null
@@ -1,985 +0,0 @@ -// Copyright 2018 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 <stdint.h> - -#include <utility> - -#include "base/callback_helpers.h" -#include "base/location.h" -#include "base/logging.h" -#include "base/macros.h" -#include "base/run_loop.h" -#include "base/test/scoped_task_environment.h" -#include "base/threading/thread.h" -#include "mojo/common/data_pipe_utils.h" -#include "mojo/public/cpp/system/simple_watcher.h" -#include "net/base/completion_callback.h" -#include "net/base/completion_once_callback.h" -#include "net/base/net_errors.h" -#include "net/base/test_completion_callback.h" -#include "net/socket/server_socket.h" -#include "net/socket/socket_test_util.h" -#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" -#include "services/network/public/mojom/network_service.mojom.h" -#include "services/network/public/mojom/udp_socket.mojom.h" -#include "services/network/socket_factory.h" -#include "services/network/tcp_connected_socket.h" -#include "services/network/tcp_server_socket.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace network { - -namespace { - -// A mock ServerSocket that completes Accept() using a specified result. -class MockServerSocket : public net::ServerSocket { - public: - MockServerSocket() {} - ~MockServerSocket() override {} - - // net::ServerSocket implementation. - int Listen(const net::IPEndPoint& address, int backlog) override { - return net::OK; - } - - int GetLocalAddress(net::IPEndPoint* address) const override { - return net::OK; - } - - int Accept(std::unique_ptr<net::StreamSocket>* socket, - const net::CompletionCallback& callback) override { - DCHECK(accept_callback_.is_null()); - if (accept_result_ == net::OK && mode_ == net::SYNCHRONOUS) - *socket = CreateMockAcceptSocket(); - if (mode_ == net::ASYNC || accept_result_ == net::ERR_IO_PENDING) { - accept_socket_ = socket; - accept_callback_ = callback; - } - run_loop_.Quit(); - - if (mode_ == net::ASYNC) { - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(&MockServerSocket::CompleteAccept, - base::Unretained(this), accept_result_)); - return net::ERR_IO_PENDING; - } - return accept_result_; - } - - void SetAcceptResult(net::IoMode mode, int result) { - // It doesn't make sense to return net::ERR_IO_PENDING asynchronously. - DCHECK(!(mode == net::ASYNC && result == net::ERR_IO_PENDING)); - - mode_ = mode; - accept_result_ = result; - } - - void WaitForFirstAccept() { run_loop_.Run(); } - - void CompleteAccept(int result) { - DCHECK(!accept_callback_.is_null()); - DCHECK_NE(net::ERR_IO_PENDING, result); - - *accept_socket_ = CreateMockAcceptSocket(); - accept_socket_ = nullptr; - base::ResetAndReturn(&accept_callback_).Run(result); - } - - private: - // Must live longer than all SocketDataProviders. - const net::MockRead kReads[1] = { - net::MockRead(net::ASYNC, net::ERR_IO_PENDING)}; - - std::unique_ptr<net::StreamSocket> CreateMockAcceptSocket() { - auto data_provider = std::make_unique<net::StaticSocketDataProvider>( - kReads, arraysize(kReads), nullptr, 0); - data_provider->set_connect_data( - net::MockConnect(net::SYNCHRONOUS, net::OK)); - auto mock_socket = std::make_unique<net::MockTCPClientSocket>( - net::AddressList(), nullptr /*netlog*/, data_provider.get()); - data_providers_.push_back(std::move(data_provider)); - EXPECT_EQ(net::OK, mock_socket->Connect(base::DoNothing())); - return std::move(mock_socket); - } - - net::IoMode mode_ = net::SYNCHRONOUS; - int accept_result_ = net::OK; - net::CompletionCallback accept_callback_; - std::unique_ptr<net::StreamSocket>* accept_socket_; - base::RunLoop run_loop_; - std::vector<std::unique_ptr<net::StaticSocketDataProvider>> data_providers_; -}; - -class TestTCPConnectedSocketObserver - : public mojom::TCPConnectedSocketObserver { - public: - TestTCPConnectedSocketObserver() : binding_(this) {} - ~TestTCPConnectedSocketObserver() override { - EXPECT_EQ(net::OK, read_error_); - EXPECT_EQ(net::OK, write_error_); - } - - // Returns a mojo pointer. This can only be called once. - mojom::TCPConnectedSocketObserverPtr GetObserverPtr() { - DCHECK(!binding_); - mojom::TCPConnectedSocketObserverPtr ptr; - binding_.Bind(mojo::MakeRequest(&ptr)); - return ptr; - } - - // Waits for Read and Write error. Returns the error observed. - int WaitForReadError() { - read_loop_.Run(); - int error = read_error_; - read_error_ = net::OK; - return error; - } - - int WaitForWriteError() { - write_loop_.Run(); - int error = write_error_; - write_error_ = net::OK; - return error; - } - - private: - // mojom::TCPConnectedSocketObserver implementation. - void OnReadError(int net_error) override { - read_error_ = net_error; - read_loop_.Quit(); - } - - void OnWriteError(int net_error) override { - write_error_ = net_error; - write_loop_.Quit(); - } - - int read_error_ = net::OK; - int write_error_ = net::OK; - base::RunLoop read_loop_; - base::RunLoop write_loop_; - mojo::Binding<mojom::TCPConnectedSocketObserver> binding_; - - DISALLOW_COPY_AND_ASSIGN(TestTCPConnectedSocketObserver); -}; - -// A server implemented using mojom::TCPServerSocket. It owns the server socket -// pointer and as well as the latest client connection, -// mojom::TCPConnectedSocket. -class TestServer { - public: - TestServer() - : TestServer(net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0)) {} - explicit TestServer(const net::IPEndPoint& server_addr) - : factory_(nullptr), - readable_handle_watcher_(FROM_HERE, - mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC), - server_addr_(server_addr) {} - ~TestServer() {} - - void Start(uint32_t backlog) { - int net_error = net::ERR_FAILED; - base::RunLoop run_loop; - factory_.CreateTCPServerSocket( - server_addr_, backlog, TRAFFIC_ANNOTATION_FOR_TESTS, - mojo::MakeRequest(&server_socket_), - base::BindOnce( - [](base::RunLoop* run_loop, int* result_out, - net::IPEndPoint* local_addr_out, int result, - const base::Optional<net::IPEndPoint>& local_addr) { - *result_out = result; - if (local_addr) - *local_addr_out = local_addr.value(); - run_loop->Quit(); - }, - base::Unretained(&run_loop), base::Unretained(&net_error), - base::Unretained(&server_addr_))); - run_loop.Run(); - EXPECT_EQ(net::OK, net_error); - } - - // Accepts one connection. Upon successful completion, |callback| will be - // invoked. - void AcceptOneConnection(net::CompletionOnceCallback callback) { - observer_ = std::make_unique<TestTCPConnectedSocketObserver>(); - server_socket_->Accept( - observer_->GetObserverPtr(), - base::BindOnce(&TestServer::OnAccept, base::Unretained(this), - std::move(callback))); - } - - // Sends data over the most recent connection that is established. - void SendData(const std::string& msg) { - EXPECT_TRUE( - mojo::common::BlockingCopyFromString(msg, server_socket_send_handle_)); - } - - // Starts reading. Can be called multiple times. It cancels any previous - // StartReading(). Once |expected_contents| is read, |callback| will be - // invoked. If an error occurs or the pipe is broken before read can - // complete, |callback| will be run, but ADD_FAILURE() will be called. - void StartReading(const std::string& expected_contents, - base::OnceClosure callback) { - readable_handle_watcher_.Cancel(); - received_contents_.clear(); - expected_contents_ = expected_contents; - read_callback_ = std::move(callback); - readable_handle_watcher_.Watch( - server_socket_receive_handle_.get(), - MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, - base::BindRepeating(&TestServer::OnReadable, base::Unretained(this))); - } - - void DestroyServerSocket() { server_socket_.reset(); } - - const net::IPEndPoint& server_addr() { return server_addr_; } - - private: - void OnAccept(net::CompletionOnceCallback callback, - int result, - const base::Optional<net::IPEndPoint>& remote_addr, - mojom::TCPConnectedSocketPtr connected_socket, - mojo::ScopedDataPipeConsumerHandle receive_pipe_handle, - mojo::ScopedDataPipeProducerHandle send_pipe_handle) { - connected_socket_ = std::move(connected_socket); - server_socket_receive_handle_ = std::move(receive_pipe_handle); - server_socket_send_handle_ = std::move(send_pipe_handle); - std::move(callback).Run(result); - } - - void OnReadable(MojoResult result) { - if (result != MOJO_RESULT_OK) { - ADD_FAILURE() << "Unexpected broken pipe with error: " << result; - EXPECT_EQ(expected_contents_, received_contents_); - std::move(read_callback_).Run(); - return; - } - char buffer[16]; - uint32_t read_size = sizeof(buffer); - result = server_socket_receive_handle_->ReadData(buffer, &read_size, - MOJO_READ_DATA_FLAG_NONE); - if (result == MOJO_RESULT_SHOULD_WAIT) - return; - if (result != MOJO_RESULT_OK) { - ADD_FAILURE() << "Unexpected read error: " << result; - EXPECT_EQ(expected_contents_, received_contents_); - std::move(read_callback_).Run(); - return; - } - - received_contents_.append(buffer, read_size); - - if (received_contents_.size() == expected_contents_.size()) { - EXPECT_EQ(expected_contents_, received_contents_); - std::move(read_callback_).Run(); - } - } - - SocketFactory factory_; - mojom::TCPServerSocketPtr server_socket_; - mojom::TCPConnectedSocketPtr connected_socket_; - std::unique_ptr<TestTCPConnectedSocketObserver> observer_; - mojo::ScopedDataPipeConsumerHandle server_socket_receive_handle_; - mojo::ScopedDataPipeProducerHandle server_socket_send_handle_; - mojo::SimpleWatcher readable_handle_watcher_; - net::IPEndPoint server_addr_; - std::string expected_contents_; - base::OnceClosure read_callback_; - std::string received_contents_; -}; - -} // namespace - -class TCPSocketTest : public testing::Test { - public: - TCPSocketTest() - : scoped_task_environment_( - base::test::ScopedTaskEnvironment::MainThreadType::IO), - factory_(nullptr /*net_log*/) {} - ~TCPSocketTest() override {} - - // Reads |num_bytes| from |handle| or reads until an error occurs. Returns the - // bytes read as a string. - std::string Read(mojo::ScopedDataPipeConsumerHandle* handle, - size_t num_bytes) { - std::string received_contents; - while (received_contents.size() < num_bytes) { - base::RunLoop().RunUntilIdle(); - std::vector<char> buffer(num_bytes); - uint32_t read_size = static_cast<uint32_t>(num_bytes); - MojoResult result = handle->get().ReadData(buffer.data(), &read_size, - MOJO_READ_DATA_FLAG_NONE); - if (result == MOJO_RESULT_SHOULD_WAIT) - continue; - if (result != MOJO_RESULT_OK) - return received_contents; - received_contents.append(buffer.data(), read_size); - } - return received_contents; - } - - // Creates a TCPServerSocket with the mock server socket, |socket|. - void CreateServerSocketWithMockSocket( - uint32_t backlog, - mojom::TCPServerSocketRequest request, - std::unique_ptr<net::ServerSocket> socket) { - auto server_socket_impl = std::make_unique<TCPServerSocket>( - &factory_, nullptr /*netlog*/, TRAFFIC_ANNOTATION_FOR_TESTS); - server_socket_impl->SetSocketForTest(std::move(socket)); - net::IPEndPoint local_addr; - EXPECT_EQ(net::OK, - server_socket_impl->Listen(local_addr, backlog, &local_addr)); - tcp_server_socket_bindings_.AddBinding(std::move(server_socket_impl), - std::move(request)); - } - - // Creates a TCPConnectedSocket with a mock client socket, |socket|. - // This can be only called once. - void CreateConnectedSocketWithMockSocket( - mojom::TCPConnectedSocketRequest request, - mojo::ScopedDataPipeProducerHandle receive_pipe_handle, - mojo::ScopedDataPipeConsumerHandle send_pipe_handle, - std::unique_ptr<net::MockTCPClientSocket> socket) { - net::TestCompletionCallback dummy_callback; - EXPECT_EQ(net::OK, socket->Connect(dummy_callback.callback())); - auto socket_impl = std::make_unique<TCPConnectedSocket>( - test_observer_.GetObserverPtr(), std::move(socket), - std::move(receive_pipe_handle), std::move(send_pipe_handle), - TRAFFIC_ANNOTATION_FOR_TESTS); - tcp_connected_socket_bindings_.AddBinding(std::move(socket_impl), - std::move(request)); - } - - int CreateTCPConnectedSocketSync( - mojom::TCPConnectedSocketRequest request, - mojom::TCPConnectedSocketObserverPtr observer, - const base::Optional<net::IPEndPoint>& local_addr, - const net::IPEndPoint& remote_addr, - mojo::ScopedDataPipeConsumerHandle* receive_pipe_handle_out, - mojo::ScopedDataPipeProducerHandle* send_pipe_handle_out) { - net::AddressList remote_addr_list(remote_addr); - base::RunLoop run_loop; - int net_error = net::ERR_FAILED; - factory_.CreateTCPConnectedSocket( - local_addr, remote_addr_list, TRAFFIC_ANNOTATION_FOR_TESTS, - std::move(request), std::move(observer), - base::BindOnce( - [](base::RunLoop* run_loop, int* result_out, - mojo::ScopedDataPipeConsumerHandle* consumer_handle, - mojo::ScopedDataPipeProducerHandle* producer_handle, int result, - mojo::ScopedDataPipeConsumerHandle receive_pipe_handle, - mojo::ScopedDataPipeProducerHandle send_pipe_handle) { - *result_out = result; - *consumer_handle = std::move(receive_pipe_handle); - *producer_handle = std::move(send_pipe_handle); - run_loop->Quit(); - }, - base::Unretained(&run_loop), base::Unretained(&net_error), - receive_pipe_handle_out, send_pipe_handle_out)); - run_loop.Run(); - return net_error; - } - - TestTCPConnectedSocketObserver* observer() { return &test_observer_; } - - private: - base::test::ScopedTaskEnvironment scoped_task_environment_; - SocketFactory factory_; - TestTCPConnectedSocketObserver test_observer_; - mojo::StrongBindingSet<mojom::TCPServerSocket> tcp_server_socket_bindings_; - mojo::StrongBindingSet<mojom::TCPConnectedSocket> - tcp_connected_socket_bindings_; - - DISALLOW_COPY_AND_ASSIGN(TCPSocketTest); -}; - -TEST_F(TCPSocketTest, ReadAndWrite) { - const struct TestData { - base::Optional<net::IPEndPoint> client_addr; - net::IPEndPoint server_addr; - } kTestCases[] = { - {base::nullopt, net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0)}, - {base::nullopt, net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0)}, - {net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0), - net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0)}, - {net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0), - net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0)}, - }; - for (auto test : kTestCases) { - TestServer server(test.server_addr); - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - - mojom::TCPConnectedSocketPtr client_socket; - TestTCPConnectedSocketObserver observer; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - test.client_addr, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Test sending data from server to client. - const char kTestMsg[] = "hello"; - server.SendData(kTestMsg); - EXPECT_EQ(kTestMsg, - Read(&client_socket_receive_handle, arraysize(kTestMsg) - 1)); - - // Test sending data from client to server. - base::RunLoop read_run_loop; - server.StartReading(kTestMsg, read_run_loop.QuitClosure()); - EXPECT_TRUE(mojo::common::BlockingCopyFromString( - kTestMsg, client_socket_send_handle)); - read_run_loop.Run(); - } -} - -TEST_F(TCPSocketTest, CannotConnectToWrongInterface) { - const struct TestData { - net::IPEndPoint client_addr; - net::IPEndPoint server_addr; - } kTestCases[] = { - {net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0), - net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0)}, - {net::IPEndPoint(net::IPAddress::IPv4Localhost(), 0), - net::IPEndPoint(net::IPAddress::IPv6Localhost(), 0)}, - }; - for (auto test : kTestCases) { - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - - TestTCPConnectedSocketObserver observer; - TestServer server(test.server_addr); - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojom::TCPConnectedSocketPtr client_socket; - int result = CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - test.client_addr, server.server_addr(), &client_socket_receive_handle, - &client_socket_send_handle); - // Both net::ERR_INVALID_ARGUMENT and net::ERR_ADDRESS_UNREACHABLE can be - // returned. On Linux, for eample, the former is returned when talking ipv4 - // to a ipv6 remote, and the latter is returned when talking ipv6 to a ipv4 - // remote. net::ERR_CONNECTION_FAILED is returned on Windows. - EXPECT_TRUE(result == net::ERR_CONNECTION_FAILED || - result == net::ERR_INVALID_ARGUMENT || - result == net::ERR_ADDRESS_UNREACHABLE) - << "actual result: " << result; - } -} - -TEST_F(TCPSocketTest, ReadAndWriteMultiple) { - SocketFactory factory(nullptr /*net_log*/); - - TestServer server; - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - - TestTCPConnectedSocketObserver observer; - mojom::TCPConnectedSocketPtr client_socket; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Test sending data multiple times from the server to client. - const char kTestMsg[] = "01234567890"; - - // Loop 3 times to test that writes can follow reads, and reads can follow - // writes. - for (int j = 0; j < 3; ++j) { - for (size_t i = 0; i < arraysize(kTestMsg); ++i) { - std::string data(1, kTestMsg[i]); - server.SendData(data); - EXPECT_EQ(data, Read(&client_socket_receive_handle, 1)); - } - - // Test sending data from client to server. - base::RunLoop read_run_loop; - server.StartReading(kTestMsg, read_run_loop.QuitClosure()); - - // Test sending data multiple times from the client to server. - for (size_t i = 0; i < arraysize(kTestMsg); ++i) { - mojo::common::BlockingCopyFromString(std::string(1, kTestMsg[i]), - client_socket_send_handle); - // Flush the 1 byte write. - base::RunLoop().RunUntilIdle(); - } - read_run_loop.Run(); - } -} - -TEST_F(TCPSocketTest, ServerReceivesMultipleAccept) { - uint32_t backlog = 10; - TestServer server; - server.Start(backlog); - - std::vector<std::unique_ptr<net::TestCompletionCallback>> accept_callbacks; - // Issue |backlog| Accepts(), so the queue is filled up. - for (size_t i = 0; i < backlog; ++i) { - auto callback = std::make_unique<net::TestCompletionCallback>(); - server.AcceptOneConnection(callback->callback()); - accept_callbacks.push_back(std::move(callback)); - } - // Accept() beyond the queue size should fail immediately. - net::TestCompletionCallback callback; - server.AcceptOneConnection(callback.callback()); - EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, callback.WaitForResult()); - - // After handling incoming connections, all callbacks should now complete. - for (size_t i = 0; i < backlog; ++i) { - TestTCPConnectedSocketObserver observer; - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - mojom::TCPConnectedSocketPtr client_socket; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - } - for (const auto& callback : accept_callbacks) { - EXPECT_EQ(net::OK, callback->WaitForResult()); - } -} - -// Tests that if a socket is closed, the other side can observe that the pipes -// are broken. -TEST_F(TCPSocketTest, SocketClosed) { - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - mojom::TCPConnectedSocketPtr client_socket; - - TestTCPConnectedSocketObserver observer; - const char kTestMsg[] = "hello"; - auto server = std::make_unique<TestServer>(); - server->Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server->AcceptOneConnection(accept_callback.callback()); - - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server->server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Send some data from server to client. - server->SendData(kTestMsg); - EXPECT_EQ(kTestMsg, - Read(&client_socket_receive_handle, arraysize(kTestMsg) - 1)); - // Resetting the |server| destroys the TCPConnectedSocket ptr owned by the - // server. - server = nullptr; - - // Read should return EOF. - EXPECT_EQ("", Read(&client_socket_receive_handle, 1)); - - // Read from |client_socket_receive_handle| again should return that the pipe - // is broken. - char buffer[16]; - uint32_t read_size = sizeof(buffer); - MojoResult mojo_result = client_socket_receive_handle->ReadData( - buffer, &read_size, MOJO_READ_DATA_FLAG_NONE); - ASSERT_EQ(MOJO_RESULT_FAILED_PRECONDITION, mojo_result); - EXPECT_TRUE(client_socket_receive_handle->QuerySignalsState().peer_closed()); - - // Send pipe should be closed. - while (true) { - base::RunLoop().RunUntilIdle(); - uint32_t size = arraysize(kTestMsg); - MojoResult r = client_socket_send_handle->WriteData( - kTestMsg, &size, MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); - if (r == MOJO_RESULT_SHOULD_WAIT) - continue; - if (r == MOJO_RESULT_FAILED_PRECONDITION) - break; - } - EXPECT_TRUE(client_socket_send_handle->QuerySignalsState().peer_closed()); - int result = observer.WaitForWriteError(); - EXPECT_TRUE(result == net::ERR_CONNECTION_RESET || - result == net::ERR_CONNECTION_ABORTED) - << "actual result: " << result; -} - -TEST_F(TCPSocketTest, ReadPipeClosed) { - TestTCPConnectedSocketObserver observer; - const char kTestMsg[] = "hello"; - TestServer server; - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - mojom::TCPConnectedSocketPtr client_socket; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Close |client_socket_receive_handle|. The socket should remain open. - client_socket_receive_handle.reset(); - - // Send should proceed as normal. - base::RunLoop read_run_loop; - server.StartReading(kTestMsg, read_run_loop.QuitClosure()); - EXPECT_TRUE(mojo::common::BlockingCopyFromString(kTestMsg, - client_socket_send_handle)); - read_run_loop.Run(); -} - -TEST_F(TCPSocketTest, WritePipeClosed) { - TestTCPConnectedSocketObserver observer; - const char kTestMsg[] = "hello"; - TestServer server; - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - mojom::TCPConnectedSocketPtr client_socket; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Close |client_socket_send_handle|. The socket should remain open. - client_socket_send_handle.reset(); - - // Receive should proceed as normal. - server.SendData(kTestMsg); - EXPECT_EQ(kTestMsg, - Read(&client_socket_receive_handle, arraysize(kTestMsg) - 1)); -} - -// Tests that if the server socket is destroyed, any connected sockets that it -// handed out remain alive. -TEST_F(TCPSocketTest, ServerSocketClosedAcceptedSocketAlive) { - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle; - mojo::ScopedDataPipeProducerHandle client_socket_send_handle; - - TestTCPConnectedSocketObserver observer; - const char kTestMsg[] = "hello"; - TestServer server; - server.Start(1 /*backlog*/); - net::TestCompletionCallback accept_callback; - server.AcceptOneConnection(accept_callback.callback()); - - mojom::TCPConnectedSocketPtr client_socket; - EXPECT_EQ(net::OK, - CreateTCPConnectedSocketSync( - mojo::MakeRequest(&client_socket), observer.GetObserverPtr(), - base::nullopt /*local_addr*/, server.server_addr(), - &client_socket_receive_handle, &client_socket_send_handle)); - ASSERT_EQ(net::OK, accept_callback.WaitForResult()); - - // Now destroys the server socket. - server.DestroyServerSocket(); - base::RunLoop().RunUntilIdle(); - - // Sending and receiving should still work. - server.SendData(kTestMsg); - EXPECT_EQ(kTestMsg, - Read(&client_socket_receive_handle, arraysize(kTestMsg) - 1)); - - base::RunLoop read_run_loop; - server.StartReading(kTestMsg, read_run_loop.QuitClosure()); - EXPECT_TRUE(mojo::common::BlockingCopyFromString(kTestMsg, - client_socket_send_handle)); - read_run_loop.Run(); -} - -// Tests both async and sync cases. -class TCPSocketWithMockSocketTest - : public TCPSocketTest, - public ::testing::WithParamInterface<net::IoMode> {}; - -INSTANTIATE_TEST_CASE_P(/* no prefix */, - TCPSocketWithMockSocketTest, - testing::Values(net::SYNCHRONOUS, net::ASYNC)); - -// Tests that a server socket handles Accept() correctly when the underlying -// implementation completes Accept() in sync and async mode. -TEST_P(TCPSocketWithMockSocketTest, - ServerAcceptClientConnectionWithMockSocket) { - net::IoMode mode = GetParam(); - auto mock_server_socket = std::make_unique<MockServerSocket>(); - MockServerSocket* mock_server_socket_raw = mock_server_socket.get(); - mojom::TCPServerSocketPtr server_socket; - uint32_t kBacklog = 10; - // Use a mock socket to control net::ServerSocket::Accept() behavior. - CreateServerSocketWithMockSocket(kBacklog, mojo::MakeRequest(&server_socket), - std::move(mock_server_socket)); - - // Complete first Accept() using manual completion via CompleteAccept(). - mock_server_socket_raw->SetAcceptResult(net::SYNCHRONOUS, - net::ERR_IO_PENDING); - std::vector<std::unique_ptr<net::TestCompletionCallback>> accept_callbacks; - for (size_t i = 0; i < kBacklog; ++i) { - auto callback = std::make_unique<net::TestCompletionCallback>(); - TestTCPConnectedSocketObserver observer; - server_socket->Accept( - observer.GetObserverPtr(), - base::BindOnce( - [](net::CompletionOnceCallback callback, int result, - const base::Optional<net::IPEndPoint>& remote_addr, - mojom::TCPConnectedSocketPtr connected_socket, - mojo::ScopedDataPipeConsumerHandle receive_pipe_handle, - mojo::ScopedDataPipeProducerHandle send_pipe_handle) { - std::move(callback).Run(result); - }, - std::move(callback->callback()))); - accept_callbacks.push_back(std::move(callback)); - } - - mock_server_socket_raw->WaitForFirstAccept(); - mock_server_socket_raw->SetAcceptResult(mode, net::OK); - mock_server_socket_raw->CompleteAccept(net::OK); - - // First net::ServerSocket::Accept() will complete asynchronously - // internally. Other queued Accept() will complete - // synchronously/asynchronously depending on |mode| internally. - for (const auto& callback : accept_callbacks) { - EXPECT_EQ(net::OK, callback->WaitForResult()); - } - - // New Accept() should complete synchronously internally. Make sure this is - // okay. - auto callback = std::make_unique<net::TestCompletionCallback>(); - TestTCPConnectedSocketObserver observer; - server_socket->Accept( - observer.GetObserverPtr(), - base::BindOnce( - [](net::CompletionOnceCallback callback, int result, - const base::Optional<net::IPEndPoint>& remote_addr, - mojom::TCPConnectedSocketPtr connected_socket, - mojo::ScopedDataPipeConsumerHandle receive_pipe_handle, - mojo::ScopedDataPipeProducerHandle send_pipe_handle) { - std::move(callback).Run(result); - }, - std::move(callback->callback()))); - EXPECT_EQ(net::OK, callback->WaitForResult()); -} - -TEST_P(TCPSocketWithMockSocketTest, ReadAndWriteMultipleWithMockClientSocket) { - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle = - std::move(receive_pipe.consumer_handle); - mojo::ScopedDataPipeProducerHandle client_socket_send_handle = - std::move(send_pipe.producer_handle); - - mojom::TCPConnectedSocketPtr client_socket; - const char kTestMsg[] = "abcdefghij"; - const size_t kMsgSize = arraysize(kTestMsg) - 1; - const int kNumIterations = 3; - std::vector<net::MockRead> reads; - std::vector<net::MockWrite> writes; - int sequence_number = 0; - net::IoMode mode = GetParam(); - for (int j = 0; j < kNumIterations; ++j) { - for (size_t i = 0; i < kMsgSize; ++i) { - reads.push_back(net::MockRead(mode, &kTestMsg[i], 1, sequence_number++)); - } - if (j == kNumIterations - 1) { - reads.push_back(net::MockRead(mode, net::OK, sequence_number++)); - } - for (size_t i = 0; i < kMsgSize; ++i) { - writes.push_back( - net::MockWrite(mode, &kTestMsg[i], 1, sequence_number++)); - } - } - net::StaticSocketDataProvider data_provider(reads.data(), reads.size(), - writes.data(), writes.size()); - data_provider.set_connect_data(net::MockConnect(net::SYNCHRONOUS, net::OK)); - auto mock_socket = std::make_unique<net::MockTCPClientSocket>( - net::AddressList(), nullptr /*netlog*/, &data_provider); - - CreateConnectedSocketWithMockSocket(mojo::MakeRequest(&client_socket), - std::move(receive_pipe.producer_handle), - std::move(send_pipe.consumer_handle), - std::move(mock_socket)); - - // Loop kNumIterations times to test that writes can follow reads, and reads - // can follow writes. - for (int j = 0; j < kNumIterations; ++j) { - // Reading kMsgSize should coalesce the 1-byte mock reads. - EXPECT_EQ(kTestMsg, Read(&client_socket_receive_handle, kMsgSize)); - // Write multiple times. - for (size_t i = 0; i < kMsgSize; ++i) { - std::string data(1, kTestMsg[i]); - uint32_t num_bytes = 1; - EXPECT_EQ(MOJO_RESULT_OK, - client_socket_send_handle->WriteData( - &kTestMsg[i], &num_bytes, MOJO_WRITE_DATA_FLAG_NONE)); - // Flush the 1 byte write. - base::RunLoop().RunUntilIdle(); - } - } - EXPECT_TRUE(data_provider.AllReadDataConsumed()); - EXPECT_TRUE(data_provider.AllWriteDataConsumed()); -} - -TEST_P(TCPSocketWithMockSocketTest, PartialStreamSocketWrite) { - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle = - std::move(receive_pipe.consumer_handle); - mojo::ScopedDataPipeProducerHandle client_socket_send_handle = - std::move(send_pipe.producer_handle); - - mojom::TCPConnectedSocketPtr client_socket; - const char kTestMsg[] = "abcdefghij"; - const size_t kMsgSize = arraysize(kTestMsg) - 1; - const int kNumIterations = 3; - std::vector<net::MockRead> reads; - std::vector<net::MockWrite> writes; - int sequence_number = 0; - net::IoMode mode = GetParam(); - for (int j = 0; j < kNumIterations; ++j) { - for (size_t i = 0; i < kMsgSize; ++i) { - reads.push_back(net::MockRead(mode, &kTestMsg[i], 1, sequence_number++)); - } - if (j == kNumIterations - 1) { - reads.push_back(net::MockRead(mode, net::OK, sequence_number++)); - } - for (size_t i = 0; i < kMsgSize; ++i) { - writes.push_back( - net::MockWrite(mode, &kTestMsg[i], 1, sequence_number++)); - } - } - net::StaticSocketDataProvider data_provider(reads.data(), reads.size(), - writes.data(), writes.size()); - data_provider.set_connect_data(net::MockConnect(net::SYNCHRONOUS, net::OK)); - auto mock_socket = std::make_unique<net::MockTCPClientSocket>( - net::AddressList(), nullptr /*netlog*/, &data_provider); - - CreateConnectedSocketWithMockSocket(mojo::MakeRequest(&client_socket), - std::move(receive_pipe.producer_handle), - std::move(send_pipe.consumer_handle), - std::move(mock_socket)); - - // Loop kNumIterations times to test that writes can follow reads, and reads - // can follow writes. - for (int j = 0; j < kNumIterations; ++j) { - // Reading kMsgSize should coalesce the 1-byte mock reads. - EXPECT_EQ(kTestMsg, Read(&client_socket_receive_handle, kMsgSize)); - // Write twice, each with kMsgSize/2 bytes which is bigger than the 1-byte - // MockWrite(). This is to exercise that StreamSocket::Write() can do - // partial write. - uint32_t first_write_size = kMsgSize / 2; - EXPECT_EQ(MOJO_RESULT_OK, - client_socket_send_handle->WriteData( - &kTestMsg[0], &first_write_size, MOJO_WRITE_DATA_FLAG_NONE)); - // Flush the kMsgSize/2 byte write. - base::RunLoop().RunUntilIdle(); - uint32_t second_write_size = kMsgSize - first_write_size; - EXPECT_EQ(MOJO_RESULT_OK, - client_socket_send_handle->WriteData(&kTestMsg[first_write_size], - &second_write_size, - MOJO_WRITE_DATA_FLAG_NONE)); - // Flush the kMsgSize/2 byte write. - base::RunLoop().RunUntilIdle(); - } - EXPECT_TRUE(data_provider.AllReadDataConsumed()); - EXPECT_TRUE(data_provider.AllWriteDataConsumed()); -} - -TEST_P(TCPSocketWithMockSocketTest, ReadError) { - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle = - std::move(receive_pipe.consumer_handle); - mojo::ScopedDataPipeProducerHandle client_socket_send_handle = - std::move(send_pipe.producer_handle); - - mojom::TCPConnectedSocketPtr client_socket; - net::IoMode mode = GetParam(); - net::MockRead reads[] = {net::MockRead(mode, net::ERR_FAILED)}; - const char kTestMsg[] = "hello!"; - net::MockWrite writes[] = { - net::MockWrite(mode, kTestMsg, arraysize(kTestMsg) - 1, 0)}; - net::StaticSocketDataProvider data_provider(reads, arraysize(reads), writes, - arraysize(writes)); - data_provider.set_connect_data(net::MockConnect(net::SYNCHRONOUS, net::OK)); - auto mock_socket = std::make_unique<net::MockTCPClientSocket>( - net::AddressList(), nullptr /*netlog*/, &data_provider); - - CreateConnectedSocketWithMockSocket(mojo::MakeRequest(&client_socket), - std::move(receive_pipe.producer_handle), - std::move(send_pipe.consumer_handle), - std::move(mock_socket)); - - EXPECT_EQ("", Read(&client_socket_receive_handle, 1)); - EXPECT_EQ(net::ERR_FAILED, observer()->WaitForReadError()); - // Writes can proceed even though there is a read error. - uint32_t num_bytes = arraysize(kTestMsg) - 1; - EXPECT_EQ(MOJO_RESULT_OK, - client_socket_send_handle->WriteData(&kTestMsg, &num_bytes, - MOJO_WRITE_DATA_FLAG_NONE)); - - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(data_provider.AllReadDataConsumed()); - EXPECT_TRUE(data_provider.AllWriteDataConsumed()); -} - -TEST_P(TCPSocketWithMockSocketTest, WriteError) { - mojo::DataPipe send_pipe; - mojo::DataPipe receive_pipe; - mojo::ScopedDataPipeConsumerHandle client_socket_receive_handle = - std::move(receive_pipe.consumer_handle); - mojo::ScopedDataPipeProducerHandle client_socket_send_handle = - std::move(send_pipe.producer_handle); - - mojom::TCPConnectedSocketPtr client_socket; - net::IoMode mode = GetParam(); - const char kTestMsg[] = "hello!"; - net::MockRead reads[] = { - net::MockRead(mode, kTestMsg, arraysize(kTestMsg) - 1, 0), - net::MockRead(mode, net::OK)}; - net::MockWrite writes[] = {net::MockWrite(mode, net::ERR_FAILED)}; - net::StaticSocketDataProvider data_provider(reads, arraysize(reads), writes, - arraysize(writes)); - data_provider.set_connect_data(net::MockConnect(net::SYNCHRONOUS, net::OK)); - auto mock_socket = std::make_unique<net::MockTCPClientSocket>( - net::AddressList(), nullptr /*netlog*/, &data_provider); - - CreateConnectedSocketWithMockSocket(mojo::MakeRequest(&client_socket), - std::move(receive_pipe.producer_handle), - std::move(send_pipe.consumer_handle), - std::move(mock_socket)); - - uint32_t num_bytes = arraysize(kTestMsg) - 1; - EXPECT_EQ(MOJO_RESULT_OK, - client_socket_send_handle->WriteData(&kTestMsg, &num_bytes, - MOJO_WRITE_DATA_FLAG_NONE)); - EXPECT_EQ(net::ERR_FAILED, observer()->WaitForWriteError()); - // Reads can proceed even though there is a read error. - EXPECT_EQ(kTestMsg, Read(&client_socket_receive_handle, arraysize(kTestMsg))); - - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(data_provider.AllReadDataConsumed()); - EXPECT_TRUE(data_provider.AllWriteDataConsumed()); -} - -} // namespace network
diff --git a/services/network/udp_socket.cc b/services/network/udp_socket.cc index e43690f..4a19c98 100644 --- a/services/network/udp_socket.cc +++ b/services/network/udp_socket.cc
@@ -137,15 +137,22 @@ UDPSocket::PendingSendRequest::~PendingSendRequest() {} -UDPSocket::UDPSocket(mojom::UDPSocketReceiverPtr receiver, net::NetLog* net_log) - : net_log_(net_log), - is_bound_(false), +UDPSocket::UDPSocket(mojom::UDPSocketRequest request, + mojom::UDPSocketReceiverPtr receiver) + : is_bound_(false), is_connected_(false), receiver_(std::move(receiver)), - remaining_recv_slots_(0) {} + remaining_recv_slots_(0), + binding_(this) { + binding_.Bind(std::move(request)); +} UDPSocket::~UDPSocket() {} +void UDPSocket::set_connection_error_handler(base::OnceClosure handler) { + binding_.set_connection_error_handler(std::move(handler)); +} + void UDPSocket::Connect(const net::IPEndPoint& remote_addr, mojom::UDPSocketOptionsPtr options, ConnectCallback callback) { @@ -288,7 +295,7 @@ const { return std::make_unique<SocketWrapperImpl>( net::DatagramSocket::RANDOM_BIND, base::BindRepeating(&base::RandInt), - net_log_, net::NetLogSource()); + nullptr, net::NetLogSource()); } bool UDPSocket::IsConnectedOrBound() const {
diff --git a/services/network/udp_socket.h b/services/network/udp_socket.h index b5b627a..8f5ae10 100644 --- a/services/network/udp_socket.h +++ b/services/network/udp_socket.h
@@ -13,6 +13,8 @@ #include "base/containers/span.h" #include "base/macros.h" #include "base/memory/ref_counted.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/interface_request.h" #include "net/base/address_family.h" #include "net/base/completion_callback.h" #include "net/base/ip_endpoint.h" @@ -24,7 +26,6 @@ namespace net { class IOBuffer; class IOBufferWithSize; -class NetLog; } // namespace net namespace network { @@ -69,9 +70,13 @@ const net::CompletionCallback& callback) = 0; }; - UDPSocket(mojom::UDPSocketReceiverPtr receiver, net::NetLog* net_log); + UDPSocket(mojom::UDPSocketRequest request, + mojom::UDPSocketReceiverPtr receiver); ~UDPSocket() override; + // Sets connection error handler. + void set_connection_error_handler(base::OnceClosure handler); + // UDPSocket implementation. void Connect(const net::IPEndPoint& remote_addr, mojom::UDPSocketOptionsPtr options, @@ -132,8 +137,6 @@ void OnRecvFromCompleted(uint32_t buffer_size, int net_result); void OnSendToCompleted(int net_result); - net::NetLog* net_log_; - // Whether a Bind() has been successfully executed. bool is_bound_; @@ -163,6 +166,8 @@ base::circular_deque<std::unique_ptr<PendingSendRequest>> pending_send_requests_; + mojo::Binding<mojom::UDPSocket> binding_; + DISALLOW_COPY_AND_ASSIGN(UDPSocket); };
diff --git a/services/network/udp_socket_factory.cc b/services/network/udp_socket_factory.cc new file mode 100644 index 0000000..54ac3e4 --- /dev/null +++ b/services/network/udp_socket_factory.cc
@@ -0,0 +1,40 @@ +// Copyright 2018 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 "services/network/udp_socket_factory.h" + +#include <utility> + +#include "base/memory/ptr_util.h" +#include "base/optional.h" +#include "net/base/net_errors.h" +#include "services/network/udp_socket.h" + +namespace network { + +UDPSocketFactory::UDPSocketFactory() {} + +UDPSocketFactory::~UDPSocketFactory() {} + +void UDPSocketFactory::CreateUDPSocket(mojom::UDPSocketRequest request, + mojom::UDPSocketReceiverPtr receiver) { + auto socket = + std::make_unique<UDPSocket>(std::move(request), std::move(receiver)); + // base::Unretained is safe as the destruction of |this| will also destroy + // |udp_sockets_| which owns this socket. + socket->set_connection_error_handler( + base::BindOnce(&UDPSocketFactory::OnPipeBroken, base::Unretained(this), + base::Unretained(socket.get()))); + udp_sockets_.push_back(std::move(socket)); +} + +void UDPSocketFactory::OnPipeBroken(UDPSocket* socket) { + udp_sockets_.erase( + std::find_if(udp_sockets_.begin(), udp_sockets_.end(), + [socket](const std::unique_ptr<network::UDPSocket>& ptr) { + return ptr.get() == socket; + })); +} + +} // namespace network
diff --git a/services/network/udp_socket_factory.h b/services/network/udp_socket_factory.h new file mode 100644 index 0000000..58d47e8 --- /dev/null +++ b/services/network/udp_socket_factory.h
@@ -0,0 +1,41 @@ +// Copyright 2018 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_NETWORK_UDP_SOCKET_FACTORY_H_ +#define SERVICES_NETWORK_UDP_SOCKET_FACTORY_H_ + +#include <memory> +#include <vector> + +#include "base/component_export.h" +#include "base/macros.h" +#include "services/network/public/mojom/udp_socket.mojom.h" + +namespace network { + +class UDPSocket; + +// Helper class that handles UDPSocketRequest. It takes care of destroying the +// UDPSocket implementation instances when mojo pipes are broken. +class COMPONENT_EXPORT(NETWORK_SERVICE) UDPSocketFactory { + public: + UDPSocketFactory(); + virtual ~UDPSocketFactory(); + + void CreateUDPSocket(mojom::UDPSocketRequest request, + mojom::UDPSocketReceiverPtr receiver); + + protected: + // Handles connection errors. This is virtual for testing. + virtual void OnPipeBroken(UDPSocket* client); + + private: + std::vector<std::unique_ptr<UDPSocket>> udp_sockets_; + + DISALLOW_COPY_AND_ASSIGN(UDPSocketFactory); +}; + +} // namespace network + +#endif // SERVICES_NETWORK_UDP_SOCKET_FACTORY_H_
diff --git a/services/network/udp_socket_factory_unittest.cc b/services/network/udp_socket_factory_unittest.cc new file mode 100644 index 0000000..2076e6e5 --- /dev/null +++ b/services/network/udp_socket_factory_unittest.cc
@@ -0,0 +1,63 @@ +// 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 <utility> + +#include "services/network/udp_socket_factory.h" + +#include "base/logging.h" +#include "base/macros.h" +#include "base/run_loop.h" +#include "base/test/scoped_task_environment.h" +#include "net/base/net_errors.h" +#include "services/network/public/mojom/udp_socket.mojom.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace network { + +class UDPSocketFactoryTest : public testing::Test { + public: + UDPSocketFactoryTest() {} + ~UDPSocketFactoryTest() override {} + + private: + base::test::ScopedTaskEnvironment scoped_task_environment_; + + DISALLOW_COPY_AND_ASSIGN(UDPSocketFactoryTest); +}; + +class TestUDPSocketFactory : public UDPSocketFactory { + public: + TestUDPSocketFactory() {} + ~TestUDPSocketFactory() override {} + + void WaitUntilPipeBroken() { run_loop_.Run(); } + + private: + // UDPSocketFactory implementation: + void OnPipeBroken(UDPSocket* client) override { + UDPSocketFactory::OnPipeBroken(client); + run_loop_.Quit(); + } + + base::RunLoop run_loop_; +}; +// Tests that when client end of the pipe is closed, the factory implementation +// cleans up the server side of the pipe. +TEST_F(UDPSocketFactoryTest, ConnectionError) { + TestUDPSocketFactory factory; + + mojom::UDPSocketReceiverPtr receiver_interface_ptr; + mojom::UDPSocketPtr socket_ptr; + + factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), + std::move(receiver_interface_ptr)); + + // Close client side of the pipe. + socket_ptr.reset(); + + factory.WaitUntilPipeBroken(); +} + +} // namespace network
diff --git a/services/network/udp_socket_unittest.cc b/services/network/udp_socket_unittest.cc index 7ca3552..0fa16b75 100644 --- a/services/network/udp_socket_unittest.cc +++ b/services/network/udp_socket_unittest.cc
@@ -21,7 +21,6 @@ #include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "services/network/public/mojom/udp_socket.mojom.h" -#include "services/network/socket_factory.h" #include "services/network/udp_socket_test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -200,9 +199,8 @@ }; TEST_F(UDPSocketTest, Settings) { - SocketFactory factory(nullptr /*net_log*/); mojom::UDPSocketPtr socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), nullptr); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); net::IPEndPoint server_addr; net::IPEndPoint any_port(GetLocalHostWithAnyPort()); @@ -219,9 +217,8 @@ // Tests that Send() is used after Bind() is not supported. Send() should only // be used after Connect(). TEST_F(UDPSocketTest, TestSendWithBind) { - SocketFactory factory(nullptr /*net_log*/); mojom::UDPSocketPtr socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), nullptr); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); @@ -238,7 +235,6 @@ // Tests that when SendTo() is used after Connect() is not supported. SendTo() // should only be used after Bind(). TEST_F(UDPSocketTest, TestSendToWithConnect) { - SocketFactory factory(nullptr /*net_log*/); // Create a server socket to listen for incoming datagrams. test::UDPSocketReceiverImpl receiver; mojo::Binding<mojom::UDPSocketReceiver> receiver_binding(&receiver); @@ -246,8 +242,8 @@ receiver_binding.Bind(mojo::MakeRequest(&receiver_interface_ptr)); mojom::UDPSocketPtr server_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket), - std::move(receiver_interface_ptr)); + UDPSocket impl(mojo::MakeRequest(&server_socket), + std::move(receiver_interface_ptr)); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -255,7 +251,7 @@ // Create a client socket to send datagrams. mojom::UDPSocketPtr client_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&client_socket), nullptr); + UDPSocket client_impl(mojo::MakeRequest(&client_socket), nullptr); net::IPEndPoint client_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper client_helper(&client_socket); ASSERT_EQ(net::OK, @@ -269,9 +265,8 @@ // Tests that the sequence of calling Bind()/Connect() and setters is // important. TEST_F(UDPSocketTest, TestUnexpectedSequences) { - SocketFactory factory(nullptr /*net_log*/); mojom::UDPSocketPtr socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), nullptr); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); test::UDPSocketTestHelper helper(&socket_ptr); net::IPEndPoint local_addr(GetLocalHostWithAnyPort()); @@ -296,9 +291,7 @@ // ERR_IO_PENDING, udp_socket.cc doesn't free the send buffer. TEST_F(UDPSocketTest, TestBufferValid) { mojom::UDPSocketPtr socket_ptr; - UDPSocket impl(nullptr /*receiver*/, nullptr /*net_log*/); - mojo::Binding<mojom::UDPSocket> binding(&impl); - binding.Bind(mojo::MakeRequest(&socket_ptr)); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&socket_ptr); @@ -336,9 +329,7 @@ // ERR_INSUFFICIENT_RESOURCES is returned appropriately. TEST_F(UDPSocketTest, TestInsufficientResources) { mojom::UDPSocketPtr socket_ptr; - UDPSocket impl(nullptr /*receiver*/, nullptr /*net_log*/); - mojo::Binding<mojom::UDPSocket> binding(&impl); - binding.Bind(mojo::MakeRequest(&socket_ptr)); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); const size_t kQueueSize = UDPSocket::kMaxPendingSendRequests; @@ -385,9 +376,8 @@ receiver_binding.Bind(mojo::MakeRequest(&receiver_interface_ptr)); mojom::UDPSocketPtr server_socket; - UDPSocket impl(std::move(receiver_interface_ptr), nullptr /*net_log*/); - mojo::Binding<mojom::UDPSocket> binding(&impl); - binding.Bind(mojo::MakeRequest(&server_socket)); + UDPSocket impl(mojo::MakeRequest(&server_socket), + std::move(receiver_interface_ptr)); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -402,7 +392,6 @@ } TEST_F(UDPSocketTest, TestReadSend) { - SocketFactory factory(nullptr /*net_log*/); // Create a server socket to listen for incoming datagrams. test::UDPSocketReceiverImpl receiver; mojo::Binding<mojom::UDPSocketReceiver> receiver_binding(&receiver); @@ -410,8 +399,8 @@ receiver_binding.Bind(mojo::MakeRequest(&receiver_interface_ptr)); mojom::UDPSocketPtr server_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket), - std::move(receiver_interface_ptr)); + UDPSocket impl(mojo::MakeRequest(&server_socket), + std::move(receiver_interface_ptr)); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -419,7 +408,7 @@ // Create a client socket to send datagrams. mojom::UDPSocketPtr client_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&client_socket), nullptr); + UDPSocket client_impl(mojo::MakeRequest(&client_socket), nullptr); net::IPEndPoint client_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper client_helper(&client_socket); ASSERT_EQ(net::OK, @@ -472,10 +461,9 @@ } TEST_F(UDPSocketTest, TestReadSendTo) { - SocketFactory factory(nullptr /*net_log*/); // Create a server socket to send data. mojom::UDPSocketPtr server_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket), nullptr); + UDPSocket impl(mojo::MakeRequest(&server_socket), nullptr); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -488,8 +476,8 @@ receiver_binding.Bind(mojo::MakeRequest(&client_receiver_ptr)); mojom::UDPSocketPtr client_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&client_socket), - std::move(client_receiver_ptr)); + UDPSocket client_impl(mojo::MakeRequest(&client_socket), + std::move(client_receiver_ptr)); net::IPEndPoint client_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper client_helper(&client_socket); ASSERT_EQ(net::OK, @@ -539,7 +527,6 @@ } TEST_F(UDPSocketTest, TestReceiveMoreWithBufferSize) { - SocketFactory factory(nullptr /*net_log*/); // Create a server socket to listen for incoming datagrams. test::UDPSocketReceiverImpl receiver; mojo::Binding<mojom::UDPSocketReceiver> receiver_binding(&receiver); @@ -547,8 +534,8 @@ receiver_binding.Bind(mojo::MakeRequest(&receiver_interface_ptr)); mojom::UDPSocketPtr server_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket), - std::move(receiver_interface_ptr)); + UDPSocket impl(mojo::MakeRequest(&server_socket), + std::move(receiver_interface_ptr)); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -556,7 +543,7 @@ // Create a client socket to send datagrams. mojom::UDPSocketPtr client_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&client_socket), nullptr); + UDPSocket client_impl(mojo::MakeRequest(&client_socket), nullptr); net::IPEndPoint client_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper client_helper(&client_socket); ASSERT_EQ(net::OK, @@ -591,9 +578,8 @@ // Make sure passing an invalid net::IPEndPoint will be detected by // serialization/deserialization in mojo. TEST_F(UDPSocketTest, TestSendToInvalidAddress) { - SocketFactory factory(nullptr /*net_log*/); mojom::UDPSocketPtr server_socket; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket), nullptr); + UDPSocket impl(mojo::MakeRequest(&server_socket), nullptr); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&server_socket); @@ -625,9 +611,8 @@ receiver_binding.Bind(mojo::MakeRequest(&receiver_interface_ptr)); mojom::UDPSocketPtr socket_ptr; - UDPSocket impl(std::move(receiver_interface_ptr), nullptr /*net_log*/); - mojo::Binding<mojom::UDPSocket> binding(&impl); - binding.Bind(mojo::MakeRequest(&socket_ptr)); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), + std::move(receiver_interface_ptr)); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); test::UDPSocketTestHelper helper(&socket_ptr); @@ -655,7 +640,6 @@ #define MAYBE_JoinMulticastGroup JoinMulticastGroup #endif // defined(OS_ANDROID) TEST_F(UDPSocketTest, MAYBE_JoinMulticastGroup) { - SocketFactory factory(nullptr /*net_log*/); const char kGroup[] = "237.132.100.17"; net::IPAddress group_ip; @@ -665,8 +649,7 @@ test::UDPSocketReceiverImpl receiver; mojo::Binding<mojom::UDPSocketReceiver> receiver_binding(&receiver); receiver_binding.Bind(mojo::MakeRequest(&receiver_ptr)); - factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), - std::move(receiver_ptr)); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), std::move(receiver_ptr)); test::UDPSocketTestHelper helper(&socket_ptr); @@ -702,7 +685,7 @@ // Create a second socket to send a packet to multicast group. mojom::UDPSocketPtr second_socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&second_socket_ptr), nullptr); + UDPSocket second_socket_impl(mojo::MakeRequest(&second_socket_ptr), nullptr); test::UDPSocketTestHelper second_socket_helper(&second_socket_ptr); net::IPEndPoint second_socket_address(bind_ip_address, 0); ASSERT_EQ(net::OK, @@ -733,16 +716,15 @@ } TEST_F(UDPSocketTest, ErrorHappensDuringSocketOptionsConfiguration) { - SocketFactory factory(nullptr /*net_log*/); mojom::UDPSocketPtr server_socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&server_socket_ptr), nullptr); + UDPSocket server_impl(mojo::MakeRequest(&server_socket_ptr), nullptr); test::UDPSocketTestHelper server_helper(&server_socket_ptr); net::IPEndPoint server_addr(GetLocalHostWithAnyPort()); ASSERT_EQ(net::OK, server_helper.BindSync(server_addr, nullptr, &server_addr)); mojom::UDPSocketPtr socket_ptr; - factory.CreateUDPSocket(mojo::MakeRequest(&socket_ptr), nullptr); + UDPSocket impl(mojo::MakeRequest(&socket_ptr), nullptr); test::UDPSocketTestHelper helper(&socket_ptr); // Invalid options.
diff --git a/services/service_manager/sandbox/mac/common.sb b/services/service_manager/sandbox/mac/common.sb index f8fe48b..0e90c9ab 100644 --- a/services/service_manager/sandbox/mac/common.sb +++ b/services/service_manager/sandbox/mac/common.sb
@@ -16,7 +16,6 @@ ; Define constants for all of the parameter strings passed in. (define disable-sandbox-denial-logging "DISABLE_SANDBOX_DENIAL_LOGGING") (define enable-logging "ENABLE_LOGGING") -(define permitted-dir "PERMITTED_DIR") (define homedir-as-literal "USER_HOMEDIR_AS_LITERAL") (define elcap-or-later "ELCAP_OR_LATER") (define macos-1013 "MACOS_1013")
diff --git a/services/service_manager/sandbox/mac/common_v2.sb b/services/service_manager/sandbox/mac/common_v2.sb index d33adf3..b4b0420 100644 --- a/services/service_manager/sandbox/mac/common_v2.sb +++ b/services/service_manager/sandbox/mac/common_v2.sb
@@ -21,7 +21,6 @@ (define homedir-as-literal "USER_HOMEDIR_AS_LITERAL") (define log-file-path "LOG_FILE_PATH") (define os-version (string->number (param "OS_VERSION"))) -(define permitted-dir "PERMITTED_DIR") ; Backwards compatibility for 10.9 (if (not (defined? 'path))
diff --git a/services/service_manager/sandbox/mac/package_sb_file.py b/services/service_manager/sandbox/mac/package_sb_file.py index 41f9285c..098d689 100755 --- a/services/service_manager/sandbox/mac/package_sb_file.py +++ b/services/service_manager/sandbox/mac/package_sb_file.py
@@ -18,7 +18,8 @@ 'extern const char kSeatbeltPolicyString_%s[];\n\n') cc_include = '#include "services/service_manager/sandbox/mac/%s.sb.h"\n' cc_definition = 'const char kSeatbeltPolicyString_%s[] = \n' -cc_definition_end = ';\n' +cc_definition_end = '"";\n' # Add "" so the definition has some content + # (the empty string) if the sb file is empty. def escape_for_c(line): if line and line[0] == ';':
diff --git a/services/service_manager/sandbox/mac/sandbox_mac.h b/services/service_manager/sandbox/mac/sandbox_mac.h index 45d5959e..31df9dd5 100644 --- a/services/service_manager/sandbox/mac/sandbox_mac.h +++ b/services/service_manager/sandbox/mac/sandbox_mac.h
@@ -29,12 +29,9 @@ // Turns on the OS X sandbox for this process. // |sandbox_type| - type of Sandbox to use. See SandboxWarmup() for legal // values. - // |allowed_dir| - directory to allow access to, currently the only sandbox - // profile that supports this is SANDBOX_TYPE_UTILITY . // // Returns true on success, false if an error occurred enabling the sandbox. - static bool Enable(SandboxType sandbox_type, - const base::FilePath& allowed_dir); + static bool Enable(SandboxType sandbox_type); // Returns true if the sandbox has been enabled for the current process. static bool IsCurrentlyActive(); @@ -53,7 +50,6 @@ static const char* kSandboxHomedirAsLiteral; static const char* kSandboxLoggingPathAsLiteral; static const char* kSandboxOSVersion; - static const char* kSandboxPermittedDir; // TODO(kerrnel): this is only for the legacy sandbox. static const char* kSandboxElCapOrLater;
diff --git a/services/service_manager/sandbox/mac/sandbox_mac.mm b/services/service_manager/sandbox/mac/sandbox_mac.mm index 0619501d..33bc339 100644 --- a/services/service_manager/sandbox/mac/sandbox_mac.mm +++ b/services/service_manager/sandbox/mac/sandbox_mac.mm
@@ -92,7 +92,6 @@ const char* SandboxMac::kSandboxHomedirAsLiteral = "USER_HOMEDIR_AS_LITERAL"; const char* SandboxMac::kSandboxLoggingPathAsLiteral = "LOG_FILE_PATH"; const char* SandboxMac::kSandboxOSVersion = "OS_VERSION"; -const char* SandboxMac::kSandboxPermittedDir = "PERMITTED_DIR"; const char* SandboxMac::kSandboxElCapOrLater = "ELCAP_OR_LATER"; const char* SandboxMac::kSandboxMacOS1013 = "MACOS_1013"; const char* SandboxMac::kSandboxBundleVersionPath = "BUNDLE_VERSION_PATH"; @@ -198,29 +197,13 @@ // Turns on the OS X sandbox for this process. // static -bool SandboxMac::Enable(SandboxType sandbox_type, - const base::FilePath& allowed_dir) { - // Sanity - currently only some sandboxes support a directory being - // passed in. - if (sandbox_type != SANDBOX_TYPE_UTILITY) { - DCHECK(allowed_dir.empty()) - << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter."; - } - +bool SandboxMac::Enable(SandboxType sandbox_type) { std::string sandbox_data = LoadSandboxTemplate(sandbox_type); if (sandbox_data.empty()) return false; sandbox::SandboxCompiler compiler(sandbox_data); - if (!allowed_dir.empty()) { - // Add the sandbox parameters necessary to access the given directory. - base::FilePath allowed_dir_canonical = GetCanonicalPath(allowed_dir); - if (!compiler.InsertStringParam(kSandboxPermittedDir, - allowed_dir_canonical.value())) - return false; - } - // Enable verbose logging if enabled on the command line. (See common.sb // for details). const base::CommandLine* command_line =
diff --git a/services/service_manager/sandbox/mac/utility.sb b/services/service_manager/sandbox/mac/utility.sb index 2267a31..22d18adc 100644 --- a/services/service_manager/sandbox/mac/utility.sb +++ b/services/service_manager/sandbox/mac/utility.sb
@@ -13,8 +13,5 @@ ; *** The contents of common.sb are implicitly included here. *** -; Enable full access to given directory if needed. -(if (param-defined? permitted-dir) - (begin - (allow file-read-metadata ) - (allow file-read* file-write* (subpath (param permitted-dir))))) +; No additional resource access needed. +
diff --git a/services/service_manager/sandbox/sandbox.cc b/services/service_manager/sandbox/sandbox.cc index e7913e9..a93202c 100644 --- a/services/service_manager/sandbox/sandbox.cc +++ b/services/service_manager/sandbox/sandbox.cc
@@ -31,9 +31,7 @@ #endif // defined(OS_LINUX) #if defined(OS_MACOSX) -bool Sandbox::Initialize(SandboxType sandbox_type, - const base::FilePath& allowed_dir, - base::OnceClosure hook) { +bool Sandbox::Initialize(SandboxType sandbox_type, base::OnceClosure hook) { // Warm up APIs before turning on the sandbox. SandboxMac::Warmup(sandbox_type); @@ -42,7 +40,7 @@ std::move(hook).Run(); // Actually sandbox the process. - return SandboxMac::Enable(sandbox_type, allowed_dir); + return SandboxMac::Enable(sandbox_type); } #endif // defined(OS_MACOSX)
diff --git a/services/service_manager/sandbox/sandbox.h b/services/service_manager/sandbox/sandbox.h index 7e1ec05..0071ca1 100644 --- a/services/service_manager/sandbox/sandbox.h +++ b/services/service_manager/sandbox/sandbox.h
@@ -15,7 +15,6 @@ #if defined(OS_MACOSX) #include "base/callback.h" -#include "base/files/file_path.h" #endif // defined(OS_MACOSX) namespace sandbox { @@ -42,12 +41,10 @@ #endif // defined(OS_LINUX) #if defined(OS_MACOSX) - // Initialize the sandbox of |sandbox_type|, permitting access to the one - // directory specified by |allowed_dir| if non-empty. Runs |post_warmup_hook| - // if non-empty after performing any sandbox warmup but immediately before + // Initialize the sandbox of |sandbox_type|. Runs |post_warmup_hook| if + // non-empty after performing any sandbox warmup but immediately before // engaging the sandbox. Return true on success, false otherwise. static bool Initialize(SandboxType sandbox_type, - const base::FilePath& allowed_dir, base::OnceClosure post_warmup_hook); #endif // defined(OS_MACOSX)
diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h index 3a1e8df..08242a6 100644 --- a/skia/config/SkUserConfig.h +++ b/skia/config/SkUserConfig.h
@@ -213,6 +213,10 @@ #define SK_LEGACY_GPU_PIXEL_OPS #endif +#ifndef SK_SUPPORT_LEGACY_BLURMASKFILTER +#define SK_SUPPORT_LEGACY_BLURMASKFILTER +#endif + #ifndef SK_SUPPORT_LEGACY_YUV_COLORSPACE #define SK_SUPPORT_LEGACY_YUV_COLORSPACE #endif
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index fdf56e3..2ef845f2 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -9134,6 +9134,158 @@ ] }, "linux-blink-heap-verification": { + "gtest_tests": [ + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "base_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "blink_heap_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "cacheinvalidation_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "capture_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "components_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "content_browsertests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "content_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "crypto_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "google_apis_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gpu_ipc_service_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "gpu_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ipc_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "jingle_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "media_blink_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "media_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "midi_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "net_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "services_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "skia_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "sql_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "ui_base_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "url_unittests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "webkit_unit_tests" + }, + { + "swarming": { + "can_use_on_swarming_builders": true + }, + "test": "wtf_unittests" + } + ], "isolated_scripts": [ { "isolate_name": "webkit_layout_tests_exparchive",
diff --git a/testing/buildbot/chromium.swarm.json b/testing/buildbot/chromium.swarm.json index 98a7de2..489881a 100644 --- a/testing/buildbot/chromium.swarm.json +++ b/testing/buildbot/chromium.swarm.json
@@ -630,11 +630,9 @@ "isolated_scripts": [ { "args": [ - "--browser=exact", - "--browser-executable=./test_chrome", - "--xvfb", - "--skip=benchmarks.benchmark_smoke_unittest.BenchmarkSmokeTest.v8.runtime_stats.top_25", - "--skip=scripts_smoke_unittest.ScriptsSmokeTest.testRunTelemetryBenchmarkAsGoogletest" + "--browser=cros-chrome", + "--remote=variable_chromeos_device_hostname", + "--xvfb" ], "isolate_name": "telemetry_perf_unittests", "name": "telemetry_perf_unittests", @@ -652,14 +650,9 @@ }, { "args": [ - "--browser=exact", - "--browser-executable=./test_chrome", - "--jobs=1", - "--skip=telemetry.internal.actions.action_runner_unittest.ActionRunnerTest.testWaitForElement", - "--skip=telemetry.internal.actions.action_runner_unittest.ActionRunnerTest.testWaitForElementWithWrongText", - "--skip=telemetry.internal.actions.action_runner_unittest.ActionRunnerTest.testWaitForJavaScriptCondition", - "--skip=telemetry.internal.actions.key_event_unittest.KeyPressActionTest.testPressEndAndHome", - "--skip=telemetry.page.page_run_end_to_end_unittest.ActualPageRunEndToEndTests.testTrafficSettings" + "--browser=cros-chrome", + "--remote=variable_chromeos_device_hostname", + "--jobs=1" ], "isolate_name": "telemetry_unittests", "name": "telemetry_unittests",
diff --git a/testing/buildbot/filters/fuchsia.content_unittests.filter b/testing/buildbot/filters/fuchsia.content_unittests.filter index 67db632..9d3c4f14 100644 --- a/testing/buildbot/filters/fuchsia.content_unittests.filter +++ b/testing/buildbot/filters/fuchsia.content_unittests.filter
@@ -30,6 +30,9 @@ -MediaStreamManagerTest.MakeMediaAccessRequest -MediaStreamManagerTest.MakeMultipleRequests +# Flaky: http://crbug.com/819924. +-WebMediaPlayerMSTest.CreateHardwareFrames + # Failing: https://crbug.com/771701. -IndexedDBFactoryTest.DataFormatVersion
diff --git a/testing/buildbot/filters/fuchsia.ipc_tests.filter b/testing/buildbot/filters/fuchsia.ipc_tests.filter index 1bab3b84..abcb4c76 100644 --- a/testing/buildbot/filters/fuchsia.ipc_tests.filter +++ b/testing/buildbot/filters/fuchsia.ipc_tests.filter
@@ -2,12 +2,3 @@ # These tests are too slow under Fuchsia in QEMU w/out KVM. -IPCSyncChannelTest.ChattyServer* - -# Flaky, https://crbug.com/764018. --IPCChannelBadMessageTest.BadMessage - -# Flaky, https://crbug.com/764015. --IPCChannelProxyTest.*MessageClassFilters - -# Flaky, https://crbug.com/756112. --IPCMojoBootstrapTest.Connect
diff --git a/testing/buildbot/filters/fuchsia.mojo_unittests.filter b/testing/buildbot/filters/fuchsia.mojo_unittests.filter index 37c4941..6a6824b3 100644 --- a/testing/buildbot/filters/fuchsia.mojo_unittests.filter +++ b/testing/buildbot/filters/fuchsia.mojo_unittests.filter
@@ -12,11 +12,5 @@ -MultiprocessMessagePipeTestWithPeerSupport.PingPongPipe* -MessagePipeTest.SharedBufferHandlePingPong -# Flaky, https://crbug.com/810448. --MultiprocessMessagePipeTestWithPeerSupport*/1 - # Flaky since migration to unified mojo_unittests, https://crbug.com/814914. -FileDataPipeProducerTest.HugeFile - -# Flaky, https://crbug.com/815314. --SharedBufferTest.CreateAndPassFromChildReadOnlyBuffer
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl index 3ef286b..6ae9624 100644 --- a/testing/buildbot/test_suites.pyl +++ b/testing/buildbot/test_suites.pyl
@@ -334,6 +334,30 @@ }, }, + 'chromeos_remote_device_isolated_tests': { + 'telemetry_perf_unittests': { + 'args': [ + '--browser=cros-chrome', + '--remote=variable_chromeos_device_hostname', + '--xvfb', + ], + 'swarming': { + 'hard_timeout': 960, + 'shards': 12, + }, + }, + 'telemetry_unittests': { + 'args': [ + '--browser=cros-chrome', + '--remote=variable_chromeos_device_hostname', + '--jobs=1', + ], + 'swarming': { + 'shards': 4, + }, + }, + }, + 'chromium_android_asan_gtests': { # TODO(kbr): reduce duplication among these tests, and with other # test suites.
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 6694461..b662c70 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -1125,6 +1125,7 @@ }, 'linux-blink-heap-verification': { 'test_suites': { + 'gtest_tests': 'chromium_gtests', 'isolated_scripts': 'chromium_webkit_isolated_scripts', }, }, @@ -1742,7 +1743,7 @@ 'chromiumos_preflight', ], 'test_suites': { - 'isolated_scripts': 'linux_chromeos_rel_isolated_scripts', + 'isolated_scripts': 'chromeos_remote_device_isolated_tests', }, 'swarming': { 'dimension_sets': [
diff --git a/testing/test.gni b/testing/test.gni index f9f8c91..251b003fa 100644 --- a/testing/test.gni +++ b/testing/test.gni
@@ -10,6 +10,7 @@ import("//build/config/android/config.gni") import("//build/config/android/rules.gni") import("//build/config/sanitizers/sanitizers.gni") + import("//build/config/android/extract_unwind_tables.gni") } if (is_fuchsia) { @@ -100,6 +101,18 @@ "write_asset_list", "use_native_activity", ] + + # Adds the unwind tables from unstripped binary as an asset file in the + # apk, if |add_unwind_tables_in_apk| is specified by the test. + if (defined(invoker.add_unwind_tables_in_apk) && + invoker.add_unwind_tables_in_apk) { + _unwind_table_asset_name = "${target_name}_unwind_assets" + unwind_table_asset(_unwind_table_asset_name) { + testonly = true + library_target = _library_target + } + } + shared_library(_library_target) { # Configs will always be defined since we set_defaults in BUILDCONFIG.gn. configs = [] # Prevent list overwriting warning. @@ -129,6 +142,10 @@ # Add the Java classes so that each target does not have to do it. deps += [ "//base/test:test_support_java" ] + if (defined(_unwind_table_asset_name)) { + deps += [ ":${_unwind_table_asset_name}" ] + } + # TODO(agrieve): Remove this data_dep once bots don't build the _apk # target (post-GYP). # It's a bit backwards for the apk to depend on the runner script, since
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG index 9520521..42f3000 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG
@@ -12,10 +12,6 @@ crbug.com/707656 fast/inline-block/14498-positionForCoordinates.html [ Failure ] crbug.com/789878 fast/inline/inline-focus-ring.html [ Failure ] -# NGPhysicalFragment has stale style. -crbug.com/812981 scrollbars/scrollbar-pointer-events.html [ Failure ] -crbug.com/812981 scrollbars/scrollbar-visibility-hidden.html [ Failure ] - # Non-interoperable behavior not worth to fix. crbug.com/591099 fast/text/apply-start-width-after-skipped-text.html [ Skip ] @@ -65,7 +61,7 @@ crbug.com/714962 accessibility/bounds-calc.html [ Failure ] crbug.com/591099 accessibility/canvas-fallback-content-2.html [ Timeout ] crbug.com/591099 accessibility/computed-name.html [ Timeout ] -crbug.com/591099 accessibility/computed-role.html [ Pass Timeout ] +crbug.com/591099 accessibility/computed-role.html [ Timeout ] crbug.com/714962 accessibility/css-first-letter-children.html [ Failure ] crbug.com/591099 accessibility/css-generated-content.html [ Failure ] crbug.com/591099 accessibility/css-styles.html [ Failure ] @@ -110,7 +106,6 @@ crbug.com/714962 compositing/background-color/view-blending-base-background.html [ Failure ] crbug.com/591099 compositing/draws-content/canvas-background-layer.html [ Failure ] crbug.com/591099 compositing/draws-content/webgl-background-layer.html [ Failure ] -crbug.com/714962 compositing/flex-composited-animated-table-row-background.html [ Failure Pass ] crbug.com/591099 compositing/generated-content.html [ Failure Pass ] crbug.com/591099 compositing/geometry/bounds-ignores-hidden-dynamic.html [ Failure ] crbug.com/591099 compositing/geometry/bounds-ignores-hidden.html [ Failure ] @@ -136,7 +131,6 @@ crbug.com/591099 compositing/overflow/universal-accelerated-overflow-scroll.html [ Timeout ] crbug.com/591099 compositing/overflow/update-widget-positions-on-nested-frames-and-scrollers.html [ Failure ] crbug.com/591099 compositing/reflections/compositing-change-inside-reflection.html [ Failure Pass ] -crbug.com/591099 compositing/reflections/nested-reflection-mask-change.html [ Failure ] crbug.com/591099 compositing/reflections/transform-inside-reflection.html [ Failure Pass ] crbug.com/591099 compositing/rtl/rtl-and-writing-mode-scrolling.html [ Failure ] crbug.com/591099 compositing/scrollbars/nested-overlay-scrollbars.html [ Failure ] @@ -156,15 +150,10 @@ crbug.com/591099 css2.1/20110323/margin-applies-to-008.htm [ Failure ] crbug.com/714962 css2.1/20110323/overflow-applies-to-012.htm [ Failure ] crbug.com/591099 css2.1/20110323/table-caption-margins-001.htm [ Failure ] -crbug.com/591099 css2.1/t040103-case-01-c.html [ Failure Pass ] -crbug.com/591099 css2.1/t040304-c64-uri-00-a-g.html [ Failure Pass ] crbug.com/591099 css2.1/t0510-c25-pseudo-elmnt-00-c.html [ Failure ] crbug.com/591099 css2.1/t051201-c23-first-line-00-b.html [ Crash ] crbug.com/591099 css2.1/t051202-c26-psudo-nest-00-c.html [ Crash ] crbug.com/591099 css2.1/t0905-c414-flt-wrap-01-d-g.html [ Failure ] -crbug.com/591099 css2.1/t1002-c5523-width-00-b-g.html [ Failure Pass ] -crbug.com/591099 css2.1/t1005-c5524-width-00-b-g.html [ Failure Pass ] -crbug.com/591099 css2.1/t1005-c5524-width-01-b-g.html [ Failure Pass ] crbug.com/591099 css2.1/t100801-c544-valgn-00-a-ag.html [ Failure ] crbug.com/591099 css2.1/t100801-c544-valgn-03-d-agi.html [ Failure ] crbug.com/591099 css2.1/t1202-counter-04-b.html [ Failure ] @@ -172,12 +161,6 @@ crbug.com/591099 css2.1/t1202-counters-04-b.html [ Failure ] crbug.com/591099 css2.1/t1205-c564-list-img-00-b-g.html [ Failure ] crbug.com/591099 css2.1/t1205-c566-list-stl-01-c-g.html [ Failure ] -crbug.com/591099 css2.1/t140201-c533-bgimage-00-a.html [ Failure Pass ] -crbug.com/591099 css2.1/t140201-c534-bgre-00-b-ag.html [ Failure Pass ] -crbug.com/591099 css2.1/t140201-c534-bgreps-02-c-ag.html [ Failure Pass ] -crbug.com/591099 css2.1/t140201-c534-bgreps-03-c-ag.html [ Failure Pass ] -crbug.com/591099 css2.1/t140201-c534-bgreps-04-c-ag.html [ Failure Pass ] -crbug.com/591099 css2.1/t140201-c534-bgreps-05-c-ag.html [ Failure Pass ] crbug.com/591099 css3/blending/background-blend-mode-overlapping-accelerated-elements.html [ Failure ] crbug.com/591099 css3/filters/composited-layer-child-bounds-after-composited-to-sw-shadow-change.html [ Failure ] crbug.com/591099 css3/filters/effect-reference-subregion-nested.html [ Pass ] @@ -194,7 +177,6 @@ crbug.com/591099 css3/flexbox/floated-flexbox.html [ Failure ] crbug.com/591099 css3/flexbox/intrinsic-width-orthogonal-writing-mode.html [ Failure ] crbug.com/591099 css3/flexbox/line-wrapping.html [ Failure ] -crbug.com/591099 css3/flexbox/mozilla/flexbox-inlinecontent-horiz-5.xhtml [ Failure Pass ] crbug.com/714962 css3/flexbox/mozilla/flexbox-items-as-stacking-contexts-2.html [ Failure ] crbug.com/591099 css3/flexbox/position-absolute-child-with-contenteditable.html [ Failure ] crbug.com/591099 css3/flexbox/scrollbars-auto.html [ Failure ] @@ -394,14 +376,8 @@ crbug.com/591099 external/wpt/css/CSS2/text/text-decoration-applies-to-015.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-color-5.html [ Failure ] crbug.com/714962 external/wpt/css/css-backgrounds/background-attachment-local/attachment-local-clipping-image-5.html [ Failure ] -crbug.com/714962 external/wpt/css/css-backgrounds/background-image-003.html [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-backgrounds/background-image-004.html [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-backgrounds/background-image-005.html [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-backgrounds/background-image-006.html [ Failure Pass ] crbug.com/591099 external/wpt/css/css-backgrounds/box-shadow-syntax-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-display/display-contents-details.html [ Crash ] -crbug.com/714962 external/wpt/css/css-display/display-contents-dynamic-before-after-001.html [ Failure ] -crbug.com/714962 external/wpt/css/css-display/display-contents-dynamic-before-after-first-letter-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-display/display-contents-dynamic-list-001-inline.html [ Failure ] crbug.com/591099 external/wpt/css/css-display/display-contents-dynamic-list-001-none.html [ Failure ] crbug.com/714962 external/wpt/css/css-display/display-contents-dynamic-multicol-001-inline.html [ Failure ] @@ -420,7 +396,6 @@ crbug.com/591099 external/wpt/css/css-flexbox/percentage-heights-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-flexbox/percentage-heights-003.html [ Pass ] crbug.com/591099 external/wpt/css/css-fonts/alternates-order.html [ Pass ] -crbug.com/714962 external/wpt/css/css-fonts/font-display/font-display.html [ Failure ] crbug.com/714962 external/wpt/css/css-fonts/font-features-across-space-1.html [ Pass ] crbug.com/714962 external/wpt/css/css-fonts/font-features-across-space-3.html [ Pass ] crbug.com/591099 external/wpt/css/css-fonts/font-kerning-03.html [ Pass ] @@ -588,8 +563,6 @@ crbug.com/714962 external/wpt/css/css-multicol/multicol-width-large-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-width-small-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-zero-height-001.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-paint-api/style-before-pseudo.https.html [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-paint-api/style-first-letter-pseudo.https.html [ Failure Pass ] crbug.com/591099 external/wpt/css/css-position/position-relative-table-tbody-top.html [ Pass ] crbug.com/591099 external/wpt/css/css-position/position-sticky-nested-inline.html [ Crash ] crbug.com/591099 external/wpt/css/css-position/position-sticky-overflow-padding.html [ Failure ] @@ -716,8 +689,6 @@ crbug.com/591099 external/wpt/css/css-shapes/spec-examples/shape-outside-017.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes/spec-examples/shape-outside-018.html [ Failure ] crbug.com/591099 external/wpt/css/css-shapes/spec-examples/shape-outside-019.html [ Failure ] -crbug.com/591099 external/wpt/css/css-style-attr/style-attr-urls-001.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-style-attr/style-attr-urls-002.xht [ Failure Pass ] crbug.com/591099 external/wpt/css/css-tables/fixup-dynamic-anonymous-inline-table-002.html [ Pass ] crbug.com/591099 external/wpt/css/css-tables/fixup-dynamic-anonymous-table-001.html [ Pass ] crbug.com/591099 external/wpt/css/css-tables/floats/floats-wrap-bfc-006c.xht [ Pass ] @@ -806,228 +777,71 @@ crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-018.xht [ Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-020.xht [ Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-icb-vrl-030.xht [ Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-003.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-005.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-007.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-009.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-011.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-013.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-015.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-017.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-019.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-021.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-023.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-025.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-027.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-029.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-031.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-033.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-035.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-037.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-039.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-041.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-043.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-045.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-047.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-049.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-051.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-053.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-055.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-057.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-059.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-061.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-063.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-065.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-067.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-069.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-071.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-073.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-075.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-077.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-079.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-081.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-083.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-085.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-087.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-089.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-091.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-093.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-095.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-097.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-103.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-105.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-107.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-109.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-111.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-113.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-115.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-117.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-119.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-121.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-123.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-125.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-127.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-129.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-131.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-133.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-135.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-137.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-139.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-141.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-143.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-145.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-147.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-149.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-151.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-153.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-155.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-157.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-159.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-161.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-163.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-165.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-167.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-169.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-171.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-173.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-175.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-177.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-179.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-181.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-183.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-185.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-187.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-189.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-191.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-193.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-195.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-197.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-199.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-201.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-203.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-205.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-207.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-209.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-211.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-213.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-215.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-217.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-219.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-221.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-223.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-225.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-227.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vlr-229.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-002.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-004.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-006.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-008.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-010.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-012.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-014.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-016.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-018.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-020.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-022.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-024.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-026.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-028.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-030.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-032.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-034.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-036.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-038.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-040.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-042.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-044.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-046.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-048.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-050.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-052.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-054.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-056.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-058.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-060.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-062.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-064.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-066.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-068.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-070.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-072.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-074.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-076.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-078.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-080.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-082.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-084.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-086.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-088.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-090.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-092.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-094.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-096.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-102.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-104.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-106.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-108.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-110.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-112.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-114.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-116.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-118.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-120.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-122.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-124.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-126.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-128.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-130.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-132.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-134.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-136.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-138.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-140.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-142.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-144.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-146.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-148.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-150.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-152.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-154.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-156.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-158.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-160.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-162.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-164.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-166.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-168.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-170.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-172.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-174.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-176.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-178.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-180.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-182.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-184.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-186.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-188.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-190.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-192.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-194.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-196.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-198.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-200.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-202.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-204.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-206.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-208.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-210.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-212.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-214.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-216.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-218.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-220.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-222.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-224.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-226.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/abs-pos-non-replaced-vrl-228.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/available-size-001.html [ Failure ] @@ -1053,20 +867,12 @@ crbug.com/591099 external/wpt/css/css-writing-modes/clearance-calculations-vrl-006.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/clearance-calculations-vrl-008.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/clip-rect-vrl-004.xht [ Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/direction-vlr-003.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/direction-vlr-005.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/direction-vrl-002.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/direction-vrl-004.xht [ Failure Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/float-contiguous-vrl-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/float-contiguous-vrl-004.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/float-contiguous-vrl-006.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/float-contiguous-vrl-008.xht [ Failure ] crbug.com/714962 external/wpt/css/css-writing-modes/float-shrink-to-fit-vrl-008.xht [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/float-vlr-005.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/float-vlr-007.xht [ Failure Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/float-vlr-013.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-writing-modes/float-vrl-004.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/float-vrl-006.xht [ Failure Pass ] crbug.com/714962 external/wpt/css/css-writing-modes/float-vrl-008.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/float-vrl-012.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/horizontal-rule-vrl-002.xht [ Failure ] @@ -1140,32 +946,10 @@ crbug.com/591099 external/wpt/css/css-writing-modes/table-column-order-003.xht [ Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/table-column-order-004.xht [ Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/table-column-order-005.xht [ Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-003.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-005.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-007.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-009.xht [ Failure Pass ] -crbug.com/591099 external/wpt/css/css-writing-modes/text-align-vlr-011.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-013.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-015.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-017.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vlr-019.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-002.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-004.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-006.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-008.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-010.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-012.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-014.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-016.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-align-vrl-018.xht [ Failure Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/text-baseline-vlr-007.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/text-baseline-vrl-006.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/text-combine-upright-decorations-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/text-combine-upright-layout-rules-001.html [ Failure ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-indent-vlr-003.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-indent-vlr-005.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-indent-vlr-011.xht [ Failure Pass ] -crbug.com/714962 external/wpt/css/css-writing-modes/text-indent-vlr-013.xht [ Failure Pass ] crbug.com/591099 external/wpt/css/css-writing-modes/text-indent-vrl-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/text-indent-vrl-004.xht [ Failure ] crbug.com/591099 external/wpt/css/css-writing-modes/text-indent-vrl-006.xht [ Failure ] @@ -1206,15 +990,9 @@ crbug.com/591099 external/wpt/css/cssom-view/cssom-getClientRects-002.html [ Failure ] crbug.com/591099 external/wpt/css/cssom-view/elementFromPoint-002.html [ Failure ] crbug.com/591099 external/wpt/css/cssom-view/elementFromPoint-003.html [ Failure ] -crbug.com/714962 external/wpt/css/cssom/medialist-dynamic-001.html [ Failure ] -crbug.com/626703 external/wpt/css/cssom/stylesheet-replacedata-dynamic.html [ Failure ] crbug.com/591099 external/wpt/css/geometry/interfaces.html [ Timeout ] crbug.com/591099 external/wpt/css/geometry/interfaces.worker.html [ Timeout ] -crbug.com/714962 external/wpt/css/selectors/focus-within-001.html [ Failure ] crbug.com/591099 external/wpt/css/selectors/focus-within-004.html [ Failure ] -crbug.com/714962 external/wpt/css/selectors/focus-within-007.html [ Failure ] -crbug.com/714962 external/wpt/css/selectors/focus-within-008.html [ Failure ] -crbug.com/591099 external/wpt/css/selectors/invalidation/sheet-going-away-002.html [ Failure ] crbug.com/591099 external/wpt/css/selectors/selector-placeholder-shown-type-change-001.html [ Pass ] crbug.com/591099 external/wpt/css/selectors/selectors-dir-selector-rtl-001.html [ Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-align-content-vert-001a.xhtml [ Failure ] @@ -1225,7 +1003,7 @@ crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-align-self-horiz-001-table.xhtml [ Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-align-self-vert-001.xhtml [ Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-align-self-vert-rtl-001.xhtml [ Pass ] -crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-baseline-multi-item-vert-001b.html [ Failure Pass ] +crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-baseline-multi-item-vert-001b.html [ Failure ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-break-request-horiz-001a.html [ Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-intrinsic-ratio-003v.html [ Pass ] crbug.com/714962 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-items-as-stacking-contexts-002.html [ Failure ] @@ -1236,7 +1014,6 @@ crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-writing-mode-012.html [ Failure ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-writing-mode-014.html [ Failure ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-writing-mode-015.html [ Failure ] -crbug.com/714962 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/selectors4/class-id-attr-selector-invalidation-01.html [ Failure ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/selectors4/dir-style-03a.html [ Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/variables/variable-declaration-15.html [ Failure Pass ] crbug.com/591099 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/variables/variable-font-face-01.html [ Failure Pass ] @@ -1384,7 +1161,8 @@ crbug.com/591099 external/wpt/encoding/textdecoder-fatal-single-byte.html [ Timeout ] crbug.com/591099 external/wpt/feature-policy/payment-allowed-by-feature-policy.https.sub.html [ Pass ] crbug.com/591099 external/wpt/feature-policy/payment-disabled-by-feature-policy.https.sub.html [ Pass ] -crbug.com/591099 external/wpt/geolocation-API/PositionOptions.https.html [ Failure ] +crbug.com/591099 external/wpt/fetch/api/request/request-cache-default-conditional.html [ Timeout ] +crbug.com/591099 external/wpt/geolocation-API/PositionOptions.https.html [ Failure Pass ] crbug.com/591099 external/wpt/html-media-capture/capture_audio_cancel-manual.html [ Failure ] crbug.com/591099 external/wpt/html-media-capture/capture_image_cancel-manual.html [ Failure ] crbug.com/591099 external/wpt/html-media-capture/capture_video_cancel-manual.html [ Failure ] @@ -1403,7 +1181,6 @@ crbug.com/591099 external/wpt/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-img-auto.html [ Failure ] crbug.com/591099 external/wpt/html/rendering/replaced-elements/svg-embedded-sizing/svg-in-img-percentage.html [ Failure ] crbug.com/591099 external/wpt/html/rendering/replaced-elements/svg-inline-sizing/svg-inline.html [ Timeout ] -crbug.com/714962 external/wpt/html/rendering/the-css-user-agent-style-sheet-and-presentational-hints/body-bgcolor-attribute-change.html [ Failure ] crbug.com/591099 external/wpt/html/semantics/document-metadata/the-link-element/stylesheet-change-href.html [ Failure ] crbug.com/591099 external/wpt/html/semantics/embedded-content/media-elements/track/track-element/track-webvtt-non-snap-to-lines.html [ Failure ] crbug.com/591099 external/wpt/html/semantics/grouping-content/the-li-element/grouping-li-reftest-list-owner-menu.html [ Failure ] @@ -1588,7 +1365,6 @@ crbug.com/591099 external/wpt/workers/Worker_terminate_event_queue.htm [ Timeout ] crbug.com/591099 external/wpt/xhr/send-authentication-prompt-2-manual.htm [ Failure ] crbug.com/591099 fast/animation/scroll-animations/scrolltimeline-currenttime.html [ Failure ] -crbug.com/591099 fast/backgrounds/animated-svg-as-mask.html [ Failure Pass ] crbug.com/591099 fast/backgrounds/background-clip-text.html [ Failure ] crbug.com/591099 fast/backgrounds/background-inherit-color-bug.html [ Failure ] crbug.com/591099 fast/backgrounds/background-leakage-transforms.html [ Failure ] @@ -1603,7 +1379,6 @@ crbug.com/591099 fast/backgrounds/size/backgroundSize16.html [ Failure ] crbug.com/591099 fast/backgrounds/size/contain-and-cover.html [ Failure ] crbug.com/591099 fast/backgrounds/size/zero.html [ Failure Pass ] -crbug.com/591099 fast/backgrounds/svg-as-mask.html [ Failure Pass ] crbug.com/591099 fast/block/basic/quirk-percent-height-table-cell.html [ Failure ] crbug.com/591099 fast/block/block-add-child-crash.html [ Crash ] crbug.com/591099 fast/block/block-width-recalc-with-relative-height.html [ Failure ] @@ -1644,17 +1419,10 @@ crbug.com/591099 fast/block/positioning/rel-positioned-inline-changes-width.html [ Crash ] crbug.com/591099 fast/block/positioning/relative-overflow-replaced.html [ Failure ] crbug.com/591099 fast/block/positioning/vertical-rl/002.html [ Failure ] -crbug.com/591099 fast/body-propagation/background-image/003-declarative.xhtml [ Failure Pass ] -crbug.com/591099 fast/body-propagation/background-image/004-declarative.xhtml [ Failure Pass ] -crbug.com/591099 fast/body-propagation/background-image/006-declarative.xhtml [ Failure Pass ] -crbug.com/591099 fast/body-propagation/background-image/007-declarative.xhtml [ Failure Pass ] crbug.com/591099 fast/borders/bidi-002.html [ Failure ] crbug.com/591099 fast/borders/bidi-012.html [ Failure ] -crbug.com/714962 fast/borders/block-mask-overlay-image.html [ Failure Pass ] crbug.com/591099 fast/borders/border-antialiasing.html [ Failure ] crbug.com/591099 fast/borders/border-image-border-radius.html [ Failure ] -crbug.com/591099 fast/borders/border-image-fill-inline-no-border.html [ Failure Pass ] -crbug.com/591099 fast/borders/border-image-inherits-with-border.html [ Failure Pass ] crbug.com/714962 fast/borders/border-image-outset-split-inline.html [ Failure ] crbug.com/714962 fast/borders/border-image-scaled.html [ Failure Pass ] crbug.com/714962 fast/borders/border-inner-bleed.html [ Failure ] @@ -1720,14 +1488,11 @@ crbug.com/591099 fast/css-generated-content/after-duplicated-after-split.html [ Failure Pass ] crbug.com/805301 fast/css-generated-content/crash-selection-editing-removes-pseudo.html [ Failure ] crbug.com/591099 fast/css-generated-content/empty-first-letter-with-columns-crash.html [ Crash ] -crbug.com/591099 fast/css-generated-content/first-letter-in-nested-before-table.html [ Failure ] crbug.com/591099 fast/css-generated-content/first-letter-next-sibling-crash.html [ Crash ] crbug.com/591099 fast/css-generated-content/float-first-letter-siblings-convert-to-inline.html [ Crash ] crbug.com/714962 fast/css-generated-content/hover-inline.html [ Failure ] crbug.com/591099 fast/css-generated-content/table-before-after-child-add.html [ Failure ] crbug.com/591099 fast/css-generated-content/table-cell-before-after-child-add.html [ Failure ] -crbug.com/591099 fast/css-generated-content/table-cell-before-content.html [ Failure ] -crbug.com/591099 fast/css-generated-content/table-parts-before-and-after.html [ Failure ] crbug.com/591099 fast/css-generated-content/table-row-before-after-child-add.html [ Failure ] crbug.com/591099 fast/css-generated-content/table-row-group-to-inline.html [ Failure ] crbug.com/591099 fast/css-generated-content/table-row-group-with-before.html [ Failure ] @@ -1865,7 +1630,6 @@ crbug.com/591099 fast/css/first-child-pseudo-class.html [ Failure ] crbug.com/714962 fast/css/first-letter-before-hit-test.html [ Failure ] crbug.com/714962 fast/css/first-letter-hit-test.html [ Failure ] -crbug.com/714962 fast/css/first-letter-hover-002.html [ Failure ] crbug.com/714962 fast/css/first-letter-hover-hit-test.html [ Failure ] crbug.com/591099 fast/css/first-letter-hover.html [ Failure ] crbug.com/714962 fast/css/first-letter-range-insert.html [ Failure ] @@ -1887,8 +1651,6 @@ crbug.com/591099 fast/css/hover-subselector.html [ Failure ] crbug.com/591099 fast/css/ignore-empty-focus-ring-rects.html [ Failure ] crbug.com/591099 fast/css/import_with_baseurl.html [ Failure Pass ] -crbug.com/714962 fast/css/invalidation/sheet-loaded-before-invalidation.html [ Failure ] -crbug.com/714962 fast/css/invalidation/style-invalidation-before-attach.html [ Failure ] crbug.com/591099 fast/css/large-numbers.html [ Timeout ] crbug.com/591099 fast/css/last-child-pseudo-class.html [ Failure ] crbug.com/591099 fast/css/last-of-type-pseudo-class.html [ Failure ] @@ -1944,7 +1706,6 @@ crbug.com/591099 fast/deprecated-flexbox/relpos-flex-item-with-percent-height-abspos-child.html [ Failure ] crbug.com/591099 fast/deprecated-flexbox/relpos-flex-item-with-percent-height-abspos-descendant.html [ Failure ] crbug.com/591099 fast/deprecated-flexbox/repaint-scrollbar.html [ Failure ] -crbug.com/714962 fast/dnd/link-dragging-draggable-link.html [ Failure ] crbug.com/591099 fast/doctypes/001.html [ Failure ] crbug.com/591099 fast/doctypes/002.html [ Failure ] crbug.com/591099 fast/doctypes/003.html [ Failure ] @@ -1985,15 +1746,12 @@ crbug.com/591099 fast/dom/nodesFromRect/nodesFromRect-inner-documents.html [ Failure ] crbug.com/714962 fast/dom/nodesFromRect/nodesFromRect-links-and-text.html [ Failure ] crbug.com/591099 fast/dom/rtl-scroll-to-leftmost-and-resize.html [ Failure ] -crbug.com/714962 fast/dom/shadow/content-pseudo-element-dynamic-attribute-change.html [ Failure ] -crbug.com/714962 fast/dom/shadow/import-rule-in-shadow-tree-needs-document-style-recalc.html [ Failure ] crbug.com/714962 fast/dom/shadow/scrollbar.html [ Crash ] crbug.com/591099 fast/dom/shadow/selections-in-shadow.html [ Timeout ] crbug.com/591099 fast/dom/shadow/shadow-dom-event-dispatching-details-summary.html [ Pass ] crbug.com/591099 fast/dom/wrapper-classes.html [ Timeout ] crbug.com/591099 fast/dynamic/continuation-detach-crash.html [ Crash ] crbug.com/591099 fast/dynamic/first-letter-after-list-marker.html [ Failure ] -crbug.com/714962 fast/dynamic/focus-clear-resolver-crash.html [ Failure ] crbug.com/591099 fast/dynamic/layer-hit-test-crash.html [ Failure Pass ] crbug.com/591099 fast/dynamic/outerHTML-img.html [ Failure Pass ] crbug.com/591099 fast/dynamic/selection-highlight-adjust.html [ Failure ] @@ -2057,7 +1815,6 @@ crbug.com/591099 fast/forms/select/select-initial-position.html [ Failure ] crbug.com/591099 fast/forms/select/select-style.html [ Failure ] crbug.com/591099 fast/forms/selection-direction.html [ Timeout ] -crbug.com/714962 fast/forms/suggestion-picker/date-suggestion-picker-appearance-with-scroll-bar.html [ Failure ] crbug.com/591099 fast/forms/suggestion-picker/date-suggestion-picker-appearance-zoom125.html [ Failure ] crbug.com/591099 fast/forms/suggestion-picker/date-suggestion-picker-appearance-zoom200.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/date-suggestion-picker-appearance.html [ Failure ] @@ -2065,13 +1822,11 @@ crbug.com/714962 fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-rtl.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-with-scroll-bar.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance.html [ Failure ] -crbug.com/714962 fast/forms/suggestion-picker/month-suggestion-picker-appearance-with-scroll-bar.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/month-suggestion-picker-appearance.html [ Failure ] crbug.com/591099 fast/forms/suggestion-picker/time-suggestion-picker-appearance-locale-hebrew.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/time-suggestion-picker-appearance-rtl.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/time-suggestion-picker-appearance-with-scroll-bar.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/time-suggestion-picker-appearance.html [ Failure ] -crbug.com/714962 fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar.html [ Failure ] crbug.com/714962 fast/forms/suggestion-picker/week-suggestion-picker-appearance.html [ Failure ] crbug.com/591099 fast/forms/text-control-intrinsic-widths.html [ Timeout ] crbug.com/591099 fast/forms/textarea/textarea-align.html [ Failure ] @@ -2080,7 +1835,6 @@ crbug.com/714962 fast/forms/textarea/textarea-resize-below-min-intrinsic-size.html [ Pass ] crbug.com/591099 fast/forms/textarea/textarea-resize-orthogonal-containing-block.html [ Pass ] crbug.com/591099 fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html [ Timeout ] -crbug.com/591099 fast/frames/content-opacity-1.html [ Failure Pass ] crbug.com/591099 fast/frames/iframe-with-frameborder.html [ Failure ] crbug.com/591099 fast/gradients/generated-gradients.html [ Failure Pass ] crbug.com/591099 fast/gradients/list-item-gradient.html [ Failure ] @@ -2090,8 +1844,6 @@ crbug.com/591099 fast/hidpi/broken-image-icon-hidpi.html [ Failure ] crbug.com/591099 fast/hidpi/image-set-list-style-image.html [ Failure ] crbug.com/591099 fast/hidpi/image-set-shape-outside.html [ Failure ] -crbug.com/714962 fast/history/visited-link-hover-background-color.html [ Failure ] -crbug.com/714962 fast/history/visited-link-hover-border-color.html [ Failure ] crbug.com/714962 fast/history/visited-link-hover-emphasis-color.html [ Failure ] crbug.com/591099 fast/history/visited-link-hover-outline-color.html [ Failure ] crbug.com/714962 fast/history/visited-link-hover-text-decoration-color.html [ Failure ] @@ -2493,6 +2245,7 @@ crbug.com/591099 fast/multicol/span/vertical-rl.html [ Failure ] crbug.com/591099 fast/multicol/span/with-border.html [ Failure ] crbug.com/591099 fast/multicol/static-child-becomes-fixedpos.html [ Failure ] +crbug.com/591099 fast/multicol/svg-change-column-crash.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-and-cells-fixed-width.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-and-cells.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-with-block.html [ Failure ] @@ -2853,19 +2606,7 @@ crbug.com/714962 fast/table/split-table-section-before-anonymous-block-2.html [ Failure ] crbug.com/714962 fast/table/split-table-section-before-anonymous-block-3.html [ Failure ] crbug.com/714962 fast/table/split-table-section-before-anonymous-block-4.html [ Failure ] -crbug.com/714962 fast/table/table-after-child-in-table.html [ Failure ] -crbug.com/714962 fast/table/table-before-child-in-table.html [ Failure ] -crbug.com/714962 fast/table/table-cell-after-child-in-block.html [ Failure ] -crbug.com/714962 fast/table/table-cell-after-child-in-table.html [ Failure ] -crbug.com/714962 fast/table/table-cell-before-after-content-around-table-block.html [ Failure ] -crbug.com/714962 fast/table/table-cell-before-after-content-around-table-row.html [ Failure ] -crbug.com/714962 fast/table/table-cell-before-after-content-around-table.html [ Failure ] -crbug.com/714962 fast/table/table-cell-before-child-in-block.html [ Failure ] -crbug.com/714962 fast/table/table-cell-before-child-in-table.html [ Failure ] crbug.com/591099 fast/table/table-display-types-vertical.html [ Failure ] -crbug.com/714962 fast/table/table-row-after-child-in-block.html [ Failure ] -crbug.com/714962 fast/table/table-row-before-after-content-around-block.html [ Failure ] -crbug.com/714962 fast/table/table-row-before-child-in-block.html [ Failure ] crbug.com/714962 fast/table/text-field-baseline.html [ Failure Pass ] crbug.com/591099 fast/table/unbreakable-images-quirk.html [ Failure ] crbug.com/591099 fast/table/unused-percent-heights.html [ Failure Pass ] @@ -3157,7 +2898,7 @@ crbug.com/591099 fullscreen/full-screen-element-stack.html [ Crash ] crbug.com/591099 fullscreen/full-screen-iframe-not-allowed.html [ Failure ] crbug.com/591099 fullscreen/full-screen-remove-ancestor-after.html [ Crash Pass ] -crbug.com/591099 fullscreen/full-screen-ruleset-crash.html [ Crash ] +crbug.com/591099 fullscreen/full-screen-ruleset-crash.html [ Crash Pass ] crbug.com/591099 fullscreen/full-screen-twice-newapi.html [ Crash ] crbug.com/591099 fullscreen/full-screen-with-css-reference-filter.html [ Crash ] crbug.com/591099 fullscreen/full-screen-with-flex-item.html [ Crash ] @@ -3183,7 +2924,7 @@ crbug.com/591099 html/marquee/marquee-scroll.html [ Failure ] crbug.com/591099 html/marquee/marquee-scrollamount.html [ Failure ] crbug.com/591099 http/tests/css/css-image-valued-shape.html [ Failure ] -crbug.com/591099 http/tests/css/missing-repaint-after-slow-style-sheet.pl [ Failure ] +crbug.com/591099 http/tests/css/missing-repaint-after-slow-style-sheet.pl [ Failure Pass ] crbug.com/591099 http/tests/css/shape-image-file.html [ Failure ] crbug.com/591099 http/tests/csspaint/invalidation-background-image.html [ Timeout ] crbug.com/591099 http/tests/csspaint/invalidation-border-image.html [ Timeout ] @@ -3213,22 +2954,21 @@ crbug.com/591099 http/tests/devtools/elements/styles-3/styles-disable-inherited.js [ Failure ] crbug.com/714962 http/tests/devtools/jump-to-previous-editing-location.js [ Failure ] crbug.com/591099 http/tests/devtools/network/network-datareceived.js [ Failure ] -crbug.com/591099 http/tests/devtools/oopif/oopif-elements-navigate-in.js [ Failure ] crbug.com/714962 http/tests/devtools/service-workers/service-workers-view.js [ Failure ] crbug.com/591099 http/tests/devtools/text-autosizing-override.js [ Failure ] crbug.com/591099 http/tests/devtools/tracing/scroll-invalidations.js [ Failure ] crbug.com/591099 http/tests/devtools/tracing/timeline-misc/timeline-bound-function.js [ Failure ] crbug.com/591099 http/tests/devtools/tracing/timeline-misc/timeline-grouped-invalidations.js [ Failure ] crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-and-multiple-style-invalidations.js [ Failure ] -crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.js [ Pass Timeout ] -crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations.js [ Failure Pass ] -crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.js [ Failure Pass ] +crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.js [ Timeout ] +crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations.js [ Failure ] +crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint-with-style-recalc-invalidations.js [ Failure ] crbug.com/591099 http/tests/devtools/tracing/timeline-paint/timeline-paint.js [ Pass ] crbug.com/591099 http/tests/feature-policy/fullscreen-disabled.php [ Pass ] crbug.com/591099 http/tests/feature-policy/payment-disabled.php [ Pass ] crbug.com/591099 http/tests/feature-policy/payment-enabledforall.php [ Pass ] crbug.com/591099 http/tests/images/restyle-decode-error.html [ Failure ] -crbug.com/783102 http/tests/incremental/frame-focus-before-load.html [ Timeout ] +crbug.com/783102 http/tests/incremental/frame-focus-before-load.html [ Pass Timeout ] crbug.com/591099 http/tests/incremental/slow-utf8-text.pl [ Pass Timeout ] crbug.com/591099 http/tests/inspector-protocol/network/response-interception-no-change-content-not-ready.js [ Pass ] crbug.com/591099 http/tests/inspector-protocol/network/response-interception-request-completes-network-closes.js [ Pass ] @@ -3259,7 +2999,6 @@ crbug.com/591099 http/tests/shapes/shape-outside-svg-image-shape-margin.html [ Failure ] crbug.com/591099 http/tests/text-autosizing/narrow-iframe.html [ Failure ] crbug.com/591099 http/tests/text-autosizing/wide-iframe.html [ Failure ] -crbug.com/714962 http/tests/webfont/font-display-intervention.html [ Failure Pass ] crbug.com/591099 http/tests/websocket/invalid-subprotocol-characters.html [ Timeout ] crbug.com/591099 http/tests/workers/shared-worker-performance-timeline.html [ Pass ] crbug.com/591099 ietestcenter/css3/bordersbackgrounds/background-attachment-local-scrolling.htm [ Failure ] @@ -3329,11 +3068,13 @@ crbug.com/591099 inspector-protocol/timeline/page-frames.js [ Pass ] crbug.com/714962 intersection-observer/root-margin.html [ Failure ] crbug.com/714962 intersection-observer/text-target.html [ Failure ] +crbug.com/591099 media/audio-controls-rendering.html [ Failure ] crbug.com/591099 media/autoplay/document-user-activation.html [ Failure ] crbug.com/591099 media/controls/volumechange-muted-attribute.html [ Failure Pass ] crbug.com/591099 media/video-aspect-ratio.html [ Failure Pass ] crbug.com/591099 media/video-colorspace-yuv420.html [ Failure Pass ] crbug.com/591099 media/video-colorspace-yuv422.html [ Failure Pass ] +crbug.com/591099 media/video-display-toggle.html [ Failure ] crbug.com/591099 media/video-persistence.html [ Crash ] crbug.com/591099 media/video-transformed.html [ Failure ] crbug.com/591099 netinfo/estimate-multiple-frames.html [ Failure Pass ] @@ -3348,7 +3089,7 @@ crbug.com/591099 paint/invalidation/block-no-inflow-children.html [ Failure ] crbug.com/591099 paint/invalidation/box/border-radius-repaint.html [ Failure ] crbug.com/591099 paint/invalidation/box/border-repaint-glitch.html [ Failure ] -crbug.com/591099 paint/invalidation/box/box-inline-resize.html [ Crash Failure ] +crbug.com/591099 paint/invalidation/box/box-inline-resize.html [ Failure ] crbug.com/591099 paint/invalidation/box/box-shadow-dynamic.html [ Failure ] crbug.com/591099 paint/invalidation/box/hover-pseudo-borders.html [ Failure ] crbug.com/591099 paint/invalidation/box/invalidate-box-shadow-currentColor.html [ Failure ] @@ -3368,7 +3109,6 @@ crbug.com/591099 paint/invalidation/clip/replaced-clipped-positioned-not-wrong-incremental-repainting.html [ Failure ] crbug.com/591099 paint/invalidation/compositing/column-span-under-composited-column-child.html [ Crash ] crbug.com/714962 paint/invalidation/compositing/composited-inline-change-text-data-keep-geometry.html [ Crash ] -crbug.com/714962 paint/invalidation/compositing/composited-non-stacking-context-not-invalidation-container.html [ Failure ] crbug.com/591099 paint/invalidation/compositing/fixed-pos-with-abs-pos-child-scroll.html [ Failure ] crbug.com/591099 paint/invalidation/compositing/iframe-clip-removed.html [ Failure ] crbug.com/591099 paint/invalidation/compositing/iframe-inside-squashed-layer.html [ Failure ] @@ -3477,10 +3217,8 @@ crbug.com/591099 paint/invalidation/outline/outline-shrinking.html [ Failure ] crbug.com/591099 paint/invalidation/overflow/align-items-overflow-change.html [ Failure ] crbug.com/591099 paint/invalidation/overflow/align-self-overflow-change.html [ Failure ] -crbug.com/591099 paint/invalidation/overflow/float-overflow-right.html [ Crash Failure ] -crbug.com/591099 paint/invalidation/overflow/float-overflow.html [ Crash Failure ] -crbug.com/591099 paint/invalidation/overflow/inline-block-overflow-repaint.html [ Failure ] -crbug.com/591099 paint/invalidation/overflow/inline-box-overflow-repaint.html [ Failure ] +crbug.com/591099 paint/invalidation/overflow/float-overflow-right.html [ Failure ] +crbug.com/591099 paint/invalidation/overflow/float-overflow.html [ Failure ] crbug.com/714962 paint/invalidation/overflow/inline-overflow.html [ Failure ] crbug.com/714962 paint/invalidation/overflow/inline-vertical-lr-overflow.html [ Failure ] crbug.com/714962 paint/invalidation/overflow/inline-vertical-rl-overflow.html [ Failure ] @@ -3559,7 +3297,6 @@ crbug.com/591099 paint/invalidation/selection/selected-replaced.html [ Failure ] crbug.com/591099 paint/invalidation/selection/selection-after-delete.html [ Failure ] crbug.com/591099 paint/invalidation/selection/selection-after-remove.html [ Failure ] -crbug.com/714962 paint/invalidation/selection/selection-and-text-repaint.html [ Failure ] crbug.com/591099 paint/invalidation/selection/selection-change-in-iframe-with-relative-parent.html [ Failure ] crbug.com/714962 paint/invalidation/selection/selection-clear-after-move.html [ Failure ] crbug.com/591099 paint/invalidation/selection/selection-clear.html [ Failure ] @@ -3618,9 +3355,7 @@ crbug.com/591099 paint/invalidation/table/cached-change-tbody-border-width.html [ Failure ] crbug.com/591099 paint/invalidation/table/caret-contenteditable-content-after.html [ Failure ] crbug.com/591099 paint/invalidation/table/collapsed-border-cell-resize.html [ Failure ] -crbug.com/591099 paint/invalidation/table/collapsed-border-cell-visibility.html [ Failure ] crbug.com/591099 paint/invalidation/table/collapsed-border-change-rowspan.html [ Failure ] -crbug.com/714962 paint/invalidation/table/collapsed-border-current-color.html [ Failure ] crbug.com/591099 paint/invalidation/table/composited-table-background-col-initial-empty.html [ Failure ] crbug.com/591099 paint/invalidation/table/composited-table-background-col-span-initial-empty.html [ Failure ] crbug.com/591099 paint/invalidation/table/composited-table-background-col-span.html [ Failure ] @@ -3642,7 +3377,6 @@ crbug.com/591099 paint/invalidation/table/resize-table-repaint-vertical-align-cell.html [ Failure ] crbug.com/591099 paint/invalidation/table/resize-table-row-repaint.html [ Failure ] crbug.com/591099 paint/invalidation/table/single-line-cells-repeating-thead-break-inside-on-thead-only.html [ Failure ] -crbug.com/714962 paint/invalidation/table/table-cell-become-visible-using-row-background.html [ Crash Pass ] crbug.com/591099 paint/invalidation/table/table-cell-collapsed-border.html [ Failure ] crbug.com/591099 paint/invalidation/table/table-cell-move.html [ Failure ] crbug.com/591099 paint/invalidation/table/table-collapsed-border.html [ Failure ] @@ -3650,7 +3384,7 @@ crbug.com/591099 paint/invalidation/table/table-outer-border.html [ Failure ] crbug.com/591099 paint/invalidation/table/table-row.html [ Failure ] crbug.com/591099 paint/invalidation/table/table-section-repaint.html [ Failure ] -crbug.com/591099 paint/invalidation/table/table-shrink-row-repaint.html [ Crash Failure ] +crbug.com/591099 paint/invalidation/table/table-shrink-row-repaint.html [ Failure ] crbug.com/591099 paint/invalidation/table/table-two-pass-layout-overpaint.html [ Failure ] crbug.com/591099 paint/invalidation/text-append-dirty-lines.html [ Failure ] crbug.com/714962 paint/invalidation/text-decoration-invalidation.html [ Failure ] @@ -3767,7 +3501,6 @@ crbug.com/714962 scrollbars/scrollbar-position-crash.html [ Crash ] crbug.com/591099 shadow-dom/css-style-inherit.html [ Pass ] crbug.com/591099 shadow-dom/focus-navigation-with-delegatesFocus.html [ Timeout ] -crbug.com/714962 shadow-dom/slotted-pseudo-element-dynamic-attribute-change.html [ Failure ] crbug.com/591099 shapedetection/detection-HTMLVideoElement.html [ Pass ] crbug.com/591099 storage/indexeddb/cursor-advance.html [ Pass Timeout ] crbug.com/591099 storage/indexeddb/cursor-continue-validity.html [ Timeout ] @@ -3783,14 +3516,7 @@ crbug.com/591099 storage/indexeddb/objectstore-cursor.html [ Timeout ] crbug.com/591099 storage/indexeddb/objectstore-keycursor.html [ Timeout ] crbug.com/591099 storage/indexeddb/structured-clone.html [ Timeout ] -crbug.com/591099 svg/as-background-image/animated-svg-as-background.html [ Crash Pass ] -crbug.com/591099 svg/as-background-image/svg-as-background-1.html [ Failure Pass ] -crbug.com/591099 svg/as-background-image/svg-as-background-3.html [ Failure Pass ] -crbug.com/591099 svg/as-background-image/svg-as-background-5.html [ Failure Pass ] -crbug.com/591099 svg/as-background-image/svg-as-background-6.html [ Failure Pass ] crbug.com/714962 svg/as-background-image/svg-as-background-body.html [ Failure ] -crbug.com/591099 svg/as-background-image/svg-as-background-with-relative-size.html [ Failure Pass ] -crbug.com/591099 svg/as-background-image/svg-as-tiled-background.html [ Failure Pass ] crbug.com/591099 svg/as-border-image/svg-as-border-image-2.html [ Failure ] crbug.com/591099 svg/as-border-image/svg-as-border-image.html [ Failure ] crbug.com/714962 svg/canvas/canvas-pattern-svg.html [ Failure Pass ] @@ -3835,12 +3561,10 @@ crbug.com/714962 svg/text/tspan-multiple-outline.svg [ Failure ] crbug.com/591099 svg/transforms/text-with-pattern-inside-transformed-html.xhtml [ Failure ] crbug.com/591099 svg/transforms/transformed-text-fill-pattern.html [ Failure ] -crbug.com/591099 svg/wicd/test-scalable-background-image1.xhtml [ Crash Failure ] +crbug.com/591099 svg/wicd/test-scalable-background-image1.xhtml [ Failure ] crbug.com/591099 svg/zoom/page/zoom-hixie-mixed-009.xml [ Failure Pass ] crbug.com/591099 svg/zoom/page/zoom-hixie-rendering-model-004.xhtml [ Failure Pass ] crbug.com/591099 svg/zoom/page/zoom-replaced-intrinsic-ratio-001.htm [ Failure ] -crbug.com/591099 svg/zoom/page/zoom-svg-as-background-with-relative-size-and-viewBox.html [ Crash Pass ] -crbug.com/591099 svg/zoom/page/zoom-svg-as-background-with-relative-size.html [ Crash Pass ] crbug.com/591099 svg/zoom/page/zoom-svg-through-object-with-percentage-size.xhtml [ Failure Pass ] crbug.com/591099 svg/zoom/text/zoom-hixie-mixed-009.xml [ Failure Pass ] crbug.com/591099 tables/layering/paint-test-layering-1.html [ Failure ] @@ -4082,8 +3806,6 @@ crbug.com/591099 virtual/incremental-shadow-dom/external/wpt/shadow-dom/untriaged/shadow-trees/reprojection/reprojection-001.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/external/wpt/shadow-dom/untriaged/shadow-trees/shadow-root-002.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/external/wpt/shadow-dom/untriaged/user-interaction/ranges-and-selections/test-002.html [ Pass ] -crbug.com/714962 virtual/incremental-shadow-dom/fast/dom/shadow/content-pseudo-element-dynamic-attribute-change.html [ Failure ] -crbug.com/714962 virtual/incremental-shadow-dom/fast/dom/shadow/import-rule-in-shadow-tree-needs-document-style-recalc.html [ Failure ] crbug.com/591099 virtual/incremental-shadow-dom/fast/dom/shadow/make-marquee-bold-by-exec-command-crash.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/fast/dom/shadow/no-renderers-for-light-children.html [ Pass ] crbug.com/714962 virtual/incremental-shadow-dom/fast/dom/shadow/scrollbar.html [ Crash ] @@ -4105,7 +3827,6 @@ crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slots-1.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slots-2.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slots-dynamic.html [ Pass ] -crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slotted-pseudo-element-dynamic-attribute-change.html [ Failure ] crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slotted-pseudo-element-shared-style.html [ Pass ] crbug.com/591099 virtual/incremental-shadow-dom/shadow-dom/slotted-pseudo-element.html [ Pass ] crbug.com/591099 virtual/layout_ng/ [ Skip ] @@ -4122,7 +3843,7 @@ crbug.com/591099 virtual/mouseevent_fractional/fast/events/mouseevent-getModifierState.html [ Timeout ] crbug.com/714962 virtual/mouseevent_fractional/fast/events/offsetX-offsetY.html [ Failure ] crbug.com/591099 virtual/mouseevent_fractional/fast/events/onclick-list-marker.html [ Failure ] -crbug.com/591099 virtual/mouseevent_fractional/fast/events/overflow-scroll-fake-mouse-move.html [ Timeout ] +crbug.com/591099 virtual/mouseevent_fractional/fast/events/overflow-scroll-fake-mouse-move.html [ Pass Timeout ] crbug.com/591099 virtual/mouseevent_fractional/fast/events/pointer-events-2.html [ Failure ] crbug.com/591099 virtual/mouseevent_fractional/fast/events/pointerevents/mouse-pointer-capture-transition-events.html [ Timeout ] crbug.com/591099 virtual/mouseevent_fractional/fast/events/pointerevents/mouse-pointer-capture.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/SmokeTests b/third_party/WebKit/LayoutTests/SmokeTests index 18818f3..68afc0b 100644 --- a/third_party/WebKit/LayoutTests/SmokeTests +++ b/third_party/WebKit/LayoutTests/SmokeTests
@@ -69,8 +69,6 @@ custom-elements/array-squat-crash.html custom-elements/imports/upgrade-order.html custom-elements/spec/state-failed-create.html -custom-properties/register-property.html -custom-properties/var-reference-registered-properties.html device_orientation/motion/add-listener-from-callback.html device_orientation/orientation/create-event.html dom/attr/parent-adopt-node.html @@ -157,6 +155,8 @@ external/wpt/css/cssom/medialist-interfaces-004.html external/wpt/css/cssom-view/cssom-view/media-query-list-interface.xht external/wpt/css/cssom-view/cssom-view-window-screen-interface.html +external/wpt/css/css-properties-values-api/register-property.html +external/wpt/css/css-properties-values-api/var-reference-registered-properties.html external/wpt/css/cssom-view/ttwf-scrollintoview.html external/wpt/css/css-timing/cubic-bezier-timing-functions-output.html external/wpt/css/css-timing/frames-timing-functions-output.html
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index 074c9e1..2708dbb 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -307,7 +307,6 @@ ### virtual/layout_ng/fast/block/basic crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/basic/011.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/018.html [ Failure ] -crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-percent-height-grandchild.html [ Failure ] crbug.com/635619 virtual/layout_ng/fast/block/basic/quirk-percent-height-table-cell.html [ Failure ] crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/basic/text-indent-rtl.html [ Failure ] crbug.com/635619 [ Mac ] virtual/layout_ng/fast/block/basic/truncation-rtl.html [ Failure ] @@ -469,7 +468,6 @@ crbug.com/714962 [ Mac ] virtual/layout_ng/fast/writing-mode/margins.html [ Failure ] crbug.com/714962 [ Mac ] virtual/layout_ng/fast/writing-mode/orthogonal-inline-block.html [ Failure ] crbug.com/714962 virtual/layout_ng/fast/writing-mode/orthogonal-writing-modes-available-width-absolute-crash.html [ Failure ] -crbug.com/714962 virtual/layout_ng/fast/writing-mode/percentage-height-orthogonal-writing-modes-quirks.html [ Failure ] crbug.com/714962 virtual/layout_ng/fast/writing-mode/percentage-height-orthogonal-writing-modes.html [ Failure ] crbug.com/714962 virtual/layout_ng/fast/writing-mode/percentage-margins-absolute-replaced.html [ Failure ] crbug.com/714962 virtual/layout_ng/fast/writing-mode/percentage-margins-absolute.html [ Failure ] @@ -2585,6 +2583,7 @@ # Importing 'fetch' tests from WPT. crbug.com/705490 external/wpt/fetch/api/basic/error-after-response.html [ Timeout Pass ] crbug.com/813694 external/wpt/fetch/api/redirect/redirect-location-worker.html [ Pass Timeout ] +crbug.com/820334 external/wpt/fetch/api/request/request-cache-default-conditional.html [ Timeout Pass ] crbug.com/705490 virtual/outofblink-cors/external/wpt/fetch/api/basic/error-after-response.html [ Timeout Pass ] crbug.com/765116 external/wpt/xhr/responsexml-document-properties.htm [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json b/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json index 11962b4e..5badc09 100644 --- a/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json +++ b/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json
@@ -118104,6 +118104,11 @@ {} ] ], + "css/css-properties-values-api/register-property-syntax-parsing-expected.txt": [ + [ + {} + ] + ], "css/css-pseudo/first-letter-001-ref.html": [ [ {} @@ -129014,21 +129019,11 @@ {} ] ], - "css/cssom/medialist-interfaces-001-expected.txt": [ - [ - {} - ] - ], "css/cssom/medialist-interfaces-002-expected.txt": [ [ {} ] ], - "css/cssom/medialist-interfaces-004-expected.txt": [ - [ - {} - ] - ], "css/cssom/selectorText-modification-restyle-001-ref.html": [ [ {} @@ -180434,6 +180429,54 @@ {} ] ], + "css/css-properties-values-api/register-property-syntax-parsing.html": [ + [ + "/css/css-properties-values-api/register-property-syntax-parsing.html", + {} + ] + ], + "css/css-properties-values-api/register-property.html": [ + [ + "/css/css-properties-values-api/register-property.html", + {} + ] + ], + "css/css-properties-values-api/registered-properties-inheritance.html": [ + [ + "/css/css-properties-values-api/registered-properties-inheritance.html", + {} + ] + ], + "css/css-properties-values-api/registered-property-computation.html": [ + [ + "/css/css-properties-values-api/registered-property-computation.html", + {} + ] + ], + "css/css-properties-values-api/registered-property-cssom.html": [ + [ + "/css/css-properties-values-api/registered-property-cssom.html", + {} + ] + ], + "css/css-properties-values-api/registered-property-initial.html": [ + [ + "/css/css-properties-values-api/registered-property-initial.html", + {} + ] + ], + "css/css-properties-values-api/var-reference-registered-properties-cycles.html": [ + [ + "/css/css-properties-values-api/var-reference-registered-properties-cycles.html", + {} + ] + ], + "css/css-properties-values-api/var-reference-registered-properties.html": [ + [ + "/css/css-properties-values-api/var-reference-registered-properties.html", + {} + ] + ], "css/css-pseudo/first-letter-property-whitelist.html": [ [ "/css/css-pseudo/first-letter-property-whitelist.html", @@ -288581,6 +288624,42 @@ "c7b441a3a07276cad9528dd3ef7d82844d06e2d8", "support" ], + "css/css-properties-values-api/register-property-syntax-parsing-expected.txt": [ + "be5081a45adf9fabd3b1644c7b0c1186bee6a1c6", + "support" + ], + "css/css-properties-values-api/register-property-syntax-parsing.html": [ + "b065f4840b3c1deb4a2f8a59428e102f2ae11686", + "testharness" + ], + "css/css-properties-values-api/register-property.html": [ + "df61ce5dd13847deaa9b7165dd1277c1ddefb646", + "testharness" + ], + "css/css-properties-values-api/registered-properties-inheritance.html": [ + "131676bfa0733a64b679473b411ef651a9df1ab0", + "testharness" + ], + "css/css-properties-values-api/registered-property-computation.html": [ + "875acfd6e6446e4cb14fcd19fe16e83630b5fe31", + "testharness" + ], + "css/css-properties-values-api/registered-property-cssom.html": [ + "0fecf81c4089cb67107a9339ee52cd2c44cde60b", + "testharness" + ], + "css/css-properties-values-api/registered-property-initial.html": [ + "fc0b90f23ea8c8dab20baa3fecdd7d60863527b6", + "testharness" + ], + "css/css-properties-values-api/var-reference-registered-properties-cycles.html": [ + "bc061780caa0085fca5b003c1aed68c7b162eabd", + "testharness" + ], + "css/css-properties-values-api/var-reference-registered-properties.html": [ + "988badd19fd1880446db9827e3d96cb4961732a0", + "testharness" + ], "css/css-pseudo/first-letter-001-ref.html": [ "f53ee70c3b61a9f812a9a44afb1364040563f473", "support" @@ -302898,7 +302977,7 @@ "support" ], "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html": [ - "9d855c711332b344078fc89bac6ed67091fa1ddd", + "e2d56515f3580649fc9cc8188b39056beb030036", "testharness" ], "css/css-typed-om/stylevalue-subclasses/numeric-objects/cssnumericvalue-multiply-two-types.tentative.html": [ @@ -313205,12 +313284,8 @@ "8c62d1e6b5791b68240551c0c9cd115f4d16a892", "reftest" ], - "css/cssom/medialist-interfaces-001-expected.txt": [ - "0a6f54e6927a8ce27b16585062dc85b7df8ac18b", - "support" - ], "css/cssom/medialist-interfaces-001.html": [ - "32d486ecdd41418e734be028c150b0183b8d3316", + "bae698d83d94e35d31750e0690e13c1ab5334379", "testharness" ], "css/cssom/medialist-interfaces-002-expected.txt": [ @@ -313225,12 +313300,8 @@ "42c6fb48a67af381e09995e27dcd8795557345dd", "testharness" ], - "css/cssom/medialist-interfaces-004-expected.txt": [ - "b9cd4da24d32acb31671e945c881e9f93a24c62a", - "support" - ], "css/cssom/medialist-interfaces-004.html": [ - "9558544a6785ac732150b8a50bedbaf3615fa890", + "a8a6a1b9966526de2d846baf6176880353f84e1a", "testharness" ], "css/cssom/overflow-serialization.html": [ @@ -372126,11 +372197,11 @@ "support" ], "web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt": [ - "480bb8f3b0ff1938666dd967be9aa1b649c7b2e0", + "e589be60818899c3248557f4329439f06650fdb9", "support" ], "web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html": [ - "a7da92b9624750eccb9dce1d32e522fdbb65176f", + "aa5f258132490ade2dbd9485c85f749cbab293a5", "testharness" ], "web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt": [
diff --git a/third_party/WebKit/LayoutTests/external/wpt/client-hints/OWNERS b/third_party/WebKit/LayoutTests/external/wpt/client-hints/OWNERS new file mode 100644 index 0000000..5cb08fb --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/client-hints/OWNERS
@@ -0,0 +1,2 @@ +# TEAM: loading-dev@chromium.org +# COMPONENT: Blink>Loader
diff --git a/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html b/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html new file mode 100644 index 0000000..c0f0581 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html
@@ -0,0 +1,30 @@ +<html> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> + +// If the response for the HTML file contains "Accept-CH: device-memory" in +// the response headers, then the browser should attach device-memory client +// hint in the HTTP request headers. Test this functionality by fetching an +// XHR from this page. The response headers for this page include +// "Accept-CH: device-memory". +// +// echo_device_memory_header_received.py includes "device-memory-received" in +// the response headers only if the request included "device-memory" in the +// headers. + + promise_test(t => { + return fetch("/client-hints/echo_device_memory_header_received.py").then(r => { + assert_equals(r.status, 200) + // Verify that the browser included "device-memory" in the headers when + // fetching the XHR. + assert_true(r.headers.has("device-memory-received")); + }); +}, "Accept-CH header test"); + +</script> + +</body> +</html>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html.headers b/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html.headers new file mode 100644 index 0000000..401e1af --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/client-hints/accept_ch.https.html.headers
@@ -0,0 +1 @@ +Accept-CH: device-memory \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/external/wpt/client-hints/echo_device_memory_header_received.py b/third_party/WebKit/LayoutTests/external/wpt/client-hints/echo_device_memory_header_received.py new file mode 100644 index 0000000..0ab4368 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/client-hints/echo_device_memory_header_received.py
@@ -0,0 +1,8 @@ +def main(request, response): + """ + Simple handler that sets a response header based on if device-memory + request header was received or not. + """ + + if "device-memory" in request.headers: + response.headers.set("device-memory-received", "true") \ No newline at end of file
diff --git a/third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing-expected.txt similarity index 98% rename from third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing-expected.txt rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing-expected.txt index 56dff41..beae57d 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing-expected.txt +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing-expected.txt
@@ -1,4 +1,5 @@ This is a testharness.js-based test. +Found 121 tests; 120 PASS, 1 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS syntax:'*', initialValue:'a' is valid PASS syntax:' * ', initialValue:'b' is valid PASS syntax:'<length>', initialValue:'2px' is valid
diff --git a/third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing.html similarity index 94% rename from third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing.html index 127bef3..500add40e 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/register-property-syntax-parsing.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property-syntax-parsing.html
@@ -1,6 +1,8 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" /> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script> test_count = 0;
diff --git a/third_party/WebKit/LayoutTests/custom-properties/register-property.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property.html similarity index 89% rename from third_party/WebKit/LayoutTests/custom-properties/register-property.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property.html index 5c8b45b9..597247c 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/register-property.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/register-property.html
@@ -1,6 +1,7 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#register-a-custom-property" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script> // Tests for error checking during property registration
diff --git a/third_party/WebKit/LayoutTests/custom-properties/registered-properties-inheritance.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-properties-inheritance.html similarity index 87% rename from third_party/WebKit/LayoutTests/custom-properties/registered-properties-inheritance.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-properties-inheritance.html index 29c0714..17074a6 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/registered-properties-inheritance.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-properties-inheritance.html
@@ -1,6 +1,8 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-propertydescriptor-inherits" /> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#register-a-custom-property" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> #outer { --inherited-length-1: 10px;
diff --git a/third_party/WebKit/LayoutTests/custom-properties/registered-property-computation.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-computation.html similarity index 94% rename from third_party/WebKit/LayoutTests/custom-properties/registered-property-computation.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-computation.html index d860385..8f635e9 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/registered-property-computation.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-computation.html
@@ -1,6 +1,7 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#calculation-of-computed-values" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> #divWithFontSizeSet, #parentDiv {
diff --git a/third_party/WebKit/LayoutTests/custom-properties/registered-property-cssom.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-cssom.html similarity index 93% rename from third_party/WebKit/LayoutTests/custom-properties/registered-property-cssom.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-cssom.html index de03c531..9dc9d7e 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/registered-property-cssom.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-cssom.html
@@ -1,6 +1,7 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> #inner {
diff --git a/third_party/WebKit/LayoutTests/custom-properties/registered-property-initial.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-initial.html similarity index 83% rename from third_party/WebKit/LayoutTests/custom-properties/registered-property-initial.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-initial.html index dfc338a..22ea3c4 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/registered-property-initial.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/registered-property-initial.html
@@ -1,6 +1,8 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-propertydescriptor-initialvalue" /> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#register-a-custom-property" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> #target { background: var(--inherited-color);
diff --git a/third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties-cycles.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties-cycles.html similarity index 96% rename from third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties-cycles.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties-cycles.html index 2e5039f..fdf8eaa 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties-cycles.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties-cycles.html
@@ -1,6 +1,7 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> #test1 {
diff --git a/third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties.html similarity index 93% rename from third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties.html rename to third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties.html index 6e08ff867..5dd1f0f 100644 --- a/third_party/WebKit/LayoutTests/custom-properties/var-reference-registered-properties.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-properties-values-api/var-reference-registered-properties.html
@@ -1,6 +1,7 @@ <!DOCTYPE HTML> -<script src="../resources/testharness.js"></script> -<script src="../resources/testharnessreport.js"></script> +<link rel="help" href="https://drafts.css-houdini.org/css-properties-values-api/#dom-css-registerproperty" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <style> div { --registered-length-1: 10px;
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html index 24769b3..e1278b20 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/stylevalue-subclasses/numeric-objects/cssUnitValue.tentative.html
@@ -9,8 +9,8 @@ 'use strict'; const gInvalidTestUnits = [ - { value: '', desc: 'an empty string' }, - { value: 'lemon', desc: 'an invalid unit' }, + { unit: '', desc: 'an empty string' }, + { unit: 'lemon', desc: 'an invalid unit' }, ]; for (const {unit, desc} of gInvalidTestUnits) {
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/scroll-padding.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/scroll-padding.html new file mode 100644 index 0000000..228cf1f --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-typed-om/the-stylepropertymap/properties/scroll-padding.html
@@ -0,0 +1,34 @@ +<!doctype html> +<meta charset="utf-8"> +<title>scroll-padding related properties</title> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-get"> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-set"> +<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#property-stle-value-normalization"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/testhelper.js"></script> +<script src="resources/testsuite.js"></script> +<body> +<div id="log"></div> +<script> +'use strict'; + +for (const suffix of ['top', 'left', 'right', 'bottom']) { + runPropertyTests('scroll-padding-' + suffix, [ + { syntax: '<percentage>' }, + { syntax: '<length>' }, + ]); +} + +for (const suffix of ['inline-start', 'block-start', 'inline-end', 'block-end']) { + runPropertyTests('scroll-padding-' + suffix, [ + { syntax: '<percentage>' }, + { syntax: '<length>' }, + ]); +} + +runUnsupportedPropertyTests('scroll-padding', + ['0%', '1px 2px', '3% 4px 5%', '6px 7% 8% 9px'] +); + +</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001-expected.txt deleted file mode 100644 index 8df65f2b..0000000 --- a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001-expected.txt +++ /dev/null
@@ -1,7 +0,0 @@ -This is a testharness.js-based test. -PASS mediatest_medialist_serialize_element -PASS mediatest_medialist_serialize_comma -PASS mediatest_medialist_serialize_empty -FAIL mediatest_medialist_serialize_lexicographical assert_equals: expected "all, print, screen" but got "all, screen, print" -Harness: the test ran to completion. -
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001.html b/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001.html index f5dbb56..19c661e1 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-001.html
@@ -57,7 +57,7 @@ assert_equals(mediaList.mediaText, "all, screen"); }, "mediatest_medialist_serialize_comma", - { help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serializing-media-queries"], + { help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serialize-a-media-query-list"], assert: ["To serialize a comma-separated list concatenate all items of the list in list order while separating them by \",\" (U+002C), followed by a space (U+0020)."] }); test(function() { @@ -75,11 +75,11 @@ mediaList.appendMedium('screen'); mediaList.appendMedium('print'); - assert_equals(mediaList.mediaText, "all, print, screen"); + assert_equals(mediaList.mediaText, "all, screen, print"); - }, "mediatest_medialist_serialize_lexicographical", - { help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serializing-media-queries"], - assert: ["Each media query in the list of media queries should be sorted in lexicographical order."] }); + }, "mediatest_medialist_serialize_order", + { help: ["http://www.w3.org/TR/cssom-1/#the-medialist-interface", "http://www.w3.org/TR/cssom-1/#serialize-a-media-query-list"], + assert: ["Each media query should be sorted in the same order as they appear in the list of media queries."] }); </script> </body>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004.html b/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004.html index 416addae..cf9befb8 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004.html +++ b/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004.html
@@ -55,7 +55,7 @@ assert_equals(media_list.length, 2); assert_equals(media_list.item(0), "screen"); assert_equals(media_list.item(1), "all"); - assert_equals(media_list.mediaText, "all, screen"); + assert_equals(media_list.mediaText, "screen, all"); }, "appendMedium_correctly_appends_medium_to_nonempty_MediaList", { assert: "MediaList.appendMedium correctly adds medium to a MediaList that already has a medium." });
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt index 507c24e..79fae9f 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt +++ b/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt
@@ -1,4 +1,7 @@ This is a testharness.js-based test. +FAIL Setting the current time of a pending animation to unresolved does not throw a TypeError Failed to set the 'currentTime' property on 'Animation': currentTime may not be changed from resolved to unresolved +PASS Setting the current time of a playing animation to unresolved throws a TypeError +PASS Setting the current time of a paused animation to unresolved throws a TypeError FAIL Setting the current time of a pausing animation applies a pending playback rate assert_true: expected true got undefined Harness: the test ran to completion.
diff --git a/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html b/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html index 04589ff..b1fc43e 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html +++ b/third_party/WebKit/LayoutTests/external/wpt/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html
@@ -11,6 +11,39 @@ <script> 'use strict'; +test(t => { + const anim = new Animation(); + assert_equals(anim.playState, 'idle'); + assert_equals(anim.currentTime, null); + + // This should not throw because the currentTime is already null. + anim.currentTime = null; +}, 'Setting the current time of a pending animation to unresolved does not' + + ' throw a TypeError'); + +promise_test(async t => { + const anim = createDiv(t).animate(null, 100 * MS_PER_SEC); + await anim.ready; + + assert_greater_than_equal(anim.currentTime, 0); + assert_throws({ name: 'TypeError' }, () => { + anim.currentTime = null; + }); +}, 'Setting the current time of a playing animation to unresolved throws a' + + ' TypeError'); + +promise_test(async t => { + const anim = createDiv(t).animate(null, 100 * MS_PER_SEC); + await anim.ready; + anim.pause(); + + assert_greater_than_equal(anim.currentTime, 0); + assert_throws({ name: 'TypeError' }, () => { + anim.currentTime = null; + }); +}, 'Setting the current time of a paused animation to unresolved throws a' + + ' TypeError'); + promise_test(async t => { const anim = createDiv(t).animate(null, 100 * MS_PER_SEC); await anim.ready;
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004-expected.txt b/third_party/WebKit/LayoutTests/platform/fuchsia/external/wpt/css/cssom/medialist-interfaces-004-expected.txt similarity index 100% rename from third_party/WebKit/LayoutTests/external/wpt/css/cssom/medialist-interfaces-004-expected.txt rename to third_party/WebKit/LayoutTests/platform/fuchsia/external/wpt/css/cssom/medialist-interfaces-004-expected.txt
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyBase.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyBase.cpp index 0ddd7dd..1af310d5 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyBase.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptPromisePropertyBase.cpp
@@ -40,9 +40,11 @@ v8::Local<v8::Object> wrapper = EnsureHolderWrapper(script_state); DCHECK(wrapper->CreationContext() == context); - v8::Local<v8::Value> cached_promise = PromiseSymbol().GetOrUndefined(wrapper); - if (!cached_promise->IsUndefined() && cached_promise->IsPromise()) + v8::Local<v8::Value> cached_promise; + if (PromiseSymbol().GetOrUndefined(wrapper).ToLocal(&cached_promise) && + cached_promise->IsPromise()) { return ScriptPromise(script_state, cached_promise); + } // Create and cache the Promise v8::Local<v8::Promise::Resolver> resolver; @@ -90,11 +92,12 @@ V8PrivateProperty::Symbol symbol = ResolverSymbol(); DCHECK(symbol.HasValue(wrapper)); - v8::Local<v8::Promise::Resolver> resolver = - symbol.GetOrUndefined(wrapper).As<v8::Promise::Resolver>(); - + v8::Local<v8::Value> resolver_value; + if (!symbol.GetOrUndefined(wrapper).ToLocal(&resolver_value)) + return; symbol.DeleteProperty(wrapper); - ResolveOrRejectInternal(resolver); + ResolveOrRejectInternal( + v8::Local<v8::Promise::Resolver>::Cast(resolver_value)); ++i; } }
diff --git a/third_party/WebKit/Source/bindings/core/v8/V0CustomElementConstructorBuilder.cpp b/third_party/WebKit/Source/bindings/core/v8/V0CustomElementConstructorBuilder.cpp index 4afcdda3..dbb4b5d 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V0CustomElementConstructorBuilder.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V0CustomElementConstructorBuilder.cpp
@@ -326,19 +326,36 @@ } v8::Local<v8::Object> data = v8::Local<v8::Object>::Cast(info.Data()); - Document* document = - V8Document::ToImpl(V8PrivateProperty::GetCustomElementDocument(isolate) - .GetOrEmpty(data) - .As<v8::Object>()); - TOSTRING_VOID( - V8StringResource<>, namespace_uri, - V8PrivateProperty::GetCustomElementNamespaceURI(isolate).GetOrEmpty( - data)); - TOSTRING_VOID( - V8StringResource<>, tag_name, - V8PrivateProperty::GetCustomElementTagName(isolate).GetOrEmpty(data)); - v8::Local<v8::Value> maybe_type = - V8PrivateProperty::GetCustomElementType(isolate).GetOrEmpty(data); + v8::Local<v8::Value> document_value; + if (!V8PrivateProperty::GetCustomElementDocument(isolate) + .GetOrUndefined(data) + .ToLocal(&document_value)) { + return; + } + Document* document = V8Document::ToImpl(document_value.As<v8::Object>()); + v8::Local<v8::Value> namespace_uri_value; + if (!V8PrivateProperty::GetCustomElementNamespaceURI(isolate) + .GetOrUndefined(data) + .ToLocal(&namespace_uri_value) || + namespace_uri_value->IsUndefined()) { + return; + } + TOSTRING_VOID(V8StringResource<>, namespace_uri, namespace_uri_value); + v8::Local<v8::Value> tag_name_value; + if (!V8PrivateProperty::GetCustomElementTagName(isolate) + .GetOrUndefined(data) + .ToLocal(&tag_name_value) || + tag_name_value->IsUndefined()) { + return; + } + TOSTRING_VOID(V8StringResource<>, tag_name, tag_name_value); + v8::Local<v8::Value> maybe_type; + if (!V8PrivateProperty::GetCustomElementType(isolate) + .GetOrUndefined(data) + .ToLocal(&maybe_type) || + maybe_type->IsUndefined()) { + return; + } TOSTRING_VOID(V8StringResource<>, type, maybe_type); ExceptionState exception_state(isolate, ExceptionState::kConstructionContext,
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8AbstractEventListener.cpp b/third_party/WebKit/Source/bindings/core/v8/V8AbstractEventListener.cpp index 20bd5b78..259020d6 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8AbstractEventListener.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8AbstractEventListener.cpp
@@ -136,7 +136,9 @@ V8PrivateProperty::Symbol event_symbol = V8PrivateProperty::GetGlobalEvent(GetIsolate()); // Save the old 'event' property so we can restore it later. - v8::Local<v8::Value> saved_event = event_symbol.GetOrUndefined(global); + v8::Local<v8::Value> saved_event; + if (!event_symbol.GetOrUndefined(global).ToLocal(&saved_event)) + return; try_catch.Reset(); // Expose the event object as |window.event|, except when the event's target
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ErrorHandler.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ErrorHandler.cpp index a57330d..2d755ba 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8ErrorHandler.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8ErrorHandler.cpp
@@ -68,8 +68,9 @@ if (!js_event->ToObject(context).ToLocal(&event_object)) return v8::Null(GetIsolate()); auto private_error = V8PrivateProperty::GetErrorEventError(GetIsolate()); - v8::Local<v8::Value> error = private_error.GetOrUndefined(event_object); - if (error->IsUndefined()) + v8::Local<v8::Value> error; + if (!private_error.GetOrUndefined(event_object).ToLocal(&error) || + error->IsUndefined()) error = v8::Null(GetIsolate()); v8::Local<v8::Value> parameters[5] = { @@ -120,10 +121,12 @@ DCHECK(wrapped_event->IsObject()); auto private_error = V8PrivateProperty::GetErrorEventError(script_state->GetIsolate()); - v8::Local<v8::Value> error = - private_error.GetOrUndefined(wrapped_event.As<v8::Object>()); - if (error->IsUndefined()) + v8::Local<v8::Value> error; + if (!private_error.GetOrUndefined(wrapped_event.As<v8::Object>()) + .ToLocal(&error) || + error->IsUndefined()) { return v8::Local<v8::Value>(); + } return error; }
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8EventListenerHelper.cpp b/third_party/WebKit/Source/bindings/core/v8/V8EventListenerHelper.cpp index 2505eb1..33568de 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8EventListenerHelper.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8EventListenerHelper.cpp
@@ -48,8 +48,9 @@ ListenerLookupType lookup, const ListenerFactory& listener_factory) { DCHECK(isolate->InContext()); - v8::Local<v8::Value> listener_value = - listener_property.GetOrUndefined(object); + v8::Local<v8::Value> listener_value; + if (!listener_property.GetOrUndefined(object).ToLocal(&listener_value)) + return nullptr; ListenerType* listener = listener_value->IsUndefined() ? nullptr
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp index 2e3cacb..04ae4948 100644 --- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp
@@ -259,10 +259,12 @@ // DOMException). DCHECK(exception->IsObject()); auto private_error = V8PrivateProperty::GetDOMExceptionError(isolate); - v8::Local<v8::Value> error = - private_error.GetOrUndefined(exception.As<v8::Object>()); - if (!error->IsUndefined()) + v8::Local<v8::Value> error; + if (private_error.GetOrUndefined(exception.As<v8::Object>()) + .ToLocal(&error) && + !error->IsUndefined()) { exception = error; + } } String error_message;
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8ErrorEventCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8ErrorEventCustom.cpp index 5df34b0..d1c260b 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8ErrorEventCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8ErrorEventCustom.cpp
@@ -40,9 +40,9 @@ v8::Isolate* isolate = info.GetIsolate(); auto private_error = V8PrivateProperty::GetErrorEventError(isolate); - v8::Local<v8::Value> cached_error = - private_error.GetOrUndefined(info.Holder()); - if (!cached_error->IsUndefined()) { + v8::Local<v8::Value> cached_error; + if (private_error.GetOrUndefined(info.Holder()).ToLocal(&cached_error) && + !cached_error->IsUndefined()) { V8SetReturnValue(info, cached_error); return; }
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp index 708435a..057fc8b 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8MessageEventCustom.cpp
@@ -47,9 +47,9 @@ v8::Isolate* isolate = info.GetIsolate(); auto private_cached_data = V8PrivateProperty::GetMessageEventCachedData(isolate); - v8::Local<v8::Value> cached_data = - private_cached_data.GetOrEmpty(info.Holder()); - if (!cached_data.IsEmpty()) { + v8::Local<v8::Value> cached_data; + if (private_cached_data.GetOrUndefined(info.Holder()).ToLocal(&cached_data) && + !cached_data->IsUndefined()) { V8SetReturnValue(info, cached_data); return; }
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp index 2779a3bf..2f7f6bc2 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp
@@ -59,9 +59,10 @@ ScriptState* script_state = ScriptState::Current(isolate); V8PrivateProperty::Symbol property_symbol = V8PrivateProperty::GetPopStateEventState(isolate); - v8::Local<v8::Value> result = property_symbol.GetOrEmpty(info.Holder()); + v8::Local<v8::Value> result; - if (!result.IsEmpty()) { + if (property_symbol.GetOrUndefined(info.Holder()).ToLocal(&result) && + !result->IsUndefined()) { V8SetReturnValue(info, result); return; } @@ -100,9 +101,10 @@ return; v8::Local<v8::Object> v8_history = v8_history_value.As<v8::Object>(); if (!history->stateChanged() && history_state.HasValue(v8_history)) { - V8SetReturnValue(info, - CacheState(script_state, info.Holder(), - history_state.GetOrUndefined(v8_history))); + v8::Local<v8::Value> value; + if (!history_state.GetOrUndefined(v8_history).ToLocal(&value)) + return; + V8SetReturnValue(info, CacheState(script_state, info.Holder(), value)); return; } result = event->SerializedState()->Deserialize(isolate);
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp index 3a594cf2..1d97721 100644 --- a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
@@ -112,8 +112,12 @@ return; } - v8::Local<v8::Value> js_event = - V8PrivateProperty::GetGlobalEvent(isolate).GetOrUndefined(info.Holder()); + v8::Local<v8::Value> js_event; + if (!V8PrivateProperty::GetGlobalEvent(isolate) + .GetOrUndefined(info.Holder()) + .ToLocal(&js_event)) { + return; + } // Track usage of window.event when the event's target is inside V0 shadow // tree.
diff --git a/third_party/WebKit/Source/bindings/modules/v8/custom/V8ExtendableMessageEventCustom.cpp b/third_party/WebKit/Source/bindings/modules/v8/custom/V8ExtendableMessageEventCustom.cpp index ba00f418..72dcc0a 100644 --- a/third_party/WebKit/Source/bindings/modules/v8/custom/V8ExtendableMessageEventCustom.cpp +++ b/third_party/WebKit/Source/bindings/modules/v8/custom/V8ExtendableMessageEventCustom.cpp
@@ -64,8 +64,9 @@ v8::Isolate* isolate = info.GetIsolate(); auto private_cached_data = V8PrivateProperty::GetMessageEventCachedData(isolate); - v8::Local<v8::Value> result = private_cached_data.GetOrEmpty(info.Holder()); - if (!result.IsEmpty()) { + v8::Local<v8::Value> result; + if (private_cached_data.GetOrUndefined(info.Holder()).ToLocal(&result) && + !result->IsUndefined()) { V8SetReturnValue(info, result); return; } @@ -77,9 +78,9 @@ options.message_ports = &ports; data = serialized_value->Deserialize(isolate, options); } else if (DOMWrapperWorld::Current(isolate).IsIsolatedWorld()) { - v8::Local<v8::Value> main_world_data = - private_cached_data.GetFromMainWorld(event); - if (!main_world_data.IsEmpty()) { + v8::Local<v8::Value> main_world_data; + if (private_cached_data.GetFromMainWorld(event).ToLocal(&main_world_data) && + !main_world_data->IsUndefined()) { // TODO(bashi): Enter the main world's ScriptState::Scope while // serializing the main world's value. event->SetSerializedData(
diff --git a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl index 33e93e9..dc4af1e 100644 --- a/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl +++ b/third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl
@@ -49,8 +49,8 @@ // X(SameObject, {{same_object_private_key}}) auto privateSameObject = V8PrivateProperty::GetSameObject{{same_object_private_key}}(info.GetIsolate()); { - v8::Local<v8::Value> v8Value = privateSameObject.GetOrEmpty(holder); - if (!v8Value.IsEmpty()) { + v8::Local<v8::Value> v8Value; + if (privateSameObject.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -79,8 +79,8 @@ V8PrivateProperty::GetSymbol(info.GetIsolate(), "{{cpp_class}}#{{attribute.name.capitalize()}}"); if (!static_cast<const {{cpp_class}}*>(impl)->{{attribute.cached_attribute_validation_method}}()) { - v8::Local<v8::Value> v8Value = propertySymbol.GetOrUndefined(holder); - if (!v8Value->IsUndefined()) { + v8::Local<v8::Value> v8Value; + if (propertySymbol.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; }
diff --git a/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl index 6acfe5e..374af84 100644 --- a/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl +++ b/third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl
@@ -769,9 +769,9 @@ // Set the prototype of named constructors to the regular constructor. auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info.GetIsolate()); v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext(); - v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructor); + v8::Local<v8::Value> privateValue; - if (privateValue.IsEmpty()) { + if (!privateProperty.GetOrUndefined(namedConstructor).ToLocal(&privateValue) || privateValue->IsUndefined()) { v8::Local<v8::Function> interface = perContextData->ConstructorForType(&{{v8_class}}::wrapperTypeInfo); v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8AtomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype).ToChecked();
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp index 362c185..33770087 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceConstructor.cpp
@@ -455,9 +455,9 @@ // Set the prototype of named constructors to the regular constructor. auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info.GetIsolate()); v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext(); - v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructor); + v8::Local<v8::Value> privateValue; - if (privateValue.IsEmpty()) { + if (!privateProperty.GetOrUndefined(namedConstructor).ToLocal(&privateValue) || privateValue->IsUndefined()) { v8::Local<v8::Function> interface = perContextData->ConstructorForType(&V8TestInterfaceConstructor::wrapperTypeInfo); v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8AtomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype).ToChecked();
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp index 0735657f..d76f00e 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceEventTarget.cpp
@@ -136,9 +136,9 @@ // Set the prototype of named constructors to the regular constructor. auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info.GetIsolate()); v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext(); - v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructor); + v8::Local<v8::Value> privateValue; - if (privateValue.IsEmpty()) { + if (!privateProperty.GetOrUndefined(namedConstructor).ToLocal(&privateValue) || privateValue->IsUndefined()) { v8::Local<v8::Function> interface = perContextData->ConstructorForType(&V8TestInterfaceEventTarget::wrapperTypeInfo); v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8AtomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype).ToChecked();
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp index aabd35a..7ce661b 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor.cpp
@@ -219,9 +219,9 @@ // Set the prototype of named constructors to the regular constructor. auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info.GetIsolate()); v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext(); - v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructor); + v8::Local<v8::Value> privateValue; - if (privateValue.IsEmpty()) { + if (!privateProperty.GetOrUndefined(namedConstructor).ToLocal(&privateValue) || privateValue->IsUndefined()) { v8::Local<v8::Function> interface = perContextData->ConstructorForType(&V8TestInterfaceNamedConstructor::wrapperTypeInfo); v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8AtomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype).ToChecked();
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp index 9796d98a..4416996 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestInterfaceNamedConstructor2.cpp
@@ -145,9 +145,9 @@ // Set the prototype of named constructors to the regular constructor. auto privateProperty = V8PrivateProperty::GetNamedConstructorInitialized(info.GetIsolate()); v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext(); - v8::Local<v8::Value> privateValue = privateProperty.GetOrEmpty(namedConstructor); + v8::Local<v8::Value> privateValue; - if (privateValue.IsEmpty()) { + if (!privateProperty.GetOrUndefined(namedConstructor).ToLocal(&privateValue) || privateValue->IsUndefined()) { v8::Local<v8::Function> interface = perContextData->ConstructorForType(&V8TestInterfaceNamedConstructor2::wrapperTypeInfo); v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, V8AtomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); bool result = namedConstructor->Set(currentContext, V8AtomicString(info.GetIsolate(), "prototype"), interfacePrototype).ToChecked();
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp index a5364d6a..3ade6e9 100644 --- a/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp +++ b/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
@@ -1949,8 +1949,8 @@ V8PrivateProperty::GetSymbol(info.GetIsolate(), "TestObject#Cachedattributeanyattribute"); if (!static_cast<const TestObject*>(impl)->isValueDirty()) { - v8::Local<v8::Value> v8Value = propertySymbol.GetOrUndefined(holder); - if (!v8Value->IsUndefined()) { + v8::Local<v8::Value> v8Value; + if (propertySymbol.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -1996,8 +1996,8 @@ V8PrivateProperty::GetSymbol(info.GetIsolate(), "TestObject#Cachedarrayattribute"); if (!static_cast<const TestObject*>(impl)->isFrozenArrayDirty()) { - v8::Local<v8::Value> v8Value = propertySymbol.GetOrUndefined(holder); - if (!v8Value->IsUndefined()) { + v8::Local<v8::Value> v8Value; + if (propertySymbol.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -2047,8 +2047,8 @@ V8PrivateProperty::GetSymbol(info.GetIsolate(), "TestObject#Cachedstringornoneattribute"); if (!static_cast<const TestObject*>(impl)->isStringDirty()) { - v8::Local<v8::Value> v8Value = propertySymbol.GetOrUndefined(holder); - if (!v8Value->IsUndefined()) { + v8::Local<v8::Value> v8Value; + if (propertySymbol.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -3058,8 +3058,8 @@ V8PrivateProperty::GetSymbol(info.GetIsolate(), "TestObject#Cachedattributeraisesexceptiongetteranyattribute"); if (!static_cast<const TestObject*>(impl)->isValueDirty()) { - v8::Local<v8::Value> v8Value = propertySymbol.GetOrUndefined(holder); - if (!v8Value->IsUndefined()) { + v8::Local<v8::Value> v8Value; + if (propertySymbol.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -4118,8 +4118,8 @@ // X(SameObject, TestObjectSaveSameObjectAttribute) auto privateSameObject = V8PrivateProperty::GetSameObjectTestObjectSaveSameObjectAttribute(info.GetIsolate()); { - v8::Local<v8::Value> v8Value = privateSameObject.GetOrEmpty(holder); - if (!v8Value.IsEmpty()) { + v8::Local<v8::Value> v8Value; + if (privateSameObject.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; } @@ -4155,8 +4155,8 @@ // X(SameObject, TestObjectStaticSaveSameObjectAttribute) auto privateSameObject = V8PrivateProperty::GetSameObjectTestObjectStaticSaveSameObjectAttribute(info.GetIsolate()); { - v8::Local<v8::Value> v8Value = privateSameObject.GetOrEmpty(holder); - if (!v8Value.IsEmpty()) { + v8::Local<v8::Value> v8Value; + if (privateSameObject.GetOrUndefined(holder).ToLocal(&v8Value) && !v8Value->IsUndefined()) { V8SetReturnValue(info, v8Value); return; }
diff --git a/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl b/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl index 4e6a520..e7481b8 100644 --- a/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl +++ b/third_party/WebKit/Source/build/scripts/core/css/templates/CSSOMTypes.cpp.tmpl
@@ -60,6 +60,18 @@ } +bool CSSOMTypes::IsPropertySupported(CSSPropertyID id) { + switch (id) { + case CSSPropertyVariable: + {% for property in properties if property.typedom_types %} + case {{property.property_id}}: + {% endfor %} + return true; + default: + return false; + } +} + bool CSSOMTypes::PropertyCanTake(CSSPropertyID id, const CSSStyleValue& value) { if (value.GetType() == CSSStyleValue::kKeywordType) { @@ -77,12 +89,14 @@ case CSSPropertyVariable: return value.GetType() == CSSStyleValue::kUnparsedType; {% for property in properties if property.typedom_types %} + {% if property.typedom_types != ['Keyword'] %} case {{property.property_id}}: return ( - {% for type in property.typedom_types %} + {% for type in property.typedom_types if type != 'Keyword' %} {{ "|| " if not loop.first }}IsCSSStyleValue{{type}}(value) {% endfor %} ); + {% endif %} {% endfor %} default: return false;
diff --git a/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py b/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py index 36c950b..cf9d1f4 100755 --- a/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py +++ b/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py
@@ -17,10 +17,10 @@ self._units = {entry['name']: entry['unit_type'] for entry in self.json5_file.name_dictionaries} self._outputs = { - 'CSSPrimitiveValueUnitTrie.cpp': self.generate_implementation + 'css_primitive_value_unit_trie.cc': self.generate_implementation } - @template_expander.use_jinja('templates/CSSPrimitiveValueUnitTrie.cpp.tmpl') + @template_expander.use_jinja('templates/css_primitive_value_unit_trie.cc.tmpl') def generate_implementation(self): return { 'input_files': self._input_files,
diff --git a/third_party/WebKit/Source/build/scripts/make_css_tokenizer_codepoints.py b/third_party/WebKit/Source/build/scripts/make_css_tokenizer_codepoints.py index ce9cb40b..54d4a37 100755 --- a/third_party/WebKit/Source/build/scripts/make_css_tokenizer_codepoints.py +++ b/third_party/WebKit/Source/build/scripts/make_css_tokenizer_codepoints.py
@@ -73,7 +73,7 @@ super(MakeCSSTokenizerCodePointsWriter, self).__init__(in_file_path) self._outputs = { - ('CSSTokenizerCodepoints.cpp'): self.generate, + ('css_tokenizer_codepoints.cc'): self.generate, } def generate(self):
diff --git a/third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/css_primitive_value_unit_trie.cc.tmpl similarity index 100% rename from third_party/WebKit/Source/build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl rename to third_party/WebKit/Source/build/scripts/templates/css_primitive_value_unit_trie.cc.tmpl
diff --git a/third_party/WebKit/Source/core/BUILD.gn b/third_party/WebKit/Source/core/BUILD.gn index c2c13c4..b19fe07 100644 --- a/third_party/WebKit/Source/core/BUILD.gn +++ b/third_party/WebKit/Source/core/BUILD.gn
@@ -1396,7 +1396,7 @@ script = "../build/scripts/make_css_tokenizer_codepoints.py" outputs = [ - "$blink_core_output_dir/CSSTokenizerCodepoints.cpp", + "$blink_core_output_dir/css_tokenizer_codepoints.cc", ] args = [ @@ -1418,13 +1418,13 @@ visibility = [ ":*" ] script = "../build/scripts/make_css_primitive_value_unit_trie.py" - input_file = "css/CSSPrimitiveValueUnits.json5" + input_file = "css/css_primitive_value_units.json5" inputs = make_trie_helpers_files + [ input_file, - "../build/scripts/templates/CSSPrimitiveValueUnitTrie.cpp.tmpl", + "../build/scripts/templates/css_primitive_value_unit_trie.cc.tmpl", ] outputs = [ - "$blink_core_output_dir/CSSPrimitiveValueUnitTrie.cpp", + "$blink_core_output_dir/css_primitive_value_unit_trie.cc", ] args = [
diff --git a/third_party/WebKit/Source/core/DEPS b/third_party/WebKit/Source/core/DEPS index 6fc12e3d..646ce0c 100644 --- a/third_party/WebKit/Source/core/DEPS +++ b/third_party/WebKit/Source/core/DEPS
@@ -48,8 +48,4 @@ "+core/frame/WebRemoteFrameImpl.h", "+gin" ], - # Allow LocalFrame.cpp to use WebLocalFrameImpl.h - "LocalFrame.cpp" : [ - "+core/frame/WebLocalFrameImpl.h", - ] }
diff --git a/third_party/WebKit/Source/core/OWNERS b/third_party/WebKit/Source/core/OWNERS index c528ab5d..a53ea7657 100644 --- a/third_party/WebKit/Source/core/OWNERS +++ b/third_party/WebKit/Source/core/OWNERS
@@ -30,6 +30,7 @@ futhark@chromium.org haraken@chromium.org hayato@chromium.org +hiroshige@chromium.org ikilpatrick@chromium.org inferno@chromium.org japhet@chromium.org
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp index 10ab095..1be8787 100644 --- a/third_party/WebKit/Source/core/animation/Animation.cpp +++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -30,6 +30,9 @@ #include "core/animation/Animation.h" +#include <limits> +#include <memory> + #include "core/animation/AnimationTimeline.h" #include "core/animation/DocumentTimeline.h" #include "core/animation/KeyframeEffectReadOnly.h" @@ -51,7 +54,6 @@ #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/runtime_enabled_features.h" #include "platform/wtf/MathExtras.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/Platform.h" #include "public/platform/TaskType.h" #include "public/platform/WebCompositorSupport.h" @@ -164,9 +166,22 @@ (playback_rate_ > 0 && current_time >= EffectEnd()); } -void Animation::setCurrentTime(double new_current_time, bool is_null) { +void Animation::setCurrentTime(double new_current_time, + bool is_null, + ExceptionState& exception_state) { PlayStateUpdateScope update_scope(*this, kTimingUpdateOnDemand); + // Step 1. of the procedure to silently set the current time of an + // animation states that we abort if the new time is null. + if (is_null) { + // If the current time is resolved, then throw a TypeError. + if (!IsNull(CurrentTimeInternal())) { + exception_state.ThrowTypeError( + "currentTime may not be changed from resolved to unresolved"); + } + return; + } + if (PlayStateInternal() == kIdle) paused_ = true; @@ -328,7 +343,7 @@ if (failure_code.Ok()) { CreateCompositorAnimation(); StartAnimationOnCompositor(composited_element_ids); - compositor_state_ = WTF::WrapUnique(new CompositorState(*this)); + compositor_state_ = std::make_unique<CompositorState>(*this); } else { // failure_code.Ok() is equivalent of |will_composite| = true, so if the // |can_composite| is true here, then we know that it is a main thread @@ -455,6 +470,7 @@ } double Animation::CalculateCurrentTime() const { + // TODO(crbug.com/818196): By spec, this should be unresolved, not 0. if (IsNull(start_time_) || !timeline_) return 0; return (timeline_->EffectiveTime() - start_time_) * playback_rate_;
diff --git a/third_party/WebKit/Source/core/animation/Animation.h b/third_party/WebKit/Source/core/animation/Animation.h index 2613b37..c0f99ce 100644 --- a/third_party/WebKit/Source/core/animation/Animation.h +++ b/third_party/WebKit/Source/core/animation/Animation.h
@@ -112,7 +112,9 @@ double currentTime(bool& is_null); double currentTime(); - void setCurrentTime(double new_current_time, bool is_null); + void setCurrentTime(double new_current_time, + bool is_null, + ExceptionState& = ASSERT_NO_EXCEPTION); double CurrentTimeInternal() const; double UnlimitedCurrentTimeInternal() const;
diff --git a/third_party/WebKit/Source/core/animation/Animation.idl b/third_party/WebKit/Source/core/animation/Animation.idl index 0c309ca..87ed0c8 100644 --- a/third_party/WebKit/Source/core/animation/Animation.idl +++ b/third_party/WebKit/Source/core/animation/Animation.idl
@@ -43,7 +43,7 @@ [RuntimeEnabled=WebAnimationsAPI] attribute AnimationEffectReadOnly? effect; [RuntimeEnabled=WebAnimationsAPI] readonly attribute AnimationTimeline? timeline; [Measure] attribute double? startTime; - [Measure] attribute double? currentTime; + [Measure, RaisesException=Setter] attribute double? currentTime; [Measure] attribute double playbackRate; [Measure] readonly attribute AnimationPlayState playState; [Measure, RaisesException] void finish();
diff --git a/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp index 1ce393a7..af9f0bd 100644 --- a/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSBasicShapeInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSBasicShapeInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/BasicShapeInterpolationFunctions.h" #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" @@ -12,7 +15,6 @@ #include "core/style/BasicShapes.h" #include "core/style/ComputedStyle.h" #include "core/style/DataEquivalency.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -46,7 +48,7 @@ public: static std::unique_ptr<UnderlyingCompatibilityChecker> Create( scoped_refptr<NonInterpolableValue> underlying_non_interpolable_value) { - return WTF::WrapUnique(new UnderlyingCompatibilityChecker( + return base::WrapUnique(new UnderlyingCompatibilityChecker( std::move(underlying_non_interpolable_value))); } @@ -72,7 +74,7 @@ static std::unique_ptr<InheritedShapeChecker> Create( const CSSProperty& property, scoped_refptr<BasicShape> inherited_shape) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedShapeChecker(property, std::move(inherited_shape))); }
diff --git a/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp index 7e59961..d1a1b50 100644 --- a/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSBorderImageLengthBoxInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSBorderImageLengthBoxInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/animation/SideIndex.h" #include "core/css/CSSIdentifierValue.h" @@ -12,7 +15,6 @@ #include "core/css/resolver/StyleResolverState.h" #include "core/css_property_names.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -169,7 +171,7 @@ public: static std::unique_ptr<UnderlyingSideTypesChecker> Create( const SideTypes& underlying_side_types) { - return WTF::WrapUnique( + return base::WrapUnique( new UnderlyingSideTypesChecker(underlying_side_types)); } @@ -198,7 +200,7 @@ static std::unique_ptr<InheritedSideTypesChecker> Create( const CSSProperty& property, const SideTypes& inherited_side_types) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedSideTypesChecker(property, inherited_side_types)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp index da0e6d4..cd9495d 100644 --- a/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSClipInterpolationType.cpp
@@ -5,12 +5,14 @@ #include "core/animation/CSSClipInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" #include "core/css/CSSQuadValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -58,7 +60,7 @@ const ComputedStyle& parent_style) { Vector<Length> inherited_length_list; GetClipLengthList(parent_style, inherited_length_list); - return WTF::WrapUnique( + return base::WrapUnique( new InheritedClipChecker(std::move(inherited_length_list))); } @@ -118,7 +120,7 @@ static std::unique_ptr<UnderlyingAutosChecker> Create( const ClipAutos& underlying_autos) { - return WTF::WrapUnique(new UnderlyingAutosChecker(underlying_autos)); + return base::WrapUnique(new UnderlyingAutosChecker(underlying_autos)); } static ClipAutos GetUnderlyingAutos(const InterpolationValue& underlying) {
diff --git a/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp index 0bc5d24..ddbeae6 100644 --- a/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp
@@ -5,12 +5,14 @@ #include "core/animation/CSSColorInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/ColorPropertyFunctions.h" #include "core/css/CSSColorValue.h" #include "core/css/CSSIdentifierValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/layout/LayoutTheme.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -167,7 +169,7 @@ static std::unique_ptr<InheritedColorChecker> Create( const CSSProperty& property, const OptionalStyleColor& color) { - return WTF::WrapUnique(new InheritedColorChecker(property, color)); + return base::WrapUnique(new InheritedColorChecker(property, color)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp index fee7b17..80e7814 100644 --- a/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSFilterListInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/FilterInterpolationFunctions.h" #include "core/animation/ListInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" @@ -12,7 +15,6 @@ #include "core/css/resolver/StyleResolverState.h" #include "core/css_property_names.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -52,7 +54,7 @@ public: static std::unique_ptr<UnderlyingFilterListChecker> Create( scoped_refptr<NonInterpolableList> non_interpolable_list) { - return WTF::WrapUnique( + return base::WrapUnique( new UnderlyingFilterListChecker(std::move(non_interpolable_list))); } @@ -86,7 +88,7 @@ static std::unique_ptr<InheritedFilterListChecker> Create( const CSSProperty& property, const FilterOperations& filter_operations) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedFilterListChecker(property, filter_operations)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp index 26dac9a..713ecd71 100644 --- a/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFontSizeInterpolationType.cpp
@@ -5,13 +5,15 @@ #include "core/animation/CSSFontSizeInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "platform/LengthFunctions.h" #include "platform/fonts/FontDescription.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -20,7 +22,7 @@ class IsMonospaceChecker : public CSSInterpolationType::CSSConversionChecker { public: static std::unique_ptr<IsMonospaceChecker> Create(bool is_monospace) { - return WTF::WrapUnique(new IsMonospaceChecker(is_monospace)); + return base::WrapUnique(new IsMonospaceChecker(is_monospace)); } private: @@ -39,7 +41,7 @@ public: static std::unique_ptr<InheritedFontSizeChecker> Create( const FontDescription::Size& inherited_font_size) { - return WTF::WrapUnique(new InheritedFontSizeChecker(inherited_font_size)); + return base::WrapUnique(new InheritedFontSizeChecker(inherited_font_size)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp index 6aa72e29..00b0c64 100644 --- a/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFontVariationSettingsInterpolationType.cpp
@@ -4,6 +4,10 @@ #include "core/animation/CSSFontVariationSettingsInterpolationType.h" +#include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/css/CSSFontVariationValue.h" #include "core/css/CSSValueList.h" #include "core/style/ComputedStyle.h" @@ -56,7 +60,7 @@ static std::unique_ptr<UnderlyingTagsChecker> Create( const Vector<AtomicString>& tags) { - return WTF::WrapUnique(new UnderlyingTagsChecker(tags)); + return base::WrapUnique(new UnderlyingTagsChecker(tags)); } private: @@ -77,7 +81,8 @@ static std::unique_ptr<InheritedFontVariationSettingsChecker> Create( const FontVariationSettings* settings) { - return WTF::WrapUnique(new InheritedFontVariationSettingsChecker(settings)); + return base::WrapUnique( + new InheritedFontVariationSettingsChecker(settings)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSFontWeightInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSFontWeightInterpolationType.cpp index 40d2213..98afd515 100644 --- a/third_party/WebKit/Source/core/animation/CSSFontWeightInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSFontWeightInterpolationType.cpp
@@ -5,11 +5,12 @@ #include "core/animation/CSSFontWeightInterpolationType.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/css/CSSPrimitiveValueMappings.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "platform/wtf/MathExtras.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -18,7 +19,7 @@ public: static std::unique_ptr<InheritedFontWeightChecker> Create( FontSelectionValue font_weight) { - return WTF::WrapUnique(new InheritedFontWeightChecker(font_weight)); + return base::WrapUnique(new InheritedFontWeightChecker(font_weight)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSImageInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSImageInterpolationType.cpp index 8c7f4a1..d257003 100644 --- a/third_party/WebKit/Source/core/animation/CSSImageInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSImageInterpolationType.cpp
@@ -5,13 +5,14 @@ #include "core/animation/CSSImageInterpolationType.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/css/CSSCrossfadeValue.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/css_property_names.h" #include "core/style/ComputedStyle.h" #include "core/style/StyleImage.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -162,7 +163,7 @@ static std::unique_ptr<UnderlyingImageChecker> Create( const InterpolationValue& underlying) { - return WTF::WrapUnique(new UnderlyingImageChecker(underlying)); + return base::WrapUnique(new UnderlyingImageChecker(underlying)); } private: @@ -206,7 +207,7 @@ static std::unique_ptr<InheritedImageChecker> Create( const CSSProperty& property, StyleImage* inherited_image) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedImageChecker(property, inherited_image)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp index 840966d..22b306ee 100644 --- a/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSImageListInterpolationType.cpp
@@ -5,13 +5,15 @@ #include "core/animation/CSSImageListInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSImageInterpolationType.h" #include "core/animation/ImageListPropertyFunctions.h" #include "core/animation/ListInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -22,7 +24,7 @@ static std::unique_ptr<UnderlyingImageListChecker> Create( const InterpolationValue& underlying) { - return WTF::WrapUnique(new UnderlyingImageListChecker(underlying)); + return base::WrapUnique(new UnderlyingImageListChecker(underlying)); } private: @@ -75,7 +77,7 @@ static std::unique_ptr<InheritedImageListChecker> Create( const CSSProperty& property, const StyleImageList& inherited_image_list) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedImageListChecker(property, inherited_image_list)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp index e1a5ecef..f8f5b73 100644 --- a/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.cpp
@@ -5,12 +5,14 @@ #include "core/animation/CSSImageSliceInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSLengthInterpolationType.h" #include "core/animation/ImageSlicePropertyFunctions.h" #include "core/animation/SideIndex.h" #include "core/css/CSSBorderImageSliceValue.h" #include "core/css/resolver/StyleResolverState.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -82,7 +84,7 @@ public: static std::unique_ptr<UnderlyingSliceTypesChecker> Create( const SliceTypes& underlying_types) { - return WTF::WrapUnique(new UnderlyingSliceTypesChecker(underlying_types)); + return base::WrapUnique(new UnderlyingSliceTypesChecker(underlying_types)); } static SliceTypes GetUnderlyingSliceTypes( @@ -110,7 +112,7 @@ static std::unique_ptr<InheritedSliceTypesChecker> Create( const CSSProperty& property, const SliceTypes& inherited_types) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedSliceTypesChecker(property, inherited_types)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSInterpolationType.cpp index 9a32e9b..f2b719c 100644 --- a/third_party/WebKit/Source/core/animation/CSSInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSInterpolationEnvironment.h" #include "core/animation/StringKeyframe.h" #include "core/css/CSSCustomPropertyDeclaration.h" @@ -20,7 +23,6 @@ #include "core/style/ComputedStyle.h" #include "core/style/DataEquivalency.h" #include "core/style_property_shorthand.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -31,7 +33,7 @@ CSSPropertyID property, const CSSValue* variable_reference, const CSSValue* resolved_value) { - return WTF::WrapUnique(new ResolvedVariableChecker( + return base::WrapUnique(new ResolvedVariableChecker( property, variable_reference, resolved_value)); } @@ -67,7 +69,7 @@ bool is_inherited_property, const CSSValue* inherited_value, const CSSValue* initial_value) { - return WTF::WrapUnique(new InheritedCustomPropertyChecker( + return base::WrapUnique(new InheritedCustomPropertyChecker( property, is_inherited_property, inherited_value, initial_value)); } @@ -104,7 +106,7 @@ static std::unique_ptr<ResolvedRegisteredCustomPropertyChecker> Create( const CSSCustomPropertyDeclaration& declaration, scoped_refptr<CSSVariableData> resolved_tokens) { - return WTF::WrapUnique(new ResolvedRegisteredCustomPropertyChecker( + return base::WrapUnique(new ResolvedRegisteredCustomPropertyChecker( declaration, std::move(resolved_tokens))); }
diff --git a/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp index e5e866d..a73786af 100644 --- a/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSLengthInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSLengthInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/animation/LengthPropertyFunctions.h" #include "core/animation/css/CSSAnimatableValueFactory.h" @@ -14,7 +17,6 @@ #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "platform/LengthFunctions.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -37,7 +39,7 @@ static std::unique_ptr<InheritedLengthChecker> Create( const CSSProperty& property, const Length& length) { - return WTF::WrapUnique(new InheritedLengthChecker(property, length)); + return base::WrapUnique(new InheritedLengthChecker(property, length)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSLengthListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSLengthListInterpolationType.cpp index bb6ebd4b..8015287 100644 --- a/third_party/WebKit/Source/core/animation/CSSLengthListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSLengthListInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSLengthListInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/animation/LengthListPropertyFunctions.h" #include "core/animation/ListInterpolationFunctions.h" @@ -13,7 +16,6 @@ #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -70,7 +72,7 @@ static std::unique_ptr<InheritedLengthListChecker> Create( const CSSProperty& property, const Vector<Length>& inherited_length_list) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedLengthListChecker(property, inherited_length_list)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSNumberInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSNumberInterpolationType.cpp index a0955681..a27fbce 100644 --- a/third_party/WebKit/Source/core/animation/CSSNumberInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSNumberInterpolationType.cpp
@@ -5,11 +5,12 @@ #include "core/animation/CSSNumberInterpolationType.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/animation/NumberPropertyFunctions.h" #include "core/css/resolver/StyleBuilder.h" #include "core/css/resolver/StyleResolverState.h" #include "platform/wtf/Optional.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -19,7 +20,7 @@ static std::unique_ptr<InheritedNumberChecker> Create( const CSSProperty& property, Optional<double> number) { - return WTF::WrapUnique(new InheritedNumberChecker(property, number)); + return base::WrapUnique(new InheritedNumberChecker(property, number)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSOffsetRotateInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSOffsetRotateInterpolationType.cpp index e05e77d..9d1fefe 100644 --- a/third_party/WebKit/Source/core/animation/CSSOffsetRotateInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSOffsetRotateInterpolationType.cpp
@@ -5,10 +5,12 @@ #include "core/animation/CSSOffsetRotateInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/css/resolver/StyleBuilderConverter.h" #include "core/style/ComputedStyle.h" #include "core/style/StyleOffsetRotation.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -43,7 +45,7 @@ public: static std::unique_ptr<UnderlyingRotationTypeChecker> Create( OffsetRotationType underlying_rotation_type) { - return WTF::WrapUnique( + return base::WrapUnique( new UnderlyingRotationTypeChecker(underlying_rotation_type)); } @@ -66,7 +68,7 @@ public: static std::unique_ptr<InheritedOffsetRotationChecker> Create( StyleOffsetRotation inherited_rotation) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedOffsetRotationChecker(inherited_rotation)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp index b19972c8..a27a606 100644 --- a/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSPaintInterpolationType.cpp
@@ -5,12 +5,14 @@ #include "core/animation/CSSPaintInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSColorInterpolationType.h" #include "core/css/StyleColor.h" #include "core/css/resolver/StyleResolverState.h" #include "core/css_property_names.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -70,11 +72,11 @@ static std::unique_ptr<InheritedPaintChecker> Create( const CSSProperty& property, const StyleColor& color) { - return WTF::WrapUnique(new InheritedPaintChecker(property, color)); + return base::WrapUnique(new InheritedPaintChecker(property, color)); } static std::unique_ptr<InheritedPaintChecker> Create( const CSSProperty& property) { - return WTF::WrapUnique(new InheritedPaintChecker(property)); + return base::WrapUnique(new InheritedPaintChecker(property)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp index e707ff91..ad465d27 100644 --- a/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSPathInterpolationType.cpp
@@ -5,11 +5,13 @@ #include "core/animation/CSSPathInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/PathInterpolationFunctions.h" #include "core/css/CSSPathValue.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -95,7 +97,7 @@ static std::unique_ptr<InheritedPathChecker> Create( const CSSProperty& property, scoped_refptr<StylePath> style_path) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedPathChecker(property, std::move(style_path))); }
diff --git a/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp index b1bde5a..17ee391 100644 --- a/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSRayInterpolationType.cpp
@@ -4,11 +4,14 @@ #include "core/animation/CSSRayInterpolationType.h" +#include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/css/BasicShapeFunctions.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "core/style/StyleRay.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -71,7 +74,7 @@ : public CSSInterpolationType::CSSConversionChecker { public: static std::unique_ptr<UnderlyingRayModeChecker> Create(const RayMode& mode) { - return WTF::WrapUnique(new UnderlyingRayModeChecker(mode)); + return base::WrapUnique(new UnderlyingRayModeChecker(mode)); } bool IsValid(const StyleResolverState&, @@ -91,7 +94,7 @@ public: static std::unique_ptr<InheritedRayChecker> Create( scoped_refptr<StyleRay> style_ray) { - return WTF::WrapUnique(new InheritedRayChecker(std::move(style_ray))); + return base::WrapUnique(new InheritedRayChecker(std::move(style_ray))); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp index bfd7c51..50242f8 100644 --- a/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSRotateInterpolationType.cpp
@@ -5,11 +5,12 @@ #include "core/animation/CSSRotateInterpolationType.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/css/resolver/StyleBuilderConverter.h" #include "core/style/ComputedStyle.h" #include "platform/transforms/RotateTransformOperation.h" #include "platform/transforms/Rotation.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -156,7 +157,7 @@ public: static std::unique_ptr<InheritedRotationChecker> Create( const OptionalRotation& inherited_rotation) { - return WTF::WrapUnique(new InheritedRotationChecker(inherited_rotation)); + return base::WrapUnique(new InheritedRotationChecker(inherited_rotation)); } bool IsValid(const StyleResolverState& state,
diff --git a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp index 8934b030..6b8cc0a0a 100644 --- a/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSScaleInterpolationType.cpp
@@ -5,11 +5,13 @@ #include "core/animation/CSSScaleInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -67,7 +69,7 @@ : public CSSInterpolationType::CSSConversionChecker { public: static std::unique_ptr<InheritedScaleChecker> Create(const Scale& scale) { - return WTF::WrapUnique(new InheritedScaleChecker(scale)); + return base::WrapUnique(new InheritedScaleChecker(scale)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSShadowListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSShadowListInterpolationType.cpp index dca696a..bcab177 100644 --- a/third_party/WebKit/Source/core/animation/CSSShadowListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSShadowListInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSShadowListInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/ListInterpolationFunctions.h" #include "core/animation/ShadowInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" @@ -14,7 +17,6 @@ #include "core/css_property_names.h" #include "core/style/ComputedStyle.h" #include "core/style/ShadowList.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -68,7 +70,7 @@ static std::unique_ptr<InheritedShadowListChecker> Create( const CSSProperty& property, scoped_refptr<ShadowList> shadow_list) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedShadowListChecker(property, std::move(shadow_list))); }
diff --git a/third_party/WebKit/Source/core/animation/CSSSizeListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSSizeListInterpolationType.cpp index 2699981..1042c75 100644 --- a/third_party/WebKit/Source/core/animation/CSSSizeListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSSizeListInterpolationType.cpp
@@ -4,6 +4,10 @@ #include "core/animation/CSSSizeListInterpolationType.h" +#include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/ListInterpolationFunctions.h" #include "core/animation/SizeInterpolationFunctions.h" #include "core/animation/SizeListPropertyFunctions.h" @@ -20,7 +24,7 @@ static std::unique_ptr<UnderlyingSizeListChecker> Create( const NonInterpolableList& underlying_list) { - return WTF::WrapUnique(new UnderlyingSizeListChecker(underlying_list)); + return base::WrapUnique(new UnderlyingSizeListChecker(underlying_list)); } private: @@ -55,7 +59,7 @@ static std::unique_ptr<InheritedSizeListChecker> Create( const CSSProperty& property, const SizeList& inherited_size_list) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedSizeListChecker(property, inherited_size_list)); }
diff --git a/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp index d17e680..a3d604fd 100644 --- a/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTextIndentInterpolationType.cpp
@@ -5,13 +5,15 @@ #include "core/animation/CSSTextIndentInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/css/CSSIdentifierValue.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -75,7 +77,7 @@ public: static std::unique_ptr<UnderlyingIndentModeChecker> Create( const IndentMode& mode) { - return WTF::WrapUnique(new UnderlyingIndentModeChecker(mode)); + return base::WrapUnique(new UnderlyingIndentModeChecker(mode)); } bool IsValid(const StyleResolverState&, @@ -97,7 +99,7 @@ static std::unique_ptr<InheritedIndentChecker> Create( const Length& length, const IndentMode& mode) { - return WTF::WrapUnique(new InheritedIndentChecker(length, mode)); + return base::WrapUnique(new InheritedIndentChecker(length, mode)); } bool IsValid(const StyleResolverState& state,
diff --git a/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp index de2684b..8c4bd01 100644 --- a/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTransformInterpolationType.cpp
@@ -5,6 +5,9 @@ #include "core/animation/CSSTransformInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthUnitsChecker.h" #include "core/css/CSSFunctionValue.h" #include "core/css/CSSPrimitiveValue.h" @@ -14,7 +17,6 @@ #include "core/style/ComputedStyle.h" #include "platform/transforms/TransformOperations.h" #include "platform/transforms/TranslateTransformOperation.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -136,7 +138,7 @@ public: static std::unique_ptr<InheritedTransformChecker> Create( const TransformOperations& inherited_transform) { - return WTF::WrapUnique(new InheritedTransformChecker(inherited_transform)); + return base::WrapUnique(new InheritedTransformChecker(inherited_transform)); } bool IsValid(const StyleResolverState& state,
diff --git a/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp index 181120ce..e03c819 100644 --- a/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSTranslateInterpolationType.cpp
@@ -5,12 +5,14 @@ #include "core/animation/CSSTranslateInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/LengthInterpolationFunctions.h" #include "core/css/CSSValueList.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" #include "platform/transforms/TranslateTransformOperation.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -31,7 +33,7 @@ static std::unique_ptr<InheritedTranslateChecker> Create( scoped_refptr<TranslateTransformOperation> inherited_translate) { - return WTF::WrapUnique( + return base::WrapUnique( new InheritedTranslateChecker(std::move(inherited_translate))); }
diff --git a/third_party/WebKit/Source/core/animation/CSSVarCycleInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSVarCycleInterpolationType.cpp index 5180d533..191a333 100644 --- a/third_party/WebKit/Source/core/animation/CSSVarCycleInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSVarCycleInterpolationType.cpp
@@ -4,6 +4,10 @@ #include "core/animation/CSSVarCycleInterpolationType.h" +#include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSInterpolationEnvironment.h" #include "core/animation/StringKeyframe.h" #include "core/css/CSSCustomPropertyDeclaration.h" @@ -19,7 +23,7 @@ static std::unique_ptr<CycleChecker> Create( const CSSCustomPropertyDeclaration& declaration, bool cycle_detected) { - return WTF::WrapUnique(new CycleChecker(declaration, cycle_detected)); + return base::WrapUnique(new CycleChecker(declaration, cycle_detected)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CSSVisibilityInterpolationType.cpp b/third_party/WebKit/Source/core/animation/CSSVisibilityInterpolationType.cpp index 45fb4df7..b4bffbf 100644 --- a/third_party/WebKit/Source/core/animation/CSSVisibilityInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/CSSVisibilityInterpolationType.cpp
@@ -5,10 +5,11 @@ #include "core/animation/CSSVisibilityInterpolationType.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/css/CSSPrimitiveValueMappings.h" #include "core/css/resolver/StyleResolverState.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -57,7 +58,7 @@ static std::unique_ptr<UnderlyingVisibilityChecker> Create( EVisibility visibility) { - return WTF::WrapUnique(new UnderlyingVisibilityChecker(visibility)); + return base::WrapUnique(new UnderlyingVisibilityChecker(visibility)); } private: @@ -82,7 +83,7 @@ public: static std::unique_ptr<InheritedVisibilityChecker> Create( EVisibility visibility) { - return WTF::WrapUnique(new InheritedVisibilityChecker(visibility)); + return base::WrapUnique(new InheritedVisibilityChecker(visibility)); } private:
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp index 6109d341..8800b86 100644 --- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp +++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
@@ -30,7 +30,11 @@ #include "core/animation/CompositorAnimations.h" +#include <limits> #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "base/memory/scoped_refptr.h" #include "core/animation/Animation.h" #include "core/animation/DocumentTimeline.h" @@ -62,7 +66,6 @@ #include "platform/transforms/TransformOperations.h" #include "platform/transforms/TranslateTransformOperation.h" #include "platform/wtf/HashFunctions.h" -#include "platform/wtf/PtrUtil.h" #include "public/web/WebSettings.h" #include "testing/gtest/include/gtest/gtest.h" @@ -221,7 +224,7 @@ std::unique_ptr<StringKeyframeVector> CreateCompositableFloatKeyframeVector( Vector<double>& values) { std::unique_ptr<StringKeyframeVector> frames = - WTF::WrapUnique(new StringKeyframeVector); + base::WrapUnique(new StringKeyframeVector); for (size_t i = 0; i < values.size(); i++) { double offset = 1.0 / (values.size() - 1) * i; String value = String::Number(values[i]); @@ -234,7 +237,7 @@ std::unique_ptr<StringKeyframeVector> CreateCompositableTransformKeyframeVector(const Vector<String>& values) { std::unique_ptr<StringKeyframeVector> frames = - WTF::WrapUnique(new StringKeyframeVector); + base::WrapUnique(new StringKeyframeVector); for (size_t i = 0; i < values.size(); ++i) { double offset = 1.0f / (values.size() - 1) * i; frames->push_back(
diff --git a/third_party/WebKit/Source/core/animation/InterpolableValue.h b/third_party/WebKit/Source/core/animation/InterpolableValue.h index 570cd977..5242a4c 100644 --- a/third_party/WebKit/Source/core/animation/InterpolableValue.h +++ b/third_party/WebKit/Source/core/animation/InterpolableValue.h
@@ -6,11 +6,12 @@ #define InterpolableValue_h #include <memory> +#include <utility> +#include "base/memory/ptr_util.h" #include "core/CoreExport.h" #include "core/animation/animatable/AnimatableValue.h" #include "platform/heap/Handle.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Vector.h" namespace blink { @@ -53,7 +54,7 @@ class CORE_EXPORT InterpolableNumber final : public InterpolableValue { public: static std::unique_ptr<InterpolableNumber> Create(double value) { - return WTF::WrapUnique(new InterpolableNumber(value)); + return base::WrapUnique(new InterpolableNumber(value)); } bool IsNumber() const final { return true; } @@ -90,11 +91,11 @@ static std::unique_ptr<InterpolableList> Create( const InterpolableList& other) { - return WTF::WrapUnique(new InterpolableList(other)); + return base::WrapUnique(new InterpolableList(other)); } static std::unique_ptr<InterpolableList> Create(size_t size) { - return WTF::WrapUnique(new InterpolableList(size)); + return base::WrapUnique(new InterpolableList(size)); } bool IsList() const final { return true; }
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp index 3d435fb..43f63fdf 100644 --- a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp +++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
@@ -30,6 +30,9 @@ #include "core/animation/KeyframeEffectModel.h" +#include <limits> +#include <utility> + #include "core/animation/AnimationEffectReadOnly.h" #include "core/animation/CompositorAnimations.h" #include "core/animation/css/CSSAnimatableValueFactory.h" @@ -40,7 +43,6 @@ #include "platform/animation/AnimationUtilities.h" #include "platform/geometry/FloatBox.h" #include "platform/transforms/TransformationMatrix.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/text/StringHash.h" namespace blink { @@ -222,7 +224,7 @@ if (keyframe_groups_) return; - keyframe_groups_ = WTF::WrapUnique(new KeyframeGroupMap); + keyframe_groups_ = std::make_unique<KeyframeGroupMap>(); scoped_refptr<TimingFunction> zero_offset_easing = default_keyframe_easing_; Vector<double> computed_offsets = GetComputedOffsets(keyframes_); DCHECK_EQ(computed_offsets.size(), keyframes_.size()); @@ -239,7 +241,7 @@ if (group_iter == keyframe_groups_->end()) { group = keyframe_groups_ ->insert(property, - WTF::WrapUnique(new PropertySpecificKeyframeGroup)) + std::make_unique<PropertySpecificKeyframeGroup>()) .stored_value->value.get(); } else { group = group_iter->value.get();
diff --git a/third_party/WebKit/Source/core/animation/LengthUnitsChecker.h b/third_party/WebKit/Source/core/animation/LengthUnitsChecker.h index 65e0a05a..daea182 100644 --- a/third_party/WebKit/Source/core/animation/LengthUnitsChecker.h +++ b/third_party/WebKit/Source/core/animation/LengthUnitsChecker.h
@@ -6,10 +6,12 @@ #define LengthUnitsChecker_h #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/CSSInterpolationType.h" #include "core/css/CSSPrimitiveValue.h" #include "core/css/resolver/StyleResolverState.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -30,7 +32,7 @@ } if (!create) return nullptr; - return WTF::WrapUnique( + return base::WrapUnique( new LengthUnitsChecker(std::move(length_array), last_index)); }
diff --git a/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp index 5c55941..a224fae 100644 --- a/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp +++ b/third_party/WebKit/Source/core/animation/PathInterpolationFunctions.cpp
@@ -5,6 +5,9 @@ #include "core/animation/PathInterpolationFunctions.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/InterpolatedSVGPathSource.h" #include "core/animation/InterpolationEnvironment.h" #include "core/animation/SVGPathSegInterpolationFunctions.h" @@ -13,7 +16,6 @@ #include "core/svg/SVGPathByteStreamBuilder.h" #include "core/svg/SVGPathByteStreamSource.h" #include "core/svg/SVGPathParser.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -99,7 +101,7 @@ static std::unique_ptr<UnderlyingPathSegTypesChecker> Create( const InterpolationValue& underlying) { - return WTF::WrapUnique( + return base::WrapUnique( new UnderlyingPathSegTypesChecker(GetPathSegTypes(underlying))); }
diff --git a/third_party/WebKit/Source/core/animation/PrimitiveInterpolation.h b/third_party/WebKit/Source/core/animation/PrimitiveInterpolation.h index fdb7d29..e97e8c107 100644 --- a/third_party/WebKit/Source/core/animation/PrimitiveInterpolation.h +++ b/third_party/WebKit/Source/core/animation/PrimitiveInterpolation.h
@@ -6,13 +6,15 @@ #define PrimitiveInterpolation_h #include <cmath> +#include <limits> #include <memory> +#include <utility> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/animation/TypedInterpolationValue.h" #include "platform/animation/AnimationUtilities.h" #include "platform/heap/Handle.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -49,7 +51,7 @@ std::unique_ptr<InterpolableValue> start, std::unique_ptr<InterpolableValue> end, scoped_refptr<NonInterpolableValue> non_interpolable_value) { - return WTF::WrapUnique(new PairwisePrimitiveInterpolation( + return base::WrapUnique(new PairwisePrimitiveInterpolation( type, std::move(start), std::move(end), std::move(non_interpolable_value))); } @@ -106,7 +108,7 @@ static std::unique_ptr<FlipPrimitiveInterpolation> Create( std::unique_ptr<TypedInterpolationValue> start, std::unique_ptr<TypedInterpolationValue> end) { - return WTF::WrapUnique( + return base::WrapUnique( new FlipPrimitiveInterpolation(std::move(start), std::move(end))); }
diff --git a/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp b/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp index 0a91b6e..7686eb5 100644 --- a/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp +++ b/third_party/WebKit/Source/core/animation/SVGTransformListInterpolationType.cpp
@@ -5,13 +5,15 @@ #include "core/animation/SVGTransformListInterpolationType.h" #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/InterpolableValue.h" #include "core/animation/NonInterpolableValue.h" #include "core/animation/SVGInterpolationEnvironment.h" #include "core/animation/StringKeyframe.h" #include "core/svg/SVGTransform.h" #include "core/svg/SVGTransformList.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -175,7 +177,7 @@ public: static std::unique_ptr<SVGTransformListChecker> Create( const InterpolationValue& underlying) { - return WTF::WrapUnique(new SVGTransformListChecker(underlying)); + return base::WrapUnique(new SVGTransformListChecker(underlying)); } bool IsValid(const InterpolationEnvironment&,
diff --git a/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h b/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h index 67ba7fe..f4f14cd3 100644 --- a/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h +++ b/third_party/WebKit/Source/core/animation/TypedInterpolationValue.h
@@ -6,8 +6,10 @@ #define TypedInterpolationValue_h #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/animation/InterpolationValue.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -21,7 +23,7 @@ const InterpolationType& type, std::unique_ptr<InterpolableValue> interpolable_value, scoped_refptr<NonInterpolableValue> non_interpolable_value = nullptr) { - return WTF::WrapUnique( + return base::WrapUnique( new TypedInterpolationValue(type, std::move(interpolable_value), std::move(non_interpolable_value))); }
diff --git a/third_party/WebKit/Source/core/animation/UnderlyingLengthChecker.h b/third_party/WebKit/Source/core/animation/UnderlyingLengthChecker.h index 4058a457..0e480cc 100644 --- a/third_party/WebKit/Source/core/animation/UnderlyingLengthChecker.h +++ b/third_party/WebKit/Source/core/animation/UnderlyingLengthChecker.h
@@ -6,9 +6,10 @@ #define UnderlyingLengthChecker_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/animation/InterpolableValue.h" #include "core/animation/InterpolationType.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -16,7 +17,7 @@ public: static std::unique_ptr<UnderlyingLengthChecker> Create( size_t underlying_length) { - return WTF::WrapUnique(new UnderlyingLengthChecker(underlying_length)); + return base::WrapUnique(new UnderlyingLengthChecker(underlying_length)); } static size_t GetUnderlyingLength(const InterpolationValue& underlying) {
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimationData.h b/third_party/WebKit/Source/core/animation/css/CSSAnimationData.h index ebd0ba6..9154cff 100644 --- a/third_party/WebKit/Source/core/animation/css/CSSAnimationData.h +++ b/third_party/WebKit/Source/core/animation/css/CSSAnimationData.h
@@ -6,21 +6,22 @@ #define CSSAnimationData_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/animation/Timing.h" #include "core/animation/css/CSSTimingData.h" #include "core/style/ComputedStyleConstants.h" -#include "platform/wtf/PtrUtil.h" namespace blink { class CSSAnimationData final : public CSSTimingData { public: static std::unique_ptr<CSSAnimationData> Create() { - return WTF::WrapUnique(new CSSAnimationData); + return base::WrapUnique(new CSSAnimationData); } std::unique_ptr<CSSAnimationData> Clone() const { - return WTF::WrapUnique(new CSSAnimationData(*this)); + return base::WrapUnique(new CSSAnimationData(*this)); } bool AnimationsMatchForStyleRecalc(const CSSAnimationData& other) const;
diff --git a/third_party/WebKit/Source/core/animation/css/CSSTransitionData.h b/third_party/WebKit/Source/core/animation/css/CSSTransitionData.h index 9c2687b..8891135 100644 --- a/third_party/WebKit/Source/core/animation/css/CSSTransitionData.h +++ b/third_party/WebKit/Source/core/animation/css/CSSTransitionData.h
@@ -6,9 +6,10 @@ #define CSSTransitionData_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/animation/css/CSSTimingData.h" #include "core/css_property_names.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Vector.h" namespace blink { @@ -51,11 +52,11 @@ }; static std::unique_ptr<CSSTransitionData> Create() { - return WTF::WrapUnique(new CSSTransitionData); + return base::WrapUnique(new CSSTransitionData); } std::unique_ptr<CSSTransitionData> Clone() { - return WTF::WrapUnique(new CSSTransitionData(*this)); + return base::WrapUnique(new CSSTransitionData(*this)); } bool TransitionsMatchForStyleRecalc(const CSSTransitionData& other) const;
diff --git a/third_party/WebKit/Source/core/css/CSSProperties.json5 b/third_party/WebKit/Source/core/css/CSSProperties.json5 index 43541bf..72f5c67 100644 --- a/third_party/WebKit/Source/core/css/CSSProperties.json5 +++ b/third_party/WebKit/Source/core/css/CSSProperties.json5
@@ -213,10 +213,8 @@ }, // Flags which go into CSSOMTypes: - // - typedom_types: ["Type", "OtherType"] + // - typedom_types: ["Keyword", "Type", "OtherType"] // The property can take types specified in typedom_types for CSS Typed OM. - // Keyword does not need to be specified as every property can take - // keywords. // - separator // The property supports a list of values, and when there is more than one, // it is separated with this character. @@ -227,6 +225,7 @@ "Angle", "Flex", "Frequency", + "Keyword", "Length", "Number", "Percentage", @@ -361,6 +360,7 @@ name: "animation-direction", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], keywords: ["normal", "reverse", "alternate", "alternate-reverse"], + typedom_types: ["Keyword"], separator: ",", custom_apply_functions_all: true, priority: "Animation", @@ -368,7 +368,6 @@ { name: "animation-duration", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], - typedom_types: ["Time"], separator: ",", custom_apply_functions_all: true, priority: "Animation", @@ -414,7 +413,7 @@ { name: "transition-duration", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], - typedom_types: ["Time"], + typedom_types: ["Keyword", "Time"], separator: ",", custom_apply_functions_all: true, priority: "Animation", @@ -448,7 +447,8 @@ computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, priority: "High", - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "direction", @@ -458,6 +458,7 @@ field_template: "keyword", include_paths: ["platform/text/TextDirection.h"], keywords: ["ltr", "rtl"], + typedom_types: ["Keyword"], default_value: "ltr", type_name: "TextDirection", custom_apply_functions_value: true, @@ -524,7 +525,8 @@ name_for_methods: "Style", converter: "ConvertFontStyle", priority: "High", - keywords: ["normal", "italic", "oblique"] + keywords: ["normal", "italic", "oblique"], + typedom_types: ["Keyword"], }, { name: "font-variant-ligatures", @@ -574,7 +576,7 @@ converter: "ConvertFontWeight", priority: "High", keywords: ["normal", "bold", "bolder", "lighter"], - typedom_types: ["Number"] + typedom_types: ["Keyword", "Number"] }, { name: "font-feature-settings", @@ -728,6 +730,7 @@ field_group: "*", field_template: "keyword", keywords: ["visible", "hidden"], + typedom_types: ["Keyword"], default_value: "visible", }, { @@ -756,14 +759,15 @@ type_name: "StyleColor", computed_style_custom_functions: ["getter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "background-image", property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], interpolable: true, keywords: ["auto", "none"], - typedom_types: ["Image"], + typedom_types: ["Keyword", "Image"], separator: " ", custom_apply_functions_all: true, }, @@ -817,7 +821,8 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "border-bottom-left-radius", @@ -850,6 +855,7 @@ "none", "hidden", "inset", "groove", "outset", "ridge", "dotted", "dashed", "solid", "double" ], + typedom_types: ["Keyword"], default_value: "none", type_name: "EBorderStyle", }, @@ -862,7 +868,7 @@ include_paths: ["platform/LayoutUnit.h"], keywords: ["thin", "medium", "thick"], default_value: "LayoutUnit(3)", - typedom_types: ["Length"], + typedom_types: ["Keyword", "Length"], type_name: "LayoutUnit", computed_style_custom_functions: ["getter", "setter"], converter: "ConvertBorderWidth", @@ -874,6 +880,7 @@ inherited: true, field_template: "keyword", keywords: ["separate", "collapse"], + typedom_types: ["Keyword"], default_value: "separate", }, { @@ -898,7 +905,7 @@ property_methods: ["ParseSingleValue", "CSSValueFromComputedStyleInternal"], interpolable: true, keywords: ["none"], - typedom_types: ["Image"], + typedom_types: ["Keyword", "Image"], custom_apply_functions_value: true, }, { @@ -918,7 +925,8 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "border-left-style", @@ -929,6 +937,7 @@ "none", "hidden", "inset", "groove", "outset", "ridge", "dotted", "dashed", "solid", "double" ], + typedom_types: ["Keyword"], default_value: "none", type_name: "EBorderStyle", }, @@ -941,7 +950,7 @@ include_paths: ["platform/LayoutUnit.h"], keywords: ["thin", "medium", "thick"], default_value: "LayoutUnit(3)", - typedom_types: ["Length"], + typedom_types: ["Keyword", "Length"], type_name: "LayoutUnit", computed_style_custom_functions: ["getter", "setter"], converter: "ConvertBorderWidth", @@ -957,7 +966,8 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "border-right-style", @@ -968,6 +978,7 @@ "none", "hidden", "inset", "groove", "outset", "ridge", "dotted", "dashed", "solid", "double" ], + typedom_types: ["Keyword"], default_value: "none", type_name: "EBorderStyle", }, @@ -980,7 +991,7 @@ include_paths: ["platform/LayoutUnit.h"], keywords: ["thin", "medium", "thick"], default_value: "LayoutUnit(3)", - typedom_types: ["Length"], + typedom_types: ["Keyword", "Length"], type_name: "LayoutUnit", computed_style_custom_functions: ["getter", "setter"], converter: "ConvertBorderWidth", @@ -996,7 +1007,8 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "border-top-left-radius", @@ -1029,6 +1041,7 @@ "none", "hidden", "inset", "groove", "outset", "ridge", "dotted", "dashed", "solid", "double" ], + typedom_types: ["Keyword"], default_value: "none", type_name: "EBorderStyle", }, @@ -1041,7 +1054,7 @@ include_paths: ["platform/LayoutUnit.h"], keywords: ["thin", "medium", "thick"], default_value: "LayoutUnit(3)", - typedom_types: ["Length"], + typedom_types: ["Keyword", "Length"], type_name: "LayoutUnit", computed_style_custom_functions: ["getter", "setter"], converter: "ConvertBorderWidth", @@ -1055,7 +1068,7 @@ field_template: "<length>", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -1076,6 +1089,7 @@ field_group: "box", field_template: "keyword", keywords: ["content-box", "border-box"], + typedom_types: ["Keyword"], default_value: "content-box", }, { @@ -1139,13 +1153,15 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["auto", "currentcolor"] + keywords: ["auto", "currentcolor"], + typedom_types: ["Keyword"], }, { name: "clear", property_methods: ["CSSValueFromComputedStyleInternal"], field_template: "keyword", keywords: ["none", "left", "right", "both"], + typedom_types: ["Keyword"], default_value: "none", }, { @@ -1227,7 +1243,6 @@ include_paths: ["core/style/ContentData.h"], wrapper_pointer_name: "Persistent", default_value: "nullptr", - typedom_types: ["Image"], separator: ",", type_name: "ContentData", computed_style_custom_functions: ["getter", "setter"], @@ -1291,6 +1306,7 @@ "table-caption", "-webkit-box", "-webkit-inline-box", "flex", "inline-flex", "grid", "inline-grid", "contents", "flow-root", "none" ], + typedom_types: ["Keyword"], custom_apply_functions_all: true, }, { @@ -1306,6 +1322,7 @@ inherited: true, field_template: "keyword", keywords: ["show", "hide"], + typedom_types: ["Keyword"], default_value: "show", }, { @@ -1394,6 +1411,7 @@ property_methods: ["CSSValueFromComputedStyleInternal"], field_template: "keyword", keywords: ["none", "left", "right"], + typedom_types: ["Keyword"], default_value: "none", name_for_methods: "Floating", type_name: "EFloat", @@ -1520,7 +1538,7 @@ field_template: "<length>", keywords: ["auto", "fit-content", "min-content", "max-content"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthSizing", }, { @@ -1604,7 +1622,7 @@ field_template: "<length>", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -1633,7 +1651,7 @@ computed_style_custom_functions: ["getter"], converter: "ConvertLineHeight", keywords: ["normal"], - typedom_types: ["Length", "Number", "Percentage"] + typedom_types: ["Keyword", "Length", "Number", "Percentage"] }, { name: "line-height-step", @@ -1656,7 +1674,7 @@ include_paths: ["core/style/StyleImage.h"], wrapper_pointer_name: "Persistent", default_value: "nullptr", - typedom_types: ["Image"], + typedom_types: ["Keyword", "Image"], type_name: "StyleImage", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_value: true, @@ -1669,6 +1687,7 @@ inherited: true, field_template: "keyword", keywords: ["outside", "inside"], + typedom_types: ["Keyword"], default_value: "outside", }, { @@ -1703,7 +1722,7 @@ default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", keywords: ["auto"], - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "margin-left", @@ -1715,7 +1734,7 @@ default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", keywords: ["auto"], - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "margin-right", @@ -1727,7 +1746,7 @@ default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", keywords: ["auto"], - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "margin-top", @@ -1739,7 +1758,7 @@ default_value: "Length(kFixed)", converter: "ConvertQuirkyLength", keywords: ["auto"], - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "marker-end", @@ -1857,7 +1876,7 @@ default_value: "LengthPoint(Length(50.0, kPercent), Length(50.0, kPercent))", type_name: "LengthPoint", converter: "ConvertPosition", - typedom_types: ["Position"], + typedom_types: ["Keyword", "Position"], }, { name: "offset-anchor", @@ -1925,7 +1944,7 @@ default_value: "1.0", type_name: "float", computed_style_custom_functions: ["setter"], - typedom_types: ["Number"] + typedom_types: ["Keyword", "Number"] }, { name: "order", @@ -1958,7 +1977,8 @@ type_name: "Color", computed_style_custom_functions: ["getter", "setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "outline-offset", @@ -1980,6 +2000,7 @@ "none", "hidden", "inset", "groove", "outset", "ridge", "dotted", "dashed", "solid", "double" ], + typedom_types: ["Keyword"], default_value: "none", type_name: "EBorderStyle", custom_apply_functions_all: true, @@ -2005,6 +2026,7 @@ keywords: [ "visible", "none", "auto" ], + typedom_types: ["Keyword"], default_value: "auto", }, { @@ -2024,6 +2046,7 @@ "visible", "hidden", "scroll", "auto", "overlay", "-webkit-paged-x", "-webkit-paged-y" ], + typedom_types: ["Keyword"], default_value: "visible", type_name: "EOverflow", }, @@ -2035,6 +2058,7 @@ "visible", "hidden", "scroll", "auto", "overlay", "-webkit-paged-x", "-webkit-paged-y" ], + typedom_types: ["Keyword"], default_value: "visible", type_name: "EOverflow", }, @@ -2065,7 +2089,7 @@ field_template: "<length>", default_value: "Length(kFixed)", converter: "ConvertLength", - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "padding-left", @@ -2076,7 +2100,7 @@ field_template: "<length>", default_value: "Length(kFixed)", converter: "ConvertLength", - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "padding-right", @@ -2087,7 +2111,7 @@ field_template: "<length>", default_value: "Length(kFixed)", converter: "ConvertLength", - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "padding-top", @@ -2098,7 +2122,7 @@ field_template: "<length>", default_value: "Length(kFixed)", converter: "ConvertLength", - typedom_types: ["Length", "Percentage"] + typedom_types: ["Keyword", "Length", "Percentage"] }, { name: "paint-order", @@ -2148,6 +2172,7 @@ keywords: [ "static", "relative", "absolute", "fixed", "sticky" ], + typedom_types: ["Keyword"], default_value: "static", getter: "GetPosition", custom_apply_functions_inherit: true, @@ -2170,6 +2195,7 @@ field_group: "*", field_template: "keyword", keywords: ["none", "both", "horizontal", "vertical"], + typedom_types: ["Keyword"], default_value: "none", custom_apply_functions_value: true, }, @@ -2182,7 +2208,7 @@ field_template: "<length>", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -2309,7 +2335,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2322,7 +2348,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2337,7 +2363,7 @@ field_group: "*", field_template: "<length>", default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLength", }, { @@ -2345,7 +2371,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2358,7 +2384,7 @@ property_methods: ["ParseSingleValue"], runtime_flag: "CSSScrollSnapPoints", include_paths: ["platform/Length.h"], - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], type_name: "Length", converter: "ConvertLength", direction_aware_options: { @@ -2373,7 +2399,7 @@ field_group: "*", field_template: "<length>", default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLength", }, { @@ -2383,7 +2409,7 @@ field_group: "*", field_template: "<length>", default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLength", }, { @@ -2393,7 +2419,7 @@ field_group: "*", field_template: "<length>", default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLength", }, { @@ -2456,7 +2482,7 @@ include_paths: ["core/style/ShapeValue.h"], wrapper_pointer_name: "Persistent", default_value: "nullptr", - typedom_types: ["Image"], + typedom_types: ["Keyword", "Image"], type_name: "ShapeValue", computed_style_custom_functions: ["getter"], converter: "ConvertShapeValue", @@ -2598,6 +2624,7 @@ "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center", "start", "end" ], + typedom_types: ["Keyword"], default_value: "start", getter: "GetTextAlign", custom_apply_functions_value: true, @@ -2637,7 +2664,8 @@ default_value: "StyleColor::CurrentColor()", type_name: "StyleColor", custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "text-decoration-line", @@ -2665,6 +2693,7 @@ field_group: "*", field_template: "keyword", keywords: ["solid", "double", "dotted", "dashed", "wavy"], + typedom_types: ["Keyword"], default_value: "solid", }, { @@ -2730,6 +2759,7 @@ inherited: true, field_template: "keyword", keywords: ["capitalize", "uppercase", "lowercase", "none"], + typedom_types: ["Keyword"], default_value: "none", }, // FIXME: Implement support for 'under left' and 'under right' values. @@ -2752,7 +2782,7 @@ field_template: "<length>", keywords: ["auto"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthOrAuto", }, { @@ -2777,7 +2807,7 @@ include_paths: ["platform/transforms/TransformOperations.h"], keywords: ["none"], default_value: "EmptyTransformOperations()", - typedom_types: ["Transform"], + typedom_types: ["Keyword", "Transform"], type_name: "TransformOperations", converter: "ConvertTransformOperations", }, @@ -2878,7 +2908,7 @@ interpolable: true, custom_apply_functions_inherit: true, custom_apply_functions_value: true, - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], keywords: ["baseline", "sub", "super", "text-top", "text-bottom", "middle"], }, { @@ -2889,6 +2919,7 @@ inherited: true, field_template: "keyword", keywords: ["visible", "hidden", "collapse"], + typedom_types: ["Keyword"], default_value: "visible", }, { @@ -3085,7 +3116,8 @@ type_name: "Color", computed_style_custom_functions: ["getter","setter"], custom_apply_functions_all: true, - keywords: ["currentcolor"] + keywords: ["currentcolor"], + typedom_types: ["Keyword"], }, { name: "column-rule-style", @@ -3470,6 +3502,7 @@ keywords: [ "normal", "pre", "pre-wrap", "pre-line", "nowrap", "-webkit-nowrap" ], + typedom_types: ["Keyword"], default_value: "normal", }, { @@ -3492,7 +3525,7 @@ field_template: "<length>", keywords: ["auto", "fit-content", "min-content", "max-content"], default_value: "Length()", - typedom_types: ["Length", "Percentage"], + typedom_types: ["Keyword", "Length", "Percentage"], converter: "ConvertLengthSizing", }, {
diff --git a/third_party/WebKit/Source/core/css/CSSPrimitiveValueUnits.json5 b/third_party/WebKit/Source/core/css/css_primitive_value_units.json5 similarity index 100% rename from third_party/WebKit/Source/core/css/CSSPrimitiveValueUnits.json5 rename to third_party/WebKit/Source/core/css/css_primitive_value_units.json5
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp b/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp index 53dd807a..bbe1f0f 100644 --- a/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp +++ b/third_party/WebKit/Source/core/css/cssom/CSSNumericValue.cpp
@@ -192,6 +192,8 @@ } CSSPrimitiveValue::UnitType CSSNumericValue::UnitFromName(const String& name) { + if (name.IsEmpty()) + return CSSPrimitiveValue::UnitType::kUnknown; if (EqualIgnoringASCIICase(name, "number")) return CSSPrimitiveValue::UnitType::kNumber; if (EqualIgnoringASCIICase(name, "percent") || name == "%")
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSOMTypes.h b/third_party/WebKit/Source/core/css/cssom/CSSOMTypes.h index 0a636b11..d517b91 100644 --- a/third_party/WebKit/Source/core/css/cssom/CSSOMTypes.h +++ b/third_party/WebKit/Source/core/css/cssom/CSSOMTypes.h
@@ -19,6 +19,7 @@ STATIC_ONLY(CSSOMTypes); public: + static bool IsPropertySupported(CSSPropertyID); static bool PropertyCanTake(CSSPropertyID, const CSSStyleValue&); static bool PropertyCanTakeType(CSSPropertyID, CSSStyleValue::StyleValueType); };
diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp index b19980f8..8cef459 100644 --- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp +++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
@@ -91,80 +91,6 @@ return nullptr; } -bool IsPropertySupported(CSSPropertyID property_id) { - switch (property_id) { - case CSSPropertyVariable: - case CSSPropertyAnimationDirection: - case CSSPropertyTransitionDuration: - case CSSPropertyColor: - case CSSPropertyDirection: - case CSSPropertyFontStyle: - case CSSPropertyFontWeight: - case CSSPropertyBackfaceVisibility: - case CSSPropertyBackgroundColor: - case CSSPropertyBackgroundImage: - case CSSPropertyBorderBottomColor: - case CSSPropertyBorderBottomStyle: - case CSSPropertyBorderBottomWidth: - case CSSPropertyBorderCollapse: - case CSSPropertyBorderImageSource: - case CSSPropertyBorderLeftColor: - case CSSPropertyBorderLeftStyle: - case CSSPropertyBorderLeftWidth: - case CSSPropertyBorderRightColor: - case CSSPropertyBorderRightStyle: - case CSSPropertyBorderRightWidth: - case CSSPropertyBorderTopColor: - case CSSPropertyBorderTopStyle: - case CSSPropertyBorderTopWidth: - case CSSPropertyBottom: - case CSSPropertyBoxSizing: - case CSSPropertyCaretColor: - case CSSPropertyClear: - case CSSPropertyColumnRuleColor: - case CSSPropertyDisplay: - case CSSPropertyEmptyCells: - case CSSPropertyFloat: - case CSSPropertyHeight: - case CSSPropertyLeft: - case CSSPropertyLineHeight: - case CSSPropertyListStyleImage: - case CSSPropertyListStylePosition: - case CSSPropertyMarginBottom: - case CSSPropertyMarginLeft: - case CSSPropertyMarginRight: - case CSSPropertyMarginTop: - case CSSPropertyObjectPosition: - case CSSPropertyOpacity: - case CSSPropertyOutlineColor: - case CSSPropertyOutlineStyle: - case CSSPropertyOverflowAnchor: - case CSSPropertyOverflowX: - case CSSPropertyOverflowY: - case CSSPropertyPaddingBottom: - case CSSPropertyPaddingLeft: - case CSSPropertyPaddingRight: - case CSSPropertyPaddingTop: - case CSSPropertyPosition: - case CSSPropertyResize: - case CSSPropertyRight: - case CSSPropertyShapeOutside: - case CSSPropertyTextAlign: - case CSSPropertyTextDecorationColor: - case CSSPropertyTextDecorationStyle: - case CSSPropertyTextTransform: - case CSSPropertyTop: - case CSSPropertyTransform: - case CSSPropertyVerticalAlign: - case CSSPropertyVisibility: - case CSSPropertyWhiteSpace: - case CSSPropertyWidth: - return true; - default: - return false; - } -} - CSSStyleValue* CreateStyleValueWithProperty(CSSPropertyID property_id, const CSSValue& value) { // These cannot be overridden by individual properties. @@ -179,7 +105,7 @@ return CSSUnparsedValue::FromCSSValue(*variable_data); } - if (!IsPropertySupported(property_id)) + if (!CSSOMTypes::IsPropertySupported(property_id)) return CSSUnsupportedStyleValue::Create(property_id, value); CSSStyleValue* style_value =
diff --git a/third_party/WebKit/Source/core/css/parser/CSSTokenizer.cpp b/third_party/WebKit/Source/core/css/parser/CSSTokenizer.cpp index f043eee..2961ec3 100644 --- a/third_party/WebKit/Source/core/css/parser/CSSTokenizer.cpp +++ b/third_party/WebKit/Source/core/css/parser/CSSTokenizer.cpp
@@ -5,7 +5,7 @@ #include "core/css/parser/CSSTokenizer.h" namespace blink { -#include "core/CSSTokenizerCodepoints.cpp" +#include "core/css_tokenizer_codepoints.cc" } #include "core/css/parser/CSSParserIdioms.h"
diff --git a/third_party/WebKit/Source/core/editing/commands/ClipboardCommands.h b/third_party/WebKit/Source/core/editing/commands/ClipboardCommands.h index cfdb366..e3c9e144a 100644 --- a/third_party/WebKit/Source/core/editing/commands/ClipboardCommands.h +++ b/third_party/WebKit/Source/core/editing/commands/ClipboardCommands.h
@@ -81,9 +81,10 @@ static bool PasteSupported(LocalFrame*); - private: static bool CanReadClipboard(LocalFrame&, EditorCommandSource); static bool CanWriteClipboard(LocalFrame&, EditorCommandSource); + + private: static bool CanSmartReplaceWithPasteboard(LocalFrame&, Pasteboard*); static bool CanDeleteRange(const EphemeralRange&); static Element* FindEventTargetForClipboardEvent(LocalFrame&,
diff --git a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp index 973cd72b..0d4f5754 100644 --- a/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp +++ b/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp
@@ -266,9 +266,6 @@ static const bool kNotTextInsertion = false; static const bool kIsTextInsertion = true; -static const bool kAllowExecutionWhenDisabled = true; -static const bool kDoNotAllowExecutionWhenDisabled = false; - // Related to Editor::selectionForCommand. // Certain operations continue to use the target control's selection even if the // event handler already moved the selection outside of the text control. @@ -828,13 +825,6 @@ Event*, EditorCommandSource source, const String&) { - // To support |allowExecutionWhenDisabled|, we need to check clipboard - // accessibility here rather than |Editor::Command::execute()|. - // TODO(yosin) We should move checking |canWriteClipboard()| to - // |Editor::Command::execute()| with introducing appropriate predicate, e.g. - // |canExecute()|. See also "Cut", and "Paste" command. - if (!CanWriteClipboard(frame, source)) - return false; if (!DispatchCopyOrCutEvent(frame, source, EventTypeNames::copy)) return true; if (!frame.GetEditor().CanCopy()) @@ -899,13 +889,6 @@ Event*, EditorCommandSource source, const String&) { - // To support |allowExecutionWhenDisabled|, we need to check clipboard - // accessibility here rather than |Editor::Command::execute()|. - // TODO(yosin) We should move checking |canWriteClipboard()| to - // |Editor::Command::execute()| with introducing appropriate predicate, e.g. - // |canExecute()|. See also "Copy", and "Paste" command. - if (!CanWriteClipboard(frame, source)) - return false; if (!DispatchCopyOrCutEvent(frame, source, EventTypeNames::cut)) return true; if (!frame.GetEditor().CanCut()) @@ -2177,13 +2160,6 @@ Event*, EditorCommandSource source, const String&) { - // To support |allowExecutionWhenDisabled|, we need to check clipboard - // accessibility here rather than |Editor::Command::execute()|. - // TODO(yosin) We should move checking |canReadClipboard()| to - // |Editor::Command::execute()| with introducing appropriate predicate, e.g. - // |canExecute()|. See also "Copy", and "Cut" command. - if (!CanReadClipboard(frame, source)) - return false; Paste(frame, source); return true; } @@ -2192,13 +2168,6 @@ Event*, EditorCommandSource source, const String&) { - // To support |allowExecutionWhenDisabled|, we need to check clipboard - // accessibility here rather than |Editor::Command::execute()|. - // TODO(yosin) We should move checking |canReadClipboard()| to - // |Editor::Command::execute()| with introducing appropriate predicate, e.g. - // |canExecute()|. See also "Copy", and "Cut" command. - if (!CanReadClipboard(frame, source)) - return false; if (!frame.GetEditor().Behavior().SupportsGlobalSelection()) return false; DCHECK_EQ(source, EditorCommandSource::kMenuOrKeyBinding); @@ -2997,11 +2966,7 @@ // CanExectue functions static bool CanNotExecuteWhenDisabled(LocalFrame&, EditorCommandSource) { - return kDoNotAllowExecutionWhenDisabled; -} - -static bool CanExecuteWhenDisabled(LocalFrame&, EditorCommandSource) { - return kAllowExecutionWhenDisabled; + return false; } // Map of functions @@ -3033,13 +2998,13 @@ kNotTextInsertion, CanNotExecuteWhenDisabled}, {WebEditingCommandType::kCopy, ClipboardCommands::ExecuteCopy, Supported, ClipboardCommands::EnabledCopy, StateNone, ValueStateOrNull, - kNotTextInsertion, CanExecuteWhenDisabled}, + kNotTextInsertion, ClipboardCommands::CanWriteClipboard}, {WebEditingCommandType::kCreateLink, ExecuteCreateLink, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, CanNotExecuteWhenDisabled}, {WebEditingCommandType::kCut, ClipboardCommands::ExecuteCut, Supported, ClipboardCommands::EnabledCut, StateNone, ValueStateOrNull, - kNotTextInsertion, CanExecuteWhenDisabled}, + kNotTextInsertion, ClipboardCommands::CanWriteClipboard}, {WebEditingCommandType::kDefaultParagraphSeparator, ExecuteDefaultParagraphSeparator, Supported, Enabled, StateNone, ValueDefaultParagraphSeparator, kNotTextInsertion, @@ -3365,15 +3330,17 @@ ValueStateOrNull, kNotTextInsertion, CanNotExecuteWhenDisabled}, {WebEditingCommandType::kPaste, ClipboardCommands::ExecutePaste, ClipboardCommands::PasteSupported, ClipboardCommands::EnabledPaste, - StateNone, ValueStateOrNull, kNotTextInsertion, CanExecuteWhenDisabled}, + StateNone, ValueStateOrNull, kNotTextInsertion, + ClipboardCommands::CanReadClipboard}, {WebEditingCommandType::kPasteAndMatchStyle, ClipboardCommands::ExecutePasteAndMatchStyle, Supported, ClipboardCommands::EnabledPaste, StateNone, ValueStateOrNull, - kNotTextInsertion, CanExecuteWhenDisabled}, + kNotTextInsertion, ClipboardCommands::CanReadClipboard}, {WebEditingCommandType::kPasteGlobalSelection, ClipboardCommands::ExecutePasteGlobalSelection, SupportedFromMenuOrKeyBinding, ClipboardCommands::EnabledPaste, - StateNone, ValueStateOrNull, kNotTextInsertion, CanExecuteWhenDisabled}, + StateNone, ValueStateOrNull, kNotTextInsertion, + ClipboardCommands::CanReadClipboard}, {WebEditingCommandType::kPrint, ExecutePrint, Supported, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, CanNotExecuteWhenDisabled},
diff --git a/third_party/WebKit/Source/core/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/core/fetch/BodyStreamBuffer.cpp index 608c2485..a821932 100644 --- a/third_party/WebKit/Source/core/fetch/BodyStreamBuffer.cpp +++ b/third_party/WebKit/Source/core/fetch/BodyStreamBuffer.cpp
@@ -144,7 +144,7 @@ return ScriptValue( script_state_.get(), V8PrivateProperty::GetInternalBodyStream(script_state_->GetIsolate()) - .GetOrEmpty(body)); + .GetOrUndefined(body)); } scoped_refptr<BlobDataHandle> BodyStreamBuffer::DrainAsBlobDataHandle(
diff --git a/third_party/WebKit/Source/core/frame/FrameOwner.h b/third_party/WebKit/Source/core/frame/FrameOwner.h index bd93e3e..88a798d3 100644 --- a/third_party/WebKit/Source/core/frame/FrameOwner.h +++ b/third_party/WebKit/Source/core/frame/FrameOwner.h
@@ -45,8 +45,8 @@ virtual bool CanRenderFallbackContent() const = 0; virtual void RenderFallbackContent() = 0; - // The intrinsic dimensions of the embedded object changed. This is relevant - // for SVG documents that are embedded via <object> or <embed>. + // The intrinsic dimensions of the embedded object changed. This is only + // relevant for SVG documents that are embedded via <object> or <embed>. virtual void IntrinsicSizingInfoChanged() = 0; // Returns the 'name' content attribute value of the browsing context
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.cpp b/third_party/WebKit/Source/core/frame/LocalFrame.cpp index a61a543..2f0402b 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrame.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrame.cpp
@@ -56,8 +56,6 @@ #include "core/frame/LocalFrameView.h" #include "core/frame/PerformanceMonitor.h" #include "core/frame/Settings.h" -#include "core/frame/WebFrameWidgetBase.h" -#include "core/frame/WebLocalFrameImpl.h" #include "core/html/HTMLFrameElementBase.h" #include "core/html/HTMLPlugInElement.h" #include "core/html/PluginDocument.h" @@ -460,22 +458,6 @@ return GetDocument() ? GetDocument()->GetLayoutView() : nullptr; } -void LocalFrame::IntrinsicSizingInfoChanged( - const IntrinsicSizingInfo& sizing_info) { - if (!Owner()) - return; - // Notify the owner. For remote frame owners, notify via - // an IPC to the parent renderer; otherwise notify directly. - // TODO(dcheng): Move this into a virtual on FrameOwner. - if (Owner()->IsRemote()) { - WebLocalFrameImpl::FromFrame(this) - ->FrameWidgetImpl() - ->IntrinsicSizingInfoChanged(sizing_info); - } else { - Owner()->IntrinsicSizingInfoChanged(); - } -} - void LocalFrame::DidChangeVisibilityState() { if (GetDocument()) GetDocument()->DidChangeVisibilityState();
diff --git a/third_party/WebKit/Source/core/frame/LocalFrame.h b/third_party/WebKit/Source/core/frame/LocalFrame.h index 20584e7c..d971b4d 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrame.h +++ b/third_party/WebKit/Source/core/frame/LocalFrame.h
@@ -161,8 +161,6 @@ SpellChecker& GetSpellChecker() const; FrameConsole& Console() const; - void IntrinsicSizingInfoChanged(const IntrinsicSizingInfo&); - // A local root is the root of a connected subtree that contains only // LocalFrames. The local root is responsible for coordinating input, layout, // et cetera for that subtree of frames.
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp index 755a9287..31ff5ca 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
@@ -862,16 +862,6 @@ layout_view->UpdateCounters(); } -bool LocalFrameView::UsesCompositedScrolling() const { - auto* layout_view = GetLayoutView(); - if (!layout_view) - return false; - if (frame_->GetSettings() && - frame_->GetSettings()->GetPreferCompositingToLCDTextEnabled()) - return layout_view->Compositor()->InCompositingMode(); - return false; -} - bool LocalFrameView::ShouldScrollOnMainThread() const { if (GetMainThreadScrollingReasons()) return true;
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.h b/third_party/WebKit/Source/core/frame/LocalFrameView.h index 406a472..77d1aef3 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.h +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.h
@@ -481,7 +481,6 @@ IntRect ScrollableAreaBoundingBox() const override; CompositorElementId GetCompositorElementId() const override; bool ScrollAnimatorEnabled() const override; - bool UsesCompositedScrolling() const override; bool ShouldScrollOnMainThread() const override; PaintLayer* Layer() const override; GraphicsLayer* LayerForScrolling() const override;
diff --git a/third_party/WebKit/Source/core/frame/RemoteFrameOwner.cpp b/third_party/WebKit/Source/core/frame/RemoteFrameOwner.cpp index 57dedcb7..af03cc7 100644 --- a/third_party/WebKit/Source/core/frame/RemoteFrameOwner.cpp +++ b/third_party/WebKit/Source/core/frame/RemoteFrameOwner.cpp
@@ -6,6 +6,7 @@ #include "core/frame/LocalFrame.h" #include "core/frame/LocalFrameClient.h" +#include "core/frame/WebFrameWidgetBase.h" #include "core/frame/WebLocalFrameImpl.h" #include "core/timing/Performance.h" #include "public/platform/WebResourceTimingInfo.h" @@ -63,4 +64,17 @@ web_frame->Client()->DispatchLoad(); } +void RemoteFrameOwner::IntrinsicSizingInfoChanged() { + LocalFrame& local_frame = ToLocalFrame(*frame_); + IntrinsicSizingInfo intrinsic_sizing_info; + bool result = + local_frame.View()->GetIntrinsicSizingInfo(intrinsic_sizing_info); + // By virtue of having been invoked, GetIntrinsicSizingInfo() should always + // succeed here. + DCHECK(result); + WebLocalFrameImpl::FromFrame(local_frame) + ->FrameWidgetImpl() + ->IntrinsicSizingInfoChanged(intrinsic_sizing_info); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/frame/RemoteFrameOwner.h b/third_party/WebKit/Source/core/frame/RemoteFrameOwner.h index 7c24176..e946852 100644 --- a/third_party/WebKit/Source/core/frame/RemoteFrameOwner.h +++ b/third_party/WebKit/Source/core/frame/RemoteFrameOwner.h
@@ -42,7 +42,7 @@ // TODO(dcheng): Implement. bool CanRenderFallbackContent() const override { return false; } void RenderFallbackContent() override {} - void IntrinsicSizingInfoChanged() override {} + void IntrinsicSizingInfoChanged() override; AtomicString BrowsingContextContainerName() const override { return browsing_context_container_name_;
diff --git a/third_party/WebKit/Source/core/html/MediaElementFillingViewportTest.cpp b/third_party/WebKit/Source/core/html/MediaElementFillingViewportTest.cpp index 873207c..9f06f24 100644 --- a/third_party/WebKit/Source/core/html/MediaElementFillingViewportTest.cpp +++ b/third_party/WebKit/Source/core/html/MediaElementFillingViewportTest.cpp
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> + #include "core/dom/Document.h" #include "core/html/media/HTMLMediaElement.h" #include "core/testing/sim/SimCompositor.h" @@ -34,7 +36,7 @@ std::unique_ptr<SimRequest> CreateMainResource() { std::unique_ptr<SimRequest> main_resource = - WTF::WrapUnique(new SimRequest("https://example.com/", "text/html")); + std::make_unique<SimRequest>("https://example.com/", "text/html"); LoadURL("https://example.com"); return main_resource; }
diff --git a/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp b/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp index c19aceb..4f0ebff 100644 --- a/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp +++ b/third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp
@@ -10,7 +10,6 @@ #include "core/style/ComputedStyle.h" #include "platform/MemoryCoordinator.h" #include "platform/fonts/FontCache.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/Platform.h" namespace { @@ -137,7 +136,7 @@ if (pruning_scheduled_) return; DCHECK(!main_cache_purge_preventer_); - main_cache_purge_preventer_ = WTF::WrapUnique(new FontCachePurgePreventer); + main_cache_purge_preventer_ = std::make_unique<FontCachePurgePreventer>(); Platform::Current()->CurrentThread()->AddTaskObserver(this); pruning_scheduled_ = true; }
diff --git a/third_party/WebKit/Source/core/html/forms/ExternalPopupMenu.cpp b/third_party/WebKit/Source/core/html/forms/ExternalPopupMenu.cpp index fae579a3..b8a7566 100644 --- a/third_party/WebKit/Source/core/html/forms/ExternalPopupMenu.cpp +++ b/third_party/WebKit/Source/core/html/forms/ExternalPopupMenu.cpp
@@ -45,7 +45,6 @@ #include "platform/geometry/FloatQuad.h" #include "platform/geometry/IntPoint.h" #include "platform/text/TextDirection.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/TaskType.h" #include "public/platform/WebCoalescedInputEvent.h" #include "public/platform/WebMouseEvent.h" @@ -121,7 +120,7 @@ #if defined(OS_MACOSX) const WebInputEvent* current_event = CurrentInputEvent::Get(); if (current_event && current_event->GetType() == WebInputEvent::kMouseDown) { - synthetic_event_ = WTF::WrapUnique(new WebMouseEvent); + synthetic_event_ = std::make_unique<WebMouseEvent>(); *synthetic_event_ = *static_cast<const WebMouseEvent*>(current_event); synthetic_event_->SetType(WebInputEvent::kMouseUp); dispatch_event_timer_.StartOneShot(TimeDelta(), FROM_HERE);
diff --git a/third_party/WebKit/Source/core/html/forms/FormController.cpp b/third_party/WebKit/Source/core/html/forms/FormController.cpp index 05a2e8c..b18b1ec1 100644 --- a/third_party/WebKit/Source/core/html/forms/FormController.cpp +++ b/third_party/WebKit/Source/core/html/forms/FormController.cpp
@@ -21,8 +21,10 @@ #include "core/html/forms/FormController.h" #include <memory> +#include <utility> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/dom/events/ScopedEventQueue.h" #include "core/html/forms/FileChooser.h" #include "core/html/forms/HTMLFormControlElementWithState.h" @@ -30,7 +32,6 @@ #include "core/html/forms/HTMLInputElement.h" #include "platform/wtf/Deque.h" #include "platform/wtf/HashTableDeletedValueType.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/text/StringBuilder.h" namespace blink { @@ -209,7 +210,7 @@ }; std::unique_ptr<SavedFormState> SavedFormState::Create() { - return WTF::WrapUnique(new SavedFormState); + return base::WrapUnique(new SavedFormState); } static bool IsNotFormControlTypeCharacter(UChar ch) { @@ -226,7 +227,7 @@ if (!item_count) return nullptr; std::unique_ptr<SavedFormState> saved_form_state = - WTF::WrapUnique(new SavedFormState); + base::WrapUnique(new SavedFormState); while (item_count--) { if (index + 1 >= state_vector.size()) return nullptr; @@ -432,7 +433,7 @@ Vector<String> DocumentState::ToStateVector() { FormKeyGenerator* key_generator = FormKeyGenerator::Create(); std::unique_ptr<SavedFormStateMap> state_map = - WTF::WrapUnique(new SavedFormStateMap); + base::WrapUnique(new SavedFormStateMap); for (HTMLFormControlElementWithState* control = form_controls_.Head(); control; control = control->Next()) { DCHECK(control->isConnected());
diff --git a/third_party/WebKit/Source/core/html/forms/InputType.cpp b/third_party/WebKit/Source/core/html/forms/InputType.cpp index e97a9aed..a3d8c47 100644 --- a/third_party/WebKit/Source/core/html/forms/InputType.cpp +++ b/third_party/WebKit/Source/core/html/forms/InputType.cpp
@@ -28,7 +28,9 @@ #include "core/html/forms/InputType.h" +#include <limits> #include <memory> +#include <utility> #include "bindings/core/v8/ExceptionMessages.h" #include "bindings/core/v8/ExceptionState.h" @@ -72,7 +74,6 @@ #include "platform/json/JSONValues.h" #include "platform/text/PlatformLocale.h" #include "platform/text/TextBreakIterator.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -84,7 +85,7 @@ static std::unique_ptr<InputTypeFactoryMap> CreateInputTypeFactoryMap() { std::unique_ptr<InputTypeFactoryMap> map = - WTF::WrapUnique(new InputTypeFactoryMap); + std::make_unique<InputTypeFactoryMap>(); map->insert(InputTypeNames::button, ButtonInputType::Create); map->insert(InputTypeNames::checkbox, CheckboxInputType::Create); map->insert(InputTypeNames::color, ColorInputType::Create);
diff --git a/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp index 156b7c0..69657e9 100644 --- a/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp +++ b/third_party/WebKit/Source/core/html/media/HTMLMediaElement.cpp
@@ -26,7 +26,10 @@ #include "core/html/media/HTMLMediaElement.h" +#include <algorithm> #include <limits> + +#include "base/memory/ptr_util.h" #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/ScriptController.h" #include "bindings/core/v8/ScriptEventListener.h" @@ -86,7 +89,6 @@ #include "platform/weborigin/SecurityOrigin.h" #include "platform/wtf/AutoReset.h" #include "platform/wtf/MathExtras.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Time.h" #include "platform/wtf/text/CString.h" #include "public/platform/Platform.h" @@ -3919,7 +3921,7 @@ void HTMLMediaElement::MediaSourceOpened(WebMediaSource* web_media_source) { SetShouldDelayLoadEvent(false); - media_source_->SetWebMediaSourceAndOpen(WTF::WrapUnique(web_media_source)); + media_source_->SetWebMediaSourceAndOpen(base::WrapUnique(web_media_source)); } bool HTMLMediaElement::IsInteractiveContent() const {
diff --git a/third_party/WebKit/Source/core/html/media/HTMLMediaElementEventListenersTest.cpp b/third_party/WebKit/Source/core/html/media/HTMLMediaElementEventListenersTest.cpp index 819b190..933a648 100644 --- a/third_party/WebKit/Source/core/html/media/HTMLMediaElementEventListenersTest.cpp +++ b/third_party/WebKit/Source/core/html/media/HTMLMediaElementEventListenersTest.cpp
@@ -4,6 +4,9 @@ #include "core/html/media/HTMLMediaElement.h" +#include <algorithm> +#include <memory> + #include "core/dom/UserGestureIndicator.h" #include "core/event_type_names.h" #include "core/fullscreen/Fullscreen.h" @@ -85,7 +88,7 @@ const WebMediaPlayerSource&, WebMediaPlayerClient* client, WebLayerTreeView*) override { - return WTF::WrapUnique(new FakeWebMediaPlayer(client)); + return std::make_unique<FakeWebMediaPlayer>(client); } };
diff --git a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp index 2188de39..b0b83c6 100644 --- a/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/BackgroundHTMLParser.cpp
@@ -26,6 +26,8 @@ #include "core/html/parser/BackgroundHTMLParser.h" #include <memory> +#include <utility> + #include "base/single_thread_task_runner.h" #include "core/html/parser/HTMLDocumentParser.h" #include "core/html/parser/TextResourceDecoder.h" @@ -36,7 +38,6 @@ #include "platform/WebTaskRunner.h" #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/wtf/Functional.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Time.h" #include "platform/wtf/text/TextPosition.h" #include "public/platform/Platform.h" @@ -114,13 +115,13 @@ std::unique_ptr<Configuration> config, scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner) : weak_factory_(this), - token_(WTF::WrapUnique(new HTMLToken)), + token_(std::make_unique<HTMLToken>()), tokenizer_(HTMLTokenizer::Create(config->options)), tree_builder_simulator_(config->options), options_(config->options), outstanding_token_limit_(config->outstanding_token_limit), parser_(config->parser), - pending_tokens_(WTF::WrapUnique(new CompactHTMLTokenStream)), + pending_tokens_(std::make_unique<CompactHTMLTokenStream>()), pending_token_limit_(config->pending_token_limit), xss_auditor_(std::move(config->xss_auditor)), decoder_(std::move(config->decoder)), @@ -317,7 +318,7 @@ #endif std::unique_ptr<HTMLDocumentParser::TokenizedChunk> chunk = - WTF::WrapUnique(new HTMLDocumentParser::TokenizedChunk); + std::make_unique<HTMLDocumentParser::TokenizedChunk>(); TRACE_EVENT_WITH_FLOW0("blink,loading", "BackgroundHTMLParser::sendTokensToMainThread", chunk.get(), TRACE_EVENT_FLAG_FLOW_OUT); @@ -339,7 +340,7 @@ bool is_empty = tokenized_chunk_queue_->Enqueue(std::move(chunk)); - pending_tokens_ = WTF::WrapUnique(new CompactHTMLTokenStream); + pending_tokens_ = std::make_unique<CompactHTMLTokenStream>(); return is_empty; }
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp index 174c792..191857d 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLDocumentParser.cpp
@@ -26,6 +26,8 @@ #include "core/html/parser/HTMLDocumentParser.h" #include <memory> +#include <utility> + #include "core/css/MediaValuesCached.h" #include "core/css/resolver/StyleResolver.h" #include "core/dom/DocumentFragment.h" @@ -56,7 +58,6 @@ #include "platform/loader/fetch/ResourceFetcher.h" #include "platform/scheduler/child/web_scheduler.h" #include "platform/wtf/AutoReset.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/Platform.h" #include "public/platform/TaskType.h" #include "public/platform/WebLoadingBehaviorFlag.h" @@ -128,7 +129,7 @@ options_(&document), reentry_permit_(HTMLParserReentryPermit::Create()), token_(sync_policy == kForceSynchronousParsing - ? WTF::WrapUnique(new HTMLToken) + ? std::make_unique<HTMLToken>() : nullptr), tokenizer_(sync_policy == kForceSynchronousParsing ? HTMLTokenizer::Create(options_) @@ -448,7 +449,7 @@ queued_preloads_.clear(); std::unique_ptr<BackgroundHTMLParser::Checkpoint> checkpoint = - WTF::WrapUnique(new BackgroundHTMLParser::Checkpoint); + std::make_unique<BackgroundHTMLParser::Checkpoint>(); checkpoint->parser = weak_factory_.GetWeakPtr(); checkpoint->token = std::move(token); checkpoint->tokenizer = std::move(tokenizer); @@ -767,7 +768,7 @@ if (!tokenizer_) { DCHECK(!InPumpSession()); DCHECK(have_background_parser_ || WasCreatedByScript()); - token_ = WTF::WrapUnique(new HTMLToken); + token_ = std::make_unique<HTMLToken>(); tokenizer_ = HTMLTokenizer::Create(options_); } @@ -803,10 +804,10 @@ GetDocument()->EnsureStyleResolver(); std::unique_ptr<BackgroundHTMLParser::Configuration> config = - WTF::WrapUnique(new BackgroundHTMLParser::Configuration); + std::make_unique<BackgroundHTMLParser::Configuration>(); config->options = options_; config->parser = weak_factory_.GetWeakPtr(); - config->xss_auditor = WTF::WrapUnique(new XSSAuditor); + config->xss_auditor = std::make_unique<XSSAuditor>(); config->xss_auditor->Init(GetDocument(), &xss_auditor_delegate_); config->decoder = TakeDecoder(); @@ -986,7 +987,7 @@ DCHECK(!token_); // We're finishing before receiving any data. Rather than booting up the // background parser just to spin it down, we finish parsing synchronously. - token_ = WTF::WrapUnique(new HTMLToken); + token_ = std::make_unique<HTMLToken>(); tokenizer_ = HTMLTokenizer::Create(options_); } @@ -1202,7 +1203,7 @@ // Fallback to synchronous parsing in that case. if (!have_background_parser_) { should_use_threading_ = false; - token_ = WTF::WrapUnique(new HTMLToken); + token_ = std::make_unique<HTMLToken>(); tokenizer_ = HTMLTokenizer::Create(options_); DecodedDataDocumentParser::Flush(); return;
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLMetaCharsetParser.h b/third_party/WebKit/Source/core/html/parser/HTMLMetaCharsetParser.h index ea0af78..34176c9 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLMetaCharsetParser.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLMetaCharsetParser.h
@@ -29,9 +29,9 @@ #include <memory> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/html/parser/HTMLToken.h" #include "platform/text/SegmentedString.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/text/TextCodec.h" #include "platform/wtf/text/TextEncoding.h" @@ -44,7 +44,7 @@ public: static std::unique_ptr<HTMLMetaCharsetParser> Create() { - return WTF::WrapUnique(new HTMLMetaCharsetParser()); + return base::WrapUnique(new HTMLMetaCharsetParser()); } ~HTMLMetaCharsetParser();
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h index d8eee9e1..c28e890 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.h
@@ -28,8 +28,10 @@ #define HTMLPreloadScanner_h #include <memory> +#include <utility> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/CoreExport.h" #include "core/css/MediaValuesCached.h" #include "core/dom/ViewportDescription.h" @@ -38,7 +40,6 @@ #include "core/html/parser/HTMLToken.h" #include "core/html/parser/PreloadRequest.h" #include "platform/text/SegmentedString.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Vector.h" namespace blink { @@ -60,11 +61,11 @@ public: static std::unique_ptr<CachedDocumentParameters> Create(Document* document) { - return WTF::WrapUnique(new CachedDocumentParameters(document)); + return base::WrapUnique(new CachedDocumentParameters(document)); } static std::unique_ptr<CachedDocumentParameters> Create() { - return WTF::WrapUnique(new CachedDocumentParameters); + return base::WrapUnique(new CachedDocumentParameters); } bool do_html_preload_scanning; @@ -178,7 +179,7 @@ std::unique_ptr<CachedDocumentParameters> document_parameters, const MediaValuesCached::MediaValuesCachedData& media_values_cached_data, const TokenPreloadScanner::ScannerType scanner_type) { - return WTF::WrapUnique(new HTMLPreloadScanner( + return base::WrapUnique(new HTMLPreloadScanner( options, document_url, std::move(document_parameters), media_values_cached_data, scanner_type)); }
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLToken.h b/third_party/WebKit/Source/core/html/parser/HTMLToken.h index 88524d7..eedf773 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLToken.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLToken.h
@@ -27,12 +27,12 @@ #define HTMLToken_h #include <memory> +#include <utility> #include "base/macros.h" #include "core/dom/Attribute.h" #include "core/html/parser/HTMLParserIdioms.h" #include "platform/wtf/Forward.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -217,7 +217,7 @@ void BeginDOCTYPE() { DCHECK_EQ(type_, kUninitialized); type_ = DOCTYPE; - doctype_data_ = WTF::WrapUnique(new DoctypeData); + doctype_data_ = std::make_unique<DoctypeData>(); } void BeginDOCTYPE(UChar character) {
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLTokenizer.h b/third_party/WebKit/Source/core/html/parser/HTMLTokenizer.h index 54c9d8b4..c6a3b48 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLTokenizer.h +++ b/third_party/WebKit/Source/core/html/parser/HTMLTokenizer.h
@@ -30,12 +30,12 @@ #include <memory> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/CoreExport.h" #include "core/html/parser/HTMLParserOptions.h" #include "core/html/parser/HTMLToken.h" #include "core/html/parser/InputStreamPreprocessor.h" #include "platform/text/SegmentedString.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -45,7 +45,7 @@ public: static std::unique_ptr<HTMLTokenizer> Create( const HTMLParserOptions& options) { - return WTF::WrapUnique(new HTMLTokenizer(options)); + return base::WrapUnique(new HTMLTokenizer(options)); } ~HTMLTokenizer();
diff --git a/third_party/WebKit/Source/core/html/parser/PreloadRequest.h b/third_party/WebKit/Source/core/html/parser/PreloadRequest.h index f4c8a29..3c2aabf1 100644 --- a/third_party/WebKit/Source/core/html/parser/PreloadRequest.h +++ b/third_party/WebKit/Source/core/html/parser/PreloadRequest.h
@@ -6,6 +6,8 @@ #define PreloadRequest_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/CoreExport.h" #include "core/script/Script.h" #include "platform/CrossOriginAttributeValue.h" @@ -16,7 +18,6 @@ #include "platform/loader/fetch/ResourceFetcher.h" #include "platform/weborigin/SecurityPolicy.h" #include "platform/wtf/Allocator.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/text/TextPosition.h" namespace blink { @@ -60,7 +61,7 @@ ProtocolIs(resource_url, "data")) { return nullptr; } - return WTF::WrapUnique(new PreloadRequest( + return base::WrapUnique(new PreloadRequest( initiator_name, initiator_position, resource_url, base_url, resource_type, resource_width, client_hints_preferences, request_type, referrer_policy, referrer_source, is_image_set));
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h index 85f63d8..a4c5e404 100644 --- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h +++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
@@ -26,10 +26,10 @@ #include <memory> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/CoreExport.h" #include "platform/loader/fetch/TextResourceDecoderOptions.h" #include "platform/weborigin/KURL.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/text/TextEncoding.h" namespace blink { @@ -53,7 +53,7 @@ static std::unique_ptr<TextResourceDecoder> Create( const TextResourceDecoderOptions& options) { - return WTF::WrapUnique(new TextResourceDecoder(options)); + return base::WrapUnique(new TextResourceDecoder(options)); } ~TextResourceDecoder();
diff --git a/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp b/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp index 958c498..b246bca 100644 --- a/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp +++ b/third_party/WebKit/Source/core/html/parser/XSSAuditor.cpp
@@ -27,6 +27,7 @@ #include "core/html/parser/XSSAuditor.h" #include <memory> + #include "core/dom/Document.h" #include "core/frame/LocalFrame.h" #include "core/frame/Settings.h" @@ -46,7 +47,6 @@ #include "platform/network/EncodedFormData.h" #include "platform/text/DecodeEscapeSequences.h" #include "platform/wtf/ASCIICType.h" -#include "platform/wtf/PtrUtil.h" namespace { @@ -476,9 +476,11 @@ http_body_as_string_ = String(); if (decoded_http_body_.Find(IsRequiredForInjection) == kNotFound) decoded_http_body_ = String(); - if (decoded_http_body_.length() >= kMiniumLengthForSuffixTree) - decoded_http_body_suffix_tree_ = WTF::WrapUnique( - new SuffixTree<ASCIICodebook>(decoded_http_body_, kSuffixTreeDepth)); + if (decoded_http_body_.length() >= kMiniumLengthForSuffixTree) { + decoded_http_body_suffix_tree_ = + std::make_unique<SuffixTree<ASCIICodebook>>(decoded_http_body_, + kSuffixTreeDepth); + } } if (decoded_url_.IsEmpty() && decoded_http_body_.IsEmpty())
diff --git a/third_party/WebKit/Source/core/html/parser/XSSAuditorDelegate.h b/third_party/WebKit/Source/core/html/parser/XSSAuditorDelegate.h index 530e782..5f5cadf2 100644 --- a/third_party/WebKit/Source/core/html/parser/XSSAuditorDelegate.h +++ b/third_party/WebKit/Source/core/html/parser/XSSAuditorDelegate.h
@@ -29,9 +29,9 @@ #include <memory> #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "platform/heap/Handle.h" #include "platform/weborigin/KURL.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/Vector.h" #include "platform/wtf/text/TextPosition.h" #include "platform/wtf/text/WTFString.h" @@ -48,8 +48,8 @@ static std::unique_ptr<XSSInfo> Create(const String& original_url, bool did_block_entire_page, bool did_send_xss_protection_header) { - return WTF::WrapUnique(new XSSInfo(original_url, did_block_entire_page, - did_send_xss_protection_header)); + return base::WrapUnique(new XSSInfo(original_url, did_block_entire_page, + did_send_xss_protection_header)); } String BuildConsoleError() const;
diff --git a/third_party/WebKit/Source/core/layout/FloatingObjects.cpp b/third_party/WebKit/Source/core/layout/FloatingObjects.cpp index 8add4e6..a185825 100644 --- a/third_party/WebKit/Source/core/layout/FloatingObjects.cpp +++ b/third_party/WebKit/Source/core/layout/FloatingObjects.cpp
@@ -26,13 +26,15 @@ #include <algorithm> #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/layout/LayoutBlockFlow.h" #include "core/layout/LayoutBox.h" #include "core/layout/LayoutView.h" #include "core/layout/api/LineLayoutBlockFlow.h" #include "core/layout/shapes/ShapeOutsideInfo.h" #include "core/paint/PaintLayer.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -90,7 +92,7 @@ std::unique_ptr<FloatingObject> FloatingObject::Create( LayoutBox* layout_object) { std::unique_ptr<FloatingObject> new_obj = - WTF::WrapUnique(new FloatingObject(layout_object)); + base::WrapUnique(new FloatingObject(layout_object)); // If a layer exists, the float will paint itself. Otherwise someone else // will. @@ -114,14 +116,14 @@ LayoutSize offset, bool should_paint, bool is_descendant) const { - return WTF::WrapUnique(new FloatingObject( + return base::WrapUnique(new FloatingObject( GetLayoutObject(), GetType(), LayoutRect(FrameRect().Location() - offset, FrameRect().Size()), should_paint, is_descendant, IsLowestNonOverhangingFloatInChild())); } std::unique_ptr<FloatingObject> FloatingObject::UnsafeClone() const { - std::unique_ptr<FloatingObject> clone_object = WTF::WrapUnique( + std::unique_ptr<FloatingObject> clone_object = base::WrapUnique( new FloatingObject(GetLayoutObject(), GetType(), frame_rect_, should_paint_, is_descendant_, false)); clone_object->is_placed_ = is_placed_; @@ -547,7 +549,7 @@ std::unique_ptr<FloatingObject> floating_object) { FloatingObject* new_object = floating_object.release(); IncreaseObjectsCount(new_object->GetType()); - set_.insert(WTF::WrapUnique(new_object)); + set_.insert(base::WrapUnique(new_object)); if (new_object->IsPlaced()) AddPlacedObject(*new_object); MarkLowestFloatLogicalBottomCacheAsDirty();
diff --git a/third_party/WebKit/Source/core/layout/Grid.cpp b/third_party/WebKit/Source/core/layout/Grid.cpp index a7e716ee..b70e7b6 100644 --- a/third_party/WebKit/Source/core/layout/Grid.cpp +++ b/third_party/WebKit/Source/core/layout/Grid.cpp
@@ -4,6 +4,10 @@ #include "core/layout/Grid.h" +#include <algorithm> +#include <memory> +#include <utility> + #include "core/layout/LayoutGrid.h" namespace blink { @@ -228,11 +232,11 @@ for (; varying_track_index < end_of_varying_track_index; ++varying_track_index) { if (CheckEmptyCells(row_span, column_span)) { - std::unique_ptr<GridArea> result = WTF::WrapUnique( - new GridArea(GridSpan::TranslatedDefiniteGridSpan( - row_index_, row_index_ + row_span), - GridSpan::TranslatedDefiniteGridSpan( - column_index_, column_index_ + column_span))); + std::unique_ptr<GridArea> result = std::make_unique<GridArea>( + GridSpan::TranslatedDefiniteGridSpan(row_index_, + row_index_ + row_span), + GridSpan::TranslatedDefiniteGridSpan(column_index_, + column_index_ + column_span)); // Advance the iterator to avoid an infinite loop where we would return // the same grid area over and over. ++varying_track_index;
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp index 9975af2..cfd0dbe44 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -24,7 +24,11 @@ #include "core/layout/LayoutBlock.h" +#include <algorithm> #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/css/StyleEngine.h" #include "core/dom/Document.h" #include "core/dom/Element.h" @@ -58,7 +62,6 @@ #include "core/paint/PaintLayer.h" #include "core/style/ComputedStyle.h" #include "platform/runtime_enabled_features.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/StdLibExtras.h" namespace blink { @@ -947,7 +950,7 @@ g_positioned_descendants_map->at(this); if (!descendant_set) { descendant_set = new TrackedLayoutBoxListHashSet; - g_positioned_descendants_map->Set(this, WTF::WrapUnique(descendant_set)); + g_positioned_descendants_map->Set(this, base::WrapUnique(descendant_set)); } descendant_set->insert(o); @@ -1058,7 +1061,7 @@ if (!descendant_set) { descendant_set = new TrackedLayoutBoxListHashSet; g_percent_height_descendants_map->Set(this, - WTF::WrapUnique(descendant_set)); + base::WrapUnique(descendant_set)); } descendant_set->insert(descendant);
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp index 57ffac68..6d3900a 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -30,7 +30,10 @@ #include "core/layout/LayoutBlockFlow.h" +#include <algorithm> #include <memory> +#include <utility> + #include "core/editing/Editor.h" #include "core/frame/LocalFrame.h" #include "core/frame/LocalFrameView.h" @@ -57,7 +60,6 @@ #include "core/paint/BlockFlowPaintInvalidator.h" #include "core/paint/PaintLayer.h" #include "platform/runtime_enabled_features.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -2877,7 +2879,7 @@ void LayoutBlockFlow::CreateFloatingObjects() { floating_objects_ = - WTF::WrapUnique(new FloatingObjects(this, IsHorizontalWritingMode())); + std::make_unique<FloatingObjects>(this, IsHorizontalWritingMode()); } void LayoutBlockFlow::WillBeDestroyed() {
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp index 6e148bb..68b9657 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -74,7 +74,6 @@ #include "platform/geometry/DoubleRect.h" #include "platform/geometry/FloatQuad.h" #include "platform/geometry/FloatRoundedRect.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/WebRect.h" #include "public/platform/WebScrollIntoViewParams.h" @@ -5198,8 +5197,7 @@ } if (!overflow_) { - overflow_ = - WTF::WrapUnique(new BoxOverflowModel(client_box, BorderBoxRect())); + overflow_ = std::make_unique<BoxOverflowModel>(client_box, BorderBoxRect()); } overflow_->AddLayoutOverflow(overflow_rect); @@ -5215,7 +5213,7 @@ if (!overflow_) { overflow_ = - WTF::WrapUnique(new BoxOverflowModel(NoOverflowRect(), border_box)); + std::make_unique<BoxOverflowModel>(NoOverflowRect(), border_box); } overflow_->AddSelfVisualOverflow(rect); @@ -5236,7 +5234,7 @@ if (!overflow_) { overflow_ = - WTF::WrapUnique(new BoxOverflowModel(NoOverflowRect(), border_box)); + std::make_unique<BoxOverflowModel>(NoOverflowRect(), border_box); } overflow_->AddContentsVisualOverflow(rect); }
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.h b/third_party/WebKit/Source/core/layout/LayoutBox.h index 6f35aaf3..4c33848 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBox.h +++ b/third_party/WebKit/Source/core/layout/LayoutBox.h
@@ -24,6 +24,7 @@ #define LayoutBox_h #include <memory> + #include "base/macros.h" #include "core/CoreExport.h" #include "core/layout/LayoutBoxModelObject.h" @@ -31,7 +32,6 @@ #include "core/layout/custom/CustomLayoutChild.h" #include "platform/scroll/ScrollTypes.h" #include "platform/wtf/Compiler.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -101,7 +101,7 @@ SnapAreaSet& EnsureSnapAreas() { if (!snap_areas_) - snap_areas_ = WTF::WrapUnique(new SnapAreaSet); + snap_areas_ = std::make_unique<SnapAreaSet>(); return *snap_areas_; }
diff --git a/third_party/WebKit/Source/core/layout/LayoutCounter.cpp b/third_party/WebKit/Source/core/layout/LayoutCounter.cpp index ffdd0b8..f139c73 100644 --- a/third_party/WebKit/Source/core/layout/LayoutCounter.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutCounter.cpp
@@ -22,6 +22,8 @@ #include "core/layout/LayoutCounter.h" #include <memory> + +#include "base/memory/ptr_util.h" #include "core/dom/Element.h" #include "core/dom/ElementTraversal.h" #include "core/dom/NodeComputedStyle.h" @@ -34,7 +36,6 @@ #include "core/layout/LayoutView.h" #include "core/layout/ListMarkerText.h" #include "core/style/ComputedStyle.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/StdLibExtras.h" #ifndef NDEBUG @@ -415,7 +416,7 @@ node_map = GetCounterMaps().at(&object); } else { node_map = new CounterMap; - GetCounterMaps().Set(&object, WTF::WrapUnique(node_map)); + GetCounterMaps().Set(&object, base::WrapUnique(node_map)); object.SetHasCounterNodeMap(true); } node_map->Set(identifier, new_node);
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp index 79d6857..8283df3 100644 --- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -27,6 +27,8 @@ #include <algorithm> #include <memory> +#include <utility> + #include "core/frame/UseCounter.h" #include "core/layout/GridLayoutUtils.h" #include "core/layout/LayoutState.h" @@ -37,7 +39,6 @@ #include "core/style/GridArea.h" #include "platform/LengthFunctions.h" #include "platform/text/WritingMode.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -717,7 +718,7 @@ first_auto_repeat_track + grid.AutoRepeatTracks(direction); if (!grid.HasGridItems()) { - empty_track_indexes = WTF::WrapUnique(new OrderedTrackIndexSet); + empty_track_indexes = std::make_unique<OrderedTrackIndexSet>(); for (size_t track_index = first_auto_repeat_track; track_index < last_auto_repeat_track; ++track_index) empty_track_indexes->insert(track_index); @@ -727,7 +728,7 @@ GridIterator iterator(grid, direction, track_index); if (!iterator.NextGridItem()) { if (!empty_track_indexes) - empty_track_indexes = WTF::WrapUnique(new OrderedTrackIndexSet); + empty_track_indexes = std::make_unique<OrderedTrackIndexSet>(); empty_track_indexes->insert(track_index); } } @@ -932,11 +933,11 @@ GridSpan cross_direction_positions = GridSpan::TranslatedDefiniteGridSpan( end_of_cross_direction, end_of_cross_direction + cross_direction_span_size); - return WTF::WrapUnique(new GridArea( + return std::make_unique<GridArea>( specified_direction == kForColumns ? cross_direction_positions : specified_positions, specified_direction == kForColumns ? specified_positions - : cross_direction_positions)); + : cross_direction_positions); } void LayoutGrid::PlaceSpecifiedMajorAxisItemsOnGrid(
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp index 790a777..436ab77b8 100644 --- a/third_party/WebKit/Source/core/layout/LayoutView.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutView.cpp
@@ -22,6 +22,7 @@ #include "core/layout/LayoutView.h" #include <inttypes.h> + #include "core/dom/Document.h" #include "core/dom/Element.h" #include "core/editing/FrameSelection.h" @@ -34,7 +35,6 @@ #include "core/layout/LayoutCounter.h" #include "core/layout/LayoutEmbeddedContent.h" #include "core/layout/LayoutGeometryMap.h" -#include "core/layout/LayoutView.h" #include "core/layout/ViewFragmentationContext.h" #include "core/layout/svg/LayoutSVGRoot.h" #include "core/page/ChromeClient.h" @@ -50,7 +50,6 @@ #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/instrumentation/tracing/TracedValue.h" #include "platform/runtime_enabled_features.h" -#include "platform/wtf/PtrUtil.h" #include "public/platform/Platform.h" namespace blink { @@ -305,7 +304,7 @@ LogicalWidth(); if (!fragmentation_context_) { fragmentation_context_ = - WTF::WrapUnique(new ViewFragmentationContext(*this)); + std::make_unique<ViewFragmentationContext>(*this); pagination_state_changed_ = true; } } else if (fragmentation_context_) { @@ -839,7 +838,7 @@ PaintLayerCompositor* LayoutView::Compositor() { if (!compositor_) - compositor_ = WTF::WrapUnique(new PaintLayerCompositor(*this)); + compositor_ = std::make_unique<PaintLayerCompositor>(*this); return compositor_.get(); }
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp index 7dabcd9..c80dd48 100644 --- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp +++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -4,6 +4,9 @@ #include "core/layout/ScrollAnchor.h" +#include <algorithm> +#include <memory> + #include "core/css/CSSMarkup.h" #include "core/dom/ElementTraversal.h" #include "core/dom/NthIndexCache.h" @@ -140,7 +143,7 @@ static const AtomicString UniqueClassnameAmongSiblings(Element* element) { DCHECK(element); - auto classname_filter = WTF::WrapUnique(new ClassnameFilter()); + auto classname_filter = std::make_unique<ClassnameFilter>(); Element* parent_element = ElementTraversal::FirstAncestor(*element->ToNode()); Element* sibling_element =
diff --git a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp index 9a0c9bd..879ed9e1 100644 --- a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp +++ b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp
@@ -30,7 +30,11 @@ #include "core/layout/TextAutosizer.h" +#include <algorithm> #include <memory> +#include <utility> + +#include "base/memory/ptr_util.h" #include "core/dom/Document.h" #include "core/frame/LocalFrame.h" #include "core/frame/LocalFrameView.h" @@ -49,7 +53,6 @@ #include "core/page/ChromeClient.h" #include "core/page/Page.h" #include "platform/geometry/IntRect.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -323,7 +326,7 @@ blocks_that_have_begun_layout_.insert(block); #endif if (Cluster* cluster = MaybeCreateCluster(block)) - cluster_stack_.push_back(WTF::WrapUnique(cluster)); + cluster_stack_.push_back(base::WrapUnique(cluster)); } } @@ -341,7 +344,7 @@ DCHECK(!cluster_stack_.IsEmpty() || block->IsLayoutView()); if (Cluster* cluster = MaybeCreateCluster(block)) - cluster_stack_.push_back(WTF::WrapUnique(cluster)); + cluster_stack_.push_back(base::WrapUnique(cluster)); DCHECK(!cluster_stack_.IsEmpty()); @@ -855,7 +858,7 @@ return add_result.stored_value->value.get(); Supercluster* supercluster = new Supercluster(roots); - add_result.stored_value->value = WTF::WrapUnique(supercluster); + add_result.stored_value->value = base::WrapUnique(supercluster); return supercluster; } @@ -1249,7 +1252,7 @@ ReverseFingerprintMap::AddResult add_result = blocks_for_fingerprint_.insert(fingerprint, std::unique_ptr<BlockSet>()); if (add_result.is_new_entry) - add_result.stored_value->value = WTF::WrapUnique(new BlockSet); + add_result.stored_value->value = std::make_unique<BlockSet>(); add_result.stored_value->value->insert(block); #if DCHECK_IS_ON() AssertMapsAreConsistent();
diff --git a/third_party/WebKit/Source/core/layout/line/RootInlineBox.h b/third_party/WebKit/Source/core/layout/line/RootInlineBox.h index 44b44748..a572171bb 100644 --- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.h +++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.h
@@ -22,11 +22,11 @@ #define RootInlineBox_h #include <memory> + #include "core/layout/api/LineLayoutItem.h" #include "core/layout/api/SelectionState.h" #include "core/layout/line/InlineFlowBox.h" #include "platform/text/BidiContext.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -162,7 +162,7 @@ if (floats_) floats_->push_back(floating_box); else - floats_ = WTF::WrapUnique(new Vector<LayoutBox*>(1, floating_box)); + floats_ = std::make_unique<Vector<LayoutBox*>>(1, floating_box); } Vector<LayoutBox*>* FloatsPtr() {
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.cc index 6a15fa9..be1cff0 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.cc
@@ -54,7 +54,8 @@ bidi_level_(UBIDI_LTR), shape_options_(kPreContext | kPostContext), is_empty_item_(false), - should_create_box_fragment_(false) { + should_create_box_fragment_(false), + style_variant_(static_cast<unsigned>(NGStyleVariant::kStandard)) { DCHECK_GE(end, start); ComputeBoxProperties(); }
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.h index e2b9c0cb..efce19c 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.h +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_item.h
@@ -6,6 +6,7 @@ #define NGInlineItem_h #include "core/CoreExport.h" +#include "core/layout/ng/ng_style_variant.h" #include "platform/LayoutUnit.h" #include "platform/fonts/FontFallbackPriority.h" #include "platform/fonts/SimpleFontData.h" @@ -93,6 +94,13 @@ bool HasStartEdge() const; bool HasEndEdge() const; + void SetStyleVariant(NGStyleVariant style_variant) { + style_variant_ = static_cast<unsigned>(style_variant); + } + NGStyleVariant StyleVariant() const { + return static_cast<NGStyleVariant>(style_variant_); + } + static void Split(Vector<NGInlineItem>&, unsigned index, unsigned offset); static unsigned SetBidiLevel(Vector<NGInlineItem>&, unsigned index, @@ -119,7 +127,7 @@ unsigned shape_options_ : 2; unsigned is_empty_item_ : 1; unsigned should_create_box_fragment_ : 1; - + unsigned style_variant_ : 2; friend class NGInlineNode; };
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc index 33c37d2..a8e915d 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
@@ -412,6 +412,7 @@ if (item.style_) { DCHECK(item.layout_object_); item.style_ = item.layout_object_->FirstLineStyle(); + item.SetStyleVariant(NGStyleVariant::kFirstLine); } }
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc index cb4d820..6a13aef 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
@@ -468,7 +468,7 @@ shaper.Shape(&style.GetFont(), direction); NGTextFragmentBuilder builder(node_, constraint_space_.GetWritingMode()); builder.SetText(item.GetLayoutObject(), hyphen_string, &style, - std::move(hyphen_result)); + /* is_ellipsis_style */ false, std::move(hyphen_result)); SetLineEndFragment(builder.ToTextFragment(), line_info); } @@ -968,7 +968,8 @@ // This is stored seprately from other results so that it can be appended // after bidi reorder. NGTextFragmentBuilder builder(node_, constraint_space_.GetWritingMode()); - builder.SetText(layout_object, ellipsis, style, std::move(shape_result)); + builder.SetText(layout_object, ellipsis, style, true /* is_ellipsis_style */, + std::move(shape_result)); SetLineEndFragment(builder.ToTextFragment(), line_info); }
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.cc index fb18d40..40f75230 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.cc
@@ -73,6 +73,14 @@ return {}; } +scoped_refptr<NGPhysicalFragment> NGPhysicalTextFragment::CloneWithoutOffset() + const { + return base::AdoptRef(new NGPhysicalTextFragment( + layout_object_, Style(), static_cast<NGStyleVariant>(style_variant_), + TextType(), text_, start_offset_, end_offset_, size_, LineOrientation(), + EndEffect(), shape_result_)); +} + bool NGPhysicalTextFragment::IsAnonymousText() const { // TODO(xiaochengh): Introduce and set a flag for anonymous text. const LayoutObject* layout_object = GetLayoutObject();
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.h index c6a6048..d1f5e76d 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.h +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_physical_text_fragment.h
@@ -52,6 +52,7 @@ NGPhysicalTextFragment(LayoutObject* layout_object, const ComputedStyle& style, + NGStyleVariant style_variant, NGTextType text_type, const String& text, unsigned start_offset, @@ -62,6 +63,7 @@ scoped_refptr<const ShapeResult> shape_result) : NGPhysicalFragment(layout_object, style, + style_variant, size, kFragmentText, text_type), @@ -111,11 +113,7 @@ return static_cast<NGTextEndEffect>(end_effect_); } - scoped_refptr<NGPhysicalFragment> CloneWithoutOffset() const { - return base::AdoptRef(new NGPhysicalTextFragment( - layout_object_, Style(), TextType(), text_, start_offset_, end_offset_, - size_, LineOrientation(), EndEffect(), shape_result_)); - } + scoped_refptr<NGPhysicalFragment> CloneWithoutOffset() const; NGTextFragmentPaintInfo PaintInfo() const { return NGTextFragmentPaintInfo{text_, StartOffset(), EndOffset(),
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.cc index 779c573..23d80e3 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.cc
@@ -47,7 +47,7 @@ item_index_ = item_result->item_index; start_offset_ = item_result->start_offset; end_offset_ = item_result->end_offset; - SetStyle(item_result->item->Style()); + SetStyle(item_result->item->Style(), item_result->item->StyleVariant()); size_ = {item_result->inline_size, line_height}; end_effect_ = item_result->text_end_effect; shape_result_ = std::move(item_result->shape_result); @@ -58,6 +58,7 @@ LayoutObject* layout_object, const String& text, scoped_refptr<const ComputedStyle> style, + bool is_ellipsis_style, scoped_refptr<const ShapeResult> shape_result) { DCHECK(layout_object); DCHECK(style); @@ -68,7 +69,8 @@ item_index_ = std::numeric_limits<unsigned>::max(); start_offset_ = shape_result->StartIndexForResult(); end_offset_ = shape_result->EndIndexForResult(); - SetStyle(style); + SetStyle(style, is_ellipsis_style ? NGStyleVariant::kEllipsis + : NGStyleVariant::kStandard); FontBaseline baseline_type = style->IsHorizontalWritingMode() ? kAlphabeticBaseline : kIdeographicBaseline; @@ -82,8 +84,8 @@ scoped_refptr<NGPhysicalTextFragment> NGTextFragmentBuilder::ToTextFragment() { scoped_refptr<NGPhysicalTextFragment> fragment = base::AdoptRef(new NGPhysicalTextFragment( - layout_object_, Style(), text_type_, text_, start_offset_, - end_offset_, size_.ConvertToPhysical(GetWritingMode()), + layout_object_, Style(), style_variant_, text_type_, text_, + start_offset_, end_offset_, size_.ConvertToPhysical(GetWritingMode()), ToLineOrientation(GetWritingMode()), end_effect_, std::move(shape_result_))); return fragment;
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.h index 2acaae2..b5d92da 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.h +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_text_fragment_builder.h
@@ -31,6 +31,7 @@ void SetText(LayoutObject*, const String& text, scoped_refptr<const ComputedStyle>, + bool is_ellipsis_style, scoped_refptr<const ShapeResult>); // Creates the fragment. Can only be called once.
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.cc b/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.cc index 1abf582..9545e998 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.cc
@@ -23,9 +23,11 @@ NGBaseFragmentBuilder::~NGBaseFragmentBuilder() = default; NGBaseFragmentBuilder& NGBaseFragmentBuilder::SetStyle( - scoped_refptr<const ComputedStyle> style) { + scoped_refptr<const ComputedStyle> style, + NGStyleVariant style_variant) { DCHECK(style); style_ = std::move(style); + style_variant_ = style_variant; return *this; }
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.h b/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.h index 4755b12..76861b5 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.h +++ b/third_party/WebKit/Source/core/layout/ng/ng_base_fragment_builder.h
@@ -7,6 +7,7 @@ #include "base/memory/scoped_refptr.h" #include "core/CoreExport.h" +#include "core/layout/ng/ng_style_variant.h" #include "core/style/ComputedStyle.h" #include "platform/text/TextDirection.h" #include "platform/text/WritingMode.h" @@ -23,7 +24,8 @@ DCHECK(style_); return *style_; } - NGBaseFragmentBuilder& SetStyle(scoped_refptr<const ComputedStyle>); + NGBaseFragmentBuilder& SetStyle(scoped_refptr<const ComputedStyle>, + NGStyleVariant); WritingMode GetWritingMode() const { return writing_mode_; } TextDirection Direction() const { return direction_; } @@ -38,6 +40,9 @@ scoped_refptr<const ComputedStyle> style_; WritingMode writing_mode_; TextDirection direction_; + + protected: + NGStyleVariant style_variant_; }; } // namespace blink
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc index 51ecf10..cc87643 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
@@ -4,6 +4,8 @@ #include "core/layout/ng/ng_block_node.h" +#include <memory> + #include "core/layout/LayoutBlockFlow.h" #include "core/layout/LayoutMultiColumnFlowThread.h" #include "core/layout/LayoutMultiColumnSet.h" @@ -310,6 +312,7 @@ ToNGPhysicalBoxFragment(*layout_result.PhysicalFragment()); NGBoxFragment fragment(constraint_space.GetWritingMode(), physical_fragment); + NGLogicalSize fragment_logical_size = fragment.Size(); // For each fragment we process, we'll accumulate the logical height and // logical intrinsic content box height. We reset it at the first fragment, // and accumulate at each method call for fragments belonging to the same @@ -319,14 +322,14 @@ LayoutUnit logical_height; LayoutUnit intrinsic_content_logical_height; if (IsFirstFragment(constraint_space, physical_fragment)) { - box_->SetLogicalWidth(fragment.InlineSize()); + box_->SetLogicalWidth(fragment_logical_size.inline_size); } else { - DCHECK_EQ(box_->LogicalWidth(), fragment.InlineSize()) + DCHECK_EQ(box_->LogicalWidth(), fragment_logical_size.inline_size) << "Variable fragment inline size not supported"; logical_height = box_->LogicalHeight(); intrinsic_content_logical_height = box_->IntrinsicContentLogicalHeight(); } - logical_height += fragment.BlockSize(); + logical_height += fragment_logical_size.block_size; intrinsic_content_logical_height += layout_result.IntrinsicBlockSize(); NGBoxStrut border_scrollbar_padding = ComputeBorders(constraint_space, Style()) + @@ -359,8 +362,6 @@ if (box_->IsLayoutBlock() && IsLastFragment(physical_fragment)) { LayoutBlock* block = ToLayoutBlock(box_); - WritingMode writing_mode = constraint_space.GetWritingMode(); - NGBoxFragment fragment(writing_mode, physical_fragment); LayoutUnit intrinsic_block_size = layout_result.IntrinsicBlockSize(); if (constraint_space.HasBlockFragmentation()) { intrinsic_block_size += @@ -569,7 +570,7 @@ // over to LayoutNG yet. // TODO(ikilpatrick): Remove this once the above isn't true. builder.SetExclusionSpace( - WTF::WrapUnique(new NGExclusionSpace(constraint_space.ExclusionSpace()))); + std::make_unique<NGExclusionSpace>(constraint_space.ExclusionSpace())); CopyBaselinesFromOldLayout(constraint_space, &builder); return builder.ToBoxFragment();
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_result.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_result.cc index c3f1506..4b8d353 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_layout_result.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_result.cc
@@ -4,10 +4,12 @@ #include "core/layout/ng/ng_layout_result.h" +#include <memory> +#include <utility> + #include "core/layout/ng/exclusions/ng_exclusion_space.h" #include "core/layout/ng/ng_positioned_float.h" #include "core/layout/ng/ng_unpositioned_float.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -57,9 +59,10 @@ std::unique_ptr<const NGExclusionSpace> exclusion_space; // TODO(layoutng) Replace this with DCHECK(exclusion_space_) when // callers guarantee exclusion_space_ != null. - if (exclusion_space_) - exclusion_space = WTF::WrapUnique(new NGExclusionSpace(*exclusion_space_)); - + if (exclusion_space_) { + std::unique_ptr<const NGExclusionSpace> exclusion_space( + std::make_unique<NGExclusionSpace>(*exclusion_space_)); + } return base::AdoptRef(new NGLayoutResult( physical_fragment_->CloneWithoutOffset(), oof_positioned_descendants, positioned_floats, unpositioned_floats, unpositioned_list_marker_,
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_physical_container_fragment.cc b/third_party/WebKit/Source/core/layout/ng/ng_physical_container_fragment.cc index e6e2121..7a5d510 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_physical_container_fragment.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_physical_container_fragment.cc
@@ -63,6 +63,7 @@ scoped_refptr<NGBreakToken> break_token) : NGPhysicalFragment(layout_object, style, + NGStyleVariant::kStandard, size, type, sub_type,
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.cc b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.cc index 21368fa6..1abe233 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.cc
@@ -5,6 +5,7 @@ #include "core/layout/ng/ng_physical_fragment.h" #include "core/layout/LayoutBlock.h" +#include "core/layout/LayoutObjectInlines.h" #include "core/layout/ng/geometry/ng_border_edges.h" #include "core/layout/ng/geometry/ng_box_strut.h" #include "core/layout/ng/inline/ng_physical_line_box_fragment.h" @@ -182,6 +183,7 @@ NGPhysicalFragment::NGPhysicalFragment(LayoutObject* layout_object, const ComputedStyle& style, + NGStyleVariant style_variant, NGPhysicalSize size, NGFragmentType type, unsigned sub_type, @@ -193,7 +195,8 @@ type_(type), sub_type_(sub_type), is_old_layout_root_(false), - is_placed_(false) {} + is_placed_(false), + style_variant_((unsigned)style_variant) {} // Keep the implementation of the destructor here, to avoid dependencies on // ComputedStyle in the header file. @@ -218,6 +221,16 @@ const ComputedStyle& NGPhysicalFragment::Style() const { DCHECK(style_); + if (!GetLayoutObject()) + return *style_; + switch ((NGStyleVariant)style_variant_) { + case NGStyleVariant::kStandard: + return *GetLayoutObject()->Style(); + case NGStyleVariant::kFirstLine: + return *GetLayoutObject()->FirstLineStyle(); + case NGStyleVariant::kEllipsis: + return *style_; + } return *style_; }
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h index b47b867e1..d3cc4f4 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h +++ b/third_party/WebKit/Source/core/layout/ng/ng_physical_fragment.h
@@ -11,6 +11,7 @@ #include "core/layout/ng/geometry/ng_physical_offset.h" #include "core/layout/ng/geometry/ng_physical_size.h" #include "core/layout/ng/ng_break_token.h" +#include "core/layout/ng/ng_style_variant.h" #include "platform/geometry/LayoutRect.h" namespace blink { @@ -200,6 +201,7 @@ protected: NGPhysicalFragment(LayoutObject* layout_object, const ComputedStyle& style, + NGStyleVariant, NGPhysicalSize size, NGFragmentType type, unsigned sub_type, @@ -216,6 +218,7 @@ unsigned is_old_layout_root_ : 1; unsigned is_placed_ : 1; unsigned border_edge_ : 4; // NGBorderEdges::Physical + unsigned style_variant_ : 2; // NGStyleVariant private: friend struct NGPhysicalFragmentTraits;
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_style_variant.h b/third_party/WebKit/Source/core/layout/ng/ng_style_variant.h new file mode 100644 index 0000000..ffcd06f --- /dev/null +++ b/third_party/WebKit/Source/core/layout/ng/ng_style_variant.h
@@ -0,0 +1,15 @@ +// Copyright 2018 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 ng_style_variant_h +#define ng_style_variant_h + +namespace blink { + +// LayoutObject can have multiple style variations. +enum class NGStyleVariant { kStandard, kFirstLine, kEllipsis }; + +} // namespace blink + +#endif // ng_style_variant_h
diff --git a/third_party/WebKit/Source/core/layout/shapes/RasterShape.cpp b/third_party/WebKit/Source/core/layout/shapes/RasterShape.cpp index ca75caa..48fd80e7 100644 --- a/third_party/WebKit/Source/core/layout/shapes/RasterShape.cpp +++ b/third_party/WebKit/Source/core/layout/shapes/RasterShape.cpp
@@ -29,9 +29,10 @@ #include "core/layout/shapes/RasterShape.h" +#include <algorithm> #include <memory> + #include "platform/wtf/MathExtras.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -78,8 +79,8 @@ ? size() : size() - Offset() * 2 + shape_margin * 2; std::unique_ptr<RasterShapeIntervals> result = - WTF::WrapUnique(new RasterShapeIntervals( - margin_intervals_size, std::max(shape_margin, Offset()))); + std::make_unique<RasterShapeIntervals>(margin_intervals_size, + std::max(shape_margin, Offset())); MarginIntervalGenerator margin_interval_generator(shape_margin); for (int y = Bounds().Y(); y < Bounds().MaxY(); ++y) {
diff --git a/third_party/WebKit/Source/core/layout/shapes/Shape.cpp b/third_party/WebKit/Source/core/layout/shapes/Shape.cpp index 412b4ca..f355bed 100644 --- a/third_party/WebKit/Source/core/layout/shapes/Shape.cpp +++ b/third_party/WebKit/Source/core/layout/shapes/Shape.cpp
@@ -29,7 +29,10 @@ #include "core/layout/shapes/Shape.h" +#include <algorithm> #include <memory> +#include <utility> + #include "core/css/BasicShapeFunctions.h" #include "core/layout/shapes/BoxShape.h" #include "core/layout/shapes/PolygonShape.h" @@ -46,7 +49,6 @@ #include "platform/graphics/paint/PaintCanvas.h" #include "platform/graphics/paint/PaintFlags.h" #include "platform/wtf/MathExtras.h" -#include "platform/wtf/PtrUtil.h" #include "platform/wtf/typed_arrays/ArrayBufferContents.h" #include "public/platform/Platform.h" #include "third_party/skia/include/core/SkSurface.h" @@ -62,26 +64,26 @@ static std::unique_ptr<Shape> CreateCircleShape(const FloatPoint& center, float radius) { DCHECK_GE(radius, 0); - return WTF::WrapUnique( - new RectangleShape(FloatRect(center.X() - radius, center.Y() - radius, - radius * 2, radius * 2), - FloatSize(radius, radius))); + return std::make_unique<RectangleShape>( + FloatRect(center.X() - radius, center.Y() - radius, radius * 2, + radius * 2), + FloatSize(radius, radius)); } static std::unique_ptr<Shape> CreateEllipseShape(const FloatPoint& center, const FloatSize& radii) { DCHECK_GE(radii.Width(), 0); DCHECK_GE(radii.Height(), 0); - return WTF::WrapUnique(new RectangleShape( + return std::make_unique<RectangleShape>( FloatRect(center.X() - radii.Width(), center.Y() - radii.Height(), radii.Width() * 2, radii.Height() * 2), - radii)); + radii); } static std::unique_ptr<Shape> CreatePolygonShape( std::unique_ptr<Vector<FloatPoint>> vertices, WindRule fill_rule) { - return WTF::WrapUnique(new PolygonShape(std::move(vertices), fill_rule)); + return std::make_unique<PolygonShape>(std::move(vertices), fill_rule); } static inline FloatRect PhysicalRectToLogical(const FloatRect& rect, @@ -164,7 +166,7 @@ size_t values_size = values.size(); DCHECK(!(values_size % 2)); std::unique_ptr<Vector<FloatPoint>> vertices = - WTF::WrapUnique(new Vector<FloatPoint>(values_size / 2)); + std::make_unique<Vector<FloatPoint>>(values_size / 2); for (unsigned i = 0; i < values_size; i += 2) { FloatPoint vertex(FloatValueForLength(values.at(i), box_width), FloatValueForLength(values.at(i + 1), box_height)); @@ -225,7 +227,7 @@ std::unique_ptr<RasterShapeIntervals> intervals = std::make_unique<RasterShapeIntervals>(0, 0); std::unique_ptr<RasterShape> raster_shape = - WTF::WrapUnique(new RasterShape(std::move(intervals), IntSize())); + std::make_unique<RasterShape>(std::move(intervals), IntSize()); raster_shape->writing_mode_ = writing_mode; raster_shape->margin_ = margin; return std::move(raster_shape); @@ -288,8 +290,9 @@ int max_buffer_y = std::min(image_rect.Height(), margin_rect.MaxY() - image_rect.Y()); - std::unique_ptr<RasterShapeIntervals> intervals = WTF::WrapUnique( - new RasterShapeIntervals(margin_rect.Height(), -margin_rect.Y())); + std::unique_ptr<RasterShapeIntervals> intervals = + std::make_unique<RasterShapeIntervals>(margin_rect.Height(), + -margin_rect.Y()); for (int y = min_buffer_y; y < max_buffer_y; ++y) { int start_x = -1; @@ -343,8 +346,8 @@ std::unique_ptr<RasterShapeIntervals> intervals = ExtractIntervalsFromImageData(contents, threshold, image_rect, margin_rect); - std::unique_ptr<RasterShape> raster_shape = WTF::WrapUnique( - new RasterShape(std::move(intervals), margin_rect.Size())); + std::unique_ptr<RasterShape> raster_shape = + std::make_unique<RasterShape>(std::move(intervals), margin_rect.Size()); raster_shape->writing_mode_ = writing_mode; raster_shape->margin_ = margin; return std::move(raster_shape);
diff --git a/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h b/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h index cb12ff17..b7c7da80 100644 --- a/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h +++ b/third_party/WebKit/Source/core/layout/shapes/ShapeOutsideInfo.h
@@ -31,11 +31,12 @@ #define ShapeOutsideInfo_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/layout/shapes/Shape.h" #include "core/style/ShapeValue.h" #include "platform/geometry/FloatRect.h" #include "platform/geometry/LayoutSize.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -120,7 +121,7 @@ static std::unique_ptr<ShapeOutsideInfo> CreateInfo( const LayoutBox& layout_box) { - return WTF::WrapUnique(new ShapeOutsideInfo(layout_box)); + return base::WrapUnique(new ShapeOutsideInfo(layout_box)); } static bool IsEnabledFor(const LayoutBox&);
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.cpp index 24c1520..18a2d17 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.cpp
@@ -267,4 +267,9 @@ return transform.MapRect(local_clip_bounds_); } +void LayoutSVGResourceClipper::WillBeDestroyed() { + MarkAllClientsForInvalidation(kBoundariesInvalidation | kPaintInvalidation); + LayoutSVGResourceContainer::WillBeDestroyed(); +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.h index 9c2dc4bf..c2ec6944 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.h +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.h
@@ -62,6 +62,9 @@ in_clip_expansion_ = false; } + protected: + void WillBeDestroyed() override; + private: void CalculateLocalClipBounds();
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceGradient.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceGradient.cpp index e859efb..95bdc54 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceGradient.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceGradient.cpp
@@ -23,7 +23,6 @@ #include "core/layout/svg/LayoutSVGResourceGradient.h" #include <memory> -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -72,7 +71,7 @@ std::unique_ptr<GradientData>& gradient_data = gradient_map_.insert(&object, nullptr).stored_value->value; if (!gradient_data) - gradient_data = WTF::WrapUnique(new GradientData); + gradient_data = std::make_unique<GradientData>(); // Create gradient object if (!gradient_data->gradient) {
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePattern.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePattern.cpp index 419ff13a..87bd542 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePattern.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGResourcePattern.cpp
@@ -23,6 +23,7 @@ #include <memory> +#include "base/memory/ptr_util.h" #include "core/layout/svg/SVGLayoutSupport.h" #include "core/layout/svg/SVGResources.h" #include "core/layout/svg/SVGResourcesCache.h" @@ -34,7 +35,6 @@ #include "platform/graphics/paint/PaintController.h" #include "platform/graphics/paint/PaintRecord.h" #include "platform/graphics/paint/PaintRecordBuilder.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -119,7 +119,7 @@ } } - std::unique_ptr<PatternData> pattern_data = WTF::WrapUnique(new PatternData); + std::unique_ptr<PatternData> pattern_data = base::WrapUnique(new PatternData); pattern_data->pattern = Pattern::CreatePaintRecordPattern( AsPaintRecord(tile_bounds.Size(), tile_transform), FloatRect(FloatPoint(), tile_bounds.Size()));
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp index 411bab8..56bcbe69 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
@@ -283,9 +283,8 @@ // document, or not embedded in a way that supports/allows size negotiation. if (!IsEmbeddedThroughFrameContainingSVGDocument()) return; - IntrinsicSizingInfo sizing_info; - ComputeIntrinsicSizingInfo(sizing_info); - GetFrame()->IntrinsicSizingInfoChanged(sizing_info); + DCHECK(GetFrame()->Owner()); + GetFrame()->Owner()->IntrinsicSizingInfoChanged(); } void LayoutSVGRoot::StyleDidChange(StyleDifference diff, @@ -297,10 +296,7 @@ has_box_decoration_background_ = StyleRef().HasBoxDecorationBackground(); } - // If we previously didn't have any computed style, we wouldn't have been - // able to determine our intrinsic dimensions, so in that case always - // initiate a size negotiation. - if (!old_style || StyleChangeAffectsIntrinsicSize(*old_style)) + if (old_style && StyleChangeAffectsIntrinsicSize(*old_style)) IntrinsicSizingInfoChanged(); LayoutReplaced::StyleDidChange(diff, old_style);
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h index c0c954f..5f271d5d 100644 --- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h +++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h
@@ -22,8 +22,9 @@ #define LayoutSVGTextPath_h #include <memory> + +#include "base/memory/ptr_util.h" #include "core/layout/svg/LayoutSVGInline.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -37,7 +38,7 @@ static std::unique_ptr<PathPositionMapper> Create(const Path& path, float computed_path_length, float start_offset) { - return WTF::WrapUnique( + return base::WrapUnique( new PathPositionMapper(path, computed_path_length, start_offset)); }
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGResources.cpp b/third_party/WebKit/Source/core/layout/svg/SVGResources.cpp index 747df45..0d96518 100644 --- a/third_party/WebKit/Source/core/layout/svg/SVGResources.cpp +++ b/third_party/WebKit/Source/core/layout/svg/SVGResources.cpp
@@ -20,6 +20,8 @@ #include "core/layout/svg/SVGResources.h" #include <memory> +#include <utility> + #include "core/layout/svg/LayoutSVGResourceClipper.h" #include "core/layout/svg/LayoutSVGResourceFilter.h" #include "core/layout/svg/LayoutSVGResourceMarker.h" @@ -32,7 +34,6 @@ #include "core/svg/SVGTreeScopeResources.h" #include "core/svg/SVGURIReference.h" #include "core/svg_names.h" -#include "platform/wtf/PtrUtil.h" #ifndef NDEBUG #include <stdio.h> @@ -178,7 +179,7 @@ static inline SVGResources& EnsureResources( std::unique_ptr<SVGResources>& resources) { if (!resources) - resources = WTF::WrapUnique(new SVGResources); + resources = std::make_unique<SVGResources>(); return *resources.get(); }
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGResources.h b/third_party/WebKit/Source/core/layout/svg/SVGResources.h index 7cb88a9..aa66c01 100644 --- a/third_party/WebKit/Source/core/layout/svg/SVGResources.h +++ b/third_party/WebKit/Source/core/layout/svg/SVGResources.h
@@ -21,11 +21,12 @@ #define SVGResources_h #include <memory> + #include "base/macros.h" +#include "base/memory/ptr_util.h" #include "core/layout/svg/LayoutSVGResourceContainer.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/HashSet.h" -#include "platform/wtf/PtrUtil.h" namespace blink { @@ -135,7 +136,7 @@ : clipper(nullptr), filter(nullptr), masker(nullptr) {} static std::unique_ptr<ClipperFilterMaskerData> Create() { - return WTF::WrapUnique(new ClipperFilterMaskerData); + return base::WrapUnique(new ClipperFilterMaskerData); } LayoutSVGResourceClipper* clipper; @@ -153,7 +154,7 @@ : marker_start(nullptr), marker_mid(nullptr), marker_end(nullptr) {} static std::unique_ptr<MarkerData> Create() { - return WTF::WrapUnique(new MarkerData); + return std::make_unique<MarkerData>(); } LayoutSVGResourceMarker* marker_start; @@ -173,7 +174,7 @@ FillStrokeData() : fill(nullptr), stroke(nullptr) {} static std::unique_ptr<FillStrokeData> Create() { - return WTF::WrapUnique(new FillStrokeData); + return std::make_unique<FillStrokeData>(); } LayoutSVGResourcePaintServer* fill;
diff --git a/third_party/WebKit/Source/core/page/PageWidgetDelegate.cpp b/third_party/WebKit/Source/core/page/PageWidgetDelegate.cpp index 814c041..a52dc62f 100644 --- a/third_party/WebKit/Source/core/page/PageWidgetDelegate.cpp +++ b/third_party/WebKit/Source/core/page/PageWidgetDelegate.cpp
@@ -78,38 +78,31 @@ if (rect.IsEmpty()) return; - PaintRecordBuilder builder; - { - GraphicsContext& paint_context = builder.Context(); + // FIXME: device scale factor settings are layering violations and should + // not be used within Blink paint code. + float scale_factor = page.DeviceScaleFactorDeprecated(); + canvas->save(); + canvas->scale(scale_factor, scale_factor); - // FIXME: device scale factor settings are layering violations and should - // not be used within Blink paint code. - float scale_factor = page.DeviceScaleFactorDeprecated(); - paint_context.SetDeviceScaleFactor(scale_factor); + IntRect dirty_rect(rect); + LocalFrameView* view = root.View(); + if (view) { + DCHECK(view->GetLayoutView()->GetDocument().Lifecycle().GetState() == + DocumentLifecycle::kPaintClean); + canvas->clipRect(dirty_rect); - AffineTransform scale; - scale.Scale(scale_factor); - TransformRecorder scale_recorder(paint_context, builder, scale); - - IntRect dirty_rect(rect); - LocalFrameView* view = root.View(); - if (view) { - DCHECK(view->GetLayoutView()->GetDocument().Lifecycle().GetState() == - DocumentLifecycle::kPaintClean); - ClipRecorder clip_recorder(paint_context, builder, - DisplayItem::kPageWidgetDelegateClip, - dirty_rect); - view->PaintWithLifecycleUpdate(paint_context, global_paint_flags, - CullRect(dirty_rect)); - } else { - DrawingRecorder recorder( - paint_context, builder, - DisplayItem::kPageWidgetDelegateBackgroundFallback); - paint_context.FillRect(dirty_rect, Color::kWhite); - } + PaintRecordBuilder builder; + builder.Context().SetDeviceScaleFactor(scale_factor); + view->PaintWithLifecycleUpdate(builder.Context(), global_paint_flags, + CullRect(dirty_rect)); + builder.EndRecording(*canvas); + } else { + PaintFlags flags; + flags.setColor(SK_ColorWHITE); + canvas->drawRect(dirty_rect, flags); } - builder.EndRecording(*canvas); + canvas->restore(); } void PageWidgetDelegate::Paint(Page& page,
diff --git a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp index 923591c..1c03d82 100644 --- a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp +++ b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
@@ -308,13 +308,10 @@ squashing_layer->SetNeedsDisplayInRect(EnclosingIntRect(rect), reason, object_); } - } else if (object_.CompositedScrollsWithRespectTo( - paint_invalidation_container)) { - layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect( - rect, reason, object_); } else if (paint_invalidation_container.UsesCompositedScrolling()) { - DCHECK(object_ == paint_invalidation_container); - if (reason == + // If object_ is not paint_invalidation_container, then it scrolls. + if (&object_ != paint_invalidation_container || + reason == PaintInvalidationReason::kBackgroundOnScrollingContentsLayer || reason == PaintInvalidationReason::kCaret) { layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect(
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp index 5fa31d1..dc0c2f6 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -101,7 +101,7 @@ struct SameSizeAsPaintLayer : DisplayItemClient { int bit_fields; - void* pointers[11]; + void* pointers[10]; LayoutUnit layout_units[4]; IntSize size; Persistent<PaintLayerScrollableArea> scrollable_area; @@ -109,6 +109,11 @@ IntSize size; LayoutRect rect; } previous_paint_status; + + struct { + void* pointers[10]; + IntRect int_rects[2]; + } ancestor_dependent_compositing_inputs; }; static_assert(sizeof(PaintLayer) == sizeof(SameSizeAsPaintLayer), @@ -1083,8 +1088,7 @@ void PaintLayer::UpdateAncestorDependentCompositingInputs( const AncestorDependentCompositingInputs& compositing_inputs) { - ancestor_dependent_compositing_inputs_ = - std::make_unique<AncestorDependentCompositingInputs>(compositing_inputs); + ancestor_dependent_compositing_inputs_ = compositing_inputs; needs_ancestor_dependent_compositing_inputs_update_ = false; }
diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.h b/third_party/WebKit/Source/core/paint/PaintLayer.h index 80c99ff..f00f9d41 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayer.h +++ b/third_party/WebKit/Source/core/paint/PaintLayer.h
@@ -695,31 +695,19 @@ CompositingReason::kComboAllDirectStyleDeterminedReasons; } - class AncestorDependentCompositingInputs { + struct AncestorDependentCompositingInputs { public: - AncestorDependentCompositingInputs() - : opacity_ancestor(nullptr), - transform_ancestor(nullptr), - filter_ancestor(nullptr), - clip_path_ancestor(nullptr), - mask_ancestor(nullptr), - ancestor_scrolling_layer(nullptr), - nearest_fixed_position_layer(nullptr), - scroll_parent(nullptr), - clip_parent(nullptr), - clipping_container(nullptr) {} - - const PaintLayer* opacity_ancestor; - const PaintLayer* transform_ancestor; - const PaintLayer* filter_ancestor; - const PaintLayer* clip_path_ancestor; - const PaintLayer* mask_ancestor; + const PaintLayer* opacity_ancestor = nullptr; + const PaintLayer* transform_ancestor = nullptr; + const PaintLayer* filter_ancestor = nullptr; + const PaintLayer* clip_path_ancestor = nullptr; + const PaintLayer* mask_ancestor = nullptr; // The fist ancestor which can scroll. This is a subset of the // ancestorOverflowLayer chain where the scrolling layer is visible and // has a larger scroll content than its bounds. - const PaintLayer* ancestor_scrolling_layer; - const PaintLayer* nearest_fixed_position_layer; + const PaintLayer* ancestor_scrolling_layer = nullptr; + const PaintLayer* nearest_fixed_position_layer = nullptr; // A scroll parent is a compositor concept. It's only needed in blink // because we need to use it as a promotion trigger. A layer has a @@ -727,18 +715,18 @@ // other layer scrolled by this ancestor, is a stacking ancestor of this // layer. Layers with scroll parents must be scrolled with the main // scrolling layer by the compositor. - const PaintLayer* scroll_parent; + const PaintLayer* scroll_parent = nullptr; // A clip parent is another compositor concept that has leaked into // blink so that it may be used as a promotion trigger. Layers with clip // parents escape the clip of a stacking tree ancestor. The compositor // needs to know about clip parents in order to circumvent its normal // clipping logic. - const PaintLayer* clip_parent; + const PaintLayer* clip_parent = nullptr; IntRect clipped_absolute_bounding_box; IntRect unclipped_absolute_bounding_box; - const LayoutBoxModelObject* clipping_container; + const LayoutBoxModelObject* clipping_container = nullptr; }; void SetNeedsCompositingInputsUpdate(); @@ -756,82 +744,54 @@ const AncestorDependentCompositingInputs&); void DidUpdateCompositingInputs(); - const IntRect& ClippedAbsoluteBoundingBox() const { + const AncestorDependentCompositingInputs& + GetAncestorDependentCompositingInputs() const { DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ->clipped_absolute_bounding_box; + return ancestor_dependent_compositing_inputs_; + } + const IntRect& ClippedAbsoluteBoundingBox() const { + return GetAncestorDependentCompositingInputs() + .clipped_absolute_bounding_box; } const IntRect& UnclippedAbsoluteBoundingBox() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ->unclipped_absolute_bounding_box; + return GetAncestorDependentCompositingInputs() + .unclipped_absolute_bounding_box; } const PaintLayer* OpacityAncestor() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->opacity_ancestor - : nullptr; + return GetAncestorDependentCompositingInputs().opacity_ancestor; } const PaintLayer* TransformAncestor() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->transform_ancestor - : nullptr; + return GetAncestorDependentCompositingInputs().transform_ancestor; } const PaintLayer& TransformAncestorOrRoot() const; const PaintLayer* FilterAncestor() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->filter_ancestor - : nullptr; + return GetAncestorDependentCompositingInputs().filter_ancestor; } const LayoutBoxModelObject* ClippingContainer() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_->clipping_container; + return GetAncestorDependentCompositingInputs().clipping_container; } const PaintLayer* AncestorOverflowLayer() const { return ancestor_overflow_layer_; } const PaintLayer* AncestorScrollingLayer() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_ - ->ancestor_scrolling_layer - : nullptr; + return GetAncestorDependentCompositingInputs().ancestor_scrolling_layer; } const PaintLayer* NearestFixedPositionLayer() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_ - ->nearest_fixed_position_layer - : nullptr; + return GetAncestorDependentCompositingInputs().nearest_fixed_position_layer; } const PaintLayer* ScrollParent() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->scroll_parent - : nullptr; + return GetAncestorDependentCompositingInputs().scroll_parent; } const PaintLayer* ClipParent() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->clip_parent - : nullptr; + return GetAncestorDependentCompositingInputs().clip_parent; } const PaintLayer* ClipPathAncestor() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->clip_path_ancestor - : nullptr; + return GetAncestorDependentCompositingInputs().clip_path_ancestor; } const PaintLayer* MaskAncestor() const { - DCHECK(!needs_ancestor_dependent_compositing_inputs_update_); - return ancestor_dependent_compositing_inputs_ - ? ancestor_dependent_compositing_inputs_->mask_ancestor - : nullptr; + return GetAncestorDependentCompositingInputs().mask_ancestor; } bool HasDescendantWithClipPath() const { - DCHECK(!needs_descendant_dependent_flags_update_); return has_descendant_with_clip_path_; } @@ -1290,8 +1250,7 @@ // The first ancestor having a non visible overflow. const PaintLayer* ancestor_overflow_layer_; - std::unique_ptr<AncestorDependentCompositingInputs> - ancestor_dependent_compositing_inputs_; + AncestorDependentCompositingInputs ancestor_dependent_compositing_inputs_; Persistent<PaintLayerScrollableArea> scrollable_area_;
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp index 5f179d6..aa350e9 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
@@ -2140,14 +2140,6 @@ return page->GetScrollingCoordinator(); } -bool PaintLayerScrollableArea::UsesCompositedScrolling() const { - // See https://codereview.chromium.org/176633003/ for the tests that fail - // without this disabler. - DisableCompositingQueryAsserts disabler; - return Layer()->HasCompositedLayerMapping() && - Layer()->GetCompositedLayerMapping()->ScrollingLayer(); -} - bool PaintLayerScrollableArea::ShouldScrollOnMainThread() const { if (HasBeenDisposed()) return true;
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h index 43e8e5f..f779af5 100644 --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
@@ -265,7 +265,6 @@ GraphicsLayer* LayerForVerticalScrollbar() const override; GraphicsLayer* LayerForScrollCorner() const override; - bool UsesCompositedScrolling() const override; bool ShouldScrollOnMainThread() const override; bool ShouldUseIntegerScrollOffset() const override; bool IsActive() const override;
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp index a931b08..1661f7b 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp
@@ -822,6 +822,7 @@ } else { OnClear(properties_->ClearEffect()); OnClear(properties_->ClearMask()); + OnClear(properties_->ClearClipPath()); OnClearClip(properties_->ClearMaskClip()); } }
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp index cbd6651..c17164c 100644 --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -5243,4 +5243,38 @@ EXPECT_TRUE(root.FirstFragment().PaintProperties()->Mask()); } +TEST_P(PaintPropertyTreeBuilderTest, ClearClipPathEffectNode) { + // This test makes sure ClipPath effect node is cleared properly upon + // removal of a clip-path. + + // SPv1 has no effect tree. + if (!RuntimeEnabledFeatures::SlimmingPaintV175Enabled()) + return; + SetBodyInnerHTML(R"HTML( + <svg> + <clipPath clip-path="circle()" id="clip"></clipPath> + <rect id="rect" width="800" clip-path="url(#clip)" height="800"/> + </svg> + )HTML"); + + { + const auto* rect = GetLayoutObjectByElementId("rect"); + ASSERT_TRUE(rect); + EXPECT_TRUE(rect->FirstFragment().PaintProperties()->MaskClip()); + EXPECT_TRUE(rect->FirstFragment().PaintProperties()->ClipPath()); + } + + Element* clip = GetDocument().getElementById("clip"); + ASSERT_TRUE(clip); + clip->remove(); + GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); + + { + const auto* rect = GetLayoutObjectByElementId("rect"); + ASSERT_TRUE(rect); + EXPECT_FALSE(rect->FirstFragment().PaintProperties()->MaskClip()); + EXPECT_FALSE(rect->FirstFragment().PaintProperties()->ClipPath()); + } +} + } // namespace blink
diff --git a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp index cf4b24ec8..03c6f1c 100644 --- a/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp +++ b/third_party/WebKit/Source/core/paint/compositing/CompositedLayerMapping.cpp
@@ -2553,6 +2553,8 @@ owning_layer_.GetScrollingCoordinator(); auto* scrollable_area = owning_layer_.GetScrollableArea(); + if (scrollable_area) + scrollable_area->SetUsesCompositedScrolling(needs_scrolling_layers); bool layer_changed = false; if (needs_scrolling_layers) {
diff --git a/third_party/WebKit/Source/core/paint/compositing/PaintLayerCompositor.cpp b/third_party/WebKit/Source/core/paint/compositing/PaintLayerCompositor.cpp index b41e263..8e43953 100644 --- a/third_party/WebKit/Source/core/paint/compositing/PaintLayerCompositor.cpp +++ b/third_party/WebKit/Source/core/paint/compositing/PaintLayerCompositor.cpp
@@ -111,6 +111,10 @@ else DestroyRootLayer(); + LocalFrameView* view = layout_view_.GetFrameView(); + view->SetUsesCompositedScrolling( + view->GetFrame().GetSettings()->GetPreferCompositingToLCDTextEnabled()); + // Schedule an update in the parent frame so the <iframe>'s layer in the owner // document matches the compositing state here. if (HTMLFrameOwnerElement* owner_element =
diff --git a/third_party/WebKit/Source/core/paint/ng/ng_box_fragment_painter.cc b/third_party/WebKit/Source/core/paint/ng/ng_box_fragment_painter.cc index 139b75b..0e455bd 100644 --- a/third_party/WebKit/Source/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/WebKit/Source/core/paint/ng/ng_box_fragment_painter.cc
@@ -85,7 +85,7 @@ adjustment.AdjustedPaintOffset()); return; } - + DCHECK_EQ(layout_object->Style(), &PhysicalFragment().Style()); AdjustPaintOffsetScope adjustment(box_fragment_, paint_info, paint_offset); PaintWithAdjustedOffset(adjustment.MutablePaintInfo(), adjustment.AdjustedPaintOffset());
diff --git a/third_party/WebKit/Source/core/paint/ng/ng_fragment_painter.cc b/third_party/WebKit/Source/core/paint/ng/ng_fragment_painter.cc index c209bb3c..8e7296b2 100644 --- a/third_party/WebKit/Source/core/paint/ng/ng_fragment_painter.cc +++ b/third_party/WebKit/Source/core/paint/ng/ng_fragment_painter.cc
@@ -64,11 +64,11 @@ // Collect and group outline rects. for (auto& paint_descendant : NGPaintFragmentTraversal::DescendantsOf(paint_fragment_)) { - const ComputedStyle& descendant_style = paint_descendant.fragment->Style(); if (!paint_descendant.fragment->PhysicalFragment().IsBox() || paint_descendant.fragment->PhysicalFragment().IsAtomicInline()) continue; + const ComputedStyle& descendant_style = paint_descendant.fragment->Style(); if (!descendant_style.HasOutline() || descendant_style.Visibility() != EVisibility::kVisible) continue;
diff --git a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp index 6f4e01a..9903fe1 100644 --- a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp
@@ -518,6 +518,13 @@ return IsValid() && Element::LayoutObjectIsNeeded(style); } +void SVGSVGElement::AttachLayoutTree(AttachContext& context) { + SVGGraphicsElement::AttachLayoutTree(context); + + if (GetLayoutObject() && GetLayoutObject()->IsSVGRoot()) + ToLayoutSVGRoot(GetLayoutObject())->IntrinsicSizingInfoChanged(); +} + LayoutObject* SVGSVGElement::CreateLayoutObject(const ComputedStyle&) { if (IsOutermostSVGSVGElement()) return new LayoutSVGRoot(this);
diff --git a/third_party/WebKit/Source/core/svg/SVGSVGElement.h b/third_party/WebKit/Source/core/svg/SVGSVGElement.h index 41a9e9a..b60a091 100644 --- a/third_party/WebKit/Source/core/svg/SVGSVGElement.h +++ b/third_party/WebKit/Source/core/svg/SVGSVGElement.h
@@ -128,6 +128,7 @@ const AtomicString&, MutableCSSPropertyValueSet*) override; + void AttachLayoutTree(AttachContext&) override; bool LayoutObjectIsNeeded(const ComputedStyle&) override; LayoutObject* CreateLayoutObject(const ComputedStyle&) override;
diff --git a/third_party/WebKit/Source/devtools/BUILD.gn b/third_party/WebKit/Source/devtools/BUILD.gn index 952b922..9e7b4bf 100644 --- a/third_party/WebKit/Source/devtools/BUILD.gn +++ b/third_party/WebKit/Source/devtools/BUILD.gn
@@ -1048,7 +1048,6 @@ "$resources_out_dir/cm_modes/cm_modes_module.js", "$resources_out_dir/emulated_devices/emulated_devices_module.js", "$resources_out_dir/product_registry_impl/product_registry_impl_module.js", - "$resources_out_dir/screencast/screencast_module.js", ] devtools_applications = [
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js index 19452451..728c0ee17 100644 --- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js +++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js
@@ -1086,6 +1086,8 @@ break; case SDK.ConsoleMessage.MessageLevel.Info: this._element.classList.add('console-info-level'); + if (this._message.type === SDK.ConsoleMessage.MessageType.System) + this._element.classList.add('console-system-type'); break; case SDK.ConsoleMessage.MessageLevel.Warning: this._element.classList.add('console-warning-level');
diff --git a/third_party/WebKit/Source/devtools/front_end/console/consoleView.css b/third_party/WebKit/Source/devtools/front_end/console/consoleView.css index ed1612b..98567435 100644 --- a/third_party/WebKit/Source/devtools/front_end/console/consoleView.css +++ b/third_party/WebKit/Source/devtools/front_end/console/consoleView.css
@@ -256,12 +256,17 @@ color: red !important; } +.console-system-type.console-info-level { + color: blue; +} + .-theme-with-dark-background .console-error-level .console-message-text, .-theme-with-dark-background .console-error-level .console-view-object-properties-section { color: hsl(0, 100%, 75%) !important; } -.-theme-with-dark-background .console-verbose-level .console-message-text { +.-theme-with-dark-background .console-verbose-level:not(.console-warning-level) .console-message-text, +.-theme-with-dark-background .console-system-type.console-info-level { color: hsl(220, 100%, 65%) !important; }
diff --git a/third_party/WebKit/Source/devtools/front_end/inspector.json b/third_party/WebKit/Source/devtools/front_end/inspector.json index 36c222f5..dc2149a 100644 --- a/third_party/WebKit/Source/devtools/front_end/inspector.json +++ b/third_party/WebKit/Source/devtools/front_end/inspector.json
@@ -1,6 +1,6 @@ { "modules" : [ - { "name": "screencast", "type": "remote" } + { "name": "screencast", "type": "autostart" } ], "extends": "devtools_app", "has_html": true
diff --git a/third_party/WebKit/Source/devtools/front_end/main/Main.js b/third_party/WebKit/Source/devtools/front_end/main/Main.js index 4c9d9aa..e6d73b18 100644 --- a/third_party/WebKit/Source/devtools/front_end/main/Main.js +++ b/third_party/WebKit/Source/devtools/front_end/main/Main.js
@@ -212,19 +212,8 @@ this._registerForwardedShortcuts(); this._registerMessageSinkListener(); - // Pick first app we could instantiate (for test harness). - for (const extension of self.runtime.extensions(Common.AppProvider)) { - try { - const instance = await extension.instance(); - if (instance) { - this._showAppUI(instance); - break; - } - } catch (e) { - console.error(e); - } - } Main.Main.timeEnd('Main._createAppUI'); + this._showAppUI(await self.runtime.extension(Common.AppProvider).instance()); } /**
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp index a4495d8..af64deb 100644 --- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp +++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
@@ -558,10 +558,6 @@ // client->DidClose may delete this object. } -ThreadableLoadingContext* DocumentWebSocketChannel::LoadingContext() { - return loading_context_; -} - Document* DocumentWebSocketChannel::GetDocument() { ExecutionContext* context = loading_context_->GetExecutionContext(); if (context->IsDocument())
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.h b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.h index 2950871..6d83b098 100644 --- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.h +++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.h
@@ -55,7 +55,6 @@ namespace blink { -class ThreadableLoadingContext; class WebSocketHandshakeRequest; class WebSocketHandshakeThrottle; @@ -152,7 +151,6 @@ void HandleDidClose(bool was_clean, unsigned short code, const String& reason); - ThreadableLoadingContext* LoadingContext(); // This may return nullptr. // TODO(kinuko): Remove dependency to document.
diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn index 7ba42d3..c246cc8 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn
@@ -229,7 +229,7 @@ } buildflag_header("rcs_count_everything") { - header = "RuntimeCallStatsCountEverything.h" + header = "runtime_call_stats_count_everything.h" header_dir = "blink/platform/bindings"
diff --git a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h index 72464ed7..33b1cb7 100644 --- a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h +++ b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h
@@ -9,7 +9,7 @@ #define RuntimeCallStats_h #include "platform/PlatformExport.h" -#include "platform/bindings/RuntimeCallStatsCountEverything.h" +#include "platform/bindings/runtime_call_stats_count_everything.h" #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/instrumentation/tracing/TracedValue.h" #include "platform/runtime_enabled_features.h"
diff --git a/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.cpp b/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.cpp index 02eeadb..fdbe83e 100644 --- a/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.cpp +++ b/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.cpp
@@ -11,10 +11,11 @@ namespace blink { -v8::Local<v8::Value> V8PrivateProperty::Symbol::GetFromMainWorld( +v8::MaybeLocal<v8::Value> V8PrivateProperty::Symbol::GetFromMainWorld( ScriptWrappable* script_wrappable) { v8::Local<v8::Object> wrapper = script_wrappable->MainWorldWrapper(isolate_); - return wrapper.IsEmpty() ? v8::Local<v8::Value>() : GetOrEmpty(wrapper); + return wrapper.IsEmpty() ? v8::MaybeLocal<v8::Value>() + : GetOrUndefined(wrapper); } v8::Local<v8::Private> V8PrivateProperty::CreateV8Private(v8::Isolate* isolate,
diff --git a/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.h b/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.h index e1f99ed..19c62ba7 100644 --- a/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.h +++ b/third_party/WebKit/Source/platform/bindings/V8PrivateProperty.h
@@ -77,7 +77,8 @@ // Usage 1) Fast path to use a pre-registered symbol. // auto private = V8PrivateProperty::getMessageEventCachedData(isolate); // v8::Local<v8::Object> object = ...; -// v8::Local<v8::Value> value = private.getOrUndefined(object); +// v8::Local<v8::Value> value; +// if (!private.GetOrUndefined(object).ToLocal(&value)) return; // value = ...; // private.set(object, value); // @@ -109,16 +110,9 @@ } // Returns the value of the private property if set, or undefined. - v8::Local<v8::Value> GetOrUndefined(v8::Local<v8::Object> object) const { - return object->GetPrivate(GetContext(), private_symbol_).ToLocalChecked(); - } - - // TODO(peria): Remove this method, and use getOrUndefined() instead. - // Returns the value of the private property if set, or an empty handle. - v8::Local<v8::Value> GetOrEmpty(v8::Local<v8::Object> object) const { - if (HasValue(object)) - return GetOrUndefined(object); - return v8::Local<v8::Value>(); + WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> GetOrUndefined( + v8::Local<v8::Object> object) const { + return object->GetPrivate(GetContext(), private_symbol_); } bool Set(v8::Local<v8::Object> object, v8::Local<v8::Value> value) const { @@ -148,7 +142,8 @@ } // Only friend classes are allowed to use this API. - v8::Local<v8::Value> GetFromMainWorld(ScriptWrappable*); + WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> GetFromMainWorld( + ScriptWrappable*); v8::Local<v8::Private> private_symbol_; v8::Isolate* isolate_;
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.cpp b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.cpp index 6a9eeb78..6854e4b27 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.cpp +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.cpp
@@ -80,7 +80,6 @@ DEBUG_STRING_CASE(LinkHighlight); DEBUG_STRING_CASE(ImageAreaFocusRing); DEBUG_STRING_CASE(PageOverlay); - DEBUG_STRING_CASE(PageWidgetDelegateBackgroundFallback); DEBUG_STRING_CASE(PopupContainerBorder); DEBUG_STRING_CASE(PopupListBoxBackground); DEBUG_STRING_CASE(PopupListBoxRow); @@ -152,7 +151,6 @@ DEBUG_STRING_CASE(ClipPopupListBoxFrame); DEBUG_STRING_CASE(ClipScrollbarsToBoxBounds); DEBUG_STRING_CASE(ClipSelectionImage); - DEBUG_STRING_CASE(PageWidgetDelegateClip); DEFAULT_CASE; } }
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h index 6be647f..949cc9c6 100644 --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h
@@ -83,7 +83,6 @@ kLinkHighlight, kImageAreaFocusRing, kPageOverlay, - kPageWidgetDelegateBackgroundFallback, kPopupContainerBorder, kPopupListBoxBackground, kPopupListBoxRow, @@ -140,8 +139,7 @@ kClipPopupListBoxFrame, kClipScrollbarsToBoxBounds, kClipSelectionImage, - kPageWidgetDelegateClip, - kClipLast = kPageWidgetDelegateClip, + kClipLast = kClipSelectionImage, kEndClipFirst, kEndClipLast = kEndClipFirst + kClipLast - kClipFirst,
diff --git a/third_party/WebKit/Source/platform/heap/BUILD.gn b/third_party/WebKit/Source/platform/heap/BUILD.gn index 1340276..c711356 100644 --- a/third_party/WebKit/Source/platform/heap/BUILD.gn +++ b/third_party/WebKit/Source/platform/heap/BUILD.gn
@@ -16,7 +16,7 @@ } buildflag_header("blink_heap_flags") { - header = "HeapFlags.h" + header = "heap_flags.h" header_dir = "blink/platform/heap" flags = [
diff --git a/third_party/WebKit/Source/platform/heap/HeapAllocator.h b/third_party/WebKit/Source/platform/heap/HeapAllocator.h index 6e3185e..12182fb 100644 --- a/third_party/WebKit/Source/platform/heap/HeapAllocator.h +++ b/third_party/WebKit/Source/platform/heap/HeapAllocator.h
@@ -7,10 +7,10 @@ #include "build/build_config.h" #include "platform/heap/Heap.h" -#include "platform/heap/HeapFlags.h" #include "platform/heap/MarkingVisitor.h" #include "platform/heap/Persistent.h" #include "platform/heap/TraceTraits.h" +#include "platform/heap/heap_flags.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/Assertions.h" #include "platform/wtf/ConstructTraits.h"
diff --git a/third_party/WebKit/Source/platform/heap/IncrementalMarkingTest.cpp b/third_party/WebKit/Source/platform/heap/IncrementalMarkingTest.cpp index 534f60a..705f047 100644 --- a/third_party/WebKit/Source/platform/heap/IncrementalMarkingTest.cpp +++ b/third_party/WebKit/Source/platform/heap/IncrementalMarkingTest.cpp
@@ -9,13 +9,13 @@ #include "platform/heap/GarbageCollected.h" #include "platform/heap/Heap.h" #include "platform/heap/HeapAllocator.h" -#include "platform/heap/HeapFlags.h" #include "platform/heap/HeapTerminatedArray.h" #include "platform/heap/HeapTerminatedArrayBuilder.h" #include "platform/heap/Member.h" #include "platform/heap/ThreadState.h" #include "platform/heap/TraceTraits.h" #include "platform/heap/Visitor.h" +#include "platform/heap/heap_flags.h" #include "testing/gtest/include/gtest/gtest.h" #if BUILDFLAG(BLINK_HEAP_INCREMENTAL_MARKING)
diff --git a/third_party/WebKit/Source/platform/heap/Member.h b/third_party/WebKit/Source/platform/heap/Member.h index 57cf87e..abe96b55 100644 --- a/third_party/WebKit/Source/platform/heap/Member.h +++ b/third_party/WebKit/Source/platform/heap/Member.h
@@ -6,8 +6,8 @@ #define Member_h #include "platform/heap/Heap.h" -#include "platform/heap/HeapFlags.h" #include "platform/heap/HeapPage.h" +#include "platform/heap/heap_flags.h" #include "platform/wtf/Allocator.h" #include "platform/wtf/HashFunctions.h" #include "platform/wtf/HashTraits.h"
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp index dc029b8..607b6b96 100644 --- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp +++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -48,11 +48,11 @@ #include "platform/heap/Handle.h" #include "platform/heap/Heap.h" #include "platform/heap/HeapCompact.h" -#include "platform/heap/HeapFlags.h" #include "platform/heap/MarkingVisitor.h" #include "platform/heap/PagePool.h" #include "platform/heap/SafePoint.h" #include "platform/heap/Visitor.h" +#include "platform/heap/heap_flags.h" #include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/instrumentation/tracing/web_memory_allocator_dump.h" #include "platform/instrumentation/tracing/web_process_memory_dump.h"
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp index 5b5d5163..4033006 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp +++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.cpp
@@ -87,7 +87,8 @@ scrollbars_hidden_(false), scrollbar_captured_(false), mouse_over_scrollbar_(false), - needs_show_scrollbar_layers_(false) {} + needs_show_scrollbar_layers_(false), + uses_composited_scrolling_(false) {} ScrollableArea::~ScrollableArea() = default;
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollableArea.h b/third_party/WebKit/Source/platform/scroll/ScrollableArea.h index b2afaf5..7a3dcd5 100644 --- a/third_party/WebKit/Source/platform/scroll/ScrollableArea.h +++ b/third_party/WebKit/Source/platform/scroll/ScrollableArea.h
@@ -277,7 +277,12 @@ virtual void RegisterForAnimation() {} virtual void DeregisterForAnimation() {} - virtual bool UsesCompositedScrolling() const { return false; } + virtual bool UsesCompositedScrolling() const { + return uses_composited_scrolling_; + } + void SetUsesCompositedScrolling(bool uses_composited_scrolling) { + uses_composited_scrolling_ = uses_composited_scrolling; + } virtual bool ShouldScrollOnMainThread() const; // Overlay scrollbars can "fade-out" when inactive. @@ -492,6 +497,7 @@ // Indicates that the next compositing update needs to call // WebLayer::showScrollbars on our scroll layer. Ignored if not composited. unsigned needs_show_scrollbar_layers_ : 1; + unsigned uses_composited_scrolling_ : 1; // There are 6 possible combinations of writing mode and direction. Scroll // origin will be non-zero in the x or y axis if there is any reversed
diff --git a/third_party/widevine/cdm/widevine_cdm_common.h b/third_party/widevine/cdm/widevine_cdm_common.h index 6fd8fe58..c20c624 100644 --- a/third_party/widevine/cdm/widevine_cdm_common.h +++ b/third_party/widevine/cdm/widevine_cdm_common.h
@@ -32,10 +32,6 @@ "Enables Widevine licenses for playback of HTML audio/video content."; #if BUILDFLAG(ENABLE_LIBRARY_CDMS) -const char kWidevineCdmPluginMimeType[] = "application/x-ppapi-widevine-cdm"; -const char kWidevineCdmPluginMimeTypeDescription[] = - "Widevine Content Decryption Module"; - // Identifier used by the PluginPrivateFileSystem to identify the files stored // for the Widevine CDM. This is used to store persistent files. As the files // were initially used by the CDM running as a pepper plugin, this ID is based @@ -46,16 +42,6 @@ // Name of the CDM library. const char kWidevineCdmLibraryName[] = "widevinecdm"; -// File name of the adapter on different platforms. -const char kWidevineCdmAdapterFileName[] = -#if defined(OS_MACOSX) - "widevinecdmadapter.plugin"; -#elif defined(OS_WIN) - "widevinecdmadapter.dll"; -#else // OS_LINUX, etc. - "libwidevinecdmadapter.so"; -#endif - #if defined(OS_MACOSX) || defined(OS_WIN) // CDM is installed by the component installer instead of the Chrome installer. #define WIDEVINE_CDM_IS_COMPONENT
diff --git a/tools/android/loading/device_setup.py b/tools/android/loading/device_setup.py index 16abfa6..cfa19bf0 100644 --- a/tools/android/loading/device_setup.py +++ b/tools/android/loading/device_setup.py
@@ -360,6 +360,11 @@ def RemoteSpeedIndexRecorder(device, connection, local_output_path): """Records on a device a video compatible for speed-index computation. + Note: + Chrome should be opened with the --disable-infobars command line argument to + avoid web page viewport size to be changed, that can change speed-index + value. + Args: device: (device_utils.DeviceUtils) Android device to connect to. connection: devtools connection.
diff --git a/tools/android/loading/sandwich_runner.py b/tools/android/loading/sandwich_runner.py index cb2a80d..5c3bb949 100644 --- a/tools/android/loading/sandwich_runner.py +++ b/tools/android/loading/sandwich_runner.py
@@ -331,6 +331,7 @@ self._chrome_ctl = controller.RemoteChromeController(self.android_device) else: self._chrome_ctl = controller.LocalChromeController() + self._chrome_ctl.AddChromeArguments(['--disable-infobars']) self._chrome_ctl.AddChromeArguments(self.chrome_args) if self.cache_operation == CacheOperation.SAVE: self._chrome_ctl.SetSlowDeath()
diff --git a/tools/bisect_repackage/bisect_repackage.py b/tools/bisect_repackage/bisect_repackage.py index d4c51d4..22b1bfb 100644 --- a/tools/bisect_repackage/bisect_repackage.py +++ b/tools/bisect_repackage/bisect_repackage.py
@@ -235,7 +235,13 @@ remote_file_path = '%s/%s_%s.zip' % (context.original_remote_path, context.file_prefix, revision_map[cp_num]) - cloud_storage.Get(context.original_gs_bucket, remote_file_path, zip_file_name) + try: + cloud_storage.Get(context.original_gs_bucket, + remote_file_path, zip_file_name) + except Exception, e: + logging.warning('Failed to download: %s, error: %s', zip_file_name, e) + return False + return True def upload_build(zip_file, context): @@ -247,14 +253,8 @@ def download_revision_map(context): """Downloads the revision map in original_gs_url in context.""" download_file = '%s/%s' % (context.repackage_remote_path, REVISION_MAP_FILE) - try: - cloud_storage.Get(context.original_gs_bucket, - remote_file_path, zip_file_name) - except Exception, e: - logging.warning('Failed to download: %s, error: %s', zip_file_name, e) - return False - return True - + cloud_storage.Get(context.repackage_gs_bucket, download_file, + context.revision_file) def get_revision_map(context): """Downloads and returns the revision map in repackage_gs_url in context."""
diff --git a/tools/gn/build_settings.cc b/tools/gn/build_settings.cc index 38b830f..79b8365 100644 --- a/tools/gn/build_settings.cc +++ b/tools/gn/build_settings.cc
@@ -49,6 +49,11 @@ return dir.Resolve(root_path_).NormalizePathSeparatorsTo('/'); } +base::FilePath BuildSettings::GetFullPath(const std::string& path, + bool as_file) const { + return ResolvePath(path, as_file, root_path_).NormalizePathSeparatorsTo('/'); +} + base::FilePath BuildSettings::GetFullPathSecondary( const SourceFile& file) const { return file.Resolve(secondary_source_path_).NormalizePathSeparatorsTo('/'); @@ -59,6 +64,12 @@ return dir.Resolve(secondary_source_path_).NormalizePathSeparatorsTo('/'); } +base::FilePath BuildSettings::GetFullPathSecondary(const std::string& path, + bool as_file) const { + return ResolvePath(path, as_file, secondary_source_path_) + .NormalizePathSeparatorsTo('/'); +} + void BuildSettings::ItemDefined(std::unique_ptr<Item> item) const { DCHECK(item); if (!item_defined_callback_.is_null())
diff --git a/tools/gn/build_settings.h b/tools/gn/build_settings.h index 670f996a..52f3625 100644 --- a/tools/gn/build_settings.h +++ b/tools/gn/build_settings.h
@@ -79,12 +79,21 @@ // root source tree. base::FilePath GetFullPath(const SourceFile& file) const; base::FilePath GetFullPath(const SourceDir& dir) const; + // Works the same way as other GetFullPath. + // Parameter as_file defines whether path should be treated as a + // SourceFile or SourceDir value. + base::FilePath GetFullPath(const std::string& path, bool as_file) const; // Returns the absolute OS path inside the secondary source path. Will return // an empty FilePath if the secondary source path is empty. When loading a // buildfile, the GetFullPath should always be consulted first. base::FilePath GetFullPathSecondary(const SourceFile& file) const; base::FilePath GetFullPathSecondary(const SourceDir& dir) const; + // Works the same way as other GetFullPathSecondary. + // Parameter as_file defines whether path should be treated as a + // SourceFile or SourceDir value. + base::FilePath GetFullPathSecondary(const std::string& path, + bool as_file) const; // Called when an item is defined from a background thread. void ItemDefined(std::unique_ptr<Item> item) const;
diff --git a/tools/gn/filesystem_utils.cc b/tools/gn/filesystem_utils.cc index 6cce895..f9f6794 100644 --- a/tools/gn/filesystem_utils.cc +++ b/tools/gn/filesystem_utils.cc
@@ -705,6 +705,109 @@ return ret; } +base::FilePath ResolvePath(const std::string& value, + bool as_file, + const base::FilePath& source_root) { + if (value.empty()) + return base::FilePath(); + + std::string converted; + if (!IsPathSourceAbsolute(value)) { + if (value.size() > 2 && value[2] == ':') { + // Windows path, strip the leading slash. + converted.assign(&value[1], value.size() - 1); + } else { + converted.assign(value); + } + return base::FilePath(UTF8ToFilePath(converted)); + } + + // String the double-leading slash for source-relative paths. + converted.assign(&value[2], value.size() - 2); + + if (as_file && source_root.empty()) + return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); + + return source_root.Append(UTF8ToFilePath(converted)) + .NormalizePathSeparatorsTo('/'); +} + +template <typename StringType> +std::string ResolveRelative(const StringType& input, + const std::string& value, + bool as_file, + const base::StringPiece& source_root) { + std::string result; + + if (input.size() >= 2 && input[0] == '/' && input[1] == '/') { + // Source-relative. + result.assign(input.data(), input.size()); + if (!as_file) { + if (!EndsWithSlash(result)) + result.push_back('/'); + } + NormalizePath(&result, source_root); + return result; + } else if (IsPathAbsolute(input)) { + if (source_root.empty() || + !MakeAbsolutePathRelativeIfPossible(source_root, input, &result)) { +#if defined(OS_WIN) + if (input[0] != '/') // See the file case for why we do this check. + result = "/"; +#endif + result.append(input.data(), input.size()); + } + NormalizePath(&result); + if (!as_file) { + if (!EndsWithSlash(result)) + result.push_back('/'); + } + return result; + } + + if (!source_root.empty()) { + std::string absolute = + FilePathToUTF8(ResolvePath(value, as_file, UTF8ToFilePath(source_root)) + .AppendASCII(input) + .value()); + NormalizePath(&absolute); + if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute, &result)) { +#if defined(OS_WIN) + if (absolute[0] != '/') // See the file case for why we do this check. + result = "/"; +#endif + result.append(absolute.data(), absolute.size()); + } + if (!as_file && !EndsWithSlash(result)) + result.push_back('/'); + return result; + } + + // With no source_root, there's nothing we can do about + // e.g. input=../../../path/to/file and value=//source and we'll + // errornously return //file. + result.reserve(value.size() + input.size()); + result.assign(value); + result.append(input.data(), input.size()); + + NormalizePath(&result); + if (!as_file && !EndsWithSlash(result)) + result.push_back('/'); + + return result; +} + +// Explicit template instantiation +template std::string ResolveRelative(const base::StringPiece& input, + const std::string& value, + bool as_file, + const base::StringPiece& source_root); + +template std::string ResolveRelative(const std::string& input, + const std::string& value, + bool as_file, + const base::StringPiece& source_root); + std::string DirectoryWithNoLastSlash(const SourceDir& dir) { std::string ret;
diff --git a/tools/gn/filesystem_utils.h b/tools/gn/filesystem_utils.h index 0396283..1313279 100644 --- a/tools/gn/filesystem_utils.h +++ b/tools/gn/filesystem_utils.h
@@ -152,6 +152,31 @@ const SourceDir& dest_dir, const base::StringPiece& source_root = base::StringPiece()); +// Resolves a file or dir name (parameter input) relative to +// value directory. Will return an empty SourceDir/File on error +// and set the give *err pointer (required). Empty input is always an error. +// Returned value can be used to set value in either SourceFile or SourceDir +// (based on as_file parameter). +// +// Parameter as_file defines whether result path will look like a file path +// or it should be treated as a directory (contains "/" and the end +// of the string). +// +// If source_root is supplied, these functions will additionally handle the +// case where the input is a system-absolute but still inside the source +// tree. This is the case for some external tools. +template <typename StringType> +std::string ResolveRelative(const StringType& input, + const std::string& value, + bool as_file, + const base::StringPiece& source_root); + +// Resolves source file or directory relative to some given source root. Returns +// an empty file path on error. +base::FilePath ResolvePath(const std::string& value, + bool as_file, + const base::FilePath& source_root); + // Returns the given directory with no terminating slash at the end, such that // appending a slash and more stuff will produce a valid path. //
diff --git a/tools/gn/function_exec_script.cc b/tools/gn/function_exec_script.cc index 139b811..0f6397c 100644 --- a/tools/gn/function_exec_script.cc +++ b/tools/gn/function_exec_script.cc
@@ -137,19 +137,21 @@ return Value(); // Find the python script to run. - SourceFile script_source = - cur_dir.ResolveRelativeFile(args[0], err, - scope->settings()->build_settings()->root_path_utf8()); + std::string script_source_path = cur_dir.ResolveRelativeAs( + true, args[0], err, + scope->settings()->build_settings()->root_path_utf8()); if (err->has_error()) return Value(); - base::FilePath script_path = build_settings->GetFullPath(script_source); + base::FilePath script_path = + build_settings->GetFullPath(script_source_path, true); if (!build_settings->secondary_source_path().empty() && !base::PathExists(script_path)) { // Fall back to secondary source root when the file doesn't exist. - script_path = build_settings->GetFullPathSecondary(script_source); + script_path = + build_settings->GetFullPathSecondary(script_source_path, true); } - ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source.value()); + ScopedTrace trace(TraceItem::TRACE_SCRIPT_EXECUTE, script_source_path); trace.SetToolchain(settings->toolchain_label()); // Add all dependencies of this script, including the script itself, to the @@ -163,10 +165,11 @@ for (const auto& dep : deps_value.list_value()) { if (!dep.VerifyTypeIs(Value::STRING, err)) return Value(); - g_scheduler->AddGenDependency( - build_settings->GetFullPath(cur_dir.ResolveRelativeFile( - dep, err, - scope->settings()->build_settings()->root_path_utf8()))); + g_scheduler->AddGenDependency(build_settings->GetFullPath( + cur_dir.ResolveRelativeAs( + true, dep, err, + scope->settings()->build_settings()->root_path_utf8()), + true)); if (err->has_error()) return Value(); } @@ -236,10 +239,12 @@ } } if (g_scheduler->verbose_logging()) { - g_scheduler->Log("Pythoning", script_source.value() + " took " + - base::Int64ToString( - (base::TimeTicks::Now() - begin_exec).InMilliseconds()) + - "ms"); + g_scheduler->Log( + "Pythoning", + script_source_path + " took " + + base::Int64ToString( + (base::TimeTicks::Now() - begin_exec).InMilliseconds()) + + "ms"); } if (exit_code != 0) {
diff --git a/tools/gn/function_get_path_info.cc b/tools/gn/function_get_path_info.cc index 1c542aa..e08eca1 100644 --- a/tools/gn/function_get_path_info.cc +++ b/tools/gn/function_get_path_info.cc
@@ -41,7 +41,7 @@ settings->build_settings()->root_path_utf8()); } - // Input is a directory. + // Input is a file. return current_dir.ResolveRelativeFile(input, err, settings->build_settings()->root_path_utf8()).GetDir(); } @@ -100,14 +100,12 @@ BuildDirType::OBJ)); } case WHAT_ABSPATH: { - if (!input_string.empty() && - input_string[input_string.size() - 1] == '/') { - return current_dir.ResolveRelativeDir(input, err, - settings->build_settings()->root_path_utf8()).value(); - } else { - return current_dir.ResolveRelativeFile(input, err, - settings->build_settings()->root_path_utf8()).value(); - } + bool as_dir = + !input_string.empty() && input_string[input_string.size() - 1] == '/'; + + return current_dir.ResolveRelativeAs( + !as_dir, input, err, settings->build_settings()->root_path_utf8(), + &input_string); } default: NOTREACHED();
diff --git a/tools/gn/source_dir.cc b/tools/gn/source_dir.cc index e8fdff0..17eeb612 100644 --- a/tools/gn/source_dir.cc +++ b/tools/gn/source_dir.cc
@@ -23,6 +23,38 @@ } } +// Validates input value (input_value) and sets proper error message. +// Note: Parameter blame_input is used only for generating error message. +template <typename StringType> +bool ValidateResolveInput(bool as_file, + const Value& blame_input_value, + const StringType& input_value, + Err* err) { + if (as_file) { + // It's an error to resolve an empty string or one that is a directory + // (indicated by a trailing slash) because this is the function that expects + // to return a file. + if (input_value.empty()) { + *err = Err(blame_input_value, "Empty file path.", + "You can't use empty strings as file paths."); + return false; + } else if (input_value[input_value.size() - 1] == '/') { + std::string help = "You specified the path\n "; + help.append(std::string(input_value)); + help.append( + "\nand it ends in a slash, indicating you think it's a directory." + "\nBut here you're supposed to be listing a file."); + *err = Err(blame_input_value, "File path ends in a slash.", help); + return false; + } + } else if (input_value.empty()) { + *err = Err(blame_input_value, "Empty directory path.", + "You can't use empty strings as directories."); + return false; + } + return true; +} + } // namespace SourceDir::SourceDir() = default; @@ -43,176 +75,85 @@ SourceDir::~SourceDir() = default; +template <typename StringType> +std::string SourceDir::ResolveRelativeAs( + bool as_file, + const Value& blame_input_value, + const StringType& input_value, + Err* err, + const base::StringPiece& source_root) const { + if (!ValidateResolveInput<StringType>(as_file, blame_input_value, input_value, + err)) { + return std::string(); + } + return ResolveRelative(input_value, value_, as_file, source_root); +} + SourceFile SourceDir::ResolveRelativeFile( const Value& p, Err* err, const base::StringPiece& source_root) const { SourceFile ret; + if (!p.VerifyTypeIs(Value::STRING, err)) return ret; - // It's an error to resolve an empty string or one that is a directory - // (indicated by a trailing slash) because this is the function that expects - // to return a file. - const std::string& str = p.string_value(); - if (str.empty()) { - *err = Err(p, "Empty file path.", - "You can't use empty strings as file paths. That's just wrong."); - return ret; - } else if (str[str.size() - 1] == '/') { - *err = Err(p, "File path ends in a slash.", - "You specified the path\n " + str + "\n" - "and it ends in a slash, indicating you think it's a directory." - "\nBut here you're supposed to be listing a file."); + const std::string& input_string = p.string_value(); + if (!ValidateResolveInput<std::string>(true, p, input_string, err)) { return ret; } - - if (str.size() >= 2 && str[0] == '/' && str[1] == '/') { - // Source-relative. - ret.value_.assign(str.data(), str.size()); - NormalizePath(&ret.value_, source_root); - return ret; - } else if (IsPathAbsolute(str)) { - if (source_root.empty() || - !MakeAbsolutePathRelativeIfPossible(source_root, str, &ret.value_)) { -#if defined(OS_WIN) - // On Windows we'll accept "C:\foo" as an absolute path, which we want - // to convert to "/C:..." here. - if (str[0] != '/') - ret.value_ = "/"; -#endif - ret.value_.append(str.data(), str.size()); - } - NormalizePath(&ret.value_); - return ret; - } - - if (!source_root.empty()) { - std::string absolute = - FilePathToUTF8(Resolve(UTF8ToFilePath(source_root)).AppendASCII( - str).value()); - NormalizePath(&absolute); - if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute, - &ret.value_)) { -#if defined(OS_WIN) - // On Windows we'll accept "C:\foo" as an absolute path, which we want - // to convert to "/C:..." here. - if (absolute[0] != '/') - ret.value_ = "/"; -#endif - ret.value_.append(absolute.data(), absolute.size()); - } - return ret; - } - - // With no source_root_, there's nothing we can do about - // e.g. p=../../../path/to/file and value_=//source and we'll - // errornously return //file. - ret.value_.reserve(value_.size() + str.size()); - ret.value_.assign(value_); - ret.value_.append(str.data(), str.size()); - - NormalizePath(&ret.value_); + ret.value_ = ResolveRelative(input_string, value_, true, source_root); return ret; } +std::string SourceDir::ResolveRelativeAs(bool as_file, + const Value& v, + Err* err, + const base::StringPiece& source_root, + const std::string* v_value) const { + if (!v.VerifyTypeIs(Value::STRING, err)) + return std::string(); + + if (!v_value) { + v_value = &v.string_value(); + } + std::string result = + ResolveRelativeAs(as_file, v, *v_value, err, source_root); + if (!as_file) + AssertValueSourceDirString(result); + return result; +} + SourceDir SourceDir::ResolveRelativeDir( - const Value& p, + const Value& v, Err* err, const base::StringPiece& source_root) const { - if (!p.VerifyTypeIs(Value::STRING, err)) + if (!v.VerifyTypeIs(Value::STRING, err)) return SourceDir(); - return ResolveRelativeDir(p, p.string_value(), err, source_root); -} -SourceDir SourceDir::ResolveRelativeDir( - const Value& blame_but_dont_use, - const base::StringPiece& str, - Err* err, - const base::StringPiece& source_root) const { - SourceDir ret; - - if (str.empty()) { - *err = Err(blame_but_dont_use, "Empty directory path.", - "You can't use empty strings as directories. " - "That's just wrong."); - return ret; - } - - if (str.size() >= 2 && str[0] == '/' && str[1] == '/') { - // Source-relative. - ret.value_.assign(str.data(), str.size()); - if (!EndsWithSlash(ret.value_)) - ret.value_.push_back('/'); - NormalizePath(&ret.value_, source_root); - return ret; - } else if (IsPathAbsolute(str)) { - if (source_root.empty() || - !MakeAbsolutePathRelativeIfPossible(source_root, str, &ret.value_)) { -#if defined(OS_WIN) - if (str[0] != '/') // See the file case for why we do this check. - ret.value_ = "/"; -#endif - ret.value_.append(str.data(), str.size()); - } - NormalizePath(&ret.value_); - if (!EndsWithSlash(ret.value_)) - ret.value_.push_back('/'); - return ret; - } - - if (!source_root.empty()) { - std::string absolute = - FilePathToUTF8(Resolve(UTF8ToFilePath(source_root)).AppendASCII( - str.as_string()).value()); - NormalizePath(&absolute); - if (!MakeAbsolutePathRelativeIfPossible(source_root, absolute, - &ret.value_)) { -#if defined(OS_WIN) - if (absolute[0] != '/') // See the file case for why we do this check. - ret.value_ = "/"; -#endif - ret.value_.append(absolute.data(), absolute.size()); - } - if (!EndsWithSlash(ret.value_)) - ret.value_.push_back('/'); - return ret; - } - - ret.value_.reserve(value_.size() + str.size()); - ret.value_.assign(value_); - ret.value_.append(str.data(), str.size()); - - NormalizePath(&ret.value_); - if (!EndsWithSlash(ret.value_)) - ret.value_.push_back('/'); - AssertValueSourceDirString(ret.value_); - - return ret; + return ResolveRelativeDir<std::string>(v, v.string_value(), err, source_root); } base::FilePath SourceDir::Resolve(const base::FilePath& source_root) const { - if (is_null()) - return base::FilePath(); - - std::string converted; - if (is_system_absolute()) { - if (value_.size() > 2 && value_[2] == ':') { - // Windows path, strip the leading slash. - converted.assign(&value_[1], value_.size() - 1); - } else { - converted.assign(value_); - } - return base::FilePath(UTF8ToFilePath(converted)); - } - - // String the double-leading slash for source-relative paths. - converted.assign(&value_[2], value_.size() - 2); - return source_root.Append(UTF8ToFilePath(converted)) - .NormalizePathSeparatorsTo('/'); + return ResolvePath(value_, false, source_root); } void SourceDir::SwapValue(std::string* v) { value_.swap(*v); AssertValueSourceDirString(value_); } + +// Explicit template instantiation +template std::string SourceDir::ResolveRelativeAs( + bool as_file, + const Value& blame_input_value, + const std::string& input_value, + Err* err, + const base::StringPiece& source_root) const; + +template std::string SourceDir::ResolveRelativeAs( + bool as_file, + const Value& blame_input_value, + const base::StringPiece& input_value, + Err* err, + const base::StringPiece& source_root) const;
diff --git a/tools/gn/source_dir.h b/tools/gn/source_dir.h index 422fa89..142285c 100644 --- a/tools/gn/source_dir.h +++ b/tools/gn/source_dir.h
@@ -37,28 +37,57 @@ SourceDir(SwapIn, std::string* s); ~SourceDir(); - // Resolves a file or dir name relative to this source directory. Will return - // an empty SourceDir/File on error and set the give *err pointer (required). - // Empty input is always an error. + // Resolves a file or dir name (based on as_file parameter) relative + // to this source directory. Will return an empty string on error + // and set the give *err pointer (required). Empty input is always an error. + // + // Passed non null v_value will be used to resolve path (in cases where + // a substring has been extracted from the value, as with label resolution). + // In this use case parameter v is used to generate proper error. // // If source_root is supplied, these functions will additionally handle the // case where the input is a system-absolute but still inside the source // tree. This is the case for some external tools. + std::string ResolveRelativeAs( + bool as_file, + const Value& v, + Err* err, + const base::StringPiece& source_root = base::StringPiece(), + const std::string* v_value = nullptr) const; + + // Like ResolveRelativeAs above, but allows to produce result + // without overhead for string conversion (on input value). + template <typename StringType> + std::string ResolveRelativeAs( + bool as_file, + const Value& blame_input_value, + const StringType& input_value, + Err* err, + const base::StringPiece& source_root = base::StringPiece()) const; + + // Wrapper for ResolveRelativeAs. SourceFile ResolveRelativeFile( const Value& p, Err* err, const base::StringPiece& source_root = base::StringPiece()) const; - SourceDir ResolveRelativeDir( - const Value& p, - Err* err, - const base::StringPiece& source_root = base::StringPiece()) const; - // Like ResolveRelativeDir but takes a separate value (which gets blamed) - // and string to use (in cases where a substring has been extracted from the - // value, as with label resolution). + // Wrapper for ResolveRelativeAs. + template <typename StringType> SourceDir ResolveRelativeDir( - const Value& blame_but_dont_use, - const base::StringPiece& p, + const Value& blame_input_value, + const StringType& input_value, + Err* err, + const base::StringPiece& source_root = base::StringPiece()) const { + SourceDir ret; + ret.value_ = ResolveRelativeAs<StringType>(false, blame_input_value, + input_value, err, source_root); + return ret; + } + + // Wrapper for ResolveRelativeDir where input_value equals to + // v.string_value(). + SourceDir ResolveRelativeDir( + const Value& v, Err* err, const base::StringPiece& source_root = base::StringPiece()) const;
diff --git a/tools/gn/source_file.cc b/tools/gn/source_file.cc index b28c3ac..befc5a5 100644 --- a/tools/gn/source_file.cc +++ b/tools/gn/source_file.cc
@@ -61,23 +61,5 @@ } base::FilePath SourceFile::Resolve(const base::FilePath& source_root) const { - if (is_null()) - return base::FilePath(); - - std::string converted; - if (is_system_absolute()) { - if (value_.size() > 2 && value_[2] == ':') { - // Windows path, strip the leading slash. - converted.assign(&value_[1], value_.size() - 1); - } else { - converted.assign(value_); - } - return base::FilePath(UTF8ToFilePath(converted)); - } - - converted.assign(&value_[2], value_.size() - 2); - if (source_root.empty()) - return UTF8ToFilePath(converted).NormalizePathSeparatorsTo('/'); - return source_root.Append(UTF8ToFilePath(converted)) - .NormalizePathSeparatorsTo('/'); + return ResolvePath(value_, true, source_root); }
diff --git a/tools/gn/target_generator.cc b/tools/gn/target_generator.cc index bbc9793..ab85729 100644 --- a/tools/gn/target_generator.cc +++ b/tools/gn/target_generator.cc
@@ -222,24 +222,18 @@ const Value& input = input_list[i]; if (!input.VerifyTypeIs(Value::STRING, err_)) return false; - const std::string& input_str = input.string_value(); + const std::string input_str = input.string_value(); // Treat each input as either a file or a directory, depending on the // last character. - if (!input_str.empty() && input_str[input_str.size() - 1] == '/') { - // Resolve as directory. - SourceDir resolved = - dir.ResolveRelativeDir(input, input_str, err_, root_path); - if (err_->has_error()) - return false; - output_list.push_back(resolved.value()); - } else { - // Resolve as file. - SourceFile resolved = dir.ResolveRelativeFile(input, err_, root_path); - if (err_->has_error()) - return false; - output_list.push_back(resolved.value()); - } + bool as_dir = !input_str.empty() && input_str[input_str.size() - 1] == '/'; + + std::string resolved = + dir.ResolveRelativeAs(!as_dir, input, err_, root_path, &input_str); + if (err_->has_error()) + return false; + + output_list.push_back(resolved); } return true; }
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index d983f23..f5d2c6d 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -25768,6 +25768,7 @@ <int value="-1833149810" label="enable-accessibility-tab-switcher"/> <int value="-1832575380" label="show-saved-copy"/> <int value="-1832221649" label="disable-out-of-process-pac"/> + <int value="-1830623562" label="hide-non-active-apps-from-shelf"/> <int value="-1821058653" label="enable-delay-agnostic-aec"/> <int value="-1817209284" label="PayWithGoogleV1:enabled"/> <int value="-1816066138" label="CastAllowAllIPs:enabled"/>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index f332ba1e..906d4b2 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -111907,12 +111907,23 @@ <histogram_suffixes name="PpapiPluginName" separator="_"> <suffix name="libpepflashplayer.so" label="Flash player on Linux or Cros"/> - <suffix name="libwidevinecdmadapter.so" - label="Widevine CDM on Linux or Cros"/> <suffix name="pepflashplayer.dll" label="Flash player on Windows"/> <suffix name="PepperFlashPlayer.plugin" label="Flash player on Mac"/> - <suffix name="widevinecdmadapter.dll" label="Widevine CDM on Windows"/> - <suffix name="widevinecdmadapter.plugin" label="Widevine CDM on Mac"/> + <suffix name="libwidevinecdmadapter.so" label="Widevine CDM on Linux or Cros"> + <obsolete> + Deprecated March 2018 + </obsolete> + </suffix> + <suffix name="widevinecdmadapter.dll" label="Widevine CDM on Windows"> + <obsolete> + Deprecated March 2018 + </obsolete> + </suffix> + <suffix name="widevinecdmadapter.plugin" label="Widevine CDM on Mac"> + <obsolete> + Deprecated March 2018 + </obsolete> + </suffix> <affected-histogram name="Plugin.PpapiBrokerLoadErrorCode"/> <affected-histogram name="Plugin.PpapiBrokerLoadResult"/> <affected-histogram name="Plugin.PpapiBrokerLoadTime"/>
diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc index 944cf27..363d557 100644 --- a/ui/app_list/views/app_list_main_view.cc +++ b/ui/app_list/views/app_list_main_view.cc
@@ -176,7 +176,8 @@ } void AppListMainView::BackButtonPressed() { - contents_view_->Back(); + if (!contents_view_->Back()) + app_list_view_->Dismiss(); } } // namespace app_list
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc index 5145cdd..47397a340 100644 --- a/ui/app_list/views/contents_view.cc +++ b/ui/app_list/views/contents_view.cc
@@ -372,7 +372,8 @@ if (GetAppsContainerView()->IsInFolderView()) { GetAppsContainerView()->app_list_folder_view()->CloseFolderPage(); } else { - app_list_view_->Dismiss(); + // Close the app list when Back() is called from the apps page. + return false; } break; case ash::AppListState::kStateSearchResults:
diff --git a/ui/base/win/direct_manipulation.cc b/ui/base/win/direct_manipulation.cc index 31d25d62..98b6ca5f 100644 --- a/ui/base/win/direct_manipulation.cc +++ b/ui/base/win/direct_manipulation.cc
@@ -101,8 +101,7 @@ DIRECTMANIPULATION_CONFIGURATION_TRANSLATION_INERTIA | DIRECTMANIPULATION_CONFIGURATION_RAILS_X | DIRECTMANIPULATION_CONFIGURATION_RAILS_Y | - DIRECTMANIPULATION_CONFIGURATION_SCALING | - DIRECTMANIPULATION_CONFIGURATION_SCALING_INERTIA; + DIRECTMANIPULATION_CONFIGURATION_SCALING; hr = viewport_->ActivateConfiguration(configuration); if (!SUCCEEDED(hr)) @@ -205,6 +204,34 @@ DirectManipulationHandler::~DirectManipulationHandler() {} +void DirectManipulationHandler::TransitionToState(Gesture new_gesture_state) { + if (gesture_state_ == new_gesture_state) + return; + + Gesture previous_gesture_state = gesture_state_; + gesture_state_ = new_gesture_state; + + if (new_gesture_state == Gesture::kPinch) { + // kScroll, kNone -> kPinch, PinchBegin. + // Pinch gesture may begin with some scroll events. + event_target_->ApplyPinchZoomBegin(); + return; + } + + if (new_gesture_state == Gesture::kNone) { + // kScroll -> kNone do nothing. + if (previous_gesture_state == Gesture::kScroll) + return; + // kPinch -> kNone, PinchEnd. + event_target_->ApplyPinchZoomEnd(); + return; + } + + // kNone -> kScroll do nothing. Not allow kPinch -> kScroll. + DCHECK_EQ(previous_gesture_state, Gesture::kNone); + DCHECK_EQ(new_gesture_state, Gesture::kScroll); +} + HRESULT DirectManipulationHandler::OnViewportStatusChanged( IDirectManipulationViewport* viewport, DIRECTMANIPULATION_STATUS current, @@ -226,6 +253,8 @@ last_scale_ = 1.0f; last_x_offset_ = 0.0f; last_y_offset_ = 0.0f; + + TransitionToState(Gesture::kNone); } return hr; @@ -237,6 +266,8 @@ return S_OK; } +namespace { + bool FloatEquals(float f1, float f2) { // The idea behind this is to use this fraction of the larger of the // two numbers as the limit of the difference. This breaks down near @@ -252,6 +283,8 @@ return abs(f1 - f2) < 1; } +} // namespace + HRESULT DirectManipulationHandler::OnContentUpdated( IDirectManipulationViewport* viewport, IDirectManipulationContent* content) { @@ -284,8 +317,22 @@ DCHECK_NE(last_scale_, 0.0f); + // DirectManipulation will send xy transform move to down-right which is noise + // when pinch zoom. We should consider the gesture either Scroll or Pinch at + // one sequence. But Pinch gesture may begin with some scroll transform since + // DirectManipulation recognition maybe wrong at start if the user pinch with + // slow motion. So we allow kScroll -> kPinch. + // Consider this is a Scroll when scale factor equals 1.0. if (FloatEquals(scale, 1.0f)) { + if (gesture_state_ == Gesture::kNone) + TransitionToState(Gesture::kScroll); + } else { + // Pinch gesture may begin with some scroll events. + TransitionToState(Gesture::kPinch); + } + + if (gesture_state_ == Gesture::kScroll) { event_target_->ApplyPanGestureScroll(x_offset - last_x_offset_, y_offset - last_y_offset_); } else {
diff --git a/ui/base/win/direct_manipulation.h b/ui/base/win/direct_manipulation.h index acd9086a..91371a8f2 100644 --- a/ui/base/win/direct_manipulation.h +++ b/ui/base/win/direct_manipulation.h
@@ -52,6 +52,10 @@ DirectManipulationHandler(); ~DirectManipulationHandler() override; + enum class Gesture { kNone, kScroll, kPinch }; + + void TransitionToState(Gesture gesture); + HRESULT STDMETHODCALLTYPE OnViewportStatusChanged(_In_ IDirectManipulationViewport* viewport, _In_ DIRECTMANIPULATION_STATUS current, @@ -71,6 +75,9 @@ int last_y_offset_ = 0; bool first_ready_ = false; + // Current recognized gesture from Direct Manipulation. + Gesture gesture_state_ = Gesture::kNone; + DISALLOW_COPY_AND_ASSIGN(DirectManipulationHandler); };
diff --git a/ui/base/win/direct_manipulation_unittest.cc b/ui/base/win/direct_manipulation_unittest.cc index 687aefb..8e6d9e0 100644 --- a/ui/base/win/direct_manipulation_unittest.cc +++ b/ui/base/win/direct_manipulation_unittest.cc
@@ -239,18 +239,20 @@ DISALLOW_COPY_AND_ASSIGN(MockDirectManipulationContent); }; -enum class Gesture { kScroll, kScale }; +enum class Gesture { kScroll, kScale, kScaleBegin, kScaleEnd }; struct Event { + explicit Event(float scale) : gesture_(Gesture::kScale), scale_(scale) {} + + Event(float scroll_x, float scroll_y) + : gesture_(Gesture::kScroll), scroll_x_(scroll_x), scroll_y_(scroll_y) {} + + explicit Event(Gesture gesture) : gesture_(gesture) {} + Gesture gesture_; float scale_ = 0; float scroll_x_ = 0; float scroll_y_ = 0; - - Event(float scale) : gesture_(Gesture::kScale), scale_(scale) {} - - Event(float scroll_x, float scroll_y) - : gesture_(Gesture::kScroll), scroll_x_(scroll_x), scroll_y_(scroll_y) {} }; class MockWindowEventTarget : public WindowEventTarget { @@ -263,6 +265,14 @@ events_.push_back(Event(scale)); } + void ApplyPinchZoomBegin() override { + events_.push_back(Event(Gesture::kScaleBegin)); + } + + void ApplyPinchZoomEnd() override { + events_.push_back(Event(Gesture::kScaleEnd)); + } + void ApplyPanGestureScroll(int scroll_x, int scroll_y) override { events_.push_back(Event(scroll_x, scroll_y)); } @@ -411,9 +421,10 @@ ContentUpdated(1.1f, 0, 0); std::vector<Event> events = GetEvents(); - EXPECT_EQ(1u, events.size()); - EXPECT_EQ(Gesture::kScale, events[0].gesture_); - EXPECT_EQ(1.1f, events[0].scale_); + EXPECT_EQ(2u, events.size()); + EXPECT_EQ(Gesture::kScaleBegin, events[0].gesture_); + EXPECT_EQ(Gesture::kScale, events[1].gesture_); + EXPECT_EQ(1.1f, events[1].scale_); // For next update, should only apply the difference. ContentUpdated(1.21f, 0, 0); @@ -421,6 +432,11 @@ EXPECT_EQ(1u, events.size()); EXPECT_EQ(Gesture::kScale, events[0].gesture_); EXPECT_EQ(1.1f, events[0].scale_); + + ViewportStatusChanged(DIRECTMANIPULATION_READY, DIRECTMANIPULATION_RUNNING); + events = GetEvents(); + EXPECT_EQ(1u, events.size()); + EXPECT_EQ(Gesture::kScaleEnd, events[0].gesture_); } TEST_F(DirectManipulationUnitTest, ReceiveScrollTransformLessThanOne) { @@ -472,9 +488,10 @@ // Scale factor more than float point error, apply. ContentUpdated(1.00001f, 0, 0); events = GetEvents(); - EXPECT_EQ(1u, events.size()); - EXPECT_EQ(Gesture::kScale, events[0].gesture_); - EXPECT_EQ(1.00001f, events[0].scale_); + EXPECT_EQ(2u, events.size()); + EXPECT_EQ(Gesture::kScaleBegin, events[0].gesture_); + EXPECT_EQ(Gesture::kScale, events[1].gesture_); + EXPECT_EQ(1.00001f, events[1].scale_); // Scale factor difference less than float point error, ignore. ContentUpdated(1.000011f, 0, 0); @@ -487,6 +504,11 @@ EXPECT_EQ(1u, events.size()); EXPECT_EQ(Gesture::kScale, events[0].gesture_); EXPECT_EQ(1.000021f / 1.00001f, events[0].scale_); + + ViewportStatusChanged(DIRECTMANIPULATION_READY, DIRECTMANIPULATION_RUNNING); + events = GetEvents(); + EXPECT_EQ(1u, events.size()); + EXPECT_EQ(Gesture::kScaleEnd, events[0].gesture_); } TEST_F(DirectManipulationUnitTest, InSameSequenceReceiveBothScrollAndScale) { @@ -505,8 +527,9 @@ // Second event comes with scale factor. Now the scroll offset only noise. ContentUpdated(1.00001f, 5, 0); events = GetEvents(); - EXPECT_EQ(1u, events.size()); - EXPECT_EQ(Gesture::kScale, events[0].gesture_); + EXPECT_EQ(2u, events.size()); + EXPECT_EQ(Gesture::kScaleBegin, events[0].gesture_); + EXPECT_EQ(Gesture::kScale, events[1].gesture_); } TEST_F(DirectManipulationUnitTest,
diff --git a/ui/base/win/window_event_target.h b/ui/base/win/window_event_target.h index 2be4b5a3..d365f2f 100644 --- a/ui/base/win/window_event_target.h +++ b/ui/base/win/window_event_target.h
@@ -90,10 +90,19 @@ virtual void HandleParentChanged() = 0; // Apply the transform from Direct Manipulation API. - // ApplyPinchZoomScale is the pinch-zoom gesture. scale is the scale factor. - // ApplyPanGestureScroll is the pan gesture, scroll_x and scroll_y are pixel - // precison scroll offset. + + // Calls ApplyPinchZoomScale() for pinch-zoom gesture. scale is the scale + // factor. virtual void ApplyPinchZoomScale(float scale) = 0; + + // Pinch gesture phase. The sequencing expected of these events. + // The sequence of calls is ApplyPinchZoomBegin(), any number of calls to + // ApplyPinchZoomScale() and finally ApplyPinchZoomEnd(). + virtual void ApplyPinchZoomBegin() = 0; + virtual void ApplyPinchZoomEnd() = 0; + + // Calls ApplyPanGestureScroll() for pan gesture, scroll_x and scroll_y are + // pixel precison scroll offset. virtual void ApplyPanGestureScroll(int scroll_x, int scroll_y) = 0; protected:
diff --git a/ui/gfx/paint_vector_icon.cc b/ui/gfx/paint_vector_icon.cc index b9832d0..2669ca3 100644 --- a/ui/gfx/paint_vector_icon.cc +++ b/ui/gfx/paint_vector_icon.cc
@@ -540,7 +540,7 @@ // If an icon has a .1x.icon version, it should only be rendered at the size // specified in that definition. - if (icon.path_1x) + if (icon.rep_1x) DCHECK_EQ(this->dip_size, GetDefaultSizeOfVectorIcon(icon)); } @@ -562,16 +562,19 @@ SkColor color, const base::TimeDelta& elapsed_time) { DCHECK(!icon.is_empty()); - if (icon.path) { - DCHECK(icon.path_size > 0); - DCHECK_EQ(END, icon.path[icon.path_size - 1].command) << icon.name; + if (icon.rep) { + DCHECK(icon.rep->path_size > 0); + DCHECK_EQ(END, icon.rep->path[icon.rep->path_size - 1].command) + << icon.name; } - if (icon.path_1x) { - DCHECK(icon.path_1x_size > 0); - DCHECK_EQ(END, icon.path_1x[icon.path_1x_size - 1].command) << icon.name; + if (icon.rep_1x) { + DCHECK(icon.rep_1x->path_size > 0); + DCHECK_EQ(END, icon.rep_1x->path[icon.rep_1x->path_size - 1].command) + << icon.name; } - const PathElement* path = - (canvas->image_scale() == 1.f && icon.path_1x) ? icon.path_1x : icon.path; + const PathElement* path = (canvas->image_scale() == 1.f && icon.rep_1x) + ? icon.rep_1x->path + : icon.rep->path; PaintPath(canvas, path, dip_size, color, elapsed_time); } @@ -609,14 +612,15 @@ } int GetDefaultSizeOfVectorIcon(const VectorIcon& icon) { - const PathElement* one_x_path = icon.path_1x ? icon.path_1x : icon.path; + const PathElement* one_x_path = + icon.rep_1x ? icon.rep_1x->path : icon.rep->path; return one_x_path[0].command == CANVAS_DIMENSIONS ? one_x_path[1].arg : kReferenceSizeDip; } base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon) { base::TimeDelta last_motion; - for (PathParser parser(icon.path); parser.CurrentCommand() != END; + for (PathParser parser(icon.rep->path); parser.CurrentCommand() != END; parser.Advance()) { if (parser.CurrentCommand() != TRANSITION_END) continue;
diff --git a/ui/gfx/paint_vector_icon_unittest.cc b/ui/gfx/paint_vector_icon_unittest.cc index 6570dc5..3b5a9f4c 100644 --- a/ui/gfx/paint_vector_icon_unittest.cc +++ b/ui/gfx/paint_vector_icon_unittest.cc
@@ -51,7 +51,8 @@ R_LINE_TO, 50, 51, END, }; - const VectorIcon icon = {elements, arraysize(elements)}; + const VectorIconRep icon_rep = {elements, arraysize(elements)}; + const VectorIcon icon = {&icon_rep}; PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA); sk_sp<cc::PaintRecord> record = recorder.finishRecordingAsPicture(); @@ -88,7 +89,8 @@ CLOSE, END, }; - const VectorIcon icon = {elements, arraysize(elements)}; + const VectorIconRep icon_rep = {elements, arraysize(elements)}; + const VectorIcon icon = {&icon_rep}; PaintVectorIcon(&canvas, icon, canvas_size, color); // Count the number of pixels in the canvas.
diff --git a/ui/gfx/vector_icon_types.h b/ui/gfx/vector_icon_types.h index fae6871..e5f14b1 100644 --- a/ui/gfx/vector_icon_types.h +++ b/ui/gfx/vector_icon_types.h
@@ -79,18 +79,29 @@ }; }; -struct VectorIcon { - VectorIcon() = default; +// Describes the drawing commands for a single vector icon at a particular pixel +// size or range of sizes. +struct VectorIconRep { + VectorIconRep() = default; - bool is_empty() const { return !path; } + const PathElement* path = nullptr; - const gfx::PathElement* path = nullptr; // The length of |path|. size_t path_size = 0u; - const gfx::PathElement* path_1x = nullptr; - // The length of |path_1x|. - size_t path_1x_size = 0u; + private: + DISALLOW_COPY_AND_ASSIGN(VectorIconRep); +}; + +// A vector icon that stores one or more representations to be used for various +// scale factors and pixel dimensions. +struct VectorIcon { + VectorIcon() = default; + + bool is_empty() const { return !rep; } + + const VectorIconRep* rep = nullptr; + const VectorIconRep* rep_1x = nullptr; // A human-readable name, useful for debugging, derived from the name of the // icon file. This can also be used as an identifier, but vector icon targets
diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc index ed2c9ea..648894a 100644 --- a/ui/message_center/views/message_popup_collection_unittest.cc +++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -18,6 +18,7 @@ #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/display/display.h" #include "ui/events/event.h" #include "ui/events/event_constants.h" @@ -29,6 +30,8 @@ #include "ui/message_center/fake_message_center.h" #include "ui/message_center/public/cpp/message_center_constants.h" #include "ui/message_center/views/desktop_popup_alignment_delegate.h" +#include "ui/message_center/views/message_view.h" +#include "ui/message_center/views/slide_out_controller.h" #include "ui/message_center/views/toast_contents_view.h" #include "ui/views/test/views_test_base.h" #include "ui/views/widget/widget.h" @@ -99,6 +102,8 @@ protected: MessagePopupCollection* collection() { return collection_.get(); } + int GetDeferCounter() { return collection_->defer_counter_; } + size_t GetToastCounts() { return collection_->toasts_.size(); } @@ -139,6 +144,15 @@ return NULL; } + void SlideOutToast(const std::string& id) { + ui::ScopedAnimationDurationScaleMode zero_duration_scope( + ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); + ui::GestureEventDetails details(ui::ET_SCROLL_FLING_START, 1000.0f, 0.f); + ui::GestureEvent event(0, 0, ui::EF_NONE, ui::EventTimeForNow(), details); + static_cast<MessageView*>(GetToast(id)->child_at(0)) + ->slide_out_controller_.OnGestureEvent(&event); + } + std::string AddNotification() { std::string id = base::IntToString(id_++); std::unique_ptr<Notification> notification = std::make_unique<Notification>( @@ -822,5 +836,18 @@ } #endif +TEST_F(MessagePopupCollectionTest, RemoveBySlide) { + std::string id = AddNotification(); + WaitForTransitionsDone(); + EXPECT_EQ(0, GetDeferCounter()); + EXPECT_EQ(1u, GetToastCounts()); + + SlideOutToast(id); + WaitForTransitionsDone(); + + EXPECT_EQ(0, GetDeferCounter()); + EXPECT_EQ(0u, GetToastCounts()); +} + } // namespace test } // namespace message_center
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc index 8f5b193f..c9aa34c 100644 --- a/ui/message_center/views/message_view.cc +++ b/ui/message_center/views/message_view.cc
@@ -276,8 +276,17 @@ void MessageView::OnSlideChanged() {} void MessageView::OnSlideOut() { - MessageCenter::Get()->RemoveNotification(notification_id_, - true /* by_user */); + // As a workaround for a MessagePopupCollection bug https://crbug.com/805208, + // pass false to by_user although it is triggered by user. + // TODO(tetsui): Rewrite MessagePopupCollection and remove this hack. + if (pinned_) { + // Also a workaround to not break notification pinning. + MessageCenter::Get()->MarkSinglePopupAsShown( + notification_id_, true /* mark_notification_as_read */); + } else { + MessageCenter::Get()->RemoveNotification(notification_id_, + false /* by_user */); + } } bool MessageView::GetPinned() const {
diff --git a/ui/message_center/views/message_view.h b/ui/message_center/views/message_view.h index 299f7ad..62922ca6 100644 --- a/ui/message_center/views/message_view.h +++ b/ui/message_center/views/message_view.h
@@ -28,14 +28,17 @@ namespace message_center { +namespace test { +class MessagePopupCollectionTest; +} + class Notification; class NotificationControlButtonsView; // An base class for a notification entry. Contains background and other // elements shared by derived notification views. -class MESSAGE_CENTER_EXPORT MessageView - : public views::InkDropHostView, - public views::SlideOutController::Delegate { +class MESSAGE_CENTER_EXPORT MessageView : public views::InkDropHostView, + public SlideOutController::Delegate { public: static const char kViewClassName[]; @@ -88,7 +91,7 @@ const char* GetClassName() const override; void OnGestureEvent(ui::GestureEvent* event) override; - // views::SlideOutController::Delegate + // message_center::SlideOutController::Delegate ui::Layer* GetSlideOutLayer() override; void OnSlideChanged() override; void OnSlideOut() override; @@ -114,6 +117,8 @@ bool is_nested() const { return is_nested_; } private: + friend class test::MessagePopupCollectionTest; + std::string notification_id_; views::View* background_view_ = nullptr; // Owned by views hierarchy. views::ScrollView* scroller_ = nullptr; @@ -125,7 +130,7 @@ std::unique_ptr<views::Painter> focus_painter_; - views::SlideOutController slide_out_controller_; + message_center::SlideOutController slide_out_controller_; // True if |this| is embedded in another view. Equivalent to |!top_level| in // MessageViewFactory parlance.
diff --git a/ui/message_center/views/slide_out_controller.cc b/ui/message_center/views/slide_out_controller.cc index efcf8e0..6a863de1 100644 --- a/ui/message_center/views/slide_out_controller.cc +++ b/ui/message_center/views/slide_out_controller.cc
@@ -8,7 +8,7 @@ #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/transform.h" -namespace views { +namespace message_center { SlideOutController::SlideOutController(ui::EventTarget* target, Delegate* delegate) @@ -108,4 +108,4 @@ delegate_->OnSlideOut(); } -} // namespace views +} // namespace message_center
diff --git a/ui/message_center/views/slide_out_controller.h b/ui/message_center/views/slide_out_controller.h index 5b01df2d..c3f134e 100644 --- a/ui/message_center/views/slide_out_controller.h +++ b/ui/message_center/views/slide_out_controller.h
@@ -8,15 +8,16 @@ #include "base/macros.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/events/scoped_target_handler.h" +#include "ui/message_center/message_center_export.h" #include "ui/views/view.h" -#include "ui/views/views_export.h" -namespace views { +namespace message_center { // This class contains logic to control sliding out of a layer in response to // swipes, i.e. gesture scroll events. -class SlideOutController : public ui::EventHandler, - public ui::ImplicitAnimationObserver { +class MESSAGE_CENTER_EXPORT SlideOutController + : public ui::EventHandler, + public ui::ImplicitAnimationObserver { public: class Delegate { public: @@ -59,6 +60,6 @@ DISALLOW_COPY_AND_ASSIGN(SlideOutController); }; -} // namespace views +} // namespace message_center #endif // UI_MESSAGE_CENTER_VIEWS_SLIDE_OUT_CONTROLLER_H_
diff --git a/ui/views/controls/webview/web_dialog_view.cc b/ui/views/controls/webview/web_dialog_view.cc index ba3480d..ef8b793f 100644 --- a/ui/views/controls/webview/web_dialog_view.cc +++ b/ui/views/controls/webview/web_dialog_view.cc
@@ -28,7 +28,7 @@ using content::WebContents; using content::WebUIMessageHandler; using ui::WebDialogDelegate; -using ui::WebDialogUI; +using ui::WebDialogUIBase; using ui::WebDialogWebContentsDelegate; namespace views { @@ -365,7 +365,7 @@ // Set the delegate. This must be done before loading the page. See // the comment above WebDialogUI in its header file for why. - WebDialogUI::SetDelegate(web_contents, this); + WebDialogUIBase::SetDelegate(web_contents, this); web_view_->LoadInitialURL(GetDialogContentURL()); }
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc index 42afd49..c889696 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -955,6 +955,11 @@ return event.handled(); } +bool DesktopWindowTreeHostWin::HandleGestureEvent(ui::GestureEvent* event) { + SendEventToSink(event); + return event->handled(); +} + void DesktopWindowTreeHostWin::HandleWindowSizeChanging() { if (compositor()) compositor()->DisableSwapUntilResize();
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h index 732f492..cbb800c3 100644 --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -214,6 +214,7 @@ LRESULT* result) override; void PostHandleMSG(UINT message, WPARAM w_param, LPARAM l_param) override; bool HandleScrollEvent(const ui::ScrollEvent& event) override; + bool HandleGestureEvent(ui::GestureEvent* event) override; void HandleWindowSizeChanging() override; void HandleWindowSizeUnchanged() override; void HandleWindowScaleFactorChanged(float window_scale_factor) override;
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index cddb014..8a12882 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc
@@ -1059,26 +1059,43 @@ } void HWNDMessageHandler::ApplyPinchZoomScale(float scale) { - // We fake a default ctrl+wheel event here. Offset 120 is the default scroll - // offset on Windows. - // TODO(chaopeng) Send pinch-zoom event here. - gfx::Vector2d offset = - scale > 1 ? gfx::Vector2d(120, 120) : gfx::Vector2d(-120, -120); + POINT cursor_pos = {0}; + ::GetCursorPos(&cursor_pos); + ScreenToClient(hwnd(), &cursor_pos); - POINT root_location = {0}; - ::GetCursorPos(&root_location); + ui::GestureEventDetails event_details(ui::ET_GESTURE_PINCH_UPDATE); + event_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); + event_details.set_scale(scale); - POINT location = {root_location.x, root_location.y}; - ScreenToClient(hwnd(), &root_location); + ui::GestureEvent event(cursor_pos.x, cursor_pos.y, ui::EF_NONE, + base::TimeTicks::Now(), event_details); + delegate_->HandleGestureEvent(&event); +} - gfx::Point cursor_location(location); - gfx::Point cursor_root_location(root_location); +void HWNDMessageHandler::ApplyPinchZoomBegin() { + POINT cursor_pos = {0}; + ::GetCursorPos(&cursor_pos); + ScreenToClient(hwnd(), &cursor_pos); - ui::MouseWheelEvent wheel_event(offset, cursor_location, cursor_root_location, - base::TimeTicks::Now(), ui::EF_CONTROL_DOWN, - ui::EF_PRECISION_SCROLLING_DELTA); + ui::GestureEventDetails event_details(ui::ET_GESTURE_PINCH_BEGIN); + event_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); - delegate_->HandleMouseEvent(wheel_event); + ui::GestureEvent event(cursor_pos.x, cursor_pos.y, ui::EF_NONE, + base::TimeTicks::Now(), event_details); + delegate_->HandleGestureEvent(&event); +} + +void HWNDMessageHandler::ApplyPinchZoomEnd() { + POINT cursor_pos = {0}; + ::GetCursorPos(&cursor_pos); + ScreenToClient(hwnd(), &cursor_pos); + + ui::GestureEventDetails event_details(ui::ET_GESTURE_PINCH_END); + event_details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHPAD); + + ui::GestureEvent event(cursor_pos.x, cursor_pos.y, ui::EF_NONE, + base::TimeTicks::Now(), event_details); + delegate_->HandleGestureEvent(&event); } void HWNDMessageHandler::ApplyPanGestureScroll(int scroll_x, int scroll_y) {
diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index c419e2b6..9daec1bd 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h
@@ -264,6 +264,8 @@ bool* handled) override; void HandleParentChanged() override; void ApplyPinchZoomScale(float scale) override; + void ApplyPinchZoomBegin() override; + void ApplyPinchZoomEnd() override; void ApplyPanGestureScroll(int scroll_x, int scroll_y) override; // Returns the auto-hide edges of the appbar. See
diff --git a/ui/views/win/hwnd_message_handler_delegate.h b/ui/views/win/hwnd_message_handler_delegate.h index d13f807..f4b3ff8e 100644 --- a/ui/views/win/hwnd_message_handler_delegate.h +++ b/ui/views/win/hwnd_message_handler_delegate.h
@@ -243,6 +243,10 @@ // handled by the delegate. virtual bool HandleScrollEvent(const ui::ScrollEvent& event) = 0; + // Called when a gesture event is received. Returns true if the event was + // handled by the delegate. + virtual bool HandleGestureEvent(ui::GestureEvent* event) = 0; + // Called when the window size is about to change. virtual void HandleWindowSizeChanging() = 0;
diff --git a/ui/web_dialogs/BUILD.gn b/ui/web_dialogs/BUILD.gn index 63923b1..68405db 100644 --- a/ui/web_dialogs/BUILD.gn +++ b/ui/web_dialogs/BUILD.gn
@@ -24,6 +24,7 @@ "//content/public/common", "//skia", "//ui/base", + "//ui/webui", "//url", ]
diff --git a/ui/web_dialogs/DEPS b/ui/web_dialogs/DEPS index d988b2f..ebad407c 100644 --- a/ui/web_dialogs/DEPS +++ b/ui/web_dialogs/DEPS
@@ -3,4 +3,5 @@ "+third_party/WebKit/public/platform/WebGestureEvent.h", "+ui/base", "+ui/gfx", + "+ui/webui", ]
diff --git a/ui/web_dialogs/web_dialog_ui.cc b/ui/web_dialogs/web_dialog_ui.cc index 5b72e0c04..1d6cbc9 100644 --- a/ui/web_dialogs/web_dialog_ui.cc +++ b/ui/web_dialogs/web_dialog_ui.cc
@@ -39,37 +39,31 @@ } // namespace -WebDialogUI::WebDialogUI(content::WebUI* web_ui) - : WebUIController(web_ui) { -} - -WebDialogUI::~WebDialogUI() { - // Don't unregister our user data. During the teardown of the WebContents, - // this will be deleted, but the WebContents will already be destroyed. - // - // This object is owned indirectly by the WebContents. WebUIs can change, so - // it's scary if this WebUI is changed out and replaced with something else, - // since the user data will still point to the old delegate. But the delegate - // is itself the owner of the WebContents for a dialog so will be in scope, - // and the HTML dialogs won't swap WebUIs anyway since they don't navigate. -} - -void WebDialogUI::CloseDialog(const base::ListValue* args) { - OnDialogClosed(args); -} - // static -void WebDialogUI::SetDelegate(content::WebContents* web_contents, - WebDialogDelegate* delegate) { +void WebDialogUIBase::SetDelegate(content::WebContents* web_contents, + WebDialogDelegate* delegate) { web_contents->SetUserData( &kWebDialogDelegateUserDataKey, std::make_unique<WebDialogDelegateUserData>(delegate)); } -//////////////////////////////////////////////////////////////////////////////// -// Private: +WebDialogUIBase::WebDialogUIBase(content::WebUI* web_ui) : web_ui_(web_ui) {} -WebDialogDelegate* WebDialogUI::GetDelegate( +// Don't unregister our user data. During the teardown of the WebContents, this +// will be deleted, but the WebContents will already be destroyed. +// +// This object is owned indirectly by the WebContents. WebUIs can change, so +// it's scary if this WebUI is changed out and replaced with something else, +// since the user data will still point to the old delegate. But the delegate is +// itself the owner of the WebContents for a dialog so will be in scope, and the +// HTML dialogs won't swap WebUIs anyway since they don't navigate. +WebDialogUIBase::~WebDialogUIBase() = default; + +void WebDialogUIBase::CloseDialog(const base::ListValue* args) { + OnDialogClosed(args); +} + +WebDialogDelegate* WebDialogUIBase::GetDelegate( content::WebContents* web_contents) { WebDialogDelegateUserData* user_data = static_cast<WebDialogDelegateUserData*>( @@ -78,17 +72,18 @@ return user_data ? user_data->delegate() : NULL; } - -void WebDialogUI::RenderFrameCreated(RenderFrameHost* render_frame_host) { +void WebDialogUIBase::HandleRenderFrameCreated( + RenderFrameHost* render_frame_host) { // Hook up the javascript function calls, also known as chrome.send("foo") // calls in the HTML, to the actual C++ functions. - web_ui()->RegisterMessageCallback("dialogClose", - base::Bind(&WebDialogUI::OnDialogClosed, base::Unretained(this))); + web_ui_->RegisterMessageCallback( + "dialogClose", + base::Bind(&WebDialogUIBase::OnDialogClosed, base::Unretained(this))); // Pass the arguments to the renderer supplied by the delegate. std::string dialog_args; std::vector<WebUIMessageHandler*> handlers; - WebDialogDelegate* delegate = GetDelegate(web_ui()->GetWebContents()); + WebDialogDelegate* delegate = GetDelegate(web_ui_->GetWebContents()); if (delegate) { dialog_args = delegate->GetDialogArgs(); delegate->GetWebUIMessageHandlers(&handlers); @@ -96,17 +91,17 @@ content::RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); - if (0 != (web_ui()->GetBindings() & content::BINDINGS_POLICY_WEB_UI)) + if (0 != (web_ui_->GetBindings() & content::BINDINGS_POLICY_WEB_UI)) render_view_host->SetWebUIProperty("dialogArguments", dialog_args); for (WebUIMessageHandler* handler : handlers) - web_ui()->AddMessageHandler(base::WrapUnique(handler)); + web_ui_->AddMessageHandler(base::WrapUnique(handler)); if (delegate) - delegate->OnDialogShown(web_ui(), render_view_host); + delegate->OnDialogShown(web_ui_, render_view_host); } -void WebDialogUI::OnDialogClosed(const base::ListValue* args) { - WebDialogDelegate* delegate = GetDelegate(web_ui()->GetWebContents()); +void WebDialogUIBase::OnDialogClosed(const base::ListValue* args) { + WebDialogDelegate* delegate = GetDelegate(web_ui_->GetWebContents()); if (delegate) { std::string json_retval; if (args && !args->empty() && !args->GetString(0, &json_retval)) @@ -116,4 +111,13 @@ } } +WebDialogUI::WebDialogUI(content::WebUI* web_ui) + : WebDialogUIBase(web_ui), content::WebUIController(web_ui) {} + +WebDialogUI::~WebDialogUI() = default; + +void WebDialogUI::RenderFrameCreated(RenderFrameHost* render_frame_host) { + HandleRenderFrameCreated(render_frame_host); +} + } // namespace ui
diff --git a/ui/web_dialogs/web_dialog_ui.h b/ui/web_dialogs/web_dialog_ui.h index 001de19..8c1c726a 100644 --- a/ui/web_dialogs/web_dialog_ui.h +++ b/ui/web_dialogs/web_dialog_ui.h
@@ -15,6 +15,7 @@ #include "content/public/browser/web_ui_controller.h" #include "ui/base/ui_base_types.h" #include "ui/web_dialogs/web_dialogs_export.h" +#include "ui/webui/mojo_web_ui_controller.h" #include "url/gurl.h" namespace content { @@ -25,6 +26,35 @@ class WebDialogDelegate; +class WEB_DIALOGS_EXPORT WebDialogUIBase { + public: + // Sets the delegate on the WebContents. + static void SetDelegate(content::WebContents* web_contents, + WebDialogDelegate* delegate); + + WebDialogUIBase(content::WebUI* web_ui); + + // Close the dialog, passing the specified arguments to the close handler. + void CloseDialog(const base::ListValue* args); + + protected: + virtual ~WebDialogUIBase(); + + // Prepares |render_frame_host| to host a dialog. + void HandleRenderFrameCreated(content::RenderFrameHost* render_frame_host); + + private: + // Gets the delegate for the WebContent set with SetDelegate. + static WebDialogDelegate* GetDelegate(content::WebContents* web_contents); + + // JS message handler. + void OnDialogClosed(const base::ListValue* args); + + content::WebUI* web_ui_; + + DISALLOW_COPY_AND_ASSIGN(WebDialogUIBase); +}; + // Displays file URL contents inside a modal web dialog. // // This application really should not use WebContents + WebUI. It should instead @@ -36,44 +66,45 @@ // the dialog to pass its delegate to the Web UI without having nasty accessors // on the WebContents. The correct design using RVH directly would avoid all of // this. -class WEB_DIALOGS_EXPORT WebDialogUI : public content::WebUIController { +class WEB_DIALOGS_EXPORT WebDialogUI : public WebDialogUIBase, + public content::WebUIController { public: - struct WebDialogParams { - // The URL for the content that will be loaded in the dialog. - GURL url; - // Width of the dialog. - int width; - // Height of the dialog. - int height; - // The JSON input to pass to the dialog when showing it. - std::string json_input; - }; - // When created, the delegate should already be set as user data on the // WebContents. explicit WebDialogUI(content::WebUI* web_ui); ~WebDialogUI() override; - // Close the dialog, passing the specified arguments to the close handler. - void CloseDialog(const base::ListValue* args); - - // Sets the delegate on the WebContents. - static void SetDelegate(content::WebContents* web_contents, - WebDialogDelegate* delegate); - private: - // WebUIController + // content::WebUIController: void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; - // Gets the delegate for the WebContent set with SetDelegate. - static WebDialogDelegate* GetDelegate(content::WebContents* web_contents); - - // JS message handler. - void OnDialogClosed(const base::ListValue* args); - DISALLOW_COPY_AND_ASSIGN(WebDialogUI); }; +// Displays file URL contents inside a modal web dialog while also enabling +// Mojo calls to be made from within the dialog. +template <typename Interface> +class WEB_DIALOGS_EXPORT MojoWebDialogUI + : public WebDialogUIBase, + public MojoWebUIController<Interface> { + public: + // When created, the delegate should already be set as user data on the + // WebContents. + explicit MojoWebDialogUI(content::WebUI* web_ui) + : WebDialogUIBase(web_ui), MojoWebUIController<Interface>(web_ui) {} + ~MojoWebDialogUI() override {} + + private: + // content::WebUIController: + void RenderFrameCreated( + content::RenderFrameHost* render_frame_host) override { + MojoWebUIControllerBase::RenderFrameCreated(render_frame_host); + HandleRenderFrameCreated(render_frame_host); + } + + DISALLOW_COPY_AND_ASSIGN(MojoWebDialogUI); +}; + } // namespace ui #endif // UI_WEB_DIALOGS_WEB_DIALOG_UI_H_