diff --git a/DEPS b/DEPS index b67f51d..5e386c6 100644 --- a/DEPS +++ b/DEPS
@@ -138,11 +138,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': '90c300fb4ac9421b7274ba7c94c8c90f600766db', + 'skia_revision': '91032f8cd7eaf5ab5d562b6bf8b726000ae33709', # 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': 'fe77d58a6a3cd9385454aa0bc29330ec668e293a', + 'v8_revision': '8034ecbaa47488bb1ca89785bb13d5fa2cee8f01', # 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. @@ -150,7 +150,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': 'dfd760055152076509c59b23e1604d83a7435688', + 'angle_revision': 'dd3ef1e788191b55260650c13a2a516ac3b4dcfa', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. @@ -158,7 +158,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': '9d1193b591c5ac53cf1680c80692911f7dd26607', + 'pdfium_revision': 'ad6de6a08a66b6310630abd09ecd6f9687c17234', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. @@ -201,7 +201,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': '6643ef1bddde64e223924eb23fabc47acc3da16c', + 'catapult_revision': 'ab176bd6b58cc828cafb73a86dac354947bbf998', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other. @@ -257,11 +257,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'spv_tools_revision': '59983a601091f1e30fe59f6b2585d9e79ac34a2a', + 'spv_tools_revision': 'df86bb44fe476515f9a298bacd8e1d4a3522e989', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'spv_headers_revision': '8b911bd2ba37677037b38c9bd286c7c05701bcda', + 'spv_headers_revision': 'de99d4d834aeb51dd9f099baa285bd44fd04bb3d', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -273,11 +273,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '4ec2c1060e85678809c73bd9ee81120567b23dd8', + 'dawn_revision': '5dee3e826bed25ea7893de29bfe612c864f81604', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'quiche_revision': 'c1cab06be6b47a0f96c7dff58802680b2b583b88', + 'quiche_revision': '4080a859725c90354baefc8ad3743e2bf5cb7280', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ios_webkit # and whatever else without interference from each other. @@ -1187,7 +1187,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + '764c50488ab39a447d304f6601941e229e2fe6c3', + Var('android_git') + '/platform/external/perfetto.git' + '@' + 'a7344dc0fbc749429c3a5253ec825a5f2f1ccecc', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1355,7 +1355,7 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + '6f0b34abee8dba611c253738d955c59f703c147a', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '9aa870a2d107560864f8e78a438789534f777734', + Var('webrtc_git') + '/src.git' + '@' + '8f7b41afd885dd55b445d36d41e126d92a14df35', 'src/third_party/xdg-utils': { 'url': Var('chromium_git') + '/chromium/deps/xdg-utils.git' + '@' + 'd80274d5869b17b8c9067a1022e4416ee7ed5e0d', @@ -1396,7 +1396,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@fb91be137da68e75372d6c7a32b6d1991e6ba1a1', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@d70229338697af120b79d4f82287d8739a53be33', 'condition': 'checkout_src_internal', },
diff --git a/ash/login/login_screen_controller.cc b/ash/login/login_screen_controller.cc index ce93989..0a87a9ffe 100644 --- a/ash/login/login_screen_controller.cc +++ b/ash/login/login_screen_controller.cc
@@ -351,9 +351,10 @@ void LoginScreenController::ShowParentAccessWidget( const AccountId& child_account_id, base::RepeatingCallback<void(bool success)> callback, - ParentAccessRequestReason reason) { + ParentAccessRequestReason reason, + bool extra_dimmer) { parent_access_widget_ = std::make_unique<ash::ParentAccessWidget>( - child_account_id, callback, reason); + child_account_id, callback, reason, extra_dimmer); } void LoginScreenController::SetAllowLoginAsGuest(bool allow_guest) {
diff --git a/ash/login/login_screen_controller.h b/ash/login/login_screen_controller.h index 2a989da1..3d196289 100644 --- a/ash/login/login_screen_controller.h +++ b/ash/login/login_screen_controller.h
@@ -117,7 +117,8 @@ void ShowParentAccessWidget( const AccountId& child_account_id, base::RepeatingCallback<void(bool success)> callback, - ParentAccessRequestReason reason) override; + ParentAccessRequestReason reason, + bool extra_dimmer) override; void SetAllowLoginAsGuest(bool allow_guest) override; // KioskAppMenu:
diff --git a/ash/login/ui/parent_access_widget.cc b/ash/login/ui/parent_access_widget.cc index b7c3357..9c9eb98 100644 --- a/ash/login/ui/parent_access_widget.cc +++ b/ash/login/ui/parent_access_widget.cc
@@ -10,6 +10,7 @@ #include "ash/public/cpp/shell_window_ids.h" #include "ash/session/session_controller_impl.h" #include "ash/shell.h" +#include "ash/wm/window_dimmer.h" #include "components/session_manager/session_manager_types.h" #include "ui/views/widget/widget.h" @@ -17,7 +18,8 @@ ParentAccessWidget::ParentAccessWidget(const AccountId& account_id, const OnExitCallback& callback, - ParentAccessRequestReason reason) + ParentAccessRequestReason reason, + bool use_extra_dimmer) : callback_(callback) { views::Widget::InitParams widget_params; // Using window frameless to be able to get focus on the view input fields, @@ -41,9 +43,13 @@ weak_factory_.GetWeakPtr()); widget_params.delegate = new ParentAccessView(account_id, callbacks, reason); + if (use_extra_dimmer) { + dimmer_ = std::make_unique<WindowDimmer>(widget_params.parent); + dimmer_->window()->Show(); + } + widget_ = std::make_unique<views::Widget>(); widget_->Init(widget_params); - widget_->CenterWindow(widget_->GetContentsView()->GetPreferredSize()); widget_->Show(); } @@ -52,6 +58,7 @@ void ParentAccessWidget::OnExit(bool success) { callback_.Run(success); widget_->Close(); + dimmer_.reset(); } } // namespace ash
diff --git a/ash/login/ui/parent_access_widget.h b/ash/login/ui/parent_access_widget.h index c11400ff..499f466 100644 --- a/ash/login/ui/parent_access_widget.h +++ b/ash/login/ui/parent_access_widget.h
@@ -20,6 +20,8 @@ namespace ash { +class WindowDimmer; + enum class ParentAccessRequestReason; // Widget to display the Parent Access View in a standalone container. @@ -34,10 +36,12 @@ // successful or (b) the back button is pressed. |reason| contains information // about why the parent access view is necessary, it is used to modify the // widget appearance by changing the title and description strings and - // background color + // background color. The parent access widget is a modal and already contains + // a dimmer, use |extra_dimmer| when another modal needs to instantiate it. ParentAccessWidget(const AccountId& account_id, const OnExitCallback& callback, - ParentAccessRequestReason reason); + ParentAccessRequestReason reason, + bool use_extra_dimmer); ~ParentAccessWidget(); @@ -46,6 +50,7 @@ void OnExit(bool success); std::unique_ptr<views::Widget> widget_; + std::unique_ptr<WindowDimmer> dimmer_; OnExitCallback callback_;
diff --git a/ash/public/cpp/BUILD.gn b/ash/public/cpp/BUILD.gn index e6c7b7b..04b66a1c 100644 --- a/ash/public/cpp/BUILD.gn +++ b/ash/public/cpp/BUILD.gn
@@ -290,7 +290,6 @@ "power_utils_unittest.cc", "rounded_corner_decorator_unittest.cc", "shelf_model_unittest.cc", - "tablet_mode_unittest.cc", "voice_interaction_controller_unittest.cc", ]
diff --git a/ash/public/cpp/login_screen.h b/ash/public/cpp/login_screen.h index 14473377..28db3c1e 100644 --- a/ash/public/cpp/login_screen.h +++ b/ash/public/cpp/login_screen.h
@@ -65,13 +65,15 @@ // invoked when the back button is clicked or the correct code was entered. // |reason| contains information about why the parent access view is // necessary, it is used to modify the view appearance by changing the title - // and description strings and background color. Note: this is intended for - // children only. If a non child account id is provided, the validation will - // necessarily fail. + // and description strings and background color. The parent access widget is a + // modal and already contains a dimmer, use |extra_dimmer| when another modal + // needs to instantiate it. Note: this is intended for children only. If a non + // child account id is provided, the validation will necessarily fail. virtual void ShowParentAccessWidget( const AccountId& child_account_id, base::RepeatingCallback<void(bool success)> callback, - ParentAccessRequestReason reason) = 0; + ParentAccessRequestReason reason, + bool extra_dimmer = false) = 0; // Sets if the guest button on the login shelf can be shown. Even if set to // true the button may still not be visible.
diff --git a/ash/public/cpp/tablet_mode.cc b/ash/public/cpp/tablet_mode.cc index e9f6054..a0e5be2 100644 --- a/ash/public/cpp/tablet_mode.cc +++ b/ash/public/cpp/tablet_mode.cc
@@ -4,62 +4,26 @@ #include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/logging.h" -#include "base/no_destructor.h" namespace ash { namespace { - -// Singleton delegate instance. -TabletMode::Delegate* g_delegate = nullptr; - -} // namespace - -TabletMode::Delegate::Delegate() { - DCHECK(!g_delegate); - g_delegate = this; -} - -TabletMode::Delegate::~Delegate() { - DCHECK_EQ(g_delegate, this); - g_delegate = nullptr; +TabletMode* g_instance = nullptr; } TabletMode* TabletMode::Get() { - static base::NoDestructor<TabletMode> instance; - return instance.get(); + return g_instance; } -TabletMode::TabletMode() = default; -TabletMode::~TabletMode() = default; - -bool TabletMode::InTabletMode() const { - // |g_delegate| could be null in unit tests. - if (!g_delegate) - return false; - - return g_delegate->InTabletMode(); +TabletMode::TabletMode() { + DCHECK_EQ(nullptr, g_instance); + g_instance = this; } -void TabletMode::SetEnabledForTest(bool enabled) { - DCHECK(g_delegate); - g_delegate->SetEnabledForTest(enabled); -} - -void TabletMode::AddObserver(TabletModeToggleObserver* observer) { - observers_.AddObserver(observer); -} - -void TabletMode::RemoveObserver(TabletModeToggleObserver* observer) { - observers_.RemoveObserver(observer); -} - -void TabletMode::NotifyTabletModeChanged() { - const bool in_tablet_mode = InTabletMode(); - for (auto& observer : observers_) - observer.OnTabletModeToggled(in_tablet_mode); +TabletMode::~TabletMode() { + DCHECK_EQ(this, g_instance); + g_instance = nullptr; } } // namespace ash
diff --git a/ash/public/cpp/tablet_mode.h b/ash/public/cpp/tablet_mode.h index c807214..9f71113c 100644 --- a/ash/public/cpp/tablet_mode.h +++ b/ash/public/cpp/tablet_mode.h
@@ -6,63 +6,29 @@ #define ASH_PUBLIC_CPP_TABLET_MODE_H_ #include "ash/public/cpp/ash_public_export.h" -#include "base/macros.h" -#include "base/observer_list.h" - -namespace base { -template <typename T> -class NoDestructor; -} // namespace base namespace ash { -class TabletModeController; class TabletModeToggleObserver; -class TestTabletModeDelegate; -// TabletMode info that is maintained by Ash and allows Chrome to be informed -// when it changes. -class ASH_PUBLIC_EXPORT TabletMode final { +// An interface implemented by Ash that allows Chrome to be informed of changes +// to tablet mode state. +class ASH_PUBLIC_EXPORT TabletMode { public: - // Delegate interface to access tablet mode and change it. - class Delegate { - public: - // Invoked to get tablet mode. Returns true if the system is in tablet mode. - virtual bool InTabletMode() const = 0; - - // Invoked to force tablet mode for test. - virtual void SetEnabledForTest(bool enabled) = 0; - - protected: - Delegate(); - virtual ~Delegate(); - }; - // Returns the singleton instance. static TabletMode* Get(); + virtual void SetTabletModeToggleObserver( + TabletModeToggleObserver* observer) = 0; + // Returns true if the system is in tablet mode. - bool InTabletMode() const; + virtual bool InTabletMode() const = 0; - void SetEnabledForTest(bool enabled); + virtual void SetEnabledForTest(bool enabled) = 0; - void AddObserver(TabletModeToggleObserver* observer); - void RemoveObserver(TabletModeToggleObserver* observer); - - private: - friend class base::NoDestructor<TabletMode>; - friend class TabletModeController; - friend class TestTabletModeDelegate; - + protected: TabletMode(); - ~TabletMode(); - - // Invoked by TabletModeController to notify tablet mode is changed. - void NotifyTabletModeChanged(); - - base::ObserverList<TabletModeToggleObserver> observers_; - - DISALLOW_COPY_AND_ASSIGN(TabletMode); + virtual ~TabletMode(); }; } // namespace ash
diff --git a/ash/public/cpp/tablet_mode_toggle_observer.h b/ash/public/cpp/tablet_mode_toggle_observer.h index 7166aae..4bd0d200 100644 --- a/ash/public/cpp/tablet_mode_toggle_observer.h +++ b/ash/public/cpp/tablet_mode_toggle_observer.h
@@ -6,17 +6,18 @@ #define ASH_PUBLIC_CPP_TABLET_MODE_TOGGLE_OBSERVER_H_ #include "ash/public/cpp/ash_public_export.h" -#include "base/observer_list_types.h" namespace ash { // A simplified observer which allows Ash to inform Chrome when tablet mode has // been enabled or disabled. -class ASH_PUBLIC_EXPORT TabletModeToggleObserver - : public base::CheckedObserver { +class ASH_PUBLIC_EXPORT TabletModeToggleObserver { public: // Fired after the tablet mode has been toggled. virtual void OnTabletModeToggled(bool enabled) = 0; + + protected: + virtual ~TabletModeToggleObserver() = default; }; } // namespace ash
diff --git a/ash/public/cpp/tablet_mode_unittest.cc b/ash/public/cpp/tablet_mode_unittest.cc deleted file mode 100644 index 093c089..0000000 --- a/ash/public/cpp/tablet_mode_unittest.cc +++ /dev/null
@@ -1,73 +0,0 @@ -// Copyright 2019 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 "ash/public/cpp/tablet_mode.h" - -#include "ash/public/cpp/tablet_mode_toggle_observer.h" -#include "base/macros.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace ash { - -class TestTabletModeClientObserver : public TabletModeToggleObserver { - public: - TestTabletModeClientObserver() = default; - ~TestTabletModeClientObserver() override = default; - - // TabletModeToggleObserver: - void OnTabletModeToggled(bool enabled) override { - ++toggle_count_; - last_toggle_ = enabled; - } - - int toggle_count_ = 0; - bool last_toggle_ = false; - - private: - DISALLOW_COPY_AND_ASSIGN(TestTabletModeClientObserver); -}; - -class TestTabletModeDelegate : public TabletMode::Delegate { - public: - TestTabletModeDelegate() = default; - ~TestTabletModeDelegate() override = default; - - // TabletMode::Delegate: - bool InTabletMode() const override { return in_tablet_mode_; } - - void SetEnabledForTest(bool enabled) override { - in_tablet_mode_ = enabled; - TabletMode::Get()->NotifyTabletModeChanged(); - } - - private: - bool in_tablet_mode_ = false; - - DISALLOW_COPY_AND_ASSIGN(TestTabletModeDelegate); -}; - -using TabletModeTest = testing::Test; - -TEST_F(TabletModeTest, Observers) { - TestTabletModeDelegate delegate; - - TestTabletModeClientObserver observer; - TabletMode::Get()->AddObserver(&observer); - - // Observer is not notified with state when added. - EXPECT_EQ(0, observer.toggle_count_); - - // Setting state notifies observer. - TabletMode::Get()->SetEnabledForTest(true); - EXPECT_EQ(1, observer.toggle_count_); - EXPECT_TRUE(observer.last_toggle_); - - TabletMode::Get()->SetEnabledForTest(false); - EXPECT_EQ(2, observer.toggle_count_); - EXPECT_FALSE(observer.last_toggle_); - - TabletMode::Get()->RemoveObserver(&observer); -} - -} // namespace ash
diff --git a/ash/wm/tablet_mode/tablet_mode_controller.cc b/ash/wm/tablet_mode/tablet_mode_controller.cc index 5c17a50..126f095 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller.cc +++ b/ash/wm/tablet_mode/tablet_mode_controller.cc
@@ -13,6 +13,7 @@ #include "ash/public/cpp/fps_counter.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/tablet_mode.h" +#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_delegate.h" @@ -331,6 +332,13 @@ DeleteScreenshot(); } +void TabletModeController::SetTabletModeToggleObserver( + TabletModeToggleObserver* observer) { + DCHECK(observer); + DCHECK(!toggle_observer_); + toggle_observer_ = observer; +} + bool TabletModeController::InTabletMode() const { return !!tablet_mode_window_manager_; } @@ -620,7 +628,8 @@ observer.OnTabletModeEnded(); state_ = State::kInClamshellMode; - TabletMode::Get()->NotifyTabletModeChanged(); + if (toggle_observer_) // Null at startup and in tests. + toggle_observer_->OnTabletModeToggled(false); VLOG(1) << "Exit tablet mode."; } @@ -919,7 +928,8 @@ } state_ = State::kInTabletMode; - TabletMode::Get()->NotifyTabletModeChanged(); + if (toggle_observer_) // Null at startup and in tests. + toggle_observer_->OnTabletModeToggled(true); VLOG(1) << "Enter tablet mode."; }
diff --git a/ash/wm/tablet_mode/tablet_mode_controller.h b/ash/wm/tablet_mode/tablet_mode_controller.h index 1afe742..bc2ef66 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller.h +++ b/ash/wm/tablet_mode/tablet_mode_controller.h
@@ -67,7 +67,7 @@ class ASH_EXPORT TabletModeController : public AccelerometerReader::Observer, public chromeos::PowerManagerClient::Observer, - public TabletMode::Delegate, + public TabletMode, public ShellObserver, public WindowTreeHostManager::Observer, public SessionObserver, @@ -121,7 +121,8 @@ // clamshell. void StopObservingAnimation(bool record_stats, bool delete_screenshot); - // TabletMode::Delegate: + // TabletMode: + void SetTabletModeToggleObserver(TabletModeToggleObserver* observer) override; bool InTabletMode() const override; void SetEnabledForTest(bool enabled) override; @@ -359,6 +360,10 @@ gfx::Vector3dF base_smoothed_; gfx::Vector3dF lid_smoothed_; + // A simplified observer that only gets notified of entering or exiting tablet + // mode. + TabletModeToggleObserver* toggle_observer_ = nullptr; + // Tracks whether a flag is used to force ui mode. UiMode force_ui_mode_ = UiMode::kNone;
diff --git a/base/android/java/src/org/chromium/base/PathUtils.java b/base/android/java/src/org/chromium/base/PathUtils.java index 31fb11f..3f7d29c289 100644 --- a/base/android/java/src/org/chromium/base/PathUtils.java +++ b/base/android/java/src/org/chromium/base/PathUtils.java
@@ -9,13 +9,11 @@ import android.content.pm.ApplicationInfo; import android.os.Build; import android.os.Environment; -import android.os.SystemClock; import android.system.Os; import android.text.TextUtils; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.MainDex; -import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.task.AsyncTask; import java.io.File; @@ -200,26 +198,18 @@ @SuppressWarnings("unused") @CalledByNative private static String getDownloadsDirectory() { - // Temporarily allowing disk access while fixing. TODO: http://crbug.com/508615 + // TODO(crbug.com/508615): Temporarily allowing disk access until more permanent fix is in. try (StrictModeContext unused = StrictModeContext.allowDiskReads()) { - long time = SystemClock.elapsedRealtime(); - String downloadsPath; if (BuildInfo.isAtLeastQ()) { // https://developer.android.com/preview/privacy/scoped-storage // In Q+, Android has bugun sandboxing external storage. Chrome may not have // permission to write to Environment.getExternalStoragePublicDirectory(). Instead // using Context.getExternalFilesDir() will return a path to sandboxed external // storage for which no additional permissions are required. - downloadsPath = getAllPrivateDownloadsDirectories()[0]; - } else { - downloadsPath = - Environment - .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) - .getPath(); + return getAllPrivateDownloadsDirectories()[0]; } - RecordHistogram.recordTimesHistogram( - "Android.StrictMode.DownloadsDir", SystemClock.elapsedRealtime() - time); - return downloadsPath; + return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + .getPath(); } }
diff --git a/build/config/mac/rules.gni b/build/config/mac/rules.gni index 6927cf94..71c450d 100644 --- a/build/config/mac/rules.gni +++ b/build/config/mac/rules.gni
@@ -351,12 +351,6 @@ ":$_shared_library_bundle_data", ] - if (enable_dsyms) { - data = [ - "$root_out_dir/$_output_name.dSYM/", - ] - } - bundle_root_dir = _framework_base_dir bundle_contents_dir = _framework_root_dir bundle_resources_dir = "$bundle_contents_dir/Resources" @@ -557,13 +551,6 @@ if (_write_pkg_info) { deps += [ ":$_pkg_info_bundle_data" ] } - - if (enable_dsyms) { - data = [ - "$root_out_dir/$_output_name.dSYM/", - ] - } - product_type = _product_type bundle_root_dir = "$root_out_dir/${_output_name}.${_output_extension}" bundle_contents_dir = "$bundle_root_dir/Contents" @@ -630,12 +617,6 @@ } deps += [ ":$_loadable_module_bundle_data" ] - if (enable_dsyms) { - data = [ - "$root_out_dir/$_output_name.dSYM/", - ] - } - bundle_root_dir = "$root_out_dir/$_output_name.plugin" bundle_contents_dir = "$bundle_root_dir/Contents" bundle_executable_dir = "$bundle_contents_dir/MacOS"
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 9471121b..9c1cff4c 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -8909799344739653680 \ No newline at end of file +8909774244766161840 \ No newline at end of file
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index 15fa1102..a6b5b4f 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -8909803436810455824 \ No newline at end of file +8909774922283356560 \ No newline at end of file
diff --git a/cc/tiles/tile_manager.cc b/cc/tiles/tile_manager.cc index 165bb015..6e9cce9 100644 --- a/cc/tiles/tile_manager.cc +++ b/cc/tiles/tile_manager.cc
@@ -779,8 +779,12 @@ // If we couldn't fit the tile into our current memory limit, then we're // done. if (!memory_usage_is_within_limit) { - if (tile_is_needed_now) + if (tile_is_needed_now) { + LOG(ERROR) << "WARNING: tile memory limits exceeded, some content may " + "not draw"; + had_enough_memory_to_schedule_tiles_needed_now = false; + } all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; break; }
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index 3cefe8f..593a61c 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -554,6 +554,7 @@ "//chrome/browser/android/webapk/webapk_types.h", "//chrome/browser/banners/app_banner_settings_helper.h", "//chrome/browser/notifications/notification_channels_provider_android.h", + "//chrome/browser/notifications/notification_handler.h", "//chrome/browser/notifications/notification_platform_bridge_android.cc", "//chrome/browser/ntp_snippets/ntp_snippets_metrics.h", "//chrome/browser/profiles/profile_metrics.h", @@ -1509,7 +1510,6 @@ "javatests/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchTestBridge.java", "javatests/src/org/chromium/chrome/browser/test/MockCertVerifierRuleAndroid.java", ] - jni_package = "test_support_jni_headers" } # Test support code that needs access to the browser. @@ -2732,6 +2732,4 @@ "feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java", ] } - - jni_package = "chrome" }
diff --git a/chrome/android/features/autofill_assistant/BUILD.gn b/chrome/android/features/autofill_assistant/BUILD.gn index f360023..3ab38aef 100644 --- a/chrome/android/features/autofill_assistant/BUILD.gn +++ b/chrome/android/features/autofill_assistant/BUILD.gn
@@ -146,7 +146,6 @@ "java/src/org/chromium/chrome/browser/autofill_assistant/payment/AssistantPaymentRequestDelegate.java", "java/src/org/chromium/chrome/browser/autofill_assistant/payment/AssistantPaymentRequestModel.java", ] - jni_package = "autofill_assistant" } android_library("test_java") {
diff --git a/chrome/android/features/keyboard_accessory/BUILD.gn b/chrome/android/features/keyboard_accessory/BUILD.gn index 5384a03..b245a1b 100644 --- a/chrome/android/features/keyboard_accessory/BUILD.gn +++ b/chrome/android/features/keyboard_accessory/BUILD.gn
@@ -25,7 +25,6 @@ "internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingComponentBridge.java", "public/java/src/org/chromium/chrome/browser/keyboard_accessory/data/UserInfoField.java", ] - jni_package = "chrome" } android_library("test_java") { @@ -62,6 +61,7 @@ "//chrome/android/public/profiles:java", "//chrome/test/android:chrome_java_test_support", "//components/autofill/android:autofill_java", + "//components/autofill/core/common/mojom:mojo_types_java", "//components/feature_engagement/public:public_java", "//content/public/android:content_java", "//content/public/test/android:content_java_test_support",
diff --git a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingComponentBridge.java b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingComponentBridge.java index e2198e83..e55ce82 100644 --- a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingComponentBridge.java +++ b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingComponentBridge.java
@@ -170,6 +170,11 @@ } @VisibleForTesting + public static void notifyFocusedFieldType(WebContents webContents, int focusedFieldType) { + nativeNotifyFocusedFieldTypeForTesting(webContents, focusedFieldType); + } + + @VisibleForTesting public static void signalAutoGenerationStatus(WebContents webContents, boolean available) { nativeSignalAutoGenerationStatusForTesting(webContents, available); } @@ -183,6 +188,8 @@ private static native void nativeCachePasswordSheetDataForTesting( WebContents webContents, String[] userNames, String[] passwords); + private static native void nativeNotifyFocusedFieldTypeForTesting( + WebContents webContents, int focusedFieldType); private static native void nativeSignalAutoGenerationStatusForTesting( WebContents webContents, boolean available); }
diff --git a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingMediator.java b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingMediator.java index 4bcfb405..38fe36a 100644 --- a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingMediator.java +++ b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingMediator.java
@@ -583,8 +583,8 @@ ManualFillingState state = mStateCache.getStateFor(mActivity.getCurrentWebContents()); state.notifyObservers(); KeyboardAccessoryData.Tab[] tabs = state.getTabs(); + mAccessorySheet.setTabs(tabs); // Set the sheet tabs first to invalidate the tabs properly. mKeyboardAccessory.setTabs(tabs); - mAccessorySheet.setTabs(tabs); } @VisibleForTesting
diff --git a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutMediator.java b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutMediator.java index 2ff72be..ee1b002 100644 --- a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutMediator.java +++ b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutMediator.java
@@ -75,7 +75,11 @@ } return; } - if (propertyKey == TABS || propertyKey == TAB_SELECTION_CALLBACKS) { + if (propertyKey == TABS) { + closeActiveTab(); // Make sure the active tab is reset for a modified tab list. + return; + } + if (propertyKey == TAB_SELECTION_CALLBACKS) { return; } assert false : "Every property update needs to be handled explicitly!";
diff --git a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutViewBinder.java b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutViewBinder.java index 3249add..071fd61d 100644 --- a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutViewBinder.java +++ b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/tab_layout_component/KeyboardAccessoryTabLayoutViewBinder.java
@@ -27,33 +27,31 @@ @Override public void onItemsInserted(ListModel<KeyboardAccessoryData.Tab> model, KeyboardAccessoryTabLayoutView view, int index, int count) { - assert count > 0 : "Tried to insert invalid amount of tabs - must be at least one."; - for (int i = index; i < index + count; i++) { - KeyboardAccessoryData.Tab tab = model.get(i); - view.addTabAt(i, tab.getIcon(), tab.getContentDescription()); - } + // More fine-grained implementations showed artifacts when adding in quick succession. + updateAllTabs(view, model); } @Override public void onItemsRemoved(ListModel<KeyboardAccessoryData.Tab> model, KeyboardAccessoryTabLayoutView view, int index, int count) { - assert count > 0 : "Tried to remove invalid amount of tabs - must be at least one."; - while (count-- > 0) { - view.tryToRemoveTabAt(index++); - } + // More fine-grained implementations showed artifacts when removing in quick succession. + updateAllTabs(view, model); } @Override public void onItemsChanged(ListModel<KeyboardAccessoryData.Tab> model, KeyboardAccessoryTabLayoutView view, int index, int count) { - // TODO(fhorschig): Implement fine-grained, ranged changes should the need arise. updateAllTabs(view, model); } private void updateAllTabs( KeyboardAccessoryTabLayoutView view, ListModel<KeyboardAccessoryData.Tab> model) { view.removeAllTabs(); - if (model.size() > 0) onItemsInserted(model, view, 0, model.size()); + if (model.size() <= 0) return; + for (int i = 0; i < model.size(); i++) { + KeyboardAccessoryData.Tab tab = model.get(i); + view.addTabAt(i, tab.getIcon(), tab.getContentDescription()); + } } protected static void bind(
diff --git a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/AutofillKeyboardAccessoryIntegrationTest.java b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/AutofillKeyboardAccessoryIntegrationTest.java index 2f8fc040..a661b7f 100644 --- a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/AutofillKeyboardAccessoryIntegrationTest.java +++ b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/AutofillKeyboardAccessoryIntegrationTest.java
@@ -28,6 +28,7 @@ import org.junit.Test; import org.junit.runner.RunWith; +import org.chromium.autofill.mojom.FocusedFieldType; import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.RetryOnFailure; import org.chromium.chrome.browser.ChromeFeatureList; @@ -118,6 +119,7 @@ loadTestPage(FakeKeyboard::new); mHelper.clickNodeAndShowKeyboard("EMAIL_ADDRESS"); mHelper.waitForKeyboardAccessoryToBeShown(); + CriteriaHelper.pollUiThread(() -> getFirstSuggestion() != null); // Wait for suggestions. // Scroll to the second position and check it actually happened. TestThreadUtils.runOnUiThreadBlocking(() -> getSuggestionsComponent().scrollToPosition(2)); @@ -155,7 +157,7 @@ throws ExecutionException, InterruptedException, TimeoutException { MultiWindowUtils.getInstance().setIsInMultiWindowModeForTesting(true); loadTestPage(MultiWindowKeyboard::new); - mHelper.clickNode("NAME_FIRST"); + mHelper.clickNode("NAME_FIRST", FocusedFieldType.FILLABLE_NON_SEARCH_FIELD); mHelper.waitForKeyboardAccessoryToBeShown(); CriteriaHelper.pollUiThread(() -> getFirstSuggestion() != null); @@ -189,7 +191,7 @@ throws ExecutionException, InterruptedException, TimeoutException { MultiWindowUtils.getInstance().setIsInMultiWindowModeForTesting(true); loadTestPage(MultiWindowKeyboard::new); - mHelper.clickNode("NAME_FIRST"); + mHelper.clickNode("NAME_FIRST", FocusedFieldType.FILLABLE_NON_SEARCH_FIELD); mHelper.waitForKeyboardAccessoryToBeShown(); whenDisplayed(withId(R.id.bar_items_view)) @@ -223,6 +225,7 @@ private View getFirstSuggestion() { ViewGroup recyclerView = getSuggestionsComponent(); assert recyclerView != null; - return recyclerView.getChildAt(0); + View view = recyclerView.getChildAt(0); + return isKeyboardAccessoryTabLayout().matches(view) ? null : view; } }
diff --git a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingTestHelper.java b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingTestHelper.java index 0c1ddf2..6247ee3 100644 --- a/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingTestHelper.java +++ b/chrome/android/features/keyboard_accessory/javatests/src/org/chromium/chrome/browser/keyboard_accessory/ManualFillingTestHelper.java
@@ -11,6 +11,7 @@ import static org.hamcrest.core.AllOf.allOf; +import static org.chromium.autofill.mojom.FocusedFieldType.FILLABLE_NON_SEARCH_FIELD; import static org.chromium.chrome.test.util.ViewUtils.VIEW_GONE; import static org.chromium.chrome.test.util.ViewUtils.VIEW_INVISIBLE; import static org.chromium.chrome.test.util.ViewUtils.VIEW_NULL; @@ -168,12 +169,22 @@ public void clickNodeAndShowKeyboard(String node) throws TimeoutException, InterruptedException { - clickNode(node); + clickNodeAndShowKeyboard(node, FILLABLE_NON_SEARCH_FIELD); + } + + public void clickNodeAndShowKeyboard(String node, int focusedFieldType) + throws TimeoutException, InterruptedException { + clickNode(node, focusedFieldType); getKeyboard().showKeyboard(mActivityTestRule.getActivity().getCurrentFocus()); } - public void clickNode(String node) throws TimeoutException, InterruptedException { + public void clickNode(String node, int focusedFieldType) + throws TimeoutException, InterruptedException { DOMUtils.clickNode(mWebContentsRef.get(), node); + TestThreadUtils.runOnUiThreadBlocking(() -> { + ManualFillingComponentBridge.notifyFocusedFieldType( + mActivityTestRule.getWebContents(), focusedFieldType); + }); } /**
diff --git a/chrome/android/features/media_router/BUILD.gn b/chrome/android/features/media_router/BUILD.gn index b80012a4..4ba1824 100644 --- a/chrome/android/features/media_router/BUILD.gn +++ b/chrome/android/features/media_router/BUILD.gn
@@ -72,7 +72,6 @@ "java/src/org/chromium/chrome/browser/media/router/FlingingControllerBridge.java", "java/src/org/chromium/chrome/browser/media/router/MediaStatusBridge.java", ] - jni_package = "media_router" } android_library("test_java") {
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListRecyclerView.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListRecyclerView.java index 73ff78e5..bbea47a 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListRecyclerView.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabListRecyclerView.java
@@ -89,27 +89,16 @@ } private class TabListOnScrollListener extends RecyclerView.OnScrollListener { - // TODO(mattsimmons): Remove state from this class. This is here to prevent scroll signals - // from showing the toolbar shadow after the show/hide of the GTS has already triggered the - // shadow being hidden. Due to this view's visibility being updated asynchronously after - // animating off-screen, checking View.getVisibility() can't be used as the guard condition - // here. Removing/Adding the listener from the view also happens asynchronously and has - // similar undesirable effects. - private boolean mIsActive; - - public void pause() { - mIsActive = false; - } - - public void resume() { - mIsActive = true; - } - @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { - if (!mIsActive) return; - final int yOffset = recyclerView.computeVerticalScrollOffset(); + if (yOffset == 0) { + setShadowVisibility(false); + return; + } + + if (dy == 0 || recyclerView.getScrollState() == SCROLL_STATE_SETTLING) return; + setShadowVisibility(yOffset > 0); } } @@ -176,7 +165,6 @@ mListener.finishedShowing(); // Restore the original value. setItemAnimator(mOriginalAnimator); - mScrollListener.resume(); setShadowVisibility(computeVerticalScrollOffset() > 0); if (mDynamicView != null) { mDynamicView.dropCachedBitmap(); @@ -335,7 +323,6 @@ mListener.finishedHiding(); } }); - mScrollListener.pause(); setShadowVisibility(false); mFadeOutAnimator.start(); if (!animate) mFadeOutAnimator.end();
diff --git a/chrome/android/features/vr/BUILD.gn b/chrome/android/features/vr/BUILD.gn index bbb1230..9f7e084 100644 --- a/chrome/android/features/vr/BUILD.gn +++ b/chrome/android/features/vr/BUILD.gn
@@ -150,6 +150,4 @@ "java/src/org/chromium/chrome/browser/vr/keyboard/GvrKeyboardLoaderClient.java", "java/src/org/chromium/chrome/browser/vr/keyboard/TextEditAction.java", ] - - jni_package = "vr" }
diff --git a/chrome/android/java/res/xml/theme_preferences.xml b/chrome/android/java/res/xml/theme_preferences.xml index 9e1f0e7..5368fa6 100644 --- a/chrome/android/java/res/xml/theme_preferences.xml +++ b/chrome/android/java/res/xml/theme_preferences.xml
@@ -3,7 +3,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> -<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> +<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <org.chromium.chrome.browser.preferences.themes.RadioButtonGroupThemePreference android:key="ui_theme_pref" /> -</PreferenceScreen> \ No newline at end of file +</android.support.v7.preference.PreferenceScreen> \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadActivity.java index 5a28fbe3..d39991129 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadActivity.java
@@ -22,13 +22,14 @@ import org.chromium.ui.base.ActivityAndroidPermissionDelegate; import org.chromium.ui.base.AndroidPermissionDelegate; import org.chromium.ui.modaldialog.ModalDialogManager; +import org.chromium.ui.modaldialog.ModalDialogManagerHolder; import java.lang.ref.WeakReference; /** * Activity for managing downloads handled through Chrome. */ -public class DownloadActivity extends SnackbarActivity { +public class DownloadActivity extends SnackbarActivity implements ModalDialogManagerHolder { private static final String BUNDLE_KEY_CURRENT_URL = "current_url"; private DownloadManagerCoordinator mDownloadCoordinator; @@ -105,6 +106,11 @@ super.onDestroy(); } + @Override + public ModalDialogManager getModalDialogManager() { + return mModalDialogManager; + } + @VisibleForTesting DownloadManagerUi getDownloadManagerUiForTests() { // TODO(856383): Generalize/fix download home tests for the new DownloadManagerCoordinator.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java index ef079eb..332feb1 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java
@@ -6,12 +6,8 @@ import android.Manifest.permission; import android.app.Activity; -import android.content.DialogInterface; import android.content.pm.PackageManager; -import android.support.v7.app.AlertDialog; import android.util.Pair; -import android.view.View; -import android.widget.TextView; import org.chromium.base.ApplicationStatus; import org.chromium.base.Callback; @@ -21,13 +17,13 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeFeatureList; +import org.chromium.chrome.browser.permissions.AndroidPermissionRequester; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.components.download.DownloadCollectionBridge; import org.chromium.content_public.browser.BrowserStartupController; import org.chromium.content_public.browser.WebContents; -import org.chromium.ui.UiUtils; import org.chromium.ui.base.AndroidPermissionDelegate; import org.chromium.ui.base.PermissionCallback; import org.chromium.ui.base.WindowAndroid; @@ -199,27 +195,18 @@ return; } - View view = activity.getLayoutInflater().inflate(R.layout.update_permissions_dialog, null); - TextView dialogText = (TextView) view.findViewById(R.id.text); - dialogText.setText(R.string.missing_storage_permission_download_education_text); - final AndroidPermissionDelegate permissionDelegate = delegate; final PermissionCallback permissionCallback = (permissions, grantResults) -> callback.onResult(Pair.create(grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED, null)); - AlertDialog.Builder builder = - new UiUtils - .CompatibleAlertDialogBuilder(activity, R.style.Theme_Chromium_AlertDialog) - .setView(view) - .setPositiveButton(R.string.infobar_update_permissions_button_text, - (DialogInterface.OnClickListener) (dialog, id) - -> permissionDelegate.requestPermissions( - new String[] {permission.WRITE_EXTERNAL_STORAGE}, - permissionCallback)) - .setOnCancelListener(dialog -> callback.onResult(Pair.create(false, null))); - builder.create().show(); + AndroidPermissionRequester.showMissingPermissionDialog(activity, + R.string.missing_storage_permission_download_education_text, + () -> permissionDelegate.requestPermissions( + new String[] {permission.WRITE_EXTERNAL_STORAGE}, + permissionCallback), + () -> callback.onResult(Pair.create(false, null))); } /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java index 551bdfa..05b1bc8b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/init/AsyncInitializationActivity.java
@@ -49,14 +49,15 @@ import org.chromium.ui.display.DisplayAndroid; import org.chromium.ui.display.DisplayUtil; import org.chromium.ui.modaldialog.ModalDialogManager; +import org.chromium.ui.modaldialog.ModalDialogManagerHolder; import java.lang.reflect.Field; /** * An activity that talks with application and activity level delegates for async initialization. */ -public abstract class AsyncInitializationActivity - extends ChromeBaseAppCompatActivity implements ChromeActivityNativeDelegate, BrowserParts { +public abstract class AsyncInitializationActivity extends ChromeBaseAppCompatActivity + implements ChromeActivityNativeDelegate, BrowserParts, ModalDialogManagerHolder { private static final String TAG = "AsyncInitActivity"; protected final Handler mHandler; @@ -603,6 +604,7 @@ * @return The {@link ModalDialogManager} that manages the display of modal dialogs (e.g. * JavaScript dialogs). */ + @Override public ModalDialogManager getModalDialogManager() { return mModalDialogManager; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationConstants.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationConstants.java index 7fd1fb44..6e39b551 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationConstants.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationConstants.java
@@ -30,6 +30,7 @@ * it *must* also be set in {@link NotificationJobService#getJobExtrasFromIntent(Intent)} */ public static final String EXTRA_NOTIFICATION_ID = "notification_id"; + static final String EXTRA_NOTIFICATION_TYPE = "notification_type"; static final String EXTRA_NOTIFICATION_INFO_ORIGIN = "notification_info_origin"; static final String EXTRA_NOTIFICATION_INFO_SCOPE = "notification_info_scope"; static final String EXTRA_NOTIFICATION_INFO_PROFILE_ID = "notification_info_profile_id";
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationJobService.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationJobService.java index 91b00ff..26c3828 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationJobService.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationJobService.java
@@ -25,6 +25,9 @@ PersistableBundle bundle = new PersistableBundle(); bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_ID, intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_ID)); + bundle.putInt(NotificationConstants.EXTRA_NOTIFICATION_TYPE, + intent.getIntExtra(NotificationConstants.EXTRA_NOTIFICATION_TYPE, + NotificationType.WEB_PERSISTENT)); bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN, intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN)); bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_SCOPE,
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java index 13007f8..ad606be 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
@@ -163,6 +163,9 @@ recordJobStartDelayUMA(intent); String notificationId = intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_ID); + @NotificationType + int notificationType = intent.getIntExtra( + NotificationConstants.EXTRA_NOTIFICATION_TYPE, NotificationType.WEB_PERSISTENT); String origin = intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN); String scopeUrl = @@ -183,15 +186,15 @@ } int actionIndex = intent.getIntExtra( NotificationConstants.EXTRA_NOTIFICATION_INFO_ACTION_INDEX, -1); - sInstance.onNotificationClicked(notificationId, origin, scopeUrl, profileId, incognito, - webApkPackage, actionIndex, getNotificationReply(intent)); + sInstance.onNotificationClicked(notificationId, notificationType, origin, scopeUrl, + profileId, incognito, webApkPackage, actionIndex, getNotificationReply(intent)); return true; } else if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) { // Notification deleteIntent is executed only "when the notification is explicitly // dismissed by the user, either with the 'Clear All' button or by swiping it away // individually" (though a third-party NotificationListenerService may also trigger it). - sInstance.onNotificationClosed( - notificationId, origin, profileId, incognito, true /* byUser */); + sInstance.onNotificationClosed(notificationId, notificationType, origin, profileId, + incognito, true /* byUser */); return true; } @@ -320,8 +323,9 @@ * @param actionIndex The zero-based index of the action button, or -1 if not applicable. */ private PendingIntentProvider makePendingIntent(Context context, String action, - String notificationId, String origin, String scopeUrl, String profileId, - boolean incognito, String webApkPackage, int actionIndex) { + String notificationId, @NotificationType int notificationType, String origin, + String scopeUrl, String profileId, boolean incognito, String webApkPackage, + int actionIndex) { Uri intentData = makeIntentData(notificationId, origin, actionIndex); Intent intent = new Intent(action, intentData); intent.setClass(context, NotificationService.Receiver.class); @@ -329,6 +333,7 @@ // Make sure to update NotificationJobService.getJobExtrasFromIntent() when changing any // of the extras included with the |intent|. intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_ID, notificationId); + intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_TYPE, notificationType); intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN, origin); intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_SCOPE, scopeUrl); intent.putExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_ID, profileId); @@ -485,16 +490,18 @@ * Android Notification API</a> */ @CalledByNative - private void displayNotification(final String notificationId, final String origin, + private void displayNotification(final String notificationId, + @NotificationType final int notificationType, final String origin, final String scopeUrl, final String profileId, final boolean incognito, final String title, final String body, final Bitmap image, final Bitmap icon, final Bitmap badge, final int[] vibrationPattern, final long timestamp, final boolean renotify, final boolean silent, final ActionInfo[] actions) { getWebApkPackage(scopeUrl).then( (Callback<String>) (webApkPackage) - -> displayNotificationInternal(notificationId, origin, scopeUrl, profileId, - incognito, title, body, image, icon, badge, vibrationPattern, - timestamp, renotify, silent, actions, webApkPackage)); + -> displayNotificationInternal(notificationId, notificationType, origin, + scopeUrl, profileId, incognito, title, body, image, icon, badge, + vibrationPattern, timestamp, renotify, silent, actions, + webApkPackage)); } private Promise<String> getWebApkPackage(String scopeUrl) { @@ -509,7 +516,8 @@ } /** Called after querying whether the browser backs the given WebAPK. */ - private void displayNotificationInternal(String notificationId, String origin, String scopeUrl, + private void displayNotificationInternal(String notificationId, + @NotificationType int notificationType, String origin, String scopeUrl, String profileId, boolean incognito, String title, String body, Bitmap image, Bitmap icon, Bitmap badge, int[] vibrationPattern, long timestamp, boolean renotify, boolean silent, ActionInfo[] actions, String webApkPackage) { @@ -519,8 +527,8 @@ NotificationSystemStatusUtil.recordAppNotificationStatusHistogram(); NotificationBuilderBase notificationBuilder = prepareNotificationBuilder(notificationId, - origin, scopeUrl, profileId, incognito, title, body, image, icon, badge, - vibrationPattern, timestamp, renotify, silent, actions, webApkPackage); + notificationType, origin, scopeUrl, profileId, incognito, title, body, image, icon, + badge, vibrationPattern, timestamp, renotify, silent, actions, webApkPackage); // Delegate notification to WebAPK. if (!webApkPackage.isEmpty()) { @@ -550,18 +558,19 @@ }); } - private NotificationBuilderBase prepareNotificationBuilder(String notificationId, String origin, - String scopeUrl, String profileId, boolean incognito, String title, String body, - Bitmap image, Bitmap icon, Bitmap badge, int[] vibrationPattern, long timestamp, - boolean renotify, boolean silent, ActionInfo[] actions, String webApkPackage) { + private NotificationBuilderBase prepareNotificationBuilder(String notificationId, + @NotificationType int notificationType, String origin, String scopeUrl, + String profileId, boolean incognito, String title, String body, Bitmap image, + Bitmap icon, Bitmap badge, int[] vibrationPattern, long timestamp, boolean renotify, + boolean silent, ActionInfo[] actions, String webApkPackage) { Context context = ContextUtils.getApplicationContext(); PendingIntentProvider clickIntent = makePendingIntent(context, - NotificationConstants.ACTION_CLICK_NOTIFICATION, notificationId, origin, scopeUrl, - profileId, incognito, webApkPackage, -1 /* actionIndex */); + NotificationConstants.ACTION_CLICK_NOTIFICATION, notificationId, notificationType, + origin, scopeUrl, profileId, incognito, webApkPackage, -1 /* actionIndex */); PendingIntentProvider closeIntent = makePendingIntent(context, - NotificationConstants.ACTION_CLOSE_NOTIFICATION, notificationId, origin, scopeUrl, - profileId, incognito, webApkPackage, -1 /* actionIndex */); + NotificationConstants.ACTION_CLOSE_NOTIFICATION, notificationId, notificationType, + origin, scopeUrl, profileId, incognito, webApkPackage, -1 /* actionIndex */); boolean hasImage = image != null; boolean forWebApk = !webApkPackage.isEmpty(); @@ -589,9 +598,10 @@ } for (int actionIndex = 0; actionIndex < actions.length; actionIndex++) { - PendingIntentProvider intent = makePendingIntent(context, - NotificationConstants.ACTION_CLICK_NOTIFICATION, notificationId, origin, - scopeUrl, profileId, incognito, webApkPackage, actionIndex); + PendingIntentProvider intent = + makePendingIntent(context, NotificationConstants.ACTION_CLICK_NOTIFICATION, + notificationId, notificationType, origin, scopeUrl, profileId, + incognito, webApkPackage, actionIndex); ActionInfo action = actions[actionIndex]; // Don't show action button icons when there's an image, as then action buttons go on // the same row as the Site Settings button, so icons wouldn't leave room for text. @@ -781,12 +791,13 @@ * @param reply User reply to a text action on the notification. Null if the user did not click * on a text action or if inline replies are not supported. */ - private void onNotificationClicked(String notificationId, String origin, String scopeUrl, - String profileId, boolean incognito, String webApkPackage, int actionIndex, - @Nullable String reply) { + private void onNotificationClicked(String notificationId, int notificationType, String origin, + String scopeUrl, String profileId, boolean incognito, String webApkPackage, + int actionIndex, @Nullable String reply) { mLastNotificationClickMs = System.currentTimeMillis(); - nativeOnNotificationClicked(mNativeNotificationPlatformBridge, notificationId, origin, - scopeUrl, profileId, incognito, webApkPackage, actionIndex, reply); + nativeOnNotificationClicked(mNativeNotificationPlatformBridge, notificationId, + notificationType, origin, scopeUrl, profileId, incognito, webApkPackage, + actionIndex, reply); } /** @@ -799,10 +810,10 @@ * @param incognito if the profile session was an off the record one. * @param byUser Whether the notification was closed by a user gesture. */ - private void onNotificationClosed(String notificationId, String origin, String profileId, - boolean incognito, boolean byUser) { - nativeOnNotificationClosed(mNativeNotificationPlatformBridge, notificationId, origin, - profileId, incognito, byUser); + private void onNotificationClosed(String notificationId, int notificationType, String origin, + String profileId, boolean incognito, boolean byUser) { + nativeOnNotificationClosed(mNativeNotificationPlatformBridge, notificationId, + notificationType, origin, profileId, incognito, byUser); } private TrustedWebActivityClient getTwaClient() { @@ -815,11 +826,12 @@ private static native void nativeInitializeNotificationPlatformBridge(); private native void nativeOnNotificationClicked(long nativeNotificationPlatformBridgeAndroid, - String notificationId, String origin, String scopeUrl, String profileId, - boolean incognito, String webApkPackage, int actionIndex, String reply); + String notificationId, @NotificationType int notificationType, String origin, + String scopeUrl, String profileId, boolean incognito, String webApkPackage, + int actionIndex, String reply); private native void nativeOnNotificationClosed(long nativeNotificationPlatformBridgeAndroid, - String notificationId, String origin, String profileId, boolean incognito, - boolean byUser); + String notificationId, @NotificationType int notificationType, String origin, + String profileId, boolean incognito, boolean byUser); private native void nativeStoreCachedWebApkPackageForNotificationId( long nativeNotificationPlatformBridgeAndroid, String notificationId, String webApkPackage);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java b/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java index 208d133d..c4982e6 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java
@@ -5,9 +5,8 @@ package org.chromium.chrome.browser.permissions; import android.app.Activity; -import android.content.DialogInterface; import android.content.pm.PackageManager; -import android.support.v7.app.AlertDialog; +import android.support.annotation.StringRes; import android.util.SparseArray; import android.view.View; import android.widget.TextView; @@ -17,10 +16,16 @@ import org.chromium.chrome.browser.metrics.WebApkUma; import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.tab.Tab; +import org.chromium.chrome.browser.touchless.TouchlessDelegate; +import org.chromium.chrome.browser.util.FeatureUtilities; import org.chromium.chrome.browser.webapps.WebApkActivity; -import org.chromium.ui.UiUtils; import org.chromium.ui.base.PermissionCallback; import org.chromium.ui.base.WindowAndroid; +import org.chromium.ui.modaldialog.DialogDismissalCause; +import org.chromium.ui.modaldialog.ModalDialogManager; +import org.chromium.ui.modaldialog.ModalDialogManagerHolder; +import org.chromium.ui.modaldialog.ModalDialogProperties; +import org.chromium.ui.modelutil.PropertyModel; import java.util.ArrayList; import java.util.Collections; @@ -149,28 +154,9 @@ != -1 : "Invalid combination of missing content settings: " + deniedContentSettings; - View view = activity.getLayoutInflater().inflate( - R.layout.update_permissions_dialog, null); - TextView dialogText = (TextView) view.findViewById(R.id.text); - dialogText.setText(deniedStringId); - - AlertDialog.Builder builder = new UiUtils.CompatibleAlertDialogBuilder( - activity, R.style.Theme_Chromium_AlertDialog); - builder.setView(view); - builder.setPositiveButton(R.string.infobar_update_permissions_button_text, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - requestAndroidPermissions(tab, contentSettingsTypes, delegate); - } - }); - builder.setOnCancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - delegate.onAndroidPermissionCanceled(); - } - }); - builder.create().show(); + showMissingPermissionDialog(activity, deniedStringId, + () -> requestAndroidPermissions(tab, contentSettingsTypes, delegate), + delegate::onAndroidPermissionCanceled); } else if (deniedContentSettings.isEmpty()) { delegate.onAndroidPermissionAccepted(); } else { @@ -192,4 +178,57 @@ } return true; } + + /** + * Shows a dialog that informs the user about a missing Android permission. + * @param activity Current Activity. It should implement {@link ModalDialogManagerHolder}. + * @param messageId The message that is shown on the dialog. + * @param onPositiveButtonClicked Runnable that is executed on positive button click. + * @param onCancelled Runnable that is executed on cancellation. + */ + public static void showMissingPermissionDialog(Activity activity, @StringRes int messageId, + Runnable onPositiveButtonClicked, Runnable onCancelled) { + assert activity instanceof ModalDialogManagerHolder + : "Activity should implement ModalDialogManagerHolder"; + final ModalDialogManager modalDialogManager = + ((ModalDialogManagerHolder) activity).getModalDialogManager(); + assert modalDialogManager != null : "ModalDialogManager is null"; + + ModalDialogProperties.Controller controller = new ModalDialogProperties.Controller() { + @Override + public void onClick(PropertyModel model, int buttonType) { + if (buttonType == ModalDialogProperties.ButtonType.POSITIVE) { + onPositiveButtonClicked.run(); + modalDialogManager.dismissDialog( + model, DialogDismissalCause.POSITIVE_BUTTON_CLICKED); + } + } + + @Override + public void onDismiss(PropertyModel model, int dismissalCause) { + if (dismissalCause != DialogDismissalCause.POSITIVE_BUTTON_CLICKED) { + onCancelled.run(); + } + } + }; + PropertyModel dialogModel; + if (FeatureUtilities.isNoTouchModeEnabled()) { + dialogModel = TouchlessDelegate.getMissingPermissionDialogModel( + activity, controller, messageId); + } else { + View view = + activity.getLayoutInflater().inflate(R.layout.update_permissions_dialog, null); + TextView dialogText = view.findViewById(R.id.text); + dialogText.setText(messageId); + dialogModel = new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS) + .with(ModalDialogProperties.CUSTOM_VIEW, view) + .with(ModalDialogProperties.CANCEL_ON_TOUCH_OUTSIDE, true) + .with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, + activity.getString( + R.string.infobar_update_permissions_button_text)) + .with(ModalDialogProperties.CONTROLLER, controller) + .build(); + } + modalDialogManager.showDialog(dialogModel, ModalDialogManager.ModalDialogType.APP); + } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/permissions/PermissionDialogModel.java b/chrome/android/java/src/org/chromium/chrome/browser/permissions/PermissionDialogModel.java index d82f58d..c6a7c35a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/permissions/PermissionDialogModel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/permissions/PermissionDialogModel.java
@@ -24,7 +24,7 @@ public static PropertyModel getModel( ModalDialogProperties.Controller controller, PermissionDialogDelegate delegate) { if (FeatureUtilities.isNoTouchModeEnabled()) { - return TouchlessDelegate.getTouchlessPermissionDialogModel(controller, delegate); + return TouchlessDelegate.getPermissionDialogModel(controller, delegate); } Context context = delegate.getTab().getActivity();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/RadioButtonGroupThemePreference.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/RadioButtonGroupThemePreference.java index 4e3585d..ad8a6f8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/RadioButtonGroupThemePreference.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/RadioButtonGroupThemePreference.java
@@ -5,9 +5,9 @@ package org.chromium.chrome.browser.preferences.themes; import android.content.Context; -import android.preference.Preference; +import android.support.v7.preference.Preference; +import android.support.v7.preference.PreferenceViewHolder; import android.util.AttributeSet; -import android.view.View; import org.chromium.base.VisibleForTesting; import org.chromium.chrome.R; @@ -45,13 +45,16 @@ } @Override - protected void onBindView(View view) { - super.onBindView(view); + public void onBindViewHolder(PreferenceViewHolder holder) { + super.onBindViewHolder(holder); assert ThemeSetting.NUM_ENTRIES == 3; - mButtons.set(ThemeSetting.SYSTEM_DEFAULT, view.findViewById(R.id.system_default)); - mButtons.set(ThemeSetting.LIGHT, view.findViewById(R.id.light)); - mButtons.set(ThemeSetting.DARK, view.findViewById(R.id.dark)); + mButtons.set(ThemeSetting.SYSTEM_DEFAULT, + (RadioButtonWithDescription) holder.findViewById(R.id.system_default)); + mButtons.set( + ThemeSetting.LIGHT, (RadioButtonWithDescription) holder.findViewById(R.id.light)); + mButtons.set( + ThemeSetting.DARK, (RadioButtonWithDescription) holder.findViewById(R.id.dark)); for (int i = 0; i < ThemeSetting.NUM_ENTRIES; i++) { mButtons.get(i).setRadioButtonGroup(mButtons);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/ThemePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/ThemePreferences.java index 18b47ad..a0b8181 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/ThemePreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/themes/ThemePreferences.java
@@ -8,10 +8,9 @@ import android.os.Build; import android.os.Bundle; -import android.preference.PreferenceFragment; import android.support.annotation.IntDef; import android.support.annotation.Nullable; -import android.widget.ListView; +import android.support.v7.preference.PreferenceFragmentCompat; import org.chromium.chrome.R; import org.chromium.chrome.browser.preferences.ChromePreferenceManager; @@ -24,7 +23,7 @@ /** * Fragment to manage the theme user settings. */ -public class ThemePreferences extends PreferenceFragment { +public class ThemePreferences extends PreferenceFragmentCompat { /** * Theme preference variations. This is also used for histograms and should therefore be treated * as append-only. See DarkThemePreferences in tools/metrics/histograms/enums.xml. @@ -43,9 +42,7 @@ static final String PREF_UI_THEME_PREF = "ui_theme_pref"; @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - + public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) { PreferenceUtils.addPreferencesFromResource(this, R.xml.theme_preferences); getActivity().setTitle(getResources().getString(R.string.prefs_themes)); @@ -72,7 +69,6 @@ getResources().getBoolean(R.bool.window_light_navigation_bar)); } - ListView listView = getView().findViewById(android.R.id.list); - listView.setDivider(null); + setDivider(null); } } \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java index b506d372..f95f5ac5 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java
@@ -14,7 +14,6 @@ import android.os.Build; import android.os.Bundle; import android.os.StrictMode; -import android.os.SystemClock; import android.support.annotation.Nullable; import android.text.TextUtils; import android.view.View; @@ -25,6 +24,7 @@ import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApplicationStatus; import org.chromium.base.Log; +import org.chromium.base.StrictModeContext; import org.chromium.base.VisibleForTesting; import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordUserAction; @@ -360,15 +360,9 @@ String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false); File tabFile = new File(getActivityDirectory(), tabFileName); - // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 - StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - long time = SystemClock.elapsedRealtime(); + // TODO(crbug.com/525785): Temporarily allowing disk access until more permanent fix is in. + try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) { TabState.saveState(tabFile, TabState.from(getActivityTab()), false); - RecordHistogram.recordTimesHistogram( - "Android.StrictMode.WebappSaveState", SystemClock.elapsedRealtime() - time); - } finally { - StrictMode.setThreadPolicy(oldPolicy); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappAuthenticator.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappAuthenticator.java index 52f56f2..c72ab6c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappAuthenticator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappAuthenticator.java
@@ -6,14 +6,12 @@ import android.annotation.SuppressLint; import android.content.Context; -import android.os.StrictMode; -import android.os.SystemClock; import android.util.Log; import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ContextUtils; import org.chromium.base.SecureRandomInitializer; -import org.chromium.base.metrics.CachedMetrics.TimesHistogramSample; +import org.chromium.base.StrictModeContext; import java.io.File; import java.io.FileInputStream; @@ -46,9 +44,6 @@ private static SecretKey sKey; - private static final TimesHistogramSample sWebappValidationTimes = - new TimesHistogramSample("Android.StrictMode.WebappAuthenticatorMac"); - /** * @see #getMacForUrl * @@ -58,15 +53,10 @@ * @return true if the MAC is a valid MAC for the URL, false otherwise. */ public static boolean isUrlValid(String url, byte[] mac) { - byte[] goodMac = null; - // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525785 - StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); - try { - long time = SystemClock.elapsedRealtime(); + byte[] goodMac; + // TODO(crbug.com/525785): Temporarily allowing disk access until more permanent fix is in. + try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) { goodMac = getMacForUrl(url); - sWebappValidationTimes.record(SystemClock.elapsedRealtime() - time); - } finally { - StrictMode.setThreadPolicy(oldPolicy); } if (goodMac == null) { return false;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDirectoryManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDirectoryManager.java index df77a03..d057184 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDirectoryManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDirectoryManager.java
@@ -11,8 +11,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Build; -import android.os.StrictMode; -import android.os.SystemClock; import android.text.TextUtils; import android.text.format.DateUtils; @@ -21,7 +19,7 @@ import org.chromium.base.Log; import org.chromium.base.PackageUtils; import org.chromium.base.PathUtils; -import org.chromium.base.metrics.RecordHistogram; +import org.chromium.base.StrictModeContext; import org.chromium.base.task.AsyncTask; import org.chromium.base.task.BackgroundOnlyAsyncTask; import org.chromium.chrome.browser.document.DocumentUtils; @@ -185,19 +183,13 @@ * @return File for storing information about the web app. */ File getWebappDirectory(Context context, String webappId) { - // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 - StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); - try { - long timeMs = SystemClock.elapsedRealtime(); + // TODO(crbug.com/525785): Temporarily allowing disk access until more permanent fix is in. + try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) { File webappDirectory = new File(getBaseWebappDirectory(context), webappId); if (!webappDirectory.exists() && !webappDirectory.mkdir()) { Log.e(TAG, "Failed to create web app directory."); } - RecordHistogram.recordTimesHistogram( - "Android.StrictMode.WebappDir", SystemClock.elapsedRealtime() - timeMs); return webappDirectory; - } finally { - StrictMode.setThreadPolicy(oldPolicy); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java index f82ad603..43fb9323 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webauth/AuthenticatorImpl.java
@@ -40,6 +40,8 @@ .Callback2<Integer, MakeCredentialAuthenticatorResponse> mMakeCredentialCallback; private org.chromium.mojo.bindings.Callbacks .Callback2<Integer, GetAssertionAuthenticatorResponse> mGetAssertionCallback; + private org.chromium.mojo.bindings.Callbacks + .Callback1<Boolean> mIsUserVerifyingPlatformAuthenticatorAvailableCallback; /** * Builds the Authenticator service implementation. @@ -140,6 +142,13 @@ } @Override + public void onIsUserVerifyingPlatformAuthenticatorAvailableResponse(boolean isUVPAA) { + assert mIsUserVerifyingPlatformAuthenticatorAvailableCallback != null; + mIsUserVerifyingPlatformAuthenticatorAvailableCallback.call(isUVPAA); + close(); + } + + @Override public void onError(Integer status) { assert((mMakeCredentialCallback != null && mGetAssertionCallback == null) || (mMakeCredentialCallback == null && mGetAssertionCallback != null));
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webauth/Fido2ApiHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/webauth/Fido2ApiHandler.java index 2a6670f..c7ba264 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webauth/Fido2ApiHandler.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webauth/Fido2ApiHandler.java
@@ -50,4 +50,7 @@ protected void getAssertion(PublicKeyCredentialRequestOptions options, RenderFrameHost frameHost, HandlerResponseCallback callback) {} + + protected void isUserVerifyingPlatformAuthenticatorAvailable( + RenderFrameHost frameHost, HandlerResponseCallback callback) {} }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webauth/HandlerResponseCallback.java b/chrome/android/java/src/org/chromium/chrome/browser/webauth/HandlerResponseCallback.java index 453a3be8..35c67b06 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/webauth/HandlerResponseCallback.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/webauth/HandlerResponseCallback.java
@@ -24,6 +24,12 @@ void onSignResponse(Integer status, GetAssertionAuthenticatorResponse response); /** + * Interface that returns the response from a request to call + * isUserVerifyingPlatformAuthenticatorAvailable. + */ + void onIsUserVerifyingPlatformAuthenticatorAvailableResponse(boolean isUVPAA); + + /** * Interface that returns any errors from either register or sign requests. */ void onError(Integer status);
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/themes/ThemePreferencesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/themes/ThemePreferencesTest.java index cd987bb..2cd0ac73 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/themes/ThemePreferencesTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/themes/ThemePreferencesTest.java
@@ -41,7 +41,7 @@ ChromePreferenceManager.getInstance().removeKey(UI_THEME_SETTING_KEY); Preferences preferences = PreferencesTest.startPreferences( InstrumentationRegistry.getInstrumentation(), ThemePreferences.class.getName()); - mFragment = (ThemePreferences) preferences.getMainFragment(); + mFragment = (ThemePreferences) preferences.getMainFragmentCompat(); mPreference = (RadioButtonGroupThemePreference) mFragment.findPreference( ThemePreferences.PREF_UI_THEME_PREF); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/background_task_scheduler/NativeBackgroundTaskTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/background_task_scheduler/NativeBackgroundTaskTest.java index c3cc0390..8c7def2 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/background_task_scheduler/NativeBackgroundTaskTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/background_task_scheduler/NativeBackgroundTaskTest.java
@@ -89,6 +89,9 @@ @Override public void initChromiumBrowserProcessForTests() {} + @Override + public void setContentMainCallbackForTests(Runnable r) {} + public void setIsStartupSuccessfullyCompleted(boolean flag) { mStartupSucceeded = flag; }
diff --git a/chrome/android/public/profiles/BUILD.gn b/chrome/android/public/profiles/BUILD.gn index a196365..fc3721c 100644 --- a/chrome/android/public/profiles/BUILD.gn +++ b/chrome/android/public/profiles/BUILD.gn
@@ -28,5 +28,4 @@ "java/src/org/chromium/chrome/browser/profiles/ProfileKey.java", "java/src/org/chromium/chrome/browser/profiles/ProfileManagerUtils.java", ] - jni_package = "chrome" }
diff --git a/chrome/android/touchless/fallback/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java b/chrome/android/touchless/fallback/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java index 86f5e0b..3593283 100644 --- a/chrome/android/touchless/fallback/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java +++ b/chrome/android/touchless/fallback/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java
@@ -4,6 +4,9 @@ package org.chromium.chrome.browser.touchless; +import android.content.Context; +import android.support.annotation.StringRes; + import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.native_page.NativePage; import org.chromium.chrome.browser.native_page.NativePageHost; @@ -39,11 +42,16 @@ return null; } - public static PropertyModel getTouchlessPermissionDialogModel( + public static PropertyModel getPermissionDialogModel( ModalDialogProperties.Controller controller, PermissionDialogDelegate delegate) { return null; } + public static PropertyModel getMissingPermissionDialogModel(Context context, + ModalDialogProperties.Controller controller, @StringRes int messageId) { + return null; + } + public static TouchlessUiCoordinator getTouchlessUiCoordinator(ChromeActivity activity) { return null; }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java index 7c42dfb..89a6c7c 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/OpenLastTabMediator.java
@@ -218,8 +218,7 @@ @Override public boolean isItemSupported( @ContextMenuManager.ContextMenuItemId int menuItemId) { - return menuItemId == ContextMenuManager.ContextMenuItemId.ADD_TO_MY_APPS - || menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE; + return menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE; } @Override
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/SiteSuggestionsAdapter.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/SiteSuggestionsAdapter.java index e90da67..0bb5a1e6 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/SiteSuggestionsAdapter.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/SiteSuggestionsAdapter.java
@@ -94,8 +94,7 @@ @Override public boolean isItemSupported(int menuItemId) { - return menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE - || menuItemId == ContextMenuManager.ContextMenuItemId.ADD_TO_MY_APPS; + return menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE; } @Override
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java index e97b9eae..9ed6f47b 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessDelegate.java
@@ -4,6 +4,9 @@ package org.chromium.chrome.browser.touchless; +import android.content.Context; +import android.support.annotation.StringRes; + import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.native_page.NativePage; import org.chromium.chrome.browser.native_page.NativePageHost; @@ -40,11 +43,17 @@ return TouchlessPreferences.class; } - public static PropertyModel getTouchlessPermissionDialogModel( + public static PropertyModel getPermissionDialogModel( ModalDialogProperties.Controller controller, PermissionDialogDelegate delegate) { return TouchlessPermissionDialogModel.getModel(controller, delegate); } + public static PropertyModel getMissingPermissionDialogModel(Context context, + ModalDialogProperties.Controller controller, @StringRes int messageId) { + return TouchlessPermissionDialogModel.getMissingPermissionDialogModel( + context, controller, messageId); + } + public static TouchlessUiCoordinator getTouchlessUiCoordinator(ChromeActivity activity) { return new TouchlessUiCoordinatorImpl(activity); }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java index 7c91e7b..996a86d 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/TouchlessExploreSitesCategoryCardView.java
@@ -44,8 +44,7 @@ @Override public boolean isItemSupported(int menuItemId) { - return menuItemId == ContextMenuManager.ContextMenuItemId.ADD_TO_MY_APPS - || menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE; + return menuItemId == ContextMenuManager.ContextMenuItemId.REMOVE; } }
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/dialog/TouchlessDialogPresenter.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/dialog/TouchlessDialogPresenter.java index 3dfdb56..8da79bd 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/dialog/TouchlessDialogPresenter.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/dialog/TouchlessDialogPresenter.java
@@ -156,7 +156,6 @@ customGroup.addView(model.get(ModalDialogProperties.CUSTOM_VIEW)); customGroup.setVisibility(View.VISIBLE); } else if (TouchlessDialogProperties.LIST_MODELS == propertyKey) { - ListView listView = dialogView.findViewById(R.id.touchless_dialog_option_list); PropertyModel[] models = model.get(TouchlessDialogProperties.LIST_MODELS); ArrayList<Pair<Integer, PropertyModel>> modelPairs = new ArrayList<>(); for (int i = 0; i < models.length; i++) {
diff --git a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/permissions/TouchlessPermissionDialogModel.java b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/permissions/TouchlessPermissionDialogModel.java index 466e7d1..0a4173cc 100644 --- a/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/permissions/TouchlessPermissionDialogModel.java +++ b/chrome/android/touchless/java/src/org/chromium/chrome/browser/touchless/permissions/TouchlessPermissionDialogModel.java
@@ -4,16 +4,19 @@ package org.chromium.chrome.browser.touchless.permissions; +import android.content.Context; import android.content.res.Resources; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; +import android.support.annotation.StringRes; import android.text.TextUtils; import org.chromium.base.ApiCompatibilityUtils; import org.chromium.chrome.R; import org.chromium.chrome.browser.permissions.PermissionDialogDelegate; import org.chromium.chrome.browser.touchless.dialog.TouchlessDialogProperties; +import org.chromium.ui.UiUtils; import org.chromium.ui.modaldialog.DialogDismissalCause; import org.chromium.ui.modaldialog.ModalDialogProperties; import org.chromium.ui.modelutil.PropertyModel; @@ -81,4 +84,40 @@ DialogDismissalCause.NAVIGATE_BACK_OR_TOUCH_OUTSIDE)); return model; } + + public static PropertyModel getMissingPermissionDialogModel(Context context, + ModalDialogProperties.Controller controller, @StringRes int messageId) { + Resources resources = context.getResources(); + Drawable iconDrawable = UiUtils.getTintedDrawable( + context, R.drawable.exclamation_triangle, R.color.default_icon_color); + TouchlessDialogProperties.ActionNames names = new TouchlessDialogProperties.ActionNames(); + names.cancel = R.string.cancel; + names.select = R.string.select; + names.alt = 0; + PropertyModel model = new PropertyModel.Builder(TouchlessDialogProperties.ALL_DIALOG_KEYS) + .with(TouchlessDialogProperties.IS_FULLSCREEN, false) + .with(TouchlessDialogProperties.PRIORITY, + TouchlessDialogProperties.Priority.HIGH) + .with(ModalDialogProperties.CONTROLLER, controller) + .with(ModalDialogProperties.MESSAGE, resources, messageId) + .with(ModalDialogProperties.TITLE_ICON, iconDrawable) + .with(TouchlessDialogProperties.ACTION_NAMES, names) + .with(TouchlessDialogProperties.ALT_ACTION, null) + .build(); + model.set(TouchlessDialogProperties.LIST_MODELS, + new PropertyModel[] { + new PropertyModel + .Builder( + TouchlessDialogProperties.DialogListItemProperties.ALL_KEYS) + .with(TouchlessDialogProperties.DialogListItemProperties.TEXT, + resources, R.string.infobar_update_permissions_button_text) + .with(TouchlessDialogProperties.DialogListItemProperties.ICON, + context, R.drawable.ic_check_circle) + .with(TouchlessDialogProperties.DialogListItemProperties + .CLICK_LISTENER, + (v) -> controller.onClick(model, + ModalDialogProperties.ButtonType.POSITIVE)) + .build()}); + return model; + } }
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index 52e27d1..54a80a4e 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -249,7 +249,7 @@ other {Update within # seconds}} </message> <message name="IDS_RELAUNCH_REQUIRED_BODY" desc="The body text of a dialog that tells users the device must be restarted."> - Your company or organization requires an update to this device + Your organization requires an update to this device </message> <message name="IDS_RELAUNCH_RECOMMENDED_TITLE" desc="The title of a dialog that tells users that a device restart is recommended for an update."> @@ -259,10 +259,10 @@ Update overdue </message> <message name="IDS_RELAUNCH_RECOMMENDED_BODY" desc="The body text of a dialog that tells users the device must be restarted."> - Your company or organization asks that you update this device + Your organization asks that you update this device </message> <message name="IDS_RELAUNCH_RECOMMENDED_OVERDUE_BODY" desc="The body text of a dialog that tells users the device must be restarted right now."> - Your company or organization requires an update to this device right away + Your organization requires an update to this device right away </message> <!-- Chrome OS Strings -->
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 03e8169f..9e2e10d 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -3675,6 +3675,9 @@ <message name="IDS_EXTENSION_PROMPT_WARNING_INPUT" desc="Permission string for access to input."> Read and change anything you type </message> + <message name="IDS_EXTENSION_PROMPT_WARNING_LOGIN" desc="Permission string for access to Login API."> + Launch and exit managed guest sessions + </message> <message name="IDS_EXTENSION_PROMPT_WARNING_LOGIN_SCREEN_UI" desc="Permission string for access to login screen UI."> Display UI on the login screen </message> @@ -7320,20 +7323,17 @@ <message name="IDS_SYNC_START_SYNC_BUTTON_LABEL" desc="The label that appears on the sync button in the options dialog when sync has not been set up by the user."> Sign in to <ph name="PRODUCT_NAME">$1<ex>Chrome</ex></ph> </message> - <message name="IDS_SIGNED_IN_WITH_SYNC_DISABLED" desc="The message that appears in the settings page indicating that user is signed in, but sync is not enabled."> + <message name="IDS_SIGNED_IN_WITH_SYNC_DISABLED_BY_POLICY" desc="The message that appears in the settings page indicating that user is signed in, but sync is disabled by enterprise policy."> Sync is disabled by your administrator. </message> - <message name="IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED" desc="The message that appears in the settings page indicating that user is signed in, but sync has been stopped."> + <message name="IDS_SIGNED_IN_WITH_SYNC_STOPPED_VIA_DASHBOARD" desc="The message that appears in the settings page indicating that user is signed in, but sync has been stopped via the Google dashboard."> Sync has been stopped via the Google Dashboard. </message> <message name="IDS_SYNC_SETTINGS_NOT_CONFIRMED" desc="The message that appears in the settings page indicating that user is signed in, but sync hasn't started because the sync settings haven't been confirmed."> Confirm sync settings to start sync. </message> - <message name="IDS_SYNC_ERROR_SIGNING_IN" desc="An error was encountered while signing the user in."> - Error signing in. - </message> - <message name="IDS_SYNC_UNRECOVERABLE_ERROR" desc="Message shown when sync setup failed due to an unrecoverable error and can't continue."> - Oops, Sync has stopped working. + <message name="IDS_SYNC_SETUP_IN_PROGRESS" desc="The message to display in the settings page when the sync setup is underway."> + Setup in progress... </message> <message name="IDS_SYNC_STATUS_UNRECOVERABLE_ERROR" desc="Message shown on the personal options page when there is an unrecoverable error."> Sync isn’t working. Try signing in again. @@ -7384,20 +7384,12 @@ Advanced settings </message> - <!-- Sync New Tab Page strings --> - <message name="IDS_SYNC_NTP_SETUP_IN_PROGRESS" desc="The message to display in the New Tab Page sync section when the sync setup is underway."> - Setup in progress... - </message> - - <!-- Spinner dialog for waiting sync backend to start up --> - <message name="IDS_SYNC_SETUP_SPINNER_TITLE" desc="The title of the sync setup dialog showing spinner."> - Please wait... - </message> - - <!-- Choose data types dialog strings --> - <message name="IDS_SYNC_EVERYTHING" desc="A drop-down menu item for users who want to sync all data types."> - Sync everything - </message> + <if expr="chromeos"> + <!-- Spinner dialog for waiting sync backend to start up --> + <message name="IDS_SYNC_SETUP_SPINNER_TITLE" desc="The title of the sync setup dialog showing spinner."> + Please wait... + </message> + </if> <!-- Encryption tab of the configure sync dialog --> <message name="IDS_SYNC_FULL_ENCRYPTION_BODY_CUSTOM" desc="Text of the radio that when selected enables full encryption."> @@ -7412,16 +7404,18 @@ <ph name="TIME">$1<ex>Sept 1, 2012</ex></ph>. This doesn't include payment methods and addresses from Google Pay. </message> - <!-- Sync promo page chrome://signin --> - <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER" desc="The first line of the of the message shown in NTP when a user is not signed into sync."> - Not signed in to <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph> - </message> - <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER" desc="The second line of the of the message shown in NTP when a user is not signed in to sync."> - (You're missing out—<ph name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK">$1<ex>sign in</ex></ph>) - </message> - <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK" desc="The linkified portion of the sync sign in promo on the NTP. Clicking this text allows the user to sign in to sync."> - sign in - </message> + <!-- Sync promo on chrome://apps --> + <if expr="not chromeos"> + <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_HEADER" desc="The first line of the of the message shown in NTP when a user is not signed into sync."> + Not signed in to <ph name="SHORT_PRODUCT_NAME">$1<ex>Chrome</ex></ph> + </message> + <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_SUB_HEADER" desc="The second line of the of the message shown in NTP when a user is not signed in to sync."> + (You're missing out—<ph name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK">$1<ex>sign in</ex></ph>) + </message> + <message name="IDS_SYNC_PROMO_NOT_SIGNED_IN_STATUS_LINK" desc="The linkified portion of the sync sign in promo on the NTP. Clicking this text allows the user to sign in to sync."> + sign in + </message> + </if> </if> <!-- Translate Bubble -->
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index acc20bb..3d6430a 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -1014,8 +1014,6 @@ "password_manager/password_manager_util_win.h", "password_manager/password_store_factory.cc", "password_manager/password_store_factory.h", - "password_manager/password_store_mac.cc", - "password_manager/password_store_mac.h", "password_manager/reauth_purpose.h", "payments/payment_handler_permission_context.cc", "payments/payment_handler_permission_context.h", @@ -1163,6 +1161,8 @@ "policy/chrome_browser_policy_connector.h", "policy/cloud/cloud_policy_invalidator.cc", "policy/cloud/cloud_policy_invalidator.h", + "policy/cloud/policy_invalidation_util.cc", + "policy/cloud/policy_invalidation_util.h", "policy/cloud/remote_commands_invalidator.cc", "policy/cloud/remote_commands_invalidator.h", "policy/cloud/remote_commands_invalidator_impl.cc", @@ -2229,7 +2229,6 @@ "android/compositor/navigation_glow.cc", "android/compositor/navigation_glow.h", "android/compositor/resources/resource_factory.cc", - "android/compositor/resources/resource_factory.h", "android/compositor/resources/toolbar_resource.cc", "android/compositor/resources/toolbar_resource.h", "android/compositor/scene_layer/contextual_search_scene_layer.cc", @@ -5374,6 +5373,8 @@ "autofill/mock_address_accessory_controller.h", "autofill/mock_manual_filling_view.cc", "autofill/mock_manual_filling_view.h", + "autofill/mock_password_accessory_controller.cc", + "autofill/mock_password_accessory_controller.h", ] deps += [ "//chrome/android:test_support_jni_headers" ] } else {
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index beb0b7d..a494420 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS
@@ -1,6 +1,9 @@ include_rules = [ "+apps", "+cc/paint", + "+chrome/android/chrome_jni_headers", + "+chrome/android/features/autofill_assistant/jni_headers", + "+chrome/android/public/profiles/jni_headers", "+chrome/app", "+chrome/chrome_watcher", "+chrome/credential_provider/common", @@ -44,7 +47,6 @@ "+google_apis", "+google_update", "+installer_util_strings", # For generated headers - "+jni", "+mash/public/mojom", "+media/media_buildflags.h", "+media/audio", # For media audio hang monitor.
diff --git a/chrome/browser/after_startup_task_utils_android.cc b/chrome/browser/after_startup_task_utils_android.cc index 17881fcc..5be0177 100644 --- a/chrome/browser/after_startup_task_utils_android.cc +++ b/chrome/browser/after_startup_task_utils_android.cc
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/android/chrome_jni_headers/AfterStartupTaskUtils_jni.h" #include "chrome/browser/after_startup_task_utils.h" -#include "jni/AfterStartupTaskUtils_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/DEPS b/chrome/browser/android/DEPS index 0fe49540..0206149 100644 --- a/chrome/browser/android/DEPS +++ b/chrome/browser/android/DEPS
@@ -2,6 +2,9 @@ "-components/devtools_bridge", "+cc/layers/layer.h", "+chrome_jni_registration/chrome_jni_registration.h", + "+chrome/android/test_support_jni_headers", + "+chrome/lib/image_fetcher/public/android/jni_headers", + "+chrome/lib/util/public/android/jni_headers", "+device/vr/buildflags/buildflags.h", "+media/gpu", "+media/video",
diff --git a/chrome/browser/android/accessibility/font_size_prefs_android.cc b/chrome/browser/android/accessibility/font_size_prefs_android.cc index 6ca4d88..a572fc7 100644 --- a/chrome/browser/android/accessibility/font_size_prefs_android.cc +++ b/chrome/browser/android/accessibility/font_size_prefs_android.cc
@@ -6,12 +6,12 @@ #include "base/bind.h" #include "base/observer_list.h" +#include "chrome/android/chrome_jni_headers/FontSizePrefs_jni.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_change_registrar.h" #include "components/prefs/pref_service.h" -#include "jni/FontSizePrefs_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/android/app_hooks.cc b/chrome/browser/android/app_hooks.cc index b4ca61a..680d708 100644 --- a/chrome/browser/android/app_hooks.cc +++ b/chrome/browser/android/app_hooks.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/app_hooks.h" #include "base/android/jni_android.h" -#include "jni/AppHooks_jni.h" +#include "chrome/android/chrome_jni_headers/AppHooks_jni.h" using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/autofill_assistant/assistant_form_delegate.cc b/chrome/browser/android/autofill_assistant/assistant_form_delegate.cc index a17c3502..48c0618e 100644 --- a/chrome/browser/android/autofill_assistant/assistant_form_delegate.cc +++ b/chrome/browser/android/autofill_assistant/assistant_form_delegate.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/android/autofill_assistant/assistant_form_delegate.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantFormDelegate_jni.h" #include "chrome/browser/android/autofill_assistant/ui_controller_android.h" -#include "jni/AssistantFormDelegate_jni.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/autofill_assistant/assistant_header_delegate.cc b/chrome/browser/android/autofill_assistant/assistant_header_delegate.cc index f2d9b5e0..2b0adb0 100644 --- a/chrome/browser/android/autofill_assistant/assistant_header_delegate.cc +++ b/chrome/browser/android/autofill_assistant/assistant_header_delegate.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/android/autofill_assistant/assistant_header_delegate.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantHeaderDelegate_jni.h" #include "chrome/browser/android/autofill_assistant/ui_controller_android.h" -#include "jni/AssistantHeaderDelegate_jni.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/autofill_assistant/assistant_overlay_delegate.cc b/chrome/browser/android/autofill_assistant/assistant_overlay_delegate.cc index f0ddfbb4..91401cf 100644 --- a/chrome/browser/android/autofill_assistant/assistant_overlay_delegate.cc +++ b/chrome/browser/android/autofill_assistant/assistant_overlay_delegate.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/android/autofill_assistant/assistant_overlay_delegate.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantOverlayDelegate_jni.h" #include "chrome/browser/android/autofill_assistant/ui_controller_android.h" -#include "jni/AssistantOverlayDelegate_jni.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/autofill_assistant/assistant_payment_request_delegate.cc b/chrome/browser/android/autofill_assistant/assistant_payment_request_delegate.cc index 1e53230d..aebb1b9 100644 --- a/chrome/browser/android/autofill_assistant/assistant_payment_request_delegate.cc +++ b/chrome/browser/android/autofill_assistant/assistant_payment_request_delegate.cc
@@ -8,11 +8,11 @@ #include <utility> #include "base/android/jni_string.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantPaymentRequestDelegate_jni.h" #include "chrome/browser/android/autofill_assistant/ui_controller_android.h" #include "chrome/browser/autofill/android/personal_data_manager_android.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" #include "chrome/browser/profiles/profile_manager.h" -#include "jni/AssistantPaymentRequestDelegate_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/autofill_assistant/client_android.cc b/chrome/browser/android/autofill_assistant/client_android.cc index 8e450ff..08c58be 100644 --- a/chrome/browser/android/autofill_assistant/client_android.cc +++ b/chrome/browser/android/autofill_assistant/client_android.cc
@@ -17,6 +17,7 @@ #include "base/no_destructor.h" #include "base/task/post_task.h" #include "base/time/default_tick_clock.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AutofillAssistantClient_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/autofill/android/personal_data_manager_android.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" @@ -33,7 +34,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "google_apis/google_api_keys.h" -#include "jni/AutofillAssistantClient_jni.h" #include "services/identity/public/cpp/identity_manager.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/autofill_assistant/ui_controller_android.cc b/chrome/browser/android/autofill_assistant/ui_controller_android.cc index d931a43..140323d 100644 --- a/chrome/browser/android/autofill_assistant/ui_controller_android.cc +++ b/chrome/browser/android/autofill_assistant/ui_controller_android.cc
@@ -16,6 +16,17 @@ #include "base/metrics/field_trial_params.h" #include "base/task/post_task.h" #include "base/time/time.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantDetailsModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantDetails_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantFormInput_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantFormModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantHeaderModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantInfoBoxModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantInfoBox_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantOverlayModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AssistantPaymentRequestModel_jni.h" +#include "chrome/android/features/autofill_assistant/jni_headers/AutofillAssistantUiController_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/autofill/android/personal_data_manager_android.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" @@ -36,17 +47,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "google_apis/google_api_keys.h" -#include "jni/AssistantDetailsModel_jni.h" -#include "jni/AssistantDetails_jni.h" -#include "jni/AssistantFormInput_jni.h" -#include "jni/AssistantFormModel_jni.h" -#include "jni/AssistantHeaderModel_jni.h" -#include "jni/AssistantInfoBoxModel_jni.h" -#include "jni/AssistantInfoBox_jni.h" -#include "jni/AssistantModel_jni.h" -#include "jni/AssistantOverlayModel_jni.h" -#include "jni/AssistantPaymentRequestModel_jni.h" -#include "jni/AutofillAssistantUiController_jni.h" #include "services/identity/public/cpp/identity_manager.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/android/background_sync_launcher_android.cc b/chrome/browser/android/background_sync_launcher_android.cc index f9b61da2..cc6489e 100644 --- a/chrome/browser/android/background_sync_launcher_android.cc +++ b/chrome/browser/android/background_sync_launcher_android.cc
@@ -10,15 +10,15 @@ #include "base/barrier_closure.h" #include "base/bind.h" #include "base/feature_list.h" +#include "chrome/android/chrome_jni_headers/BackgroundSyncBackgroundTaskScheduler_jni.h" +#include "chrome/android/chrome_jni_headers/BackgroundSyncBackgroundTask_jni.h" +#include "chrome/android/chrome_jni_headers/BackgroundSyncLauncher_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/background_sync_context.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" -#include "jni/BackgroundSyncBackgroundTaskScheduler_jni.h" -#include "jni/BackgroundSyncBackgroundTask_jni.h" -#include "jni/BackgroundSyncLauncher_jni.h" using content::BrowserThread;
diff --git a/chrome/browser/android/bookmarks/bookmark_bridge.cc b/chrome/browser/android/bookmarks/bookmark_bridge.cc index 6907232..fcf3af5 100644 --- a/chrome/browser/android/bookmarks/bookmark_bridge.cc +++ b/chrome/browser/android/bookmarks/bookmark_bridge.cc
@@ -15,6 +15,7 @@ #include "base/containers/stack.h" #include "base/containers/stack_container.h" #include "base/i18n/string_compare.h" +#include "chrome/android/chrome_jni_headers/BookmarkBridge_jni.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" #include "chrome/browser/profiles/incognito_helpers.h" @@ -34,7 +35,6 @@ #include "components/undo/bookmark_undo_service.h" #include "components/undo/undo_manager.h" #include "content/public/browser/browser_thread.h" -#include "jni/BookmarkBridge_jni.h" #include "services/identity/public/cpp/identity_manager.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/bookmarks/partner_bookmarks_reader.cc b/chrome/browser/android/bookmarks/partner_bookmarks_reader.cc index b3aa3bf..4617da13 100644 --- a/chrome/browser/android/bookmarks/partner_bookmarks_reader.cc +++ b/chrome/browser/android/bookmarks/partner_bookmarks_reader.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/logging.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/PartnerBookmarksReader_jni.h" #include "chrome/browser/android/bookmarks/partner_bookmarks_shim.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/favicon/favicon_service_factory.h" @@ -23,7 +24,6 @@ #include "components/image_fetcher/core/image_fetcher.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "jni/PartnerBookmarksReader_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/favicon_size.h"
diff --git a/chrome/browser/android/bottombar/overlay_panel_content.cc b/chrome/browser/android/bottombar/overlay_panel_content.cc index d2af1412..eb30ffc 100644 --- a/chrome/browser/android/bottombar/overlay_panel_content.cc +++ b/chrome/browser/android/bottombar/overlay_panel_content.cc
@@ -11,6 +11,7 @@ #include "base/callback.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/OverlayPanelContent_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile_manager.h" @@ -24,7 +25,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/browser_controls_state.h" -#include "jni/OverlayPanelContent_jni.h" #include "net/url_request/url_fetcher_impl.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/android/browserservices/ukm_recorder.cc b/chrome/browser/android/browserservices/ukm_recorder.cc index e95490f..a2b75f9 100644 --- a/chrome/browser/android/browserservices/ukm_recorder.cc +++ b/chrome/browser/android/browserservices/ukm_recorder.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "services/metrics/public/cpp/ukm_recorder.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/UkmRecorder_jni.h" #include "components/ukm/content/source_url_recorder.h" #include "content/public/browser/web_contents.h" -#include "jni/UkmRecorder_jni.h" #include "services/metrics/public/cpp/ukm_builders.h" -#include "services/metrics/public/cpp/ukm_recorder.h" namespace browserservices {
diff --git a/chrome/browser/android/browsing_data/browsing_data_bridge.cc b/chrome/browser/android/browsing_data/browsing_data_bridge.cc index 4091cdf..e17ba2b 100644 --- a/chrome/browser/android/browsing_data/browsing_data_bridge.cc +++ b/chrome/browser/android/browsing_data/browsing_data_bridge.cc
@@ -20,6 +20,7 @@ #include "base/scoped_observer.h" #include "base/trace_event/trace_event.h" #include "base/values.h" +#include "chrome/android/chrome_jni_headers/BrowsingDataBridge_jni.h" #include "chrome/browser/browsing_data/browsing_data_important_sites_util.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" #include "chrome/browser/engagement/important_sites_util.h" @@ -35,7 +36,6 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/browsing_data_filter_builder.h" #include "content/public/browser/browsing_data_remover.h" -#include "jni/BrowsingDataBridge_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/browsing_data/browsing_data_counter_bridge.cc b/chrome/browser/android/browsing_data/browsing_data_counter_bridge.cc index a9887c10..0b90a69c 100644 --- a/chrome/browser/android/browsing_data/browsing_data_counter_bridge.cc +++ b/chrome/browser/android/browsing_data/browsing_data_counter_bridge.cc
@@ -7,12 +7,12 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/trace_event/trace_event.h" +#include "chrome/android/chrome_jni_headers/BrowsingDataCounterBridge_jni.h" #include "chrome/browser/browsing_data/counters/browsing_data_counter_factory.h" #include "chrome/browser/browsing_data/counters/browsing_data_counter_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/pref_names.h" -#include "jni/BrowsingDataCounterBridge_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/browsing_data/url_filter_bridge.cc b/chrome/browser/android/browsing_data/url_filter_bridge.cc index d012891..2f083ea 100644 --- a/chrome/browser/android/browsing_data/url_filter_bridge.cc +++ b/chrome/browser/android/browsing_data/url_filter_bridge.cc
@@ -6,7 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" -#include "jni/UrlFilterBridge_jni.h" +#include "chrome/android/chrome_jni_headers/UrlFilterBridge_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/chrome_backup_agent.cc b/chrome/browser/android/chrome_backup_agent.cc index 9eb7208..524cffa 100644 --- a/chrome/browser/android/chrome_backup_agent.cc +++ b/chrome/browser/android/chrome_backup_agent.cc
@@ -8,12 +8,12 @@ #include "base/android/jni_array.h" #include "base/stl_util.h" +#include "chrome/android/chrome_jni_headers/ChromeBackupAgent_jni.h" #include "chrome/browser/android/chrome_backup_agent.h" #include "chrome/browser/profiles/profile_manager.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/prefs/pref_service.h" #include "components/sync/base/pref_names.h" -#include "jni/ChromeBackupAgent_jni.h" namespace {
diff --git a/chrome/browser/android/chrome_backup_watcher.cc b/chrome/browser/android/chrome_backup_watcher.cc index d20b507..cd92b5c 100644 --- a/chrome/browser/android/chrome_backup_watcher.cc +++ b/chrome/browser/android/chrome_backup_watcher.cc
@@ -4,9 +4,9 @@ #include "chrome/browser/android/chrome_backup_watcher.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/ChromeBackupWatcher_jni.h" #include "chrome/browser/android/chrome_backup_agent.h" #include "chrome/browser/profiles/profile.h" -#include "jni/ChromeBackupWatcher_jni.h" namespace android {
diff --git a/chrome/browser/android/chrome_context_util.cc b/chrome/browser/android/chrome_context_util.cc index a55294d3..035c139 100644 --- a/chrome/browser/android/chrome_context_util.cc +++ b/chrome/browser/android/chrome_context_util.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/chrome_context_util.h" #include "base/android/jni_android.h" -#include "jni/ChromeContextUtil_jni.h" +#include "chrome/android/chrome_jni_headers/ChromeContextUtil_jni.h" namespace chrome { namespace android {
diff --git a/chrome/browser/android/chrome_feature_list.cc b/chrome/browser/android/chrome_feature_list.cc index c8c8a9f..64ca1ad 100644 --- a/chrome/browser/android/chrome_feature_list.cc +++ b/chrome/browser/android/chrome_feature_list.cc
@@ -12,6 +12,7 @@ #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" #include "base/stl_util.h" +#include "chrome/android/chrome_jni_headers/ChromeFeatureList_jni.h" #include "chrome/common/chrome_features.h" #include "components/autofill/core/common/autofill_features.h" #include "components/autofill_assistant/browser/features.h" @@ -34,7 +35,6 @@ #include "components/translate/core/browser/translate_prefs.h" #include "components/unified_consent/feature.h" #include "content/public/common/content_features.h" -#include "jni/ChromeFeatureList_jni.h" #include "media/base/media_switches.h" #include "services/device/public/cpp/device_features.h" #include "services/network/public/cpp/features.h"
diff --git a/chrome/browser/android/component_updater/background_task_update_scheduler.cc b/chrome/browser/android/component_updater/background_task_update_scheduler.cc index 724d1b2..2efb5cde 100644 --- a/chrome/browser/android/component_updater/background_task_update_scheduler.cc +++ b/chrome/browser/android/component_updater/background_task_update_scheduler.cc
@@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/threading/sequenced_task_runner_handle.h" -#include "jni/UpdateScheduler_jni.h" +#include "chrome/android/chrome_jni_headers/UpdateScheduler_jni.h" namespace component_updater {
diff --git a/chrome/browser/android/compositor/compositor_view.cc b/chrome/browser/android/compositor/compositor_view.cc index 9368522..7871652f 100644 --- a/chrome/browser/android/compositor/compositor_view.cc +++ b/chrome/browser/android/compositor/compositor_view.cc
@@ -21,6 +21,7 @@ #include "cc/layers/layer_collections.h" #include "cc/layers/solid_color_layer.h" #include "cc/layers/texture_layer.h" +#include "chrome/android/chrome_jni_headers/CompositorView_jni.h" #include "chrome/browser/android/compositor/layer/toolbar_layer.h" #include "chrome/browser/android/compositor/layer_title_cache.h" #include "chrome/browser/android/compositor/scene_layer/scene_layer.h" @@ -29,7 +30,6 @@ #include "content/public/browser/child_process_data.h" #include "content/public/browser/web_contents.h" #include "content/public/common/process_type.h" -#include "jni/CompositorView_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/android/resources/resource_manager.h" #include "ui/android/resources/ui_resource_provider.h"
diff --git a/chrome/browser/android/compositor/layer_title_cache.cc b/chrome/browser/android/compositor/layer_title_cache.cc index 1a0f15a0..60bd07b 100644 --- a/chrome/browser/android/compositor/layer_title_cache.cc +++ b/chrome/browser/android/compositor/layer_title_cache.cc
@@ -10,8 +10,8 @@ #include "cc/layers/layer.h" #include "cc/layers/ui_resource_layer.h" +#include "chrome/android/chrome_jni_headers/LayerTitleCache_jni.h" #include "chrome/browser/android/compositor/decoration_title.h" -#include "jni/LayerTitleCache_jni.h" #include "ui/android/resources/resource_manager.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/geometry/point_f.h"
diff --git a/chrome/browser/android/compositor/navigation_glow.cc b/chrome/browser/android/compositor/navigation_glow.cc index 12d5c73..c12b2c6 100644 --- a/chrome/browser/android/compositor/navigation_glow.cc +++ b/chrome/browser/android/compositor/navigation_glow.cc
@@ -5,9 +5,9 @@ #include "chrome/browser/android/compositor/navigation_glow.h" #include "base/android/build_info.h" +#include "chrome/android/chrome_jni_headers/CompositorNavigationGlow_jni.h" #include "chrome/browser/android/compositor/scene_layer/scene_layer.h" #include "content/public/browser/web_contents.h" -#include "jni/CompositorNavigationGlow_jni.h" #include "ui/android/edge_effect.h" #include "ui/android/edge_effect_l.h" #include "ui/android/resources/resource_manager.h"
diff --git a/chrome/browser/android/compositor/resources/resource_factory.cc b/chrome/browser/android/compositor/resources/resource_factory.cc index c51220a..539fdeae 100644 --- a/chrome/browser/android/compositor/resources/resource_factory.cc +++ b/chrome/browser/android/compositor/resources/resource_factory.cc
@@ -2,10 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/android/compositor/resources/resource_factory.h" - +#include "chrome/android/chrome_jni_headers/ResourceFactory_jni.h" #include "chrome/browser/android/compositor/resources/toolbar_resource.h" -#include "jni/ResourceFactory_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/compositor/resources/resource_factory.h b/chrome/browser/android/compositor/resources/resource_factory.h deleted file mode 100644 index b0d5d002..0000000 --- a/chrome/browser/android/compositor/resources/resource_factory.h +++ /dev/null
@@ -1,28 +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_ANDROID_COMPOSITOR_RESOURCES_RESOURCE_FACTORY_H_ -#define CHROME_BROWSER_ANDROID_COMPOSITOR_RESOURCES_RESOURCE_FACTORY_H_ - -#include "base/android/jni_android.h" -#include "jni/ResourceFactory_jni.h" - -using base::android::JavaParamRef; - -namespace android { - -jlong CreateToolbarContainerResource(JNIEnv* env, - const JavaParamRef<jclass>& clazz, - jint toolbar_left, - jint toolbar_top, - jint toolbar_right, - jint toolbar_bottom, - jint location_bar_left, - jint location_bar_top, - jint location_bar_right, - jint location_bar_bottom, - jint shadow_height); -} // namespace android - -#endif // CHROME_BROWSER_ANDROID_COMPOSITOR_RESOURCES_RESOURCE_FACTORY_H_
diff --git a/chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc index 70137a5..1956b0d 100644 --- a/chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc
@@ -8,13 +8,13 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "cc/layers/solid_color_layer.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/browser/android/compositor.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" -#include "jni/ContextualSearchSceneLayer_jni.h" #include "net/base/load_flags.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
diff --git a/chrome/browser/android/compositor/scene_layer/ephemeral_tab_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/ephemeral_tab_scene_layer.cc index 2883bca..b30141e 100644 --- a/chrome/browser/android/compositor/scene_layer/ephemeral_tab_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/ephemeral_tab_scene_layer.cc
@@ -6,9 +6,9 @@ #include "base/callback.h" #include "cc/layers/solid_color_layer.h" +#include "chrome/android/chrome_jni_headers/EphemeralTabSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/ephemeral_tab_layer.h" #include "content/public/browser/web_contents.h" -#include "jni/EphemeralTabSceneLayer_jni.h" #include "ui/android/resources/resource_manager_impl.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/android/compositor/scene_layer/scene_layer.cc b/chrome/browser/android/compositor/scene_layer/scene_layer.cc index 16f30af..f5af23e 100644 --- a/chrome/browser/android/compositor/scene_layer/scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/scene_layer.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/compositor/scene_layer/scene_layer.h" #include "cc/layers/layer.h" +#include "chrome/android/chrome_jni_headers/SceneLayer_jni.h" #include "content/public/browser/android/compositor.h" -#include "jni/SceneLayer_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/android/compositor/scene_layer/scrolling_bottom_view_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/scrolling_bottom_view_scene_layer.cc index ac18fcc..72ae9ca 100644 --- a/chrome/browser/android/compositor/scene_layer/scrolling_bottom_view_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/scrolling_bottom_view_scene_layer.cc
@@ -7,8 +7,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "cc/layers/ui_resource_layer.h" +#include "chrome/android/chrome_jni_headers/ScrollingBottomViewSceneLayer_jni.h" #include "content/public/browser/android/compositor.h" -#include "jni/ScrollingBottomViewSceneLayer_jni.h" #include "ui/android/resources/resource_manager_impl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.cc index 484bef4..0aa9654 100644 --- a/chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.cc
@@ -5,11 +5,11 @@ #include "chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.h" #include "cc/layers/layer.h" +#include "chrome/android/chrome_jni_headers/StaticTabSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/content_layer.h" #include "chrome/browser/android/compositor/layer_title_cache.h" #include "chrome/browser/android/compositor/tab_content_manager.h" #include "content/public/browser/android/compositor.h" -#include "jni/StaticTabSceneLayer_jni.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/android/resources/resource_manager_impl.h"
diff --git a/chrome/browser/android/compositor/scene_layer/tab_list_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/tab_list_scene_layer.cc index c6ac06f..191e2cf 100644 --- a/chrome/browser/android/compositor/scene_layer/tab_list_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/tab_list_scene_layer.cc
@@ -9,12 +9,12 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "cc/layers/picture_image_layer.h" +#include "chrome/android/chrome_jni_headers/TabListSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/content_layer.h" #include "chrome/browser/android/compositor/layer/tab_layer.h" #include "chrome/browser/android/compositor/layer_title_cache.h" #include "chrome/browser/android/compositor/tab_content_manager.h" #include "content/public/browser/android/compositor.h" -#include "jni/TabListSceneLayer_jni.h" #include "ui/android/resources/resource_manager_impl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/compositor/scene_layer/tab_strip_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/tab_strip_scene_layer.cc index 422c578..765e4da 100644 --- a/chrome/browser/android/compositor/scene_layer/tab_strip_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/tab_strip_scene_layer.cc
@@ -6,10 +6,10 @@ #include "base/android/jni_android.h" #include "cc/resources/scoped_ui_resource.h" +#include "chrome/android/chrome_jni_headers/TabStripSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/tab_handle_layer.h" #include "chrome/browser/android/compositor/layer_title_cache.h" #include "content/public/browser/android/compositor.h" -#include "jni/TabStripSceneLayer_jni.h" #include "ui/android/resources/nine_patch_resource.h" #include "ui/android/resources/resource_manager_impl.h" #include "ui/gfx/transform.h"
diff --git a/chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.cc b/chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.cc index b21f00a..0152a06e 100644 --- a/chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.cc +++ b/chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.cc
@@ -7,9 +7,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "cc/layers/solid_color_layer.h" +#include "chrome/android/chrome_jni_headers/ToolbarSceneLayer_jni.h" #include "chrome/browser/android/compositor/layer/toolbar_layer.h" #include "content/public/browser/android/compositor.h" -#include "jni/ToolbarSceneLayer_jni.h" #include "ui/android/resources/resource_manager_impl.h" #include "ui/gfx/android/java_bitmap.h"
diff --git a/chrome/browser/android/compositor/tab_content_manager.cc b/chrome/browser/android/compositor/tab_content_manager.cc index 87cd5e40..be92bc2 100644 --- a/chrome/browser/android/compositor/tab_content_manager.cc +++ b/chrome/browser/android/compositor/tab_content_manager.cc
@@ -18,6 +18,7 @@ #include "base/bind_helpers.h" #include "base/macros.h" #include "cc/layers/layer.h" +#include "chrome/android/chrome_jni_headers/TabContentManager_jni.h" #include "chrome/browser/android/compositor/layer/thumbnail_layer.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/thumbnail/thumbnail.h" @@ -27,7 +28,6 @@ #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 "jni/TabContentManager_jni.h" #include "skia/ext/image_operations.h" #include "ui/android/resources/ui_resource_provider.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/android/consent_auditor/consent_auditor_bridge.cc b/chrome/browser/android/consent_auditor/consent_auditor_bridge.cc index 7338740..383160e 100644 --- a/chrome/browser/android/consent_auditor/consent_auditor_bridge.cc +++ b/chrome/browser/android/consent_auditor/consent_auditor_bridge.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ConsentAuditorBridge_jni.h" #include "chrome/browser/consent_auditor/consent_auditor_factory.h" #include "chrome/browser/profiles/profile_android.h" #include "components/consent_auditor/consent_auditor.h" -#include "jni/ConsentAuditorBridge_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/content/content_utils.cc b/chrome/browser/android/content/content_utils.cc index 4334db0..fa28982 100644 --- a/chrome/browser/android/content/content_utils.cc +++ b/chrome/browser/android/content/content_utils.cc
@@ -3,11 +3,11 @@ // found in the LICENSE file. #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ContentUtils_jni.h" #include "chrome/browser/chrome_content_browser_client.h" #include "components/version_info/version_info.h" #include "content/public/browser/web_contents.h" #include "content/public/common/user_agent.h" -#include "jni/ContentUtils_jni.h" static base::android::ScopedJavaLocalRef<jstring> JNI_ContentUtils_GetBrowserUserAgent(JNIEnv* env) {
diff --git a/chrome/browser/android/contextualsearch/contextual_search_context.cc b/chrome/browser/android/contextualsearch/contextual_search_context.cc index e84132b..b8d63f9c 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_context.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_context.cc
@@ -5,10 +5,10 @@ #include <chrome/browser/android/contextualsearch/contextual_search_context.h> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchContext_jni.h" #include "components/translate/core/common/translate_constants.h" #include "components/translate/core/language_detection/language_detection_util.h" #include "content/public/browser/browser_thread.h" -#include "jni/ContextualSearchContext_jni.h" ContextualSearchContext::ContextualSearchContext(JNIEnv* env, jobject obj) : can_resolve(false),
diff --git a/chrome/browser/android/contextualsearch/contextual_search_manager.cc b/chrome/browser/android/contextualsearch/contextual_search_manager.cc index 64d4031..de1afa8 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_manager.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_manager.cc
@@ -13,6 +13,7 @@ #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchManager_jni.h" #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" #include "chrome/browser/android/contextualsearch/resolved_search_term.h" #include "chrome/browser/profiles/profile_manager.h" @@ -24,7 +25,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" -#include "jni/ContextualSearchManager_jni.h" #include "net/url_request/url_fetcher_impl.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/service_manager/public/cpp/binder_registry.h"
diff --git a/chrome/browser/android/contextualsearch/contextual_search_preference_helper.cc b/chrome/browser/android/contextualsearch/contextual_search_preference_helper.cc index 6302c15..6bd83ae54 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_preference_helper.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_preference_helper.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/contextualsearch/contextual_search_preference_helper.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchPreferenceHelper_jni.h" #include "components/contextual_search/core/browser/contextual_search_preference.h" -#include "jni/ContextualSearchPreferenceHelper_jni.h" ContextualSearchPreferenceHelper::ContextualSearchPreferenceHelper( JNIEnv* env,
diff --git a/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.cc b/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.cc index 64f8ae2b..f9f7cbdd 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_ranker_logger_impl.cc
@@ -8,6 +8,7 @@ #include "base/android/scoped_java_ref.h" #include "base/feature_list.h" #include "base/metrics/histogram_functions.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchRankerLoggerImpl_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/assist_ranker/assist_ranker_service_factory.h" #include "chrome/browser/browser_process.h" @@ -18,7 +19,6 @@ #include "components/keyed_service/core/keyed_service.h" #include "components/ukm/content/source_url_recorder.h" #include "content/public/browser/web_contents.h" -#include "jni/ContextualSearchRankerLoggerImpl_jni.h" namespace content { class BrowserContext;
diff --git a/chrome/browser/android/contextualsearch/contextual_search_tab_helper.cc b/chrome/browser/android/contextualsearch/contextual_search_tab_helper.cc index 06078182..63aedd5 100644 --- a/chrome/browser/android/contextualsearch/contextual_search_tab_helper.cc +++ b/chrome/browser/android/contextualsearch/contextual_search_tab_helper.cc
@@ -8,13 +8,13 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "build/build_config.h" +#include "chrome/android/chrome_jni_headers/ContextualSearchTabHelper_jni.h" #include "chrome/browser/android/contextualsearch/unhandled_tap_web_contents_observer.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_change_registrar.h" #include "content/public/browser/web_contents.h" -#include "jni/ContextualSearchTabHelper_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/contextualsearch/ctr_suppression.cc b/chrome/browser/android/contextualsearch/ctr_suppression.cc index aef4a43..f399ba8b 100644 --- a/chrome/browser/android/contextualsearch/ctr_suppression.cc +++ b/chrome/browser/android/contextualsearch/ctr_suppression.cc
@@ -7,7 +7,7 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" -#include "jni/CtrSuppression_jni.h" +#include "chrome/android/chrome_jni_headers/CtrSuppression_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/contextualsearch/simple_search_term_resolver.cc b/chrome/browser/android/contextualsearch/simple_search_term_resolver.cc index bfe8af7..456e22e 100644 --- a/chrome/browser/android/contextualsearch/simple_search_term_resolver.cc +++ b/chrome/browser/android/contextualsearch/simple_search_term_resolver.cc
@@ -13,6 +13,7 @@ #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/SimpleSearchTermResolver_jni.h" #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" #include "chrome/browser/android/contextualsearch/resolved_search_term.h" #include "chrome/browser/profiles/profile_manager.h" @@ -24,7 +25,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" -#include "jni/SimpleSearchTermResolver_jni.h" #include "net/url_request/url_fetcher_impl.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/service_manager/public/cpp/binder_registry.h"
diff --git a/chrome/browser/android/cookies/cookies_fetcher_util.cc b/chrome/browser/android/cookies/cookies_fetcher_util.cc index 6267b0c..fe1543a 100644 --- a/chrome/browser/android/cookies/cookies_fetcher_util.cc +++ b/chrome/browser/android/cookies/cookies_fetcher_util.cc
@@ -7,12 +7,12 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/time/time.h" +#include "chrome/android/public/profiles/jni_headers/CookiesFetcher_jni.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/content_switches.h" -#include "jni/CookiesFetcher_jni.h" #include "net/url_request/url_request_context.h" #include "services/network/public/mojom/cookie_manager.mojom.h"
diff --git a/chrome/browser/android/crash/pure_java_exception_handler.cc b/chrome/browser/android/crash/pure_java_exception_handler.cc index 42dc591..f75c048e 100644 --- a/chrome/browser/android/crash/pure_java_exception_handler.cc +++ b/chrome/browser/android/crash/pure_java_exception_handler.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/android/crash/pure_java_exception_handler.h" -#include "jni/PureJavaExceptionHandler_jni.h" +#include "chrome/android/chrome_jni_headers/PureJavaExceptionHandler_jni.h" void UninstallPureJavaExceptionHandler() { Java_PureJavaExceptionHandler_uninstallHandler(
diff --git a/chrome/browser/android/customtabs/detached_resource_request_android.cc b/chrome/browser/android/customtabs/detached_resource_request_android.cc index 57a5655..a187756b 100644 --- a/chrome/browser/android/customtabs/detached_resource_request_android.cc +++ b/chrome/browser/android/customtabs/detached_resource_request_android.cc
@@ -7,11 +7,11 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/bind_helpers.h" +#include "chrome/android/chrome_jni_headers/CustomTabsConnection_jni.h" #include "chrome/browser/android/customtabs/detached_resource_request.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/common/referrer.h" -#include "jni/CustomTabsConnection_jni.h" #include "url/gurl.h" namespace customtabs {
diff --git a/chrome/browser/android/customtabs/dynamicmodule/module_metrics.cc b/chrome/browser/android/customtabs/dynamicmodule/module_metrics.cc index c2e6d7d..7cb16ce2 100644 --- a/chrome/browser/android/customtabs/dynamicmodule/module_metrics.cc +++ b/chrome/browser/android/customtabs/dynamicmodule/module_metrics.cc
@@ -11,7 +11,7 @@ #include "base/android/jni_string.h" #include "base/metrics/histogram_functions.h" #include "base/process/process_handle.h" -#include "jni/ModuleMetrics_jni.h" +#include "chrome/android/chrome_jni_headers/ModuleMetrics_jni.h" #include "services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h"
diff --git a/chrome/browser/android/customtabs/origin_verifier.cc b/chrome/browser/android/customtabs/origin_verifier.cc index d5a434c8..73c8082 100644 --- a/chrome/browser/android/customtabs/origin_verifier.cc +++ b/chrome/browser/android/customtabs/origin_verifier.cc
@@ -9,13 +9,13 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/OriginVerifier_jni.h" #include "chrome/browser/android/digital_asset_links/digital_asset_links_handler.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" -#include "jni/OriginVerifier_jni.h" #include "services/network/public/cpp/simple_url_loader.h" using base::android::ConvertJavaStringToUTF16;
diff --git a/chrome/browser/android/devtools_server.cc b/chrome/browser/android/devtools_server.cc index f5619fec..15e6cecd 100644 --- a/chrome/browser/android/devtools_server.cc +++ b/chrome/browser/android/devtools_server.cc
@@ -19,6 +19,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/DevToolsServer_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" @@ -38,7 +39,6 @@ #include "content/public/common/content_switches.h" #include "content/public/common/url_constants.h" #include "content/public/common/user_agent.h" -#include "jni/DevToolsServer_jni.h" #include "net/base/net_errors.h" #include "net/socket/unix_domain_server_socket_posix.h" #include "net/url_request/url_request_context_getter.h"
diff --git a/chrome/browser/android/document/document_web_contents_delegate.cc b/chrome/browser/android/document/document_web_contents_delegate.cc index d1f5c65..3b75d30 100644 --- a/chrome/browser/android/document/document_web_contents_delegate.cc +++ b/chrome/browser/android/document/document_web_contents_delegate.cc
@@ -4,9 +4,9 @@ #include "chrome/browser/android/document/document_web_contents_delegate.h" +#include "chrome/android/chrome_jni_headers/DocumentWebContentsDelegate_jni.h" #include "components/embedder_support/android/delegate/web_contents_delegate_android.h" #include "content/public/browser/web_contents.h" -#include "jni/DocumentWebContentsDelegate_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/dom_distiller/distiller_ui_handle_android.cc b/chrome/browser/android/dom_distiller/distiller_ui_handle_android.cc index 26274dd..fa3154e 100644 --- a/chrome/browser/android/dom_distiller/distiller_ui_handle_android.cc +++ b/chrome/browser/android/dom_distiller/distiller_ui_handle_android.cc
@@ -5,10 +5,10 @@ #include "chrome/browser/android/dom_distiller/distiller_ui_handle_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/DomDistillerUIUtils_jni.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "components/dom_distiller/core/url_utils.h" #include "content/public/browser/web_contents.h" -#include "jni/DomDistillerUIUtils_jni.h" #include "ui/android/window_android.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/download/download_controller.cc b/chrome/browser/android/download/download_controller.cc index 04504b4..76b0fe0a 100644 --- a/chrome/browser/android/download/download_controller.cc +++ b/chrome/browser/android/download/download_controller.cc
@@ -17,6 +17,7 @@ #include "base/metrics/histogram_macros.h" #include "base/synchronization/lock.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/DownloadController_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/download/dangerous_download_infobar_delegate.h" #include "chrome/browser/android/download/download_manager_service.h" @@ -44,7 +45,6 @@ #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/common/referrer.h" -#include "jni/DownloadController_jni.h" #include "net/base/filename_util.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/android/download/download_location_dialog_bridge_impl.cc b/chrome/browser/android/download/download_location_dialog_bridge_impl.cc index 9cff337..2b2015b 100644 --- a/chrome/browser/android/download/download_location_dialog_bridge_impl.cc +++ b/chrome/browser/android/download/download_location_dialog_bridge_impl.cc
@@ -7,8 +7,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/DownloadLocationDialogBridge_jni.h" #include "chrome/browser/android/download/download_controller.h" -#include "jni/DownloadLocationDialogBridge_jni.h" #include "ui/android/window_android.h" DownloadLocationDialogBridgeImpl::DownloadLocationDialogBridgeImpl()
diff --git a/chrome/browser/android/download/download_manager_bridge.cc b/chrome/browser/android/download/download_manager_bridge.cc index a0f7423..c2a64c8 100644 --- a/chrome/browser/android/download/download_manager_bridge.cc +++ b/chrome/browser/android/download/download_manager_bridge.cc
@@ -10,9 +10,9 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/feature_list.h" +#include "chrome/android/chrome_jni_headers/DownloadManagerBridge_jni.h" #include "components/download/public/common/download_features.h" #include "content/public/browser/browser_thread.h" -#include "jni/DownloadManagerBridge_jni.h" #include "url/gurl.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/download/download_manager_service.cc b/chrome/browser/android/download/download_manager_service.cc index ea7e740..128f0b6e 100644 --- a/chrome/browser/android/download/download_manager_service.cc +++ b/chrome/browser/android/download/download_manager_service.cc
@@ -16,6 +16,9 @@ #include "base/strings/string_number_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/DownloadInfo_jni.h" +#include "chrome/android/chrome_jni_headers/DownloadItem_jni.h" +#include "chrome/android/chrome_jni_headers/DownloadManagerService_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/download/download_controller.h" #include "chrome/browser/android/download/download_utils.h" @@ -43,9 +46,6 @@ #include "content/public/browser/network_service_instance.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/system_connector.h" -#include "jni/DownloadInfo_jni.h" -#include "jni/DownloadItem_jni.h" -#include "jni/DownloadManagerService_jni.h" #include "third_party/blink/public/common/mime_util/mime_util.h" #include "url/origin.h"
diff --git a/chrome/browser/android/download/download_media_parser_bridge.cc b/chrome/browser/android/download/download_media_parser_bridge.cc index 754b1e0..7ac2b957 100644 --- a/chrome/browser/android/download/download_media_parser_bridge.cc +++ b/chrome/browser/android/download/download_media_parser_bridge.cc
@@ -9,8 +9,8 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/task/post_task.h" -#include "jni/DownloadMediaData_jni.h" -#include "jni/DownloadMediaParserBridge_jni.h" +#include "chrome/android/chrome_jni_headers/DownloadMediaData_jni.h" +#include "chrome/android/chrome_jni_headers/DownloadMediaParserBridge_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h"
diff --git a/chrome/browser/android/download/download_utils.cc b/chrome/browser/android/download/download_utils.cc index ede353c..928185b 100644 --- a/chrome/browser/android/download/download_utils.cc +++ b/chrome/browser/android/download/download_utils.cc
@@ -9,6 +9,7 @@ #include "base/android/jni_string.h" #include "base/metrics/field_trial_params.h" #include "base/strings/string_number_conversions.h" +#include "chrome/android/chrome_jni_headers/DownloadUtils_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/download/offline_item_utils.h" #include "chrome/browser/profiles/profile.h" @@ -16,7 +17,6 @@ #include "components/download/public/common/download_utils.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/download_item_utils.h" -#include "jni/DownloadUtils_jni.h" #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc b/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc index e65630fa..58ddb33 100644 --- a/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc +++ b/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc
@@ -4,12 +4,12 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/OfflineContentAggregatorFactory_jni.h" #include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/offline_items_collection/core/android/offline_content_aggregator_bridge.h" #include "components/offline_items_collection/core/offline_content_aggregator.h" -#include "jni/OfflineContentAggregatorFactory_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/download/rename_utils.cc b/chrome/browser/android/download/rename_utils.cc index 1a846e5..742ef5ee 100644 --- a/chrome/browser/android/download/rename_utils.cc +++ b/chrome/browser/android/download/rename_utils.cc
@@ -4,7 +4,7 @@ #include "base/android/jni_string.h" #include "base/files/file_path.h" -#include "jni/RenameUtils_jni.h" +#include "chrome/android/chrome_jni_headers/RenameUtils_jni.h" using base::android::ConvertUTF8ToJavaString; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/download/service/download_background_task.cc b/chrome/browser/android/download/service/download_background_task.cc index 2e233d4d..3b54f6b 100644 --- a/chrome/browser/android/download/service/download_background_task.cc +++ b/chrome/browser/android/download/service/download_background_task.cc
@@ -5,6 +5,7 @@ #include "base/android/callback_android.h" #include "base/bind.h" #include "base/callback_forward.h" +#include "chrome/android/chrome_jni_headers/DownloadBackgroundTask_jni.h" #include "chrome/browser/android/download/download_manager_service.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/download/download_service_factory.h" @@ -12,7 +13,6 @@ #include "components/download/public/background_service/download_service.h" #include "components/download/public/common/auto_resumption_handler.h" #include "content/public/browser/browser_context.h" -#include "jni/DownloadBackgroundTask_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/download/service/download_task_scheduler.cc b/chrome/browser/android/download/service/download_task_scheduler.cc index cc53312..7f4770c 100644 --- a/chrome/browser/android/download/service/download_task_scheduler.cc +++ b/chrome/browser/android/download/service/download_task_scheduler.cc
@@ -6,7 +6,7 @@ #include "base/android/jni_android.h" #include "base/trace_event/trace_event.h" -#include "jni/DownloadTaskScheduler_jni.h" +#include "chrome/android/chrome_jni_headers/DownloadTaskScheduler_jni.h" namespace download { namespace android {
diff --git a/chrome/browser/android/explore_sites/explore_sites_bridge.cc b/chrome/browser/android/explore_sites/explore_sites_bridge.cc index 0db7013..893e40d6 100644 --- a/chrome/browser/android/explore_sites/explore_sites_bridge.cc +++ b/chrome/browser/android/explore_sites/explore_sites_bridge.cc
@@ -13,6 +13,9 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/ExploreSitesBridge_jni.h" +#include "chrome/android/chrome_jni_headers/ExploreSitesCategory_jni.h" +#include "chrome/android/chrome_jni_headers/ExploreSitesSite_jni.h" #include "chrome/browser/android/explore_sites/explore_sites_bridge.h" #include "chrome/browser/android/explore_sites/explore_sites_feature.h" #include "chrome/browser/android/explore_sites/explore_sites_service.h" @@ -22,9 +25,6 @@ #include "chrome/browser/profiles/profile_android.h" #include "components/language/core/browser/pref_names.h" #include "components/prefs/pref_service.h" -#include "jni/ExploreSitesBridge_jni.h" -#include "jni/ExploreSitesCategory_jni.h" -#include "jni/ExploreSitesSite_jni.h" #include "ui/gfx/android/java_bitmap.h" namespace explore_sites {
diff --git a/chrome/browser/android/explore_sites/explore_sites_bridge_experimental.cc b/chrome/browser/android/explore_sites/explore_sites_bridge_experimental.cc index 9bead57..2c9a09a 100644 --- a/chrome/browser/android/explore_sites/explore_sites_bridge_experimental.cc +++ b/chrome/browser/android/explore_sites/explore_sites_bridge_experimental.cc
@@ -11,6 +11,8 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/ExploreSitesBridgeExperimental_jni.h" +#include "chrome/android/chrome_jni_headers/ExploreSitesCategoryTile_jni.h" #include "chrome/browser/android/explore_sites/catalog.h" #include "chrome/browser/android/explore_sites/catalog.pb.h" #include "chrome/browser/android/explore_sites/ntp_json_fetcher.h" @@ -21,8 +23,6 @@ #include "components/image_fetcher/core/image_fetcher.h" #include "components/image_fetcher/core/image_fetcher_impl.h" #include "content/public/browser/storage_partition.h" -#include "jni/ExploreSitesBridgeExperimental_jni.h" -#include "jni/ExploreSitesCategoryTile_jni.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/simple_url_loader.h"
diff --git a/chrome/browser/android/favicon_helper.cc b/chrome/browser/android/favicon_helper.cc index db70943..988a2586 100644 --- a/chrome/browser/android/favicon_helper.cc +++ b/chrome/browser/android/favicon_helper.cc
@@ -16,6 +16,7 @@ #include "base/bind.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/FaviconHelper_jni.h" #include "chrome/browser/favicon/favicon_request_handler_factory.h" #include "chrome/browser/favicon/favicon_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -30,7 +31,6 @@ #include "components/sync_sessions/open_tabs_ui_delegate.h" #include "components/sync_sessions/session_sync_service.h" #include "content/public/browser/web_contents.h" -#include "jni/FaviconHelper_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/codec/png_codec.h"
diff --git a/chrome/browser/android/feature_engagement/tracker_factory_android.cc b/chrome/browser/android/feature_engagement/tracker_factory_android.cc index a3fe513..20fcd1e9 100644 --- a/chrome/browser/android/feature_engagement/tracker_factory_android.cc +++ b/chrome/browser/android/feature_engagement/tracker_factory_android.cc
@@ -3,11 +3,11 @@ // found in the LICENSE file. #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/TrackerFactory_jni.h" #include "chrome/browser/feature_engagement/tracker_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feature_engagement/public/tracker.h" -#include "jni/TrackerFactory_jni.h" static base::android::ScopedJavaLocalRef<jobject> JNI_TrackerFactory_GetTrackerForProfile(
diff --git a/chrome/browser/android/feature_utilities.cc b/chrome/browser/android/feature_utilities.cc index 126b17c..0a2ab01b 100644 --- a/chrome/browser/android/feature_utilities.cc +++ b/chrome/browser/android/feature_utilities.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/android/feature_utilities.h" -#include "jni/FeatureUtilities_jni.h" +#include "chrome/android/chrome_jni_headers/FeatureUtilities_jni.h" #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" #include "chrome/browser/profiles/profile_manager.h"
diff --git a/chrome/browser/android/feed/feed_content_bridge.cc b/chrome/browser/android/feed/feed_content_bridge.cc index 6a76b7fd..e20165d 100644 --- a/chrome/browser/android/feed/feed_content_bridge.cc +++ b/chrome/browser/android/feed/feed_content_bridge.cc
@@ -15,13 +15,13 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/FeedContentBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" #include "components/feed/core/feed_content_database.h" #include "components/feed/core/feed_content_mutation.h" -#include "jni/FeedContentBridge_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/android/feed/feed_debugging_bridge.cc b/chrome/browser/android/feed/feed_debugging_bridge.cc index 5d6f501..305d9ef1 100644 --- a/chrome/browser/android/feed/feed_debugging_bridge.cc +++ b/chrome/browser/android/feed/feed_debugging_bridge.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/feed/feed_debugging_bridge.h" #include "base/android/jni_string.h" -#include "jni/FeedDebuggingBridge_jni.h" +#include "chrome/android/chrome_jni_headers/FeedDebuggingBridge_jni.h" #include "url/gurl.h" namespace feed {
diff --git a/chrome/browser/android/feed/feed_journal_bridge.cc b/chrome/browser/android/feed/feed_journal_bridge.cc index db7295b..7a373c5 100644 --- a/chrome/browser/android/feed/feed_journal_bridge.cc +++ b/chrome/browser/android/feed/feed_journal_bridge.cc
@@ -15,13 +15,13 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/FeedJournalBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" #include "components/feed/core/feed_journal_database.h" #include "components/feed/core/feed_journal_mutation.h" -#include "jni/FeedJournalBridge_jni.h" namespace feed {
diff --git a/chrome/browser/android/feed/feed_lifecycle_bridge.cc b/chrome/browser/android/feed/feed_lifecycle_bridge.cc index 30d260ec..6e844cc 100644 --- a/chrome/browser/android/feed/feed_lifecycle_bridge.cc +++ b/chrome/browser/android/feed/feed_lifecycle_bridge.cc
@@ -6,12 +6,12 @@ #include "base/android/jni_android.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/FeedLifecycleBridge_jni.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/feed_feature_list.h" #include "components/history/core/browser/history_service.h" -#include "jni/FeedLifecycleBridge_jni.h" using base::android::JavaRef; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/feed/feed_logging_bridge.cc b/chrome/browser/android/feed/feed_logging_bridge.cc index e29fe06..a29ff7f 100644 --- a/chrome/browser/android/feed/feed_logging_bridge.cc +++ b/chrome/browser/android/feed/feed_logging_bridge.cc
@@ -10,12 +10,12 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/FeedLoggingBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" #include "components/feed/core/feed_logging_metrics.h" -#include "jni/FeedLoggingBridge_jni.h" namespace feed {
diff --git a/chrome/browser/android/feed/feed_network_bridge.cc b/chrome/browser/android/feed/feed_network_bridge.cc index c2a7742..70642a0 100644 --- a/chrome/browser/android/feed/feed_network_bridge.cc +++ b/chrome/browser/android/feed/feed_network_bridge.cc
@@ -13,12 +13,12 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/trace_event/trace_event.h" +#include "chrome/android/chrome_jni_headers/FeedNetworkBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" #include "components/feed/core/feed_networking_host.h" -#include "jni/FeedNetworkBridge_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/feed/feed_offline_bridge.cc b/chrome/browser/android/feed/feed_offline_bridge.cc index 66072cb..664fd053 100644 --- a/chrome/browser/android/feed/feed_offline_bridge.cc +++ b/chrome/browser/android/feed/feed_offline_bridge.cc
@@ -14,12 +14,12 @@ #include "base/bind.h" #include "base/optional.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/FeedOfflineBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" #include "components/feed/core/content_metadata.h" -#include "jni/FeedOfflineBridge_jni.h" using base::android::JavaRef; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/feed/feed_scheduler_bridge.cc b/chrome/browser/android/feed/feed_scheduler_bridge.cc index e9ad48b9..0360a58 100644 --- a/chrome/browser/android/feed/feed_scheduler_bridge.cc +++ b/chrome/browser/android/feed/feed_scheduler_bridge.cc
@@ -10,11 +10,11 @@ #include "base/android/jni_android.h" #include "base/bind.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/FeedSchedulerBridge_jni.h" #include "chrome/browser/android/feed/feed_host_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/feed/content/feed_host_service.h" -#include "jni/FeedSchedulerBridge_jni.h" using base::android::JavaRef; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/feedback/connectivity_checker.cc b/chrome/browser/android/feedback/connectivity_checker.cc index ac9cbea..030a0edd 100644 --- a/chrome/browser/android/feedback/connectivity_checker.cc +++ b/chrome/browser/android/feedback/connectivity_checker.cc
@@ -11,10 +11,10 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/timer/timer.h" +#include "chrome/android/chrome_jni_headers/ConnectivityChecker_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/browser/storage_partition.h" -#include "jni/ConnectivityChecker_jni.h" #include "net/base/load_flags.h" #include "net/http/http_status_code.h" #include "services/network/public/cpp/resource_request.h"
diff --git a/chrome/browser/android/feedback/process_id_feedback_source.cc b/chrome/browser/android/feedback/process_id_feedback_source.cc index e66abf8..20318bd 100644 --- a/chrome/browser/android/feedback/process_id_feedback_source.cc +++ b/chrome/browser/android/feedback/process_id_feedback_source.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/feedback/process_id_feedback_source.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/ProcessIdFeedbackSource_jni.h" #include "content/public/browser/browser_task_traits.h" -#include "jni/ProcessIdFeedbackSource_jni.h" #include "base/android/jni_array.h" #include "base/bind.h"
diff --git a/chrome/browser/android/feedback/screenshot_task.cc b/chrome/browser/android/feedback/screenshot_task.cc index cf87a05..875eb38 100644 --- a/chrome/browser/android/feedback/screenshot_task.cc +++ b/chrome/browser/android/feedback/screenshot_task.cc
@@ -7,7 +7,7 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/memory/ref_counted_memory.h" -#include "jni/ScreenshotTask_jni.h" +#include "chrome/android/chrome_jni_headers/ScreenshotTask_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/android/window_android.h" #include "ui/gfx/geometry/rect.h"
diff --git a/chrome/browser/android/feedback/system_info_feedback_source.cc b/chrome/browser/android/feedback/system_info_feedback_source.cc index fec73455..ba47635 100644 --- a/chrome/browser/android/feedback/system_info_feedback_source.cc +++ b/chrome/browser/android/feedback/system_info_feedback_source.cc
@@ -6,9 +6,9 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/system/sys_info.h" +#include "chrome/android/chrome_jni_headers/SystemInfoFeedbackSource_jni.h" #include "content/public/browser/gpu_data_manager.h" #include "gpu/config/gpu_info.h" -#include "jni/SystemInfoFeedbackSource_jni.h" using base::android::ConvertUTF8ToJavaString; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/find_in_page/find_in_page_bridge.cc b/chrome/browser/android/find_in_page/find_in_page_bridge.cc index e9fef6a..84b237df 100644 --- a/chrome/browser/android/find_in_page/find_in_page_bridge.cc +++ b/chrome/browser/android/find_in_page/find_in_page_bridge.cc
@@ -5,9 +5,9 @@ #include "chrome/browser/android/find_in_page/find_in_page_bridge.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/FindInPageBridge_jni.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" #include "content/public/browser/web_contents.h" -#include "jni/FindInPageBridge_jni.h" using base::android::ConvertUTF16ToJavaString; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/foreign_session_helper.cc b/chrome/browser/android/foreign_session_helper.cc index a2c62865..ce3928e 100644 --- a/chrome/browser/android/foreign_session_helper.cc +++ b/chrome/browser/android/foreign_session_helper.cc
@@ -9,6 +9,7 @@ #include "base/android/jni_string.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/ForeignSessionHelper_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/profiles/profile_android.h" @@ -28,7 +29,6 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" -#include "jni/ForeignSessionHelper_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaGlobalRef;
diff --git a/chrome/browser/android/headers_classifier.cc b/chrome/browser/android/headers_classifier.cc index 58301dc..c935a34 100644 --- a/chrome/browser/android/headers_classifier.cc +++ b/chrome/browser/android/headers_classifier.cc
@@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/android/jni_string.h" -#include "jni/IntentHeadersRecorder_jni.h" +#include "chrome/android/chrome_jni_headers/IntentHeadersRecorder_jni.h" #include "services/network/public/cpp/cors/cors.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/history/browsing_history_bridge.cc b/chrome/browser/android/history/browsing_history_bridge.cc index 5d16650..d6bd48b 100644 --- a/chrome/browser/android/history/browsing_history_bridge.cc +++ b/chrome/browser/android/history/browsing_history_bridge.cc
@@ -12,13 +12,13 @@ #include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/BrowsingHistoryBridge_jni.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "components/history/core/browser/browsing_history_service.h" #include "components/keyed_service/core/service_access_type.h" #include "components/url_formatter/url_formatter.h" -#include "jni/BrowsingHistoryBridge_jni.h" using history::BrowsingHistoryService;
diff --git a/chrome/browser/android/history/history_deletion_bridge.cc b/chrome/browser/android/history/history_deletion_bridge.cc index bce4453..e1d8036 100644 --- a/chrome/browser/android/history/history_deletion_bridge.cc +++ b/chrome/browser/android/history/history_deletion_bridge.cc
@@ -7,12 +7,12 @@ #include <string> #include <vector> +#include "chrome/android/chrome_jni_headers/HistoryDeletionBridge_jni.h" #include "chrome/browser/android/history/history_deletion_info.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "components/history/core/browser/history_service.h" -#include "jni/HistoryDeletionBridge_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/android/history/history_deletion_info.cc b/chrome/browser/android/history/history_deletion_info.cc index 73264433..ff78d78 100644 --- a/chrome/browser/android/history/history_deletion_info.cc +++ b/chrome/browser/android/history/history_deletion_info.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/history/history_deletion_info.h" #include "base/android/jni_array.h" +#include "chrome/android/chrome_jni_headers/HistoryDeletionInfo_jni.h" #include "components/history/core/browser/history_types.h" -#include "jni/HistoryDeletionInfo_jni.h" using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/history_report/history_report_jni_bridge.cc b/chrome/browser/android/history_report/history_report_jni_bridge.cc index 1c41dc1..90222e0 100644 --- a/chrome/browser/android/history_report/history_report_jni_bridge.cc +++ b/chrome/browser/android/history_report/history_report_jni_bridge.cc
@@ -13,6 +13,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/HistoryReportJniBridge_jni.h" #include "chrome/browser/android/history_report/data_observer.h" #include "chrome/browser/android/history_report/data_provider.h" #include "chrome/browser/android/history_report/delta_file_commons.h" @@ -27,7 +28,6 @@ #include "components/bookmarks/browser/bookmark_model.h" #include "components/history/core/browser/history_service.h" #include "content/public/browser/browser_thread.h" -#include "jni/HistoryReportJniBridge_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc b/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc index 6ec9662..184de0a 100644 --- a/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc +++ b/chrome/browser/android/image_fetcher/image_fetcher_bridge.cc
@@ -16,11 +16,11 @@ #include "chrome/browser/image_fetcher/image_fetcher_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" +#include "chrome/lib/image_fetcher/public/android/jni_headers/ImageFetcherBridge_jni.h" #include "components/image_fetcher/core/cache/image_cache.h" #include "components/image_fetcher/core/image_fetcher.h" #include "components/image_fetcher/core/image_fetcher_metrics_reporter.h" #include "components/image_fetcher/core/image_fetcher_service.h" -#include "jni/ImageFetcherBridge_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/android/instantapps/instant_apps_infobar_delegate.cc b/chrome/browser/android/instantapps/instant_apps_infobar_delegate.cc index c707052..d6a8f3ef1 100644 --- a/chrome/browser/android/instantapps/instant_apps_infobar_delegate.cc +++ b/chrome/browser/android/instantapps/instant_apps_infobar_delegate.cc
@@ -9,13 +9,13 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/metrics/user_metrics.h" +#include "chrome/android/chrome_jni_headers/InstantAppsInfoBarDelegate_jni.h" #include "chrome/browser/android/instantapps/instant_apps_settings.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/android/infobars/instant_apps_infobar.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" -#include "jni/InstantAppsInfoBarDelegate_jni.h" #include "ui/base/page_transition_types.h" namespace {
diff --git a/chrome/browser/android/instantapps/instant_apps_settings.cc b/chrome/browser/android/instantapps/instant_apps_settings.cc index 044126fe..63e75f4 100644 --- a/chrome/browser/android/instantapps/instant_apps_settings.cc +++ b/chrome/browser/android/instantapps/instant_apps_settings.cc
@@ -9,10 +9,10 @@ #include "base/metrics/histogram_macros.h" #include "base/time/time.h" #include "base/values.h" +#include "chrome/android/chrome_jni_headers/InstantAppsSettings_jni.h" #include "chrome/browser/banners/app_banner_settings_helper.h" #include "chrome/browser/installable/installable_logging.h" #include "content/public/browser/web_contents.h" -#include "jni/InstantAppsSettings_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/intent_helper.cc b/chrome/browser/android/intent_helper.cc index 187d1ec..2811d8c 100644 --- a/chrome/browser/android/intent_helper.cc +++ b/chrome/browser/android/intent_helper.cc
@@ -9,7 +9,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" -#include "jni/IntentHelper_jni.h" +#include "chrome/android/chrome_jni_headers/IntentHelper_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF16ToJavaString;
diff --git a/chrome/browser/android/intercept_navigation_delegate_impl.cc b/chrome/browser/android/intercept_navigation_delegate_impl.cc index 76722b7f..d654b01 100644 --- a/chrome/browser/android/intercept_navigation_delegate_impl.cc +++ b/chrome/browser/android/intercept_navigation_delegate_impl.cc
@@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/android/chrome_jni_headers/InterceptNavigationDelegateImpl_jni.h" #include "components/navigation_interception/intercept_navigation_delegate.h" #include "components/navigation_interception/navigation_params.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" -#include "jni/InterceptNavigationDelegateImpl_jni.h" #include "net/base/escape.h" namespace {
diff --git a/chrome/browser/android/large_icon_bridge.cc b/chrome/browser/android/large_icon_bridge.cc index fbd7d6f..b413f6e 100644 --- a/chrome/browser/android/large_icon_bridge.cc +++ b/chrome/browser/android/large_icon_bridge.cc
@@ -11,13 +11,13 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/LargeIconBridge_jni.h" #include "chrome/browser/favicon/large_icon_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/favicon/core/large_icon_service.h" #include "components/favicon_base/fallback_icon_style.h" #include "components/favicon_base/favicon_types.h" -#include "jni/LargeIconBridge_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/codec/png_codec.h"
diff --git a/chrome/browser/android/locale/locale_manager.cc b/chrome/browser/android/locale/locale_manager.cc index 89f1af3..36a3754 100644 --- a/chrome/browser/android/locale/locale_manager.cc +++ b/chrome/browser/android/locale/locale_manager.cc
@@ -6,8 +6,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/LocaleManager_jni.h" #include "components/search_engines/template_url_prepopulate_data.h" -#include "jni/LocaleManager_jni.h" #include "url/gurl.h" // static
diff --git a/chrome/browser/android/locale/locale_template_url_loader.cc b/chrome/browser/android/locale/locale_template_url_loader.cc index cc0accf7..30926be 100644 --- a/chrome/browser/android/locale/locale_template_url_loader.cc +++ b/chrome/browser/android/locale/locale_template_url_loader.cc
@@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/jni_weak_ref.h" +#include "chrome/android/chrome_jni_headers/LocaleTemplateUrlLoader_jni.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "components/search_engines/prepopulated_engines.h" @@ -13,7 +14,6 @@ #include "components/search_engines/template_url_prepopulate_data.h" #include "components/search_engines/template_url_service.h" #include "components/search_engines/util.h" -#include "jni/LocaleTemplateUrlLoader_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaGlobalRef;
diff --git a/chrome/browser/android/location_settings_impl.cc b/chrome/browser/android/location_settings_impl.cc index 41cb5467..a623325c 100644 --- a/chrome/browser/android/location_settings_impl.cc +++ b/chrome/browser/android/location_settings_impl.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/location_settings_impl.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/LocationSettings_jni.h" #include "content/public/browser/web_contents.h" -#include "jni/LocationSettings_jni.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/logo_bridge.cc b/chrome/browser/android/logo_bridge.cc index 4cb8c89..12ab566 100644 --- a/chrome/browser/android/logo_bridge.cc +++ b/chrome/browser/android/logo_bridge.cc
@@ -12,13 +12,13 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/LogoBridge_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/search_provider_logos/logo_service_factory.h" #include "components/search_provider_logos/logo_observer.h" #include "components/search_provider_logos/logo_service.h" #include "content/public/browser/storage_partition.h" -#include "jni/LogoBridge_jni.h" #include "net/http/http_status_code.h" #include "services/network/public/cpp/resource_response_info.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
diff --git a/chrome/browser/android/metrics/BUILD.gn b/chrome/browser/android/metrics/BUILD.gn index 7c005ea7..cdb8fca 100644 --- a/chrome/browser/android/metrics/BUILD.gn +++ b/chrome/browser/android/metrics/BUILD.gn
@@ -22,7 +22,6 @@ sources = [ "../../../android/java/src/org/chromium/chrome/browser/metrics/UkmUtilsForTest.java", ] - jni_package = "chrome" } android_library("ukm_utils_java") {
diff --git a/chrome/browser/android/metrics/launch_metrics.cc b/chrome/browser/android/metrics/launch_metrics.cc index 9a9f0b18..204ed37 100644 --- a/chrome/browser/android/metrics/launch_metrics.cc +++ b/chrome/browser/android/metrics/launch_metrics.cc
@@ -5,6 +5,7 @@ #include "base/android/jni_string.h" #include "base/metrics/histogram_macros.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/LaunchMetrics_jni.h" #include "chrome/browser/android/shortcut_info.h" #include "chrome/browser/banners/app_banner_settings_helper.h" #include "chrome/browser/browser_process.h" @@ -14,7 +15,6 @@ #include "components/rappor/public/rappor_utils.h" #include "components/rappor/rappor_service_impl.h" #include "content/public/browser/web_contents.h" -#include "jni/LaunchMetrics_jni.h" #include "third_party/blink/public/common/manifest/web_display_mode.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/metrics/ukm_utils_for_test.cc b/chrome/browser/android/metrics/ukm_utils_for_test.cc index 1ae6ea6..c30dbca 100644 --- a/chrome/browser/android/metrics/ukm_utils_for_test.cc +++ b/chrome/browser/android/metrics/ukm_utils_for_test.cc
@@ -4,10 +4,10 @@ #include "base/android/jni_string.h" #include "base/stl_util.h" +#include "chrome/browser/android/metrics/jni_headers/UkmUtilsForTest_jni.h" #include "chrome/browser/browser_process.h" #include "components/metrics_services_manager/metrics_services_manager.h" #include "components/ukm/ukm_service.h" -#include "jni/UkmUtilsForTest_jni.h" #include "chrome/browser/android/metrics/ukm_utils_for_test.h"
diff --git a/chrome/browser/android/metrics/uma_session_stats.cc b/chrome/browser/android/metrics/uma_session_stats.cc index c55ed7b8..b2d6529 100644 --- a/chrome/browser/android/metrics/uma_session_stats.cc +++ b/chrome/browser/android/metrics/uma_session_stats.cc
@@ -13,6 +13,7 @@ #include "base/strings/string_number_conversions.h" #include "base/time/time.h" #include "build/build_config.h" +#include "chrome/android/chrome_jni_headers/UmaSessionStats_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/metrics/android_profile_session_durations_service.h" #include "chrome/browser/android/metrics/android_profile_session_durations_service_factory.h" @@ -29,7 +30,6 @@ #include "components/variations/hashing.h" #include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_thread.h" -#include "jni/UmaSessionStats_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/metrics/uma_utils.cc b/chrome/browser/android/metrics/uma_utils.cc index 7228d1d..767e0894 100644 --- a/chrome/browser/android/metrics/uma_utils.cc +++ b/chrome/browser/android/metrics/uma_utils.cc
@@ -6,10 +6,10 @@ #include <stdint.h> +#include "chrome/android/chrome_jni_headers/UmaUtils_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" #include "components/metrics/metrics_reporting_default_state.h" -#include "jni/UmaUtils_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/metrics/variations_session.cc b/chrome/browser/android/metrics/variations_session.cc index 8b34186..23daabdb 100644 --- a/chrome/browser/android/metrics/variations_session.cc +++ b/chrome/browser/android/metrics/variations_session.cc
@@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/VariationsSession_jni.h" #include "chrome/browser/browser_process.h" #include "components/variations/service/variations_service.h" -#include "jni/VariationsSession_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/mojo/chrome_interface_registrar_android.cc b/chrome/browser/android/mojo/chrome_interface_registrar_android.cc index f04effc0..5ed987e 100644 --- a/chrome/browser/android/mojo/chrome_interface_registrar_android.cc +++ b/chrome/browser/android/mojo/chrome_interface_registrar_android.cc
@@ -7,7 +7,7 @@ #include <jni.h> #include "base/android/jni_android.h" -#include "jni/ChromeInterfaceRegistrar_jni.h" +#include "chrome/android/chrome_jni_headers/ChromeInterfaceRegistrar_jni.h" void RegisterChromeJavaMojoInterfaces() { Java_ChromeInterfaceRegistrar_registerMojoInterfaces(
diff --git a/chrome/browser/android/net/nqe/network_quality_provider.cc b/chrome/browser/android/net/nqe/network_quality_provider.cc index 4ceffda..3933070 100644 --- a/chrome/browser/android/net/nqe/network_quality_provider.cc +++ b/chrome/browser/android/net/nqe/network_quality_provider.cc
@@ -5,10 +5,10 @@ #include "chrome/browser/android/net/nqe/network_quality_provider.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/NetworkQualityProvider_jni.h" #include "chrome/browser/browser_process.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/network_quality_observer_factory.h" -#include "jni/NetworkQualityProvider_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/ntp/most_visited_sites_bridge.cc b/chrome/browser/android/ntp/most_visited_sites_bridge.cc index 160c72d..f27bfd7 100644 --- a/chrome/browser/android/ntp/most_visited_sites_bridge.cc +++ b/chrome/browser/android/ntp/most_visited_sites_bridge.cc
@@ -16,6 +16,8 @@ #include "base/bind.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/MostVisitedSitesBridge_jni.h" +#include "chrome/android/chrome_jni_headers/MostVisitedSites_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/ntp_tiles/chrome_most_visited_sites_factory.h" @@ -27,8 +29,6 @@ #include "components/ntp_tiles/most_visited_sites.h" #include "components/ntp_tiles/section_type.h" #include "components/rappor/rappor_service_impl.h" -#include "jni/MostVisitedSitesBridge_jni.h" -#include "jni/MostVisitedSites_jni.h" #include "ui/gfx/android/java_bitmap.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc index 6be3886..e0538d1 100644 --- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc +++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -18,6 +18,7 @@ #include "base/callback.h" #include "base/feature_list.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/SnippetsBridge_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/ntp/get_remote_suggestions_scheduler.h" #include "chrome/browser/history/history_service_factory.h" @@ -30,7 +31,6 @@ #include "components/ntp_snippets/pref_names.h" #include "components/ntp_snippets/remote/remote_suggestions_provider.h" #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" -#include "jni/SnippetsBridge_jni.h" #include "ui/base/window_open_disposition.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/android/ntp/ntp_snippets_launcher.cc b/chrome/browser/android/ntp/ntp_snippets_launcher.cc index b2476800..22503020 100644 --- a/chrome/browser/android/ntp/ntp_snippets_launcher.cc +++ b/chrome/browser/android/ntp/ntp_snippets_launcher.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" +#include "chrome/android/chrome_jni_headers/SnippetsLauncher_jni.h" #include "content/public/browser/browser_thread.h" -#include "jni/SnippetsLauncher_jni.h" using content::BrowserThread;
diff --git a/chrome/browser/android/ntp/recent_tabs_page_prefs.cc b/chrome/browser/android/ntp/recent_tabs_page_prefs.cc index da0224d..d81a78b 100644 --- a/chrome/browser/android/ntp/recent_tabs_page_prefs.cc +++ b/chrome/browser/android/ntp/recent_tabs_page_prefs.cc
@@ -7,12 +7,12 @@ #include <jni.h> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/RecentTabsPagePrefs_jni.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" -#include "jni/RecentTabsPagePrefs_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/ntp/suggestions_event_reporter_bridge.cc b/chrome/browser/android/ntp/suggestions_event_reporter_bridge.cc index 2305142..34213161c 100644 --- a/chrome/browser/android/ntp/suggestions_event_reporter_bridge.cc +++ b/chrome/browser/android/ntp/suggestions_event_reporter_bridge.cc
@@ -9,6 +9,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/SuggestionsEventReporterBridge_jni.h" #include "chrome/browser/android/ntp/get_remote_suggestions_scheduler.h" #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -17,7 +18,6 @@ #include "components/ntp_snippets/content_suggestions_service.h" #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" #include "components/ntp_snippets/user_classifier.h" -#include "jni/SuggestionsEventReporterBridge_jni.h" #include "net/base/network_change_notifier.h" #include "ui/base/window_open_disposition.h"
diff --git a/chrome/browser/android/omnibox/autocomplete_controller_android.cc b/chrome/browser/android/omnibox/autocomplete_controller_android.cc index 8a3f3bb..b348ced9 100644 --- a/chrome/browser/android/omnibox/autocomplete_controller_android.cc +++ b/chrome/browser/android/omnibox/autocomplete_controller_android.cc
@@ -17,6 +17,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "base/timer/timer.h" +#include "chrome/android/chrome_jni_headers/AutocompleteController_jni.h" #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" @@ -52,7 +53,6 @@ #include "components/url_formatter/url_formatter.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" -#include "jni/AutocompleteController_jni.h" #include "net/base/escape.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "third_party/metrics_proto/omnibox_event.pb.h"
diff --git a/chrome/browser/android/omnibox/omnibox_prerender.cc b/chrome/browser/android/omnibox/omnibox_prerender.cc index 59808cd..efe2d590 100644 --- a/chrome/browser/android/omnibox/omnibox_prerender.cc +++ b/chrome/browser/android/omnibox/omnibox_prerender.cc
@@ -6,6 +6,7 @@ #include "base/android/jni_string.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/OmniboxPrerender_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/predictors/autocomplete_action_predictor.h" #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" @@ -14,7 +15,6 @@ #include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_result.h" #include "content/public/browser/web_contents.h" -#include "jni/OmniboxPrerender_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/oom_intervention/near_oom_monitor.cc b/chrome/browser/android/oom_intervention/near_oom_monitor.cc index 72f96b1..97cd11a 100644 --- a/chrome/browser/android/oom_intervention/near_oom_monitor.cc +++ b/chrome/browser/android/oom_intervention/near_oom_monitor.cc
@@ -7,8 +7,8 @@ #include "base/bind.h" #include "base/system/sys_info.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/NearOomMonitor_jni.h" #include "chrome/browser/android/oom_intervention/oom_intervention_config.h" -#include "jni/NearOomMonitor_jni.h" namespace {
diff --git a/chrome/browser/android/partner_browser_customizations.cc b/chrome/browser/android/partner_browser_customizations.cc index fb53ca59..1d581ae 100644 --- a/chrome/browser/android/partner_browser_customizations.cc +++ b/chrome/browser/android/partner_browser_customizations.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/partner_browser_customizations.h" #include "base/android/jni_android.h" -#include "jni/PartnerBrowserCustomizations_jni.h" +#include "chrome/android/chrome_jni_headers/PartnerBrowserCustomizations_jni.h" namespace chrome { namespace android {
diff --git a/chrome/browser/android/password_ui_view_android.cc b/chrome/browser/android/password_ui_view_android.cc index fc679b5..2b10041 100644 --- a/chrome/browser/android/password_ui_view_android.cc +++ b/chrome/browser/android/password_ui_view_android.cc
@@ -23,6 +23,7 @@ #include "base/strings/string_piece.h" #include "base/task/post_task.h" #include "base/threading/scoped_blocking_call.h" +#include "chrome/android/chrome_jni_headers/PasswordUIView_jni.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/grit/generated_resources.h" #include "components/autofill/core/common/password_form.h" @@ -30,7 +31,6 @@ #include "components/password_manager/core/browser/password_ui_utils.h" #include "components/password_manager/core/browser/ui/credential_provider_interface.h" #include "content/public/browser/browser_thread.h" -#include "jni/PasswordUIView_jni.h" #include "ui/base/l10n/l10n_util.h" using base::android::ConvertUTF16ToJavaString;
diff --git a/chrome/browser/android/payments/service_worker_payment_app_bridge.cc b/chrome/browser/android/payments/service_worker_payment_app_bridge.cc index d980c32e..b4274247 100644 --- a/chrome/browser/android/payments/service_worker_payment_app_bridge.cc +++ b/chrome/browser/android/payments/service_worker_payment_app_bridge.cc
@@ -12,6 +12,7 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/macros.h" +#include "chrome/android/chrome_jni_headers/ServiceWorkerPaymentAppBridge_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/web_data_service_factory.h" @@ -22,7 +23,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/payment_app_provider.h" #include "content/public/browser/web_contents.h" -#include "jni/ServiceWorkerPaymentAppBridge_jni.h" #include "third_party/blink/public/mojom/payments/payment_app.mojom.h" #include "ui/gfx/android/java_bitmap.h" #include "url/origin.h"
diff --git a/chrome/browser/android/photo_picker_sandbox_bridge.cc b/chrome/browser/android/photo_picker_sandbox_bridge.cc index d5888b5..5c26961 100644 --- a/chrome/browser/android/photo_picker_sandbox_bridge.cc +++ b/chrome/browser/android/photo_picker_sandbox_bridge.cc
@@ -6,7 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/metrics/histogram_macros.h" -#include "jni/DecoderService_jni.h" +#include "chrome/android/chrome_jni_headers/DecoderService_jni.h" #include "sandbox/linux/seccomp-bpf-helpers/seccomp_starter_android.h" #include "sandbox/sandbox_buildflags.h"
diff --git a/chrome/browser/android/policy/policy_auditor.cc b/chrome/browser/android/policy/policy_auditor.cc index dae43388..1150791b 100644 --- a/chrome/browser/android/policy/policy_auditor.cc +++ b/chrome/browser/android/policy/policy_auditor.cc
@@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/android/chrome_jni_headers/PolicyAuditor_jni.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/ssl_status.h" #include "content/public/browser/web_contents.h" -#include "jni/PolicyAuditor_jni.h" #include "net/cert/cert_status_flags.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc b/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc index da961c9..7c31f6c 100644 --- a/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc +++ b/chrome/browser/android/preferences/autofill/autofill_profile_bridge.cc
@@ -7,9 +7,9 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/AutofillProfileBridge_jni.h" #include "chrome/browser/browser_process.h" #include "components/autofill/core/browser/geo/autofill_country.h" -#include "jni/AutofillProfileBridge_jni.h" #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_metadata.h" #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
diff --git a/chrome/browser/android/preferences/pref_change_registrar_android.cc b/chrome/browser/android/preferences/pref_change_registrar_android.cc index 32cb2a0e..a42f5e0 100644 --- a/chrome/browser/android/preferences/pref_change_registrar_android.cc +++ b/chrome/browser/android/preferences/pref_change_registrar_android.cc
@@ -7,9 +7,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/PrefChangeRegistrar_jni.h" #include "chrome/browser/android/preferences/pref_service_bridge.h" #include "chrome/browser/profiles/profile_manager.h" -#include "jni/PrefChangeRegistrar_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF8;
diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc index bc9712b..c3eb492 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.cc +++ b/chrome/browser/android/preferences/pref_service_bridge.cc
@@ -25,6 +25,7 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/values.h" +#include "chrome/android/chrome_jni_headers/PrefServiceBridge_jni.h" #include "chrome/browser/android/preferences/prefs.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" @@ -54,7 +55,6 @@ #include "components/version_info/version_info.h" #include "components/web_resource/web_resource_pref_names.h" #include "content/public/browser/browser_thread.h" -#include "jni/PrefServiceBridge_jni.h" #include "third_party/icu/source/common/unicode/uloc.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/android/preferences/preferences_launcher.cc b/chrome/browser/android/preferences/preferences_launcher.cc index be5185d5..2bb2463 100644 --- a/chrome/browser/android/preferences/preferences_launcher.cc +++ b/chrome/browser/android/preferences/preferences_launcher.cc
@@ -5,10 +5,10 @@ #include "chrome/browser/android/preferences/preferences_launcher.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/PreferencesLauncher_jni.h" #include "chrome/browser/android/tab_android.h" #include "components/password_manager/core/browser/manage_passwords_referrer.h" #include "content/public/browser/web_contents.h" -#include "jni/PreferencesLauncher_jni.h" namespace chrome { namespace android {
diff --git a/chrome/browser/android/preferences/website_preference_bridge.cc b/chrome/browser/android/preferences/website_preference_bridge.cc index 761ab2f..3af2e23 100644 --- a/chrome/browser/android/preferences/website_preference_bridge.cc +++ b/chrome/browser/android/preferences/website_preference_bridge.cc
@@ -17,6 +17,7 @@ #include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" +#include "chrome/android/chrome_jni_headers/WebsitePreferenceBridge_jni.h" #include "chrome/browser/android/search_permissions/search_permissions_service.h" #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" #include "chrome/browser/content_settings/cookie_settings_factory.h" @@ -39,7 +40,6 @@ #include "components/content_settings/core/browser/host_content_settings_map.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" -#include "jni/WebsitePreferenceBridge_jni.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "services/network/public/mojom/cookie_manager.mojom.h" #include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
diff --git a/chrome/browser/android/profiles/profile_downloader_android.cc b/chrome/browser/android/profiles/profile_downloader_android.cc index 0e84f7e..18cad19 100644 --- a/chrome/browser/android/profiles/profile_downloader_android.cc +++ b/chrome/browser/android/profiles/profile_downloader_android.cc
@@ -7,6 +7,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/macros.h" +#include "chrome/android/chrome_jni_headers/ProfileDownloader_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_attributes_entry.h" @@ -17,7 +18,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "google_apis/gaia/gaia_auth_util.h" -#include "jni/ProfileDownloader_jni.h" #include "services/identity/public/cpp/identity_manager.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h"
diff --git a/chrome/browser/android/profiles/profile_manager_utils.cc b/chrome/browser/android/profiles/profile_manager_utils.cc index 5fdb6da..5f4585dc 100644 --- a/chrome/browser/android/profiles/profile_manager_utils.cc +++ b/chrome/browser/android/profiles/profile_manager_utils.cc
@@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/bind.h" +#include "chrome/android/public/profiles/jni_headers/ProfileManagerUtils_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -13,7 +14,6 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" -#include "jni/ProfileManagerUtils_jni.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "services/network/public/mojom/cookie_manager.mojom.h"
diff --git a/chrome/browser/android/provider/chrome_browser_provider.cc b/chrome/browser/android/provider/chrome_browser_provider.cc index 3490ad3..756e197 100644 --- a/chrome/browser/android/provider/chrome_browser_provider.cc +++ b/chrome/browser/android/provider/chrome_browser_provider.cc
@@ -20,6 +20,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/task/cancelable_task_tracker.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/ChromeBrowserProvider_jni.h" #include "chrome/browser/android/provider/blocking_ui_thread_async_request.h" #include "chrome/browser/android/provider/bookmark_model_task.h" #include "chrome/browser/android/provider/run_on_ui_thread_blocking.h" @@ -43,7 +44,6 @@ #include "components/search_engines/template_url.h" #include "components/search_engines/template_url_service.h" #include "content/public/browser/browser_thread.h" -#include "jni/ChromeBrowserProvider_jni.h" #include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/favicon_size.h"
diff --git a/chrome/browser/android/rappor/rappor_service_bridge.cc b/chrome/browser/android/rappor/rappor_service_bridge.cc index 8c62adf..75aebc1 100644 --- a/chrome/browser/android/rappor/rappor_service_bridge.cc +++ b/chrome/browser/android/rappor/rappor_service_bridge.cc
@@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/RapporServiceBridge_jni.h" #include "chrome/browser/browser_process.h" #include "components/rappor/public/rappor_utils.h" #include "components/rappor/rappor_service_impl.h" -#include "jni/RapporServiceBridge_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/recently_closed_tabs_bridge.cc b/chrome/browser/android/recently_closed_tabs_bridge.cc index 611d4037..5df602d 100644 --- a/chrome/browser/android/recently_closed_tabs_bridge.cc +++ b/chrome/browser/android/recently_closed_tabs_bridge.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/android/recently_closed_tabs_bridge.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/RecentlyClosedBridge_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" @@ -14,7 +15,6 @@ #include "components/sessions/core/live_tab.h" #include "components/sessions/core/tab_restore_service.h" #include "content/public/browser/web_contents.h" -#include "jni/RecentlyClosedBridge_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF16ToJavaString;
diff --git a/chrome/browser/android/rlz/revenue_stats.cc b/chrome/browser/android/rlz/revenue_stats.cc index 7a6dacfe..4776a425 100644 --- a/chrome/browser/android/rlz/revenue_stats.cc +++ b/chrome/browser/android/rlz/revenue_stats.cc
@@ -4,8 +4,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/RevenueStats_jni.h" #include "chrome/browser/search_engines/ui_thread_search_terms_data_android.h" -#include "jni/RevenueStats_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/rlz/rlz_ping_handler.cc b/chrome/browser/android/rlz/rlz_ping_handler.cc index bfae3de..24fb0058 100644 --- a/chrome/browser/android/rlz/rlz_ping_handler.cc +++ b/chrome/browser/android/rlz/rlz_ping_handler.cc
@@ -11,11 +11,11 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/strings/stringprintf.h" +#include "chrome/android/chrome_jni_headers/RlzPingHandler_jni.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h" -#include "jni/RlzPingHandler_jni.h" #include "net/base/load_flags.h" #include "net/base/url_util.h" #include "net/http/http_response_headers.h"
diff --git a/chrome/browser/android/search_permissions/search_geolocation_disclosure_tab_helper.cc b/chrome/browser/android/search_permissions/search_geolocation_disclosure_tab_helper.cc index 132a73ca..23491cd2b 100644 --- a/chrome/browser/android/search_permissions/search_geolocation_disclosure_tab_helper.cc +++ b/chrome/browser/android/search_permissions/search_geolocation_disclosure_tab_helper.cc
@@ -11,6 +11,8 @@ #include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/GeolocationHeader_jni.h" +#include "chrome/android/chrome_jni_headers/SearchGeolocationDisclosureTabHelper_jni.h" #include "chrome/browser/android/search_permissions/search_geolocation_disclosure_infobar_delegate.h" #include "chrome/browser/android/search_permissions/search_permissions_service.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" @@ -30,8 +32,6 @@ #include "components/search_engines/template_url_service.h" #include "components/variations/variations_associated_data.h" #include "content/public/browser/web_contents.h" -#include "jni/GeolocationHeader_jni.h" -#include "jni/SearchGeolocationDisclosureTabHelper_jni.h" #include "third_party/blink/public/mojom/permissions/permission_status.mojom.h" #include "url/origin.h"
diff --git a/chrome/browser/android/send_tab_to_self/android_notification_handler.cc b/chrome/browser/android/send_tab_to_self/android_notification_handler.cc index 93bcd39..a098d0bd 100644 --- a/chrome/browser/android/send_tab_to_self/android_notification_handler.cc +++ b/chrome/browser/android/send_tab_to_self/android_notification_handler.cc
@@ -10,8 +10,8 @@ #include "base/android/jni_string.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/NotificationManager_jni.h" #include "components/send_tab_to_self/send_tab_to_self_entry.h" -#include "jni/NotificationManager_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc index 5487371..04ce5ee 100644 --- a/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_android_bridge.cc
@@ -9,6 +9,8 @@ #include "base/android/jni_string.h" #include "base/metrics/histogram_macros.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/SendTabToSelfAndroidBridge_jni.h" +#include "chrome/android/chrome_jni_headers/TargetDeviceInfo_jni.h" #include "chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h" #include "chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.h" #include "chrome/browser/profiles/profile.h" @@ -22,8 +24,6 @@ #include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "components/send_tab_to_self/target_device_info.h" #include "content/public/browser/web_contents.h" -#include "jni/SendTabToSelfAndroidBridge_jni.h" -#include "jni/TargetDeviceInfo_jni.h" #include "url/gurl.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc index d408b8f..c393a239 100644 --- a/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.cc
@@ -6,8 +6,8 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/SendTabToSelfEntry_jni.h" #include "components/send_tab_to_self/send_tab_to_self_entry.h" -#include "jni/SendTabToSelfEntry_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.cc index 9280a9c..b0f2400 100644 --- a/chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.cc +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_infobar.cc
@@ -11,12 +11,12 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/SendTabToSelfInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/android/infobars/infobar_android.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/SendTabToSelfInfoBar_jni.h" namespace send_tab_to_self {
diff --git a/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc index fe2af45..47fb7c8 100644 --- a/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc +++ b/chrome/browser/android/send_tab_to_self/send_tab_to_self_model_observer_bridge.cc
@@ -10,6 +10,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/SendTabToSelfModelObserverBridge_jni.h" #include "chrome/browser/android/send_tab_to_self/send_tab_to_self_entry_bridge.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" @@ -18,7 +19,6 @@ #include "components/send_tab_to_self/send_tab_to_self_model.h" #include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "content/public/browser/web_contents.h" -#include "jni/SendTabToSelfModelObserverBridge_jni.h" #include "url/gurl.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/service_tab_launcher.cc b/chrome/browser/android/service_tab_launcher.cc index 0077f25a..5016ae0 100644 --- a/chrome/browser/android/service_tab_launcher.cc +++ b/chrome/browser/android/service_tab_launcher.cc
@@ -8,10 +8,10 @@ #include "base/android/jni_string.h" #include "base/callback.h" +#include "chrome/android/chrome_jni_headers/ServiceTabLauncher_jni.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/web_contents.h" -#include "jni/ServiceTabLauncher_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/servicification_background_service_jni.cc b/chrome/browser/android/servicification_background_service_jni.cc index d9f075b..ab7f7e1 100644 --- a/chrome/browser/android/servicification_background_service_jni.cc +++ b/chrome/browser/android/servicification_background_service_jni.cc
@@ -11,8 +11,8 @@ #include "base/files/memory_mapped_file.h" #include "base/metrics/persistent_histogram_allocator.h" #include "base/system/sys_info.h" +#include "chrome/android/test_support_jni_headers/ServicificationBackgroundService_jni.h" #include "components/metrics/persistent_system_profile.h" -#include "jni/ServicificationBackgroundService_jni.h" #include "third_party/metrics_proto/system_profile.pb.h" // Verifies that the memory-mapped file for persistent histograms data exists
diff --git a/chrome/browser/android/sessions/session_tab_helper_android.cc b/chrome/browser/android/sessions/session_tab_helper_android.cc index 3950bff..8edf06c 100644 --- a/chrome/browser/android/sessions/session_tab_helper_android.cc +++ b/chrome/browser/android/sessions/session_tab_helper_android.cc
@@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/SessionTabHelper_jni.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "content/public/browser/web_contents.h" -#include "jni/SessionTabHelper_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc index ec24eeb..5eccb3af 100644 --- a/chrome/browser/android/shortcut_helper.cc +++ b/chrome/browser/android/shortcut_helper.cc
@@ -18,6 +18,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/threading/thread_restrictions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/ShortcutHelper_jni.h" #include "chrome/browser/android/color_helpers.h" #include "chrome/browser/android/webapk/chrome_webapk_host.h" #include "chrome/browser/android/webapk/webapk_install_service.h" @@ -26,7 +27,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/manifest_icon_downloader.h" #include "content/public/browser/web_contents.h" -#include "jni/ShortcutHelper_jni.h" #include "third_party/blink/public/common/manifest/manifest.h" #include "third_party/blink/public/common/manifest/manifest_icon_selector.h" #include "third_party/skia/include/core/SkColor.h"
diff --git a/chrome/browser/android/signin/signin_investigator_android.cc b/chrome/browser/android/signin/signin_investigator_android.cc index 6618fc9..f670a389 100644 --- a/chrome/browser/android/signin/signin_investigator_android.cc +++ b/chrome/browser/android/signin/signin_investigator_android.cc
@@ -6,12 +6,12 @@ #include "base/android/jni_string.h" #include "base/optional.h" +#include "chrome/android/chrome_jni_headers/SigninInvestigator_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/investigator_dependency_provider.h" #include "components/signin/core/browser/account_info.h" -#include "jni/SigninInvestigator_jni.h" #include "services/identity/public/cpp/identity_manager.h" using base::android::ConvertJavaStringToUTF8;
diff --git a/chrome/browser/android/signin/signin_manager_android.cc b/chrome/browser/android/signin/signin_manager_android.cc index ed022b69..55056a93 100644 --- a/chrome/browser/android/signin/signin_manager_android.cc +++ b/chrome/browser/android/signin/signin_manager_android.cc
@@ -17,6 +17,7 @@ #include "base/memory/ref_counted.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/SigninManager_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" @@ -37,7 +38,6 @@ #include "content/public/browser/storage_partition.h" #include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_constants.h" -#include "jni/SigninManager_jni.h" #include "services/identity/public/cpp/primary_account_mutator.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/signin/signin_promo_util_android.cc b/chrome/browser/android/signin/signin_promo_util_android.cc index 3e357f56..6d22830 100644 --- a/chrome/browser/android/signin/signin_promo_util_android.cc +++ b/chrome/browser/android/signin/signin_promo_util_android.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/signin/signin_promo_util_android.h" #include "base/android/jni_android.h" -#include "jni/SigninPromoUtil_jni.h" +#include "chrome/android/chrome_jni_headers/SigninPromoUtil_jni.h" #include "ui/android/window_android.h" namespace chrome {
diff --git a/chrome/browser/android/signin/signin_utils.cc b/chrome/browser/android/signin/signin_utils.cc index e5ede463..b62b6ab 100644 --- a/chrome/browser/android/signin/signin_utils.cc +++ b/chrome/browser/android/signin/signin_utils.cc
@@ -7,10 +7,10 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/SigninUtils_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_metrics.h" -#include "jni/SigninUtils_jni.h" #include "ui/android/window_android.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/signin/unified_consent_service_bridge.cc b/chrome/browser/android/signin/unified_consent_service_bridge.cc index 85d016a..8998abc0 100644 --- a/chrome/browser/android/signin/unified_consent_service_bridge.cc +++ b/chrome/browser/android/signin/unified_consent_service_bridge.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/UnifiedConsentServiceBridge_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/sync/profile_sync_service_factory.h" @@ -11,7 +12,6 @@ #include "components/sync/driver/sync_service.h" #include "components/unified_consent/pref_names.h" #include "components/unified_consent/unified_consent_service.h" -#include "jni/UnifiedConsentServiceBridge_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/ssl/mock_cert_verifier_rule_android.cc b/chrome/browser/android/ssl/mock_cert_verifier_rule_android.cc index 36ead1b..b7f5787 100644 --- a/chrome/browser/android/ssl/mock_cert_verifier_rule_android.cc +++ b/chrome/browser/android/ssl/mock_cert_verifier_rule_android.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/ssl/mock_cert_verifier_rule_android.h" #include "base/command_line.h" -#include "jni/MockCertVerifierRuleAndroid_jni.h" +#include "chrome/android/test_support_jni_headers/MockCertVerifierRuleAndroid_jni.h" jlong JNI_MockCertVerifierRuleAndroid_Init(JNIEnv* env, jint result) { return reinterpret_cast<intptr_t>(new MockCertVerifierRuleAndroid(result));
diff --git a/chrome/browser/android/startup_bridge.cc b/chrome/browser/android/startup_bridge.cc index 718db043..12af6b0 100644 --- a/chrome/browser/android/startup_bridge.cc +++ b/chrome/browser/android/startup_bridge.cc
@@ -8,8 +8,8 @@ #include "base/android/jni_android.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/NativeStartupBridge_jni.h" #include "chrome/browser/browser_process.h" -#include "jni/NativeStartupBridge_jni.h" namespace android_startup {
diff --git a/chrome/browser/android/subresource_filter/test_subresource_filter_publisher.cc b/chrome/browser/android/subresource_filter/test_subresource_filter_publisher.cc index 35f346e2b..c0d2018 100644 --- a/chrome/browser/android/subresource_filter/test_subresource_filter_publisher.cc +++ b/chrome/browser/android/subresource_filter/test_subresource_filter_publisher.cc
@@ -19,11 +19,11 @@ #include "base/files/scoped_temp_dir.h" #include "base/numerics/safe_conversions.h" #include "base/threading/thread_restrictions.h" +#include "chrome/android/chrome_jni_headers/TestSubresourceFilterPublisher_jni.h" #include "chrome/browser/browser_process.h" #include "components/subresource_filter/content/browser/ruleset_service.h" #include "components/subresource_filter/core/common/unindexed_ruleset.h" #include "content/public/browser/browser_thread.h" -#include "jni/TestSubresourceFilterPublisher_jni.h" #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h" // TODO(csharrison): This whole file is a hack, because Android cannot use
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc index 5fc58e87..1d37311 100644 --- a/chrome/browser/android/tab_android.cc +++ b/chrome/browser/android/tab_android.cc
@@ -13,6 +13,7 @@ #include "base/metrics/user_metrics.h" #include "base/trace_event/trace_event.h" #include "cc/layers/layer.h" +#include "chrome/android/chrome_jni_headers/Tab_jni.h" #include "chrome/browser/android/background_tab_manager.h" #include "chrome/browser/android/compositor/tab_content_manager.h" #include "chrome/browser/android/metrics/uma_utils.h" @@ -63,7 +64,6 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_user_data.h" #include "content/public/common/resource_request_body_android.h" -#include "jni/Tab_jni.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/android/tab_browser_controls_state.cc b/chrome/browser/android/tab_browser_controls_state.cc index 0e15fede..d52e2695 100644 --- a/chrome/browser/android/tab_browser_controls_state.cc +++ b/chrome/browser/android/tab_browser_controls_state.cc
@@ -4,12 +4,12 @@ #include "chrome/browser/android/tab_browser_controls_state.h" +#include "chrome/android/chrome_jni_headers/TabBrowserControlsState_jni.h" #include "chrome/common/chrome_render_frame.mojom.h" #include "content/public/browser/interstitial_page.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/browser_controls_state.h" -#include "jni/TabBrowserControlsState_jni.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/tab_favicon.cc b/chrome/browser/android/tab_favicon.cc index f800f58..3489223 100644 --- a/chrome/browser/android/tab_favicon.cc +++ b/chrome/browser/android/tab_favicon.cc
@@ -4,9 +4,9 @@ #include "chrome/browser/android/tab_favicon.h" +#include "chrome/android/chrome_jni_headers/TabFavicon_jni.h" #include "components/favicon/content/content_favicon_driver.h" #include "content/public/browser/web_contents.h" -#include "jni/TabFavicon_jni.h" #include "skia/ext/image_operations.h" #include "ui/display/display.h" #include "ui/display/screen.h"
diff --git a/chrome/browser/android/tab_printer.cc b/chrome/browser/android/tab_printer.cc index 486ad9e..a1095f4 100644 --- a/chrome/browser/android/tab_printer.cc +++ b/chrome/browser/android/tab_printer.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/android/tab_printer.h" +#include "chrome/android/chrome_jni_headers/TabPrinter_jni.h" #include "chrome/browser/printing/print_view_manager_basic.h" #include "chrome/browser/printing/print_view_manager_common.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" -#include "jni/TabPrinter_jni.h" using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/tab_state.cc b/chrome/browser/android/tab_state.cc index 2f3df18f..69e1ca54 100644 --- a/chrome/browser/android/tab_state.cc +++ b/chrome/browser/android/tab_state.cc
@@ -15,6 +15,7 @@ #include "base/android/jni_string.h" #include "base/logging.h" #include "base/pickle.h" +#include "chrome/android/chrome_jni_headers/TabState_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -25,7 +26,6 @@ #include "content/public/browser/navigation_entry.h" #include "content/public/browser/restore_type.h" #include "content/public/browser/web_contents.h" -#include "jni/TabState_jni.h" using base::android::ConvertUTF16ToJavaString; using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/tab_web_contents_delegate_android.cc b/chrome/browser/android/tab_web_contents_delegate_android.cc index a2b977c1..6906071b 100644 --- a/chrome/browser/android/tab_web_contents_delegate_android.cc +++ b/chrome/browser/android/tab_web_contents_delegate_android.cc
@@ -15,6 +15,7 @@ #include "base/metrics/histogram_macros.h" #include "base/optional.h" #include "base/rand_util.h" +#include "chrome/android/chrome_jni_headers/TabWebContentsDelegateAndroid_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/feature_utilities.h" #include "chrome/browser/android/hung_renderer_infobar_delegate.h" @@ -59,7 +60,6 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/security_style_explanations.h" #include "content/public/browser/web_contents.h" -#include "jni/TabWebContentsDelegateAndroid_jni.h" #include "third_party/blink/public/common/mediastream/media_stream_request.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h"
diff --git a/chrome/browser/android/trusted_cdn.cc b/chrome/browser/android/trusted_cdn.cc index 546ffc6..302bfc6 100644 --- a/chrome/browser/android/trusted_cdn.cc +++ b/chrome/browser/android/trusted_cdn.cc
@@ -11,13 +11,13 @@ #include "base/command_line.h" #include "base/feature_list.h" #include "base/no_destructor.h" +#include "chrome/android/chrome_jni_headers/TrustedCdn_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/offline_pages/offline_page_utils.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_switches.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" -#include "jni/TrustedCdn_jni.h" #include "url/gurl.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/android/usage_stats/notification_suspender.cc b/chrome/browser/android/usage_stats/notification_suspender.cc index 74c65098..cd32d15 100644 --- a/chrome/browser/android/usage_stats/notification_suspender.cc +++ b/chrome/browser/android/usage_stats/notification_suspender.cc
@@ -7,12 +7,12 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/NotificationSuspender_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/platform_notification_context.h" #include "content/public/browser/storage_partition.h" -#include "jni/NotificationSuspender_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/android/usage_stats/usage_stats_bridge.cc b/chrome/browser/android/usage_stats/usage_stats_bridge.cc index 5835e45..282ee71 100644 --- a/chrome/browser/android/usage_stats/usage_stats_bridge.cc +++ b/chrome/browser/android/usage_stats/usage_stats_bridge.cc
@@ -10,6 +10,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/UsageStatsBridge_jni.h" #include "chrome/browser/android/usage_stats/usage_stats_database.h" #include "chrome/browser/android/usage_stats/website_event.pb.h" #include "chrome/browser/history/history_service_factory.h" @@ -18,7 +19,6 @@ #include "chrome/common/pref_names.h" #include "components/history/core/browser/history_service.h" #include "components/pref_registry/pref_registry_syncable.h" -#include "jni/UsageStatsBridge_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/util/url_utilities.cc b/chrome/browser/android/util/url_utilities.cc index aa9be11..337c229e 100644 --- a/chrome/browser/android/util/url_utilities.cc +++ b/chrome/browser/android/util/url_utilities.cc
@@ -7,8 +7,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/strings/string_util.h" +#include "chrome/lib/util/public/android/jni_headers/UrlUtilities_jni.h" #include "components/google/core/common/google_util.h" -#include "jni/UrlUtilities_jni.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/vr/BUILD.gn b/chrome/browser/android/vr/BUILD.gn index f40b4b4..7497ce23 100644 --- a/chrome/browser/android/vr/BUILD.gn +++ b/chrome/browser/android/vr/BUILD.gn
@@ -222,7 +222,6 @@ sources = [ "//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java", ] - jni_package = "vr" } }
diff --git a/chrome/browser/android/vr/DEPS b/chrome/browser/android/vr/DEPS index 23b174d..36776e6 100644 --- a/chrome/browser/android/vr/DEPS +++ b/chrome/browser/android/vr/DEPS
@@ -2,6 +2,7 @@ "+cc/base", "+cc/layers", "+cc/test", + "+chrome/android/features/vr/jni_headers", "+device/vr", "+services/metrics/public/cpp/ukm_builders.h", "+third_party/gvr-android-keyboard/src",
diff --git a/chrome/browser/android/vr/android_ui_gesture_target.cc b/chrome/browser/android/vr/android_ui_gesture_target.cc index 16c92c1..94a47ea8 100644 --- a/chrome/browser/android/vr/android_ui_gesture_target.cc +++ b/chrome/browser/android/vr/android_ui_gesture_target.cc
@@ -6,8 +6,8 @@ #include <cmath> +#include "chrome/android/features/vr/jni_headers/AndroidUiGestureTarget_jni.h" #include "chrome/browser/vr/input_event.h" -#include "jni/AndroidUiGestureTarget_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/android/vr/android_vsync_helper.cc b/chrome/browser/android/vr/android_vsync_helper.cc index 3eca7ae..1742e5b 100644 --- a/chrome/browser/android/vr/android_vsync_helper.cc +++ b/chrome/browser/android/vr/android_vsync_helper.cc
@@ -8,7 +8,7 @@ #include "base/android/jni_android.h" #include "base/logging.h" -#include "jni/AndroidVSyncHelper_jni.h" +#include "chrome/android/features/vr/jni_headers/AndroidVSyncHelper_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/vr/arcore_device/arcore_java_utils.cc b/chrome/browser/android/vr/arcore_device/arcore_java_utils.cc index dee136f..ed7fe69 100644 --- a/chrome/browser/android/vr/arcore_device/arcore_java_utils.cc +++ b/chrome/browser/android/vr/arcore_device/arcore_java_utils.cc
@@ -6,12 +6,12 @@ #include "base/android/jni_string.h" #include "chrome/browser/android/tab_android.h" +#include "chrome/browser/android/vr/ar_jni_headers/ArCoreJavaUtils_jni.h" #include "chrome/browser/android/vr/arcore_device/arcore_device_provider.h" #include "chrome/browser/android/vr/arcore_device/arcore_shim.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "device/vr/android/arcore/arcore_device_provider_factory.h" -#include "jni/ArCoreJavaUtils_jni.h" using base::android::AttachCurrentThread; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/vr/gvr_consent_helper_impl.cc b/chrome/browser/android/vr/gvr_consent_helper_impl.cc index 23dfa84..e0b99d7 100644 --- a/chrome/browser/android/vr/gvr_consent_helper_impl.cc +++ b/chrome/browser/android/vr/gvr_consent_helper_impl.cc
@@ -9,10 +9,10 @@ #include "base/android/jni_string.h" #include "base/callback.h" #include "base/macros.h" +#include "chrome/android/features/vr/jni_headers/VrConsentDialog_jni.h" #include "chrome/browser/android/tab_android.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" -#include "jni/VrConsentDialog_jni.h" using base::android::AttachCurrentThread; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/vr/gvr_keyboard_shim.cc b/chrome/browser/android/vr/gvr_keyboard_shim.cc index 2e29ce5b..efa41d21 100644 --- a/chrome/browser/android/vr/gvr_keyboard_shim.cc +++ b/chrome/browser/android/vr/gvr_keyboard_shim.cc
@@ -12,7 +12,7 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/logging.h" -#include "jni/GvrKeyboardLoaderClient_jni.h" +#include "chrome/android/features/vr/jni_headers/GvrKeyboardLoaderClient_jni.h" namespace {
diff --git a/chrome/browser/android/vr/vr_core_info.cc b/chrome/browser/android/vr/vr_core_info.cc index 43ffa84d..d402ea2 100644 --- a/chrome/browser/android/vr/vr_core_info.cc +++ b/chrome/browser/android/vr/vr_core_info.cc
@@ -5,7 +5,7 @@ #include "chrome/browser/android/vr/vr_core_info.h" #include "base/android/jni_android.h" -#include "jni/VrCoreInfo_jni.h" +#include "chrome/android/features/vr/jni_headers/VrCoreInfo_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/vr/vr_input_connection.cc b/chrome/browser/android/vr/vr_input_connection.cc index b4d806fc..bb729949 100644 --- a/chrome/browser/android/vr/vr_input_connection.cc +++ b/chrome/browser/android/vr/vr_input_connection.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_string.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/features/vr/jni_headers/TextEditAction_jni.h" +#include "chrome/android/features/vr/jni_headers/VrInputConnection_jni.h" #include "chrome/browser/vr/model/text_input_info.h" #include "content/public/browser/web_contents.h" -#include "jni/TextEditAction_jni.h" -#include "jni/VrInputConnection_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/android/vr/vr_module_provider.cc b/chrome/browser/android/vr/vr_module_provider.cc index f958649..623e897 100644 --- a/chrome/browser/android/vr/vr_module_provider.cc +++ b/chrome/browser/android/vr/vr_module_provider.cc
@@ -7,12 +7,12 @@ #include <memory> #include <utility> +#include "chrome/android/features/vr/jni_headers/VrModuleProvider_jni.h" #include "chrome/browser/android/vr/gvr_consent_helper_impl.h" #include "chrome/browser/android/vr/register_jni.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "device/vr/android/gvr/vr_module_delegate.h" -#include "jni/VrModuleProvider_jni.h" namespace vr {
diff --git a/chrome/browser/android/vr/vr_shell.cc b/chrome/browser/android/vr/vr_shell.cc index 992cc781..7353577 100644 --- a/chrome/browser/android/vr/vr_shell.cc +++ b/chrome/browser/android/vr/vr_shell.cc
@@ -21,6 +21,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "base/values.h" +#include "chrome/android/features/vr/jni_headers/VrShell_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/vr/android_ui_gesture_target.h" #include "chrome/browser/android/vr/autocomplete_controller.h" @@ -68,7 +69,6 @@ #include "device/vr/android/gvr/gvr_device.h" #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" #include "gpu/command_buffer/common/mailbox.h" -#include "jni/VrShell_jni.h" #include "services/device/public/mojom/constants.mojom.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/service_manager/public/cpp/connector.h"
diff --git a/chrome/browser/android/vr/vr_shell_delegate.cc b/chrome/browser/android/vr/vr_shell_delegate.cc index cc526ae5..973dcd6 100644 --- a/chrome/browser/android/vr/vr_shell_delegate.cc +++ b/chrome/browser/android/vr/vr_shell_delegate.cc
@@ -8,6 +8,7 @@ #include "base/android/jni_android.h" #include "base/bind.h" +#include "chrome/android/features/vr/jni_headers/VrShellDelegate_jni.h" #include "chrome/browser/android/vr/arcore_device/arcore_device_provider.h" #include "chrome/browser/android/vr/metrics_util_android.h" #include "chrome/browser/android/vr/vr_shell.h" @@ -24,7 +25,6 @@ #include "device/vr/buildflags/buildflags.h" #include "device/vr/public/cpp/session_mode.h" #include "device/vr/public/mojom/vr_service.mojom.h" -#include "jni/VrShellDelegate_jni.h" #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/android/warmup_manager.cc b/chrome/browser/android/warmup_manager.cc index ba43a27..1f6a5d982 100644 --- a/chrome/browser/android/warmup_manager.cc +++ b/chrome/browser/android/warmup_manager.cc
@@ -4,12 +4,12 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/WarmupManager_jni.h" #include "chrome/browser/predictors/loading_predictor.h" #include "chrome/browser/predictors/loading_predictor_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/browser/render_process_host.h" -#include "jni/WarmupManager_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/web_contents_factory.cc b/chrome/browser/android/web_contents_factory.cc index e68ab2c..db2de11 100644 --- a/chrome/browser/android/web_contents_factory.cc +++ b/chrome/browser/android/web_contents_factory.cc
@@ -3,12 +3,12 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/WebContentsFactory_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/web_contents.h" -#include "jni/WebContentsFactory_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/android/webapk/webapk_install_service.cc b/chrome/browser/android/webapk/webapk_install_service.cc index dff0770..9c4134c 100644 --- a/chrome/browser/android/webapk/webapk_install_service.cc +++ b/chrome/browser/android/webapk/webapk_install_service.cc
@@ -10,11 +10,11 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/files/file_path.h" +#include "chrome/android/chrome_jni_headers/WebApkInstallService_jni.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/shortcut_info.h" #include "chrome/browser/android/webapk/webapk_install_service_factory.h" #include "chrome/browser/android/webapk/webapk_installer.h" -#include "jni/WebApkInstallService_jni.h" #include "ui/gfx/android/java_bitmap.h" // static
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc index 9e8119e..e7fb55d 100644 --- a/chrome/browser/android/webapk/webapk_installer.cc +++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -26,6 +26,7 @@ #include "base/task_runner_util.h" #include "base/threading/scoped_blocking_call.h" #include "base/timer/elapsed_timer.h" +#include "chrome/android/chrome_jni_headers/WebApkInstaller_jni.h" #include "chrome/browser/android/color_helpers.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/webapk/chrome_webapk_host.h" @@ -41,7 +42,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" #include "content/public/browser/storage_partition.h" -#include "jni/WebApkInstaller_jni.h" #include "net/base/load_flags.h" #include "net/http/http_status_code.h" #include "net/traffic_annotation/network_traffic_annotation.h"
diff --git a/chrome/browser/android/webapk/webapk_post_share_target_navigator.cc b/chrome/browser/android/webapk/webapk_post_share_target_navigator.cc index bd6bcbb..6398a151 100644 --- a/chrome/browser/android/webapk/webapk_post_share_target_navigator.cc +++ b/chrome/browser/android/webapk/webapk_post_share_target_navigator.cc
@@ -12,8 +12,8 @@ #include "base/android/jni_string.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversion_utils.h" +#include "chrome/android/chrome_jni_headers/WebApkPostShareTargetNavigator_jni.h" #include "content/public/browser/web_contents.h" -#include "jni/WebApkPostShareTargetNavigator_jni.h" #include "net/base/escape.h" #include "net/base/mime_util.h" #include "ui/base/window_open_disposition.h"
diff --git a/chrome/browser/android/webapk/webapk_update_data_fetcher.cc b/chrome/browser/android/webapk/webapk_update_data_fetcher.cc index 7bd52ac9f..ea51b1c 100644 --- a/chrome/browser/android/webapk/webapk_update_data_fetcher.cc +++ b/chrome/browser/android/webapk/webapk_update_data_fetcher.cc
@@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/WebApkUpdateDataFetcher_jni.h" #include "chrome/browser/android/color_helpers.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/webapk/webapk_icon_hasher.h" @@ -21,7 +22,6 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" -#include "jni/WebApkUpdateDataFetcher_jni.h" #include "third_party/blink/public/common/manifest/manifest.h" #include "third_party/smhasher/src/MurmurHash2.h" #include "ui/gfx/android/java_bitmap.h"
diff --git a/chrome/browser/android/webapk/webapk_update_manager.cc b/chrome/browser/android/webapk/webapk_update_manager.cc index 9772c2b..d9986a5b0 100644 --- a/chrome/browser/android/webapk/webapk_update_manager.cc +++ b/chrome/browser/android/webapk/webapk_update_manager.cc
@@ -14,6 +14,7 @@ #include "base/files/file_path.h" #include "base/strings/string16.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/WebApkUpdateManager_jni.h" #include "chrome/browser/android/color_helpers.h" #include "chrome/browser/android/shortcut_info.h" #include "chrome/browser/android/webapk/webapk_install_service.h" @@ -21,7 +22,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/public/browser/browser_thread.h" -#include "jni/WebApkUpdateManager_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h" #include "url/gurl.h"
diff --git a/chrome/browser/android/webapps/add_to_homescreen_manager.cc b/chrome/browser/android/webapps/add_to_homescreen_manager.cc index c064cd66..b882493 100644 --- a/chrome/browser/android/webapps/add_to_homescreen_manager.cc +++ b/chrome/browser/android/webapps/add_to_homescreen_manager.cc
@@ -9,6 +9,7 @@ #include "base/location.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/AddToHomescreenManager_jni.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/webapk/webapk_install_service.h" #include "chrome/browser/banners/app_banner_manager_android.h" @@ -19,7 +20,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" -#include "jni/AddToHomescreenManager_jni.h" #include "mojo/public/cpp/bindings/interface_request.h" #include "services/service_manager/public/cpp/interface_provider.h" #include "third_party/blink/public/mojom/installation/installation.mojom.h"
diff --git a/chrome/browser/android/webapps/webapp_registry.cc b/chrome/browser/android/webapps/webapp_registry.cc index bb909c8..f567b03c 100644 --- a/chrome/browser/android/webapps/webapp_registry.cc +++ b/chrome/browser/android/webapps/webapp_registry.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/android/webapps/webapp_registry.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/WebappRegistry_jni.h" #include "chrome/browser/android/browsing_data/url_filter_bridge.h" -#include "jni/WebappRegistry_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/android/widget/thumbnail_generator.cc b/chrome/browser/android/widget/thumbnail_generator.cc index 55c4b58..bd6db3db 100644 --- a/chrome/browser/android/widget/thumbnail_generator.cc +++ b/chrome/browser/android/widget/thumbnail_generator.cc
@@ -9,10 +9,10 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/threading/thread_restrictions.h" +#include "chrome/android/chrome_jni_headers/ThumbnailGenerator_jni.h" #include "chrome/browser/android/download/download_media_parser.h" #include "chrome/browser/download/thumbnail_util.h" #include "content/public/browser/browser_thread.h" -#include "jni/ThumbnailGenerator_jni.h" #include "ui/gfx/android/java_bitmap.h" class SkBitmap;
diff --git a/chrome/browser/autofill/address_accessory_controller_impl.cc b/chrome/browser/autofill/address_accessory_controller_impl.cc index 8d528d18..debb8e0 100644 --- a/chrome/browser/autofill/address_accessory_controller_impl.cc +++ b/chrome/browser/autofill/address_accessory_controller_impl.cc
@@ -137,8 +137,7 @@ if (profiles.empty()) title_or_empty_message = l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SHEET_EMPTY_MESSAGE); - GetManualFillingController()->RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, + GetManualFillingController()->RefreshSuggestions( autofill::CreateAccessorySheetData( autofill::AccessoryTabType::ADDRESSES, title_or_empty_message, UserInfosForProfiles(profiles), CreateManageAddressesFooter()));
diff --git a/chrome/browser/autofill/address_accessory_controller_impl_unittest.cc b/chrome/browser/autofill/address_accessory_controller_impl_unittest.cc index cf562af..bbf7e26 100644 --- a/chrome/browser/autofill/address_accessory_controller_impl_unittest.cc +++ b/chrome/browser/autofill/address_accessory_controller_impl_unittest.cc
@@ -105,10 +105,8 @@ personal_data_manager()->AddProfile(canadian); AccessorySheetData result(AccessoryTabType::PASSWORDS, base::string16()); - EXPECT_CALL(mock_manual_filling_controller_, - RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, _)) - .WillOnce(SaveArg<1>(&result)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)) + .WillOnce(SaveArg<0>(&result)); controller()->RefreshSuggestions(); @@ -141,10 +139,8 @@ TEST_F(AddressAccessoryControllerTest, ProvidesEmptySuggestionsMessage) { AccessorySheetData result(AccessoryTabType::PASSWORDS, base::string16()); - EXPECT_CALL(mock_manual_filling_controller_, - RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, _)) - .WillOnce(SaveArg<1>(&result)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)) + .WillOnce(SaveArg<0>(&result)); controller()->RefreshSuggestions(); @@ -154,10 +150,8 @@ TEST_F(AddressAccessoryControllerTest, TriggersRefreshWhenDataChanges) { AccessorySheetData result(AccessoryTabType::PASSWORDS, base::string16()); - EXPECT_CALL(mock_manual_filling_controller_, - RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, _)) - .WillRepeatedly(SaveArg<1>(&result)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)) + .WillRepeatedly(SaveArg<0>(&result)); // A refresh without data stores an empty sheet and registers an observer. controller()->RefreshSuggestions();
diff --git a/chrome/browser/autofill/android/personal_data_manager_android.cc b/chrome/browser/autofill/android/personal_data_manager_android.cc index b1d2293..91fc1c3 100644 --- a/chrome/browser/autofill/android/personal_data_manager_android.cc +++ b/chrome/browser/autofill/android/personal_data_manager_android.cc
@@ -17,6 +17,7 @@ #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/PersonalDataManager_jni.h" #include "chrome/browser/android/preferences/prefs.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/autofill/address_normalizer_factory.h" @@ -44,7 +45,6 @@ #include "components/autofill/core/common/autofill_switches.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_contents.h" -#include "jni/PersonalDataManager_jni.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "third_party/libaddressinput/chromium/chrome_metadata_source.h" #include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
diff --git a/chrome/browser/autofill/android/phone_number_util_android.cc b/chrome/browser/autofill/android/phone_number_util_android.cc index 406925e..f768c0b 100644 --- a/chrome/browser/autofill/android/phone_number_util_android.cc +++ b/chrome/browser/autofill/android/phone_number_util_android.cc
@@ -4,9 +4,9 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/PhoneNumberUtil_jni.h" #include "chrome/browser/browser_process.h" #include "components/autofill/core/browser/geo/autofill_country.h" -#include "jni/PhoneNumberUtil_jni.h" #include "third_party/libphonenumber/phonenumber_api.h" namespace autofill {
diff --git a/chrome/browser/autofill/credit_card_accessory_controller_impl.cc b/chrome/browser/autofill/credit_card_accessory_controller_impl.cc index c9ff538..3a9ea01 100644 --- a/chrome/browser/autofill/credit_card_accessory_controller_impl.cc +++ b/chrome/browser/autofill/credit_card_accessory_controller_impl.cc
@@ -114,8 +114,7 @@ AccessoryAction::MANAGE_CREDIT_CARDS)}; bool has_suggestions = !info_to_add.empty(); - GetManualFillingController()->RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, + GetManualFillingController()->RefreshSuggestions( autofill::CreateAccessorySheetData( AccessoryTabType::CREDIT_CARDS, GetTitle(has_suggestions), std::move(info_to_add), std::move(footer_commands)));
diff --git a/chrome/browser/autofill/credit_card_accessory_controller_impl_unittest.cc b/chrome/browser/autofill/credit_card_accessory_controller_impl_unittest.cc index cccd490..3ec1e78d 100644 --- a/chrome/browser/autofill/credit_card_accessory_controller_impl_unittest.cc +++ b/chrome/browser/autofill/credit_card_accessory_controller_impl_unittest.cc
@@ -70,10 +70,8 @@ autofill::AccessorySheetData result(autofill::AccessoryTabType::PASSWORDS, base::string16()); - EXPECT_CALL(mock_mf_controller_, - RefreshSuggestionsForField( - mojom::FocusedFieldType::kFillableTextField, _)) - .WillOnce(SaveArg<1>(&result)); + EXPECT_CALL(mock_mf_controller_, RefreshSuggestions(_)) + .WillOnce(SaveArg<0>(&result)); auto* cc_controller = controller(); ASSERT_TRUE(cc_controller);
diff --git a/chrome/browser/autofill/manual_filling_controller.h b/chrome/browser/autofill/manual_filling_controller.h index 7218225..7023fcd 100644 --- a/chrome/browser/autofill/manual_filling_controller.h +++ b/chrome/browser/autofill/manual_filling_controller.h
@@ -42,7 +42,12 @@ public: // The controller checks if at least one of these sources needs the accessory // to be displayed. - enum class FillingSource { AUTOFILL, PASSWORD_FALLBACKS, ADDRESS_FALLBACKS }; + enum class FillingSource { + AUTOFILL, + PASSWORD_FALLBACKS, + CREDIT_CARD_FALLBACKS, + ADDRESS_FALLBACKS + }; ManualFillingController() = default; virtual ~ManualFillingController() = default; @@ -58,33 +63,33 @@ // Methods called by type-specific controllers. // -------------------------------------------- - // Forwards |accessory_sheet_data| to the view provided by a type-specific - // controller to be shown on the accessory sheet. - virtual void RefreshSuggestionsForField( - autofill::mojom::FocusedFieldType focused_field_type, + // Depending on the type of the given |accessory_sheet_data|, this updates a + // accessory sheet. Controllers to handle touch events are determined by the + // type of the sheet. + virtual void RefreshSuggestions( const autofill::AccessorySheetData& accessory_sheet_data) = 0; + // Notifies that the focused field changed which allows the controller to + // update the UI visibility. + virtual void NotifyFocusedInputChanged( + autofill::mojom::FocusedFieldType focused_field_type) = 0; + // Completes a filling attempt by recording metrics, giving feedback to the // user and dismissing the accessory sheet. virtual void OnFilledIntoFocusedField( autofill::mojom::FillingStatus status) = 0; - // Requests to show the accessory bar. The accessory will only be shown - // when the keyboard becomes visible. - // TODO(crbug.com/965478): Rename method to reflect latest logic changes. - virtual void ShowWhenKeyboardIsVisible(FillingSource source) = 0; + // Reports for a source whether it provides suggestions or just default + // options. The controller then updates the UI visibility accordingly. + virtual void UpdateSourceAvailability(FillingSource source, + bool has_suggestions) = 0; // Requests to show the touch to fill sheet. virtual void ShowTouchToFillSheet( const autofill::AccessorySheetData& data) = 0; - // This signals that the accessory data corresponding to |source| doesn't - // need to be shown anymore. If no FillingSource needs to be shown, the - // accessory sheet and bar will be hidden. - virtual void DeactivateFillingSource(FillingSource source) = 0; - - // Requests to hide the accessory. This hides both the accessory sheet - // (if open) and the accessory bar. + // Explicitly hides all manual filling UI without checking any filling source. + // E.g. after autofilling suggestions, or generating a password. virtual void Hide() = 0; // Notifies the view that automatic password generation status changed.
diff --git a/chrome/browser/autofill/manual_filling_controller_impl.cc b/chrome/browser/autofill/manual_filling_controller_impl.cc index 8c36672..0fe14a4c 100644 --- a/chrome/browser/autofill/manual_filling_controller_impl.cc +++ b/chrome/browser/autofill/manual_filling_controller_impl.cc
@@ -24,6 +24,30 @@ using autofill::mojom::FillingStatus; using autofill::mojom::FocusedFieldType; +using FillingSource = ManualFillingController::FillingSource; + +namespace { + +FillingSource GetSourceForTab(const AccessorySheetData& accessory_sheet) { + switch (accessory_sheet.get_sheet_type()) { + case AccessoryTabType::PASSWORDS: + return FillingSource::PASSWORD_FALLBACKS; + case AccessoryTabType::CREDIT_CARDS: + return FillingSource::CREDIT_CARD_FALLBACKS; + case AccessoryTabType::ADDRESSES: + return FillingSource::ADDRESS_FALLBACKS; + case AccessoryTabType::TOUCH_TO_FILL: + case AccessoryTabType::ALL: + case AccessoryTabType::COUNT: + break; // Intentional failure. + } + NOTREACHED() << "Cannot determine filling source for " + << accessory_sheet.get_sheet_type(); + return FillingSource::PASSWORD_FALLBACKS; +} + +} // namespace + ManualFillingControllerImpl::~ManualFillingControllerImpl() = default; // static @@ -72,33 +96,44 @@ view_->SwapSheetWithKeyboard(); } -void ManualFillingControllerImpl::RefreshSuggestionsForField( - FocusedFieldType focused_field_type, +void ManualFillingControllerImpl::RefreshSuggestions( const AccessorySheetData& accessory_sheet_data) { view_->OnItemsAvailable(accessory_sheet_data); + UpdateSourceAvailability(GetSourceForTab(accessory_sheet_data), + !accessory_sheet_data.user_info_list().empty()); +} - // TODO(crbug.com/965478): Refresh visibility for non-PWDs in V2. - if (accessory_sheet_data.get_sheet_type() != AccessoryTabType::PASSWORDS) - return; - - // TODO(crbug.com/905669): The decision for showing the sheet or not will need - // to take into account if Autofill suggestions are also available. - if (autofill::IsFillable(focused_field_type)) +void ManualFillingControllerImpl::NotifyFocusedInputChanged( + autofill::mojom::FocusedFieldType focused_field_type) { + focused_field_type_ = focused_field_type; + // Whenever the focus changes, reset the accessory. + if (ShouldShowAccessory()) view_->SwapSheetWithKeyboard(); else view_->CloseAccessorySheet(); + + UpdateVisibility(); } -void ManualFillingControllerImpl::ShowWhenKeyboardIsVisible( - FillingSource source) { +void ManualFillingControllerImpl::UpdateSourceAvailability( + FillingSource source, + bool has_suggestions) { if (source == FillingSource::AUTOFILL && !base::FeatureList::IsEnabled( autofill::features::kAutofillKeyboardAccessory)) { // Ignore autofill signals if the feature is disabled. return; } - visible_sources_.insert(source); - view_->ShowWhenKeyboardIsVisible(); + + if (has_suggestions == available_sources_.contains(source)) + return; + + if (has_suggestions) + available_sources_.insert(source); + else + available_sources_.erase(source); + + UpdateVisibility(); } void ManualFillingControllerImpl::ShowTouchToFillSheet( @@ -107,19 +142,6 @@ view_->ShowTouchToFillSheet(); } -void ManualFillingControllerImpl::DeactivateFillingSource( - FillingSource source) { - if (source == FillingSource::AUTOFILL && - !base::FeatureList::IsEnabled( - autofill::features::kAutofillKeyboardAccessory)) { - // Ignore autofill signals if the feature is disabled. - return; - } - visible_sources_.erase(source); - if (visible_sources_.empty()) - view_->Hide(); -} - void ManualFillingControllerImpl::Hide() { view_->Hide(); } @@ -190,6 +212,49 @@ address_controller_(std::move(address_controller)), view_(std::move(view)) {} +bool ManualFillingControllerImpl::ShouldShowAccessory() const { + // If we only provide password fallbacks (== accessory V1), show them for + // passwords and username fields only. + if (!base::FeatureList::IsEnabled( + autofill::features::kAutofillKeyboardAccessory) && + !base::FeatureList::IsEnabled( + autofill::features::kAutofillManualFallbackAndroid)) { + return focused_field_type_ == FocusedFieldType::kFillablePasswordField || + (focused_field_type_ == FocusedFieldType::kFillableUsernameField && + available_sources_.contains(FillingSource::PASSWORD_FALLBACKS)); + } + switch (focused_field_type_) { + // Always show on password fields to provide management and generation. + case FocusedFieldType::kFillablePasswordField: + return true; + + // If there are suggestions, show on usual form fields. + case FocusedFieldType::kFillableUsernameField: + case FocusedFieldType::kFillableNonSearchField: + return !available_sources_.empty(); + + // Even if there are suggestions, don't show on search fields and textareas. + case FocusedFieldType::kFillableSearchField: + case FocusedFieldType::kFillableTextArea: + return false; // TODO(https://crbug.com/965478): true on long-press. + + // Never show if the focused field is not explicitly fillable. + case FocusedFieldType::kUnfillableElement: + case FocusedFieldType::kUnknown: + return false; + } + NOTREACHED() << "Unhandled field type " << focused_field_type_; + return false; +} + +void ManualFillingControllerImpl::UpdateVisibility() { + if (ShouldShowAccessory()) { + view_->ShowWhenKeyboardIsVisible(); + } else { + view_->Hide(); + } +} + AccessoryController* ManualFillingControllerImpl::GetControllerForTab( AccessoryTabType type) { switch (type) {
diff --git a/chrome/browser/autofill/manual_filling_controller_impl.h b/chrome/browser/autofill/manual_filling_controller_impl.h index 19d0d34..fed10891 100644 --- a/chrome/browser/autofill/manual_filling_controller_impl.h +++ b/chrome/browser/autofill/manual_filling_controller_impl.h
@@ -12,6 +12,7 @@ #include "base/memory/weak_ptr.h" #include "chrome/browser/autofill/manual_filling_controller.h" #include "chrome/browser/autofill/manual_filling_view_interface.h" +#include "components/autofill/core/common/mojom/autofill_types.mojom-shared.h" #include "content/public/browser/web_contents_user_data.h" namespace autofill { @@ -29,13 +30,14 @@ ~ManualFillingControllerImpl() override; // ManualFillingController: - void RefreshSuggestionsForField( - autofill::mojom::FocusedFieldType focused_field_type, + void RefreshSuggestions( const autofill::AccessorySheetData& accessory_sheet_data) override; + void NotifyFocusedInputChanged( + autofill::mojom::FocusedFieldType focused_field_type) override; void OnFilledIntoFocusedField(autofill::mojom::FillingStatus status) override; - void ShowWhenKeyboardIsVisible(FillingSource source) override; + void UpdateSourceAvailability(FillingSource source, + bool has_suggestions) override; void ShowTouchToFillSheet(const autofill::AccessorySheetData& data) override; - void DeactivateFillingSource(FillingSource source) override; void Hide() override; void OnAutomaticGenerationStatusChanged(bool available) override; void OnFillingTriggered(autofill::AccessoryTabType type, @@ -90,6 +92,12 @@ base::WeakPtr<autofill::AddressAccessoryController> address_controller, std::unique_ptr<ManualFillingViewInterface> view); + // Returns true if the keyboard accessory needs to be shown. + bool ShouldShowAccessory() const; + + // Adjusts visibility based on focused field type and available suggestions. + void UpdateVisibility(); + // Returns the controller that is responsible for a tab of given |type|. AccessoryController* GetControllerForTab(autofill::AccessoryTabType type); @@ -101,7 +109,11 @@ content::WebContents* web_contents_; // This set contains sources to be shown to the user. - base::flat_set<FillingSource> visible_sources_; + base::flat_set<FillingSource> available_sources_; + + // Type of the last known selected field. Helps to determine UI visibility. + autofill::mojom::FocusedFieldType focused_field_type_ = + autofill::mojom::FocusedFieldType::kUnknown; // The password accessory controller object to forward view requests to. base::WeakPtr<PasswordAccessoryController> pwd_controller_;
diff --git a/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc b/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc index 5f8e4db..8adaae8 100644 --- a/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc +++ b/chrome/browser/autofill/manual_filling_controller_impl_unittest.cc
@@ -15,6 +15,7 @@ #include "base/test/scoped_feature_list.h" #include "chrome/browser/autofill/mock_address_accessory_controller.h" #include "chrome/browser/autofill/mock_manual_filling_view.h" +#include "chrome/browser/autofill/mock_password_accessory_controller.h" #include "chrome/browser/password_manager/password_accessory_controller.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "components/autofill/core/common/autofill_features.h" @@ -24,6 +25,8 @@ namespace { using autofill::AccessoryAction; +using autofill::AccessorySheetData; +using autofill::AccessoryTabType; using autofill::mojom::FillingStatus; using autofill::mojom::FocusedFieldType; using testing::_; @@ -34,27 +37,17 @@ constexpr char kExampleSite[] = "https://example.com"; -class MockPasswordAccessoryController : public PasswordAccessoryController { - public: - MOCK_METHOD2( - SavePasswordsForOrigin, - void(const std::map<base::string16, const autofill::PasswordForm*>&, - const url::Origin&)); - MOCK_METHOD1(OnFilledIntoFocusedField, void(FillingStatus)); - MOCK_METHOD2(RefreshSuggestionsForField, void(FocusedFieldType, bool)); - MOCK_METHOD1(OnGenerationRequested, void(bool)); - MOCK_METHOD0(DidNavigateMainFrame, void()); - MOCK_METHOD2(GetFavicon, - void(int, base::OnceCallback<void(const gfx::Image&)>)); - MOCK_METHOD1(OnFillingTriggered, void(const autofill::UserInfo::Field&)); - MOCK_METHOD1(OnOptionSelected, void(AccessoryAction selected_action)); -}; +AccessorySheetData empty_passwords_sheet() { + constexpr char kTitle[] = "Example title"; + return AccessorySheetData(AccessoryTabType::PASSWORDS, + base::ASCIIToUTF16(kTitle)); +} -autofill::AccessorySheetData dummy_accessory_sheet_data() { - constexpr char kExampleAccessorySheetDataTitle[] = "Example title"; - return autofill::AccessorySheetData( - autofill::AccessoryTabType::PASSWORDS, - base::ASCIIToUTF16(kExampleAccessorySheetDataTitle)); +AccessorySheetData populate_sheet(AccessoryTabType type) { + constexpr char kTitle[] = "Suggestions available!"; + return AccessorySheetData::Builder(type, base::ASCIIToUTF16(kTitle)) + .AddUserInfo() + .Build(); } } // namespace @@ -69,10 +62,24 @@ ManualFillingControllerImpl::CreateForWebContentsForTesting( web_contents(), mock_pwd_controller_.AsWeakPtr(), mock_address_controller_.AsWeakPtr(), - std::make_unique<StrictMock<MockManualFillingView>>()); + std::make_unique<NiceMock<MockManualFillingView>>()); NavigateAndCommit(GURL(kExampleSite)); } + void FocusFieldAndClearExpectations(FocusedFieldType fieldType) { + // Depending on |fieldType|, different calls can be expected. All of them + // are irrelevant during setup. + controller()->NotifyFocusedInputChanged(fieldType); + testing::Mock::VerifyAndClearExpectations(view()); + } + + void SetSuggestionsAndClearExpectations(AccessorySheetData sheet) { + // Depending on |sheet| and last set field type, different calls can be + // expected. All of them are irrelevant during setup. + controller()->RefreshSuggestions(std::move(sheet)); + testing::Mock::VerifyAndClearExpectations(view()); + } + ManualFillingControllerImpl* controller() { return ManualFillingControllerImpl::FromWebContents(web_contents()); } @@ -95,28 +102,102 @@ initial_controller); } -// TODO(fhorschig): Check for recorded metrics here or similar to this. -TEST_F(ManualFillingControllerTest, ClosesViewWhenRefreshingSuggestions) { - // Ignore Items - only the closing calls are interesting here. - EXPECT_CALL(*view(), OnItemsAvailable(_)).Times(AnyNumber()); +TEST_F(ManualFillingControllerTest, ClosesSheetWhenFocusingUnfillableField) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); EXPECT_CALL(*view(), CloseAccessorySheet()); - EXPECT_CALL(*view(), SwapSheetWithKeyboard()) - .Times(0); // Don't touch the keyboard! - controller()->RefreshSuggestionsForField(FocusedFieldType::kUnfillableElement, - dummy_accessory_sheet_data()); + EXPECT_CALL(*view(), SwapSheetWithKeyboard()).Times(0); + controller()->NotifyFocusedInputChanged(FocusedFieldType::kUnfillableElement); } -// TODO(fhorschig): Check for recorded metrics here or similar to this. -TEST_F(ManualFillingControllerTest, - SwapSheetWithKeyboardWhenRefreshingSuggestions) { - // Ignore Items - only the closing calls are interesting here. - EXPECT_CALL(*view(), OnItemsAvailable(_)).Times(AnyNumber()); +TEST_F(ManualFillingControllerTest, ClosesSheetWhenFocusingFillableField) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); EXPECT_CALL(*view(), CloseAccessorySheet()).Times(0); EXPECT_CALL(*view(), SwapSheetWithKeyboard()); - controller()->RefreshSuggestionsForField(FocusedFieldType::kFillableTextField, - dummy_accessory_sheet_data()); + controller()->NotifyFocusedInputChanged( + FocusedFieldType::kFillablePasswordField); +} + +TEST_F(ManualFillingControllerTest, ClosesSheetWhenFocusingSearchField) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); + + EXPECT_CALL(*view(), CloseAccessorySheet()); + EXPECT_CALL(*view(), SwapSheetWithKeyboard()).Times(0); + controller()->NotifyFocusedInputChanged( + FocusedFieldType::kFillableSearchField); +} + +TEST_F(ManualFillingControllerTest, ClosesSheetWhenFocusingTextArea) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); + + EXPECT_CALL(*view(), CloseAccessorySheet()); + EXPECT_CALL(*view(), SwapSheetWithKeyboard()).Times(0); + controller()->NotifyFocusedInputChanged(FocusedFieldType::kFillableTextArea); +} + +TEST_F(ManualFillingControllerTest, AlwaysShowsAccessoryForPasswordFields) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); + FocusFieldAndClearExpectations(FocusedFieldType::kFillablePasswordField); + + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); + controller()->RefreshSuggestions(empty_passwords_sheet()); +} + +TEST_F(ManualFillingControllerTest, + HidesAccessoryWithoutSuggestionsOnNonPasswordFields) { + SetSuggestionsAndClearExpectations( + populate_sheet(AccessoryTabType::PASSWORDS)); + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + autofill::features::kAutofillKeyboardAccessory); + FocusFieldAndClearExpectations(FocusedFieldType::kFillableUsernameField); + + EXPECT_CALL(*view(), Hide()); + controller()->RefreshSuggestions(empty_passwords_sheet()); +} + +TEST_F(ManualFillingControllerTest, ShowsAccessoryWithSuggestions) { + FocusFieldAndClearExpectations(FocusedFieldType::kFillableUsernameField); + + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); + controller()->RefreshSuggestions(populate_sheet(AccessoryTabType::PASSWORDS)); +} + +TEST_F(ManualFillingControllerTest, DoesntShowFallbacksOutsideUsernameInV1) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeatures( + /*enabled_features=*/{}, + /*disabled_features=*/{ + autofill::features::kAutofillKeyboardAccessory, + autofill::features::kAutofillManualFallbackAndroid}); + FocusFieldAndClearExpectations(FocusedFieldType::kFillableNonSearchField); + + EXPECT_CALL(*view(), Hide()); + controller()->RefreshSuggestions(populate_sheet(AccessoryTabType::PASSWORDS)); +} + +TEST_F(ManualFillingControllerTest, ShowsFallbacksOutsideUsernameInV2) { + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitAndEnableFeature( + autofill::features::kAutofillKeyboardAccessory); + FocusFieldAndClearExpectations(FocusedFieldType::kFillableNonSearchField); + + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); + controller()->RefreshSuggestions(populate_sheet(AccessoryTabType::PASSWORDS)); +} + +// TODO(fhorschig): Check for recorded metrics here or similar to this. +TEST_F(ManualFillingControllerTest, ShowsAccessoryWhenRefreshingSuggestions) { + FocusFieldAndClearExpectations(FocusedFieldType::kFillableUsernameField); + + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); + controller()->RefreshSuggestions(populate_sheet(AccessoryTabType::PASSWORDS)); } // TODO(fhorschig): Check for recorded metrics here or similar to this. @@ -132,37 +213,51 @@ controller()->OnFilledIntoFocusedField(FillingStatus::SUCCESS); } -TEST_F(ManualFillingControllerTest, RelaysShowAndHideKeyboardAccessory) { +TEST_F(ManualFillingControllerTest, ShowsAndHidesAccessoryForPasswords) { + FocusFieldAndClearExpectations(FocusedFieldType::kFillableUsernameField); + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); - controller()->ShowWhenKeyboardIsVisible(FillingSource::PASSWORD_FALLBACKS); + controller()->UpdateSourceAvailability(FillingSource::PASSWORD_FALLBACKS, + /*has_suggestions=*/true); + EXPECT_CALL(*view(), Hide()); - controller()->DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS); + controller()->UpdateSourceAvailability(FillingSource::PASSWORD_FALLBACKS, + /*has_suggestions=*/false); } TEST_F(ManualFillingControllerTest, RelaysShowTouchToFillSheet) { - EXPECT_CALL(*view(), OnItemsAvailable(dummy_accessory_sheet_data())); + EXPECT_CALL(*view(), OnItemsAvailable(empty_passwords_sheet())); EXPECT_CALL(*view(), ShowTouchToFillSheet); - controller()->ShowTouchToFillSheet(dummy_accessory_sheet_data()); + controller()->ShowTouchToFillSheet(empty_passwords_sheet()); } -TEST_F(ManualFillingControllerTest, HidesAccessoryWhenAllSourcesRequestedIt) { +TEST_F(ManualFillingControllerTest, HidesAccessoryWithoutAvailableSources) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndEnableFeature( autofill::features::kAutofillKeyboardAccessory); - EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()).Times(3); - controller()->ShowWhenKeyboardIsVisible(FillingSource::PASSWORD_FALLBACKS); - controller()->ShowWhenKeyboardIsVisible(FillingSource::AUTOFILL); - // This duplicate call accounts for a single, visible source. - controller()->ShowWhenKeyboardIsVisible(FillingSource::PASSWORD_FALLBACKS); + FocusFieldAndClearExpectations(FocusedFieldType::kFillableNonSearchField); + + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()).Times(2); + controller()->UpdateSourceAvailability(FillingSource::PASSWORD_FALLBACKS, + /*has_suggestions=*/true); + controller()->UpdateSourceAvailability(FillingSource::AUTOFILL, + /*has_suggestions=*/true); + // This duplicate call is a noop. + controller()->UpdateSourceAvailability(FillingSource::PASSWORD_FALLBACKS, + /*has_suggestions=*/true); + testing::Mock::VerifyAndClearExpectations(view()); // Hiding just one of two active filling sources won't have any effect. EXPECT_CALL(*view(), Hide()).Times(0); - controller()->DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS); + EXPECT_CALL(*view(), ShowWhenKeyboardIsVisible()); + controller()->UpdateSourceAvailability(FillingSource::PASSWORD_FALLBACKS, + /*has_suggestions=*/false); testing::Mock::VerifyAndClearExpectations(view()); // Hiding the remaining second source will result in the view being hidden. EXPECT_CALL(*view(), Hide()).Times(1); - controller()->DeactivateFillingSource(FillingSource::AUTOFILL); + controller()->UpdateSourceAvailability(FillingSource::AUTOFILL, + /*has_suggestions=*/false); } TEST_F(ManualFillingControllerTest, OnAutomaticGenerationStatusChanged) { @@ -180,8 +275,7 @@ true); EXPECT_CALL(mock_pwd_controller_, OnFillingTriggered(field)); - controller()->OnFillingTriggered(autofill::AccessoryTabType::PASSWORDS, - field); + controller()->OnFillingTriggered(AccessoryTabType::PASSWORDS, field); } TEST_F(ManualFillingControllerTest, ForwardsPasswordManagingToController) {
diff --git a/chrome/browser/autofill/mock_manual_filling_controller.h b/chrome/browser/autofill/mock_manual_filling_controller.h index 59d90af4..1a64d529 100644 --- a/chrome/browser/autofill/mock_manual_filling_controller.h +++ b/chrome/browser/autofill/mock_manual_filling_controller.h
@@ -16,24 +16,22 @@ MockManualFillingController(); ~MockManualFillingController() override; - MOCK_METHOD1(OnAutomaticGenerationStatusChanged, void(bool)); + MOCK_METHOD1(RefreshSuggestions, void(const autofill::AccessorySheetData&)); + MOCK_METHOD1(NotifyFocusedInputChanged, + void(autofill::mojom::FocusedFieldType)); MOCK_METHOD1(OnFilledIntoFocusedField, void(autofill::mojom::FillingStatus)); - MOCK_METHOD2(RefreshSuggestionsForField, - void(autofill::mojom::FocusedFieldType, - const autofill::AccessorySheetData&)); - MOCK_METHOD1(ShowWhenKeyboardIsVisible, - void(ManualFillingController::FillingSource)); + MOCK_METHOD2(UpdateSourceAvailability, + void(ManualFillingController::FillingSource, bool)); MOCK_METHOD1(ShowTouchToFillSheet, void(const autofill::AccessorySheetData&)); - MOCK_METHOD1(DeactivateFillingSource, - void(ManualFillingController::FillingSource)); MOCK_METHOD0(Hide, void()); - MOCK_METHOD2(GetFavicon, - void(int, base::OnceCallback<void(const gfx::Image&)>)); + MOCK_METHOD1(OnAutomaticGenerationStatusChanged, void(bool)); MOCK_METHOD2(OnFillingTriggered, void(autofill::AccessoryTabType type, const autofill::UserInfo::Field&)); MOCK_CONST_METHOD1(OnOptionSelected, void(autofill::AccessoryAction selected_action)); + MOCK_METHOD2(GetFavicon, + void(int, base::OnceCallback<void(const gfx::Image&)>)); MOCK_CONST_METHOD0(container_view, gfx::NativeView()); private:
diff --git a/chrome/browser/autofill/mock_password_accessory_controller.cc b/chrome/browser/autofill/mock_password_accessory_controller.cc new file mode 100644 index 0000000..82a3a340 --- /dev/null +++ b/chrome/browser/autofill/mock_password_accessory_controller.cc
@@ -0,0 +1,8 @@ +// Copyright 2019 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/autofill/mock_password_accessory_controller.h" + +MockPasswordAccessoryController::MockPasswordAccessoryController() = default; +MockPasswordAccessoryController::~MockPasswordAccessoryController() = default;
diff --git a/chrome/browser/autofill/mock_password_accessory_controller.h b/chrome/browser/autofill/mock_password_accessory_controller.h new file mode 100644 index 0000000..4aaab17 --- /dev/null +++ b/chrome/browser/autofill/mock_password_accessory_controller.h
@@ -0,0 +1,41 @@ +// Copyright 2019 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_AUTOFILL_MOCK_PASSWORD_ACCESSORY_CONTROLLER_H_ +#define CHROME_BROWSER_AUTOFILL_MOCK_PASSWORD_ACCESSORY_CONTROLLER_H_ + +#include <map> + +#include "base/macros.h" +#include "chrome/browser/password_manager/password_accessory_controller.h" +#include "components/autofill/core/browser/ui/accessory_sheet_data.h" +#include "components/autofill/core/browser/ui/accessory_sheet_enums.h" +#include "components/autofill/core/common/mojom/autofill_types.mojom.h" +#include "testing/gmock/include/gmock/gmock.h" + +class MockPasswordAccessoryController : public PasswordAccessoryController { + public: + MockPasswordAccessoryController(); + ~MockPasswordAccessoryController() override; + + MOCK_METHOD2( + SavePasswordsForOrigin, + void(const std::map<base::string16, const autofill::PasswordForm*>&, + const url::Origin&)); + MOCK_METHOD1(OnFilledIntoFocusedField, void(autofill::mojom::FillingStatus)); + MOCK_METHOD2(RefreshSuggestionsForField, + void(autofill::mojom::FocusedFieldType, bool)); + MOCK_METHOD1(OnGenerationRequested, void(bool)); + MOCK_METHOD0(DidNavigateMainFrame, void()); + MOCK_METHOD2(GetFavicon, + void(int, base::OnceCallback<void(const gfx::Image&)>)); + MOCK_METHOD1(OnFillingTriggered, void(const autofill::UserInfo::Field&)); + MOCK_METHOD1(OnOptionSelected, + void(autofill::AccessoryAction selected_action)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockPasswordAccessoryController); +}; + +#endif // CHROME_BROWSER_AUTOFILL_MOCK_PASSWORD_ACCESSORY_CONTROLLER_H_
diff --git a/chrome/browser/background_sync/periodic_background_sync_permission_context.cc b/chrome/browser/background_sync/periodic_background_sync_permission_context.cc index 2157e27..cb9efe2 100644 --- a/chrome/browser/background_sync/periodic_background_sync_permission_context.cc +++ b/chrome/browser/background_sync/periodic_background_sync_permission_context.cc
@@ -16,7 +16,7 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/strings/utf_string_conversions.h" -#include "jni/BackgroundSyncPwaDetector_jni.h" +#include "chrome/android/chrome_jni_headers/BackgroundSyncPwaDetector_jni.h" #endif PeriodicBackgroundSyncPermissionContext::
diff --git a/chrome/browser/banners/app_banner_manager_android.cc b/chrome/browser/banners/app_banner_manager_android.cc index 2b0a5af..477a543 100644 --- a/chrome/browser/banners/app_banner_manager_android.cc +++ b/chrome/browser/banners/app_banner_manager_android.cc
@@ -10,6 +10,7 @@ #include "base/feature_list.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/AppBannerManager_jni.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/webapk/chrome_webapk_host.h" @@ -23,7 +24,6 @@ #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/manifest_icon_downloader.h" #include "content/public/browser/web_contents.h" -#include "jni/AppBannerManager_jni.h" #include "net/base/url_util.h" using base::android::ConvertJavaStringToUTF8;
diff --git a/chrome/browser/banners/app_banner_ui_delegate_android.cc b/chrome/browser/banners/app_banner_ui_delegate_android.cc index ed66bb29..2e100ba 100644 --- a/chrome/browser/banners/app_banner_ui_delegate_android.cc +++ b/chrome/browser/banners/app_banner_ui_delegate_android.cc
@@ -8,6 +8,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/AppBannerUiDelegateAndroid_jni.h" #include "chrome/browser/android/shortcut_helper.h" #include "chrome/browser/android/shortcut_info.h" #include "chrome/browser/android/tab_android.h" @@ -21,7 +22,6 @@ #include "components/rappor/rappor_service_impl.h" #include "components/url_formatter/elide_url.h" #include "content/public/browser/web_contents.h" -#include "jni/AppBannerUiDelegateAndroid_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "url/gurl.h"
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc index 51f62650..72f12cd 100644 --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
@@ -83,6 +83,7 @@ #include "components/password_manager/core/browser/password_manager_test_utils.h" #include "components/password_manager/core/browser/password_store_consumer.h" #include "components/prefs/testing_pref_service.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browsing_data_filter_builder.h" #include "content/public/browser/browsing_data_remover.h" @@ -108,7 +109,6 @@ #include "chrome/browser/android/webapps/webapp_registry.h" #include "components/feed/buildflags.h" #else // !defined(OS_ANDROID) -#include "components/safe_browsing/password_protection/mock_password_protection_service.h" #include "content/public/browser/host_zoom_map.h" #endif // !defined(OS_ANDROID) @@ -2844,13 +2844,9 @@ #if !defined(OS_ANDROID) auto* history_service = HistoryServiceFactory::GetForProfileWithoutCreating(profile); - // Create a PasswordProtectionService that will handle deletion of - // CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION entries. The mock is sufficient - // as we don't need to rely any functionality of the Chrome* implementation. - safe_browsing::MockPasswordProtectionService password_protection_service( - nullptr, nullptr, history_service, map); - EXPECT_CALL(password_protection_service, - RemoveUnhandledSyncPasswordReuseOnURLsDeleted(true, _)); + // Create a safe_browsing::VerdictCacheManager that will handle deletion of + // CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION entries. + safe_browsing::VerdictCacheManager sb_cache_manager(history_service, map); #endif // !defined(OS_ANDROID) GURL url("https://example.com");
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index edac44a..ea14910 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -388,7 +388,6 @@ #include "services/audio/public/mojom/constants.mojom.h" #include "services/video_capture/public/mojom/constants.mojom.h" #elif defined(OS_CHROMEOS) -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/interfaces/constants.mojom.h" #include "chrome/browser/ash_service_registry.h" #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_backend_delegate.h" @@ -414,6 +413,7 @@ #include "chrome/browser/chromeos/system/input_device_settings.h" #include "chrome/browser/speech/tts_chromeos.h" #include "chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/services/cups_proxy/cups_proxy_service.h" #include "chrome/services/cups_proxy/public/mojom/constants.mojom.h" @@ -1535,7 +1535,8 @@ #if defined(OS_ANDROID) return true; #elif defined(OS_CHROMEOS) - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled(); #else return false; #endif // defined(OS_ANDROID)
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index e66f656..2e5e477 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -2134,6 +2134,8 @@ "extensions/file_system_provider/provider_function.h", "extensions/input_method_api.cc", "extensions/input_method_api.h", + "extensions/login/login_api.cc", + "extensions/login/login_api.h", "extensions/login_screen_ui/login_screen_extension_ui_handler.cc", "extensions/login_screen_ui/login_screen_extension_ui_handler.h", "extensions/login_screen_ui/login_screen_ui_api.cc", @@ -2430,6 +2432,7 @@ "extensions/file_manager/job_event_router_unittest.cc", "extensions/gfx_utils_unittest.cc", "extensions/install_limiter_unittest.cc", + "extensions/login/login_api_unittest.cc", "extensions/login_screen_ui/login_screen_extension_ui_handler_unittest.cc", "extensions/permissions_updater_delegate_chromeos_unittest.cc", "extensions/public_session_permission_helper_unittest.cc",
diff --git a/chrome/browser/chromeos/arc/auth/arc_auth_service_browsertest.cc b/chrome/browser/chromeos/arc/auth/arc_auth_service_browsertest.cc index e3f1ce86..1ca760a5 100644 --- a/chrome/browser/chromeos/arc/auth/arc_auth_service_browsertest.cc +++ b/chrome/browser/chromeos/arc/auth/arc_auth_service_browsertest.cc
@@ -57,7 +57,6 @@ #include "components/policy/core/common/policy_switches.h" #include "components/prefs/pref_member.h" #include "components/prefs/pref_service.h" -#include "components/signin/core/browser/account_fetcher_service.h" #include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/user_manager.h" #include "components/user_manager/user_names.h"
diff --git a/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service.cc b/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service.cc index 9ad5aab7..0d16305 100644 --- a/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service.cc +++ b/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service.cc
@@ -9,8 +9,6 @@ #include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/keyboard/keyboard_switches.h" -#include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/bind.h" #include "base/logging.h" #include "base/memory/singleton.h" @@ -22,6 +20,8 @@ #include "chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_bridge_impl.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/common/pref_names.h" #include "components/arc/arc_browser_context_keyed_service_factory_base.h" #include "components/arc/common/ime_struct_traits.h" @@ -194,13 +194,12 @@ }; class ArcInputMethodManagerService::TabletModeObserver - : public ash::TabletModeToggleObserver { + : public TabletModeClientObserver { public: explicit TabletModeObserver(ArcInputMethodManagerService* owner) : owner_(owner) {} ~TabletModeObserver() override = default; - // ash::TabletModeToggleObserver overrides: void OnTabletModeToggled(bool enabled) override { owner_->UpdateArcIMEAllowed(); owner_->NotifyInputMethodManagerObservers(enabled); @@ -254,7 +253,10 @@ std::make_unique<InputMethodEngineObserver>(this), proxy_ime_extension_id_.c_str(), profile_); - ash::TabletMode::Get()->AddObserver(tablet_mode_observer_.get()); + // TabletModeClient should be already created here because it's created in + // PreProfileInit() and this service is created in PostProfileInit(). + DCHECK(TabletModeClient::Get()); + TabletModeClient::Get()->AddObserver(tablet_mode_observer_.get()); chromeos::AccessibilityManager* accessibility_manager = chromeos::AccessibilityManager::Get(); @@ -302,7 +304,8 @@ if (ui::IMEBridge::Get()) ui::IMEBridge::Get()->RemoveObserver(this); - ash::TabletMode::Get()->RemoveObserver(tablet_mode_observer_.get()); + if (TabletModeClient::Get()) + TabletModeClient::Get()->RemoveObserver(tablet_mode_observer_.get()); auto* imm = chromeos::input_method::InputMethodManager::Get(); imm->RemoveImeMenuObserver(this); @@ -740,7 +743,7 @@ const bool is_normal_vk_enabled = !profile_->GetPrefs()->GetBoolean( ash::prefs::kAccessibilityVirtualKeyboardEnabled) && - ash::TabletMode::Get()->InTabletMode(); + TabletModeClient::Get()->tablet_mode_enabled(); return is_command_line_flag_enabled || is_normal_vk_enabled; }
diff --git a/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service_unittest.cc b/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service_unittest.cc index f8bb8ad..c98e0f0 100644 --- a/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service_unittest.cc +++ b/chrome/browser/chromeos/arc/input_method_manager/arc_input_method_manager_service_unittest.cc
@@ -11,8 +11,6 @@ #include "ash/public/cpp/ash_pref_names.h" #include "ash/public/cpp/keyboard/keyboard_switches.h" -#include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/run_loop.h" @@ -23,6 +21,7 @@ #include "base/test/scoped_feature_list.h" #include "chrome/browser/chromeos/arc/input_method_manager/test_input_method_manager_bridge.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client_test_helper.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_ash_test_base.h" #include "chrome/test/base/testing_profile.h" @@ -36,7 +35,6 @@ #include "ui/base/ime/ime_bridge.h" #include "ui/base/ime/mock_ime_input_context_handler.h" #include "ui/base/ime/mock_input_method.h" -#include "ui/views/widget/widget.h" namespace arc { namespace { @@ -186,7 +184,7 @@ TestingProfile* profile() { return profile_.get(); } void ToggleTabletMode(bool enabled) { - ash::ShellTestApi().SetTabletModeEnabledForTest(enabled); + tablet_mode_client_->OnTabletModeToggled(enabled); } void SetUp() override { @@ -196,10 +194,7 @@ chromeos::input_method::InputMethodManager::Initialize( input_method_manager_); profile_ = std::make_unique<TestingProfile>(); - - // Create a test widget so that enabling tablet mode does not show app list - // whose search box could mess with the tests. - widget_ = CreateTestWidget(); + tablet_mode_client_ = std::make_unique<TabletModeClient>(); chrome_keyboard_controller_client_test_helper_ = ChromeKeyboardControllerClientTestHelper::InitializeForAsh(); @@ -223,14 +218,17 @@ // |chrome_keyboard_controller_client_test_helper_| observes the keyboard // destruction. chrome_keyboard_controller_client_test_helper_.reset(); + // To match ChromeBrowserMainExtraPartsAsh, shut down the TabletModeClient + // after Shell. + tablet_mode_client_.reset(); } private: std::unique_ptr<ArcServiceManager> arc_service_manager_; std::unique_ptr<TestingProfile> profile_; + std::unique_ptr<TabletModeClient> tablet_mode_client_; std::unique_ptr<ChromeKeyboardControllerClientTestHelper> chrome_keyboard_controller_client_test_helper_; - std::unique_ptr<views::Widget> widget_; TestInputMethodManager* input_method_manager_ = nullptr; TestInputMethodManagerBridge* test_bridge_ = nullptr; // Owned by |service_| ArcInputMethodManagerService* service_ = nullptr;
diff --git a/chrome/browser/chromeos/child_accounts/usage_time_limit_processor_unittest.cc b/chrome/browser/chromeos/child_accounts/usage_time_limit_processor_unittest.cc index 35e8d64..9a7a19d 100644 --- a/chrome/browser/chromeos/child_accounts/usage_time_limit_processor_unittest.cc +++ b/chrome/browser/chromeos/child_accounts/usage_time_limit_processor_unittest.cc
@@ -2626,6 +2626,8 @@ // Tests that local override changes state to unlocked during window time limit. TEST_F(UsageTimeLimitProcessorTest, LocalOverrideAndWindowTimeLimit) { + std::unique_ptr<icu::TimeZone> timezone(icu::TimeZone::createTimeZone("GMT")); + // Window time limit active between 18:00 and 7:00. const int kWindowStart = 18; const int kWindowEnd = 7; @@ -2652,10 +2654,10 @@ base::nullopt /* duration */) .ToDictionary(); - State state = GetState(policy, &inactive_local_override, - base::TimeDelta::FromMinutes(0), current_time, - current_time, icu::TimeZone::createTimeZone("GMT"), - base::nullopt /* previous_state */); + State state = + GetState(policy, &inactive_local_override, + base::TimeDelta::FromMinutes(0), current_time, current_time, + timezone.get(), base::nullopt /* previous_state */); base::Time monday_bedtime_end; ASSERT_TRUE( @@ -2675,10 +2677,9 @@ base::nullopt /* duration */) .ToDictionary(); - state = - GetState(policy, &active_local_override, base::TimeDelta::FromMinutes(0), - current_time, current_time, icu::TimeZone::createTimeZone("GMT"), - base::nullopt /* previous_state */); + state = GetState(policy, &active_local_override, + base::TimeDelta::FromMinutes(0), current_time, current_time, + timezone.get(), base::nullopt /* previous_state */); base::Time tuesday_bedtime_start; ASSERT_TRUE(base::Time::FromString("Tue, 2 Jan 2018 18:00 GMT", @@ -2696,6 +2697,7 @@ // Tests that local override changes state to unlocked when locked because of // time usage limit. TEST_F(UsageTimeLimitProcessorTest, LocalOverrideAndTimeUsageLimit) { + std::unique_ptr<icu::TimeZone> timezone(icu::TimeZone::createTimeZone("GMT")); const base::TimeDelta kDailyLimit = base::TimeDelta::FromHours(2); base::Time timestamp; @@ -2734,9 +2736,9 @@ const base::Time current_time = timestamp + base::TimeDelta::FromMinutes(10); - State state = GetState( - policy, &inactive_local_override, kDailyLimit, current_time, current_time, - icu::TimeZone::createTimeZone("GMT"), usage_limit_lock_state); + State state = + GetState(policy, &inactive_local_override, kDailyLimit, current_time, + current_time, timezone.get(), usage_limit_lock_state); // State did not change from previous state - time usage lock still active. AssertEqState(usage_limit_lock_state, state); @@ -2749,8 +2751,7 @@ .ToDictionary(); state = GetState(policy, &active_local_override, kDailyLimit, current_time, - current_time, icu::TimeZone::createTimeZone("GMT"), - usage_limit_lock_state); + current_time, timezone.get(), usage_limit_lock_state); // Unlocked by local override. EXPECT_FALSE(state.is_locked); @@ -2764,6 +2765,8 @@ // Tests that local override changes state to unlocked when locked by remote // override. TEST_F(UsageTimeLimitProcessorTest, LocalOverrideAndRemoteOverride) { + std::unique_ptr<icu::TimeZone> timezone(icu::TimeZone::createTimeZone("GMT")); + base::Time current_time; ASSERT_TRUE( base::Time::FromString("Mon, 1 Jan 2018 15:00 GMT", ¤t_time)); @@ -2781,10 +2784,10 @@ base::nullopt /* duration */) .ToDictionary(); - State state = GetState(policy, &inactive_local_override, - base::TimeDelta::FromMinutes(0), current_time, - current_time, icu::TimeZone::createTimeZone("GMT"), - base::nullopt /* previous_state */); + State state = + GetState(policy, &inactive_local_override, + base::TimeDelta::FromMinutes(0), current_time, current_time, + timezone.get(), base::nullopt /* previous_state */); base::Time next_day; ASSERT_TRUE(base::Time::FromString("Mon, 2 Jan 2018 00:00 GMT", &next_day)); @@ -2803,10 +2806,9 @@ base::nullopt /* duration */) .ToDictionary(); - state = - GetState(policy, &active_local_override, base::TimeDelta::FromMinutes(0), - current_time, current_time, icu::TimeZone::createTimeZone("GMT"), - base::nullopt /* previous_state */); + state = GetState(policy, &active_local_override, + base::TimeDelta::FromMinutes(0), current_time, current_time, + timezone.get(), base::nullopt /* previous_state */); // Unlocked by local override. EXPECT_FALSE(state.is_locked);
diff --git a/chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.cc b/chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.cc index 91dedc19..ae99152b 100644 --- a/chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.cc +++ b/chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/chromeos/chrome_content_browser_client_chromeos_part.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/feature_list.h" #include "chrome/browser/browser_features.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search/search.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" @@ -73,8 +73,10 @@ void OverrideWebkitPrefsForTabletMode(content::WebContents* contents, content::WebPreferences* web_prefs) { // Enable some mobile-like behaviors when in tablet mode on Chrome OS. - if (!ash::TabletMode::Get()->InTabletMode()) + if (!TabletModeClient::Get() || + !TabletModeClient::Get()->tablet_mode_enabled()) { return; + } // Do this only for webcontents displayed in browsers and are not of hosted // apps.
diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc index e8328a58..5470d3ba 100644 --- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc +++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc
@@ -51,6 +51,7 @@ #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/shelf_spinner_controller.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/views/crostini/crostini_installer_view.h" #include "chrome/browser/ui/views/crostini/crostini_uninstaller_view.h" #include "chrome/common/chrome_features.h" @@ -1554,8 +1555,8 @@ AutotestPrivateIsTabletModeEnabledFunction::Run() { DVLOG(1) << "AutotestPrivateIsTabletModeEnabledFunction"; - return RespondNow(OneArgument( - std::make_unique<base::Value>(ash::TabletMode::Get()->InTabletMode()))); + return RespondNow(OneArgument(std::make_unique<base::Value>( + TabletModeClient::Get()->tablet_mode_enabled()))); } ///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/chromeos/extensions/login/OWNERS b/chrome/browser/chromeos/extensions/login/OWNERS new file mode 100644 index 0000000..8b107e4c --- /dev/null +++ b/chrome/browser/chromeos/extensions/login/OWNERS
@@ -0,0 +1 @@ +file://chrome/browser/chromeos/extensions/login_screen_ui/OWNERS
diff --git a/chrome/browser/chromeos/extensions/login/login_api.cc b/chrome/browser/chromeos/extensions/login/login_api.cc new file mode 100644 index 0000000..bf6d2bea --- /dev/null +++ b/chrome/browser/chromeos/extensions/login/login_api.cc
@@ -0,0 +1,112 @@ +// Copyright 2019 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/extensions/login/login_api.h" + +#include <memory> +#include <string> + +#include "base/logging.h" +#include "base/values.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/login/existing_user_controller.h" +#include "chrome/browser/chromeos/login/signin_specifics.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/lifetime/application_lifetime.h" +#include "chrome/common/extensions/api/login.h" +#include "chrome/common/pref_names.h" +#include "chromeos/login/auth/user_context.h" +#include "components/prefs/pref_service.h" +#include "components/user_manager/user.h" +#include "components/user_manager/user_manager.h" +#include "components/user_manager/user_type.h" + +namespace extensions { + +namespace { + +const char kErrorNoManagedGuestSessionAccounts[] = + "No managed guest session accounts"; + +} // namespace + +namespace login_api { + +void RegisterLocalStatePrefs(PrefRegistrySimple* registry) { + registry->RegisterStringPref(prefs::kLoginExtensionApiDataForNextLoginAttempt, + ""); +} + +} // namespace login_api + +LoginLaunchManagedGuestSessionFunction:: + LoginLaunchManagedGuestSessionFunction() = default; +LoginLaunchManagedGuestSessionFunction:: + ~LoginLaunchManagedGuestSessionFunction() = default; + +ExtensionFunction::ResponseAction +LoginLaunchManagedGuestSessionFunction::Run() { + user_manager::UserManager* user_manager = user_manager::UserManager::Get(); + for (const user_manager::User* user : user_manager->GetUsers()) { + if (!user || user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) + continue; + chromeos::UserContext context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, + user->GetAccountId()); + chromeos::ExistingUserController::current_controller()->Login( + context, chromeos::SigninSpecifics()); + return RespondNow(NoArguments()); + } + return RespondNow(Error(kErrorNoManagedGuestSessionAccounts)); +} + +LoginExitCurrentSessionFunction::LoginExitCurrentSessionFunction() = default; +LoginExitCurrentSessionFunction::~LoginExitCurrentSessionFunction() = default; + +ExtensionFunction::ResponseAction LoginExitCurrentSessionFunction::Run() { + std::unique_ptr<api::login::ExitCurrentSession::Params> parameters = + api::login::ExitCurrentSession::Params::Create(*args_); + EXTENSION_FUNCTION_VALIDATE(parameters); + + PrefService* local_state = g_browser_process->local_state(); + DCHECK(local_state); + + if (parameters->data_for_next_login_attempt) { + local_state->SetString(prefs::kLoginExtensionApiDataForNextLoginAttempt, + *parameters->data_for_next_login_attempt); + } else { + local_state->ClearPref(prefs::kLoginExtensionApiDataForNextLoginAttempt); + } + + chrome::AttemptUserExit(); + return RespondNow(NoArguments()); +} + +LoginIsRunningInLoginProfileFunction::LoginIsRunningInLoginProfileFunction() = + default; +LoginIsRunningInLoginProfileFunction::~LoginIsRunningInLoginProfileFunction() = + default; + +ExtensionFunction::ResponseAction LoginIsRunningInLoginProfileFunction::Run() { + return RespondNow(OneArgument(std::make_unique<base::Value>( + profile_id() == chromeos::ProfileHelper::Get()->GetSigninProfile()))); +} + +LoginFetchDataForNextLoginAttemptFunction:: + LoginFetchDataForNextLoginAttemptFunction() = default; +LoginFetchDataForNextLoginAttemptFunction:: + ~LoginFetchDataForNextLoginAttemptFunction() = default; + +ExtensionFunction::ResponseAction +LoginFetchDataForNextLoginAttemptFunction::Run() { + PrefService* local_state = g_browser_process->local_state(); + DCHECK(local_state); + std::string data_for_next_login_attempt = + local_state->GetString(prefs::kLoginExtensionApiDataForNextLoginAttempt); + local_state->ClearPref(prefs::kLoginExtensionApiDataForNextLoginAttempt); + + return RespondNow( + OneArgument(std::make_unique<base::Value>(data_for_next_login_attempt))); +} + +} // namespace extensions
diff --git a/chrome/browser/chromeos/extensions/login/login_api.h b/chrome/browser/chromeos/extensions/login/login_api.h new file mode 100644 index 0000000..d95008e --- /dev/null +++ b/chrome/browser/chromeos/extensions/login/login_api.h
@@ -0,0 +1,92 @@ +// Copyright 2019 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_EXTENSIONS_LOGIN_LOGIN_API_H_ +#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_LOGIN_LOGIN_API_H_ + +#include "base/macros.h" +#include "components/prefs/pref_registry_simple.h" +#include "extensions/browser/extension_function.h" + +namespace extensions { + +namespace login_api { + +void RegisterLocalStatePrefs(PrefRegistrySimple* registry); + +} + +class LoginLaunchManagedGuestSessionFunction + : public UIThreadExtensionFunction { + public: + LoginLaunchManagedGuestSessionFunction(); + + DECLARE_EXTENSION_FUNCTION("login.launchManagedGuestSession", + LOGIN_LAUNCHMANAGEDGUESTSESSION) + + protected: + ~LoginLaunchManagedGuestSessionFunction() override; + + // ExtensionFunction: + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(LoginLaunchManagedGuestSessionFunction); +}; + +class LoginExitCurrentSessionFunction : public UIThreadExtensionFunction { + public: + LoginExitCurrentSessionFunction(); + + DECLARE_EXTENSION_FUNCTION("login.exitCurrentSession", + LOGIN_EXITCURRENTSESSION) + + protected: + ~LoginExitCurrentSessionFunction() override; + + // ExtensionFunction: + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(LoginExitCurrentSessionFunction); +}; + +class LoginIsRunningInLoginProfileFunction : public UIThreadExtensionFunction { + public: + LoginIsRunningInLoginProfileFunction(); + + DECLARE_EXTENSION_FUNCTION("login.isRunningInLoginProfile", + LOGIN_ISRUNNINGINLOGINPROFILE) + + protected: + ~LoginIsRunningInLoginProfileFunction() override; + + // ExtensionFunction: + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(LoginIsRunningInLoginProfileFunction); +}; + +class LoginFetchDataForNextLoginAttemptFunction + : public UIThreadExtensionFunction { + public: + LoginFetchDataForNextLoginAttemptFunction(); + + DECLARE_EXTENSION_FUNCTION("login.fetchDataForNextLoginAttempt", + LOGIN_FETCHDATAFORNEXTLOGINATTEMPT) + + protected: + ~LoginFetchDataForNextLoginAttemptFunction() override; + + // ExtensionFunction: + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(LoginFetchDataForNextLoginAttemptFunction); +}; + +} // namespace extensions + +#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_LOGIN_LOGIN_API_H_
diff --git a/chrome/browser/chromeos/extensions/login/login_api_unittest.cc b/chrome/browser/chromeos/extensions/login/login_api_unittest.cc new file mode 100644 index 0000000..7d722d0 --- /dev/null +++ b/chrome/browser/chromeos/extensions/login/login_api_unittest.cc
@@ -0,0 +1,185 @@ +// Copyright 2019 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/extensions/login/login_api.h" + +#include <memory> +#include <string> + +#include "base/strings/stringprintf.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/login/existing_user_controller.h" +#include "chrome/browser/chromeos/login/signin_specifics.h" +#include "chrome/browser/chromeos/login/ui/mock_login_display_host.h" +#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/extensions/extension_api_unittest.h" +#include "chrome/common/pref_names.h" +#include "chromeos/login/auth/user_context.h" +#include "components/account_id/account_id.h" +#include "components/user_manager/scoped_user_manager.h" +#include "extensions/browser/api_unittest.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using testing::_; +using testing::Return; + +namespace { + +class MockExistingUserController : public chromeos::ExistingUserController { + public: + MockExistingUserController() = default; + ~MockExistingUserController() override = default; + + MOCK_METHOD2(Login, + void(const chromeos::UserContext&, + const chromeos::SigninSpecifics&)); + + private: + DISALLOW_COPY_AND_ASSIGN(MockExistingUserController); +}; + +} // namespace + +namespace extensions { + +class LoginApiUnittest : public ExtensionApiUnittest { + public: + LoginApiUnittest() = default; + ~LoginApiUnittest() override = default; + + void SetUp() override { + ExtensionApiUnittest::SetUp(); + + fake_chrome_user_manager_ = new chromeos::FakeChromeUserManager(); + scoped_user_manager_ = std::make_unique<user_manager::ScopedUserManager>( + std::unique_ptr<chromeos::FakeChromeUserManager>( + fake_chrome_user_manager_)); + mock_login_display_host_ = + std::make_unique<chromeos::MockLoginDisplayHost>(); + mock_existing_user_controller_ = + std::make_unique<MockExistingUserController>(); + } + + void TearDown() override { + mock_existing_user_controller_.reset(); + mock_login_display_host_.reset(); + scoped_user_manager_.reset(); + + ExtensionApiUnittest::TearDown(); + } + + protected: + chromeos::FakeChromeUserManager* fake_chrome_user_manager_; + std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_; + std::unique_ptr<chromeos::MockLoginDisplayHost> mock_login_display_host_; + std::unique_ptr<MockExistingUserController> mock_existing_user_controller_; + + private: + DISALLOW_COPY_AND_ASSIGN(LoginApiUnittest); +}; + +MATCHER_P(MatchSigninSpecifics, expected, "") { + return expected.guest_mode_url == arg.guest_mode_url && + expected.guest_mode_url_append_locale == + arg.guest_mode_url_append_locale && + expected.kiosk_diagnostic_mode == arg.kiosk_diagnostic_mode && + expected.is_auto_login == arg.is_auto_login; +} + +// Test that calling |login.launchManagedGuestSession()| calls the corresponding +// method from the |ExistingUserController|. +TEST_F(LoginApiUnittest, LaunchManagedGuestSession) { + AccountId test_account_id = + AccountId::FromUserEmail("publicaccount@test.com"); + + fake_chrome_user_manager_->AddPublicAccountUser(test_account_id); + EXPECT_CALL(*mock_login_display_host_, GetExistingUserController()) + .WillOnce(Return(mock_existing_user_controller_.get())); + + chromeos::SigninSpecifics signin_specifics; + chromeos::UserContext userContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, + test_account_id); + EXPECT_CALL(*mock_existing_user_controller_, + Login(userContext, MatchSigninSpecifics(signin_specifics))) + .Times(1); + + RunFunction(new LoginLaunchManagedGuestSessionFunction(), "[]"); +} + +// Test that calling |login.launchManagedGuestSession()| returns an error when +// there are no managed guest session accounts. +TEST_F(LoginApiUnittest, LaunchManagedGuestSessionNoAccounts) { + ASSERT_EQ("No managed guest session accounts", + RunFunctionAndReturnError( + new LoginLaunchManagedGuestSessionFunction(), "[]")); +} + +// Test that calling |login.exitCurrentSession()| with data for the next login +// attempt sets the |kLoginExtensionApiDataForNextLoginAttempt| pref to the +// given data. +TEST_F(LoginApiUnittest, ExitCurrentSessionWithData) { + const std::string data_for_next_login_attempt = "hello world"; + + RunFunction( + new LoginExitCurrentSessionFunction(), + base::StringPrintf(R"(["%s"])", data_for_next_login_attempt.c_str())); + + PrefService* local_state = g_browser_process->local_state(); + ASSERT_EQ( + data_for_next_login_attempt, + local_state->GetString(prefs::kLoginExtensionApiDataForNextLoginAttempt)); +} + +// Test that calling |login.exitCurrentSession()| with no data clears the +// |kLoginExtensionApiDataForNextLoginAttempt| pref. +TEST_F(LoginApiUnittest, ExitCurrentSessionWithNoData) { + PrefService* local_state = g_browser_process->local_state(); + local_state->SetString(prefs::kLoginExtensionApiDataForNextLoginAttempt, + "hello world"); + + RunFunction(new LoginExitCurrentSessionFunction(), "[]"); + + ASSERT_EQ("", local_state->GetString( + prefs::kLoginExtensionApiDataForNextLoginAttempt)); +} + +// Test that calling |login.fetchDataForNextLoginAttempt()| function returns the +// value stored in the |kLoginExtensionsApiDataForNextLoginAttempt| pref and +// clears the pref. +TEST_F(LoginApiUnittest, FetchDataForNextLoginAttemptClearsPref) { + const std::string data_for_next_login_attempt = "hello world"; + + PrefService* local_state = g_browser_process->local_state(); + local_state->SetString(prefs::kLoginExtensionApiDataForNextLoginAttempt, + data_for_next_login_attempt); + + std::unique_ptr<base::Value> value(RunFunctionAndReturnValue( + new LoginFetchDataForNextLoginAttemptFunction(), "[]")); + ASSERT_EQ(data_for_next_login_attempt, value->GetString()); + + ASSERT_EQ("", local_state->GetString( + prefs::kLoginExtensionApiDataForNextLoginAttempt)); +} + +// Test that calling |login.isRunningInLoginProfile()| returns 'false' when the +// extension is not running in the login screen profile. +TEST_F(LoginApiUnittest, IsRunningInLoginProfileNotInProfile) { + ASSERT_FALSE(RunFunctionAndReturnValue( + new LoginIsRunningInLoginProfileFunction(), "[]") + ->GetBool()); +} + +// Test that calling |login.isRunningInLoginProfile()| returns 'true' when the +// extension is running in the login screen profile. +TEST_F(LoginApiUnittest, IsRunningInLoginProfileInProfile) { + LoginIsRunningInLoginProfileFunction* function = + new LoginIsRunningInLoginProfileFunction(); + function->set_profile_id(chromeos::ProfileHelper::Get()->GetSigninProfile()); + + ASSERT_TRUE(RunFunctionAndReturnValue(function, "[]")->GetBool()); +} + +} // namespace extensions
diff --git a/chrome/browser/chromeos/first_run/first_run.cc b/chrome/browser/chromeos/first_run/first_run.cc index 762eea9..8c880f20 100644 --- a/chrome/browser/chromeos/first_run/first_run.cc +++ b/chrome/browser/chromeos/first_run/first_run.cc
@@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/first_run/first_run.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/command_line.h" #include "base/macros.h" #include "base/metrics/histogram_macros.h" @@ -20,6 +19,7 @@ #include "chrome/browser/prefs/pref_service_syncable_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/identity_manager_factory.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/extensions/app_launch_params.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/common/chrome_switches.h" @@ -77,7 +77,8 @@ return; } - if (ash::TabletMode::Get()->InTabletMode()) + // TabletModeClient does not exist in some tests. + if (TabletModeClient::Get() && TabletModeClient::Get()->tablet_mode_enabled()) return; if (profile->GetProfilePolicyConnector()->IsManaged())
diff --git a/chrome/browser/chromeos/login/login_auth_recorder.cc b/chrome/browser/chromeos/login/login_auth_recorder.cc index e0e37dc0..e95299e1 100644 --- a/chrome/browser/chromeos/login/login_auth_recorder.cc +++ b/chrome/browser/chromeos/login/login_auth_recorder.cc
@@ -4,8 +4,8 @@ #include "chrome/browser/chromeos/login/login_auth_recorder.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/metrics/histogram_macros.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "components/session_manager/core/session_manager.h" namespace chromeos { @@ -114,7 +114,7 @@ } // Record usage of PIN / Password / Smartlock / Fingerprint in lock screen. - const bool is_tablet_mode = ash::TabletMode::Get()->InTabletMode(); + const bool is_tablet_mode = TabletModeClient::Get()->tablet_mode_enabled(); if (is_tablet_mode) { UMA_HISTOGRAM_ENUMERATION("Ash.Login.Lock.AuthMethod.Used.TabletMode", method, AuthMethod::kMethodCount);
diff --git a/chrome/browser/chromeos/login/login_auth_recorder_browsertest.cc b/chrome/browser/chromeos/login/login_auth_recorder_browsertest.cc index e665f248..4f9f960 100644 --- a/chrome/browser/chromeos/login/login_auth_recorder_browsertest.cc +++ b/chrome/browser/chromeos/login/login_auth_recorder_browsertest.cc
@@ -4,9 +4,9 @@ #include "chrome/browser/chromeos/login/login_auth_recorder.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "base/test/metrics/histogram_tester.h" #include "chrome/browser/ui/ash/login_screen_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/test/base/in_process_browser_test.h" #include "components/session_manager/core/session_manager.h" @@ -40,7 +40,7 @@ } void EnableTabletMode(bool enable) { - ash::ShellTestApi().SetTabletModeEnabledForTest(enable); + TabletModeClient::Get()->OnTabletModeToggled(enable); } LoginAuthRecorder* metrics_recorder() {
diff --git a/chrome/browser/chromeos/login/oobe_interactive_ui_test.cc b/chrome/browser/chromeos/login/oobe_interactive_ui_test.cc index a275f3e..40942958 100644 --- a/chrome/browser/chromeos/login/oobe_interactive_ui_test.cc +++ b/chrome/browser/chromeos/login/oobe_interactive_ui_test.cc
@@ -3,7 +3,6 @@ // found in the LICENSE file. #include "ash/public/cpp/ash_switches.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" @@ -30,6 +29,7 @@ #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/lifetime/application_lifetime.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/assistant_optin_flow_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" @@ -47,7 +47,6 @@ #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" -#include "ui/display/display_switches.h" using net::test_server::BasicHttpResponse; using net::test_server::HttpRequest; @@ -378,13 +377,8 @@ } void SetUpCommandLine(base::CommandLine* command_line) override { - if (params_.is_tablet) { - // Makes the device capable to entering tablet mode. + if (params_.is_tablet) command_line->AppendSwitch(ash::switches::kAshEnableTabletMode); - // Having an active internal display so that tablet mode does not end - // on display config change. - command_line->AppendSwitch(::switches::kUseFirstDisplayAsInternal); - } if (params_.arc_state != ArcState::kNotAvailable) { arc::SetArcAvailableCommandLineForTesting(command_line); @@ -412,7 +406,7 @@ void SetUpOnMainThread() override { if (params_.is_tablet) - ash::ShellTestApi().SetTabletModeEnabledForTest(true); + TabletModeClient::Get()->OnTabletModeToggled(true); if (params_.arc_state != ArcState::kNotAvailable) { // Init ArcSessionManager for testing.
diff --git a/chrome/browser/chromeos/login/screens/discover_screen.cc b/chrome/browser/chromeos/login/screens/discover_screen.cc index fd788654..590f2f48 100644 --- a/chrome/browser/chromeos/login/screens/discover_screen.cc +++ b/chrome/browser/chromeos/login/screens/discover_screen.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/chromeos/login/screens/discover_screen.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/logging.h" #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h" #include "chrome/browser/chromeos/login/users/chrome_user_manager_util.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/webui/chromeos/login/discover_screen_handler.h" #include "components/prefs/pref_service.h" @@ -34,7 +34,7 @@ void DiscoverScreen::Show() { PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); if (chrome_user_manager_util::IsPublicSessionOrEphemeralLogin() || - !ash::TabletMode::Get()->InTabletMode() || + !TabletModeClient::Get()->tablet_mode_enabled() || !chromeos::quick_unlock::IsPinEnabled(prefs) || chromeos::quick_unlock::IsPinDisabledByPolicy(prefs)) { exit_callback_.Run();
diff --git a/chrome/browser/chromeos/login/signin/oauth2_login_verifier.cc b/chrome/browser/chromeos/login/signin/oauth2_login_verifier.cc index 07cf5015..7c60cae 100644 --- a/chrome/browser/chromeos/login/signin/oauth2_login_verifier.cc +++ b/chrome/browser/chromeos/login/signin/oauth2_login_verifier.cc
@@ -7,7 +7,6 @@ #include <vector> #include "base/logging.h" -#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "content/public/browser/browser_thread.h" #include "services/identity/public/cpp/accounts_cookie_mutator.h" @@ -18,7 +17,7 @@ OAuth2LoginVerifier::OAuth2LoginVerifier( OAuth2LoginVerifier::Delegate* delegate, identity::IdentityManager* identity_manager, - const std::string& primary_account_id, + const CoreAccountId& primary_account_id, const std::string& oauthlogin_access_token) : delegate_(delegate), identity_manager_(identity_manager), @@ -50,7 +49,7 @@ void OAuth2LoginVerifier::VerifyProfileTokens() { DCHECK_CURRENTLY_ON(BrowserThread::UI); - GaiaCookieManagerService::AddAccountToCookieCompletedCallback + identity::AccountsCookieMutator::AddAccountToCookieCompletedCallback completion_callback = base::BindOnce(&OAuth2LoginVerifier::OnAddAccountToCookieCompleted, weak_ptr_factory_.GetWeakPtr()); @@ -66,7 +65,7 @@ } void OAuth2LoginVerifier::OnAddAccountToCookieCompleted( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error) { if (account_id != primary_account_id_) return;
diff --git a/chrome/browser/chromeos/login/signin/oauth2_login_verifier.h b/chrome/browser/chromeos/login/signin/oauth2_login_verifier.h index 6eb4ae1..e6efb27 100644 --- a/chrome/browser/chromeos/login/signin/oauth2_login_verifier.h +++ b/chrome/browser/chromeos/login/signin/oauth2_login_verifier.h
@@ -41,7 +41,7 @@ OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate* delegate, identity::IdentityManager* identity_manager, - const std::string& primary_account_id, + const CoreAccountId& primary_account_id, const std::string& oauthlogin_access_token); ~OAuth2LoginVerifier() override; @@ -58,12 +58,12 @@ const identity::AccountsInCookieJarInfo& accounts_in_cookie_jar_info, const GoogleServiceAuthError& error) override; - void OnAddAccountToCookieCompleted(const std::string& account_id, + void OnAddAccountToCookieCompleted(const CoreAccountId& account_id, const GoogleServiceAuthError& error); OAuth2LoginVerifier::Delegate* delegate_; identity::IdentityManager* identity_manager_; - const std::string primary_account_id_; + const CoreAccountId primary_account_id_; const std::string access_token_; base::WeakPtrFactory<OAuth2LoginVerifier> weak_ptr_factory_;
diff --git a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc index 15414697..475910f 100644 --- a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc +++ b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.cc
@@ -11,13 +11,13 @@ #include "ash/public/cpp/login_screen.h" #include "ash/public/cpp/login_screen_model.h" #include "ash/public/cpp/shell_window_ids.h" -#include "ash/public/cpp/tablet_mode.h" #include "chrome/browser/chromeos/login/ui/login_display_host_mojo.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/ash/login_screen_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" @@ -209,7 +209,7 @@ : controller_(controller), size_(gfx::Size(kGaiaDialogWidth, kGaiaDialogHeight)) { display_observer_.Add(display::Screen::GetScreen()); - tablet_mode_observer_.Add(ash::TabletMode::Get()); + tablet_mode_observer_.Add(TabletModeClient::Get()); keyboard_observer_.Add(ChromeKeyboardControllerClient::Get()); accel_map_[ui::Accelerator(
diff --git a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h index 423dd22..edac1eb 100644 --- a/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h +++ b/chrome/browser/chromeos/login/ui/oobe_ui_dialog_delegate.h
@@ -8,21 +8,19 @@ #include <string> #include "ash/public/cpp/login_types.h" -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" #include "base/strings/string16.h" #include "chrome/browser/chromeos/login/screens/error_screen.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" #include "components/web_modal/web_contents_modal_dialog_host.h" #include "ui/display/display_observer.h" #include "ui/web_dialogs/web_dialog_delegate.h" -namespace ash { -class TabletMode; -} +class TabletModeClient; namespace content { class WebContents; @@ -56,7 +54,7 @@ // V // clientView---->Widget's view hierarchy class OobeUIDialogDelegate : public display::DisplayObserver, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public ui::WebDialogDelegate, public ChromeKeyboardControllerClient::Observer, public CaptivePortalWindowProxy::Observer { @@ -95,7 +93,7 @@ // display::DisplayObserver: void OnDisplayMetricsChanged(const display::Display& display, uint32_t changed_metrics) override; - // ash::TabletModeToggleObserver: + // TabletModeClientObserver: void OnTabletModeToggled(bool enabled) override; // ui::WebDialogDelegate: @@ -137,7 +135,7 @@ ScopedObserver<display::Screen, display::DisplayObserver> display_observer_{ this}; - ScopedObserver<ash::TabletMode, ash::TabletModeToggleObserver> + ScopedObserver<TabletModeClient, TabletModeClientObserver> tablet_mode_observer_{this}; ScopedObserver<ChromeKeyboardControllerClient, ChromeKeyboardControllerClient::Observer>
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc index b3ca37ab..f1bfbb14 100644 --- a/chrome/browser/chromeos/login/wizard_controller.cc +++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -14,7 +14,6 @@ #include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/login_screen.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "base/callback_helpers.h" #include "base/command_line.h" @@ -65,7 +64,6 @@ #include "chrome/browser/chromeos/login/screens/network_screen.h" #include "chrome/browser/chromeos/login/screens/recommend_apps_screen.h" #include "chrome/browser/chromeos/login/screens/reset_screen.h" -#include "chrome/browser/chromeos/login/screens/supervision_onboarding_screen.h" #include "chrome/browser/chromeos/login/screens/supervision_transition_screen.h" #include "chrome/browser/chromeos/login/screens/sync_consent_screen.h" #include "chrome/browser/chromeos/login/screens/update_required_screen.h" @@ -90,6 +88,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/login_screen_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/webui/chromeos/login/app_downloading_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h" @@ -191,7 +190,7 @@ // Checks if device is in tablet mode, and that HID-detection screen is not // disabled by flag. bool CanShowHIDDetectionScreen() { - return !ash::TabletMode::Get()->InTabletMode() && + return !TabletModeClient::Get()->tablet_mode_enabled() && !base::CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kDisableHIDDetectionOnOOBE) && !base::CommandLine::ForCurrentProcess()->HasSwitch( @@ -507,10 +506,6 @@ oobe_ui->GetView<DeviceDisabledScreenHandler>())); append(std::make_unique<EncryptionMigrationScreen>( oobe_ui->GetView<EncryptionMigrationScreenHandler>())); - append(std::make_unique<SupervisionOnboardingScreen>( - oobe_ui->GetView<SupervisionOnboardingScreenHandler>(), - base::BindRepeating(&WizardController::OnSupervisionOnboardingScreenExit, - weak_factory_.GetWeakPtr()))); append(std::make_unique<SupervisionTransitionScreen>( oobe_ui->GetView<SupervisionTransitionScreenHandler>(), base::BindRepeating(&WizardController::OnSupervisionTransitionScreenExit, @@ -676,10 +671,6 @@ SetCurrentScreen(GetScreen(EncryptionMigrationScreenView::kScreenId)); } -void WizardController::ShowSupervisionOnboardingScreen() { - SetCurrentScreen(GetScreen(SupervisionOnboardingScreenView::kScreenId)); -} - void WizardController::ShowSupervisionTransitionScreen() { SetCurrentScreen(GetScreen(SupervisionTransitionScreenView::kScreenId)); } @@ -1078,7 +1069,15 @@ return; } - ShowSupervisionOnboardingScreen(); + // If the recommend app screen should be shown, show it after the user + // accepted the Arc TOS. Otherwise, advance to the assistant opt-in flow + // screen. + if (ShouldShowRecommendAppsScreen()) { + ShowRecommendAppsScreen(); + return; + } + + ShowAssistantOptInFlowScreen(); } void WizardController::OnRecommendAppsScreenExit( @@ -1138,31 +1137,6 @@ } } -void WizardController::OnSupervisionOnboardingScreenExit( - SupervisionOnboardingScreen::Result result) { - OnScreenExit(SupervisionOnboardingScreenView::kScreenId, - static_cast<int>(result)); - - // In this case, the user went through the whole Supervision Onboarding flow - // successfully, so we should just finish the OOBE/Login here. - // Note: This intentionally skips the other screens like Assistant and - // recommended app downloads. - if (result == SupervisionOnboardingScreen::Result::kFinished) { - OnOobeFlowFinished(); - return; - } - - // If the recommend app screen should be shown, show it after the user - // skipped the Supervision Onboarding. Otherwise, advance to the - // assistant opt-in flow screen. - if (ShouldShowRecommendAppsScreen()) { - ShowRecommendAppsScreen(); - return; - } - - ShowAssistantOptInFlowScreen(); -} - void WizardController::OnSupervisionTransitionScreenExit() { OnScreenExit(SupervisionTransitionScreenView::kScreenId, 0 /* exit_code */); @@ -1461,8 +1435,6 @@ ShowFingerprintSetupScreen(); } else if (screen == MarketingOptInScreenView::kScreenId) { ShowMarketingOptInScreen(); - } else if (screen == SupervisionOnboardingScreenView::kScreenId) { - ShowSupervisionOnboardingScreen(); } else if (screen == SupervisionTransitionScreenView::kScreenId) { ShowSupervisionTransitionScreen(); } else if (screen != OobeScreen::SCREEN_TEST_NO_WINDOW) {
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h index 1e38bfbb..77287f3 100644 --- a/chrome/browser/chromeos/login/wizard_controller.h +++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -30,7 +30,6 @@ #include "chrome/browser/chromeos/login/screens/kiosk_autolaunch_screen.h" #include "chrome/browser/chromeos/login/screens/network_screen.h" #include "chrome/browser/chromeos/login/screens/recommend_apps_screen.h" -#include "chrome/browser/chromeos/login/screens/supervision_onboarding_screen.h" #include "chrome/browser/chromeos/login/screens/terms_of_service_screen.h" #include "chrome/browser/chromeos/login/screens/update_screen.h" #include "chrome/browser/chromeos/policy/enrollment_config.h" @@ -179,7 +178,6 @@ void ShowHIDDetectionScreen(); void ShowDeviceDisabledScreen(); void ShowEncryptionMigrationScreen(); - void ShowSupervisionOnboardingScreen(); void ShowSupervisionTransitionScreen(); void ShowUpdateRequiredScreen(); void ShowAssistantOptInFlowScreen(); @@ -228,8 +226,6 @@ void OnMultiDeviceSetupScreenExit(); void OnResetScreenExit(); void OnDeviceModificationCanceled(); - void OnSupervisionOnboardingScreenExit( - SupervisionOnboardingScreen::Result result); void OnSupervisionTransitionScreenExit(); void OnOobeFlowFinished();
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc index 347ac05..76020bfa 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
@@ -30,6 +30,7 @@ #include "chrome/browser/chromeos/policy/remote_commands/user_commands_factory_chromeos.h" #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" #include "chrome/browser/invalidation/deprecated_profile_invalidation_provider_factory.h" +#include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/policy/cloud/remote_commands_invalidator_impl.h" @@ -121,6 +122,11 @@ UserCloudPolicyManagerChromeOSNotifierFactory() : BrowserContextKeyedServiceShutdownNotifierFactory( "UserRemoteCommandsInvalidator") { + if (base::FeatureList::IsEnabled(features::kPolicyFcmInvalidations)) { + DependsOn( + invalidation::ProfileInvalidationProviderFactory::GetInstance()); + return; + } DependsOn(invalidation::DeprecatedProfileInvalidationProviderFactory:: GetInstance()); } @@ -740,9 +746,17 @@ registrar_.Remove(this, chrome::NOTIFICATION_PROFILE_ADDED, content::Source<Profile>(profile_)); + // If true FCMInvalidationService will be used as invalidation service and + // TiclInvalidationService otherwise. + const bool is_fcm_enabled = + base::FeatureList::IsEnabled(features::kPolicyFcmInvalidations); + invalidation::ProfileInvalidationProvider* const invalidation_provider = - invalidation::DeprecatedProfileInvalidationProviderFactory::GetForProfile( - profile_); + is_fcm_enabled + ? invalidation::ProfileInvalidationProviderFactory::GetForProfile( + profile_) + : invalidation::DeprecatedProfileInvalidationProviderFactory:: + GetForProfile(profile_); if (!invalidation_provider) return; @@ -750,7 +764,12 @@ core()->StartRemoteCommandsService( std::make_unique<UserCommandsFactoryChromeOS>(profile_)); invalidator_ = std::make_unique<RemoteCommandsInvalidatorImpl>(core()); - invalidator_->Initialize(invalidation_provider->GetInvalidationService()); + + invalidator_->Initialize( + is_fcm_enabled + ? invalidation_provider->GetInvalidationServiceForCustomSender( + policy::kPolicyFCMInvalidationSenderID) + : invalidation_provider->GetInvalidationService()); shutdown_notifier_ = UserCloudPolicyManagerChromeOSNotifierFactory::GetInstance()
diff --git a/chrome/browser/chromeos/settings/device_identity_provider.cc b/chrome/browser/chromeos/settings/device_identity_provider.cc index 0eaf480..00776d9a 100644 --- a/chrome/browser/chromeos/settings/device_identity_provider.cc +++ b/chrome/browser/chromeos/settings/device_identity_provider.cc
@@ -23,11 +23,12 @@ token_service_->RemoveObserver(this); } -std::string DeviceIdentityProvider::GetActiveAccountId() { +CoreAccountId DeviceIdentityProvider::GetActiveAccountId() { return token_service_->GetRobotAccountId(); } -void DeviceIdentityProvider::SetActiveAccountId(const std::string& account_id) { +void DeviceIdentityProvider::SetActiveAccountId( + const CoreAccountId& account_id) { // On ChromeOs, the account shouldn't change during runtime, so no need to // alert observers here. if (!account_id.empty()) {
diff --git a/chrome/browser/chromeos/settings/device_identity_provider.h b/chrome/browser/chromeos/settings/device_identity_provider.h index 86780b0..a20dcec21 100644 --- a/chrome/browser/chromeos/settings/device_identity_provider.h +++ b/chrome/browser/chromeos/settings/device_identity_provider.h
@@ -21,7 +21,7 @@ ~DeviceIdentityProvider() override; // IdentityProvider: - std::string GetActiveAccountId() override; + CoreAccountId GetActiveAccountId() override; bool IsActiveAccountWithRefreshToken() override; std::unique_ptr<invalidation::ActiveAccountAccessTokenFetcher> FetchAccessToken( @@ -30,7 +30,7 @@ invalidation::ActiveAccountAccessTokenCallback callback) override; void InvalidateAccessToken(const OAuth2TokenService::ScopeSet& scopes, const std::string& access_token) override; - void SetActiveAccountId(const std::string& account_id) override; + void SetActiveAccountId(const CoreAccountId& account_id) override; // OAuth2TokenServiceObserver: void OnRefreshTokenAvailable(const CoreAccountId& account_id) override;
diff --git a/chrome/browser/complex_tasks/task_tab_helper.cc b/chrome/browser/complex_tasks/task_tab_helper.cc index b2ceaf3..e18ae1a6 100644 --- a/chrome/browser/complex_tasks/task_tab_helper.cc +++ b/chrome/browser/complex_tasks/task_tab_helper.cc
@@ -16,8 +16,8 @@ #include "content/public/browser/navigation_entry.h" #if defined(OS_ANDROID) +#include "chrome/android/chrome_jni_headers/TaskTabHelper_jni.h" #include "chrome/browser/android/tab_android.h" -#include "jni/TaskTabHelper_jni.h" using base::android::JavaParamRef; #endif // defined(OS_ANDROID)
diff --git a/chrome/browser/component_updater/vr_assets_component_installer.cc b/chrome/browser/component_updater/vr_assets_component_installer.cc index e37e7ad..c8242845 100644 --- a/chrome/browser/component_updater/vr_assets_component_installer.cc +++ b/chrome/browser/component_updater/vr_assets_component_installer.cc
@@ -27,7 +27,7 @@ #if defined(OS_ANDROID) #include "base/android/jni_android.h" -#include "jni/VrAssetsComponentInstaller_jni.h" +#include "chrome/android/chrome_jni_headers/VrAssetsComponentInstaller_jni.h" #endif // defined(OS_ANDROID) using component_updater::ComponentUpdateService;
diff --git a/chrome/browser/crash_upload_list/crash_upload_list_android.cc b/chrome/browser/crash_upload_list/crash_upload_list_android.cc index 3f05f3e..e881582 100644 --- a/chrome/browser/crash_upload_list/crash_upload_list_android.cc +++ b/chrome/browser/crash_upload_list/crash_upload_list_android.cc
@@ -12,7 +12,7 @@ #include "base/files/file_enumerator.h" #include "base/files/file_util.h" #include "base/metrics/histogram_macros_local.h" -#include "jni/MinidumpUploadService_jni.h" +#include "chrome/android/chrome_jni_headers/MinidumpUploadService_jni.h" #include "ui/base/text/bytes_formatting.h" namespace {
diff --git a/chrome/browser/data_reduction_proxy/data_reduction_promo_infobar_delegate_android.cc b/chrome/browser/data_reduction_proxy/data_reduction_promo_infobar_delegate_android.cc index 5303cda..59e3a06 100644 --- a/chrome/browser/data_reduction_proxy/data_reduction_promo_infobar_delegate_android.cc +++ b/chrome/browser/data_reduction_proxy/data_reduction_promo_infobar_delegate_android.cc
@@ -4,10 +4,10 @@ #include "chrome/browser/data_reduction_proxy/data_reduction_promo_infobar_delegate_android.h" +#include "chrome/android/chrome_jni_headers/DataReductionPromoInfoBarDelegate_jni.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/infobar.h" #include "content/public/browser/web_contents.h" -#include "jni/DataReductionPromoInfoBarDelegate_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/data_reduction_proxy/data_reduction_proxy_settings_android.cc b/chrome/browser/data_reduction_proxy/data_reduction_proxy_settings_android.cc index b3c9da2..781cd0ca 100644 --- a/chrome/browser/data_reduction_proxy/data_reduction_proxy_settings_android.cc +++ b/chrome/browser/data_reduction_proxy/data_reduction_proxy_settings_android.cc
@@ -14,6 +14,7 @@ #include "base/metrics/field_trial_params.h" #include "base/strings/string_piece.h" #include "base/values.h" +#include "chrome/android/chrome_jni_headers/DataReductionProxySettings_jni.h" #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings.h" #include "chrome/browser/data_reduction_proxy/data_reduction_proxy_chrome_settings_factory.h" #include "chrome/browser/profiles/profile.h" @@ -29,7 +30,6 @@ #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/previews/core/previews_experiments.h" -#include "jni/DataReductionProxySettings_jni.h" #include "net/base/proxy_server.h" #include "net/base/url_util.h" #include "url/gurl.h"
diff --git a/chrome/browser/dom_distiller/dom_distiller_service_factory_android.cc b/chrome/browser/dom_distiller/dom_distiller_service_factory_android.cc index 5e095bf..b67a85e 100644 --- a/chrome/browser/dom_distiller/dom_distiller_service_factory_android.cc +++ b/chrome/browser/dom_distiller/dom_distiller_service_factory_android.cc
@@ -5,11 +5,11 @@ #include "chrome/browser/dom_distiller/dom_distiller_service_factory_android.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/DomDistillerServiceFactory_jni.h" #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/dom_distiller/core/dom_distiller_service_android.h" -#include "jni/DomDistillerServiceFactory_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/dom_distiller/tab_utils_android.cc b/chrome/browser/dom_distiller/tab_utils_android.cc index 3d2729ff..53b20fc 100644 --- a/chrome/browser/dom_distiller/tab_utils_android.cc +++ b/chrome/browser/dom_distiller/tab_utils_android.cc
@@ -5,6 +5,7 @@ #include <string> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/DomDistillerTabUtils_jni.h" #include "chrome/browser/dom_distiller/tab_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -13,7 +14,6 @@ #include "components/url_formatter/url_formatter.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_constants.h" -#include "jni/DomDistillerTabUtils_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/engagement/site_engagement_service_android.cc b/chrome/browser/engagement/site_engagement_service_android.cc index 34458ca7..1d57cf9c 100644 --- a/chrome/browser/engagement/site_engagement_service_android.cc +++ b/chrome/browser/engagement/site_engagement_service_android.cc
@@ -6,9 +6,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/SiteEngagementService_jni.h" #include "chrome/browser/engagement/site_engagement_score.h" #include "chrome/browser/profiles/profile_android.h" -#include "jni/SiteEngagementService_jni.h" #include "url/gurl.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc index 6875c81e..7e81559 100644 --- a/chrome/browser/extensions/api/identity/identity_apitest.cc +++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -815,7 +815,7 @@ private: // identity::IdentityManager::DiagnosticsObserver: - void OnAccessTokenRequested(const std::string& account_id, + void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) override { if (on_access_token_requested_.is_null())
diff --git a/chrome/browser/extensions/api/messaging/native_process_launcher.cc b/chrome/browser/extensions/api/messaging/native_process_launcher.cc index 03c3e3009..a00f9a8 100644 --- a/chrome/browser/extensions/api/messaging/native_process_launcher.cc +++ b/chrome/browser/extensions/api/messaging/native_process_launcher.cc
@@ -220,20 +220,20 @@ base::PathService::Get(base::FILE_EXE, &exe_path); base::CommandLine reconnect_command_line(exe_path); - reconnect_command_line.AppendSwitch(switches::kNoStartupWindow); + reconnect_command_line.AppendSwitch(::switches::kNoStartupWindow); reconnect_command_line.AppendSwitchASCII( - switches::kNativeMessagingConnectHost, native_host_name); + ::switches::kNativeMessagingConnectHost, native_host_name); reconnect_command_line.AppendSwitchASCII( - switches::kNativeMessagingConnectExtension, origin.host()); - reconnect_command_line.AppendSwitchASCII(switches::kEnableFeatures, + ::switches::kNativeMessagingConnectExtension, origin.host()); + reconnect_command_line.AppendSwitchASCII(::switches::kEnableFeatures, features::kOnConnectNative.name); - reconnect_command_line.AppendSwitchPath(switches::kProfileDirectory, + reconnect_command_line.AppendSwitchPath(::switches::kProfileDirectory, profile_directory_.BaseName()); - reconnect_command_line.AppendSwitchPath(switches::kUserDataDir, + reconnect_command_line.AppendSwitchPath(::switches::kUserDataDir, profile_directory_.DirName()); #if defined(OS_WIN) reconnect_command_line.AppendArg( - switches::kPrefetchArgumentBrowserBackground); + ::switches::kPrefetchArgumentBrowserBackground); #endif base::Value args(base::Value::Type::LIST); args.GetList().reserve(reconnect_command_line.argv().size());
diff --git a/chrome/browser/extensions/system_display/display_info_provider_chromeos.cc b/chrome/browser/extensions/system_display/display_info_provider_chromeos.cc index 3e3bf31..a14bfc5 100644 --- a/chrome/browser/extensions/system_display/display_info_provider_chromeos.cc +++ b/chrome/browser/extensions/system_display/display_info_provider_chromeos.cc
@@ -7,13 +7,13 @@ #include <stdint.h> #include <cmath> -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/interfaces/constants.mojom.h" #include "ash/public/interfaces/cros_display_config.mojom.h" #include "base/bind.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "content/public/browser/system_connector.h" #include "extensions/common/api/system_display.h" #include "services/service_manager/public/cpp/connector.h" @@ -604,13 +604,17 @@ void DisplayInfoProviderChromeOS::StartObserving() { DisplayInfoProvider::StartObserving(); - ash::TabletMode::Get()->AddObserver(this); + TabletModeClient* client = TabletModeClient::Get(); + if (client) + client->AddObserver(this); } void DisplayInfoProviderChromeOS::StopObserving() { DisplayInfoProvider::StopObserving(); - ash::TabletMode::Get()->RemoveObserver(this); + TabletModeClient* client = TabletModeClient::Get(); + if (client) + client->RemoveObserver(this); } void DisplayInfoProviderChromeOS::OnTabletModeToggled(bool enabled) {
diff --git a/chrome/browser/extensions/system_display/display_info_provider_chromeos.h b/chrome/browser/extensions/system_display/display_info_provider_chromeos.h index 0b01a9c6..8742e39 100644 --- a/chrome/browser/extensions/system_display/display_info_provider_chromeos.h +++ b/chrome/browser/extensions/system_display/display_info_provider_chromeos.h
@@ -8,10 +8,10 @@ #include <map> #include <memory> -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "ash/public/interfaces/cros_display_config.mojom.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "extensions/browser/api/system_display/display_info_provider.h" namespace service_manager { @@ -21,7 +21,7 @@ namespace extensions { class DisplayInfoProviderChromeOS : public DisplayInfoProvider, - public ash::TabletModeToggleObserver { + public TabletModeClientObserver { public: explicit DisplayInfoProviderChromeOS(service_manager::Connector* connector); ~DisplayInfoProviderChromeOS() override; @@ -57,7 +57,7 @@ void StartObserving() override; void StopObserving() override; - // ash::TabletModeToggleObserver implementation. + // TabletModeClientObserver implementation. void OnTabletModeToggled(bool enabled) override; private:
diff --git a/chrome/browser/extensions/system_display/display_info_provider_chromeos_unittest.cc b/chrome/browser/extensions/system_display/display_info_provider_chromeos_unittest.cc index 82459eb..6795758 100644 --- a/chrome/browser/extensions/system_display/display_info_provider_chromeos_unittest.cc +++ b/chrome/browser/extensions/system_display/display_info_provider_chromeos_unittest.cc
@@ -10,16 +10,16 @@ #include "ash/display/screen_orientation_controller.h" #include "ash/display/screen_orientation_controller_test_api.h" #include "ash/public/cpp/ash_switches.h" -#include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "ash/public/interfaces/constants.mojom.h" #include "ash/shell.h" +#include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "base/bind.h" #include "base/command_line.h" #include "base/macros.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "chrome/browser/extensions/system_display/display_info_provider_chromeos.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/test/base/chrome_ash_test_base.h" #include "content/public/test/test_service_manager_context.h" #include "extensions/common/api/system_display.h" @@ -79,10 +79,20 @@ DisplayInfoProvider::InitializeForTesting( new DisplayInfoProviderChromeOS(connector_.get())); + tablet_mode_client_ = std::make_unique<TabletModeClient>(); + tablet_mode_client_->Init(); + // Wait for TabletModeController to take its initial state from the power // manager. base::RunLoop().RunUntilIdle(); - EXPECT_FALSE(ash::TabletMode::Get()->InTabletMode()); + EXPECT_FALSE(ash::Shell::Get()->tablet_mode_controller()->InTabletMode()); + } + + void TearDown() override { + ChromeAshTestBase::TearDown(); + // To match ChromeBrowserMainExtraPartsAsh, shut down the TabletModeClient + // after Shell. + tablet_mode_client_.reset(); } void AddCrosDisplayConfigControllerBinding( @@ -115,7 +125,9 @@ } void EnableTabletMode(bool enable) { - ash::ShellTestApi().SetTabletModeEnabledForTest(enable); + ash::TabletModeController* controller = + ash::Shell::Get()->tablet_mode_controller(); + controller->SetEnabledForTest(enable); } display::DisplayManager* GetDisplayManager() const { @@ -193,6 +205,7 @@ content::TestServiceManagerContext service_manager_context_; std::unique_ptr<service_manager::Connector> connector_; std::unique_ptr<ash::CrosDisplayConfig> cros_display_config_; + std::unique_ptr<TabletModeClient> tablet_mode_client_; DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); };
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 34c658e9..2c5939e 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -483,12 +483,12 @@ { "name": "cookie-deprecation-messages", "owners": [ "chlily", "aarontag" ], - "expiry_milestone": 82 + "expiry_milestone": 85 }, { "name": "cookies-without-same-site-must-be-secure", "owners": [ "chlily", "morlovich" ], - "expiry_milestone": 80 + "expiry_milestone": 83 }, { "name": "cros-regions-mode", @@ -2677,7 +2677,7 @@ { "name": "same-site-by-default-cookies", "owners": [ "chlily", "morlovich" ], - "expiry_milestone": 80 + "expiry_milestone": 83 }, { "name": "scheduler-configuration",
diff --git a/chrome/browser/history/android/sqlite_cursor.cc b/chrome/browser/history/android/sqlite_cursor.cc index 62d7ab7..094b62a 100644 --- a/chrome/browser/history/android/sqlite_cursor.cc +++ b/chrome/browser/history/android/sqlite_cursor.cc
@@ -9,10 +9,10 @@ #include "base/bind.h" #include "base/logging.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/SQLiteCursor_jni.h" #include "components/history/core/browser/android/android_history_types.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "jni/SQLiteCursor_jni.h" #include "sql/statement.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/installable/installed_webapp_bridge.cc b/chrome/browser/installable/installed_webapp_bridge.cc index 48eac0c..adaa98a 100644 --- a/chrome/browser/installable/installed_webapp_bridge.cc +++ b/chrome/browser/installable/installed_webapp_bridge.cc
@@ -8,8 +8,8 @@ #include "base/android/jni_string.h" #include "base/android/jni_utils.h" +#include "chrome/android/chrome_jni_headers/InstalledWebappBridge_jni.h" #include "components/content_settings/core/common/content_settings.h" -#include "jni/InstalledWebappBridge_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/invalidation/invalidation_service_factory_android.cc b/chrome/browser/invalidation/invalidation_service_factory_android.cc index 999faa4..cc736d9 100644 --- a/chrome/browser/invalidation/invalidation_service_factory_android.cc +++ b/chrome/browser/invalidation/invalidation_service_factory_android.cc
@@ -5,12 +5,12 @@ #include "chrome/browser/invalidation/invalidation_service_factory_android.h" #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/InvalidationServiceFactory_jni.h" #include "chrome/browser/invalidation/deprecated_profile_invalidation_provider_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "components/invalidation/impl/invalidation_service_android.h" #include "components/invalidation/impl/profile_invalidation_provider.h" -#include "jni/InvalidationServiceFactory_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/lifetime/application_lifetime_android.cc b/chrome/browser/lifetime/application_lifetime_android.cc index fbff5146..54b993d 100644 --- a/chrome/browser/lifetime/application_lifetime_android.cc +++ b/chrome/browser/lifetime/application_lifetime_android.cc
@@ -8,13 +8,13 @@ #include "base/android/jni_android.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/ApplicationLifetime_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_context.h" -#include "jni/ApplicationLifetime_jni.h" namespace chrome {
diff --git a/chrome/browser/media/DEPS b/chrome/browser/media/DEPS index 4ba0b3c8..4439343 100644 --- a/chrome/browser/media/DEPS +++ b/chrome/browser/media/DEPS
@@ -10,6 +10,7 @@ "+services/data_decoder/data_decoder_service.h", "+services/data_decoder/public", "+services/device/public/mojom", + "+chrome/android/features/media_router/jni_headers", ] specific_include_rules = {
diff --git a/chrome/browser/media/android/remote/DEPS b/chrome/browser/media/android/remote/DEPS index 92f0a1f..8f63995 100644 --- a/chrome/browser/media/android/remote/DEPS +++ b/chrome/browser/media/android/remote/DEPS
@@ -1,3 +1,7 @@ +include_rules = { + "+chrome/android/features/media_router/jni_headers", +} + specific_include_rules = { # TODO(aberent): Fix layering violation crbug.com/396828 "remote_media_player_manager\.": [ @@ -8,4 +12,4 @@ "remote_media_player_manager\.cc": [ "+content/common/media/media_player_messages_android.h", ], -} \ No newline at end of file +}
diff --git a/chrome/browser/media/android/remote/flinging_controller_bridge.cc b/chrome/browser/media/android/remote/flinging_controller_bridge.cc index 3e3154b..fe91ec0 100644 --- a/chrome/browser/media/android/remote/flinging_controller_bridge.cc +++ b/chrome/browser/media/android/remote/flinging_controller_bridge.cc
@@ -6,8 +6,8 @@ #include "base/android/jni_string.h" #include "base/time/time.h" -#include "jni/FlingingControllerBridge_jni.h" -#include "jni/MediaStatusBridge_jni.h" +#include "chrome/android/features/media_router/jni_headers/FlingingControllerBridge_jni.h" +#include "chrome/android/features/media_router/jni_headers/MediaStatusBridge_jni.h" namespace media_router {
diff --git a/chrome/browser/media/android/remote/record_cast_action.cc b/chrome/browser/media/android/remote/record_cast_action.cc index 89bbfc9..dc26ad2 100644 --- a/chrome/browser/media/android/remote/record_cast_action.cc +++ b/chrome/browser/media/android/remote/record_cast_action.cc
@@ -4,7 +4,7 @@ #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" -#include "jni/RecordCastAction_jni.h" +#include "chrome/android/chrome_jni_headers/RecordCastAction_jni.h" #include "media/base/container_names.h" using base::android::JavaParamRef;
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 b9d8775..178e7dff 100644 --- a/chrome/browser/media/android/router/media_router_android_bridge.cc +++ b/chrome/browser/media/android/router/media_router_android_bridge.cc
@@ -6,9 +6,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/features/media_router/jni_headers/ChromeMediaRouter_jni.h" #include "chrome/browser/media/android/remote/flinging_controller_bridge.h" #include "chrome/browser/media/android/router/media_router_android.h" -#include "jni/ChromeMediaRouter_jni.h" #include "media/base/media_controller.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/media/android/router/media_router_dialog_controller_android.cc b/chrome/browser/media/android/router/media_router_dialog_controller_android.cc index 63f47704..27bf2f2 100644 --- a/chrome/browser/media/android/router/media_router_dialog_controller_android.cc +++ b/chrome/browser/media/android/router/media_router_dialog_controller_android.cc
@@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/features/media_router/jni_headers/ChromeMediaRouterDialogController_jni.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/media/android/router/media_router_android.h" #include "chrome/browser/media/router/media_router.h" @@ -24,7 +25,6 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "device/vr/buildflags/buildflags.h" -#include "jni/ChromeMediaRouterDialogController_jni.h" #include "third_party/blink/public/mojom/presentation/presentation.mojom.h" using base::android::ConvertJavaStringToUTF8;
diff --git a/chrome/browser/metrics/android_metrics_provider.cc b/chrome/browser/metrics/android_metrics_provider.cc index 619bd76..a20e9b54 100644 --- a/chrome/browser/metrics/android_metrics_provider.cc +++ b/chrome/browser/metrics/android_metrics_provider.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/metrics/android_metrics_provider.h" -#include "jni/NotificationSystemStatusUtil_jni.h" +#include "chrome/android/chrome_jni_headers/NotificationSystemStatusUtil_jni.h" #include "base/metrics/histogram_macros.h" #include "base/system/sys_info.h"
diff --git a/chrome/browser/notifications/notification_channels_provider_android.cc b/chrome/browser/notifications/notification_channels_provider_android.cc index 589747c5..f16715d 100644 --- a/chrome/browser/notifications/notification_channels_provider_android.cc +++ b/chrome/browser/notifications/notification_channels_provider_android.cc
@@ -18,6 +18,7 @@ #include "base/task/post_task.h" #include "base/time/default_clock.h" #include "base/values.h" +#include "chrome/android/chrome_jni_headers/NotificationSettingsBridge_jni.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" @@ -34,7 +35,6 @@ #include "components/search_engines/template_url_service.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "jni/NotificationSettingsBridge_jni.h" #include "url/gurl.h" #include "url/origin.h" #include "url/url_constants.h"
diff --git a/chrome/browser/notifications/notification_handler.h b/chrome/browser/notifications/notification_handler.h index 877f5bb..0d145d4f 100644 --- a/chrome/browser/notifications/notification_handler.h +++ b/chrome/browser/notifications/notification_handler.h
@@ -21,6 +21,9 @@ class NotificationHandler { public: // Type of notifications that a handler can be responsible for. + // A Java counterpart will be generated for this enum. + // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.notifications + // GENERATED_JAVA_CLASS_NAME_OVERRIDE: NotificationType enum class Type { WEB_PERSISTENT = 0, WEB_NON_PERSISTENT = 1,
diff --git a/chrome/browser/notifications/notification_platform_bridge_android.cc b/chrome/browser/notifications/notification_platform_bridge_android.cc index cc4bf7a..cf0d031e 100644 --- a/chrome/browser/notifications/notification_platform_bridge_android.cc +++ b/chrome/browser/notifications/notification_platform_bridge_android.cc
@@ -17,6 +17,8 @@ #include "base/strings/nullable_string16.h" #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/ActionInfo_jni.h" +#include "chrome/android/chrome_jni_headers/NotificationPlatformBridge_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/notifications/notification_common.h" #include "chrome/browser/notifications/notification_display_service_impl.h" @@ -28,8 +30,6 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/persistent_notification_status.h" -#include "jni/ActionInfo_jni.h" -#include "jni/NotificationPlatformBridge_jni.h" #include "third_party/blink/public/common/notifications/platform_notification_data.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/android/java_bitmap.h" @@ -103,6 +103,25 @@ return ScopedJavaLocalRef<jobjectArray>(env, actions); } +constexpr jint NotificationTypeToJava( + NotificationHandler::Type notification_type) { + return static_cast<jint>(notification_type); +} + +constexpr NotificationHandler::Type JavaToNotificationType( + jint notification_type) { + constexpr jint kMinValue = + NotificationTypeToJava(NotificationHandler::Type::WEB_PERSISTENT); + constexpr jint kMaxValue = + NotificationTypeToJava(NotificationHandler::Type::MAX); + + if (notification_type >= kMinValue && notification_type <= kMaxValue) + return static_cast<NotificationHandler::Type>(notification_type); + + NOTREACHED(); + return NotificationHandler::Type::WEB_PERSISTENT; +} + } // namespace // Called by the Java side when a notification event has been received, but the @@ -138,6 +157,7 @@ JNIEnv* env, const JavaParamRef<jobject>& java_object, const JavaParamRef<jstring>& java_notification_id, + jint java_notification_type, const JavaParamRef<jstring>& java_origin, const JavaParamRef<jstring>& java_scope_url, const JavaParamRef<jstring>& java_profile_id, @@ -167,11 +187,13 @@ ProfileManager* profile_manager = g_browser_process->profile_manager(); DCHECK(profile_manager); + NotificationHandler::Type notification_type = + JavaToNotificationType(java_notification_type); + profile_manager->LoadProfile( profile_id, incognito, base::Bind(&NotificationDisplayServiceImpl::ProfileLoadedCallback, - NotificationCommon::OPERATION_CLICK, - NotificationHandler::Type::WEB_PERSISTENT, origin, + NotificationCommon::OPERATION_CLICK, notification_type, origin, notification_id, std::move(action_index), std::move(reply), base::nullopt /* by_user */)); } @@ -199,6 +221,7 @@ JNIEnv* env, const JavaParamRef<jobject>& java_object, const JavaParamRef<jstring>& java_notification_id, + jint java_notification_type, const JavaParamRef<jstring>& java_origin, const JavaParamRef<jstring>& java_profile_id, jboolean incognito, @@ -213,11 +236,13 @@ ProfileManager* profile_manager = g_browser_process->profile_manager(); DCHECK(profile_manager); + NotificationHandler::Type notification_type = + JavaToNotificationType(java_notification_type); + profile_manager->LoadProfile( profile_id, incognito, base::Bind(&NotificationDisplayServiceImpl::ProfileLoadedCallback, - NotificationCommon::OPERATION_CLOSE, - NotificationHandler::Type::WEB_PERSISTENT, + NotificationCommon::OPERATION_CLOSE, notification_type, GURL(ConvertJavaStringToUTF8(env, java_origin)), notification_id, base::nullopt /* action index */, base::nullopt /* reply */, by_user)); @@ -228,14 +253,11 @@ Profile* profile, const message_center::Notification& notification, std::unique_ptr<NotificationCommon::Metadata> metadata) { + DCHECK(CanHandleType(notification_type)); + JNIEnv* env = AttachCurrentThread(); GURL origin_url(notification.origin_url().GetOrigin()); - - // TODO(miguelg): Store the notification type in java instead of assuming it's - // persistent once/if non persistent notifications are ever implemented on - // Android. - DCHECK_EQ(notification_type, NotificationHandler::Type::WEB_PERSISTENT); GURL scope_url(PersistentNotificationMetadata::From(metadata.get()) ->service_worker_scope); if (!scope_url.is_valid()) @@ -277,11 +299,14 @@ ScopedJavaLocalRef<jstring> j_profile_id = ConvertUTF8ToJavaString(env, GetProfileId(profile)); + jint j_notification_type = NotificationTypeToJava(notification_type); + Java_NotificationPlatformBridge_displayNotification( - env, java_object_, j_notification_id, j_origin, j_scope_url, j_profile_id, - profile->IsOffTheRecord(), title, body, image, notification_icon, badge, - vibration_pattern, notification.timestamp().ToJavaTime(), - notification.renotify(), notification.silent(), actions); + env, java_object_, j_notification_id, j_notification_type, j_origin, + j_scope_url, j_profile_id, profile->IsOffTheRecord(), title, body, image, + notification_icon, badge, vibration_pattern, + notification.timestamp().ToJavaTime(), notification.renotify(), + notification.silent(), actions); regenerated_notification_infos_[notification.id()] = RegeneratedNotificationInfo(scope_url, base::nullopt);
diff --git a/chrome/browser/notifications/notification_platform_bridge_android.h b/chrome/browser/notifications/notification_platform_bridge_android.h index 45d183f..d6fc39d 100644 --- a/chrome/browser/notifications/notification_platform_bridge_android.h +++ b/chrome/browser/notifications/notification_platform_bridge_android.h
@@ -43,6 +43,7 @@ JNIEnv* env, const base::android::JavaParamRef<jobject>& java_object, const base::android::JavaParamRef<jstring>& java_notification_id, + jint java_notification_type, const base::android::JavaParamRef<jstring>& java_origin, const base::android::JavaParamRef<jstring>& java_scope_url, const base::android::JavaParamRef<jstring>& java_profile_id, @@ -64,6 +65,7 @@ JNIEnv* env, const base::android::JavaParamRef<jobject>& java_object, const base::android::JavaParamRef<jstring>& java_notification_id, + jint java_notification_type, const base::android::JavaParamRef<jstring>& java_origin, const base::android::JavaParamRef<jstring>& java_profile_id, jboolean incognito,
diff --git a/chrome/browser/notifications/notification_trigger_scheduler_android.cc b/chrome/browser/notifications/notification_trigger_scheduler_android.cc index 4b48bccd6..846d6258 100644 --- a/chrome/browser/notifications/notification_trigger_scheduler_android.cc +++ b/chrome/browser/notifications/notification_trigger_scheduler_android.cc
@@ -4,9 +4,9 @@ #include "chrome/browser/notifications/notification_trigger_scheduler_android.h" +#include "chrome/android/chrome_jni_headers/NotificationTriggerScheduler_jni.h" #include "chrome/browser/notifications/platform_notification_service_impl.h" #include "content/public/browser/browser_thread.h" -#include "jni/NotificationTriggerScheduler_jni.h" using content::BrowserThread;
diff --git a/chrome/browser/notifications/scheduler/DEPS b/chrome/browser/notifications/scheduler/DEPS index c80012b5..c1d3ca8 100644 --- a/chrome/browser/notifications/scheduler/DEPS +++ b/chrome/browser/notifications/scheduler/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+chrome/android/chrome_jni_headers", ]
diff --git a/chrome/browser/notifications/scheduler/display_agent_android.cc b/chrome/browser/notifications/scheduler/display_agent_android.cc index 8ab0a7a..01c8288 100644 --- a/chrome/browser/notifications/scheduler/display_agent_android.cc +++ b/chrome/browser/notifications/scheduler/display_agent_android.cc
@@ -6,12 +6,12 @@ #include "base/android/jni_string.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/DisplayAgent_jni.h" #include "chrome/browser/notifications/scheduler/notification_schedule_service_factory.h" #include "chrome/browser/notifications/scheduler/public/notification_schedule_service.h" #include "chrome/browser/notifications/scheduler/public/user_action_handler.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" -#include "jni/DisplayAgent_jni.h" #include "ui/gfx/android/java_bitmap.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/notifications/scheduler/notification_background_task_scheduler_android.cc b/chrome/browser/notifications/scheduler/notification_background_task_scheduler_android.cc index 60fe6fd..a6b0595 100644 --- a/chrome/browser/notifications/scheduler/notification_background_task_scheduler_android.cc +++ b/chrome/browser/notifications/scheduler/notification_background_task_scheduler_android.cc
@@ -6,12 +6,12 @@ #include "base/android/jni_android.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/NotificationSchedulerTask_jni.h" #include "chrome/browser/notifications/scheduler/notification_schedule_service_factory.h" #include "chrome/browser/notifications/scheduler/public/notification_background_task_scheduler.h" #include "chrome/browser/notifications/scheduler/public/notification_schedule_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" -#include "jni/NotificationSchedulerTask_jni.h" // static void JNI_NotificationSchedulerTask_OnStartTask(
diff --git a/chrome/browser/offline_pages/android/DEPS b/chrome/browser/offline_pages/android/DEPS index ff20cbfd..cf1c484 100644 --- a/chrome/browser/offline_pages/android/DEPS +++ b/chrome/browser/offline_pages/android/DEPS
@@ -2,4 +2,5 @@ # This folder contains Android-specific code. "+base/android", "+chrome/browser/android", + "+chrome/android/test_support_jni_headers", ]
diff --git a/chrome/browser/offline_pages/android/auto_fetch_notifier.cc b/chrome/browser/offline_pages/android/auto_fetch_notifier.cc index 5f0527f1..b44426a7 100644 --- a/chrome/browser/offline_pages/android/auto_fetch_notifier.cc +++ b/chrome/browser/offline_pages/android/auto_fetch_notifier.cc
@@ -9,11 +9,11 @@ #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/AutoFetchNotifier_jni.h" #include "chrome/browser/offline_pages/android/offline_page_auto_fetcher_service.h" #include "chrome/browser/offline_pages/android/offline_page_auto_fetcher_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" -#include "jni/AutoFetchNotifier_jni.h" namespace offline_pages {
diff --git a/chrome/browser/offline_pages/android/background_scheduler_bridge.cc b/chrome/browser/offline_pages/android/background_scheduler_bridge.cc index ad16416..bb52f54 100644 --- a/chrome/browser/offline_pages/android/background_scheduler_bridge.cc +++ b/chrome/browser/offline_pages/android/background_scheduler_bridge.cc
@@ -7,6 +7,7 @@ #include "base/android/callback_android.h" #include "base/android/scoped_java_ref.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/BackgroundSchedulerBridge_jni.h" #include "chrome/browser/offline_pages/android/offline_page_auto_fetcher_service_factory.h" #include "chrome/browser/offline_pages/offline_page_model_factory.h" #include "chrome/browser/offline_pages/request_coordinator_factory.h" @@ -15,7 +16,6 @@ #include "components/offline_pages/core/background/device_conditions.h" #include "components/offline_pages/core/background/offliner.h" #include "components/offline_pages/core/background/request_coordinator.h" -#include "jni/BackgroundSchedulerBridge_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaGlobalRef;
diff --git a/chrome/browser/offline_pages/android/cct_origin_observer.cc b/chrome/browser/offline_pages/android/cct_origin_observer.cc index 2edba95..2dfabc7b 100644 --- a/chrome/browser/offline_pages/android/cct_origin_observer.cc +++ b/chrome/browser/offline_pages/android/cct_origin_observer.cc
@@ -6,8 +6,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/CctOfflinePageModelObserver_jni.h" #include "components/offline_pages/core/offline_page_feature.h" -#include "jni/CctOfflinePageModelObserver_jni.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/offline_pages/android/cct_request_observer.cc b/chrome/browser/offline_pages/android/cct_request_observer.cc index 1ff1d993..c6e6b509 100644 --- a/chrome/browser/offline_pages/android/cct_request_observer.cc +++ b/chrome/browser/offline_pages/android/cct_request_observer.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_int_wrapper.h" #include "base/android/jni_string.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/CCTRequestStatus_jni.h" #include "chrome/browser/android/app_hooks.h" #include "components/offline_pages/core/client_namespace_constants.h" #include "components/offline_pages/core/offline_page_feature.h" -#include "jni/CCTRequestStatus_jni.h" namespace offline_pages { namespace {
diff --git a/chrome/browser/offline_pages/android/downloads/offline_page_download_bridge.cc b/chrome/browser/offline_pages/android/downloads/offline_page_download_bridge.cc index 187544e..2c212ad 100644 --- a/chrome/browser/offline_pages/android/downloads/offline_page_download_bridge.cc +++ b/chrome/browser/offline_pages/android/downloads/offline_page_download_bridge.cc
@@ -15,6 +15,7 @@ #include "base/guid.h" #include "base/logging.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/OfflinePageDownloadBridge_jni.h" #include "chrome/browser/android/download/download_controller_base.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/image_fetcher/image_decoder_impl.h" @@ -47,7 +48,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" -#include "jni/OfflinePageDownloadBridge_jni.h" #include "net/base/filename_util.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "url/gurl.h"
diff --git a/chrome/browser/offline_pages/android/evaluation/offline_page_evaluation_bridge.cc b/chrome/browser/offline_pages/android/evaluation/offline_page_evaluation_bridge.cc index e867740..8c20658 100644 --- a/chrome/browser/offline_pages/android/evaluation/offline_page_evaluation_bridge.cc +++ b/chrome/browser/offline_pages/android/evaluation/offline_page_evaluation_bridge.cc
@@ -16,6 +16,7 @@ #include "base/bind.h" #include "base/sequenced_task_runner.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/OfflinePageEvaluationBridge_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/offline_pages/android/background_scheduler_bridge.h" #include "chrome/browser/offline_pages/android/evaluation/evaluation_test_scheduler.h" @@ -36,7 +37,6 @@ #include "components/offline_pages/core/offline_page_item.h" #include "components/offline_pages/core/offline_page_model.h" #include "content/public/browser/browser_context.h" -#include "jni/OfflinePageEvaluationBridge_jni.h" using base::android::ConvertJavaStringToUTF8; using base::android::ConvertUTF16ToJavaString;
diff --git a/chrome/browser/offline_pages/android/offline_page_bridge.cc b/chrome/browser/offline_pages/android/offline_page_bridge.cc index deed342..77d3c8f 100644 --- a/chrome/browser/offline_pages/android/offline_page_bridge.cc +++ b/chrome/browser/offline_pages/android/offline_page_bridge.cc
@@ -23,6 +23,8 @@ #include "base/strings/string_number_conversions.h" #include "base/task/post_task.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/OfflinePageBridge_jni.h" +#include "chrome/android/chrome_jni_headers/SavePageRequest_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/offline_pages/offline_page_mhtml_archiver.h" #include "chrome/browser/offline_pages/offline_page_model_factory.h" @@ -47,8 +49,6 @@ #include "components/offline_pages/core/request_header/offline_page_header.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/web_contents.h" -#include "jni/OfflinePageBridge_jni.h" -#include "jni/SavePageRequest_jni.h" #include "net/base/filename_util.h" using base::android::ConvertJavaStringToUTF8;
diff --git a/chrome/browser/offline_pages/android/offline_pages_download_manager_bridge.cc b/chrome/browser/offline_pages/android/offline_pages_download_manager_bridge.cc index 46584954..6fd0b124 100644 --- a/chrome/browser/offline_pages/android/offline_pages_download_manager_bridge.cc +++ b/chrome/browser/offline_pages/android/offline_pages_download_manager_bridge.cc
@@ -8,7 +8,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" -#include "jni/OfflinePagesDownloadManagerBridge_jni.h" +#include "chrome/android/chrome_jni_headers/OfflinePagesDownloadManagerBridge_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/offline_pages/android/offline_test_util_jni.cc b/chrome/browser/offline_pages/android/offline_test_util_jni.cc index 6baad1ea..2f76339 100644 --- a/chrome/browser/offline_pages/android/offline_test_util_jni.cc +++ b/chrome/browser/offline_pages/android/offline_test_util_jni.cc
@@ -12,6 +12,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/json/json_writer.h" +#include "chrome/android/test_support_jni_headers/OfflineTestUtil_jni.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/offline_pages/android/offline_page_bridge.h" #include "chrome/browser/offline_pages/offline_page_model_factory.h" @@ -25,7 +26,6 @@ #include "components/offline_pages/core/prefetch/prefetch_prefs.h" #include "content/public/browser/network_service_instance.h" #include "content/public/test/url_loader_interceptor.h" -#include "jni/OfflineTestUtil_jni.h" // Below is the native implementation of OfflineTestUtil.java.
diff --git a/chrome/browser/offline_pages/android/prefetch_background_task_android.cc b/chrome/browser/offline_pages/android/prefetch_background_task_android.cc index 989729b..bb8abe71 100644 --- a/chrome/browser/offline_pages/android/prefetch_background_task_android.cc +++ b/chrome/browser/offline_pages/android/prefetch_background_task_android.cc
@@ -7,13 +7,13 @@ #include "base/logging.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/PrefetchBackgroundTask_jni.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" #include "chrome/browser/profiles/profile_key.h" #include "components/offline_pages/core/prefetch/prefetch_background_task.h" #include "components/offline_pages/core/prefetch/prefetch_dispatcher.h" #include "components/offline_pages/core/prefetch/prefetch_service.h" -#include "jni/PrefetchBackgroundTask_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaGlobalRef;
diff --git a/chrome/browser/offline_pages/android/prefetch_background_task_scheduler_android.cc b/chrome/browser/offline_pages/android/prefetch_background_task_scheduler_android.cc index dc1a7d0..e69e601 100644 --- a/chrome/browser/offline_pages/android/prefetch_background_task_scheduler_android.cc +++ b/chrome/browser/offline_pages/android/prefetch_background_task_scheduler_android.cc
@@ -6,7 +6,7 @@ #include <memory> -#include "jni/PrefetchBackgroundTaskScheduler_jni.h" +#include "chrome/android/chrome_jni_headers/PrefetchBackgroundTaskScheduler_jni.h" namespace offline_pages {
diff --git a/chrome/browser/offline_pages/android/prefetch_configuration_impl_android.cc b/chrome/browser/offline_pages/android/prefetch_configuration_impl_android.cc index f91ec98..2a6d1d1 100644 --- a/chrome/browser/offline_pages/android/prefetch_configuration_impl_android.cc +++ b/chrome/browser/offline_pages/android/prefetch_configuration_impl_android.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/PrefetchConfiguration_jni.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -12,7 +13,6 @@ #include "components/offline_pages/core/offline_page_feature.h" #include "components/offline_pages/core/prefetch/prefetch_prefs.h" #include "components/offline_pages/core/prefetch/prefetch_service.h" -#include "jni/PrefetchConfiguration_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc index fbdccb5..ca7eac9b 100644 --- a/chrome/browser/offline_pages/android/prefetch_test_bridge.cc +++ b/chrome/browser/offline_pages/android/prefetch_test_bridge.cc
@@ -7,6 +7,7 @@ #include "base/android/jni_string.h" #include "base/android/jni_utils.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/test_support_jni_headers/PrefetchTestBridge_jni.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/image_fetcher/image_fetcher_service_factory.h" #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" @@ -20,7 +21,6 @@ #include "components/offline_pages/core/prefetch/prefetch_prefs.h" #include "components/offline_pages/core/prefetch/prefetch_service.h" #include "components/offline_pages/core/prefetch/prefetch_types.h" -#include "jni/PrefetchTestBridge_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/offline_pages/android/prefetched_pages_notifier_android.cc b/chrome/browser/offline_pages/android/prefetched_pages_notifier_android.cc index f4eaa5d..da14716 100644 --- a/chrome/browser/offline_pages/android/prefetched_pages_notifier_android.cc +++ b/chrome/browser/offline_pages/android/prefetched_pages_notifier_android.cc
@@ -5,9 +5,9 @@ #include "chrome/browser/offline_pages/prefetch/prefetched_pages_notifier.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/OfflineNotificationBackgroundTask_jni.h" +#include "chrome/android/chrome_jni_headers/PrefetchedPagesNotifier_jni.h" #include "components/offline_pages/core/offline_page_feature.h" -#include "jni/OfflineNotificationBackgroundTask_jni.h" -#include "jni/PrefetchedPagesNotifier_jni.h" #include "url/gurl.h" using base::android::ConvertUTF8ToJavaString;
diff --git a/chrome/browser/page_load_metrics/observers/android_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/android_page_load_metrics_observer.cc index fdaaf71b..6cfe524 100644 --- a/chrome/browser/page_load_metrics/observers/android_page_load_metrics_observer.cc +++ b/chrome/browser/page_load_metrics/observers/android_page_load_metrics_observer.cc
@@ -10,11 +10,11 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/PageLoadMetrics_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" -#include "jni/PageLoadMetrics_jni.h" #include "services/network/public/cpp/network_quality_tracker.h" #include "url/gurl.h"
diff --git a/chrome/browser/password_manager/account_chooser_dialog_android.cc b/chrome/browser/password_manager/account_chooser_dialog_android.cc index 887cbe3..61200aa 100644 --- a/chrome/browser/password_manager/account_chooser_dialog_android.cc +++ b/chrome/browser/password_manager/account_chooser_dialog_android.cc
@@ -10,6 +10,7 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/macros.h" +#include "chrome/android/chrome_jni_headers/AccountChooserDialog_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/password_manager/credential_android.h" @@ -23,7 +24,6 @@ #include "components/password_manager/core/browser/password_ui_utils.h" #include "components/password_manager/core/common/credential_manager_types.h" #include "content/public/browser/storage_partition.h" -#include "jni/AccountChooserDialog_jni.h" #include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/android/java_bitmap.h"
diff --git a/chrome/browser/password_manager/auto_signin_first_run_dialog_android.cc b/chrome/browser/password_manager/auto_signin_first_run_dialog_android.cc index 70d7f44..5b0d4b0 100644 --- a/chrome/browser/password_manager/auto_signin_first_run_dialog_android.cc +++ b/chrome/browser/password_manager/auto_signin_first_run_dialog_android.cc
@@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/AutoSigninFirstRunDialog_jni.h" #include "chrome/browser/password_manager/chrome_password_manager_client.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service_factory.h" @@ -16,7 +17,6 @@ #include "components/password_manager/core/browser/password_manager_constants.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/strings/grit/components_strings.h" -#include "jni/AutoSigninFirstRunDialog_jni.h" #include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/range/range.h"
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc index 536697c0..b643f12 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -100,6 +100,7 @@ #if defined(OS_ANDROID) #include "chrome/browser/android/preferences/preferences_launcher.h" #include "chrome/browser/android/tab_android.h" +#include "chrome/browser/autofill/manual_filling_controller.h" #include "chrome/browser/password_manager/account_chooser_dialog_android.h" #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h" #include "chrome/browser/password_manager/generated_password_saved_infobar_delegate_android.h" @@ -1059,6 +1060,8 @@ password_manager::PasswordManagerDriver* driver, autofill::mojom::FocusedFieldType focused_field_type) { #if defined(OS_ANDROID) + ManualFillingController::GetOrCreate(web_contents()) + ->NotifyFocusedInputChanged(focused_field_type); password_manager::ContentPasswordManagerDriver* content_driver = static_cast<password_manager::ContentPasswordManagerDriver*>(driver); if (!PasswordAccessoryControllerImpl::ShouldAcceptFocusEvent(
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc index 1cf40ce..7a292a8 100644 --- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc +++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc
@@ -18,6 +18,9 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" +#include "chrome/browser/autofill/mock_address_accessory_controller.h" +#include "chrome/browser/autofill/mock_manual_filling_view.h" +#include "chrome/browser/autofill/mock_password_accessory_controller.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h" @@ -752,8 +755,12 @@ std::unique_ptr<password_manager::ContentPasswordManagerDriver> CreateContentPasswordManagerDriver(content::RenderFrameHost* rfh); + void CreateManualFillingController(content::WebContents* web_contents); + private: autofill::TestAutofillClient test_autofill_client_; + NiceMock<MockPasswordAccessoryController> mock_pwd_controller_; + NiceMock<MockAddressAccessoryController> mock_address_controller_; }; std::unique_ptr<password_manager::ContentPasswordManagerDriver> @@ -763,8 +770,17 @@ rfh, GetClient(), &test_autofill_client_); } +void ChromePasswordManagerClientAndroidTest::CreateManualFillingController( + content::WebContents* web_contents) { + ManualFillingControllerImpl::CreateForWebContentsForTesting( + web_contents, mock_pwd_controller_.AsWeakPtr(), + mock_address_controller_.AsWeakPtr(), + std::make_unique<NiceMock<MockManualFillingView>>()); +} + TEST_F(ChromePasswordManagerClientAndroidTest, FocusedInputChangedNoFrameFillableField) { + CreateManualFillingController(web_contents()); ASSERT_FALSE(web_contents()->GetFocusedFrame()); ChromePasswordManagerClient* client = GetClient(); @@ -781,6 +797,7 @@ TEST_F(ChromePasswordManagerClientAndroidTest, FocusedInputChangedNoFrameNoField) { + CreateManualFillingController(web_contents()); std::unique_ptr<password_manager::ContentPasswordManagerDriver> driver = CreateContentPasswordManagerDriver(main_rfh()); @@ -793,13 +810,6 @@ ChromePasswordManagerClient* client = GetClient(); - NiceMock<MockAddressAccessoryController> mock_address_controller_; - ManualFillingControllerImpl::CreateForWebContentsForTesting( - web_contents(), - PasswordAccessoryControllerImpl::GetOrCreate(web_contents())->AsWeakPtr(), - mock_address_controller_.AsWeakPtr(), - std::make_unique<MockManualFillingView>()); - ASSERT_FALSE(web_contents()->GetFocusedFrame()); ASSERT_TRUE(pwd_generation_controller->GetActiveFrameDriver()); client->FocusedInputChanged(driver.get(), FocusedFieldType::kUnknown); @@ -815,6 +825,7 @@ // Set up the main frame. NavigateAndCommit(GURL("https://example.com")); FocusWebContentsOnMainFrame(); + CreateManualFillingController(web_contents()); content::RenderFrameHost* subframe = content::RenderFrameHostTester::For(main_rfh())->AppendChild("subframe"); @@ -833,13 +844,7 @@ TEST_F(ChromePasswordManagerClientAndroidTest, FocusedInputChangedGoodFrame) { ChromePasswordManagerClient* client = GetClient(); - - NiceMock<MockAddressAccessoryController> mock_address_controller_; - ManualFillingControllerImpl::CreateForWebContentsForTesting( - web_contents(), - PasswordAccessoryControllerImpl::GetOrCreate(web_contents())->AsWeakPtr(), - mock_address_controller_.AsWeakPtr(), - std::make_unique<MockManualFillingView>()); + CreateManualFillingController(web_contents()); std::unique_ptr<password_manager::ContentPasswordManagerDriver> driver = CreateContentPasswordManagerDriver(main_rfh());
diff --git a/chrome/browser/password_manager/credential_android.cc b/chrome/browser/password_manager/credential_android.cc index c5a68d0..088d7406 100644 --- a/chrome/browser/password_manager/credential_android.cc +++ b/chrome/browser/password_manager/credential_android.cc
@@ -6,8 +6,8 @@ #include "base/android/jni_string.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/Credential_jni.h" #include "chrome/grit/generated_resources.h" -#include "jni/Credential_jni.h" #include "ui/base/l10n/l10n_util.h" #include "url/origin.h"
diff --git a/chrome/browser/password_manager/password_accessory_controller_impl.cc b/chrome/browser/password_manager/password_accessory_controller_impl.cc index 54b36cf..a4c9961 100644 --- a/chrome/browser/password_manager/password_accessory_controller_impl.cc +++ b/chrome/browser/password_manager/password_accessory_controller_impl.cc
@@ -257,20 +257,11 @@ bool has_suggestions = !info_to_add.empty(); - GetManualFillingController()->RefreshSuggestionsForField( - focused_field_type, + GetManualFillingController()->RefreshSuggestions( autofill::CreateAccessorySheetData(autofill::AccessoryTabType::PASSWORDS, GetTitle(has_suggestions, origin), std::move(info_to_add), std::move(footer_commands_to_add))); - - if (is_password_field) { - GetManualFillingController()->ShowWhenKeyboardIsVisible( - FillingSource::PASSWORD_FALLBACKS); - } else { - GetManualFillingController()->DeactivateFillingSource( - FillingSource::PASSWORD_FALLBACKS); - } } void PasswordAccessoryControllerImpl::OnGenerationRequested(bool manual) {
diff --git a/chrome/browser/password_manager/password_accessory_controller_impl_unittest.cc b/chrome/browser/password_manager/password_accessory_controller_impl_unittest.cc index b2ccddd3..561514e 100644 --- a/chrome/browser/password_manager/password_accessory_controller_impl_unittest.cc +++ b/chrome/browser/password_manager/password_accessory_controller_impl_unittest.cc
@@ -189,8 +189,7 @@ url::Origin::Create(GURL(kExampleSite))); EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -198,8 +197,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -211,16 +208,13 @@ EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(no_user_str(), no_user_str(), false, false) .AppendField(ASCIIToUTF16("S3cur3"), password_for_str(no_user_str()), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -234,8 +228,7 @@ EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Alf"), ASCIIToUTF16("Alf"), false, @@ -258,8 +251,6 @@ .AppendField(ASCIIToUTF16("M3h"), password_for_str("Zebra"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -272,8 +263,7 @@ // Pretend that any input in the same frame was focused. EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -281,8 +271,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -292,14 +280,10 @@ controller()->SavePasswordsForOrigin({}, url::Origin::Create(GURL(kExampleSite))); - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, - PasswordAccessorySheetDataBuilder(passwords_empty_str(kExampleDomain)) - .Build())); EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + RefreshSuggestions(PasswordAccessorySheetDataBuilder( + passwords_empty_str(kExampleDomain)) + .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -326,8 +310,7 @@ // suggestion. EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -335,8 +318,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -345,8 +326,7 @@ // |is_password_field| set to true, all suggestions should become interactive. EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillablePasswordField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -354,8 +334,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, true) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - ShowWhenKeyboardIsVisible(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillablePasswordField, /*is_manual_generation_available=*/false); @@ -366,8 +344,7 @@ url::Origin::Create(GURL(kExampleSite))); EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -375,8 +352,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -385,8 +360,7 @@ url::Origin::Create(GURL(kExampleSite))); EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Alf"), ASCIIToUTF16("Alf"), false, @@ -394,8 +368,6 @@ .AppendField(ASCIIToUTF16("M3lm4k"), password_for_str("Alf"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -408,8 +380,7 @@ // suggestions. EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -417,22 +388,16 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); // Pretend that the focus was lost or moved to an unfillable field. Now, only // the empty state message should be sent. - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kUnfillableElement, - PasswordAccessorySheetDataBuilder(passwords_empty_str(kExampleDomain)) - .Build())); EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + RefreshSuggestions(PasswordAccessorySheetDataBuilder( + passwords_empty_str(kExampleDomain)) + .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kUnfillableElement, /*is_manual_generation_available=*/false); @@ -445,8 +410,7 @@ url::Origin::Create(GURL(kExampleSite))); EXPECT_CALL( mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, + RefreshSuggestions( PasswordAccessorySheetDataBuilder(passwords_title_str(kExampleDomain)) .AddUserInfo() .AppendField(ASCIIToUTF16("Ben"), ASCIIToUTF16("Ben"), false, @@ -454,8 +418,6 @@ .AppendField(ASCIIToUTF16("S3cur3"), password_for_str("Ben"), true, false) .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -465,14 +427,11 @@ controller()->DidNavigateMainFrame(); // Now, only the empty state message should be sent. - EXPECT_CALL(mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kUnfillableElement, - PasswordAccessorySheetDataBuilder( - passwords_empty_str("random.other-site.org")) - .Build())); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL( + mock_manual_filling_controller_, + RefreshSuggestions(PasswordAccessorySheetDataBuilder( + passwords_empty_str("random.other-site.org")) + .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kUnfillableElement, /*is_manual_generation_available=*/false); @@ -481,11 +440,7 @@ TEST_F(PasswordAccessoryControllerTest, FetchFaviconForCurrentUrl) { base::MockCallback<base::OnceCallback<void(const gfx::Image&)>> mock_callback; - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillableUsernameField, _)); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -508,11 +463,7 @@ TEST_F(PasswordAccessoryControllerTest, RequestsFaviconsOnceForOneOrigin) { base::MockCallback<base::OnceCallback<void(const gfx::Image&)>> mock_callback; - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillableUsernameField, _)); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -555,11 +506,7 @@ non_empty_result.icon_url = GURL(kExampleSite); // Populate the cache by requesting a favicon. - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillableUsernameField, _)); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -590,11 +537,7 @@ controller()->DidNavigateMainFrame(); NavigateAndCommit(GURL(kExampleSite)); // Same origin as intially. controller()->DidNavigateMainFrame(); - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillableUsernameField, _)); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/false); @@ -617,12 +560,7 @@ TEST_F(PasswordAccessoryControllerTest, NoFaviconCallbacksWhenOriginChanges) { base::MockCallback<base::OnceCallback<void(const gfx::Image&)>> mock_callback; - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillableUsernameField, _)) - .Times(2); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + EXPECT_CALL(mock_manual_filling_controller_, RefreshSuggestions(_)).Times(2); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, false); @@ -647,8 +585,6 @@ }); EXPECT_CALL(mock_callback, Run).Times(0); controller()->GetFavicon(kIconSize, mock_callback.Get()); - EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, false); @@ -673,12 +609,8 @@ autofill::AccessoryAction::GENERATE_PASSWORD_MANUAL) .AppendFooterCommand(manage_passwords_str(), autofill::AccessoryAction::MANAGE_PASSWORDS); - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField(FocusedFieldType::kFillablePasswordField, - std::move(data_builder).Build())); EXPECT_CALL(mock_manual_filling_controller_, - ShowWhenKeyboardIsVisible(FillingSource::PASSWORD_FALLBACKS)); + RefreshSuggestions(std::move(data_builder).Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillablePasswordField, /*is_manual_generation_available=*/true); @@ -687,14 +619,10 @@ TEST_F(PasswordAccessoryControllerTest, NoGenerationCommandIfNotPasswordField) { controller()->SavePasswordsForOrigin({}, url::Origin::Create(GURL(kExampleSite))); - EXPECT_CALL( - mock_manual_filling_controller_, - RefreshSuggestionsForField( - FocusedFieldType::kFillableUsernameField, - PasswordAccessorySheetDataBuilder(passwords_empty_str(kExampleDomain)) - .Build())); EXPECT_CALL(mock_manual_filling_controller_, - DeactivateFillingSource(FillingSource::PASSWORD_FALLBACKS)); + RefreshSuggestions(PasswordAccessorySheetDataBuilder( + passwords_empty_str(kExampleDomain)) + .Build())); controller()->RefreshSuggestionsForField( FocusedFieldType::kFillableUsernameField, /*is_manual_generation_available=*/true);
diff --git a/chrome/browser/password_manager/password_store_factory.cc b/chrome/browser/password_manager/password_store_factory.cc index cd1d05d4..e509b888 100644 --- a/chrome/browser/password_manager/password_store_factory.cc +++ b/chrome/browser/password_manager/password_store_factory.cc
@@ -44,7 +44,7 @@ #if defined(OS_WIN) #include "chrome/browser/password_manager/password_manager_util_win.h" #elif defined(OS_MACOSX) -#include "chrome/browser/password_manager/password_store_mac.h" +// Use default store. #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) // Don't do anything. We're going to use the default store. #elif defined(USE_X11) @@ -178,9 +178,7 @@ scoped_refptr<PasswordStore> ps; #if defined(OS_WIN) ps = new password_manager::PasswordStoreDefault(std::move(login_db)); -#elif defined(OS_MACOSX) - ps = new PasswordStoreMac(std::move(login_db), profile->GetPrefs()); -#elif defined(OS_CHROMEOS) || defined(OS_ANDROID) +#elif defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_MACOSX) // For now, we use PasswordStoreDefault. We might want to make a native // backend for PasswordStoreX (see below) in the future though. ps = new password_manager::PasswordStoreDefault(std::move(login_db));
diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc deleted file mode 100644 index effbb927..0000000 --- a/chrome/browser/password_manager/password_store_mac.cc +++ /dev/null
@@ -1,71 +0,0 @@ -// Copyright 2015 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/password_manager/password_store_mac.h" -#include "base/bind.h" -#include "base/metrics/histogram_macros.h" -#include "components/os_crypt/os_crypt.h" -#include "components/password_manager/core/common/password_manager_pref_names.h" - -using password_manager::MigrationStatus; - -PasswordStoreMac::PasswordStoreMac( - std::unique_ptr<password_manager::LoginDatabase> login_db, - PrefService* prefs) - : PasswordStoreDefault(std::move(login_db)), - initial_status_(MigrationStatus::NOT_STARTED) { - migration_status_.Init(password_manager::prefs::kKeychainMigrationStatus, - prefs); -} - -bool PasswordStoreMac::Init( - const syncer::SyncableService::StartSyncFlare& flare, - PrefService* prefs) { - initial_status_ = static_cast<MigrationStatus>(migration_status_.GetValue()); - return PasswordStoreDefault::Init(flare, prefs); -} - -void PasswordStoreMac::ShutdownOnUIThread() { - PasswordStoreDefault::ShutdownOnUIThread(); - - // Unsubscribe the observer, otherwise it's too late in the destructor. - migration_status_.Destroy(); -} - -PasswordStoreMac::~PasswordStoreMac() = default; - -bool PasswordStoreMac::InitOnBackgroundSequence( - const syncer::SyncableService::StartSyncFlare& flare) { - if (!PasswordStoreDefault::InitOnBackgroundSequence(flare)) - return false; - - if (!OSCrypt::IsEncryptionAvailable()) - return false; - - if (login_db() && (initial_status_ == MigrationStatus::NOT_STARTED || - initial_status_ == MigrationStatus::FAILED_ONCE || - initial_status_ == MigrationStatus::FAILED_TWICE)) { - // Migration isn't possible due to Chrome changing the certificate. Just - // drop the entries in the DB because they don't have passwords anyway. - login_db()->RemoveLoginsCreatedBetween(base::Time(), base::Time(), - /*changes=*/nullptr); - initial_status_ = MigrationStatus::MIGRATION_STOPPED; - main_task_runner()->PostTask( - FROM_HERE, base::BindOnce(&PasswordStoreMac::UpdateStatusPref, this, - initial_status_)); - } - - UMA_HISTOGRAM_ENUMERATION( - "PasswordManager.KeychainMigration.Status", - static_cast<int>(initial_status_), - static_cast<int>(MigrationStatus::MIGRATION_STATUS_COUNT)); - - return true; -} - -void PasswordStoreMac::UpdateStatusPref(MigrationStatus status) { - // The method can be called after ShutdownOnUIThread(). - if (migration_status_.prefs()) - migration_status_.SetValue(static_cast<int>(status)); -}
diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h deleted file mode 100644 index 3c7431e..0000000 --- a/chrome/browser/password_manager/password_store_mac.h +++ /dev/null
@@ -1,54 +0,0 @@ -// Copyright 2015 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_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ -#define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_ - -#include <memory> - -#include "base/macros.h" -#include "components/password_manager/core/browser/keychain_migration_status_mac.h" -#include "components/password_manager/core/browser/password_store.h" -#include "components/password_manager/core/browser/password_store_default.h" -#include "components/prefs/pref_member.h" - -namespace password_manager { -class LoginDatabase; -} - -// Password store for Mac. -class PasswordStoreMac : public password_manager::PasswordStoreDefault { - public: - PasswordStoreMac(std::unique_ptr<password_manager::LoginDatabase> login_db, - PrefService* prefs); - - // PasswordStore: - bool Init(const syncer::SyncableService::StartSyncFlare& flare, - PrefService* prefs) override; - void ShutdownOnUIThread() override; - -#if defined(UNIT_TEST) - password_manager::LoginDatabase* login_metadata_db() { return login_db(); } -#endif - - private: - ~PasswordStoreMac() override; - - // PasswordStore: - bool InitOnBackgroundSequence( - const syncer::SyncableService::StartSyncFlare& flare) override; - - // Writes status to the prefs. - void UpdateStatusPref(password_manager::MigrationStatus status); - - // Bound to the pref containing migration status for the profile. - IntegerPrefMember migration_status_; - - // Initial migration status when the class is initialized. - password_manager::MigrationStatus initial_status_; - - DISALLOW_COPY_AND_ASSIGN(PasswordStoreMac); -}; - -#endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_H_
diff --git a/chrome/browser/password_manager/password_store_mac_unittest.cc b/chrome/browser/password_manager/password_store_mac_unittest.cc deleted file mode 100644 index ff81b2f2..0000000 --- a/chrome/browser/password_manager/password_store_mac_unittest.cc +++ /dev/null
@@ -1,312 +0,0 @@ -// Copyright 2015 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/password_manager/password_store_mac.h" - -#include <utility> - -#include "base/files/scoped_temp_dir.h" -#include "base/macros.h" -#include "base/scoped_observer.h" -#include "base/strings/utf_string_conversions.h" -#include "base/test/metrics/histogram_tester.h" -#include "base/test/scoped_task_environment.h" -#include "chrome/browser/prefs/browser_prefs.h" -#include "components/os_crypt/os_crypt_mocker.h" -#include "components/password_manager/core/browser/login_database.h" -#include "components/password_manager/core/browser/password_manager_test_utils.h" -#include "components/password_manager/core/browser/password_store_consumer.h" -#include "components/password_manager/core/common/password_manager_pref_names.h" -#include "components/sync_preferences/testing_pref_service_syncable.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -using autofill::PasswordForm; -using password_manager::MigrationStatus; -using password_manager::PasswordStore; -using password_manager::PasswordStoreChange; -using password_manager::PasswordStoreChangeList; -using testing::_; -using testing::ElementsAre; -using testing::IsEmpty; -using testing::Pointee; - -class MockPasswordStoreConsumer - : public password_manager::PasswordStoreConsumer { - public: - MockPasswordStoreConsumer() = default; - - const std::vector<std::unique_ptr<PasswordForm>>& forms() const { - return forms_; - } - - private: - void OnGetPasswordStoreResults( - std::vector<std::unique_ptr<PasswordForm>> results) override { - forms_.swap(results); - } - - std::vector<std::unique_ptr<PasswordForm>> forms_; - - DISALLOW_COPY_AND_ASSIGN(MockPasswordStoreConsumer); -}; - -class MockPasswordStoreObserver - : public password_manager::PasswordStore::Observer { - public: - explicit MockPasswordStoreObserver(PasswordStoreMac* password_store) - : guard_(this) { - guard_.Add(password_store); - } - MOCK_METHOD1(OnLoginsChanged, - void(const password_manager::PasswordStoreChangeList& changes)); - - private: - ScopedObserver<PasswordStoreMac, MockPasswordStoreObserver> guard_; - - DISALLOW_COPY_AND_ASSIGN(MockPasswordStoreObserver); -}; - -// A mock LoginDatabase that simulates a failing Init() method. -class BadLoginDatabase : public password_manager::LoginDatabase { - public: - BadLoginDatabase() : password_manager::LoginDatabase(base::FilePath()) {} - ~BadLoginDatabase() override {} - - // LoginDatabase: - bool Init() override { return false; } - - private: - DISALLOW_COPY_AND_ASSIGN(BadLoginDatabase); -}; - -class PasswordStoreMacTest : public testing::TestWithParam<MigrationStatus> { - public: - PasswordStoreMacTest(); - ~PasswordStoreMacTest() override; - - void CreateAndInitPasswordStore( - std::unique_ptr<password_manager::LoginDatabase> login_db); - - void ClosePasswordStore(); - - // Wait for all the previously enqueued operations to finish. - void FinishAsyncProcessing(); - - // Add/Update/Remove |form| and verify the operation succeeded. - void AddForm(const PasswordForm& form); - void UpdateForm(const PasswordForm& form); - void RemoveForm(const PasswordForm& form); - - base::FilePath test_login_db_file_path() const; - - // Returns the expected migration status after the password store was inited. - MigrationStatus GetTargetStatus() const; - - password_manager::LoginDatabase* login_db() const { - return store_->login_metadata_db(); - } - - PasswordStoreMac* store() { return store_.get(); } - - protected: - base::test::ScopedTaskEnvironment scoped_task_environment_; - base::ScopedTempDir db_dir_; - scoped_refptr<PasswordStoreMac> store_; - sync_preferences::TestingPrefServiceSyncable testing_prefs_; -}; - -PasswordStoreMacTest::PasswordStoreMacTest() { - EXPECT_TRUE(db_dir_.CreateUniqueTempDir()); - RegisterUserProfilePrefs(testing_prefs_.registry()); - testing_prefs_.SetInteger(password_manager::prefs::kKeychainMigrationStatus, - static_cast<int>(GetParam())); - // Ensure that LoginDatabase will use the mock keychain if it needs to - // encrypt/decrypt a password. - OSCryptMocker::SetUp(); -} - -PasswordStoreMacTest::~PasswordStoreMacTest() { - ClosePasswordStore(); - OSCryptMocker::TearDown(); -} - -void PasswordStoreMacTest::CreateAndInitPasswordStore( - std::unique_ptr<password_manager::LoginDatabase> login_db) { - store_ = new PasswordStoreMac(std::move(login_db), &testing_prefs_); - ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr)); -} - -void PasswordStoreMacTest::ClosePasswordStore() { - if (!store_) - return; - store_->ShutdownOnUIThread(); - store_ = nullptr; -} - -void PasswordStoreMacTest::FinishAsyncProcessing() { - scoped_task_environment_.RunUntilIdle(); -} - -base::FilePath PasswordStoreMacTest::test_login_db_file_path() const { - return db_dir_.GetPath().Append(FILE_PATH_LITERAL("login.db")); -} - -MigrationStatus PasswordStoreMacTest::GetTargetStatus() const { - if (GetParam() == MigrationStatus::NOT_STARTED || - GetParam() == MigrationStatus::FAILED_ONCE || - GetParam() == MigrationStatus::FAILED_TWICE) { - return MigrationStatus::MIGRATION_STOPPED; - } - return GetParam(); -} - -void PasswordStoreMacTest::AddForm(const PasswordForm& form) { - MockPasswordStoreObserver mock_observer(store()); - - password_manager::PasswordStoreChangeList list; - list.push_back(password_manager::PasswordStoreChange( - password_manager::PasswordStoreChange::ADD, form)); - EXPECT_CALL(mock_observer, OnLoginsChanged(list)); - store()->AddLogin(form); - FinishAsyncProcessing(); -} - -void PasswordStoreMacTest::UpdateForm(const PasswordForm& form) { - MockPasswordStoreObserver mock_observer(store()); - - password_manager::PasswordStoreChangeList list; - list.push_back(password_manager::PasswordStoreChange( - password_manager::PasswordStoreChange::UPDATE, form)); - EXPECT_CALL(mock_observer, OnLoginsChanged(list)); - store()->UpdateLogin(form); - FinishAsyncProcessing(); -} - -void PasswordStoreMacTest::RemoveForm(const PasswordForm& form) { - MockPasswordStoreObserver mock_observer(store()); - - password_manager::PasswordStoreChangeList list; - list.push_back(password_manager::PasswordStoreChange( - password_manager::PasswordStoreChange::REMOVE, form)); - EXPECT_CALL(mock_observer, OnLoginsChanged(list)); - store()->RemoveLogin(form); - FinishAsyncProcessing(); -} - -// ----------- Tests ------------- - -TEST_P(PasswordStoreMacTest, Sanity) { - base::HistogramTester histogram_tester; - - CreateAndInitPasswordStore(std::make_unique<password_manager::LoginDatabase>( - test_login_db_file_path())); - FinishAsyncProcessing(); - ClosePasswordStore(); - - int status = testing_prefs_.GetInteger( - password_manager::prefs::kKeychainMigrationStatus); - EXPECT_EQ(static_cast<int>(GetTargetStatus()), status); - histogram_tester.ExpectUniqueSample( - "PasswordManager.KeychainMigration.Status", status, 1); -} - -TEST_P(PasswordStoreMacTest, StartAndStop) { - base::HistogramTester histogram_tester; - // PasswordStore::ShutdownOnUIThread() immediately follows - // PasswordStore::Init(). The message loop isn't running in between. Anyway, - // PasswordStore should not collapse. - CreateAndInitPasswordStore(std::make_unique<password_manager::LoginDatabase>( - test_login_db_file_path())); - ClosePasswordStore(); - - FinishAsyncProcessing(); - - histogram_tester.ExpectUniqueSample( - "PasswordManager.KeychainMigration.Status", - static_cast<int>(GetTargetStatus()), 1); -} - -TEST_P(PasswordStoreMacTest, OperationsOnABadDatabaseSilentlyFail) { - // Verify that operations on a PasswordStore with a bad database cause no - // explosions, but fail without side effect, return no data and trigger no - // notifications. - CreateAndInitPasswordStore(std::make_unique<BadLoginDatabase>()); - FinishAsyncProcessing(); - EXPECT_FALSE(login_db()); - - // The store should outlive the observer. - scoped_refptr<PasswordStoreMac> store_refptr = store(); - MockPasswordStoreObserver mock_observer(store()); - EXPECT_CALL(mock_observer, OnLoginsChanged(_)).Times(0); - - // Add a new autofillable login + a blacklisted login. - password_manager::PasswordFormData www_form_data = { - PasswordForm::Scheme::kHtml, - "http://www.facebook.com/", - "http://www.facebook.com/index.html", - "login", - L"username", - L"password", - L"submit", - L"not_joe_user", - L"12345", - true, - 1}; - std::unique_ptr<PasswordForm> form = FillPasswordFormWithData(www_form_data); - std::unique_ptr<PasswordForm> blacklisted_form(new PasswordForm(*form)); - blacklisted_form->signon_realm = "http://foo.example.com"; - blacklisted_form->origin = GURL("http://foo.example.com/origin"); - blacklisted_form->action = GURL("http://foo.example.com/action"); - blacklisted_form->blacklisted_by_user = true; - store()->AddLogin(*form); - store()->AddLogin(*blacklisted_form); - FinishAsyncProcessing(); - - // Get all logins; autofillable logins; blacklisted logins. - MockPasswordStoreConsumer mock_consumer; - store()->GetLogins(PasswordStore::FormDigest(*form), &mock_consumer); - FinishAsyncProcessing(); - EXPECT_THAT(mock_consumer.forms(), IsEmpty()); - - store()->GetAutofillableLogins(&mock_consumer); - FinishAsyncProcessing(); - EXPECT_THAT(mock_consumer.forms(), IsEmpty()); - - store()->GetAllLogins(&mock_consumer); - FinishAsyncProcessing(); - EXPECT_THAT(mock_consumer.forms(), IsEmpty()); - - // Report metrics. - store()->ReportMetrics("Test Username", true, false); - FinishAsyncProcessing(); - - // Change the login. - form->password_value = base::ASCIIToUTF16("a different password"); - store()->UpdateLogin(*form); - FinishAsyncProcessing(); - - // Delete one login; a range of logins. - store()->RemoveLogin(*form); - store()->RemoveLoginsCreatedBetween(base::Time(), base::Time::Max(), - base::Closure()); - FinishAsyncProcessing(); - - // Verify no notifications are fired during shutdown either. - ClosePasswordStore(); -} - -INSTANTIATE_TEST_SUITE_P(, - PasswordStoreMacTest, - testing::Values(MigrationStatus::NOT_STARTED, - MigrationStatus::MIGRATED, - MigrationStatus::FAILED_ONCE, - MigrationStatus::FAILED_TWICE, - MigrationStatus::MIGRATED_DELETED, - MigrationStatus::MIGRATED_PARTIALLY, - MigrationStatus::MIGRATION_STOPPED)); - -} // namespace
diff --git a/chrome/browser/payments/android/can_make_payment_query_android.cc b/chrome/browser/payments/android/can_make_payment_query_android.cc index 8c1ed0ee..1778ecad3 100644 --- a/chrome/browser/payments/android/can_make_payment_query_android.cc +++ b/chrome/browser/payments/android/can_make_payment_query_android.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/CanMakePaymentQuery_jni.h" #include "components/payments/content/can_make_payment_query_factory.h" #include "components/payments/core/can_make_payment_query.h" #include "content/public/browser/web_contents.h" -#include "jni/CanMakePaymentQuery_jni.h" #include "url/gurl.h" namespace payments {
diff --git a/chrome/browser/payments/android/journey_logger_android.cc b/chrome/browser/payments/android/journey_logger_android.cc index bf7b757..17fac09d 100644 --- a/chrome/browser/payments/android/journey_logger_android.cc +++ b/chrome/browser/payments/android/journey_logger_android.cc
@@ -5,9 +5,9 @@ #include "chrome/browser/payments/android/journey_logger_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/JourneyLogger_jni.h" #include "components/ukm/content/source_url_recorder.h" #include "content/public/browser/web_contents.h" -#include "jni/JourneyLogger_jni.h" namespace payments { namespace {
diff --git a/chrome/browser/payments/android/payment_manifest_web_data_service_android.cc b/chrome/browser/payments/android/payment_manifest_web_data_service_android.cc index 0ccfed8..11bd471 100644 --- a/chrome/browser/payments/android/payment_manifest_web_data_service_android.cc +++ b/chrome/browser/payments/android/payment_manifest_web_data_service_android.cc
@@ -10,11 +10,11 @@ #include "base/android/jni_string.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" +#include "chrome/android/chrome_jni_headers/PaymentManifestWebDataService_jni.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/web_data_service_factory.h" #include "components/keyed_service/core/service_access_type.h" #include "components/webdata/common/web_data_results.h" -#include "jni/PaymentManifestWebDataService_jni.h" namespace payments {
diff --git a/chrome/browser/payments/android/ssl_validity_checker_android.cc b/chrome/browser/payments/android/ssl_validity_checker_android.cc index 5743f8e4..4a96c6f 100644 --- a/chrome/browser/payments/android/ssl_validity_checker_android.cc +++ b/chrome/browser/payments/android/ssl_validity_checker_android.cc
@@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/SslValidityChecker_jni.h" #include "chrome/browser/payments/ssl_validity_checker.h" #include "content/public/browser/web_contents.h" -#include "jni/SslValidityChecker_jni.h" namespace payments {
diff --git a/chrome/browser/permissions/permission_dialog_delegate.cc b/chrome/browser/permissions/permission_dialog_delegate.cc index 9f98da2d..07b8c71 100644 --- a/chrome/browser/permissions/permission_dialog_delegate.cc +++ b/chrome/browser/permissions/permission_dialog_delegate.cc
@@ -10,6 +10,8 @@ #include "base/android/jni_string.h" #include "base/feature_list.h" #include "build/build_config.h" +#include "chrome/android/chrome_jni_headers/PermissionDialogController_jni.h" +#include "chrome/android/chrome_jni_headers/PermissionDialogDelegate_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/profiles/profile.h" @@ -17,8 +19,6 @@ #include "chrome/grit/generated_resources.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" -#include "jni/PermissionDialogController_jni.h" -#include "jni/PermissionDialogDelegate_jni.h" #include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/permissions/permission_uma_util.cc b/chrome/browser/permissions/permission_uma_util.cc index 97ae8e1..50768c0 100644 --- a/chrome/browser/permissions/permission_uma_util.cc +++ b/chrome/browser/permissions/permission_uma_util.cc
@@ -28,7 +28,7 @@ #if defined(OS_ANDROID) #include "base/android/jni_string.h" -#include "jni/PermissionUmaUtil_jni.h" +#include "chrome/android/chrome_jni_headers/PermissionUmaUtil_jni.h" #endif // UMA keys need to be statically initialized so plain function would not
diff --git a/chrome/browser/permissions/permission_update_infobar_delegate_android.cc b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc index 165c9f7a..a74fc6a6 100644 --- a/chrome/browser/permissions/permission_update_infobar_delegate_android.cc +++ b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc
@@ -8,14 +8,14 @@ #include <utility> #include "base/android/jni_array.h" -#include "chrome/browser/android/preferences/pref_service_bridge.h" +#include "chrome/android/chrome_jni_headers/PermissionUpdateInfoBarDelegate_jni.h" #include "chrome/browser/android/android_theme_resources.h" +#include "chrome/browser/android/preferences/pref_service_bridge.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/infobars/core/infobar.h" #include "content/public/browser/web_contents.h" -#include "jni/PermissionUpdateInfoBarDelegate_jni.h" #include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/platform_util_android.cc b/chrome/browser/platform_util_android.cc index 205272d47..348c1912 100644 --- a/chrome/browser/platform_util_android.cc +++ b/chrome/browser/platform_util_android.cc
@@ -7,8 +7,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/PlatformUtil_jni.h" #include "chrome/browser/platform_util.h" -#include "jni/PlatformUtil_jni.h" #include "ui/android/view_android.h" #include "url/gurl.h"
diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc index ad47f88..7d271d1 100644 --- a/chrome/browser/policy/cloud/cloud_policy_invalidator.cc +++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.cc
@@ -16,6 +16,7 @@ #include "base/time/clock.h" #include "base/time/time.h" #include "base/values.h" +#include "chrome/browser/policy/cloud/policy_invalidation_util.h" #include "chrome/common/chrome_features.h" #include "components/invalidation/public/invalidation_service.h" #include "components/invalidation/public/invalidation_util.h" @@ -27,11 +28,6 @@ namespace policy { -namespace { - -constexpr char kFcmPolicyPublicTopicPrefix[] = "cs-"; -} // namespace - const int CloudPolicyInvalidator::kMissingPayloadDelay = 5; const int CloudPolicyInvalidator::kMaxFetchDelayDefault = 10000; const int CloudPolicyInvalidator::kMaxFetchDelayMin = 1000; @@ -140,7 +136,7 @@ std::string CloudPolicyInvalidator::GetOwnerName() const { return "Cloud"; } bool CloudPolicyInvalidator::IsPublicTopic(const syncer::Topic& topic) const { - return base::StringPiece(topic).starts_with(kFcmPolicyPublicTopicPrefix); + return IsPublicInvalidationTopic(topic); } void CloudPolicyInvalidator::OnCoreConnected(CloudPolicyCore* core) {} @@ -286,30 +282,11 @@ void CloudPolicyInvalidator::UpdateRegistration( const enterprise_management::PolicyData* policy) { // Create the ObjectId based on the policy data. - if (!policy) { - Unregister(); - return; - } - // If the policy does not specify an ObjectId, then unregister. invalidation::ObjectId object_id; - if (base::FeatureList::IsEnabled(features::kPolicyFcmInvalidations)) { - if (!policy->has_policy_invalidation_topic() || - policy->policy_invalidation_topic().empty()) { - Unregister(); - return; - } - object_id = invalidation::ObjectId(syncer::kDeprecatedSourceForFCM, - policy->policy_invalidation_topic()); - } else { - if (!policy->has_invalidation_source() || - !policy->has_invalidation_name() || - policy->invalidation_name().empty()) { - Unregister(); - return; - } - object_id = invalidation::ObjectId(policy->invalidation_source(), - policy->invalidation_name()); + if (!policy || !GetCloudPolicyObjectIdFromPolicy(*policy, &object_id)) { + Unregister(); + return; } // If the policy object id in the policy data is different from the currently
diff --git a/chrome/browser/policy/cloud/policy_invalidation_util.cc b/chrome/browser/policy/cloud/policy_invalidation_util.cc new file mode 100644 index 0000000..38acd58 --- /dev/null +++ b/chrome/browser/policy/cloud/policy_invalidation_util.cc
@@ -0,0 +1,69 @@ +// Copyright 2019 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/policy/cloud/policy_invalidation_util.h" + +#include "base/feature_list.h" +#include "base/strings/string_piece.h" +#include "chrome/common/chrome_features.h" +#include "components/invalidation/public/invalidation.h" +#include "components/policy/proto/device_management_backend.pb.h" +#include "google/cacheinvalidation/include/types.h" + +namespace policy { + +namespace { + +constexpr char kFcmPolicyPublicTopicPrefix[] = "cs-"; + +} // namespace + +bool IsPublicInvalidationTopic(const syncer::Topic& topic) { + return base::StringPiece(topic).starts_with(kFcmPolicyPublicTopicPrefix); +} + +bool GetCloudPolicyObjectIdFromPolicy( + const enterprise_management::PolicyData& policy, + invalidation::ObjectId* object_id) { + if (base::FeatureList::IsEnabled(features::kPolicyFcmInvalidations)) { + if (!policy.has_policy_invalidation_topic() || + policy.policy_invalidation_topic().empty()) { + return false; + } + *object_id = invalidation::ObjectId(syncer::kDeprecatedSourceForFCM, + policy.policy_invalidation_topic()); + } else { + if (!policy.has_invalidation_source() || !policy.has_invalidation_name() || + policy.invalidation_name().empty()) { + return false; + } + *object_id = invalidation::ObjectId(policy.invalidation_source(), + policy.invalidation_name()); + } + return true; +} + +bool GetRemoteCommandObjectIdFromPolicy( + const enterprise_management::PolicyData& policy, + invalidation::ObjectId* object_id) { + if (base::FeatureList::IsEnabled(features::kPolicyFcmInvalidations)) { + if (!policy.has_command_invalidation_topic() || + policy.command_invalidation_topic().empty()) { + return false; + } + *object_id = invalidation::ObjectId(syncer::kDeprecatedSourceForFCM, + policy.command_invalidation_topic()); + } else { + if (!policy.has_command_invalidation_source() || + !policy.has_command_invalidation_name() || + policy.command_invalidation_name().empty()) { + return false; + } + *object_id = invalidation::ObjectId(policy.command_invalidation_source(), + policy.command_invalidation_name()); + } + return true; +} + +} // namespace policy
diff --git a/chrome/browser/policy/cloud/policy_invalidation_util.h b/chrome/browser/policy/cloud/policy_invalidation_util.h new file mode 100644 index 0000000..4a327ed8 --- /dev/null +++ b/chrome/browser/policy/cloud/policy_invalidation_util.h
@@ -0,0 +1,49 @@ +// Copyright 2019 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_POLICY_CLOUD_POLICY_INVALIDATION_UTIL_H_ +#define CHROME_BROWSER_POLICY_CLOUD_POLICY_INVALIDATION_UTIL_H_ + +#include "components/invalidation/public/invalidation_util.h" + +namespace enterprise_management { + +class PolicyData; + +} // namespace enterprise_management + +namespace invalidation { + +class ObjectId; + +} // namespace invalidation + +namespace policy { + +// Returns true if |topic| is a public topic. If |topic| is public, +// publish/subscribe service will fan out all the outgoing messages to all the +// devices subscribed to this topic. +// For example: +// If device subscribes to "DeviceGuestModeEnabled" public topic all the +// instances subscribed to this topic will receive all the outgoing messages +// addressed to topic "DeviceGuestModeEnabled". But if 2 devices with different +// InstanceID subscribe to private topic "BOOKMARK", they will receive different +// set of messages addressed to pair ("BOOKMARK", InstanceID) respectievely. +bool IsPublicInvalidationTopic(const syncer::Topic& topic); + +// Returns true if |policy| has data about policy to invalidate, and saves +// that data in |object_id|, and false otherwise. +bool GetCloudPolicyObjectIdFromPolicy( + const enterprise_management::PolicyData& policy, + invalidation::ObjectId* object_id); + +// The same as GetCloudPolicyObjectIdFromPolicy but gets the |object_id| for +// remote command. +bool GetRemoteCommandObjectIdFromPolicy( + const enterprise_management::PolicyData& policy, + invalidation::ObjectId* object_id); + +} // namespace policy + +#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_INVALIDATION_UTIL_H_
diff --git a/chrome/browser/policy/cloud/remote_commands_invalidator.cc b/chrome/browser/policy/cloud/remote_commands_invalidator.cc index 51df50c..abc0d0f 100644 --- a/chrome/browser/policy/cloud/remote_commands_invalidator.cc +++ b/chrome/browser/policy/cloud/remote_commands_invalidator.cc
@@ -6,8 +6,11 @@ #include <string> +#include "base/feature_list.h" #include "base/logging.h" #include "base/syslog_logging.h" +#include "chrome/browser/policy/cloud/policy_invalidation_util.h" +#include "chrome/common/chrome_features.h" #include "components/invalidation/public/invalidation.h" #include "components/invalidation/public/invalidation_service.h" #include "components/invalidation/public/invalidation_util.h" @@ -17,8 +20,7 @@ namespace policy { -RemoteCommandsInvalidator::RemoteCommandsInvalidator() { -} +RemoteCommandsInvalidator::RemoteCommandsInvalidator() {} RemoteCommandsInvalidator::~RemoteCommandsInvalidator() { DCHECK_EQ(SHUT_DOWN, state_); @@ -116,6 +118,11 @@ return "RemoteCommands"; } +bool RemoteCommandsInvalidator::IsPublicTopic( + const syncer::Topic& topic) const { + return IsPublicInvalidationTopic(topic); +} + void RemoteCommandsInvalidator::ReloadPolicyData( const enterprise_management::PolicyData* policy) { DCHECK(thread_checker_.CalledOnValidThread()); @@ -127,13 +134,11 @@ // Create the ObjectId based on the policy data. // If the policy does not specify an the ObjectId, then unregister. - if (!policy || !policy->has_command_invalidation_source() || - !policy->has_command_invalidation_name()) { + invalidation::ObjectId object_id; + if (!policy || !GetRemoteCommandObjectIdFromPolicy(*policy, &object_id)) { Unregister(); return; } - const invalidation::ObjectId object_id(policy->command_invalidation_source(), - policy->command_invalidation_name()); // If the policy object id in the policy data is different from the currently // registered object id, update the object registration.
diff --git a/chrome/browser/policy/cloud/remote_commands_invalidator.h b/chrome/browser/policy/cloud/remote_commands_invalidator.h index 7757a86..976cfc0d 100644 --- a/chrome/browser/policy/cloud/remote_commands_invalidator.h +++ b/chrome/browser/policy/cloud/remote_commands_invalidator.h
@@ -46,6 +46,8 @@ invalidation::InvalidationService* invalidation_service() { return invalidation_service_; } + + // Whether the invalidator currently has the ability to receive invalidations. bool invalidations_enabled() { return invalidations_enabled_; } // syncer::InvalidationHandler: @@ -53,6 +55,7 @@ void OnIncomingInvalidation( const syncer::ObjectIdInvalidationMap& invalidation_map) override; std::string GetOwnerName() const override; + bool IsPublicTopic(const syncer::Topic& topic) const override; protected: virtual void OnInitialize() = 0;
diff --git a/chrome/browser/policy/cloud/remote_commands_invalidator_unittest.cc b/chrome/browser/policy/cloud/remote_commands_invalidator_unittest.cc index 3b695e0b..e089a98 100644 --- a/chrome/browser/policy/cloud/remote_commands_invalidator_unittest.cc +++ b/chrome/browser/policy/cloud/remote_commands_invalidator_unittest.cc
@@ -6,7 +6,9 @@ #include "base/macros.h" #include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" #include "base/test/scoped_task_environment.h" +#include "chrome/common/chrome_features.h" #include "components/invalidation/impl/deprecated_invalidator_registrar.h" #include "components/invalidation/impl/fake_invalidation_service.h" #include "components/invalidation/impl/mock_ack_handler.h" @@ -33,10 +35,15 @@ MOCK_METHOD0(OnStop, void()); MOCK_METHOD0(DoRemoteCommandsFetch, void()); - void SetInvalidationObjectID(const invalidation::ObjectId& object_id) { + void SetInvalidationObjectID(const invalidation::ObjectId& object_id, + bool is_fcm_enabled) { em::PolicyData policy_data; - policy_data.set_command_invalidation_source(object_id.source()); - policy_data.set_command_invalidation_name(object_id.name()); + if (is_fcm_enabled) { + policy_data.set_command_invalidation_topic(object_id.name()); + } else { + policy_data.set_command_invalidation_source(object_id.source()); + policy_data.set_command_invalidation_name(object_id.name()); + } ReloadPolicyData(&policy_data); } @@ -49,11 +56,21 @@ DISALLOW_COPY_AND_ASSIGN(MockRemoteCommandInvalidator); }; -class RemoteCommandsInvalidatorTest : public testing::Test { +class RemoteCommandsInvalidatorTest : public testing::TestWithParam<bool> { public: - RemoteCommandsInvalidatorTest() - : kTestingObjectId1(123456, "abcdef"), - kTestingObjectId2(654321, "defabc") { + RemoteCommandsInvalidatorTest() : is_fcm_enabled_(GetParam()) { + feature_list_.InitWithFeatureState(features::kPolicyFcmInvalidations, + is_fcm_enabled_); + + if (is_fcm_enabled_) { + kTestingObjectId1 = + invalidation::ObjectId(syncer::kDeprecatedSourceForFCM, "abcdef"); + kTestingObjectId2 = + invalidation::ObjectId(syncer::kDeprecatedSourceForFCM, "defabc"); + return; + } + kTestingObjectId1 = invalidation::ObjectId(123456, "abcdef"); + kTestingObjectId2 = invalidation::ObjectId(654321, "defabc"); } void EnableInvalidationService() { @@ -135,11 +152,15 @@ VerifyExpectations(); } - const invalidation::ObjectId kTestingObjectId1; - const invalidation::ObjectId kTestingObjectId2; + invalidation::ObjectId kTestingObjectId1; + invalidation::ObjectId kTestingObjectId2; + + const bool is_fcm_enabled_; base::test::ScopedTaskEnvironment scoped_task_environment_; + base::test::ScopedFeatureList feature_list_; + invalidation::FakeInvalidationService invalidation_service_; StrictMock<MockRemoteCommandInvalidator> invalidator_; @@ -148,14 +169,14 @@ }; // Verifies that only the fired invalidations will be received. -TEST_F(RemoteCommandsInvalidatorTest, FiredInvalidation) { +TEST_P(RemoteCommandsInvalidatorTest, FiredInvalidation) { InitializeAndStart(); // Invalidator won't work at this point. EXPECT_FALSE(invalidator_.invalidations_enabled()); // Load the policy data, it should work now. - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); EXPECT_TRUE(invalidator_.invalidations_enabled()); base::RunLoop().RunUntilIdle(); @@ -186,7 +207,7 @@ } // Verifies that no invalidation will be received when invalidator is shutdown. -TEST_F(RemoteCommandsInvalidatorTest, ShutDown) { +TEST_P(RemoteCommandsInvalidatorTest, ShutDown) { EXPECT_FALSE(invalidator_.invalidations_enabled()); FireInvalidation(kTestingObjectId1); @@ -195,7 +216,7 @@ } // Verifies that no invalidation will be received when invalidator is stopped. -TEST_F(RemoteCommandsInvalidatorTest, Stopped) { +TEST_P(RemoteCommandsInvalidatorTest, Stopped) { EXPECT_CALL(invalidator_, OnInitialize()).Times(1); invalidator_.Initialize(&invalidation_service_); VerifyExpectations(); @@ -211,13 +232,13 @@ } // Verifies that stated/stopped state changes work as expected. -TEST_F(RemoteCommandsInvalidatorTest, StartedStateChange) { +TEST_P(RemoteCommandsInvalidatorTest, StartedStateChange) { InitializeAndStart(); // Invalidator requires object id to work. VerifyInvalidationDisabled(kTestingObjectId1); EXPECT_FALSE(invalidator_.invalidations_enabled()); - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId1); // Stop and restart invalidator. @@ -233,24 +254,24 @@ VerifyExpectations(); // Invalidator requires object id to work. - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId1); StopAndShutdown(); } // Verifies that registered state changes work as expected. -TEST_F(RemoteCommandsInvalidatorTest, RegistedStateChange) { +TEST_P(RemoteCommandsInvalidatorTest, RegistedStateChange) { InitializeAndStart(); - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId1); - invalidator_.SetInvalidationObjectID(kTestingObjectId2); + invalidator_.SetInvalidationObjectID(kTestingObjectId2, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId2); VerifyInvalidationDisabled(kTestingObjectId1); - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId1); VerifyInvalidationDisabled(kTestingObjectId2); @@ -259,7 +280,7 @@ VerifyInvalidationDisabled(kTestingObjectId2); EXPECT_FALSE(invalidator_.invalidations_enabled()); - invalidator_.SetInvalidationObjectID(kTestingObjectId2); + invalidator_.SetInvalidationObjectID(kTestingObjectId2, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId2); VerifyInvalidationDisabled(kTestingObjectId1); @@ -267,10 +288,10 @@ } // Verifies that invalidation service enabled state changes work as expected. -TEST_F(RemoteCommandsInvalidatorTest, InvalidationServiceEnabledStateChanged) { +TEST_P(RemoteCommandsInvalidatorTest, InvalidationServiceEnabledStateChanged) { InitializeAndStart(); - invalidator_.SetInvalidationObjectID(kTestingObjectId1); + invalidator_.SetInvalidationObjectID(kTestingObjectId1, is_fcm_enabled_); VerifyInvalidationEnabled(kTestingObjectId1); DisableInvalidationService(); @@ -291,4 +312,8 @@ StopAndShutdown(); } +INSTANTIATE_TEST_SUITE_P(ToggleIsFcmEnabled, + RemoteCommandsInvalidatorTest, + testing::Bool() /* is_fcm_enabled */); + } // namespace policy
diff --git a/chrome/browser/policy/e2e_test/.vpython b/chrome/browser/policy/e2e_test/.vpython new file mode 100644 index 0000000..c7bd7004 --- /dev/null +++ b/chrome/browser/policy/e2e_test/.vpython
@@ -0,0 +1,99 @@ +# This file defines all the extra packages we need to install to run the python +# scripts in our repo and is used in LUCI to create reproducible bubbles in +# which to run our ./test.py script. +# +# You can also use this locally by invoking `vpython` instead of `python` when +# running the test scripts. +# +# More information: +# https://chromium.googlesource.com/infra/infra/+/master/doc/users/vpython.md +python_version: "2.7" + +wheel: < + name: "infra/celab/celab/windows-amd64" + version: "jgh6G7OL6nIJ2-lKS916XK0jDcIP7cCc0FdONt9AwVwC" +> + +# googleapiclient +wheel: < + name: "infra/python/wheels/google_api_python_client-py2_py3" + version: "version:1.6.2" +> + +# googleapiclient's dependencies +wheel: < + name: "infra/python/wheels/httplib2-py2_py3" + version: "version:0.10.3" +> +wheel: < + name: "infra/python/wheels/oauth2client-py2_py3" + version: "version:4.1.3" +> +wheel: < + name: "infra/python/wheels/pyasn1-py2_py3" + version: "version:0.2.3" +> +wheel: < + name: "infra/python/wheels/pyasn1_modules-py2_py3" + version: "version:0.0.8" +> +wheel: < + name: "infra/python/wheels/rsa-py2_py3" + version: "version:3.4.2" +> +wheel: < + name: "infra/python/wheels/six-py2_py3" + version: "version:1.10.0" +> +wheel: < + name: "infra/python/wheels/uritemplate-py2_py3" + version: "version:3.0.0" +> + +# google.protobuf +wheel: < + name: "infra/python/wheels/protobuf-py2_py3" + version: "version:3.6.1" +> + +# iam.admin.v1 +wheel: < + name: "infra/python/wheels/grpc-google-iam-admin-v1-py2_py3" + version: "version:0.10.0" +> + +# iam.admin.v1's dependencies +wheel: < + name: "infra/python/wheels/grpc-google-iam-v1-py2_py3" + version: "version:0.11.4" +> + +wheel: < + name: "infra/python/wheels/googleapis-common-protos-py2_py3" + version: "version:1.5.3" +> + +wheel: < + name: "infra/python/wheels/grpcio/${vpython_platform}" + version: "version:1.4.0" +> + +wheel: < + name: "infra/python/wheels/futures-py2_py3" + version: "version:3.1.1" +> + +wheel: < + name: "infra/python/wheels/enum34-py2" + version: "version:1.1.6" +> + +wheel: < + name: "infra/python/wheels/absl-py-py2_py3" + version: "version:0.7.1" +> + +wheel: < + name: "infra/python/wheels/wheel-py2_py3" + version: "version:0.33.1" +> \ No newline at end of file
diff --git a/chrome/browser/policy/e2e_test/infra/config.pyl b/chrome/browser/policy/e2e_test/infra/config.pyl new file mode 100644 index 0000000..51dbb2fe --- /dev/null +++ b/chrome/browser/policy/e2e_test/infra/config.pyl
@@ -0,0 +1,57 @@ +# Copyright 2019 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This is a .pyl, or "Python Literal", file. You can treat it just like a +# .json file, with the following exceptions: +# * all keys must be quoted (use single quotes, please); +# * comments are allowed, using '#' syntax; and +# * trailing commas are allowed. + +{ + # This is a map of buildbot master names -> buildbot builder names -> + # config names (where each config name is a key in the 'configs' dict, + # below). MB uses this dict to look up which config to use for a given bot. + 'masters': { + 'chromium.win': { + 'win-celab-builder-rel': 'win-celab', + }, + + 'tryserver.chromium.win': { + 'win-celab-try-rel': 'win-celab', + }, + }, + + # This is the list of configs that you can pass to mb; each config + # represents a particular combination of gn args that we must support. + 'configs': { + 'win-celab': [ + 'release_bot', 'minimal_symbols' + ], + }, + + # This is a dict mapping a given 'mixin' name to a dict of settings that + # mb should use. See //tools/mb/docs/user_guide.md for more information. + 'mixins': + { + 'goma': { + 'gn_args': 'use_goma=true strip_absolute_paths_from_debug_symbols=true', + }, + + 'minimal_symbols': { + 'gn_args': 'symbol_level=1', + }, + + 'release': { + 'gn_args': 'is_debug=false', + }, + + 'release_bot': { + 'mixins': ['release', 'static', 'goma'], + }, + + 'static': { + 'gn_args': 'is_component_build=false', + }, + }, +}
diff --git a/chrome/browser/policy/e2e_test/infra/generate_host_files.py b/chrome/browser/policy/e2e_test/infra/generate_host_files.py new file mode 100644 index 0000000..801d047 --- /dev/null +++ b/chrome/browser/policy/e2e_test/infra/generate_host_files.py
@@ -0,0 +1,83 @@ +# Copyright 2019 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 argparse +import logging +import os +import sys + + +def ParseArgs(): + parser = argparse.ArgumentParser( + description='Host file generator for CELab E2E tests') + + all_tokens = ['project_id', 'storage_bucket', 'storage_prefix'] + template_help = 'The full path to the *.host.textpb template file to use. ' + template_help += 'Must contain the following tokens: %s' % all_tokens + parser.add_argument( + '--template', metavar='<host_file>', required=True, help=template_help) + parser.add_argument( + '--projects', + metavar='<projectA;projectB;...>', + dest="projects", + required=True, + help='The values to replace "<project_id>" with.') + parser.add_argument( + '--storage_bucket', + metavar='<token>', + dest="storage_bucket", + required=True, + help='The value to replace "<storage_bucket>" with.') + parser.add_argument( + '--storage_prefix', + metavar='<token>', + dest="storage_prefix", + required=True, + help='The value to replace "<storage_prefix>" with.') + parser.add_argument( + '--destination_dir', + metavar='<path>', + dest='destination', + required=True, + action='store', + help='Where to collect extra logs on test failures') + + return parser.parse_args() + + +def ConfigureLogging(args): + logfmt = '%(asctime)s %(filename)s:%(lineno)s: [%(levelname)s] %(message)s' + datefmt = '%Y/%m/%d %H:%M:%S' + + logging.basicConfig(level=logging.INFO, format=logfmt, datefmt=datefmt) + + +if __name__ == '__main__': + args = ParseArgs() + + ConfigureLogging(args) + + logging.info("Arguments: %s" % args) + + if not os.path.exists(args.template): + raise ValueError('Template host file not found: %s' % args.template) + + if not os.path.exists(args.destination): + raise ValueError('Destination directory not found: %s' % args.destination) + + # Generate all the host files based off the arguments passed. + with open(args.template, 'r') as f: + template = f.read() + + for project_id in args.projects.split(';'): + filename = "%s.host.textpb" % project_id + destination = os.path.join(args.destination, filename) + with open(destination, 'w') as f: + logging.info("Generating %s" % destination) + content = template.replace("<project_id>", project_id) + content = content.replace("<storage_bucket>", args.storage_bucket) + content = content.replace("<storage_prefix>", args.storage_prefix) + f.write(content) + + sys.exit(0)
diff --git a/chrome/browser/policy/e2e_test/infra/template.host.textpb b/chrome/browser/policy/e2e_test/infra/template.host.textpb new file mode 100644 index 0000000..3c62b5207 --- /dev/null +++ b/chrome/browser/policy/e2e_test/infra/template.host.textpb
@@ -0,0 +1,131 @@ +# This file is used as a template to generate host files for our CI tests. +# <xyz> tokens are replaced with real values by generate_host_files.py. + +project { + # ID of the project. Note that it's not the name of the project. + name: '<project_id>' + + # All assets will be created in this zone. Note that this is NOT the region name. + zone: 'us-west1-b' +} + +# Where the logs go. +log_settings { admin_log: "admin" } + + +storage { + # The GCS storage bucket. + bucket: "<storage_bucket>", + + # all files used by CEL will be put under this directory. + prefix: "<storage_prefix>" +} + +machine_type { + # Name must match the host_machine_type field in the windows_machine asset + # entries. + name: 'win2012r2' + + # Going to specify instance properties for a new GCE instance. Alternatively, + # we could specify a GCE instance template name. + instance_properties { + # Go with 2 CPUs and 7.5GB of RAM. This is the GCE machine type, not to be + # confused with the CEL machine_type. + machineType: 'projects/${host.project.name}/zones/${host.project.zone}/machineTypes/n1-standard-2' + + # Scheduling options. By default instances are not pre-emptible. + scheduling { + automaticRestart: true + } + + # Disks. We only need one disk + disks { + # autoDelete must be set to true when specifying initializeParams. + # Otherwise the toolchain will remind you. + autoDelete: true + + # ... which is a boot disk. This can be left out since the first disk + # will become the boot disk by default. + boot: true + + initializeParams { + # This is a special form for referencing the URL property of the image + # object named windows-2012-r2. Furthermore, this image type is not + # defined in this file. Instead see the builtins.textpb file for a list + # of builtin host assets that can be included for convenience. + sourceImage: '${host.image.windows-2012-r2.url}' + } + } + + # Note that we are leaving a bunch of fields out because their defaults are + # reasonable. See the GCE documentation, and in particular the REST API + # documentation for what these fields do. For our convenience, we generate + # a .proto file containing the Compute API schema which has the same + # information. This generated .proto file can be found at + # /schema/gcp/compute/compute-api.proto. + } +} + +machine_type { + # Name must match the host_machine_type field in the windows_machine asset + # entries. + name: 'win2008r2' + + instance_properties { + machineType: 'projects/${host.project.name}/zones/${host.project.zone}/machineTypes/n1-standard-2' + + scheduling { + automaticRestart: true + } + + disks { + autoDelete: true + boot: true + + initializeParams { + sourceImage: '${host.image.windows-2008-r2.url}' + } + } + } +} + +machine_type { + # Name must match the host_machine_type field in the windows_machine asset + # entries. + name: 'win2016' + + instance_properties { + machineType: 'projects/${host.project.name}/zones/${host.project.zone}/machineTypes/n1-standard-2' + + scheduling { + automaticRestart: true + } + + disks { + autoDelete: true + boot: true + + initializeParams { + sourceImage: '${host.image.windows-2016.url}' + } + } + } +} + +machine_type { + name: 'win7' + nested_vm { + image: 'gs://<storage_bucket>/images/win7_sp1_ent_unlicensed.img' + user_name: 'win7' + password: 'pass@word!' + } +} + +machine_type { + name: 'win10' + nested_vm { + image: 'gs://<storage_bucket>/images/win10_pro_1803.img' + user_name: 'win10' + password: 'pass@word!' + } +}
diff --git a/chrome/browser/policy/e2e_test/run_tests.py b/chrome/browser/policy/e2e_test/run_tests.py new file mode 100644 index 0000000..2542c4c --- /dev/null +++ b/chrome/browser/policy/e2e_test/run_tests.py
@@ -0,0 +1,131 @@ +# Copyright 2019 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 argparse +import logging +import os +import sys +from chrome_ent_test.infra.multi import ArgsParser, SimpleHostProvider, SharedHostProvider, MultiTestController +import traceback +import warnings + +# Import all known tests +from tests import * + + +def ParseArgs(): + example = '%s --hosts ./hosts/' % sys.argv[0] + + parser = argparse.ArgumentParser( + description='Test suite runner for CELab', epilog='example: %s' % example) + + parser.add_argument( + '--hosts', + required=True, + metavar='<host_file;...>', + help='Full paths to *.host.textpb files to use for tests (or directory)') + parser.add_argument( + '--tests', + metavar='<test_class;...>', + default='*', + help='Fully qualified names of TestCases to run (supports my.package.*)') + parser.add_argument( + '--noprogress', + dest='show_progress', + default=True, + action='store_false', + help='Don\'t show progress while running tests') + parser.add_argument( + '--test_py', + dest='test_py', + default=os.path.join('test', 'test.py'), + help='Path to the script to use to launch a single test') + parser.add_argument( + '--test_py_args', + dest='test_py_args', + default=None, + help='Arguments to pass to the --test_py script.') + parser.add_argument( + '--shared_provider_storage', + metavar='<bucketName>', + dest='shared_provider_storage', + default=None, + action='store', + help='Where to store locks for the SharedHostProvider hosts') + parser.add_argument( + '--error_logs_dir', + metavar='<path>', + dest='error_logs_dir', + default=None, + action='store', + help='Where to collect extra logs on test failures') + parser.add_argument( + '-v', + '--verbosity', + dest='verbosity', + default=-1, + help='Logging verbosity level. Messages logged at this level or lower' + + 'will be included. Set to 1 for debug logging.') + + return parser.parse_args() + + +def ConfigureLogging(args): + level = logging.WARNING + if args.verbosity == "0": + level = logging.INFO + if args.verbosity == "1": + level = logging.DEBUG + + # Filter out logs from low level loggers + errorOnlyLoggers = ['googleapiclient', 'google.auth', 'google_auth_httplib2'] + for logger in errorOnlyLoggers: + logging.getLogger(logger).setLevel(logging.ERROR) + message = 'We recommend that most server applications use service accounts.' + warnings.filterwarnings('ignore', '.*%s' % message) + + logfmt = '%(asctime)s %(filename)s:%(lineno)s: [%(levelname)s] %(message)s' + datefmt = '%Y/%m/%d %H:%M:%S' + + logging.basicConfig(level=level, format=logfmt, datefmt=datefmt) + + logging.error("%s: Logging level error is visible." % __file__) + logging.warning("%s: Logging level warning is visible." % __file__) + logging.info("%s: Logging level info is visible." % __file__) + logging.debug("%s: Logging level debug is visible." % __file__) + + +if __name__ == '__main__': + args = ParseArgs() + + ConfigureLogging(args) + + logging.info("Arguments: %s" % args) + + tests = ArgsParser.ParseTestsArg(args.tests) + logging.debug('Found tests: %s', tests) + + hostFiles = ArgsParser.ParseHostsArg(args.hosts) + logging.debug('Found hosts: %s', hostFiles) + + hostProvider = None + if args.shared_provider_storage == None: + hostProvider = SimpleHostProvider(hostFiles) + else: + hostProvider = SharedHostProvider(hostFiles, args.shared_provider_storage) + + c = MultiTestController(tests, hostProvider, args.error_logs_dir) + + success = False + try: + success = c.ExecuteTestCases(args.test_py, args.test_py_args, + args.show_progress) + except KeyboardInterrupt: + logging.error('Test run aborted.') + should_write_logs = False + except: + print(traceback.format_exc()) + logging.error('Test run failed.') + + sys.exit(0 if success else 1)
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc index 516398a..c12e0d89 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc
@@ -112,6 +112,7 @@ #include "components/optimization_guide/optimization_guide_prefs.h" #include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/password_manager/core/browser/password_manager.h" +#include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/payments/core/payment_prefs.h" #include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/browser/url_blacklist_manager.h" @@ -243,6 +244,7 @@ #include "chrome/browser/chromeos/cryptauth/cryptauth_device_id_provider_impl.h" #include "chrome/browser/chromeos/customization/customization_document.h" #include "chrome/browser/chromeos/extensions/echo_private_api.h" +#include "chrome/browser/chromeos/extensions/login/login_api.h" #include "chrome/browser/chromeos/file_system_provider/registry.h" #include "chrome/browser/chromeos/first_run/first_run.h" #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h" @@ -633,6 +635,7 @@ extensions::ExtensionAssetsManagerChromeOS::RegisterPrefs(registry); extensions::lock_screen_data::LockScreenItemStorage::RegisterLocalState( registry); + extensions::login_api::RegisterLocalStatePrefs(registry); invalidation::FCMInvalidationService::RegisterPrefs(registry); invalidation::InvalidatorStorage::RegisterPrefs(registry); ::onc::RegisterPrefs(registry); @@ -1109,4 +1112,7 @@ // Added 6/2019. profile_prefs->ClearPref(kMediaCacheSize); +#if defined(OS_MACOSX) + profile_prefs->ClearPref(password_manager::prefs::kKeychainMigrationStatus); +#endif // defined(OS_MACOSX) }
diff --git a/chrome/browser/prerender/external_prerender_handler_android.cc b/chrome/browser/prerender/external_prerender_handler_android.cc index cd81dbe..e757eaf 100644 --- a/chrome/browser/prerender/external_prerender_handler_android.cc +++ b/chrome/browser/prerender/external_prerender_handler_android.cc
@@ -8,6 +8,7 @@ #include "base/android/jni_string.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/ExternalPrerenderHandler_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/prerender/prerender_handle.h" #include "chrome/browser/prerender/prerender_manager.h" @@ -15,7 +16,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_android.h" #include "content/public/browser/web_contents.h" -#include "jni/ExternalPrerenderHandler_jni.h" using base::android::ConvertJavaStringToUTF16; using base::android::JavaParamRef;
diff --git a/chrome/browser/previews/android/previews_android_bridge.cc b/chrome/browser/previews/android/previews_android_bridge.cc index d711798d..0b09623 100644 --- a/chrome/browser/previews/android/previews_android_bridge.cc +++ b/chrome/browser/previews/android/previews_android_bridge.cc
@@ -7,12 +7,12 @@ #include <memory> #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/PreviewsAndroidBridge_jni.h" #include "chrome/browser/previews/previews_ui_tab_helper.h" #include "components/previews/content/previews_user_data.h" #include "components/previews/core/previews_experiments.h" #include "components/previews/core/previews_lite_page_redirect.h" #include "content/public/browser/web_contents.h" -#include "jni/PreviewsAndroidBridge_jni.h" static jlong JNI_PreviewsAndroidBridge_Init( JNIEnv* env,
diff --git a/chrome/browser/profiles/profile_android.cc b/chrome/browser/profiles/profile_android.cc index 2af5c71..3a49222 100644 --- a/chrome/browser/profiles/profile_android.cc +++ b/chrome/browser/profiles/profile_android.cc
@@ -6,11 +6,11 @@ #include "base/android/jni_android.h" #include "base/memory/ptr_util.h" +#include "chrome/android/public/profiles/jni_headers/Profile_jni.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_destroyer.h" #include "chrome/browser/profiles/profile_key_android.h" #include "chrome/browser/profiles/profile_manager.h" -#include "jni/Profile_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc index 64e4a85..2d70220a 100644 --- a/chrome/browser/profiles/profile_downloader.cc +++ b/chrome/browser/profiles/profile_downloader.cc
@@ -22,7 +22,6 @@ #include "chrome/browser/profiles/profile_downloader_delegate.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/signin/identity_manager_factory.h" -#include "components/signin/core/browser/account_fetcher_service.h" #include "components/signin/core/browser/account_info.h" #include "components/signin/core/browser/avatar_icon_util.h" #include "content/public/browser/browser_thread.h"
diff --git a/chrome/browser/profiles/profile_downloader_unittest.cc b/chrome/browser/profiles/profile_downloader_unittest.cc index e0e1957..32f6f28 100644 --- a/chrome/browser/profiles/profile_downloader_unittest.cc +++ b/chrome/browser/profiles/profile_downloader_unittest.cc
@@ -81,7 +81,7 @@ } // IdentityManager::DiagnosticsObserver: - void OnAccessTokenRequested(const std::string& account_id, + void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) override { // This flow should be invoked only when a test has explicitly set up
diff --git a/chrome/browser/profiles/profile_key_android.cc b/chrome/browser/profiles/profile_key_android.cc index f335d44..d67e4d81 100644 --- a/chrome/browser/profiles/profile_key_android.cc +++ b/chrome/browser/profiles/profile_key_android.cc
@@ -6,11 +6,11 @@ #include "base/android/jni_android.h" #include "base/memory/ptr_util.h" +#include "chrome/android/public/profiles/jni_headers/ProfileKey_jni.h" #include "chrome/browser/android/profile_key_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/profiles/profile_manager.h" -#include "jni/ProfileKey_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 295c469..dd69b35 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc
@@ -79,7 +79,6 @@ #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/search_engines/default_search_manager.h" -#include "components/signin/core/browser/account_fetcher_service.h" #include "components/signin/core/browser/signin_pref_names.h" #include "components/sync/base/stop_source.h" #include "components/sync/driver/sync_service.h"
diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc index e112fa5..327b868 100644 --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -68,7 +68,7 @@ #if defined(OS_ANDROID) #include "base/android/jni_android.h" -#include "jni/PushMessagingServiceObserver_jni.h" +#include "chrome/android/chrome_jni_headers/PushMessagingServiceObserver_jni.h" #endif using instance_id::InstanceID;
diff --git a/chrome/browser/resource_coordinator/tab_manager_browsertest.cc b/chrome/browser/resource_coordinator/tab_manager_browsertest.cc index e478319..29ddf13 100644 --- a/chrome/browser/resource_coordinator/tab_manager_browsertest.cc +++ b/chrome/browser/resource_coordinator/tab_manager_browsertest.cc
@@ -1206,8 +1206,11 @@ // - (optional) Freeze happens in renderer: PENDING_FREEZE->FROZEN // - Renderer is notified of new visibility: PENDING_FREEZE->ACTIVE or // FROZEN->ACTIVE. -IN_PROC_BROWSER_TEST_F(TabManagerTestWithTwoTabs, - TabProactiveDiscardAndFocusBeforeFreezeCompletes) { +// +// DISABLED: consistent timeout crbug.com/978021 +IN_PROC_BROWSER_TEST_F( + TabManagerTestWithTwoTabs, + DISABLED_TabProactiveDiscardAndFocusBeforeFreezeCompletes) { // Proactively discard the background tab. EXPECT_EQ(LifecycleUnitState::ACTIVE, GetLifecycleUnitAt(1)->GetState()); EXPECT_TRUE(
diff --git a/chrome/browser/safe_browsing/android/file_type_policies.cc b/chrome/browser/safe_browsing/android/file_type_policies.cc index 7c773a0..17a4598 100644 --- a/chrome/browser/safe_browsing/android/file_type_policies.cc +++ b/chrome/browser/safe_browsing/android/file_type_policies.cc
@@ -6,7 +6,7 @@ #include "base/android/jni_string.h" #include "base/files/file_path.h" -#include "jni/FileTypePolicies_jni.h" +#include "chrome/android/chrome_jni_headers/FileTypePolicies_jni.h" namespace safe_browsing {
diff --git a/chrome/browser/safe_browsing/android/services_delegate_android.cc b/chrome/browser/safe_browsing/android/services_delegate_android.cc index dc8dc71..e03845b 100644 --- a/chrome/browser/safe_browsing/android/services_delegate_android.cc +++ b/chrome/browser/safe_browsing/android/services_delegate_android.cc
@@ -146,6 +146,14 @@ return telemetry_service_.get(); } +void ServicesDelegateAndroid::CreateVerdictCacheManager(Profile* profile) {} +void ServicesDelegateAndroid::RemoveVerdictCacheManager(Profile* profile) {} +VerdictCacheManager* ServicesDelegateAndroid::GetVerdictCacheManager( + Profile* profile) const { + NOTIMPLEMENTED(); + return nullptr; +} + std::string ServicesDelegateAndroid::GetSafetyNetId() const { return database_manager_->GetSafetyNetId(); }
diff --git a/chrome/browser/safe_browsing/android/services_delegate_android.h b/chrome/browser/safe_browsing/android/services_delegate_android.h index b1d8ac6..b6eb9fc3 100644 --- a/chrome/browser/safe_browsing/android/services_delegate_android.h +++ b/chrome/browser/safe_browsing/android/services_delegate_android.h
@@ -54,6 +54,10 @@ void RemoveTelemetryService() override; TelemetryService* GetTelemetryService() const override; + void CreateVerdictCacheManager(Profile* profile) override; + void RemoveVerdictCacheManager(Profile* profile) override; + VerdictCacheManager* GetVerdictCacheManager(Profile* profile) const override; + std::string GetSafetyNetId() const override; // Reports the current extended reporting level. Note that this is an
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service.cc b/chrome/browser/safe_browsing/chrome_password_protection_service.cc index b00c0b02..cfcad7a 100644 --- a/chrome/browser/safe_browsing/chrome_password_protection_service.cc +++ b/chrome/browser/safe_browsing/chrome_password_protection_service.cc
@@ -46,7 +46,9 @@ #include "components/safe_browsing/features.h" #include "components/safe_browsing/password_protection/password_protection_navigation_throttle.h" #include "components/safe_browsing/password_protection/password_protection_request.h" +#include "components/safe_browsing/proto/csd.pb.h" #include "components/safe_browsing/triggers/trigger_throttler.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "components/safe_browsing/web_ui/safe_browsing_ui.h" #include "components/signin/core/browser/account_info.h" #include "components/strings/grit/components_strings.h" @@ -205,18 +207,17 @@ ChromePasswordProtectionService::ChromePasswordProtectionService( SafeBrowsingService* sb_service, Profile* profile) - : PasswordProtectionService( - sb_service->database_manager(), - sb_service->GetURLLoaderFactory(), - HistoryServiceFactory::GetForProfile( - profile, - ServiceAccessType::EXPLICIT_ACCESS), - HostContentSettingsMapFactory::GetForProfile(profile)), + : PasswordProtectionService(sb_service->database_manager(), + sb_service->GetURLLoaderFactory(), + HistoryServiceFactory::GetForProfile( + profile, + ServiceAccessType::EXPLICIT_ACCESS)), ui_manager_(sb_service->ui_manager()), trigger_manager_(sb_service->trigger_manager()), profile_(profile), navigation_observer_manager_(sb_service->navigation_observer_manager()), - pref_change_registrar_(new PrefChangeRegistrar) { + pref_change_registrar_(new PrefChangeRegistrar), + cache_manager_(sb_service->GetVerdictCacheManager(profile)) { pref_change_registrar_->Init(profile_->GetPrefs()); pref_change_registrar_->Add( password_manager::prefs::kPasswordHashDataList, @@ -270,9 +271,6 @@ } ChromePasswordProtectionService::~ChromePasswordProtectionService() { - if (content_settings()) - CleanUpExpiredVerdicts(); - if (pref_change_registrar_) pref_change_registrar_->RemoveAll(); } @@ -877,7 +875,7 @@ verdict.set_verdict_type(LoginReputationClientResponse::SAFE); verdict.set_cache_duration_sec(kOverrideVerdictCacheDurationSec); CacheVerdict(url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - password_type, &verdict, base::Time::Now()); + password_type, verdict, base::Time::Now()); return; } @@ -1125,16 +1123,14 @@ ChromePasswordProtectionService::ChromePasswordProtectionService( Profile* profile, - scoped_refptr<HostContentSettingsMap> content_setting_map, scoped_refptr<SafeBrowsingUIManager> ui_manager, - StringProvider sync_password_hash_provider) - : PasswordProtectionService(nullptr, - nullptr, - nullptr, - content_setting_map.get()), + StringProvider sync_password_hash_provider, + VerdictCacheManager* cache_manager) + : PasswordProtectionService(nullptr, nullptr, nullptr), ui_manager_(ui_manager), trigger_manager_(nullptr), profile_(profile), + cache_manager_(cache_manager), sync_password_hash_provider_for_testing_(sync_password_hash_provider) { Init(); } @@ -1277,6 +1273,42 @@ web_contents_with_unhandled_enterprise_reuses_.end(); } +// Stores |verdict| in |settings| based on its |trigger_type|, |url|, +// reused |password_type|, |verdict| and |receive_time|. +void ChromePasswordProtectionService::CacheVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + ReusedPasswordType password_type, + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) { + if (!CanGetReputationOfURL(url) || IsIncognito()) + return; + + cache_manager_->CachePhishGuardVerdict(url, trigger_type, password_type, + verdict, receive_time); +} + +// Looks up |settings| to find the cached verdict response. If verdict is not +// available or is expired, return VERDICT_TYPE_UNSPECIFIED. Can be called on +// any thread. +LoginReputationClientResponse::VerdictType +ChromePasswordProtectionService::GetCachedVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + ReusedPasswordType password_type, + LoginReputationClientResponse* out_response) { + if (!url.is_valid() || !CanGetReputationOfURL(url)) + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + + return cache_manager_->GetCachedPhishGuardVerdict( + url, trigger_type, password_type, out_response); +} + +int ChromePasswordProtectionService::GetStoredVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type) { + return cache_manager_->GetStoredPhishGuardVerdictCount(trigger_type); +} + void ChromePasswordProtectionService::OnWarningTriggerChanged() { if (GetPasswordProtectionWarningTriggerPref() != PASSWORD_PROTECTION_OFF) return;
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service.h b/chrome/browser/safe_browsing/chrome_password_protection_service.h index 6a546d8d..ec0d31e 100644 --- a/chrome/browser/safe_browsing/chrome_password_protection_service.h +++ b/chrome/browser/safe_browsing/chrome_password_protection_service.h
@@ -38,6 +38,7 @@ class SafeBrowsingNavigationObserverManager; class SafeBrowsingUIManager; class ChromePasswordProtectionService; +class VerdictCacheManager; using OnWarningDone = base::OnceCallback<void(WarningAction)>; using StringProvider = base::RepeatingCallback<std::string()>; @@ -193,6 +194,26 @@ bool HasUnhandledEnterprisePasswordReuse( content::WebContents* web_contents) const; + // Stores |verdict| in the cache based on its |trigger_type|, |url|, + // reused |password_type|, |verdict| and |receive_time|. + void CacheVerdict(const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + ReusedPasswordType password_type, + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) override; + + // Returns the number of saved verdicts for the given |trigger_type|. + int GetStoredVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type) override; + + // Looks up the cached verdict response. If verdict is not available or is + // expired, return VERDICT_TYPE_UNSPECIFIED. Can be called on any thread. + LoginReputationClientResponse::VerdictType GetCachedVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + ReusedPasswordType password_type, + LoginReputationClientResponse* out_response) override; + protected: // PasswordProtectionService overrides. const policy::BrowserPolicyConnector* GetBrowserPolicyConnector() @@ -363,9 +384,9 @@ // Constructor used for tests only. ChromePasswordProtectionService( Profile* profile, - scoped_refptr<HostContentSettingsMap> content_setting_map, scoped_refptr<SafeBrowsingUIManager> ui_manager, - StringProvider sync_password_hash_provider); + StringProvider sync_password_hash_provider, + VerdictCacheManager* cache_manager); // Code shared by both ctors. void Init(); @@ -394,6 +415,9 @@ std::set<content::WebContents*> web_contents_with_unhandled_enterprise_reuses_; + // Reference to the current profile's VerdictCacheManager. This is unowned. + VerdictCacheManager* cache_manager_; + // Schedules the next time to log the PasswordCaptured event. base::OneShotTimer log_password_capture_timer_;
diff --git a/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc b/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc index 845adc36..22bcadb 100644 --- a/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc +++ b/chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc
@@ -29,6 +29,7 @@ #include "components/safe_browsing/db/v4_protocol_manager_util.h" #include "components/safe_browsing/password_protection/password_protection_navigation_throttle.h" #include "components/safe_browsing/password_protection/password_protection_request.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "components/signin/core/browser/account_info.h" #include "components/strings/grit/components_strings.h" #include "components/sync_preferences/testing_pref_service_syncable.h" @@ -107,13 +108,13 @@ public: explicit MockChromePasswordProtectionService( Profile* profile, - scoped_refptr<HostContentSettingsMap> content_setting_map, scoped_refptr<SafeBrowsingUIManager> ui_manager, - StringProvider sync_password_hash_provider) + StringProvider sync_password_hash_provider, + VerdictCacheManager* cache_manager) : ChromePasswordProtectionService(profile, - content_setting_map, ui_manager, - sync_password_hash_provider), + sync_password_hash_provider, + cache_manager), is_incognito_(false), is_extended_reporting_(false) {} bool IsExtendedReporting() override { return is_extended_reporting_; } @@ -154,6 +155,9 @@ false /* store_last_modified */, false /* migrate_requesting_and_top_level_origin_settings */); + cache_manager_ = std::make_unique<VerdictCacheManager>( + nullptr, content_setting_map_.get()); + service_ = NewMockPasswordProtectionService(); fake_user_event_service_ = static_cast<syncer::FakeUserEventService*>( browser_sync::UserEventServiceFactory::GetInstance() @@ -175,6 +179,7 @@ service_.reset(); request_ = nullptr; identity_test_env_profile_adaptor_.reset(); + cache_manager_.reset(); content_setting_map_->ShutdownOnUIThread(); ChromeRenderViewHostTestHarness::TearDown(); } @@ -191,11 +196,11 @@ // to use the interface in components/safe_browsing, and remove this // cast. return std::make_unique<MockChromePasswordProtectionService>( - profile(), content_setting_map_, + profile(), new SafeBrowsingUIManager( static_cast<safe_browsing::SafeBrowsingService*>( SafeBrowsingService::CreateSafeBrowsingService())), - sync_password_hash_provider); + sync_password_hash_provider, cache_manager_.get()); } content::BrowserContext* CreateBrowserContext() override { @@ -290,6 +295,7 @@ // Owned by KeyedServiceFactory. syncer::FakeUserEventService* fake_user_event_service_; extensions::TestEventRouter* test_event_router_; + std::unique_ptr<VerdictCacheManager> cache_manager_; }; TEST_F(ChromePasswordProtectionServiceTest, @@ -518,7 +524,7 @@ verdict_proto.set_cache_expression("password_reuse_url.com/"); service_->CacheVerdict( url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &verdict_proto, base::Time::Now()); + PasswordReuseEvent::SIGN_IN_PASSWORD, verdict_proto, base::Time::Now()); service_->UpdateSecurityState(SB_THREAT_TYPE_SIGN_IN_PASSWORD_REUSE, PasswordReuseEvent::SIGN_IN_PASSWORD,
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index 7e12613..2f8a137 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -42,6 +42,7 @@ #include "components/safe_browsing/db/database_manager.h" #include "components/safe_browsing/ping_manager.h" #include "components/safe_browsing/triggers/trigger_manager.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "components/safe_browsing/web_ui/safe_browsing_ui.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -267,6 +268,13 @@ cmdline->HasSwitch(::switches::kDisableBackgroundNetworking)); } +VerdictCacheManager* SafeBrowsingService::GetVerdictCacheManager( + Profile* profile) const { + if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) + return services_delegate_->GetVerdictCacheManager(profile); + return nullptr; +} + std::string SafeBrowsingService::GetProtocolConfigClientName() const { std::string client_name; // On Windows, get the safe browsing client name from the browser @@ -351,6 +359,7 @@ case chrome::NOTIFICATION_PROFILE_CREATED: { DCHECK_CURRENTLY_ON(BrowserThread::UI); Profile* profile = content::Source<Profile>(source).ptr(); + services_delegate_->CreateVerdictCacheManager(profile); services_delegate_->CreatePasswordProtectionService(profile); services_delegate_->CreateTelemetryService(profile); if (!profile->IsOffTheRecord()) @@ -360,6 +369,7 @@ case chrome::NOTIFICATION_PROFILE_DESTROYED: { DCHECK_CURRENTLY_ON(BrowserThread::UI); Profile* profile = content::Source<Profile>(source).ptr(); + services_delegate_->RemoveVerdictCacheManager(profile); services_delegate_->RemovePasswordProtectionService(profile); services_delegate_->RemoveTelemetryService(); if (!profile->IsOffTheRecord())
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index 2f15b7a7..86e44cc 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -61,6 +61,7 @@ namespace safe_browsing { class PingManager; +class VerdictCacheManager; class ClientSideDetectionService; class DownloadProtectionService; class PasswordProtectionService; @@ -175,6 +176,9 @@ // Create the default v4 protocol config struct. virtual V4ProtocolConfig GetV4ProtocolConfig() const; + // Get the cache manager by profile. + VerdictCacheManager* GetVerdictCacheManager(Profile* profile) const; + protected: // Creates the safe browsing service. Need to initialize before using. SafeBrowsingService();
diff --git a/chrome/browser/safe_browsing/services_delegate.h b/chrome/browser/safe_browsing/services_delegate.h index e315923..9808929 100644 --- a/chrome/browser/safe_browsing/services_delegate.h +++ b/chrome/browser/safe_browsing/services_delegate.h
@@ -29,6 +29,7 @@ namespace safe_browsing { +class VerdictCacheManager; class ClientSideDetectionService; class DownloadProtectionService; class IncidentReportingService; @@ -124,6 +125,11 @@ virtual void RemoveTelemetryService() = 0; virtual TelemetryService* GetTelemetryService() const = 0; + virtual void CreateVerdictCacheManager(Profile* profile) = 0; + virtual void RemoveVerdictCacheManager(Profile* profile) = 0; + virtual VerdictCacheManager* GetVerdictCacheManager( + Profile* profile) const = 0; + virtual std::string GetSafetyNetId() const = 0; };
diff --git a/chrome/browser/safe_browsing/services_delegate_desktop.cc b/chrome/browser/safe_browsing/services_delegate_desktop.cc index 48e0657..4f59570 100644 --- a/chrome/browser/safe_browsing/services_delegate_desktop.cc +++ b/chrome/browser/safe_browsing/services_delegate_desktop.cc
@@ -10,10 +10,14 @@ #include "base/command_line.h" #include "base/memory/ptr_util.h" #include "base/strings/string_util.h" +#include "chrome/browser/content_settings/host_content_settings_map_factory.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/safe_browsing/telemetry/telemetry_service.h" #include "chrome/common/chrome_switches.h" +#include "components/keyed_service/core/service_access_type.h" #include "components/safe_browsing/db/v4_local_database_manager.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "content/public/browser/browser_thread.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/preferences/public/mojom/tracked_preference_validation_delegate.mojom.h" @@ -237,6 +241,34 @@ return nullptr; } +void ServicesDelegateDesktop::CreateVerdictCacheManager(Profile* profile) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(profile); + auto it = cache_manager_map_.find(profile); + DCHECK(it == cache_manager_map_.end()); + auto cache_manager = std::make_unique<VerdictCacheManager>( + HistoryServiceFactory::GetForProfile(profile, + ServiceAccessType::EXPLICIT_ACCESS), + HostContentSettingsMapFactory::GetForProfile(profile)); + cache_manager_map_[profile] = std::move(cache_manager); +} + +void ServicesDelegateDesktop::RemoveVerdictCacheManager(Profile* profile) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(profile); + auto it = cache_manager_map_.find(profile); + if (it != cache_manager_map_.end()) + cache_manager_map_.erase(it); +} + +VerdictCacheManager* ServicesDelegateDesktop::GetVerdictCacheManager( + Profile* profile) const { + DCHECK(profile); + auto it = cache_manager_map_.find(profile); + DCHECK(it != cache_manager_map_.end()); + return it->second.get(); +} + std::string ServicesDelegateDesktop::GetSafetyNetId() const { NOTREACHED() << "Only implemented on Android"; return "";
diff --git a/chrome/browser/safe_browsing/services_delegate_desktop.h b/chrome/browser/safe_browsing/services_delegate_desktop.h index 03bff57..a820d23 100644 --- a/chrome/browser/safe_browsing/services_delegate_desktop.h +++ b/chrome/browser/safe_browsing/services_delegate_desktop.h
@@ -76,6 +76,10 @@ void RemoveTelemetryService() override; TelemetryService* GetTelemetryService() const override; + void CreateVerdictCacheManager(Profile* profile) override; + void RemoveVerdictCacheManager(Profile* profile) override; + VerdictCacheManager* GetVerdictCacheManager(Profile* profile) const override; + std::string GetSafetyNetId() const override; std::unique_ptr<ClientSideDetectionService> csd_service_; @@ -99,6 +103,10 @@ std::map<Profile*, std::unique_ptr<ChromePasswordProtectionService>> password_protection_service_map_; + // Tracks existing Profiles, and their corresponding VerdictCacheManager + // instances. Accessed on UI thread. + std::map<Profile*, std::unique_ptr<VerdictCacheManager>> cache_manager_map_; + DISALLOW_COPY_AND_ASSIGN(ServicesDelegateDesktop); };
diff --git a/chrome/browser/search_engines/template_url_service_factory_android.cc b/chrome/browser/search_engines/template_url_service_factory_android.cc index 0332bbf..59dbdfae 100644 --- a/chrome/browser/search_engines/template_url_service_factory_android.cc +++ b/chrome/browser/search_engines/template_url_service_factory_android.cc
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/android/chrome_jni_headers/TemplateUrlServiceFactory_jni.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/search_engines/template_url_service_factory.h" #include "components/search_engines/template_url_service.h" #include "components/search_provider_logos/features.h" #include "components/search_provider_logos/switches.h" -#include "jni/TemplateUrlServiceFactory_jni.h" namespace { Profile* GetOriginalProfile() {
diff --git a/chrome/browser/signin/identity_services_provider_android.cc b/chrome/browser/signin/identity_services_provider_android.cc index 683be19..b28a5af 100644 --- a/chrome/browser/signin/identity_services_provider_android.cc +++ b/chrome/browser/signin/identity_services_provider_android.cc
@@ -3,9 +3,9 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/IdentityServicesProvider_jni.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/signin/identity_manager_factory.h" -#include "jni/IdentityServicesProvider_jni.h" #include "services/identity/public/cpp/identity_manager.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ssl/captive_portal_helper_android.cc b/chrome/browser/ssl/captive_portal_helper_android.cc index 8e417da..1c5adb84 100644 --- a/chrome/browser/ssl/captive_portal_helper_android.cc +++ b/chrome/browser/ssl/captive_portal_helper_android.cc
@@ -15,10 +15,10 @@ #include "base/bind.h" #include "base/logging.h" #include "base/threading/thread_task_runner_handle.h" +#include "chrome/android/chrome_jni_headers/CaptivePortalHelper_jni.h" #include "chrome/browser/ssl/ssl_error_assistant.h" #include "chrome/browser/ssl/ssl_error_handler.h" #include "content/public/browser/browser_thread.h" -#include "jni/CaptivePortalHelper_jni.h" #include "net/android/network_library.h" namespace chrome {
diff --git a/chrome/browser/ssl/security_state_model_android.cc b/chrome/browser/ssl/security_state_model_android.cc index f51ecea9..9bb4fc5 100644 --- a/chrome/browser/ssl/security_state_model_android.cc +++ b/chrome/browser/ssl/security_state_model_android.cc
@@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/SecurityStateModel_jni.h" #include "chrome/browser/ssl/security_state_tab_helper.h" #include "components/security_state/core/security_state.h" #include "content/public/browser/web_contents.h" -#include "jni/SecurityStateModel_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.cc b/chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.cc index 9ea0cc1..64e4e948 100644 --- a/chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.cc +++ b/chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.cc
@@ -5,9 +5,9 @@ #include "chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ChildAccountFeedbackReporter_jni.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "content/public/browser/web_contents.h" -#include "jni/ChildAccountFeedbackReporter_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "url/gurl.h"
diff --git a/chrome/browser/supervised_user/child_accounts/child_account_service_android.cc b/chrome/browser/supervised_user/child_accounts/child_account_service_android.cc index 7d220918..2ea42b9 100644 --- a/chrome/browser/supervised_user/child_accounts/child_account_service_android.cc +++ b/chrome/browser/supervised_user/child_accounts/child_account_service_android.cc
@@ -9,12 +9,12 @@ #include "base/android/callback_android.h" #include "base/android/jni_string.h" #include "base/bind.h" +#include "chrome/android/chrome_jni_headers/ChildAccountService_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" #include "chrome/browser/supervised_user/child_accounts/child_account_service_factory.h" #include "content/public/browser/web_contents.h" -#include "jni/ChildAccountService_jni.h" #include "ui/android/window_android.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/sync/profile_sync_service_android.cc b/chrome/browser/sync/profile_sync_service_android.cc index 0b0ad98..a3cd9142 100644 --- a/chrome/browser/sync/profile_sync_service_android.cc +++ b/chrome/browser/sync/profile_sync_service_android.cc
@@ -17,6 +17,7 @@ #include "base/memory/ptr_util.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/ProfileSyncService_jni.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sync/device_info_sync_service_factory.h" @@ -37,7 +38,6 @@ #include "components/sync_sessions/session_sync_service.h" #include "content/public/browser/browser_thread.h" #include "google_apis/gaia/google_service_auth_error.h" -#include "jni/ProfileSyncService_jni.h" #include "ui/base/l10n/l10n_util.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc index 27cd337b..5324f4b9 100644 --- a/chrome/browser/sync/sync_ui_util.cc +++ b/chrome/browser/sync/sync_ui_util.cc
@@ -13,6 +13,7 @@ #include "components/strings/grit/components_strings.h" #include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_user_settings.h" +#include "components/unified_consent/feature.h" #include "google_apis/gaia/google_service_auth_error.h" #include "services/identity/public/cpp/identity_manager.h" #include "ui/base/l10n/l10n_util.h" @@ -140,7 +141,7 @@ syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY)) { if (status_label) { *status_label = - l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED); + l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_DISABLED_BY_POLICY); } // TODO(crbug.com/911153): Is SYNCED correct for this case? return SYNCED; @@ -150,10 +151,14 @@ // set up once again. if (!service->GetUserSettings()->IsSyncRequested()) { if (status_label) { - *status_label = - l10n_util::GetStringUTF16(IDS_SIGNED_IN_WITH_SYNC_SUPPRESSED); + *status_label = l10n_util::GetStringUTF16( + IDS_SIGNED_IN_WITH_SYNC_STOPPED_VIA_DASHBOARD); } - return SYNC_ERROR; + // Note: The pre-UnifiedConsent UI handles this case differently and does + // *not* treat it as an error. If we wanted to treat it as an error, we'd + // also have to set |link_label| and |action_type|, see crbug.com/977980. + return unified_consent::IsUnifiedConsentFeatureEnabled() ? SYNC_ERROR + : PRE_SYNCED; } if (service->GetUserSettings()->IsFirstSetupComplete()) { @@ -191,7 +196,7 @@ // If first setup is in progress, show an "in progress" message. if (service->IsSetupInProgress()) { if (status_label) { - *status_label = l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS); + *status_label = l10n_util::GetStringUTF16(IDS_SYNC_SETUP_IN_PROGRESS); } return PRE_SYNCED; }
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc index a416e237..08e8ca4 100644 --- a/chrome/browser/sync/sync_ui_util_unittest.cc +++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -18,6 +18,7 @@ #include "chrome/test/base/testing_profile.h" #include "components/sync/driver/test_sync_service.h" #include "components/sync/engine/sync_engine.h" +#include "components/unified_consent/feature.h" #include "content/public/test/test_browser_thread_bundle.h" #include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_test_environment.h" @@ -35,10 +36,11 @@ STATUS_CASE_SETUP_ERROR, STATUS_CASE_AUTH_ERROR, STATUS_CASE_PROTOCOL_ERROR, - STATUS_CASE_PASSPHRASE_ERROR, STATUS_CASE_CONFIRM_SYNC_SETTINGS, + STATUS_CASE_PASSPHRASE_ERROR, STATUS_CASE_SYNCED, STATUS_CASE_SYNC_DISABLED_BY_POLICY, + STATUS_CASE_SYNC_RESET_FROM_DASHBOARD, NUMBER_OF_STATUS_CASES }; @@ -52,22 +54,19 @@ }; // Sets up a TestSyncService to emulate one of a number of distinct cases in -// order to perform tests on the generated messages. -// Returns the expected value for the output argument |action_type| for each -// of the distinct cases. -sync_ui_util::ActionType GetDistinctCase( - TestSyncService* service, - identity::IdentityManager* identity_manager, - int case_number) { - // Auth Error object is returned by reference in mock and needs to stay in - // scope throughout test, so it is owned by calling method. However it is - // immutable so can only be allocated in this method. +// order to perform tests on the generated messages. Returns the expected values +// for the MessageType and ActionType that sync_ui_util::GetStatusLabels should +// return. +std::pair<sync_ui_util::MessageType, sync_ui_util::ActionType> +SetUpDistinctCase(TestSyncService* service, + identity::IdentityManager* identity_manager, + int case_number) { switch (case_number) { case STATUS_CASE_SETUP_IN_PROGRESS: { service->SetFirstSetupComplete(false); service->SetSetupInProgress(true); service->SetDetailedSyncStatus(false, syncer::SyncStatus()); - return sync_ui_util::NO_ACTION; + return std::make_tuple(sync_ui_util::PRE_SYNCED, sync_ui_util::NO_ACTION); } case STATUS_CASE_SETUP_ERROR: { service->SetFirstSetupComplete(false); @@ -75,7 +74,8 @@ service->SetDisableReasons( syncer::SyncService::DISABLE_REASON_UNRECOVERABLE_ERROR); service->SetDetailedSyncStatus(false, syncer::SyncStatus()); - return sync_ui_util::REAUTHENTICATE; + return std::make_tuple(sync_ui_util::SYNC_ERROR, + sync_ui_util::REAUTHENTICATE); } case STATUS_CASE_AUTH_ERROR: { service->SetFirstSetupComplete(true); @@ -92,7 +92,8 @@ identity_manager, account_id, GoogleServiceAuthError(GoogleServiceAuthError::State::SERVICE_ERROR)); service->SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); - return sync_ui_util::REAUTHENTICATE; + return std::make_tuple(sync_ui_util::SYNC_ERROR, + sync_ui_util::REAUTHENTICATE); } case STATUS_CASE_PROTOCOL_ERROR: { service->SetFirstSetupComplete(true); @@ -104,13 +105,15 @@ status.sync_protocol_error = protocol_error; service->SetDetailedSyncStatus(false, status); service->SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); - return sync_ui_util::UPGRADE_CLIENT; + return std::make_tuple(sync_ui_util::SYNC_ERROR, + sync_ui_util::UPGRADE_CLIENT); } case STATUS_CASE_CONFIRM_SYNC_SETTINGS: { service->SetFirstSetupComplete(false); service->SetPassphraseRequired(false); service->SetDetailedSyncStatus(false, syncer::SyncStatus()); - return sync_ui_util::CONFIRM_SYNC_SETTINGS; + return std::make_tuple(sync_ui_util::SYNC_ERROR, + sync_ui_util::CONFIRM_SYNC_SETTINGS); } case STATUS_CASE_PASSPHRASE_ERROR: { service->SetFirstSetupComplete(true); @@ -119,7 +122,8 @@ service->SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); service->SetPassphraseRequired(true); service->SetPassphraseRequiredForDecryption(true); - return sync_ui_util::ENTER_PASSPHRASE; + return std::make_tuple(sync_ui_util::SYNC_ERROR, + sync_ui_util::ENTER_PASSPHRASE); } case STATUS_CASE_SYNCED: { service->SetFirstSetupComplete(true); @@ -127,7 +131,7 @@ service->SetDetailedSyncStatus(false, syncer::SyncStatus()); service->SetDisableReasons(syncer::SyncService::DISABLE_REASON_NONE); service->SetPassphraseRequired(false); - return sync_ui_util::NO_ACTION; + return std::make_tuple(sync_ui_util::SYNCED, sync_ui_util::NO_ACTION); } case STATUS_CASE_SYNC_DISABLED_BY_POLICY: { service->SetDisableReasons( @@ -136,12 +140,30 @@ service->SetTransportState(syncer::SyncService::TransportState::DISABLED); service->SetPassphraseRequired(false); service->SetDetailedSyncStatus(false, syncer::SyncStatus()); - return sync_ui_util::NO_ACTION; + return std::make_tuple(sync_ui_util::SYNCED, sync_ui_util::NO_ACTION); + } + case STATUS_CASE_SYNC_RESET_FROM_DASHBOARD: { + // Note: On desktop, if there is a primary account, then + // DISABLE_REASON_USER_CHOICE can only occur if Sync was reset from the + // dashboard, and the UI treats it as such. + service->SetDisableReasons( + syncer::SyncService::DISABLE_REASON_USER_CHOICE); + service->SetFirstSetupComplete(true); + service->SetTransportState(syncer::SyncService::TransportState::ACTIVE); + service->SetPassphraseRequired(false); + service->SetDetailedSyncStatus(false, syncer::SyncStatus()); + // This case gets different treatment depending on whether UnifiedConsent + // is enabled, see crbug.com/943983 and crbug.com/977980. + sync_ui_util::MessageType expected_message_type = + unified_consent::IsUnifiedConsentFeatureEnabled() + ? sync_ui_util::SYNC_ERROR + : sync_ui_util::PRE_SYNCED; + return std::make_tuple(expected_message_type, sync_ui_util::NO_ACTION); } case NUMBER_OF_STATUS_CASES: NOTREACHED(); } - return sync_ui_util::NO_ACTION; + return std::make_tuple(sync_ui_util::PRE_SYNCED, sync_ui_util::NO_ACTION); } std::unique_ptr<KeyedService> BuildTestSyncService( @@ -165,7 +187,6 @@ // This test ensures that each distinctive SyncService status will return a // unique combination of status and link messages from GetStatusLabels(). -// Crashes on Win and Mac. https://crbug.com/954365 TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { std::set<base::string16> messages; for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { @@ -177,19 +198,23 @@ identity::IdentityManager* identity_manager = environment->identity_manager(); - // Need a primary account signed in before calling GetDistinctCase(). + // Need a primary account signed in before calling SetUpDistinctCase(). environment->MakePrimaryAccountAvailable(kTestUser); TestSyncService* service = static_cast<TestSyncService*>( ProfileSyncServiceFactory::GetForProfile(profile.get())); - sync_ui_util::ActionType expected_action_type = - GetDistinctCase(service, identity_manager, idx); + sync_ui_util::MessageType expected_message_type; + sync_ui_util::ActionType expected_action_type; + std::tie(expected_message_type, expected_action_type) = + SetUpDistinctCase(service, identity_manager, idx); base::string16 status_label; base::string16 link_label; sync_ui_util::ActionType action_type = sync_ui_util::NO_ACTION; - sync_ui_util::GetStatusLabels(profile.get(), &status_label, &link_label, - &action_type); + sync_ui_util::MessageType message_type = sync_ui_util::GetStatusLabels( + profile.get(), &status_label, &link_label, &action_type); + EXPECT_EQ(expected_message_type, message_type) + << "Wrong message type returned for case #" << idx; EXPECT_EQ(expected_action_type, action_type) << "Wrong action returned for case #" << idx; // If the status and link message combination is already present in the set
diff --git a/chrome/browser/translate/android/translate_bridge.cc b/chrome/browser/translate/android/translate_bridge.cc index f9ca78e..6e6a341 100644 --- a/chrome/browser/translate/android/translate_bridge.cc +++ b/chrome/browser/translate/android/translate_bridge.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/TranslateBridge_jni.h" #include "chrome/browser/language/language_model_manager_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" @@ -14,7 +15,6 @@ #include "components/translate/core/browser/translate_manager.h" #include "components/translate/core/browser/translate_prefs.h" #include "content/public/browser/web_contents.h" -#include "jni/TranslateBridge_jni.h" static ChromeTranslateClient* GetTranslateClient( const base::android::JavaParamRef<jobject>& j_web_contents) {
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index ec2dc97..917dedb 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1525,6 +1525,7 @@ "ash/tab_scrubber.h", "ash/tablet_mode_client.cc", "ash/tablet_mode_client.h", + "ash/tablet_mode_client_observer.h", "ash/test_ime_controller.cc", "ash/test_ime_controller.h", "ash/vpn_list_forwarder.cc", @@ -3922,6 +3923,8 @@ sources += [ "ash/ash_test_util.cc", "ash/ash_test_util.h", + "ash/fake_tablet_mode_controller.cc", + "ash/fake_tablet_mode_controller.h", "ash/test_login_screen.cc", "ash/test_login_screen.h", "ash/test_login_screen_model.cc",
diff --git a/chrome/browser/ui/android/DEPS b/chrome/browser/ui/android/DEPS new file mode 100644 index 0000000..17f36cf9 --- /dev/null +++ b/chrome/browser/ui/android/DEPS
@@ -0,0 +1,3 @@ +include_rules = { + "+chrome/android/features/keyboard_accessory/jni_headers", +}
diff --git a/chrome/browser/ui/android/android_about_app_info.cc b/chrome/browser/ui/android/android_about_app_info.cc index 96c805a..3400db8 100644 --- a/chrome/browser/ui/android/android_about_app_info.cc +++ b/chrome/browser/ui/android/android_about_app_info.cc
@@ -9,8 +9,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/system/sys_info.h" +#include "chrome/android/chrome_jni_headers/ChromeVersionInfo_jni.h" #include "content/public/common/user_agent.h" -#include "jni/ChromeVersionInfo_jni.h" std::string AndroidAboutAppInfo::GetGmsInfo() { JNIEnv* env = base::android::AttachCurrentThread();
diff --git a/chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.cc b/chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.cc index f1153427..c470c1bab 100644 --- a/chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.cc +++ b/chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.cc
@@ -9,12 +9,12 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/callback.h" +#include "chrome/android/features/keyboard_accessory/jni_headers/AutofillKeyboardAccessoryViewBridge_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "chrome/browser/ui/autofill/autofill_popup_controller.h" #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" #include "components/autofill/core/browser/ui/suggestion.h" -#include "jni/AutofillKeyboardAccessoryViewBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "ui/base/resource/resource_bundle.h"
diff --git a/chrome/browser/ui/android/autofill/autofill_logger_android.cc b/chrome/browser/ui/android/autofill/autofill_logger_android.cc index 93805a7..f04a860 100644 --- a/chrome/browser/ui/android/autofill/autofill_logger_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_logger_android.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" -#include "jni/AutofillLogger_jni.h" +#include "chrome/android/chrome_jni_headers/AutofillLogger_jni.h" using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc index 0f24006b..b5e55ef 100644 --- a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc
@@ -9,6 +9,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/command_line.h" +#include "chrome/android/chrome_jni_headers/AutofillPopupBridge_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/autofill/autofill_keyboard_accessory_adapter.h" #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.h" @@ -19,7 +20,6 @@ #include "components/autofill/core/browser/ui/suggestion.h" #include "components/autofill/core/common/autofill_util.h" #include "components/security_state/core/security_state.h" -#include "jni/AutofillPopupBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "ui/base/resource/resource_bundle.h"
diff --git a/chrome/browser/ui/android/autofill/card_expiration_date_fix_flow_view_android.cc b/chrome/browser/ui/android/autofill/card_expiration_date_fix_flow_view_android.cc index a3924153..9059e65 100644 --- a/chrome/browser/ui/android/autofill/card_expiration_date_fix_flow_view_android.cc +++ b/chrome/browser/ui/android/autofill/card_expiration_date_fix_flow_view_android.cc
@@ -6,10 +6,11 @@ #include <utility> #include "chrome/browser/ui/android/autofill/card_expiration_date_fix_flow_view_android.h" + +#include "chrome/android/chrome_jni_headers/AutofillExpirationDateFixFlowBridge_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "components/autofill/core/browser/ui/payments/card_expiration_date_fix_flow_view_delegate_mobile.h" #include "content/public/browser/web_contents.h" -#include "jni/AutofillExpirationDateFixFlowBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h"
diff --git a/chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.cc b/chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.cc index 1c51a09..8cbf660 100644 --- a/chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.cc +++ b/chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.cc
@@ -4,10 +4,10 @@ #include "chrome/browser/ui/android/autofill/card_name_fix_flow_view_android.h" +#include "chrome/android/chrome_jni_headers/AutofillNameFixFlowBridge_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "components/autofill/core/browser/ui/payments/card_name_fix_flow_view_delegate_mobile.h" #include "content/public/browser/web_contents.h" -#include "jni/AutofillNameFixFlowBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h"
diff --git a/chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.cc b/chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.cc index ee434f3..3158269 100644 --- a/chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.cc +++ b/chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h" +#include "chrome/android/chrome_jni_headers/CardUnmaskBridge_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/ui/autofill/payments/create_card_unmask_prompt_view.h" #include "components/autofill/core/browser/ui/payments/card_unmask_prompt_controller.h" #include "content/public/browser/web_contents.h" -#include "jni/CardUnmaskBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h"
diff --git a/chrome/browser/ui/android/autofill/credit_card_scanner_view_android.cc b/chrome/browser/ui/android/autofill/credit_card_scanner_view_android.cc index 09e2b4b..d500d8a 100644 --- a/chrome/browser/ui/android/autofill/credit_card_scanner_view_android.cc +++ b/chrome/browser/ui/android/autofill/credit_card_scanner_view_android.cc
@@ -9,11 +9,11 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/CreditCardScannerBridge_jni.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "chrome/browser/ui/autofill/payments/credit_card_scanner_view_delegate.h" #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/field_types.h" -#include "jni/CreditCardScannerBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h"
diff --git a/chrome/browser/ui/android/bluetooth_chooser_android.cc b/chrome/browser/ui/android/bluetooth_chooser_android.cc index b0af616..ed15f40 100644 --- a/chrome/browser/ui/android/bluetooth_chooser_android.cc +++ b/chrome/browser/ui/android/bluetooth_chooser_android.cc
@@ -7,12 +7,12 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/BluetoothChooserDialog_jni.h" #include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/common/url_constants.h" #include "components/security_state/core/security_state.h" #include "components/url_formatter/elide_url.h" #include "content/public/browser/render_frame_host.h" -#include "jni/BluetoothChooserDialog_jni.h" #include "ui/android/window_android.h" #include "url/gurl.h" #include "url/origin.h"
diff --git a/chrome/browser/ui/android/chrome_http_auth_handler.cc b/chrome/browser/ui/android/chrome_http_auth_handler.cc index 2b86620..5ce1c84 100644 --- a/chrome/browser/ui/android/chrome_http_auth_handler.cc +++ b/chrome/browser/ui/android/chrome_http_auth_handler.cc
@@ -12,7 +12,7 @@ #include "base/logging.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" -#include "jni/ChromeHttpAuthHandler_jni.h" +#include "chrome/android/chrome_jni_headers/ChromeHttpAuthHandler_jni.h" using base::android::AttachCurrentThread; using base::android::CheckException;
diff --git a/chrome/browser/ui/android/context_menu_helper.cc b/chrome/browser/ui/android/context_menu_helper.cc index e5308ae..c7825d65 100644 --- a/chrome/browser/ui/android/context_menu_helper.cc +++ b/chrome/browser/ui/android/context_menu_helper.cc
@@ -13,6 +13,8 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" +#include "chrome/android/chrome_jni_headers/ContextMenuHelper_jni.h" +#include "chrome/android/chrome_jni_headers/ContextMenuParams_jni.h" #include "chrome/browser/android/download/download_controller_base.h" #include "chrome/browser/image_decoder.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h" @@ -22,8 +24,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/common/context_menu_params.h" -#include "jni/ContextMenuHelper_jni.h" -#include "jni/ContextMenuParams_jni.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/web/web_context_menu_data.h" #include "ui/android/view_android.h"
diff --git a/chrome/browser/ui/android/infobars/ads_blocked_infobar.cc b/chrome/browser/ui/android/infobars/ads_blocked_infobar.cc index 3b65812..08d4f3ee 100644 --- a/chrome/browser/ui/android/infobars/ads_blocked_infobar.cc +++ b/chrome/browser/ui/android/infobars/ads_blocked_infobar.cc
@@ -8,7 +8,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" -#include "jni/AdsBlockedInfoBar_jni.h" +#include "chrome/android/chrome_jni_headers/AdsBlockedInfoBar_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.cc b/chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.cc index b761bf7f..965118042 100644 --- a/chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.cc +++ b/chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.cc
@@ -8,10 +8,10 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/AutofillCreditCardFillingInfoBar_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h" -#include "jni/AutofillCreditCardFillingInfoBar_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h" #include "url/gurl.h"
diff --git a/chrome/browser/ui/android/infobars/autofill_save_card_infobar.cc b/chrome/browser/ui/android/infobars/autofill_save_card_infobar.cc index 18e211a..50c6c8a 100644 --- a/chrome/browser/ui/android/infobars/autofill_save_card_infobar.cc +++ b/chrome/browser/ui/android/infobars/autofill_save_card_infobar.cc
@@ -8,13 +8,13 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/AutofillSaveCardInfoBar_jni.h" #include "chrome/browser/android/android_theme_resources.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/autofill/core/browser/payments/autofill_save_card_infobar_delegate_mobile.h" #include "components/autofill/core/browser/payments/autofill_save_card_infobar_mobile.h" #include "components/autofill/core/browser/payments/legal_message_line.h" -#include "jni/AutofillSaveCardInfoBar_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h" #include "url/gurl.h"
diff --git a/chrome/browser/ui/android/infobars/confirm_infobar.cc b/chrome/browser/ui/android/infobars/confirm_infobar.cc index f5c996b7..291507c 100644 --- a/chrome/browser/ui/android/infobars/confirm_infobar.cc +++ b/chrome/browser/ui/android/infobars/confirm_infobar.cc
@@ -8,11 +8,11 @@ #include <utility> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ConfirmInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/confirm_infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/ConfirmInfoBar_jni.h" #include "ui/android/window_android.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/ui/android/infobars/download_progress_infobar.cc b/chrome/browser/ui/android/infobars/download_progress_infobar.cc index 9ae8f2ea..3a54409b 100644 --- a/chrome/browser/ui/android/infobars/download_progress_infobar.cc +++ b/chrome/browser/ui/android/infobars/download_progress_infobar.cc
@@ -7,11 +7,11 @@ #include <memory> #include <utility> +#include "chrome/android/chrome_jni_headers/DownloadProgressInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/DownloadProgressInfoBar_jni.h" #include "ui/android/window_android.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/duplicate_download_infobar.cc b/chrome/browser/ui/android/infobars/duplicate_download_infobar.cc index bec1353..0b698fc 100644 --- a/chrome/browser/ui/android/infobars/duplicate_download_infobar.cc +++ b/chrome/browser/ui/android/infobars/duplicate_download_infobar.cc
@@ -9,8 +9,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/DuplicateDownloadInfoBar_jni.h" #include "chrome/browser/android/download/duplicate_download_infobar_delegate.h" -#include "jni/DuplicateDownloadInfoBar_jni.h" using android::DuplicateDownloadInfoBarDelegate;
diff --git a/chrome/browser/ui/android/infobars/framebust_block_infobar.cc b/chrome/browser/ui/android/infobars/framebust_block_infobar.cc index dbaa1c1..6982ddf 100644 --- a/chrome/browser/ui/android/infobars/framebust_block_infobar.cc +++ b/chrome/browser/ui/android/infobars/framebust_block_infobar.cc
@@ -9,6 +9,7 @@ #include "base/android/jni_string.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/FramebustBlockInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/android/interventions/framebust_block_message_delegate_bridge.h" @@ -16,7 +17,6 @@ #include "chrome/browser/ui/interventions/intervention_infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/FramebustBlockInfoBar_jni.h" FramebustBlockInfoBar::FramebustBlockInfoBar( std::unique_ptr<FramebustBlockMessageDelegate> message_delegate)
diff --git a/chrome/browser/ui/android/infobars/generated_password_saved_infobar.cc b/chrome/browser/ui/android/infobars/generated_password_saved_infobar.cc index 9312f7f..1d5f097 100644 --- a/chrome/browser/ui/android/infobars/generated_password_saved_infobar.cc +++ b/chrome/browser/ui/android/infobars/generated_password_saved_infobar.cc
@@ -10,9 +10,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/GeneratedPasswordSavedInfoBarDelegate_jni.h" #include "chrome/browser/infobars/infobar_service.h" #include "content/public/browser/web_contents.h" -#include "jni/GeneratedPasswordSavedInfoBarDelegate_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/infobar_android.cc b/chrome/browser/ui/android/infobars/infobar_android.cc index 4c57fb3..50839dd 100644 --- a/chrome/browser/ui/android/infobars/infobar_android.cc +++ b/chrome/browser/ui/android/infobars/infobar_android.cc
@@ -9,11 +9,11 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/strings/string_util.h" +#include "chrome/android/chrome_jni_headers/InfoBar_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar_delegate.h" -#include "jni/InfoBar_jni.h" using base::android::JavaParamRef; using base::android::JavaRef;
diff --git a/chrome/browser/ui/android/infobars/infobar_container_android.cc b/chrome/browser/ui/android/infobars/infobar_container_android.cc index 45e56e0..73264a2 100644 --- a/chrome/browser/ui/android/infobars/infobar_container_android.cc +++ b/chrome/browser/ui/android/infobars/infobar_container_android.cc
@@ -7,12 +7,12 @@ #include "base/android/jni_android.h" #include "base/logging.h" #include "base/metrics/histogram_functions.h" +#include "chrome/android/chrome_jni_headers/InfoBarContainer_jni.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/android/infobars/infobar_android.h" #include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/InfoBarContainer_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/installable_ambient_badge_infobar.cc b/chrome/browser/ui/android/infobars/installable_ambient_badge_infobar.cc index da1928f..a468795 100644 --- a/chrome/browser/ui/android/infobars/installable_ambient_badge_infobar.cc +++ b/chrome/browser/ui/android/infobars/installable_ambient_badge_infobar.cc
@@ -7,8 +7,8 @@ #include <utility> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/InstallableAmbientBadgeInfoBar_jni.h" #include "chrome/browser/installable/installable_ambient_badge_infobar_delegate.h" -#include "jni/InstallableAmbientBadgeInfoBar_jni.h" #include "ui/gfx/android/java_bitmap.h" InstallableAmbientBadgeInfoBar::InstallableAmbientBadgeInfoBar(
diff --git a/chrome/browser/ui/android/infobars/instant_apps_infobar.cc b/chrome/browser/ui/android/infobars/instant_apps_infobar.cc index 63d1d8e7..db4b24b 100644 --- a/chrome/browser/ui/android/infobars/instant_apps_infobar.cc +++ b/chrome/browser/ui/android/infobars/instant_apps_infobar.cc
@@ -7,8 +7,8 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" +#include "chrome/android/chrome_jni_headers/InstantAppsInfoBar_jni.h" #include "chrome/browser/android/instantapps/instant_apps_infobar_delegate.h" -#include "jni/InstantAppsInfoBar_jni.h" InstantAppsInfoBar::InstantAppsInfoBar( std::unique_ptr<InstantAppsInfoBarDelegate> delegate)
diff --git a/chrome/browser/ui/android/infobars/near_oom_infobar.cc b/chrome/browser/ui/android/infobars/near_oom_infobar.cc index c1532f8..87f5232 100644 --- a/chrome/browser/ui/android/infobars/near_oom_infobar.cc +++ b/chrome/browser/ui/android/infobars/near_oom_infobar.cc
@@ -11,13 +11,13 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/NearOomInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/interventions/intervention_delegate.h" #include "chrome/browser/ui/interventions/intervention_infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/NearOomInfoBar_jni.h" NearOomInfoBar::NearOomInfoBar(InterventionDelegate* delegate) : InfoBarAndroid(std::make_unique<InterventionInfoBarDelegate>(
diff --git a/chrome/browser/ui/android/infobars/near_oom_reduction_infobar.cc b/chrome/browser/ui/android/infobars/near_oom_reduction_infobar.cc index a1660a2..5d3253f2 100644 --- a/chrome/browser/ui/android/infobars/near_oom_reduction_infobar.cc +++ b/chrome/browser/ui/android/infobars/near_oom_reduction_infobar.cc
@@ -11,13 +11,13 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/memory/ptr_util.h" +#include "chrome/android/chrome_jni_headers/NearOomReductionInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/ui/interventions/intervention_delegate.h" #include "chrome/browser/ui/interventions/intervention_infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/NearOomReductionInfoBar_jni.h" NearOomReductionInfoBar::NearOomReductionInfoBar(InterventionDelegate* delegate) : InfoBarAndroid(std::make_unique<InterventionInfoBarDelegate>(
diff --git a/chrome/browser/ui/android/infobars/permission_infobar.cc b/chrome/browser/ui/android/infobars/permission_infobar.cc index a8a44ece..f8dd799 100644 --- a/chrome/browser/ui/android/infobars/permission_infobar.cc +++ b/chrome/browser/ui/android/infobars/permission_infobar.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/PermissionInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/ui/android/infobars/confirm_infobar.h" #include "components/content_settings/core/common/content_settings_types.h" -#include "jni/PermissionInfoBar_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/ui/android/infobars/previews_lite_page_infobar.cc b/chrome/browser/ui/android/infobars/previews_lite_page_infobar.cc index 29fbac9c..7a92207a 100644 --- a/chrome/browser/ui/android/infobars/previews_lite_page_infobar.cc +++ b/chrome/browser/ui/android/infobars/previews_lite_page_infobar.cc
@@ -8,7 +8,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" -#include "jni/PreviewsLitePageInfoBar_jni.h" +#include "chrome/android/chrome_jni_headers/PreviewsLitePageInfoBar_jni.h" PreviewsLitePageInfoBar::PreviewsLitePageInfoBar( std::unique_ptr<PreviewsLitePageInfoBarDelegate> delegate)
diff --git a/chrome/browser/ui/android/infobars/reader_mode_infobar.cc b/chrome/browser/ui/android/infobars/reader_mode_infobar.cc index 45f435bf..663f20b 100644 --- a/chrome/browser/ui/android/infobars/reader_mode_infobar.cc +++ b/chrome/browser/ui/android/infobars/reader_mode_infobar.cc
@@ -7,11 +7,11 @@ #include <memory> #include <utility> +#include "chrome/android/chrome_jni_headers/ReaderModeInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/ReaderModeInfoBar_jni.h" #include "ui/android/window_android.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/save_password_infobar.cc b/chrome/browser/ui/android/infobars/save_password_infobar.cc index 50a71ef..f56e114 100644 --- a/chrome/browser/ui/android/infobars/save_password_infobar.cc +++ b/chrome/browser/ui/android/infobars/save_password_infobar.cc
@@ -9,9 +9,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/SavePasswordInfoBar_jni.h" #include "chrome/browser/password_manager/save_password_infobar_delegate_android.h" #include "components/password_manager/core/common/credential_manager_types.h" -#include "jni/SavePasswordInfoBar_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc b/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc index 30f448aa..ce2e797 100644 --- a/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc +++ b/chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/SearchGeolocationDisclosureInfoBar_jni.h" #include "chrome/browser/android/search_permissions/search_geolocation_disclosure_infobar_delegate.h" -#include "jni/SearchGeolocationDisclosureInfoBar_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.cc b/chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.cc index d2eb7d0..22ee70bf 100644 --- a/chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.cc +++ b/chrome/browser/ui/android/infobars/simple_confirm_infobar_builder.cc
@@ -8,11 +8,11 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/macros.h" +#include "chrome/android/chrome_jni_headers/SimpleConfirmInfoBarBuilder_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/infobar.h" -#include "jni/SimpleConfirmInfoBarBuilder_jni.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/image/image.h"
diff --git a/chrome/browser/ui/android/infobars/survey_infobar.cc b/chrome/browser/ui/android/infobars/survey_infobar.cc index a4e5e65f..9103598 100644 --- a/chrome/browser/ui/android/infobars/survey_infobar.cc +++ b/chrome/browser/ui/android/infobars/survey_infobar.cc
@@ -8,11 +8,11 @@ #include <utility> #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/SurveyInfoBar_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/infobars/infobar_service.h" #include "components/infobars/core/infobar_delegate.h" #include "content/public/browser/web_contents.h" -#include "jni/SurveyInfoBar_jni.h" #include "ui/android/window_android.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/infobars/translate_compact_infobar.cc b/chrome/browser/ui/android/infobars/translate_compact_infobar.cc index cea221e..d2abace8 100644 --- a/chrome/browser/ui/android/infobars/translate_compact_infobar.cc +++ b/chrome/browser/ui/android/infobars/translate_compact_infobar.cc
@@ -12,12 +12,12 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/android/jni_weak_ref.h" +#include "chrome/android/chrome_jni_headers/TranslateCompactInfoBar_jni.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/translate/android/translate_utils.h" #include "components/translate/core/browser/translate_infobar_delegate.h" #include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_context.h" -#include "jni/TranslateCompactInfoBar_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/infobars/update_password_infobar.cc b/chrome/browser/ui/android/infobars/update_password_infobar.cc index 942d88ca..41388b0 100644 --- a/chrome/browser/ui/android/infobars/update_password_infobar.cc +++ b/chrome/browser/ui/android/infobars/update_password_infobar.cc
@@ -9,9 +9,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/UpdatePasswordInfoBar_jni.h" #include "chrome/browser/password_manager/update_password_infobar_delegate_android.h" #include "components/password_manager/core/common/credential_manager_types.h" -#include "jni/UpdatePasswordInfoBar_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/interventions/framebust_block_message_delegate_bridge.cc b/chrome/browser/ui/android/interventions/framebust_block_message_delegate_bridge.cc index 14f6aa8..1adffae 100644 --- a/chrome/browser/ui/android/interventions/framebust_block_message_delegate_bridge.cc +++ b/chrome/browser/ui/android/interventions/framebust_block_message_delegate_bridge.cc
@@ -10,7 +10,6 @@ #include "base/macros.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/ui/interventions/framebust_block_message_delegate.h" -#include "jni/FramebustBlockMessageDelegateBridge_jni.h" using base::android::ScopedJavaLocalRef; using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc b/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc index e42db85..ac0e615 100644 --- a/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc +++ b/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc
@@ -9,6 +9,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/JavascriptAppModalDialog_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/ui/javascript_dialogs/chrome_javascript_native_dialog_factory.h" #include "components/app_modal/app_modal_dialog_queue.h" @@ -19,7 +20,6 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/common/javascript_dialog_type.h" -#include "jni/JavascriptAppModalDialog_jni.h" #include "ui/android/window_android.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/ui/android/javascript_dialog_android.cc b/chrome/browser/ui/android/javascript_dialog_android.cc index 6f3f94d..3b58230 100644 --- a/chrome/browser/ui/android/javascript_dialog_android.cc +++ b/chrome/browser/ui/android/javascript_dialog_android.cc
@@ -8,11 +8,11 @@ #include "base/android/jni_string.h" #include "base/macros.h" #include "base/metrics/histogram_macros.h" +#include "chrome/android/chrome_jni_headers/JavascriptTabModalDialog_jni.h" #include "chrome/browser/android/tab_android.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" -#include "jni/JavascriptTabModalDialog_jni.h" #include "ui/android/window_android.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.cc b/chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.cc index 9516cc82..858dc74 100644 --- a/chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.cc +++ b/chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.cc
@@ -6,10 +6,10 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/OmniboxUrlEmphasizer_jni.h" #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" #include "chrome/browser/profiles/profile_android.h" #include "components/omnibox/browser/autocomplete_input.h" -#include "jni/OmniboxUrlEmphasizer_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/omnibox/omnibox_view_util.cc b/chrome/browser/ui/android/omnibox/omnibox_view_util.cc index f8939c4..516dbf4b 100644 --- a/chrome/browser/ui/android/omnibox/omnibox_view_util.cc +++ b/chrome/browser/ui/android/omnibox/omnibox_view_util.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/ui/android/omnibox/omnibox_view_util.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/OmniboxViewUtil_jni.h" #include "components/omnibox/browser/omnibox_view.h" -#include "jni/OmniboxViewUtil_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/page_info/certificate_chain_helper.cc b/chrome/browser/ui/android/page_info/certificate_chain_helper.cc index dcb356c..e8e9124 100644 --- a/chrome/browser/ui/android/page_info/certificate_chain_helper.cc +++ b/chrome/browser/ui/android/page_info/certificate_chain_helper.cc
@@ -5,11 +5,11 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/CertificateChainHelper_jni.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/ssl_status.h" #include "content/public/browser/web_contents.h" -#include "jni/CertificateChainHelper_jni.h" #include "net/cert/x509_certificate.h" #include "net/cert/x509_util.h"
diff --git a/chrome/browser/ui/android/page_info/certificate_viewer_android.cc b/chrome/browser/ui/android/page_info/certificate_viewer_android.cc index b30ede3..e4761e4 100644 --- a/chrome/browser/ui/android/page_info/certificate_viewer_android.cc +++ b/chrome/browser/ui/android/page_info/certificate_viewer_android.cc
@@ -4,9 +4,9 @@ #include "base/android/jni_string.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/CertificateViewer_jni.h" #include "chrome/browser/certificate_viewer.h" #include "chrome/grit/generated_resources.h" -#include "jni/CertificateViewer_jni.h" #include "net/cert/x509_certificate.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/ui/android/page_info/connection_info_popup_android.cc b/chrome/browser/ui/android/page_info/connection_info_popup_android.cc index d29a8d7..4e6c30ca 100644 --- a/chrome/browser/ui/android/page_info/connection_info_popup_android.cc +++ b/chrome/browser/ui/android/page_info/connection_info_popup_android.cc
@@ -7,6 +7,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/ConnectionInfoPopup_jni.h" #include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" @@ -19,7 +20,6 @@ #include "content/public/browser/navigation_entry.h" #include "content/public/browser/ssl_status.h" #include "content/public/browser/web_contents.h" -#include "jni/ConnectionInfoPopup_jni.h" #include "net/cert/x509_certificate.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/ui/android/page_info/page_info_controller_android.cc b/chrome/browser/ui/android/page_info/page_info_controller_android.cc index 211424d..f710d8d 100644 --- a/chrome/browser/ui/android/page_info/page_info_controller_android.cc +++ b/chrome/browser/ui/android/page_info/page_info_controller_android.cc
@@ -8,6 +8,7 @@ #include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/stl_util.h" +#include "chrome/android/chrome_jni_headers/PageInfoController_jni.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ssl/security_state_tab_helper.h" @@ -21,7 +22,6 @@ #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" -#include "jni/PageInfoController_jni.h" #include "url/origin.h" using base::android::ConvertUTF16ToJavaString;
diff --git a/chrome/browser/ui/android/passwords/manual_filling_view_android.cc b/chrome/browser/ui/android/passwords/manual_filling_view_android.cc index c7335a8..466a0186 100644 --- a/chrome/browser/ui/android/passwords/manual_filling_view_android.cc +++ b/chrome/browser/ui/android/passwords/manual_filling_view_android.cc
@@ -18,6 +18,8 @@ #include "base/bind.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/features/keyboard_accessory/jni_headers/ManualFillingComponentBridge_jni.h" +#include "chrome/android/features/keyboard_accessory/jni_headers/UserInfoField_jni.h" #include "chrome/browser/autofill/manual_filling_controller.h" #include "chrome/browser/autofill/manual_filling_controller_impl.h" #include "chrome/browser/password_manager/password_accessory_controller.h" @@ -25,8 +27,6 @@ #include "chrome/browser/password_manager/password_generation_controller.h" #include "components/autofill/core/browser/ui/accessory_sheet_data.h" #include "components/autofill/core/common/password_form.h" -#include "jni/ManualFillingComponentBridge_jni.h" -#include "jni/UserInfoField_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "ui/gfx/android/java_bitmap.h" @@ -227,6 +227,17 @@ } // static +void JNI_ManualFillingComponentBridge_NotifyFocusedFieldTypeForTesting( + JNIEnv* env, + const base::android::JavaParamRef<jobject>& j_web_contents, + jint j_available) { + ManualFillingControllerImpl::GetOrCreate( + content::WebContents::FromJavaWebContents(j_web_contents)) + ->NotifyFocusedInputChanged( + static_cast<autofill::mojom::FocusedFieldType>(j_available)); +} + +// static void JNI_ManualFillingComponentBridge_SignalAutoGenerationStatusForTesting( JNIEnv* env, const base::android::JavaParamRef<jobject>& j_web_contents,
diff --git a/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc b/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc index 6aec6269..f344cbc 100644 --- a/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc +++ b/chrome/browser/ui/android/passwords/password_generation_dialog_view_android.cc
@@ -8,12 +8,12 @@ #include "base/android/jni_string.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" +#include "chrome/android/chrome_jni_headers/PasswordGenerationDialogBridge_jni.h" #include "chrome/browser/password_manager/password_generation_controller_impl.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/password_manager/core/browser/password_manager_driver.h" #include "components/strings/grit/components_strings.h" -#include "jni/PasswordGenerationDialogBridge_jni.h" #include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/chrome/browser/ui/android/passwords/password_generation_editing_popup_view_android.cc b/chrome/browser/ui/android/passwords/password_generation_editing_popup_view_android.cc index a5fa527..72575dcc 100644 --- a/chrome/browser/ui/android/passwords/password_generation_editing_popup_view_android.cc +++ b/chrome/browser/ui/android/passwords/password_generation_editing_popup_view_android.cc
@@ -10,9 +10,9 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/logging.h" +#include "chrome/android/chrome_jni_headers/PasswordGenerationPopupBridge_jni.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "chrome/browser/ui/passwords/password_generation_popup_controller.h" -#include "jni/PasswordGenerationPopupBridge_jni.h" #include "ui/android/view_android.h" #include "ui/android/window_android.h" #include "ui/gfx/geometry/rect_f.h"
diff --git a/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc b/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc index 873cf64..5ba29d1 100644 --- a/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc +++ b/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc
@@ -6,13 +6,13 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/AutoSigninSnackbarController_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/profiles/profile.h" #include "chrome/grit/generated_resources.h" #include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/strings/grit/components_strings.h" #include "content/public/browser/web_contents.h" -#include "jni/AutoSigninSnackbarController_jni.h" #include "ui/base/l10n/l10n_util.h" using base::android::ScopedJavaLocalRef;
diff --git a/chrome/browser/ui/android/ssl_client_certificate_request.cc b/chrome/browser/ui/android/ssl_client_certificate_request.cc index fbe286f..05bea07 100644 --- a/chrome/browser/ui/android/ssl_client_certificate_request.cc +++ b/chrome/browser/ui/android/ssl_client_certificate_request.cc
@@ -15,6 +15,7 @@ #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/task/post_task.h" +#include "chrome/android/chrome_jni_headers/SSLClientCertificateRequest_jni.h" #include "chrome/browser/ssl/ssl_client_certificate_selector.h" #include "chrome/browser/ui/android/view_android_helper.h" #include "chrome/browser/vr/vr_tab_helper.h" @@ -23,7 +24,6 @@ #include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents_observer.h" -#include "jni/SSLClientCertificateRequest_jni.h" #include "net/base/host_port_pair.h" #include "net/cert/cert_database.h" #include "net/cert/x509_certificate.h"
diff --git a/chrome/browser/ui/android/tab_model/single_tab_model.cc b/chrome/browser/ui/android/tab_model/single_tab_model.cc index 39e6abf..6c3d53d30 100644 --- a/chrome/browser/ui/android/tab_model/single_tab_model.cc +++ b/chrome/browser/ui/android/tab_model/single_tab_model.cc
@@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/android/jni_android.h" +#include "chrome/android/chrome_jni_headers/SingleTabModel_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h" #include "content/public/browser/web_contents.h" -#include "jni/SingleTabModel_jni.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc b/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc index ce552b2..15424ba 100644 --- a/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc +++ b/chrome/browser/ui/android/tab_model/tab_model_jni_bridge.cc
@@ -11,6 +11,7 @@ #include "base/android/jni_weak_ref.h" #include "base/metrics/histogram_macros.h" #include "base/time/time.h" +#include "chrome/android/chrome_jni_headers/TabModelJniBridge_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" @@ -22,7 +23,6 @@ #include "chrome/browser/ui/browser_navigator_params.h" #include "content/public/browser/web_contents.h" #include "content/public/common/resource_request_body_android.h" -#include "jni/TabModelJniBridge_jni.h" #include "ui/base/window_open_disposition.h" using base::android::AttachCurrentThread;
diff --git a/chrome/browser/ui/android/tab_model/tab_model_observer_jni_bridge.cc b/chrome/browser/ui/android/tab_model/tab_model_observer_jni_bridge.cc index f46ff84..9aeb2a4c 100644 --- a/chrome/browser/ui/android/tab_model/tab_model_observer_jni_bridge.cc +++ b/chrome/browser/ui/android/tab_model/tab_model_observer_jni_bridge.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/ui/android/tab_model/tab_model_observer_jni_bridge.h" +#include "chrome/android/chrome_jni_headers/TabModelObserverJniBridge_jni.h" #include "chrome/browser/android/tab_android.h" #include "chrome/browser/ui/android/tab_model/tab_model.h" #include "chrome/browser/ui/android/tab_model/tab_model_jni_bridge.h" #include "chrome/browser/ui/android/tab_model/tab_model_observer.h" -#include "jni/TabModelObserverJniBridge_jni.h" using base::android::AttachCurrentThread; using base::android::JavaObjectArrayReader;
diff --git a/chrome/browser/ui/android/toolbar/location_bar_model_android.cc b/chrome/browser/ui/android/toolbar/location_bar_model_android.cc index b994b6c..8d12ce55 100644 --- a/chrome/browser/ui/android/toolbar/location_bar_model_android.cc +++ b/chrome/browser/ui/android/toolbar/location_bar_model_android.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ui/android/toolbar/location_bar_model_android.h" #include "base/android/jni_string.h" +#include "chrome/android/chrome_jni_headers/LocationBarModel_jni.h" #include "chrome/common/url_constants.h" #include "chrome/common/webui_url_constants.h" #include "components/omnibox/browser/location_bar_model_impl.h" @@ -12,7 +13,6 @@ #include "content/public/browser/ssl_status.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_constants.h" -#include "jni/LocationBarModel_jni.h" #include "ui/base/device_form_factor.h" using base::android::JavaParamRef;
diff --git a/chrome/browser/ui/android/usb_chooser_dialog_android.cc b/chrome/browser/ui/android/usb_chooser_dialog_android.cc index 2ded612f..78423c1 100644 --- a/chrome/browser/ui/android/usb_chooser_dialog_android.cc +++ b/chrome/browser/ui/android/usb_chooser_dialog_android.cc
@@ -13,6 +13,7 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/strings/utf_string_conversions.h" +#include "chrome/android/chrome_jni_headers/UsbChooserDialog_jni.h" #include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/vr/vr_tab_helper.h" #include "chrome/common/url_constants.h" @@ -21,7 +22,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "device/vr/buildflags/buildflags.h" -#include "jni/UsbChooserDialog_jni.h" #include "ui/android/window_android.h" #include "url/gurl.h"
diff --git a/chrome/browser/ui/app_list/app_list_client_impl.cc b/chrome/browser/ui/app_list/app_list_client_impl.cc index 5e88af35..e85a86e2 100644 --- a/chrome/browser/ui/app_list/app_list_client_impl.cc +++ b/chrome/browser/ui/app_list/app_list_client_impl.cc
@@ -10,7 +10,6 @@ #include <vector> #include "ash/public/cpp/app_list/app_list_controller.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" @@ -31,6 +30,7 @@ #include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator_params.h" @@ -47,7 +47,8 @@ AppListClientImpl* g_app_list_client_instance = nullptr; bool IsTabletMode() { - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled(); } } // namespace
diff --git a/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc b/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc index d5d9c73..1c87187e 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_context_menu.cc
@@ -6,7 +6,6 @@ #include <utility> -#include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "base/feature_list.h" #include "chrome/browser/chromeos/arc/app_shortcuts/arc_app_shortcuts_menu_builder.h" @@ -17,6 +16,7 @@ #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/chrome_pages.h" #include "chrome/common/chrome_features.h" #include "chrome/grit/generated_resources.h" @@ -139,7 +139,8 @@ if (arc::ShowPackageInfo(app_info->package_name, arc::mojom::ShowPackageInfoPage::MAIN, controller()->GetAppListDisplayId()) && - !ash::TabletMode::Get()->InTabletMode()) { + !(TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled())) { controller()->DismissView(); } }
diff --git a/chrome/browser/ui/app_list/chrome_app_list_item.cc b/chrome/browser/ui/app_list/chrome_app_list_item.cc index bf86806f..25708f2 100644 --- a/chrome/browser/ui/app_list/chrome_app_list_item.cc +++ b/chrome/browser/ui/app_list/chrome_app_list_item.cc
@@ -6,11 +6,11 @@ #include <utility> -#include "ash/public/cpp/tablet_mode.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/app_list_client_impl.h" #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" #include "chrome/browser/ui/app_list/chrome_app_list_model_updater.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "extensions/browser/app_sorting.h" #include "extensions/browser/extension_system.h" #include "ui/gfx/color_utils.h" @@ -125,7 +125,8 @@ void ChromeAppListItem::MaybeDismissAppList() { // Launching apps can take some time. It looks nicer to dismiss the app list. // Do not close app list for home launcher. - if (!ash::TabletMode::Get()->InTabletMode()) { + if (!TabletModeClient::Get() || + !TabletModeClient::Get()->tablet_mode_enabled()) { GetController()->DismissView(); } }
diff --git a/chrome/browser/ui/app_list/search/search_controller.cc b/chrome/browser/ui/app_list/search/search_controller.cc index 7bdb8faa..faf3c0e 100644 --- a/chrome/browser/ui/app_list/search/search_controller.cc +++ b/chrome/browser/ui/app_list/search/search_controller.cc
@@ -11,7 +11,6 @@ #include "ash/public/cpp/app_list/app_list_config.h" #include "ash/public/cpp/app_list/app_list_features.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_util.h" @@ -27,6 +26,7 @@ #include "chrome/browser/ui/app_list/search/search_result_ranker/ranking_item_util.h" #include "chrome/browser/ui/app_list/search/search_result_ranker/recurrence_ranker.h" #include "chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "third_party/metrics_proto/chrome_os_app_list_launch_event.pb.h" using metrics::ChromeOSAppListLaunchEventProto; @@ -114,8 +114,10 @@ // Launching apps can take some time. It looks nicer to dismiss the app list. // Do not close app list for home launcher. - if (!ash::TabletMode::Get()->InTabletMode()) + if (!TabletModeClient::Get() || + !TabletModeClient::Get()->tablet_mode_enabled()) { list_controller_->DismissView(); + } } void SearchController::InvokeResultAction(ChromeSearchResult* result,
diff --git a/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc index 2b70e3b0..ca32cb3 100644 --- a/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc
@@ -107,7 +107,12 @@ ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() : notification_observer_(std::make_unique<NotificationObserver>()) {} -ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() = default; +ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() { + // Views code observes TabletModeClient and may not be destroyed until + // ash::Shell is, so destroy |tablet_mode_client_| after ash::Shell. + // Also extensions need to remove observers after PostMainMessageLoopRun(). + tablet_mode_client_.reset(); +} void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { // NetworkConnect handles the network connection state machine for the UI. @@ -140,7 +145,11 @@ session_controller_client_->Init(); system_tray_client_ = std::make_unique<SystemTrayClient>(); + + // Makes mojo request to TabletModeController in ash. tablet_mode_client_ = std::make_unique<TabletModeClient>(); + tablet_mode_client_->Init(); + vpn_list_forwarder_ = std::make_unique<VpnListForwarder>(); wallpaper_controller_client_ = std::make_unique<WallpaperControllerClient>();
diff --git a/chrome/browser/ui/ash/fake_tablet_mode_controller.cc b/chrome/browser/ui/ash/fake_tablet_mode_controller.cc new file mode 100644 index 0000000..61a34145 --- /dev/null +++ b/chrome/browser/ui/ash/fake_tablet_mode_controller.cc
@@ -0,0 +1,24 @@ +// 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/ui/ash/fake_tablet_mode_controller.h" + +#include <utility> + +FakeTabletModeController::FakeTabletModeController() = default; + +FakeTabletModeController::~FakeTabletModeController() = default; + +void FakeTabletModeController::SetTabletModeToggleObserver( + ash::TabletModeToggleObserver* observer) { + observer_ = observer; +} + +bool FakeTabletModeController::InTabletMode() const { + return enabled_; +} + +void FakeTabletModeController::SetEnabledForTest(bool enabled) { + enabled_ = enabled; +}
diff --git a/chrome/browser/ui/ash/fake_tablet_mode_controller.h b/chrome/browser/ui/ash/fake_tablet_mode_controller.h new file mode 100644 index 0000000..99c4ae9 --- /dev/null +++ b/chrome/browser/ui/ash/fake_tablet_mode_controller.h
@@ -0,0 +1,33 @@ +// 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_UI_ASH_FAKE_TABLET_MODE_CONTROLLER_H_ +#define CHROME_BROWSER_UI_ASH_FAKE_TABLET_MODE_CONTROLLER_H_ + +#include "ash/public/cpp/tablet_mode.h" +#include "base/macros.h" + +// Simulates the TabletModeController in ash. +class FakeTabletModeController : public ash::TabletMode { + public: + FakeTabletModeController(); + + ~FakeTabletModeController() override; + + bool has_observer() const { return !!observer_; } + + // ash::mojom::TabletModeController: + void SetTabletModeToggleObserver( + ash::TabletModeToggleObserver* observer) override; + bool InTabletMode() const override; + void SetEnabledForTest(bool enabled) override; + + private: + bool enabled_ = false; + ash::TabletModeToggleObserver* observer_ = nullptr; + + DISALLOW_COPY_AND_ASSIGN(FakeTabletModeController); +}; + +#endif // CHROME_BROWSER_UI_ASH_FAKE_TABLET_MODE_CONTROLLER_H_
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc index e412d6b..44d146c 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -14,7 +14,6 @@ #include "ash/public/cpp/shelf_item.h" #include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_prefs.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/window_animation_types.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -57,6 +56,7 @@ #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_helper.h" #include "chrome/browser/ui/ash/session_controller_client_impl.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" @@ -537,7 +537,8 @@ return ash::SHELF_ACTION_WINDOW_MINIMIZED; } - if (ash::TabletMode::Get()->InTabletMode()) { + if (TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled()) { // Run slide down animation to show the window. wm::SetWindowVisibilityAnimationType( native_window, ash::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_SLIDE_DOWN);
diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc index 613b14c..5441814 100644 --- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc
@@ -8,7 +8,6 @@ #include <string> #include "ash/public/cpp/shelf_model.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/metrics/user_metrics.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h" @@ -21,6 +20,7 @@ #include "chrome/browser/ui/ash/launcher/crostini_shelf_context_menu.h" #include "chrome/browser/ui/ash/launcher/extension_launcher_context_menu.h" #include "chrome/browser/ui/ash/launcher/internal_app_shelf_context_menu.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/grit/generated_resources.h" #include "ui/display/types/display_constants.h" #include "ui/gfx/paint_vector_icon.h" @@ -107,7 +107,7 @@ controller_->Close(item_.id); } base::RecordAction(base::UserMetricsAction("CloseFromContextMenu")); - if (ash::TabletMode::Get()->InTabletMode()) { + if (TabletModeClient::Get()->tablet_mode_enabled()) { base::RecordAction( base::UserMetricsAction("Tablet_WindowCloseFromContextMenu")); }
diff --git a/chrome/browser/ui/ash/screen_orientation_delegate_chromeos.cc b/chrome/browser/ui/ash/screen_orientation_delegate_chromeos.cc index b28e45dc..48d404ef 100644 --- a/chrome/browser/ui/ash/screen_orientation_delegate_chromeos.cc +++ b/chrome/browser/ui/ash/screen_orientation_delegate_chromeos.cc
@@ -5,8 +5,8 @@ #include "chrome/browser/ui/ash/screen_orientation_delegate_chromeos.h" #include "ash/display/screen_orientation_controller.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/shell.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "content/public/browser/web_contents.h" namespace { @@ -59,7 +59,8 @@ } bool ScreenOrientationDelegateChromeos::ScreenOrientationProviderSupported() { - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled(); } void ScreenOrientationDelegateChromeos::Unlock(
diff --git a/chrome/browser/ui/ash/tablet_mode_client.cc b/chrome/browser/ui/ash/tablet_mode_client.cc index 8eb8592..e9fbe73 100644 --- a/chrome/browser/ui/ash/tablet_mode_client.cc +++ b/chrome/browser/ui/ash/tablet_mode_client.cc
@@ -9,6 +9,7 @@ #include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "chrome/browser/chromeos/arc/arc_web_contents_data.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_tab_strip_tracker.h" @@ -20,22 +21,57 @@ #include "services/service_manager/public/cpp/connector.h" #include "ui/base/material_design/material_design_controller.h" +namespace { + +TabletModeClient* g_tablet_mode_client_instance = nullptr; + +} // namespace + TabletModeClient::TabletModeClient() { - ash::TabletMode::Get()->AddObserver(this); - OnTabletModeToggled(ash::TabletMode::Get()->InTabletMode()); + DCHECK(!g_tablet_mode_client_instance); + g_tablet_mode_client_instance = this; } TabletModeClient::~TabletModeClient() { - ash::TabletMode::Get()->RemoveObserver(this); + DCHECK_EQ(this, g_tablet_mode_client_instance); + g_tablet_mode_client_instance = nullptr; + // The Ash Shell and TabletMode instance should have been destroyed by now. + DCHECK(!ash::TabletMode::Get()); +} + +void TabletModeClient::Init() { + ash::TabletMode::Get()->SetTabletModeToggleObserver(this); + OnTabletModeToggled(ash::TabletMode::Get()->InTabletMode()); +} + +// static +TabletModeClient* TabletModeClient::Get() { + return g_tablet_mode_client_instance; +} + +void TabletModeClient::AddObserver(TabletModeClientObserver* observer) { + observers_.AddObserver(observer); +} + +void TabletModeClient::RemoveObserver(TabletModeClientObserver* observer) { + observers_.RemoveObserver(observer); } void TabletModeClient::OnTabletModeToggled(bool enabled) { + if (tablet_mode_enabled_ == enabled) + return; + + tablet_mode_enabled_ = enabled; + SetMobileLikeBehaviorEnabled(enabled); + ui::MaterialDesignController::OnTabletModeToggled(enabled); + for (auto& observer : observers_) + observer.OnTabletModeToggled(enabled); } bool TabletModeClient::ShouldTrackBrowser(Browser* browser) { - return ash::TabletMode::Get()->InTabletMode(); + return tablet_mode_enabled_; } void TabletModeClient::OnTabStripModelChanged(
diff --git a/chrome/browser/ui/ash/tablet_mode_client.h b/chrome/browser/ui/ash/tablet_mode_client.h index d226911..309f364a 100644 --- a/chrome/browser/ui/ash/tablet_mode_client.h +++ b/chrome/browser/ui/ash/tablet_mode_client.h
@@ -9,10 +9,12 @@ #include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/macros.h" +#include "base/observer_list.h" #include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" class BrowserTabStripTracker; +class TabletModeClientObserver; // Holds tablet mode state in chrome. Observes ash for changes, then // synchronously fires all its observers. This allows all tablet mode code in @@ -24,6 +26,18 @@ TabletModeClient(); ~TabletModeClient() override; + // Initializes and connects to ash. + void Init(); + + static TabletModeClient* Get(); + + bool tablet_mode_enabled() const { return tablet_mode_enabled_; } + + // Adds the observer and immediately triggers it with the initial state. + void AddObserver(TabletModeClientObserver* observer); + + void RemoveObserver(TabletModeClientObserver* observer); + // ash::TabletModeToggleObserver: void OnTabletModeToggled(bool enabled) override; @@ -41,6 +55,8 @@ // well as starts observing new browser pages if |enabled| is true. void SetMobileLikeBehaviorEnabled(bool enabled); + bool tablet_mode_enabled_ = false; + // We only override the WebKit preferences of webcontents that belong to // tabstrips in browsers. When a webcontents is newly created, its WebKit // preferences are refreshed *before* it's added to any tabstrip, hence @@ -50,6 +66,9 @@ // a refresh of its WebKit prefs. std::unique_ptr<BrowserTabStripTracker> tab_strip_tracker_; + base::ObserverList<TabletModeClientObserver, + true /* check_empty */>::Unchecked observers_; + DISALLOW_COPY_AND_ASSIGN(TabletModeClient); };
diff --git a/chrome/browser/ui/ash/tablet_mode_client_observer.h b/chrome/browser/ui/ash/tablet_mode_client_observer.h new file mode 100644 index 0000000..65af83a --- /dev/null +++ b/chrome/browser/ui/ash/tablet_mode_client_observer.h
@@ -0,0 +1,18 @@ +// 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_UI_ASH_TABLET_MODE_CLIENT_OBSERVER_H_ +#define CHROME_BROWSER_UI_ASH_TABLET_MODE_CLIENT_OBSERVER_H_ + +// Observer for tablet mode changes inside chrome. +class TabletModeClientObserver { + public: + // Fired after the tablet mode has been toggled. + virtual void OnTabletModeToggled(bool enabled) = 0; + + protected: + virtual ~TabletModeClientObserver() {} +}; + +#endif // CHROME_BROWSER_UI_ASH_TABLET_MODE_CLIENT_OBSERVER_H_
diff --git a/chrome/browser/ui/ash/tablet_mode_client_unittest.cc b/chrome/browser/ui/ash/tablet_mode_client_unittest.cc new file mode 100644 index 0000000..ebf0bb6 --- /dev/null +++ b/chrome/browser/ui/ash/tablet_mode_client_unittest.cc
@@ -0,0 +1,73 @@ +// 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/ui/ash/tablet_mode_client.h" + +#include "base/macros.h" +#include "chrome/browser/ui/ash/fake_tablet_mode_controller.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +class TestTabletModeClientObserver : public TabletModeClientObserver { + public: + TestTabletModeClientObserver() = default; + ~TestTabletModeClientObserver() override = default; + + void OnTabletModeToggled(bool enabled) override { + ++toggle_count_; + last_toggle_ = enabled; + } + + int toggle_count_ = 0; + bool last_toggle_ = false; + + private: + DISALLOW_COPY_AND_ASSIGN(TestTabletModeClientObserver); +}; + +using TabletModeClientTest = testing::Test; + +TEST_F(TabletModeClientTest, Construction) { + // In production, TabletModeController is constructed before TabletModeClient + // and destroyed before it too. Match that here. + auto controller = std::make_unique<FakeTabletModeController>(); + TabletModeClient client; + client.Init(); + + // Singleton was initialized. + EXPECT_EQ(&client, TabletModeClient::Get()); + + // Object was set as client. + EXPECT_TRUE(controller->has_observer()); + + controller = nullptr; +} + +TEST_F(TabletModeClientTest, Observers) { + auto controller = std::make_unique<FakeTabletModeController>(); + TestTabletModeClientObserver observer; + TabletModeClient client; + client.Init(); + client.AddObserver(&observer); + + // Observer is not notified with state when added. + EXPECT_EQ(0, observer.toggle_count_); + + // Setting state notifies observer. + client.OnTabletModeToggled(true); + EXPECT_EQ(1, observer.toggle_count_); + EXPECT_TRUE(observer.last_toggle_); + + client.OnTabletModeToggled(false); + EXPECT_EQ(2, observer.toggle_count_); + EXPECT_FALSE(observer.last_toggle_); + + client.RemoveObserver(&observer); + + controller = nullptr; +} + +} // namespace
diff --git a/chrome/browser/ui/ash/tablet_mode_page_behavior_browsertest.cc b/chrome/browser/ui/ash/tablet_mode_page_behavior_browsertest.cc index 5146dfed..bc7e4456 100644 --- a/chrome/browser/ui/ash/tablet_mode_page_behavior_browsertest.cc +++ b/chrome/browser/ui/ash/tablet_mode_page_behavior_browsertest.cc
@@ -3,11 +3,10 @@ // found in the LICENSE file. #include "ash/public/cpp/ash_switches.h" -#include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "base/command_line.h" #include "base/test/scoped_feature_list.h" #include "chrome/browser/browser_features.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -40,11 +39,13 @@ } void ToggleTabletMode() { - ash::ShellTestApi().SetTabletModeEnabledForTest(!GetTabletModeEnabled()); + auto* tablet_mode_client = TabletModeClient::Get(); + tablet_mode_client->OnTabletModeToggled( + !tablet_mode_client->tablet_mode_enabled()); } bool GetTabletModeEnabled() const { - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get()->tablet_mode_enabled(); } content::WebContents* GetActiveWebContents(Browser* browser) const {
diff --git a/chrome/browser/ui/ash/test_login_screen.cc b/chrome/browser/ui/ash/test_login_screen.cc index dde25b3..72977e9 100644 --- a/chrome/browser/ui/ash/test_login_screen.cc +++ b/chrome/browser/ui/ash/test_login_screen.cc
@@ -37,6 +37,7 @@ void TestLoginScreen::ShowParentAccessWidget( const AccountId& child_account_id, base::RepeatingCallback<void(bool success)> callback, - ash::ParentAccessRequestReason reason) {} + ash::ParentAccessRequestReason reason, + bool extra_dimmer) {} void TestLoginScreen::SetAllowLoginAsGuest(bool allow_guest) {}
diff --git a/chrome/browser/ui/ash/test_login_screen.h b/chrome/browser/ui/ash/test_login_screen.h index a073d932..cf55c56 100644 --- a/chrome/browser/ui/ash/test_login_screen.h +++ b/chrome/browser/ui/ash/test_login_screen.h
@@ -40,7 +40,8 @@ void ShowParentAccessWidget( const AccountId& child_account_id, base::RepeatingCallback<void(bool success)> callback, - ash::ParentAccessRequestReason reason) override; + ash::ParentAccessRequestReason reason, + bool extra_dimmer) override; void SetAllowLoginAsGuest(bool allow_guest) override; private:
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc index a30812c..072a05c 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
@@ -125,7 +125,8 @@ } ManualFillingController::GetOrCreate(web_contents_) - ->ShowWhenKeyboardIsVisible(FillingSource::AUTOFILL); + ->UpdateSourceAvailability(FillingSource::AUTOFILL, + !suggestions.empty()); #endif view_->Show(); if (autoselect_first_suggestion) @@ -275,8 +276,11 @@ // should try and move to its desired position. layout_model_.UpdatePopupBounds(); #else + // Assume that suggestions are (still) available. If this is wrong, the method + // |HideViewAndDie| will be called soon after and will hide all suggestions. ManualFillingController::GetOrCreate(web_contents_) - ->ShowWhenKeyboardIsVisible(FillingSource::AUTOFILL); + ->UpdateSourceAvailability(FillingSource::AUTOFILL, + /*has_suggestions=*/true); #endif // Platform-specific draw call. @@ -310,6 +314,14 @@ void AutofillPopupControllerImpl::AcceptSuggestion(int index) { const autofill::Suggestion& suggestion = suggestions_[index]; +#if defined(OS_ANDROID) + auto mf_controller = ManualFillingController::GetOrCreate(web_contents_); + // Accepting a suggestion should hide all suggestions. To prevent them from + // coming up in Multi-Window mode, mark the source as unavailable. + mf_controller->UpdateSourceAvailability(FillingSource::AUTOFILL, + /*has_suggestions=*/false); + mf_controller->Hide(); +#endif delegate_->DidAcceptSuggestion(suggestion.value, suggestion.frontend_id, index); } @@ -554,7 +566,8 @@ void AutofillPopupControllerImpl::HideViewAndDie() { #if defined(OS_ANDROID) ManualFillingController::GetOrCreate(web_contents_) - ->DeactivateFillingSource(FillingSource::AUTOFILL); + ->UpdateSourceAvailability(FillingSource::AUTOFILL, + /*has_suggestions=*/false); #endif if (view_)
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client.cc b/chrome/browser/ui/autofill/chrome_autofill_client.cc index d6a1fda..72ea3662 100644 --- a/chrome/browser/ui/autofill/chrome_autofill_client.cc +++ b/chrome/browser/ui/autofill/chrome_autofill_client.cc
@@ -457,8 +457,6 @@ rfh); if (driver) { driver->GetPasswordGenerationHelper()->ProcessPasswordRequirements(forms); - driver->GetPasswordGenerationHelper()->DetectFormsEligibleForGeneration( - forms); driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); } }
diff --git a/chrome/browser/ui/toolbar/app_menu_model.cc b/chrome/browser/ui/toolbar/app_menu_model.cc index 36b19f6..a111149a 100644 --- a/chrome/browser/ui/toolbar/app_menu_model.cc +++ b/chrome/browser/ui/toolbar/app_menu_model.cc
@@ -79,7 +79,7 @@ #endif #if defined(OS_CHROMEOS) -#include "ash/public/cpp/tablet_mode.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chromeos/constants/chromeos_switches.h" #endif @@ -785,7 +785,8 @@ // Always show this option if we're in tablet mode on Chrome OS. if (base::CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kEnableRequestTabletSite) || - ash::TabletMode::Get()->InTabletMode()) { + (TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled())) { AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, IDS_TOGGLE_REQUEST_TABLET_SITE); }
diff --git a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc index b4f371b..1592d56 100644 --- a/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc +++ b/chrome/browser/ui/views/apps/app_info_dialog/app_info_permissions_panel.cc
@@ -138,27 +138,28 @@ std::vector<base::string16> submessages, gfx::ElideBehavior elide_behavior_for_submessages, const base::Closure& revoke_callback) { - RevokeButton* revoke_button = NULL; + std::unique_ptr<RevokeButton> revoke_button; if (!revoke_callback.is_null()) - revoke_button = new RevokeButton(revoke_callback, message); + revoke_button = std::make_unique<RevokeButton>(revoke_callback, message); - views::Label* permission_label = new views::Label(message); + auto permission_label = std::make_unique<views::Label>(message); permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); permission_label->SetMultiLine(true); - AddSinglePermissionBullet(false, permission_label, revoke_button); + AddSinglePermissionBullet(false, std::move(permission_label), + std::move(revoke_button)); for (const auto& submessage : submessages) { - views::Label* sub_permission_label = new views::Label(submessage); + auto sub_permission_label = std::make_unique<views::Label>(submessage); sub_permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); sub_permission_label->SetElideBehavior(elide_behavior_for_submessages); - AddSinglePermissionBullet(true, sub_permission_label, NULL); + AddSinglePermissionBullet(true, std::move(sub_permission_label), nullptr); } } private: void AddSinglePermissionBullet(bool is_nested, - views::Label* permission_label, - RevokeButton* revoke_button) { + std::unique_ptr<views::Label> permission_label, + std::unique_ptr<RevokeButton> revoke_button) { // Add a padding row before every item except the first. if (!children().empty()) { layout_->AddPaddingRow(views::GridLayout::kFixedSize, @@ -167,15 +168,16 @@ } const base::char16 bullet_point[] = {0x2022, 0}; - views::Label* bullet_label = new views::Label(base::string16(bullet_point)); + auto bullet_label = + std::make_unique<views::Label>(base::string16(bullet_point)); layout_->StartRow( 1.0, is_nested ? kNestedBulletColumnSetId : kBulletColumnSetId); - layout_->AddView(bullet_label); - layout_->AddView(permission_label); + layout_->AddView(std::move(bullet_label)); + layout_->AddView(std::move(permission_label)); - if (revoke_button != NULL) - layout_->AddView(revoke_button); + if (revoke_button) + layout_->AddView(std::move(revoke_button)); else layout_->SkipColumns(1); }
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc index 0368b61..467a359 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc
@@ -14,7 +14,6 @@ #include "ash/public/cpp/immersive/immersive_fullscreen_controller.h" #include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shell_window_ids.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_state_type.h" #include "ash/public/interfaces/constants.mojom.h" @@ -27,6 +26,7 @@ #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/ash/kiosk_next_shell_client.h" #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" #include "chrome/common/extensions/extension_constants.h" @@ -75,11 +75,13 @@ ChromeNativeAppWindowViewsAuraAsh::ChromeNativeAppWindowViewsAuraAsh() : exclusive_access_manager_( std::make_unique<ExclusiveAccessManager>(this)) { - ash::TabletMode::Get()->AddObserver(this); + if (TabletModeClient::Get()) + TabletModeClient::Get()->AddObserver(this); } ChromeNativeAppWindowViewsAuraAsh::~ChromeNativeAppWindowViewsAuraAsh() { - ash::TabletMode::Get()->RemoveObserver(this); + if (TabletModeClient::Get()) + TabletModeClient::Get()->RemoveObserver(this); } /////////////////////////////////////////////////////////////////////////////// @@ -517,6 +519,7 @@ if (app_window()->IsOsFullscreen()) return true; + TabletModeClient* client = TabletModeClient::Get(); // Windows in tablet mode which are resizable have their title bars // hidden in ash for more size, so enable immersive mode so users // have access to window controls. Non resizable windows do not gain @@ -524,7 +527,7 @@ // is no need for immersive mode. // TODO(crbug.com/801619): This adds a little extra animation // when minimizing or unminimizing window. - return ash::TabletMode::Get()->InTabletMode() && CanResize() && + return client && client->tablet_mode_enabled() && CanResize() && !IsMinimized(); }
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h index ed085bb..d729967c 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.h
@@ -8,10 +8,10 @@ #include <memory> #include <vector> -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "ash/wm/window_state_observer.h" #include "base/gtest_prod_util.h" #include "base/scoped_observer.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" @@ -35,7 +35,7 @@ class ChromeNativeAppWindowViewsAuraAsh : public ChromeNativeAppWindowViewsAura, public views::ContextMenuController, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public ui::AcceleratorProvider, public ExclusiveAccessContext, public ExclusiveAccessBubbleViewsContext, @@ -78,7 +78,7 @@ void SetFullscreen(int fullscreen_types) override; void SetActivateOnPointer(bool activate_on_pointer) override; - // ash::TabletModeToggleObserver: + // ash:TabletModeObserver: void OnTabletModeToggled(bool enabled) override; // ui::AcceleratorProvider:
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc index 15671385..c551d495 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc
@@ -403,9 +403,9 @@ all_labels->SetLayoutManager(std::make_unique<views::GridLayout>()); BuildColumnSet(grid_layout); grid_layout->StartRow(0, 0); - grid_layout->AddView(value_label.release()); + grid_layout->AddView(std::move(value_label)); if (description_label) - grid_layout->AddView(description_label.release()); + grid_layout->AddView(std::move(description_label)); else grid_layout->SkipColumns(1); @@ -415,7 +415,7 @@ layout_manager->set_minimum_cross_axis_size( kStandardRowHeight + kAutofillPopupAdditionalDoubleRowHeight); grid_layout->StartRowWithPadding(0, 0, 0, kAdjacentLabelsVerticalSpacing); - grid_layout->AddView(lower_value_label.release()); + grid_layout->AddView(std::move(lower_value_label)); grid_layout->SkipColumns(1); } else { layout_manager->set_minimum_cross_axis_size(kStandardRowHeight);
diff --git a/chrome/browser/ui/views/autofill/payments/card_unmask_prompt_views.cc b/chrome/browser/ui/views/autofill/payments/card_unmask_prompt_views.cc index cfd70e5f..cd89993 100644 --- a/chrome/browser/ui/views/autofill/payments/card_unmask_prompt_views.cc +++ b/chrome/browser/ui/views/autofill/payments/card_unmask_prompt_views.cc
@@ -138,7 +138,7 @@ views::GridLayout* layout = ResetOverlayLayout(overlay_); // The label of the overlay will now show the error in red. - views::Label* error_label = new views::Label(error_message); + auto error_label = std::make_unique<views::Label>(error_message); const SkColor warning_text_color = views::style::GetColor( *error_label, ChromeTextContext::CONTEXT_BODY_TEXT_SMALL, STYLE_RED); error_label->SetEnabledColor(warning_text_color); @@ -146,7 +146,7 @@ // Replace the throbber with a warning icon. Since this is a permanent // error we do not intend to return to a previous state. - views::ImageView* error_icon = new views::ImageView(); + auto error_icon = std::make_unique<views::ImageView>(); // The icon doesn't look good with the dark mode warning text color, // so use the same color in light mode and dark mode. // See https://crbug.com/924507 @@ -154,8 +154,8 @@ gfx::CreateVectorIcon(kBrowserToolsErrorIcon, gfx::kGoogleRed700)); layout->StartRow(1.0, 0); - layout->AddView(error_icon); - layout->AddView(error_label); + layout->AddView(std::move(error_icon)); + layout->AddView(std::move(error_label)); } DialogModelChanged(); } @@ -468,15 +468,15 @@ views::GridLayout* overlay_layout = ResetOverlayLayout(overlay.get()); overlay->SetVisible(false); - progress_throbber_ = new views::Throbber(); - overlay_layout->AddView(progress_throbber_); + progress_throbber_ = + overlay_layout->AddView(std::make_unique<views::Throbber>()); - overlay_label_ = new views::Label(l10n_util::GetStringUTF16( + auto overlay_label = std::make_unique<views::Label>(l10n_util::GetStringUTF16( IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_IN_PROGRESS)); - overlay_label_->SetEnabledColor( - overlay_label_->GetNativeTheme()->GetSystemColor( + overlay_label->SetEnabledColor( + overlay_label->GetNativeTheme()->GetSystemColor( ui::NativeTheme::kColorId_ThrobberSpinningColor)); - overlay_layout->AddView(overlay_label_); + overlay_label_ = overlay_layout->AddView(std::move(overlay_label)); overlay_ = AddChildView(std::move(overlay)); }
diff --git a/chrome/browser/ui/views/autofill/payments/payments_view_util.cc b/chrome/browser/ui/views/autofill/payments/payments_view_util.cc index 2b432fd..1db9948 100644 --- a/chrome/browser/ui/views/autofill/payments/payments_view_util.cc +++ b/chrome/browser/ui/views/autofill/payments/payments_view_util.cc
@@ -60,7 +60,7 @@ layout->StartRow(views::GridLayout::kFixedSize, 0); - auto* icon_view = new views::ImageView(); + auto icon_view = std::make_unique<views::ImageView>(); #if defined(GOOGLE_CHROME_BUILD) // kGooglePayLogoIcon is square, and CreateTiledImage() will clip it whereas // setting the icon size would rescale it incorrectly. @@ -77,24 +77,24 @@ ui::NativeTheme::kColorId_DefaultIconColor)); #endif icon_view->SetImage(image); - layout->AddView(icon_view); + auto* icon_view_ptr = layout->AddView(std::move(icon_view)); - auto* separator = new views::Separator(); + auto separator = std::make_unique<views::Separator>(); separator->SetColor(kTitleSeparatorColor); separator->SetPreferredHeight(kGooglePayLogoSeparatorHeight); - layout->AddView(separator); + auto* separator_ptr = layout->AddView(std::move(separator)); - auto* title_label = - new views::Label(window_title, views::style::CONTEXT_DIALOG_TITLE); + auto title_label = std::make_unique<views::Label>( + window_title, views::style::CONTEXT_DIALOG_TITLE); title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); title_label->SetMultiLine(true); - layout->AddView(title_label); + auto* title_label_ptr = layout->AddView(std::move(title_label)); // Add vertical padding to the icon and the separator so they are aligned with // the first line of title label. This needs to be done after we create the // title label, so that we can use its preferred size. - const int title_label_height = title_label->GetPreferredSize().height(); - icon_view->SetBorder(views::CreateEmptyBorder( + const int title_label_height = title_label_ptr->GetPreferredSize().height(); + icon_view_ptr->SetBorder(views::CreateEmptyBorder( /*top=*/(title_label_height - kGooglePayLogoHeight) / 2, /*left=*/0, /*bottom=*/0, /*right=*/0)); // TODO(crbug.com/873140): DISTANCE_RELATED_BUTTON_HORIZONTAL isn't the right @@ -103,7 +103,7 @@ const int separator_horizontal_padding = ChromeLayoutProvider::Get()->GetDistanceMetric( views::DISTANCE_RELATED_BUTTON_HORIZONTAL); - separator->SetBorder(views::CreateEmptyBorder( + separator_ptr->SetBorder(views::CreateEmptyBorder( /*top=*/(title_label_height - kGooglePayLogoSeparatorHeight) / 2, /*left=*/separator_horizontal_padding, /*bottom=*/0, /*right=*/separator_horizontal_padding));
diff --git a/chrome/browser/ui/views/crypto_module_password_dialog_view.cc b/chrome/browser/ui/views/crypto_module_password_dialog_view.cc index 3ef8de71..8c6db72 100644 --- a/chrome/browser/ui/views/crypto_module_password_dialog_view.cc +++ b/chrome/browser/ui/views/crypto_module_password_dialog_view.cc
@@ -113,15 +113,15 @@ default: NOTREACHED(); } - reason_label_ = new views::Label(base::UTF8ToUTF16(text)); - reason_label_->SetMultiLine(true); + auto reason_label = std::make_unique<views::Label>(base::UTF8ToUTF16(text)); + reason_label->SetMultiLine(true); - password_label_ = new views::Label(l10n_util::GetStringUTF16( - IDS_CRYPTO_MODULE_AUTH_DIALOG_PASSWORD_FIELD)); + auto password_label = std::make_unique<views::Label>( + l10n_util::GetStringUTF16(IDS_CRYPTO_MODULE_AUTH_DIALOG_PASSWORD_FIELD)); - password_entry_ = new views::Textfield(); - password_entry_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); - password_entry_->set_controller(this); + auto password_entry = std::make_unique<views::Textfield>(); + password_entry->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); + password_entry->set_controller(this); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); @@ -144,14 +144,14 @@ views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, 0); - layout->AddView(reason_label_); + reason_label_ = layout->AddView(std::move(reason_label)); layout->AddPaddingRow( views::GridLayout::kFixedSize, provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL)); layout->StartRow(views::GridLayout::kFixedSize, 1); - layout->AddView(password_label_); - layout->AddView(password_entry_); + password_label_ = layout->AddView(std::move(password_label)); + password_entry_ = layout->AddView(std::move(password_entry)); } void ShowCryptoModulePasswordDialog(
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index 9dc7317..8849c880 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -123,6 +123,20 @@ DISALLOW_COPY_AND_ASSIGN(SeparatorBorder); }; +base::string16 SpltStringWithNewLineAtPosition(const base::string16& text, + size_t pos) { + base::string16 new_text = text; + // This can be a low surrogate codepoint, but u_isUWhiteSpace will + // return false and inserting a new line after a surrogate pair + // is perfectly ok. + base::char16 line_end_char = text[pos - 1]; + if (u_isUWhiteSpace(line_end_char)) + new_text.replace(pos - 1, 1, 1, base::char16('\n')); + else + new_text.insert(pos, 1, base::char16('\n')); + return new_text; +} + } // namespace DownloadItemView::DownloadItemView(DownloadUIModel::DownloadUIModelPtr download, @@ -1002,23 +1016,69 @@ bool status = iter.Init(); DCHECK(status); + // Create strings with line break position before and after the mid point, and + // compare the width to determine whether the best break position is before or + // after them. + base::string16 prev_text = original_text; + std::vector<size_t> break_points; + + while (iter.pos() < original_text.length() / 2) { + iter.Advance(); + break_points.emplace_back(iter.pos()); + } + + size_t pos = iter.pos(); + bool searching_backward = false; + gfx::Size min_width_size = size; + // First add a line break after the mid point. If there is a very long + // word in the text, |pos| could reach the end of the text. + if (pos < original_text.length()) { + searching_backward = true; + prev_text = SpltStringWithNewLineAtPosition(original_text, pos); + label->SetText(prev_text); + min_width_size = label->GetPreferredSize(); + } + + pos = iter.prev(); + base::string16 current_text; + if (pos != 0) { + base::string16 current_text = + SpltStringWithNewLineAtPosition(original_text, pos); + label->SetText(current_text); + size = label->GetPreferredSize(); + + if (size.width() == min_width_size.width()) { + // We found the best line break position. + label->SetText(prev_text); + return size; + } else if (size.width() > min_width_size.width()) { + // The best line break position is after |pos|. + label->SetText(prev_text); + } else { + // The best line break position is before |prev|. + searching_backward = false; + prev_text = current_text; + min_width_size = size; + break_points.pop_back(); + } + } + // Go through the string and try each line break (starting with no line break) // searching for the optimal line break position. Stop if we find one that // yields minimum label width. - base::string16 prev_text = original_text; - for (gfx::Size min_width_size = size; iter.Advance(); min_width_size = size) { - size_t pos = iter.pos(); - if (pos >= original_text.length()) - break; - base::string16 current_text = original_text; - // This can be a low surrogate codepoint, but u_isUWhiteSpace will - // return false and inserting a new line after a surrogate pair - // is perfectly ok. - base::char16 line_end_char = current_text[pos - 1]; - if (u_isUWhiteSpace(line_end_char)) - current_text.replace(pos - 1, 1, 1, base::char16('\n')); - else - current_text.insert(pos, 1, base::char16('\n')); + while (true) { + if (searching_backward) { + iter.Advance(); + pos = iter.pos(); + if (pos >= original_text.length()) + break; + } else { + break_points.pop_back(); + if (break_points.empty()) + break; + pos = break_points.back(); + } + current_text = SpltStringWithNewLineAtPosition(original_text, pos); label->SetText(current_text); size = label->GetPreferredSize(); @@ -1028,6 +1088,7 @@ return min_width_size; } prev_text = current_text; + min_width_size = size; } return size; }
diff --git a/chrome/browser/ui/views/download/download_item_view_unittest.cc b/chrome/browser/ui/views/download/download_item_view_unittest.cc index fff7f40..7f0a7953 100644 --- a/chrome/browser/ui/views/download/download_item_view_unittest.cc +++ b/chrome/browser/ui/views/download/download_item_view_unittest.cc
@@ -38,4 +38,34 @@ label.SetText(label_text); DownloadItemView::AdjustTextAndGetSize(&label); EXPECT_EQ(label_text, label.text()); + + // Two lines have the same length. + label_text = + base::ASCIIToUTF16("aaaa aaaa aaaa aaaa bb bb aaaa aaaa aaaa aaaa"); + expected_text = base::ASCIIToUTF16( + "aaaa aaaa aaaa aaaa bb\n" + "bb aaaa aaaa aaaa aaaa"); + label.SetText(label_text); + DownloadItemView::AdjustTextAndGetSize(&label); + EXPECT_EQ(expected_text, label.text()); + + // Text begins with a very long word. + label_text = base::ASCIIToUTF16( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaa aaaa"); + expected_text = base::ASCIIToUTF16( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + "aaaa aaaa"); + label.SetText(label_text); + DownloadItemView::AdjustTextAndGetSize(&label); + EXPECT_EQ(expected_text, label.text()); + + // Text ends with a very long word. + label_text = base::ASCIIToUTF16( + "aaa aaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + expected_text = base::ASCIIToUTF16( + "aaa aaaa\n" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + label.SetText(label_text); + DownloadItemView::AdjustTextAndGetSize(&label); + EXPECT_EQ(expected_text, label.text()); }
diff --git a/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.cc b/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.cc index dac952d..eeaf3a2 100644 --- a/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.cc +++ b/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.cc
@@ -41,10 +41,7 @@ BookmarkAppConfirmationView::BookmarkAppConfirmationView( std::unique_ptr<WebApplicationInfo> web_app_info, chrome::AppInstallationAcceptanceCallback callback) - : web_app_info_(std::move(web_app_info)), - callback_(std::move(callback)), - open_as_window_checkbox_(nullptr), - title_tf_(nullptr) { + : web_app_info_(std::move(web_app_info)), callback_(std::move(callback)) { DCHECK(web_app_info_); const ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); set_margins(layout_provider->GetDialogInsetsForContentType(views::CONTROL, @@ -65,7 +62,7 @@ views::GridLayout::kFixedSize, views::GridLayout::FIXED, textfield_width, 0); - views::ImageView* icon_image_view = new views::ImageView(); + auto icon_image_view = std::make_unique<views::ImageView>(); gfx::Size image_size(extension_misc::EXTENSION_ICON_SMALL, extension_misc::EXTENSION_ICON_SMALL); gfx::ImageSkia image( @@ -75,24 +72,25 @@ icon_image_view->SetImageSize(image_size); icon_image_view->SetImage(image); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId); - layout->AddView(icon_image_view); + layout->AddView(std::move(icon_image_view)); - title_tf_ = new views::Textfield(); - title_tf_->SetText(web_app_info_->title); - title_tf_->SetAccessibleName( + auto title_tf = std::make_unique<views::Textfield>(); + title_tf->SetText(web_app_info_->title); + title_tf->SetAccessibleName( l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_AX_BUBBLE_NAME_LABEL)); - title_tf_->set_controller(this); - layout->AddView(title_tf_); + title_tf->set_controller(this); + title_tf_ = layout->AddView(std::move(title_tf)); layout->AddPaddingRow( views::GridLayout::kFixedSize, layout_provider->GetDistanceMetric(DISTANCE_CONTROL_LIST_VERTICAL)); - open_as_window_checkbox_ = new views::Checkbox( + auto open_as_window_checkbox = std::make_unique<views::Checkbox>( l10n_util::GetStringUTF16(IDS_BOOKMARK_APP_BUBBLE_OPEN_AS_WINDOW)); - open_as_window_checkbox_->SetChecked(web_app_info_->open_as_window); + open_as_window_checkbox->SetChecked(web_app_info_->open_as_window); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId); layout->SkipColumns(1); - layout->AddView(open_as_window_checkbox_); + open_as_window_checkbox_ = + layout->AddView(std::move(open_as_window_checkbox)); title_tf_->SelectAll(true); chrome::RecordDialogCreation(
diff --git a/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h b/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h index ce315703..fa95a2d 100644 --- a/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h +++ b/chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h
@@ -55,10 +55,10 @@ chrome::AppInstallationAcceptanceCallback callback_; // Checkbox to launch as a window. - views::Checkbox* open_as_window_checkbox_; + views::Checkbox* open_as_window_checkbox_ = nullptr; // Textfield showing the title of the app. - views::Textfield* title_tf_; + views::Textfield* title_tf_ = nullptr; DISALLOW_COPY_AND_ASSIGN(BookmarkAppConfirmationView); };
diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index dcf609b..87c17b85 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc
@@ -29,7 +29,7 @@ #include "url/gurl.h" #if defined(OS_CHROMEOS) -#include "ash/public/cpp/tablet_mode.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #endif using content::BrowserContext; @@ -175,7 +175,8 @@ bool ExtensionDialog::CanResize() const { #if defined(OS_CHROMEOS) // Prevent dialog resize mouse cursor in tablet mode, crbug.com/453634. - if (ash::TabletMode::Get()->InTabletMode()) + const auto* client = TabletModeClient::Get(); + if (client && client->tablet_mode_enabled()) return false; #endif // Can resize only if minimum contents size set.
diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc index 2896ba45..6fb62c55 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc
@@ -310,14 +310,14 @@ // Scale down to icon size, but allow smaller icons (don't scale up). const gfx::ImageSkia* image = prompt_->icon().ToImageSkia(); - views::ImageView* icon = new views::ImageView(); + auto icon = std::make_unique<views::ImageView>(); gfx::Size size(image->width(), image->height()); size.SetToMin(gfx::Size(icon_size, icon_size)); icon->SetImageSize(size); icon->SetImage(*image); layout->StartRow(views::GridLayout::kFixedSize, kTitleColumnSetId); - layout->AddView(icon); + layout->AddView(std::move(icon)); std::unique_ptr<views::Label> title_label = views::BubbleFrameView::CreateDefaultTitleLabel(title_); @@ -341,23 +341,23 @@ auto rating = std::make_unique<RatingsView>(prompt_->average_rating(), prompt_->rating_count()); prompt_->AppendRatingStars(AddResourceIcon, rating.get()); - rating_container->AddChildView(rating.release()); + rating_container->AddChildView(std::move(rating)); auto rating_count = std::make_unique<RatingLabel>(prompt_->GetRatingCount(), CONTEXT_BODY_TEXT_LARGE); rating_count->SetHorizontalAlignment(gfx::ALIGN_LEFT); - rating_container->AddChildView(rating_count.release()); - webstore_data_container->AddChildView(rating_container.release()); + rating_container->AddChildView(std::move(rating_count)); + webstore_data_container->AddChildView(std::move(rating_container)); auto user_count = std::make_unique<views::Label>( prompt_->GetUserCount(), CONTEXT_BODY_TEXT_SMALL, STYLE_SECONDARY); user_count->SetAutoColorReadabilityEnabled(false); user_count->SetEnabledColor(SK_ColorGRAY); user_count->SetHorizontalAlignment(gfx::ALIGN_LEFT); - webstore_data_container->AddChildView(user_count.release()); + webstore_data_container->AddChildView(std::move(user_count)); - layout->AddView(webstore_data_container.release()); + layout->AddView(std::move(webstore_data_container)); } else { - layout->AddView(title_label.release()); + layout->AddView(std::move(title_label)); } GetBubbleFrameView()->SetTitleView(std::move(title_container)); @@ -615,15 +615,14 @@ available_width, 0); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId); - details_view_ = new DetailsView(details); - layout->AddView(details_view_); + details_view_ = layout->AddView(std::make_unique<DetailsView>(details)); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId); - details_link_ = - new views::Link(l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); - details_link_->set_listener(this); - details_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - layout->AddView(details_link_); + auto details_link = std::make_unique<views::Link>( + l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_DETAILS)); + details_link->set_listener(this); + details_link->SetHorizontalAlignment(gfx::ALIGN_LEFT); + details_link_ = layout->AddView(std::move(details_link)); } ExpandableContainerView::~ExpandableContainerView() {
diff --git a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc index 41d44bfd..32899b1 100644 --- a/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc +++ b/chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc
@@ -123,7 +123,7 @@ // parameters may differ between platforms. const int subtext_height = subtext->GetHeightForWidth(dialog_content_width); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - layout->AddView(subtext.release(), 1, 1, views::GridLayout::FILL, + layout->AddView(std::move(subtext), 1, 1, views::GridLayout::FILL, views::GridLayout::LEADING, dialog_content_width, subtext_height); layout->AddPaddingRow(views::GridLayout::kFixedSize, vertical_padding); @@ -173,7 +173,7 @@ scroll_view->SetContents(std::move(scroll_container)); layout->StartRowWithPadding(1.0, column_set_id, views::GridLayout::kFixedSize, vertical_padding); - layout->AddView(scroll_view.release(), 1.0, 1.0, views::GridLayout::FILL, + layout->AddView(std::move(scroll_view), 1.0, 1.0, views::GridLayout::FILL, views::GridLayout::FILL, dialog_content_width, kScrollAreaHeight); }
diff --git a/chrome/browser/ui/views/first_run_dialog.cc b/chrome/browser/ui/views/first_run_dialog.cc index a92b68b7..d3e55388 100644 --- a/chrome/browser/ui/views/first_run_dialog.cc +++ b/chrome/browser/ui/views/first_run_dialog.cc
@@ -61,10 +61,7 @@ run_loop.Run(); } -FirstRunDialog::FirstRunDialog(Profile* profile) - : profile_(profile), - make_default_(NULL), - report_crashes_(NULL) { +FirstRunDialog::FirstRunDialog(Profile* profile) : profile_(profile) { set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( views::TEXT, views::TEXT)); views::GridLayout* layout = @@ -76,20 +73,20 @@ views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, 0); - make_default_ = new views::Checkbox(l10n_util::GetStringUTF16( - IDS_FR_CUSTOMIZE_DEFAULT_BROWSER)); - make_default_->SetChecked(true); - layout->AddView(make_default_); + auto make_default = std::make_unique<views::Checkbox>( + l10n_util::GetStringUTF16(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER)); + make_default->SetChecked(true); + make_default_ = layout->AddView(std::move(make_default)); layout->StartRowWithPadding(views::GridLayout::kFixedSize, 0, views::GridLayout::kFixedSize, ChromeLayoutProvider::Get()->GetDistanceMetric( views::DISTANCE_RELATED_CONTROL_VERTICAL)); - report_crashes_ = new views::Checkbox( + auto report_crashes = std::make_unique<views::Checkbox>( l10n_util::GetStringUTF16(IDS_SETTINGS_ENABLE_LOGGING)); // Having this box checked means the user has to opt-out of metrics recording. - report_crashes_->SetChecked(!first_run::IsMetricsReportingOptIn()); - layout->AddView(report_crashes_); + report_crashes->SetChecked(!first_run::IsMetricsReportingOptIn()); + report_crashes_ = layout->AddView(std::move(report_crashes)); chrome::RecordDialogCreation(chrome::DialogIdentifier::FIRST_RUN_DIALOG); }
diff --git a/chrome/browser/ui/views/first_run_dialog.h b/chrome/browser/ui/views/first_run_dialog.h index 47569724..c15b8aa 100644 --- a/chrome/browser/ui/views/first_run_dialog.h +++ b/chrome/browser/ui/views/first_run_dialog.h
@@ -42,8 +42,8 @@ void LinkClicked(views::Link* source, int event_flags) override; Profile* profile_; - views::Checkbox* make_default_; - views::Checkbox* report_crashes_; + views::Checkbox* make_default_ = nullptr; + views::Checkbox* report_crashes_ = nullptr; base::Closure quit_runloop_; DISALLOW_COPY_AND_ASSIGN(FirstRunDialog);
diff --git a/chrome/browser/ui/views/frame/browser_frame_header_ash.cc b/chrome/browser/ui/views/frame/browser_frame_header_ash.cc index 63bc131..94c9c7f 100644 --- a/chrome/browser/ui/views/frame/browser_frame_header_ash.cc +++ b/chrome/browser/ui/views/frame/browser_frame_header_ash.cc
@@ -7,9 +7,9 @@ #include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/caption_buttons/frame_caption_button_container_view.h" #include "ash/public/cpp/frame_utils.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/vector_icons/vector_icons.h" #include "base/logging.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkPaint.h" @@ -153,7 +153,8 @@ views::CaptionButtonLayoutSize BrowserFrameHeaderAsh::GetButtonLayoutSize() const { return target_widget()->IsMaximized() || target_widget()->IsFullscreen() || - ash::TabletMode::Get()->InTabletMode() + (TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled()) ? views::CaptionButtonLayoutSize::kBrowserCaptionMaximized : views::CaptionButtonLayoutSize::kBrowserCaptionRestored; }
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc index 31af247..27c3d4a 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -13,7 +13,6 @@ #include "ash/public/cpp/caption_buttons/frame_caption_button_container_view.h" #include "ash/public/cpp/default_frame_header.h" #include "ash/public/cpp/frame_utils.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/touch_uma.h" #include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_state_type.h" @@ -28,6 +27,7 @@ #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_helper.h" #include "chrome/browser/ui/ash/session_util.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_command_controller.h" #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" @@ -123,7 +123,9 @@ browser_view()->browser()->command_controller()->RemoveCommandObserver( IDC_BACK, this); - ash::TabletMode::Get()->RemoveObserver(this); + if (TabletModeClient::Get()) + TabletModeClient::Get()->RemoveObserver(this); + ash::SplitViewNotifier::Get()->RemoveObserver(this); ImmersiveModeController* immersive_controller = @@ -162,7 +164,9 @@ if (browser->profile()->IsOffTheRecord()) window->SetProperty(ash::kBlockedForAssistantSnapshotKey, true); - ash::TabletMode::Get()->AddObserver(this); + // TabletModeClient may not be initialized during unit tests. + if (TabletModeClient::Get()) + TabletModeClient::Get()->AddObserver(this); if (browser->is_app() && IsV1AppBackButtonEnabled()) { browser->command_controller()->AddCommandObserver(IDC_BACK, this); @@ -460,7 +464,7 @@ } /////////////////////////////////////////////////////////////////////////////// -// ash::TabletModeToggleObserver: +// ash::mojom::TabletModeClient: void BrowserNonClientFrameViewAsh::OnTabletModeToggled(bool enabled) { if (!enabled && browser_view()->immersive_mode_controller()->IsRevealed()) { @@ -616,8 +620,8 @@ // minimize all windows when pressing the Launcher button on the shelf. const bool hide_caption_buttons_in_tablet_mode = !UsePackagedAppHeaderStyle(browser_view()->browser()); - if (hide_caption_buttons_in_tablet_mode && - ash::TabletMode::Get()->InTabletMode()) { + if (hide_caption_buttons_in_tablet_mode && TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled()) { return false; }
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h index fbc21df..0c0130ed 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h
@@ -8,12 +8,12 @@ #include <memory> #include "ash/public/cpp/split_view.h" -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" #include "chrome/browser/command_observer.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/views/frame/browser_frame_header_ash.h" #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" @@ -40,7 +40,7 @@ class BrowserNonClientFrameViewAsh : public BrowserNonClientFrameView, public BrowserFrameHeaderAsh::AppearanceProvider, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public TabIconViewModel, public CommandObserver, public ash::SplitViewObserver, @@ -90,7 +90,7 @@ int GetFrameHeaderImageYInset() override; gfx::ImageSkia GetFrameHeaderOverlayImage(bool active) override; - // ash::TabletModeToggleObserver: + // TabletModeClientObserver: void OnTabletModeToggled(bool enabled) override; // TabIconViewModel:
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc index 1210253..8abc833e 100644 --- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc +++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc
@@ -5,7 +5,6 @@ #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" #include "ash/public/cpp/immersive/immersive_revealed_lock.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/window_properties.h" #include "base/macros.h" #include "chrome/browser/chrome_notification_types.h" @@ -130,7 +129,7 @@ bool ImmersiveModeControllerAsh::ShouldStayImmersiveAfterExitingFullscreen() { return !browser_view_->IsBrowserTypeNormal() && - ash::TabletMode::Get()->InTabletMode(); + TabletModeClient::Get()->tablet_mode_enabled(); } void ImmersiveModeControllerAsh::OnWidgetActivationChanged( @@ -139,7 +138,7 @@ if (browser_view_->IsBrowserTypeNormal()) return; - if (!ash::TabletMode::Get()->InTabletMode()) + if (!TabletModeClient::Get()->tablet_mode_enabled()) return; // Don't use immersive mode as long as we are in the locked fullscreen mode
diff --git a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc index 61e3a07..401ec7a 100644 --- a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc +++ b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.h" -#include "ash/public/cpp/tablet_mode.h" #include "base/bind.h" #include "chrome/browser/permissions/permission_request_manager.h" #include "chrome/browser/search/search.h" #include "chrome/browser/ssl/security_state_tab_helper.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/top_container_view.h" #include "chrome/common/chrome_render_frame.mojom.h" @@ -35,7 +35,8 @@ namespace { bool IsTabletModeEnabled() { - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get() && + TabletModeClient::Get()->tablet_mode_enabled(); } bool IsSpokenFeedbackEnabled() { @@ -303,7 +304,9 @@ registrar_.Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, content::NotificationService::AllSources()); - ash::TabletMode::Get()->AddObserver(this); + if (TabletModeClient::Get()) + TabletModeClient::Get()->AddObserver(this); + browser_view_->browser()->tab_strip_model()->AddObserver(this); chromeos::AccessibilityManager* accessibility_manager = @@ -322,7 +325,9 @@ OnEnabledStateChanged(false); browser_view_->browser()->tab_strip_model()->RemoveObserver(this); - ash::TabletMode::Get()->RemoveObserver(this); + + if (TabletModeClient::Get()) + TabletModeClient::Get()->RemoveObserver(this); } bool TopControlsSlideControllerChromeOS::IsEnabled() const {
diff --git a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.h b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.h index 21a24d3..f2a23afd 100644 --- a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.h +++ b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos.h
@@ -7,11 +7,11 @@ #include <memory> -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "base/containers/flat_map.h" #include "base/macros.h" #include "base/optional.h" #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/views/frame/top_controls_slide_controller.h" #include "content/public/browser/notification_observer.h" @@ -38,7 +38,7 @@ // - Page security level changes. class TopControlsSlideControllerChromeOS : public TopControlsSlideController, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public TabStripModelObserver, public content::NotificationObserver { public: @@ -55,7 +55,7 @@ void SetTopControlsGestureScrollInProgress(bool in_progress) override; bool IsTopControlsGestureScrollInProgress() const override; - // ash::TabletModeToggleObserver: + // TabletModeClientObserver: void OnTabletModeToggled(bool tablet_mode_enabled) override; // TabStripModelObserver:
diff --git a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc index baabe16..8b05a88 100644 --- a/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc +++ b/chrome/browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc
@@ -9,8 +9,6 @@ #include <vector> #include "ash/public/cpp/ash_switches.h" -#include "ash/public/cpp/tablet_mode.h" -#include "ash/public/cpp/test/shell_test_api.h" #include "ash/public/interfaces/constants.mojom.h" #include "ash/public/interfaces/cros_display_config.mojom-test-utils.h" #include "ash/public/interfaces/cros_display_config.mojom.h" @@ -23,6 +21,7 @@ #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" #include "chrome/browser/permissions/permission_request_impl.h" #include "chrome/browser/permissions/permission_request_manager.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" @@ -38,7 +37,6 @@ #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/display/display.h" -#include "ui/display/display_switches.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/geometry/rect.h" #include "ui/views/controls/native/native_view_host.h" @@ -260,12 +258,7 @@ void SetUpDefaultCommandLine(base::CommandLine* command_line) override { InProcessBrowserTest::SetUpDefaultCommandLine(command_line); - // Mark the device is capable of entering tablet mode. command_line->AppendSwitch(ash::switches::kAshEnableTabletMode); - - // Use first display as internal display. Otherwise, tablet mode is ended - // on display change. - command_line->AppendSwitch(switches::kUseFirstDisplayAsInternal); } void SetUpOnMainThread() override { @@ -295,11 +288,13 @@ } void ToggleTabletMode() { - ash::ShellTestApi().SetTabletModeEnabledForTest(!GetTabletModeEnabled()); + auto* tablet_mode_client = TabletModeClient::Get(); + tablet_mode_client->OnTabletModeToggled( + !tablet_mode_client->tablet_mode_enabled()); } bool GetTabletModeEnabled() const { - return ash::TabletMode::Get()->InTabletMode(); + return TabletModeClient::Get()->tablet_mode_enabled(); } void CheckBrowserLayout(BrowserView* browser_view,
diff --git a/chrome/browser/ui/views/global_error_bubble_view.cc b/chrome/browser/ui/views/global_error_bubble_view.cc index 876b3a1..a111986d 100644 --- a/chrome/browser/ui/views/global_error_bubble_view.cc +++ b/chrome/browser/ui/views/global_error_bubble_view.cc
@@ -117,12 +117,12 @@ // returns. std::vector<base::string16> message_strings(error_->GetBubbleViewMessages()); - std::vector<views::Label*> message_labels; - for (size_t i = 0; i < message_strings.size(); ++i) { - views::Label* message_label = new views::Label(message_strings[i]); + std::vector<std::unique_ptr<views::Label>> message_labels; + for (const auto& message_string : message_strings) { + auto message_label = std::make_unique<views::Label>(message_string); message_label->SetMultiLine(true); message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); - message_labels.push_back(message_label); + message_labels.push_back(std::move(message_label)); } views::GridLayout* layout = @@ -135,7 +135,7 @@ for (size_t i = 0; i < message_labels.size(); ++i) { layout->StartRow(1.0, 0); - layout->AddView(message_labels[i]); + layout->AddView(std::move(message_labels[i])); if (i < message_labels.size() - 1) layout->AddPaddingRow(views::GridLayout::kFixedSize, ChromeLayoutProvider::Get()->GetDistanceMetric(
diff --git a/chrome/browser/ui/views/hover_button.cc b/chrome/browser/ui/views/hover_button.cc index bb90435..62b7c316 100644 --- a/chrome/browser/ui/views/hover_button.cc +++ b/chrome/browser/ui/views/hover_button.cc
@@ -67,12 +67,7 @@ HoverButton::HoverButton(views::ButtonListener* button_listener, const base::string16& text) - : views::MenuButton(text, this), - title_(nullptr), - subtitle_(nullptr), - icon_view_(nullptr), - secondary_view_(nullptr), - listener_(button_listener) { + : views::MenuButton(text, this), listener_(button_listener) { SetInstallFocusRingOnFocus(false); SetFocusBehavior(FocusBehavior::ALWAYS); @@ -146,7 +141,6 @@ taken_width_ = GetInsets().width() + icon_view->GetPreferredSize().width() + icon_label_spacing; - icon_view_ = icon_view.get(); // Make sure hovering over the icon also hovers the |HoverButton|. icon_view->set_can_process_events_within_subtree(false); // Don't cover |icon_view| when the ink drops are being painted. |MenuButton| @@ -158,36 +152,36 @@ (total_height - remaining_vert_spacing * 2) / num_labels; grid_layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId, row_height); - grid_layout->AddView(icon_view.release(), 1, num_labels); + icon_view_ = grid_layout->AddView(std::move(icon_view), 1, num_labels); - title_ = new views::StyledLabel(title, nullptr); + auto title_label = std::make_unique<views::StyledLabel>(title, nullptr); // Size without a maximum width to get a single line label. - title_->SizeToFit(0); + title_label->SizeToFit(0); // |views::StyledLabel|s are all multi-line. With a layout manager, // |StyledLabel| will try use the available space to size itself, and long // titles will wrap to the next line (for smaller |HoverButton|s, this will // also cover up |subtitle_|). Wrap it in a parent view with no layout manager // to ensure it keeps its original size set by SizeToFit() above. Long titles // will then be truncated. - views::View* title_wrapper = new views::View; - title_wrapper->AddChildView(title_); + auto title_wrapper = std::make_unique<views::View>(); + title_ = title_wrapper->AddChildView(std::move(title_label)); // Hover the whole button when hovering |title_|. This is OK because |title_| // will never have a link in it. title_wrapper->set_can_process_events_within_subtree(false); - grid_layout->AddView(title_wrapper); + grid_layout->AddView(std::move(title_wrapper)); if (secondary_view) { columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, views::GridLayout::kFixedSize, views::GridLayout::USE_PREF, 0, 0); - secondary_view_ = secondary_view.get(); secondary_view->set_can_process_events_within_subtree( secondary_view_can_process_events); // |secondary_view| needs a layer otherwise it's obscured by the layer // used in drawing ink drops. secondary_view->SetPaintToLayer(); secondary_view->layer()->SetFillsBoundsOpaquely(false); - grid_layout->AddView(secondary_view.release(), 1, num_labels); + secondary_view_ = + grid_layout->AddView(std::move(secondary_view), 1, num_labels); if (!resize_row_for_secondary_view) { insets_ = views::MenuButton::GetInsets(); @@ -206,12 +200,12 @@ if (!subtitle.empty()) { grid_layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId, row_height); - subtitle_ = new views::Label(subtitle, views::style::CONTEXT_BUTTON, - STYLE_SECONDARY); - subtitle_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - subtitle_->SetAutoColorReadabilityEnabled(false); + auto subtitle_label = std::make_unique<views::Label>( + subtitle, views::style::CONTEXT_BUTTON, STYLE_SECONDARY); + subtitle_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + subtitle_label->SetAutoColorReadabilityEnabled(false); grid_layout->SkipColumns(1); - grid_layout->AddView(subtitle_); + subtitle_ = grid_layout->AddView(std::move(subtitle_label)); } SetTooltipAndAccessibleName(this, title_, subtitle_, GetLocalBounds(),
diff --git a/chrome/browser/ui/views/hover_button.h b/chrome/browser/ui/views/hover_button.h index fe69553..a30368a79 100644 --- a/chrome/browser/ui/views/hover_button.h +++ b/chrome/browser/ui/views/hover_button.h
@@ -121,10 +121,10 @@ FRIEND_TEST_ALL_PREFIXES(ExtensionsMenuButtonTest, UpdatesToDisplayCorrectActionTitle); - views::StyledLabel* title_; - views::Label* subtitle_; - views::View* icon_view_; - views::View* secondary_view_; + views::StyledLabel* title_ = nullptr; + views::Label* subtitle_ = nullptr; + views::View* icon_view_ = nullptr; + views::View* secondary_view_ = nullptr; // The horizontal space the padding and icon take up. Used for calculating the // available space for |title_|, if it exists.
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index 3e8866b..ca62cc5f 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -447,10 +447,10 @@ // HungRendererDialogView, private: void HungRendererDialogView::Init() { - info_label_ = new views::Label(base::string16(), CONTEXT_BODY_TEXT_LARGE, - STYLE_SECONDARY); - info_label_->SetMultiLine(true); - info_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + auto info_label = std::make_unique<views::Label>( + base::string16(), CONTEXT_BODY_TEXT_LARGE, STYLE_SECONDARY); + info_label->SetMultiLine(true); + info_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); hung_pages_table_model_.reset(new HungPagesTableModel(this)); std::vector<ui::TableColumn> columns; @@ -469,7 +469,7 @@ views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId); - layout->AddView(info_label_); + info_label_ = layout->AddView(std::move(info_label)); layout->AddPaddingRow( views::GridLayout::kFixedSize, @@ -477,8 +477,7 @@ layout->StartRow(1.0, kColumnSetId); layout->AddView( - views::TableView::CreateScrollViewWithTable(std::move(hung_pages_table)) - .release(), + views::TableView::CreateScrollViewWithTable(std::move(hung_pages_table)), 1, 1, views::GridLayout::FILL, views::GridLayout::FILL, kTableViewWidth, kTableViewHeight);
diff --git a/chrome/browser/ui/views/ime/ime_warning_bubble_view.cc b/chrome/browser/ui/views/ime/ime_warning_bubble_view.cc index 6c1d9bb9..bce1064 100644 --- a/chrome/browser/ui/views/ime/ime_warning_bubble_view.cc +++ b/chrome/browser/ui/views/ime/ime_warning_bubble_view.cc
@@ -30,8 +30,9 @@ // The column width of the warning bubble. const int kColumnWidth = 285; -views::Label* CreateExtensionNameLabel(const base::string16& text) { - views::Label* label = new views::Label(text, CONTEXT_BODY_TEXT_SMALL); +std::unique_ptr<views::Label> CreateExtensionNameLabel( + const base::string16& text) { + auto label = std::make_unique<views::Label>(text, CONTEXT_BODY_TEXT_SMALL); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); return label; @@ -91,10 +92,7 @@ : extension_(extension), browser_view_(browser_view), browser_(browser_view->browser()), - anchor_to_action_(false), - never_show_checkbox_(nullptr), response_callback_(callback), - bubble_has_shown_(false), toolbar_actions_bar_observer_(this), weak_ptr_factory_(this) { container_ = browser_view_->toolbar()->browser_actions(); @@ -176,16 +174,16 @@ layout->StartRow(views::GridLayout::kFixedSize, cs_id); base::string16 extension_name = base::UTF8ToUTF16(extension_->name()); base::i18n::AdjustStringForLocaleDirection(&extension_name); - views::Label* warning = CreateExtensionNameLabel(l10n_util::GetStringFUTF16( - IDS_IME_API_ACTIVATED_WARNING, extension_name)); - layout->AddView(warning); + std::unique_ptr<views::Label> warning = + CreateExtensionNameLabel(l10n_util::GetStringFUTF16( + IDS_IME_API_ACTIVATED_WARNING, extension_name)); + layout->AddView(std::move(warning)); layout->AddPaddingRow(views::GridLayout::kFixedSize, vertical_spacing); // The seconde row which shows the check box. layout->StartRow(views::GridLayout::kFixedSize, cs_id); - never_show_checkbox_ = - new views::Checkbox(l10n_util::GetStringUTF16(IDS_IME_API_NEVER_SHOW)); - layout->AddView(never_show_checkbox_); + never_show_checkbox_ = layout->AddView(std::make_unique<views::Checkbox>( + l10n_util::GetStringUTF16(IDS_IME_API_NEVER_SHOW))); } bool ImeWarningBubbleView::IsToolbarAnimating() {
diff --git a/chrome/browser/ui/views/ime/ime_warning_bubble_view.h b/chrome/browser/ui/views/ime/ime_warning_bubble_view.h index 0341143..3fb41336 100644 --- a/chrome/browser/ui/views/ime/ime_warning_bubble_view.h +++ b/chrome/browser/ui/views/ime/ime_warning_bubble_view.h
@@ -77,15 +77,15 @@ Browser* const browser_; // True if bubble anchors to the action of the extension. - bool anchor_to_action_; + bool anchor_to_action_ = false; // The check box on the bubble view. - views::Checkbox* never_show_checkbox_; + views::Checkbox* never_show_checkbox_ = nullptr; ImeWarningBubbleResponseCallback response_callback_; // True if the warning bubble has been shown. - bool bubble_has_shown_; + bool bubble_has_shown_ = false; BrowserActionsContainer* container_;
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view.cc b/chrome/browser/ui/views/intent_picker_bubble_view.cc index fdaf96e..285c06b 100644 --- a/chrome/browser/ui/views/intent_picker_bubble_view.cc +++ b/chrome/browser/ui/views/intent_picker_bubble_view.cc
@@ -60,8 +60,8 @@ key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_LEFT; } -views::Separator* CreateHorizontalSeparator() { - views::Separator* separator = new views::Separator; +std::unique_ptr<views::Separator> CreateHorizontalSeparator() { + auto separator = std::make_unique<views::Separator>(); separator->SetColor(kSeparatorColor); separator->SetBorder(views::CreateEmptyBorder(kSeparatorPadding)); return separator; @@ -270,9 +270,7 @@ web_contents), intent_picker_cb_(std::move(intent_picker_cb)), selected_app_tag_(0), - scroll_view_(nullptr), app_info_(std::move(app_info)), - remember_selection_checkbox_(nullptr), show_stay_in_chrome_(show_stay_in_chrome) { chrome::RecordDialogCreation(chrome::DialogIdentifier::INTENT_PICKER); } @@ -357,18 +355,18 @@ if (to_erase != app_info_.size()) app_info_.erase(app_info_.begin() + to_erase); - scroll_view_ = new views::ScrollView(); - scroll_view_->SetBackgroundColor(SK_ColorWHITE); - scroll_view_->SetContents(std::move(scrollable_view)); + auto scroll_view = std::make_unique<views::ScrollView>(); + scroll_view->SetBackgroundColor(SK_ColorWHITE); + scroll_view->SetContents(std::move(scrollable_view)); // This part gives the scroll a fixed width and height. The height depends on // how many app candidates we got and how many we actually want to show. // The added 0.5 on the else block allow us to let the user know there are // more than |kMaxAppResults| apps accessible by scrolling the list. - size_t rows = GetScrollViewSize(); + size_t rows = scroll_view->contents()->children().size(); if (rows <= kMaxAppResults) { - scroll_view_->ClipHeightTo(kRowHeight, rows * kRowHeight); + scroll_view->ClipHeightTo(kRowHeight, rows * kRowHeight); } else { - scroll_view_->ClipHeightTo(kRowHeight, (kMaxAppResults + 0.5) * kRowHeight); + scroll_view->ClipHeightTo(kRowHeight, (kMaxAppResults + 0.5) * kRowHeight); } constexpr int kColumnSetId = 0; @@ -379,7 +377,7 @@ layout->StartRowWithPadding(views::GridLayout::kFixedSize, kColumnSetId, views::GridLayout::kFixedSize, kTitlePadding); - layout->AddView(scroll_view_); + scroll_view_ = layout->AddView(std::move(scroll_view)); layout->StartRow(views::GridLayout::kFixedSize, kColumnSetId, 0); layout->AddView(CreateHorizontalSeparator()); @@ -395,10 +393,9 @@ layout->StartRowWithPadding(views::GridLayout::kFixedSize, kColumnSetIdPadded, views::GridLayout::kFixedSize, 0); if (show_remember_selection) { - remember_selection_checkbox_ = - new views::Checkbox(l10n_util::GetStringUTF16( - IDS_INTENT_PICKER_BUBBLE_VIEW_REMEMBER_SELECTION)); - layout->AddView(remember_selection_checkbox_); + remember_selection_checkbox_ = layout->AddView( + std::make_unique<views::Checkbox>(l10n_util::GetStringUTF16( + IDS_INTENT_PICKER_BUBBLE_VIEW_REMEMBER_SELECTION))); UpdateCheckboxState(); } layout->AddPaddingRow(views::GridLayout::kFixedSize, kTitlePadding);
diff --git a/chrome/browser/ui/views/intent_picker_bubble_view.h b/chrome/browser/ui/views/intent_picker_bubble_view.h index 02d9bc3..80dd0550 100644 --- a/chrome/browser/ui/views/intent_picker_bubble_view.h +++ b/chrome/browser/ui/views/intent_picker_bubble_view.h
@@ -166,11 +166,11 @@ // Pre-select the first app on the list. size_t selected_app_tag_ = 0; - views::ScrollView* scroll_view_; + views::ScrollView* scroll_view_ = nullptr; std::vector<AppInfo> app_info_; - views::Checkbox* remember_selection_checkbox_; + views::Checkbox* remember_selection_checkbox_ = nullptr; // Tells whether or not 'Stay in Chrome' should be enabled as an option. const bool show_stay_in_chrome_;
diff --git a/chrome/browser/ui/views/login_view.cc b/chrome/browser/ui/views/login_view.cc index 6b0c11d..c9bd5890 100644 --- a/chrome/browser/ui/views/login_view.cc +++ b/chrome/browser/ui/views/login_view.cc
@@ -25,13 +25,13 @@ void AddHeaderLabel(views::GridLayout* layout, const base::string16& text, int text_style) { - views::Label* label = - new views::Label(text, views::style::CONTEXT_LABEL, text_style); + auto label = std::make_unique<views::Label>(text, views::style::CONTEXT_LABEL, + text_style); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); label->SetAllowCharacterBreak(true); layout->StartRow(views::GridLayout::kFixedSize, kHeaderColumnSetId); - layout->AddView(label); + layout->AddView(std::move(label)); } } // namespace
diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc index a8393ed..0a1e203 100644 --- a/chrome/browser/ui/views/sad_tab_view.cc +++ b/chrome/browser/ui/views/sad_tab_view.cc
@@ -39,9 +39,10 @@ constexpr int kMinColumnWidth = 120; constexpr int kTitleBottomSpacing = 13; -views::Label* CreateFormattedLabel(const base::string16& message) { - views::Label* label = - new views::Label(message, views::style::CONTEXT_LABEL, STYLE_SECONDARY); +std::unique_ptr<views::Label> CreateFormattedLabel( + const base::string16& message) { + auto label = std::make_unique<views::Label>( + message, views::style::CONTEXT_LABEL, STYLE_SECONDARY); label->SetMultiLine(true); label->SetHorizontalAlignment(gfx::ALIGN_LEFT); @@ -82,7 +83,7 @@ 0, kMinColumnWidth); columns->AddPaddingColumn(1.0, unrelated_horizontal_spacing); - views::ImageView* image = new views::ImageView(); + auto image = std::make_unique<views::ImageView>(); image->SetImage( gfx::CreateVectorIcon(kCrashedTabIcon, 48, gfx::kChromeIconGrey)); @@ -91,24 +92,25 @@ DISTANCE_UNRELATED_CONTROL_VERTICAL_LARGE); layout->AddPaddingRow(1.0, unrelated_vertical_spacing_large); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - layout->AddView(image, 2, 1); + layout->AddView(std::move(image), 2, 1); - title_ = new views::Label(l10n_util::GetStringUTF16(GetTitle())); + auto title = + std::make_unique<views::Label>(l10n_util::GetStringUTF16(GetTitle())); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); - title_->SetMultiLine(true); - title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + title->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); + title->SetMultiLine(true); + title->SetHorizontalAlignment(gfx::ALIGN_LEFT); layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id, views::GridLayout::kFixedSize, unrelated_vertical_spacing_large); - layout->AddView(title_, 2, 1.0); + title_ = layout->AddView(std::move(title), 2, 1.0); - message_ = CreateFormattedLabel(l10n_util::GetStringUTF16(GetInfoMessage())); layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id, views::GridLayout::kFixedSize, kTitleBottomSpacing); - layout->AddView(message_, 2, 1.0, views::GridLayout::LEADING, - views::GridLayout::LEADING); + message_ = layout->AddView( + CreateFormattedLabel(l10n_util::GetStringUTF16(GetInfoMessage())), 2, 1.0, + views::GridLayout::LEADING, views::GridLayout::LEADING); std::vector<int> bullet_string_ids = GetSubMessages(); if (!bullet_string_ids.empty()) { @@ -117,21 +119,24 @@ list_view->AddLabel(l10n_util::GetStringUTF16(id)); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - layout->AddView(list_view.release(), 2, 1.0); + layout->AddView(std::move(list_view), 2, 1.0); } - action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( - this, l10n_util::GetStringUTF16(GetButtonTitle())) - .release(); - help_link_ = new views::Link(l10n_util::GetStringUTF16(GetHelpLinkTitle())); - help_link_->set_listener(this); + std::unique_ptr<views::LabelButton> action_button = + views::MdTextButton::CreateSecondaryUiBlueButton( + this, l10n_util::GetStringUTF16(GetButtonTitle())); + auto help_link = std::make_unique<views::Link>( + l10n_util::GetStringUTF16(GetHelpLinkTitle())); + help_link->set_listener(this); layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id, views::GridLayout::kFixedSize, unrelated_vertical_spacing_large); - layout->AddView(help_link_, 1.0, 1.0, views::GridLayout::LEADING, - views::GridLayout::CENTER); - layout->AddView(action_button_, 1.0, 1.0, views::GridLayout::TRAILING, - views::GridLayout::LEADING); + help_link_ = + layout->AddView(std::move(help_link), 1.0, 1.0, + views::GridLayout::LEADING, views::GridLayout::CENTER); + action_button_ = + layout->AddView(std::move(action_button), 1.0, 1.0, + views::GridLayout::TRAILING, views::GridLayout::LEADING); layout->AddPaddingRow(2, provider->GetDistanceMetric( views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
diff --git a/chrome/browser/ui/views/session_crashed_bubble_view.cc b/chrome/browser/ui/views/session_crashed_bubble_view.cc index 52f9340..54429a7 100644 --- a/chrome/browser/ui/views/session_crashed_bubble_view.cc +++ b/chrome/browser/ui/views/session_crashed_bubble_view.cc
@@ -214,7 +214,7 @@ provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL))); // Description text label. - views::Label* text_label = new views::Label( + auto text_label = std::make_unique<views::Label>( l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE)); text_label->SetMultiLine(true); text_label->SetLineHeight(20); @@ -223,13 +223,13 @@ provider->GetDistanceMetric( ChromeDistanceMetric::DISTANCE_BUBBLE_PREFERRED_WIDTH) - margins().width()); - AddChildView(text_label); + AddChildView(std::move(text_label)); if (offer_uma_optin_) AddChildView(CreateUmaOptInView()); } -views::View* SessionCrashedBubbleView::CreateUmaOptInView() { +std::unique_ptr<views::View> SessionCrashedBubbleView::CreateUmaOptInView() { RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN); // The text to the right of the checkbox. @@ -240,7 +240,7 @@ IDS_SESSION_CRASHED_VIEW_UMA_OPTIN, link_text, &offset); - views::StyledLabel* uma_label = new views::StyledLabel(uma_text, this); + auto uma_label = std::make_unique<views::StyledLabel>(uma_text, this); uma_label->AddStyleRange(gfx::Range(offset, offset + link_text.length()), views::StyledLabel::RangeStyleInfo::CreateForLink()); views::StyledLabel::RangeStyleInfo uma_style; @@ -255,12 +255,12 @@ uma_label->SetBorder(views::CreateEmptyBorder(1, 0, 0, 0)); // Checkbox for metric reporting setting. - uma_option_ = new views::Checkbox(base::string16()); - uma_option_->SetChecked(false); - uma_option_->SetAssociatedLabel(uma_label); + auto uma_option = std::make_unique<views::Checkbox>(base::string16()); + uma_option->SetChecked(false); + uma_option->SetAssociatedLabel(uma_label.get()); // Create a view to hold the checkbox and the text. - views::View* uma_view = new views::View(); + auto uma_view = std::make_unique<views::View>(); views::GridLayout* uma_layout = uma_view->SetLayoutManager(std::make_unique<views::GridLayout>()); @@ -276,8 +276,8 @@ views::GridLayout::USE_PREF, 0, 0); uma_layout->StartRow(views::GridLayout::kFixedSize, kReportColumnSetId); - uma_layout->AddView(uma_option_); - uma_layout->AddView(uma_label); + uma_option_ = uma_layout->AddView(std::move(uma_option)); + uma_layout->AddView(std::move(uma_label)); return uma_view; }
diff --git a/chrome/browser/ui/views/session_crashed_bubble_view.h b/chrome/browser/ui/views/session_crashed_bubble_view.h index 1b42855..a33c410a 100644 --- a/chrome/browser/ui/views/session_crashed_bubble_view.h +++ b/chrome/browser/ui/views/session_crashed_bubble_view.h
@@ -66,7 +66,7 @@ // Creates a view allowing the user to opt-in to reporting information to UMA. // Returns nullptr if offer is unavailable. - views::View* CreateUmaOptInView(); + std::unique_ptr<views::View> CreateUmaOptInView(); // Restore previous session after user selects so. void RestorePreviousSession();
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc index 8f207c0..82a6874 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -48,9 +48,9 @@ #if defined(OS_CHROMEOS) #include "ash/public/cpp/ash_features.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/window_properties.h" // nogncheck #include "ash/public/cpp/window_state_type.h" // nogncheck +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "ui/wm/core/coordinate_conversion.h" #endif @@ -117,7 +117,7 @@ void StoreCurrentDraggedBrowserBoundsInTabletMode( aura::Window* window, const gfx::Rect& bounds_in_screen) { - if (ash::TabletMode::Get()->InTabletMode()) { + if (TabletModeClient::Get()->tablet_mode_enabled()) { // The bounds that is stored in ash::kRestoreBoundsOverrideKey will be used // by DragDetails to calculate the window bounds during dragging in tablet // mode. @@ -1842,7 +1842,7 @@ } #if defined(OS_CHROMEOS) - if (ash::TabletMode::Get()->InTabletMode()) { + if (TabletModeClient::Get()->tablet_mode_enabled()) { new_bounds = GetDraggedBrowserBoundsInTabletMode( source->AsView()->GetWidget()->GetNativeWindow()); } @@ -1882,7 +1882,7 @@ const gfx::Point& point_in_screen) { gfx::Rect bounds = widget->GetWindowBoundsInScreen(); #if defined(OS_CHROMEOS) - if (ash::TabletMode::Get()->InTabletMode()) + if (TabletModeClient::Get()->tablet_mode_enabled()) bounds = GetDraggedBrowserBoundsInTabletMode(widget->GetNativeWindow()); #endif
diff --git a/chrome/browser/ui/views/textfield_layout.cc b/chrome/browser/ui/views/textfield_layout.cc index 025c6e0..c09fa18 100644 --- a/chrome/browser/ui/views/textfield_layout.cc +++ b/chrome/browser/ui/views/textfield_layout.cc
@@ -4,6 +4,8 @@ #include "chrome/browser/ui/views/textfield_layout.h" +#include <utility> + #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "ui/base/models/combobox_model.h" #include "ui/views/controls/combobox/combobox.h" @@ -16,7 +18,7 @@ void AddLabelAndField(views::GridLayout* layout, const base::string16& label_text, - views::View* field, + std::unique_ptr<views::View> field, int column_set_id, const gfx::FontList& field_font) { constexpr int kFontContext = views::style::CONTEXT_LABEL; @@ -25,8 +27,9 @@ int row_height = views::LayoutProvider::GetControlHeightForFont( kFontContext, kFontStyle, field_font); layout->StartRow(views::GridLayout::kFixedSize, column_set_id, row_height); - layout->AddView(new views::Label(label_text, kFontContext, kFontStyle)); - layout->AddView(field); + layout->AddView( + std::make_unique<views::Label>(label_text, kFontContext, kFontStyle)); + layout->AddView(std::move(field)); } } // namespace @@ -58,11 +61,12 @@ views::Textfield* AddFirstTextfieldRow(views::GridLayout* layout, const base::string16& label, int column_set_id) { - views::Textfield* textfield = new views::Textfield(); + auto textfield = std::make_unique<views::Textfield>(); textfield->SetAccessibleName(label); - AddLabelAndField(layout, label, textfield, column_set_id, - textfield->GetFontList()); - return textfield; + auto* textfield_ptr = textfield.get(); + AddLabelAndField(layout, label, std::move(textfield), column_set_id, + textfield_ptr->GetFontList()); + return textfield_ptr; } views::Textfield* AddTextfieldRow(views::GridLayout* layout, @@ -78,12 +82,13 @@ const base::string16& label, std::unique_ptr<ui::ComboboxModel> model, int column_set_id) { - views::Combobox* combobox = new views::Combobox(std::move(model)); + auto combobox = std::make_unique<views::Combobox>(std::move(model)); combobox->SetAccessibleName(label); + auto* combobox_ptr = combobox.get(); layout->AddPaddingRow(views::GridLayout::kFixedSize, ChromeLayoutProvider::Get()->GetDistanceMetric( DISTANCE_CONTROL_LIST_VERTICAL)); - AddLabelAndField(layout, label, combobox, column_set_id, - combobox->GetFontList()); - return combobox; + AddLabelAndField(layout, label, std::move(combobox), column_set_id, + combobox_ptr->GetFontList()); + return combobox_ptr; }
diff --git a/chrome/browser/ui/views/uninstall_view.cc b/chrome/browser/ui/views/uninstall_view.cc index 32f24ce..28f52b8 100644 --- a/chrome/browser/ui/views/uninstall_view.cc +++ b/chrome/browser/ui/views/uninstall_view.cc
@@ -54,10 +54,10 @@ views::GridLayout::kFixedSize, views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - confirm_label_ = new views::Label( + auto confirm_label = std::make_unique<views::Label>( l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY)); - confirm_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); - layout->AddView(confirm_label_); + confirm_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + confirm_label_ = layout->AddView(std::move(confirm_label)); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); @@ -83,9 +83,8 @@ views::GridLayout::kFixedSize, views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - delete_profile_ = new views::Checkbox( - l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE)); - layout->AddView(delete_profile_); + delete_profile_ = layout->AddView(std::make_unique<views::Checkbox>( + l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE))); // Set default browser combo box. If the default should not or cannot be // changed, widgets are not shown. We assume here that if Chrome cannot @@ -112,11 +111,12 @@ views::GridLayout::LEADING, views::GridLayout::CENTER, views::GridLayout::kFixedSize, views::GridLayout::USE_PREF, 0, 0); layout->StartRow(views::GridLayout::kFixedSize, column_set_id); - change_default_browser_ = new views::Checkbox( - l10n_util::GetStringUTF16(IDS_UNINSTALL_SET_DEFAULT_BROWSER), this); - layout->AddView(change_default_browser_); - browsers_combo_ = new views::Combobox(this); - layout->AddView(browsers_combo_); + change_default_browser_ = + layout->AddView(std::make_unique<views::Checkbox>( + l10n_util::GetStringUTF16(IDS_UNINSTALL_SET_DEFAULT_BROWSER), + this)); + browsers_combo_ = + layout->AddView(std::make_unique<views::Combobox>(this)); browsers_combo_->SetEnabled(false); } }
diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc index a2576ee..cd1d375 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -8,7 +8,6 @@ #include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/event_rewriter_controller.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/interfaces/constants.mojom.h" #include "ash/shell.h" #include "base/bind.h" @@ -34,6 +33,7 @@ #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/webui/chromeos/login/demo_setup_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" @@ -99,7 +99,8 @@ base::Bind(&CoreOobeHandler::OnAccessibilityStatusChanged, base::Unretained(this))); - ash::TabletMode::Get()->AddObserver(this); + TabletModeClient* tablet_mode_client = TabletModeClient::Get(); + tablet_mode_client->AddObserver(this); // |connector| may be null in tests. auto* connector = content::GetSystemConnector(); @@ -112,7 +113,7 @@ CoreOobeHandler::~CoreOobeHandler() { OobeConfiguration::Get()->RemoveObserver(this); - ash::TabletMode::Get()->RemoveObserver(this); + TabletModeClient::Get()->RemoveObserver(this); } void CoreOobeHandler::DeclareLocalizedValues( @@ -178,7 +179,7 @@ void CoreOobeHandler::GetAdditionalParameters(base::DictionaryValue* dict) { dict->SetKey("isInTabletMode", - base::Value(ash::TabletMode::Get()->InTabletMode())); + base::Value(TabletModeClient::Get()->tablet_mode_enabled())); dict->SetKey("isDemoModeEnabled", base::Value(DemoSetupController::IsDemoModeAllowed())); dict->SetKey("showTechnologyBadge",
diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h index 3e6ca78..41232f4 100644 --- a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h
@@ -9,7 +9,6 @@ #include <string> #include <vector> -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "ash/public/interfaces/cros_display_config.mojom.h" #include "base/callback.h" #include "base/macros.h" @@ -20,6 +19,7 @@ #include "chrome/browser/chromeos/login/help_app_launcher.h" #include "chrome/browser/chromeos/login/oobe_configuration.h" #include "chrome/browser/chromeos/login/version_info_updater.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" #include "ui/events/event_source.h" @@ -70,7 +70,7 @@ public VersionInfoUpdater::Delegate, public CoreOobeView, public ui::EventSource, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public OobeConfiguration::Observer { public: explicit CoreOobeHandler(JSCallsContainer* js_calls_container); @@ -144,7 +144,7 @@ void StopDemoModeDetection() override; void UpdateKeyboardState() override; - // ash::TabletModeToggleObserver: + // TabletModeClientObserver: void OnTabletModeToggled(bool enabled) override; // OobeConfiguration::Observer:
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index c13ec8c..54b787d4 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -11,7 +11,6 @@ #include <vector> #include "ash/public/cpp/login_constants.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/wallpaper_types.h" #include "ash/public/interfaces/tray_action.mojom.h" #include "base/bind.h" @@ -65,6 +64,7 @@ #include "chrome/browser/profiles/profile_metrics.h" #include "chrome/browser/ui/ash/ime_controller_client.h" #include "chrome/browser/ui/ash/session_controller_client_impl.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chrome/browser/ui/ash/wallpaper_controller_client.h" #include "chrome/browser/ui/webui/chromeos/internet_detail_dialog.h" #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h" @@ -266,9 +266,9 @@ base::Bind(&SigninScreenHandler::OnAllowedInputMethodsChanged, base::Unretained(this))); - ash::TabletMode* tablet_mode = ash::TabletMode::Get(); - tablet_mode->AddObserver(this); - OnTabletModeToggled(tablet_mode->InTabletMode()); + TabletModeClient* tablet_mode_client = TabletModeClient::Get(); + tablet_mode_client->AddObserver(this); + OnTabletModeToggled(tablet_mode_client->tablet_mode_enabled()); WallpaperControllerClient::Get()->AddObserver(this); } @@ -276,7 +276,7 @@ SigninScreenHandler::~SigninScreenHandler() { if (auto* wallpaper_controller_client = WallpaperControllerClient::Get()) wallpaper_controller_client->RemoveObserver(this); - ash::TabletMode::Get()->RemoveObserver(this); + TabletModeClient::Get()->RemoveObserver(this); OobeUI* oobe_ui = GetOobeUI(); if (oobe_ui && oobe_ui_observer_added_) oobe_ui->RemoveObserver(this); @@ -1359,7 +1359,7 @@ void SigninScreenHandler::HandleGetTabletModeState() { CallJS("login.AccountPickerScreen.setTabletModeState", - ash::TabletMode::Get()->InTabletMode()); + TabletModeClient::Get()->tablet_mode_enabled()); } void SigninScreenHandler::HandleGetDemoModeState() {
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h index 1ac05ab..48988d3 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -10,7 +10,6 @@ #include <set> #include <string> -#include "ash/public/cpp/tablet_mode_toggle_observer.h" #include "ash/public/cpp/wallpaper_controller_observer.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -22,6 +21,7 @@ #include "chrome/browser/chromeos/login/signin_specifics.h" #include "chrome/browser/chromeos/login/ui/login_display.h" #include "chrome/browser/chromeos/settings/cros_settings.h" +#include "chrome/browser/ui/ash/tablet_mode_client_observer.h" #include "chrome/browser/ui/webui/chromeos/login/base_webui_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" @@ -183,7 +183,7 @@ public NetworkStateInformer::NetworkStateInformerObserver, public PowerManagerClient::Observer, public input_method::ImeKeyboard::Observer, - public ash::TabletModeToggleObserver, + public TabletModeClientObserver, public OobeUI::Observer, public ash::WallpaperControllerObserver { public: @@ -302,7 +302,7 @@ // PowerManagerClient::Observer implementation: void SuspendDone(const base::TimeDelta& sleep_duration) override; - // ash::TabletModeToggleObserver: + // TabletModeClientObserver: void OnTabletModeToggled(bool enabled) override; // Restore input focus to current user pod.
diff --git a/chrome/browser/ui/webui/chromeos/set_time_ui.cc b/chrome/browser/ui/webui/chromeos/set_time_ui.cc index 95659848..7c2890f 100644 --- a/chrome/browser/ui/webui/chromeos/set_time_ui.cc +++ b/chrome/browser/ui/webui/chromeos/set_time_ui.cc
@@ -129,7 +129,8 @@ } AccountId account_id; - if (user_manager::UserManager::Get()->IsUserLoggedIn()) { + bool is_user_logged_in = user_manager::UserManager::Get()->IsUserLoggedIn(); + if (is_user_logged_in) { account_id = user_manager::UserManager::Get()->GetActiveUser()->GetAccountId(); } @@ -137,7 +138,8 @@ account_id, base::BindRepeating(&SetTimeMessageHandler::OnParentAccessValidation, weak_factory_.GetWeakPtr()), - ash::ParentAccessRequestReason::kChangeTime); + ash::ParentAccessRequestReason::kChangeTime, + !is_user_logged_in /* extra_dimmer */); } void OnParentAccessValidation(bool success) {
diff --git a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc index ef68e3e..7dc7653 100644 --- a/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc
@@ -5,11 +5,11 @@ #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h" #include "ash/public/cpp/keyboard_shortcut_viewer.h" -#include "ash/public/cpp/tablet_mode.h" #include "ash/public/interfaces/constants.mojom.h" #include "base/bind.h" #include "base/command_line.h" #include "base/values.h" +#include "chrome/browser/ui/ash/tablet_mode_client.h" #include "chromeos/constants/chromeos_switches.h" #include "chromeos/services/assistant/public/features.h" #include "content/public/browser/web_ui.h" @@ -115,7 +115,8 @@ void KeyboardHandler::UpdateKeyboards() { bool physical_keyboard = false; // In tablet mode, physical keybards are disabled / ignored. - if (!ash::TabletMode::Get()->InTabletMode()) { + if (!TabletModeClient::Get() || + !TabletModeClient::Get()->tablet_mode_enabled()) { physical_keyboard = true; } if (!physical_keyboard) {
diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index 05eb976..8e98f3f 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
@@ -1892,7 +1892,7 @@ #endif {"syncOverview", IDS_SETTINGS_SYNC_OVERVIEW}, {"syncDisabled", IDS_PROFILES_DICE_SYNC_DISABLED_TITLE}, - {"syncDisabledByAdministrator", IDS_SIGNED_IN_WITH_SYNC_DISABLED}, + {"syncDisabledByAdministrator", IDS_SIGNED_IN_WITH_SYNC_DISABLED_BY_POLICY}, {"syncSignin", IDS_SETTINGS_SYNC_SIGNIN}, {"syncDisconnect", IDS_SETTINGS_PEOPLE_SIGN_OUT}, {"syncDisconnectTitle", IDS_SETTINGS_SYNC_DISCONNECT_TITLE},
diff --git a/chrome/browser/vr/DEPS b/chrome/browser/vr/DEPS index af8f689..6c9833be 100644 --- a/chrome/browser/vr/DEPS +++ b/chrome/browser/vr/DEPS
@@ -4,6 +4,7 @@ "+cc/test", "+cc/trees", "+device/vr/util", + "+chrome/android/features/vr/jni_headers", ] specific_include_rules = { @@ -11,4 +12,4 @@ "+device/vr/test/test_hook.h", "+third_party/openvr/src/headers/openvr.h", ], -} \ No newline at end of file +}
diff --git a/chrome/browser/vr/metrics/consent_flow_metrics_helper.cc b/chrome/browser/vr/metrics/consent_flow_metrics_helper.cc index 023d4d0..65491042 100644 --- a/chrome/browser/vr/metrics/consent_flow_metrics_helper.cc +++ b/chrome/browser/vr/metrics/consent_flow_metrics_helper.cc
@@ -8,7 +8,7 @@ #if defined(OS_ANDROID) #include "base/android/jni_string.h" -#include "jni/ConsentFlowMetrics_jni.h" +#include "chrome/android/features/vr/jni_headers/ConsentFlowMetrics_jni.h" using base::android::JavaParamRef; #endif
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json index 5ce73e1..b5088fc0 100644 --- a/chrome/common/extensions/api/_api_features.json +++ b/chrome/common/extensions/api/_api_features.json
@@ -541,6 +541,10 @@ "dependencies": ["permission:launcherSearchProvider"], "contexts": ["blessed_extension"] }, + "login": { + "dependencies": ["permission:login"], + "contexts": ["blessed_extension"] + }, "loginScreenUi": { "dependencies": ["permission:loginScreenUi"], "contexts": ["blessed_extension"]
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index d097c11..fb4dddd 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json
@@ -435,6 +435,16 @@ // (staging) ] }, + "login": { + "channel": "dev", + "extension_types": ["login_screen_extension"], + "location": "policy", + "platforms": ["chromeos"], + "whitelist": [ + "E219EE36A3B40612FD2A8CD6937B03EF0C97D3FE", // Imprivata (login screen) + "A24DE1B21A67E25FB62AC8491642038FE25DA75B" // Imprivata (in session) + ] + }, "loginScreenUi": { "channel": "dev", "extension_types": ["login_screen_extension"],
diff --git a/chrome/common/extensions/api/api_sources.gni b/chrome/common/extensions/api/api_sources.gni index ddc9fd41..84367af 100644 --- a/chrome/common/extensions/api/api_sources.gni +++ b/chrome/common/extensions/api/api_sources.gni
@@ -97,6 +97,7 @@ "input_ime.json", "input_method_private.json", "launcher_search_provider.idl", + "login.idl", "login_screen_ui.idl", "platform_keys.idl", "platform_keys_internal.idl",
diff --git a/chrome/common/extensions/api/login.idl b/chrome/common/extensions/api/login.idl new file mode 100644 index 0000000..28770099 --- /dev/null +++ b/chrome/common/extensions/api/login.idl
@@ -0,0 +1,39 @@ +// Copyright 2019 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. + +// Use the <code>chrome.login</code> API to launch and exit user sessions. +[platforms=("chromeos"), + implemented_in="chrome/browser/chromeos/extensions/login/login_api.h"] +namespace login { + callback VoidCallback = void (); + callback BooleanCallback = void (boolean result); + callback StringCallback = void (DOMString result); + + interface Functions { + // Launches a managed guest session if one is set up via the admin console. + // If there are several managed guest sessions set up, it will launch the + // first available one. + static void launchManagedGuestSession(optional VoidCallback callback); + + // Exits the current session. + // |dataForNextLoginAttempt|: If set, stores data which can be read by + // <code>fetchDataForNextLoginAttempt()</code> from the login screen. If + // unset, any currently stored data will be cleared. + static void exitCurrentSession(optional DOMString dataForNextLoginAttempt, + optional VoidCallback callback); + + // Checks whether the caller extension is running in the login screen + // profile. + // |callback|: Called with true if the caller extension is running in the + // login screen profile, or false otherwise. + static void isRunningInLoginProfile(BooleanCallback callback); + + // Reads the <code>dataForNextLoginAttempt</code> set by + // <code>exitCurrentSession()</code>. Clears the previously stored data + // after reading so it can only be read once. + // |callback|: Called with the stored data, or an empty string if there was + // no previously stored data. + static void fetchDataForNextLoginAttempt(StringCallback callback); + }; +};
diff --git a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc index 5afea31..623aa14 100644 --- a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc +++ b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc
@@ -665,6 +665,7 @@ {IDS_EXTENSION_PROMPT_WARNING_ENTERPRISE_HARDWARE_PLATFORM, {APIPermission::kEnterpriseHardwarePlatform}, {}}, + {IDS_EXTENSION_PROMPT_WARNING_LOGIN, {APIPermission::kLogin}, {}}, {IDS_EXTENSION_PROMPT_WARNING_LOGIN_SCREEN_UI, {APIPermission::kLoginScreenUi}, {}},
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index efd32ff..41bf78e 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc
@@ -957,6 +957,11 @@ // be used via the WebUSB API. const char kDeviceWebUsbAllowDevicesForUrls[] = "device_webusb_allow_devices_for_urls"; + +// A string pref stored in local state. Set and read by extensions using the +// chrome.login API. +const char kLoginExtensionApiDataForNextLoginAttempt[] = + "extensions_api.login.data_for_next_login_attempt"; #endif // defined(OS_CHROMEOS) // A boolean pref set to true if a Home button to open the Home pages should be
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 9a0c816e..44707b9 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h
@@ -308,6 +308,7 @@ extern const char kAppReinstallRecommendationEnabled[]; extern const char kStartupBrowserWindowLaunchSuppressed[]; extern const char kDeviceWebUsbAllowDevicesForUrls[]; +extern const char kLoginExtensionApiDataForNextLoginAttempt[]; #endif // defined(OS_CHROMEOS) extern const char kShowHomeButton[]; extern const char kSpeechRecognitionFilterProfanities[];
diff --git a/chrome/lib/image_fetcher/public/android/BUILD.gn b/chrome/lib/image_fetcher/public/android/BUILD.gn index 02ba3114..bf0d11d 100644 --- a/chrome/lib/image_fetcher/public/android/BUILD.gn +++ b/chrome/lib/image_fetcher/public/android/BUILD.gn
@@ -28,5 +28,4 @@ sources = [ "java/src/org/chromium/chrome/browser/image_fetcher/ImageFetcherBridge.java", ] - jni_package = "chrome" }
diff --git a/chrome/lib/util/public/android/BUILD.gn b/chrome/lib/util/public/android/BUILD.gn index e2c26ab..c00fc87d 100644 --- a/chrome/lib/util/public/android/BUILD.gn +++ b/chrome/lib/util/public/android/BUILD.gn
@@ -28,5 +28,4 @@ sources = [ "java/src/org/chromium/chrome/browser/util/UrlUtilities.java", ] - jni_package = "chrome" }
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc index 9ad85d5d..5a84966 100644 --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -21,8 +21,8 @@ #include "components/autofill/content/renderer/autofill_agent.h" #include "components/autofill/content/renderer/form_autofill_util.h" #include "components/autofill/content/renderer/form_tracker.h" +#include "components/autofill/content/renderer/password_generation_agent.h" #include "components/autofill/content/renderer/test_password_autofill_agent.h" -#include "components/autofill/content/renderer/test_password_generation_agent.h" #include "components/autofill/core/common/autofill_constants.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/form_data.h" @@ -72,6 +72,8 @@ const char kCreditCardOwnerName[] = "creditcardowner"; const char kCreditCardNumberName[] = "creditcardnumber"; const char kCreditCardVerificationName[] = "cvc"; +const char kSearchField[] = "search"; +const char kSocialMediaTextArea[] = "new_chirp"; const char kAliceUsername[] = "alice"; const char kAlicePassword[] = "password"; @@ -89,6 +91,19 @@ " <INPUT type='submit' value='Login'/>" "</FORM>"; +const char kSocialNetworkPostFormHTML[] = + "<FORM id='SocialMediaPostForm' action='http://www.chirper.com'>" + " <TEXTAREA id='new_chirp'>" + " </TEXTAREA>" + " <INPUT type='submit' value='Chirp'/>" + "</FORM>"; + +const char kSearchFieldHTML[] = + "<FORM id='SearchFieldForm' action='http://www.gewgle.de'>" + " <INPUT type='search' id='search'/>" + " <INPUT type='submit' value='Chirp'/>" + "</FORM>"; + const char kVisibleFormWithNoUsernameHTML[] = "<head> <style> form {display: inline;} </style> </head>" "<body>" @@ -2571,9 +2586,9 @@ TEST_F(PasswordAutofillAgentTest, PasswordGenerationTriggered_TypedPassword) { SimulateOnFillPasswordForm(fill_data_); - SetNotBlacklistedMessage(password_generation_, kFormHTML); - SetAccountCreationFormsDetectedMessage(password_generation_, - GetMainFrame()->GetDocument(), 0, 2); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "password" /* new_password_id */, nullptr /* confirm_password_id*/); // Generation event is triggered due to focus events. EXPECT_CALL(fake_pw_client_, GenerationElementLostFocus()) @@ -2592,9 +2607,12 @@ PasswordGenerationTriggered_GeneratedPassword) { SimulateOnFillPasswordForm(fill_data_); - SetNotBlacklistedMessage(password_generation_, kFormHTML); - SetAccountCreationFormsDetectedMessage(password_generation_, - GetMainFrame()->GetDocument(), 0, 2); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "password" /* new_password_id */, nullptr /* confirm_password_id*/); + // Simulate the user clicks on a password field, that leads to showing + // generaiton pop-up. GeneratedPasswordAccepted can't be called without it. + SimulateElementClick(kPasswordName); base::string16 password = ASCIIToUTF16("NewPass22"); EXPECT_CALL(fake_pw_client_, @@ -2610,9 +2628,12 @@ TEST_F(PasswordAutofillAgentTest, ResetPasswordGenerationWhenFieldIsAutofilled) { // A user generates password. - SetNotBlacklistedMessage(password_generation_, kFormHTML); - SetAccountCreationFormsDetectedMessage(password_generation_, - GetMainFrame()->GetDocument(), 0, 2); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "password" /* new_password_id */, nullptr /* confirm_password_id*/); + // Simulate the user clicks on a password field, that leads to showing + // generaiton pop-up. GeneratedPasswordAccepted can't be called without it. + SimulateElementClick(kPasswordName); base::string16 password = ASCIIToUTF16("NewPass22"); EXPECT_CALL(fake_pw_client_, PresaveGeneratedPassword(testing::Field( @@ -2660,10 +2681,10 @@ SimulateOnFillPasswordForm(fill_data_); // Simulate generation triggering. - SetNotBlacklistedMessage(password_generation_, - kSignupFormHTML); - SetAccountCreationFormsDetectedMessage(password_generation_, - GetMainFrame()->GetDocument(), 0, 1); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "new_password" /* new_password_id */, + "confirm_password" /* confirm_password_id*/); // Simulate the field being clicked to start typing. This should trigger // generation but not password autofill. @@ -3041,14 +3062,14 @@ TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillableFields) { SimulateElementClick("random_field"); fake_driver_.Flush(); - EXPECT_EQ(FocusedFieldType::kFillableTextField, + EXPECT_EQ(FocusedFieldType::kFillableNonSearchField, fake_driver_.last_focused_field_type()); // A username field without fill data is indistinguishable from any other text // field. SimulateElementClick(kUsernameName); fake_driver_.Flush(); - EXPECT_EQ(FocusedFieldType::kFillableTextField, + EXPECT_EQ(FocusedFieldType::kFillableNonSearchField, fake_driver_.last_focused_field_type()); SimulateElementClick(kPasswordName); @@ -3064,6 +3085,23 @@ fake_driver_.last_focused_field_type()); } +TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillablSearchField) { + LoadHTML(kSearchFieldHTML); + SimulateElementClick(kSearchField); + fake_driver_.Flush(); + EXPECT_EQ(FocusedFieldType::kFillableSearchField, + fake_driver_.last_focused_field_type()); +} + +TEST_F(PasswordAutofillAgentTest, DriverIsInformedAboutFillableTextArea) { + LoadHTML(kSocialNetworkPostFormHTML); + + SimulateElementClick(kSocialMediaTextArea); + fake_driver_.Flush(); + EXPECT_EQ(FocusedFieldType::kFillableTextArea, + fake_driver_.last_focused_field_type()); +} + // Tests that credential suggestions are autofilled on a password (and change // password) forms having either ambiguous or empty name. TEST_F(PasswordAutofillAgentTest,
diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc index cf76741..691b58d 100644 --- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc +++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -18,8 +18,8 @@ #include "chrome/test/base/chrome_render_view_test.h" #include "components/autofill/content/renderer/autofill_agent.h" #include "components/autofill/content/renderer/form_autofill_util.h" +#include "components/autofill/content/renderer/password_generation_agent.h" #include "components/autofill/content/renderer/test_password_autofill_agent.h" -#include "components/autofill/content/renderer/test_password_generation_agent.h" #include "components/autofill/core/common/autofill_switches.h" #include "components/autofill/core/common/form_data.h" #include "components/autofill/core/common/password_generation_util.h" @@ -105,15 +105,6 @@ " <INPUT type = 'submit' value = 'LOGIN' />" "</FORM>"; -constexpr char kInvalidActionAccountCreationFormHTML[] = - "<FORM name = 'blah' action = 'invalid'> " - " <INPUT type = 'text' id = 'username'/> " - " <INPUT type = 'password' id = 'first_password'/> " - " <INPUT type = 'password' id = 'second_password'/> " - " <INPUT type = 'button' id = 'dummy'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - constexpr char kMultipleAccountCreationFormHTML[] = "<FORM name = 'login' action = 'http://www.random.com/'> " " <INPUT type = 'text' id = 'random'/> " @@ -131,47 +122,6 @@ " <INPUT type = 'submit' value = 'LOGIN' />" "</FORM>"; -constexpr char kBothAutocompleteAttributesFormHTML[] = - "<FORM name = 'blah' action = 'http://www.random.com/'> " - " <INPUT type = 'text' autocomplete='username' id = 'username'/> " - " <INPUT type = 'password' id = 'first_password' " - " autocomplete = 'new-password' size = 5/>" - " <INPUT type = 'password' id = 'second_password' size = 5/> " - " <INPUT type = 'button' id = 'dummy'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - -constexpr char kUsernameAutocompleteAttributeFormHTML[] = - "<FORM name = 'blah' action = 'http://www.random.com/'> " - " <INPUT type = 'text' autocomplete='username' id = 'username'/> " - " <INPUT type = 'password' id = 'first_password' size = 5/>" - " <INPUT type = 'password' id = 'second_password' size = 5/> " - " <INPUT type = 'button' id = 'dummy'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - -constexpr char kNewPasswordAutocompleteAttributeFormHTML[] = - "<FORM name = 'blah' action = 'http://www.random.com/'> " - " <INPUT type = 'text' id = 'username'/> " - " <INPUT type = 'password' id = 'first_password' " - " autocomplete='new-password' size = 5/>" - " <INPUT type = 'password' id = 'second_password' size = 5/> " - " <INPUT type = 'button' id = 'dummy'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - -constexpr char kCurrentAndNewPasswordAutocompleteAttributeFormHTML[] = - "<FORM name = 'blah' action = 'http://www.random.com/'> " - " <INPUT type = 'password' id = 'old_password' " - " autocomplete='current-password'/>" - " <INPUT type = 'password' id = 'new_password' " - " autocomplete='new-password'/>" - " <INPUT type = 'password' id = 'confirm_password' " - " autocomplete='new-password'/>" - " <INPUT type = 'button' id = 'dummy'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - constexpr char kPasswordChangeFormHTML[] = "<FORM name = 'ChangeWithUsernameForm' action = 'http://www.bidule.com'> " " <INPUT type = 'text' id = 'username'/> " @@ -217,12 +167,6 @@ bool received, const base::string16& expected_generation_element); void SelectGenerationFallbackAndExpect(bool available); - void SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus status, - int form_index = 0, - int field_index = 1); - void SetAccountCreationFormsDetectedMessageForUnownedInputs( - GenerationAvailableForFormStatus status); void BindPasswordManagerDriver(mojo::ScopedInterfaceEndpointHandle handle); void BindPasswordManagerClient(mojo::ScopedInterfaceEndpointHandle handle); @@ -370,30 +314,6 @@ testing::Mock::VerifyAndClearExpectations(this); } -void PasswordGenerationAgentTest::SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus status, - int form_index, - int field_index) { - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)) - .Times(status == GenerationAvailableForFormStatus::kAvailable); - ::autofill::SetAccountCreationFormsDetectedMessage( - password_generation_, GetMainFrame()->GetDocument(), form_index, - field_index); - fake_pw_client_.Flush(); - testing::Mock::VerifyAndClearExpectations(&fake_pw_client_); -} - -void PasswordGenerationAgentTest:: - SetAccountCreationFormsDetectedMessageForUnownedInputs( - GenerationAvailableForFormStatus status) { - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)) - .Times(status == GenerationAvailableForFormStatus::kAvailable); - ::autofill::SetAccountCreationFormsDetectedMessageForUnownedInputs( - password_generation_, GetMainFrame()->GetDocument()); - fake_pw_client_.Flush(); - testing::Mock::VerifyAndClearExpectations(&fake_pw_client_); -} - void PasswordGenerationAgentTest::BindPasswordManagerDriver( mojo::ScopedInterfaceEndpointHandle handle) { fake_driver_.BindRequest( @@ -429,14 +349,9 @@ const char* kHtmlForm = has_form_tag ? kAccountCreationFormHTML : kAccountCreationNoForm; LoadHTMLWithUserGesture(kHtmlForm); - SetNotBlacklistedMessage(password_generation_, kHtmlForm); - if (has_form_tag) { - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); - } else { - SetAccountCreationFormsDetectedMessageForUnownedInputs( - GenerationAvailableForFormStatus::kAvailable); - } + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); WebDocument document = GetMainFrame()->GetDocument(); @@ -510,28 +425,17 @@ TEST_F(PasswordGenerationAgentTest, HiddenSecondPasswordDetectionTest) { // Hidden fields are not treated differently. LoadHTMLWithUserGesture(kHiddenPasswordAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, - kHiddenPasswordAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); } -TEST_F(PasswordGenerationAgentTest, InvalidActionDetectionTest) { - // This doesn't trigger because the form action is invalid. - LoadHTMLWithUserGesture(kInvalidActionAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, - kInvalidActionAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kUnavailable); - ExpectAutomaticGenerationAvailable("first_password", kNotReported); -} - TEST_F(PasswordGenerationAgentTest, DetectionTestNoForm) { LoadHTMLWithUserGesture(kAccountCreationNoForm); - SetNotBlacklistedMessage(password_generation_, kAccountCreationNoForm); - SetAccountCreationFormsDetectedMessageForUnownedInputs( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); ExpectGenerationElementLostFocus("second_password"); @@ -548,12 +452,13 @@ std::string html = std::string(kAccountCreationFormHTML) + events_registration_script; // Begin with no gesture and therefore no focused element. - LoadHTML(html.c_str()); + LoadHTMLWithUserGesture(html.c_str()); WebDocument document = GetMainFrame()->GetDocument(); - ASSERT_TRUE(document.FocusedElement().IsNull()); - SetNotBlacklistedMessage(password_generation_, html.c_str()); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration(password_generation_, + GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, + "second_password" /* confirm_password_id*/); + ExpectAutomaticGenerationAvailable("first_password", kAvailable); WebElement element = document.GetElementById(WebString::FromUTF8("first_password")); @@ -571,6 +476,7 @@ EXPECT_CALL(fake_pw_client_, PresaveGeneratedPassword(testing::Field( &autofill::PasswordForm::password_value, password))); + password_generation_->GeneratedPasswordAccepted(password); // Password fields are filled out and set as being autofilled. @@ -586,19 +492,19 @@ EXPECT_EQ(1, value) << variable; } - // Focus moved to the next input field. - // TODO(zysxqn): Change this back to the address element once Bug 90224 - // https://bugs.webkit.org/show_bug.cgi?id=90224 has been fixed. - element = document.GetElementById(WebString::FromUTF8("first_password")); + // Check that focus returns to previously focused element. + element = document.GetElementById(WebString::FromUTF8("address")); ASSERT_FALSE(element.IsNull()); EXPECT_EQ(element, document.FocusedElement()); } TEST_F(PasswordGenerationAgentTest, EditingTest) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration(password_generation_, + GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, + "second_password" /* confirm_password_id*/); + ExpectAutomaticGenerationAvailable("first_password", kAvailable); WebDocument document = GetMainFrame()->GetDocument(); WebElement element = @@ -613,6 +519,7 @@ EXPECT_CALL(fake_pw_client_, PresaveGeneratedPassword(testing::Field( &autofill::PasswordForm::password_value, password))); + password_generation_->GeneratedPasswordAccepted(password); // Passwords start out the same. @@ -646,9 +553,9 @@ TEST_F(PasswordGenerationAgentTest, EditingEventsTest) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); // Generate password. ExpectAutomaticGenerationAvailable("first_password", kAvailable); @@ -693,43 +600,13 @@ fake_driver_.last_focused_field_type()); } -TEST_F(PasswordGenerationAgentTest, BlacklistedTest) { - // Did not receive not blacklisted message. Don't show password generation - // icon. - LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kUnavailable); - ExpectAutomaticGenerationAvailable("first_password", kNotReported); -} - -TEST_F(PasswordGenerationAgentTest, UnblacklistedAnotherFormTest) { - // Receive one not blacklisted message for non account creation form. Don't - // show password generation icon. - LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kUnavailable); - ExpectAutomaticGenerationAvailable("first_password", kNotReported); -} - -TEST_F(PasswordGenerationAgentTest, UnblacklistedTest) { - // Receive one not blacklisted message for account creation form. Show - // password generation icon. - LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); - ExpectAutomaticGenerationAvailable("first_password", kAvailable); -} - TEST_F(PasswordGenerationAgentTest, UnblacklistedMultipleTest) { // Receive two not blacklisted messages, one is for account creation form and // the other is not. Show password generation icon. LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); } @@ -737,14 +614,13 @@ // Did not receive account creation forms detected message. Don't show // password generation icon. LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); // Receive the account creation forms detected message. Show password // generation icon. LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); } @@ -752,9 +628,9 @@ base::HistogramTester histogram_tester; LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); // There should now be a message to show the UI. ExpectAutomaticGenerationAvailable("first_password", kAvailable); @@ -812,12 +688,14 @@ TEST_F(PasswordGenerationAgentTest, MinimumLengthForEditedPassword) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); + ExpectAutomaticGenerationAvailable("first_password", kAvailable); // Generate a new password. base::string16 password = base::ASCIIToUTF16("random_password"); + EXPECT_CALL(fake_pw_client_, PresaveGeneratedPassword(testing::Field( &autofill::PasswordForm::password_value, password))); @@ -862,7 +740,6 @@ TEST_F(PasswordGenerationAgentTest, DynamicFormTest) { LoadHTMLWithUserGesture(kSigninFormHTML); - SetNotBlacklistedMessage(password_generation_, kSigninFormHTML); ExecuteJavaScriptForTests( "var form = document.createElement('form');" @@ -885,8 +762,9 @@ WaitForAutofillDidAssociateFormControl(); // This needs to come after the DOM has been modified. - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable, 1, 1); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); // TODO(gcasto): I'm slightly worried about flakes in this test where // didAssociateFormControls() isn't called. If this turns out to be a problem @@ -895,46 +773,12 @@ ExpectAutomaticGenerationAvailable("first_password", kAvailable); } -TEST_F(PasswordGenerationAgentTest, MultiplePasswordFormsTest) { - // If two forms on the page looks like possible account creation forms, make - // sure to trigger on the one that is specified from Autofill. - LoadHTMLWithUserGesture(kMultipleAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, - kMultipleAccountCreationFormHTML); - - // Should trigger on the second form. - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable, 1, 1); - - ExpectAutomaticGenerationAvailable("password", kNotReported); - ExpectAutomaticGenerationAvailable("first_password", kAvailable); -} - -TEST_F(PasswordGenerationAgentTest, MessagesAfterAccountSignupFormFound) { - LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); - - // Generation should be enabled. - ExpectAutomaticGenerationAvailable("first_password", kAvailable); - - // Extra not blacklisted messages can be sent. Make sure that they are handled - // correctly (generation should still be available). - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - - // Need to focus another field first for verification to work. - ExpectGenerationElementLostFocus("second_password"); - ExpectAutomaticGenerationAvailable("first_password", kAvailable); -} - // Losing focus should not trigger a password generation popup. TEST_F(PasswordGenerationAgentTest, BlurTest) { LoadHTMLWithUserGesture(kDisabledElementAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, - kDisabledElementAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); // Focus on the first password field: password generation popup should show // up. @@ -947,55 +791,17 @@ fake_pw_client_.Flush(); } -TEST_F(PasswordGenerationAgentTest, BothAutocompleteAttributesTest) { - // Verify that autocomplete attributes can override Autofill to enable - // generation. - LoadHTMLWithUserGesture(kBothAutocompleteAttributesFormHTML); - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)); - SetNotBlacklistedMessage(password_generation_, - kBothAutocompleteAttributesFormHTML); - ExpectAutomaticGenerationAvailable("first_password", kAvailable); -} - -TEST_F(PasswordGenerationAgentTest, UsernameAutocompleteAttributesTest) { - // Only username autocomplete attribute enabled doesn't trigger generation. - LoadHTMLWithUserGesture(kUsernameAutocompleteAttributeFormHTML); - SetNotBlacklistedMessage(password_generation_, - kUsernameAutocompleteAttributeFormHTML); - ExpectAutomaticGenerationAvailable("first_password", kNotReported); -} - -TEST_F(PasswordGenerationAgentTest, NewPasswordAutocompleteAttributesTest) { - // Only new-password autocomplete attribute enabled does trigger generation. - LoadHTMLWithUserGesture(kNewPasswordAutocompleteAttributeFormHTML); - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)); - SetNotBlacklistedMessage(password_generation_, - kNewPasswordAutocompleteAttributeFormHTML); - ExpectAutomaticGenerationAvailable("first_password", kAvailable); -} - -TEST_F(PasswordGenerationAgentTest, - CurrentAndNewPasswordAutocompleteAttributesTest) { - // Generation is triggered if the form has only password fields. - LoadHTMLWithUserGesture(kCurrentAndNewPasswordAutocompleteAttributeFormHTML); - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)); - SetNotBlacklistedMessage(password_generation_, - kCurrentAndNewPasswordAutocompleteAttributeFormHTML); - ExpectAutomaticGenerationAvailable("old_password", kNotReported); - ExpectAutomaticGenerationAvailable("new_password", kAvailable); - ExpectGenerationElementLostFocus("confirm_password"); -} - TEST_F(PasswordGenerationAgentTest, ChangePasswordFormDetectionTest) { // Verify that generation is shown on correct field after message receiving. LoadHTMLWithUserGesture(kPasswordChangeFormHTML); - SetNotBlacklistedMessage(password_generation_, kPasswordChangeFormHTML); ExpectAutomaticGenerationAvailable("password", kNotReported); ExpectAutomaticGenerationAvailable("newpassword", kNotReported); ExpectAutomaticGenerationAvailable("confirmpassword", kNotReported); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable, 0, 2); + SetFoundFormEligibleForGeneration(password_generation_, + GetMainFrame()->GetDocument(), + "newpassword" /* new_passwod_id */, + "confirmpassword" /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("password", kNotReported); ExpectAutomaticGenerationAvailable("newpassword", kAvailable); ExpectGenerationElementLostFocus("confirmpassword"); @@ -1018,9 +824,9 @@ TEST_F(PasswordGenerationAgentTest, ManualGenerationDoesntSuppressAutomatic) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); // The browser may show a standard password dropdown with the "Generate" // option. In this case manual generation is triggered. @@ -1148,60 +954,13 @@ base::string16()); } -TEST_F(PasswordGenerationAgentTest, ConfirmationFieldVoteFromServer) { - LoadHTMLWithUserGesture(kPasswordChangeFormHTML); - SetNotBlacklistedMessage(password_generation_, kPasswordChangeFormHTML); - - WebDocument document = GetMainFrame()->GetDocument(); - blink::WebVector<blink::WebFormElement> web_forms; - document.Forms(web_forms); - autofill::FormData form_data; - WebFormElementToFormData(web_forms[0], blink::WebFormControlElement(), - nullptr, form_util::EXTRACT_NONE, &form_data, - nullptr /* FormFieldData */); - - std::vector<autofill::PasswordFormGenerationData> forms; - autofill::PasswordFormGenerationData generation_data( - CalculateFormSignature(form_data), - CalculateFieldSignatureForField(form_data.fields[1])); - generation_data.confirmation_field_signature.emplace( - CalculateFieldSignatureForField(form_data.fields[3])); - forms.push_back(generation_data); - EXPECT_CALL(fake_pw_client_, GenerationAvailableForForm(_)); - password_generation_->FoundFormsEligibleForGeneration(forms); - - WebElement element = - document.GetElementById(WebString::FromUTF16(form_data.fields[1].name)); - ASSERT_FALSE(element.IsNull()); - WebInputElement generation_element = element.To<WebInputElement>(); - element = - document.GetElementById(WebString::FromUTF16(form_data.fields[2].name)); - ASSERT_FALSE(element.IsNull()); - WebInputElement ignored_password_element = element.To<WebInputElement>(); - element = - document.GetElementById(WebString::FromUTF16(form_data.fields[3].name)); - ASSERT_FALSE(element.IsNull()); - WebInputElement confirmation_password_element = element.To<WebInputElement>(); - - base::string16 password = base::ASCIIToUTF16("random_password"); - EXPECT_CALL(fake_pw_client_, - PresaveGeneratedPassword(testing::Field( - &autofill::PasswordForm::password_value, password))); - password_generation_->GeneratedPasswordAccepted(password); - EXPECT_EQ(password, generation_element.Value().Utf16()); - // Check that the generated password was copied according to the server's - // response. - EXPECT_EQ(base::string16(), ignored_password_element.Value().Utf16()); - EXPECT_EQ(password, confirmation_password_element.Value().Utf16()); -} - TEST_F(PasswordGenerationAgentTest, RevealPassword) { // Checks that revealed password is masked when the field lost focus. // Test cases: user click on another input field and on non-focusable element. LoadHTMLWithUserGesture(kPasswordFormAndSpanHTML); - SetNotBlacklistedMessage(password_generation_, kPasswordFormAndSpanHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "password" /* new_passwod_id */, nullptr /* confirm_password_id*/); const char* kGenerationElementId = "password"; const char* kSpanId = "span"; const char* kTextFieldId = "username"; @@ -1240,9 +999,9 @@ TEST_F(PasswordGenerationAgentTest, JavascriptClearedTheField) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); const char kGenerationElementId[] = "first_password"; ExpectAutomaticGenerationAvailable(kGenerationElementId, kAvailable); @@ -1282,9 +1041,9 @@ TEST_F(PasswordGenerationAgentTest, AutofillToGenerationField) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); ExpectAutomaticGenerationAvailable("first_password", kAvailable); WebDocument document = GetMainFrame()->GetDocument(); @@ -1308,9 +1067,9 @@ TEST_F(PasswordGenerationAgentTest, PasswordUnmaskedUntilCompleteDeletion) { LoadHTMLWithUserGesture(kAccountCreationFormHTML); - SetNotBlacklistedMessage(password_generation_, kAccountCreationFormHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); + SetFoundFormEligibleForGeneration( + password_generation_, GetMainFrame()->GetDocument(), + "first_password" /* new_passwod_id */, nullptr /* confirm_password_id*/); constexpr char kGenerationElementId[] = "first_password"; @@ -1362,11 +1121,11 @@ TEST_F(PasswordGenerationAgentTest, ShortPasswordMaskedAfterChangingFocus) { LoadHTMLWithUserGesture(kPasswordFormAndSpanHTML); - SetNotBlacklistedMessage(password_generation_, kPasswordFormAndSpanHTML); - SetAccountCreationFormsDetectedMessage( - GenerationAvailableForFormStatus::kAvailable); - constexpr char kGenerationElementId[] = "password"; + SetFoundFormEligibleForGeneration(password_generation_, + GetMainFrame()->GetDocument(), + kGenerationElementId /* new_passwod_id */, + nullptr /* confirm_password_id*/); // Generate a new password. ExpectAutomaticGenerationAvailable(kGenerationElementId, kAvailable); @@ -1431,7 +1190,7 @@ // Simulate that the browser informs about eligible for generation form. // Check that generation is available only on new password field of this form. - NewPasswordFormGenerationData generation_data; + PasswordFormGenerationData generation_data; generation_data.new_password_renderer_id = password_elements[0].UniqueRendererFormControlId();
diff --git a/chrome/renderer/autofill/password_generation_test_utils.cc b/chrome/renderer/autofill/password_generation_test_utils.cc index 8348992a..17034b1 100644 --- a/chrome/renderer/autofill/password_generation_test_utils.cc +++ b/chrome/renderer/autofill/password_generation_test_utils.cc
@@ -7,14 +7,22 @@ #include <base/strings/utf_string_conversions.h> #include "base/strings/stringprintf.h" #include "components/autofill/content/renderer/form_autofill_util.h" -#include "components/autofill/content/renderer/test_password_generation_agent.h" +#include "components/autofill/content/renderer/password_generation_agent.h" #include "components/autofill/core/common/password_form_generation_data.h" #include "components/autofill/core/common/signatures_util.h" #include "net/base/escape.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/web/web_document.h" #include "third_party/blink/public/web/web_form_element.h" +using blink::WebDocument; +using blink::WebElement; +using blink::WebFormControlElement; +using blink::WebFormElement; +using blink::WebString; +using blink::WebVector; + namespace autofill { namespace { @@ -22,57 +30,29 @@ // Events that should be triggered when Chrome fills a field. const char* const kEvents[] = {"focus", "keydown", "input", "change", "keyup", "blur"}; + +// Returns renderer id of WebInput element with id attribute |input_id|. +uint32_t GetRendererId(WebDocument document, const char* input_id) { + WebElement element = document.GetElementById(WebString::FromUTF8(input_id)); + auto* input = ToWebInputElement(&element); + return input->UniqueRendererFormControlId(); +} + } // namespace -void SetNotBlacklistedMessage(TestPasswordGenerationAgent* generation_agent, - const char* form_str) { - std::string escaped_form = net::EscapeQueryParamValue(form_str, false); - autofill::PasswordForm form; - form.origin = form_util::StripAuthAndParams(GURL(base::StringPrintf( - "data:text/html;charset=utf-8,%s", escaped_form.c_str()))); - generation_agent->FormNotBlacklisted(form); -} +void SetFoundFormEligibleForGeneration( + PasswordGenerationAgent* generation_agent, + WebDocument document, + const char* new_password_id, + const char* cofirm_password_id) { + PasswordFormGenerationData data; + data.new_password_renderer_id = GetRendererId(document, new_password_id); + if (cofirm_password_id) { + data.confirmation_password_renderer_id = + GetRendererId(document, cofirm_password_id); + } -// Sends a message that the |form_index| form on the page is valid for -// account creation. -void SetAccountCreationFormsDetectedMessage( - TestPasswordGenerationAgent* generation_agent, - blink::WebDocument document, - int form_index, - int field_index) { - blink::WebVector<blink::WebFormElement> web_forms; - document.Forms(web_forms); - - autofill::FormData form_data; - WebFormElementToFormData( - web_forms[form_index], blink::WebFormControlElement(), nullptr, - form_util::EXTRACT_NONE, &form_data, nullptr /* FormFieldData */); - - std::vector<autofill::PasswordFormGenerationData> forms; - forms.push_back(autofill::PasswordFormGenerationData{ - CalculateFormSignature(form_data), - CalculateFieldSignatureForField(form_data.fields[field_index])}); - generation_agent->FoundFormsEligibleForGeneration(forms); -} - -// Sends a message that the form of unowned <inputs>s on the page is valid for -// account creation. -void SetAccountCreationFormsDetectedMessageForUnownedInputs( - TestPasswordGenerationAgent* generation_agent, - blink::WebDocument document) { - std::vector<blink::WebElement> fieldsets; - std::vector<blink::WebFormControlElement> control_elements = - form_util::GetUnownedFormFieldElements(document.All(), &fieldsets); - autofill::FormData form_data; - UnownedPasswordFormElementsAndFieldSetsToFormData( - fieldsets, control_elements, nullptr, document, - nullptr /* field_value_and_properties_map */, form_util::EXTRACT_NONE, - &form_data, nullptr /* FormFieldData */); - std::vector<autofill::PasswordFormGenerationData> forms; - forms.push_back(autofill::PasswordFormGenerationData{ - CalculateFormSignature(form_data), - CalculateFieldSignatureForField(form_data.fields[1])}); - generation_agent->FoundFormsEligibleForGeneration(forms); + generation_agent->FoundFormEligibleForGeneration(data); } // Creates script that registers event listeners for |element_name| field. To
diff --git a/chrome/renderer/autofill/password_generation_test_utils.h b/chrome/renderer/autofill/password_generation_test_utils.h index 68b4f077..06907a5 100644 --- a/chrome/renderer/autofill/password_generation_test_utils.h +++ b/chrome/renderer/autofill/password_generation_test_utils.h
@@ -16,18 +16,15 @@ namespace autofill { -class TestPasswordGenerationAgent; +class PasswordGenerationAgent; -void SetNotBlacklistedMessage(TestPasswordGenerationAgent* generation_agent, - const char* form_str); -void SetAccountCreationFormsDetectedMessage(TestPasswordGenerationAgent* agent, - blink::WebDocument document, - int form_index, - int field_index); - -void SetAccountCreationFormsDetectedMessageForUnownedInputs( - TestPasswordGenerationAgent* generation_agent, - blink::WebDocument document); +// Sets that automatic generation available with |generation_agent| for fields +// |new_password_id| and |cofirm_password_id| which are in document |document|. +void SetFoundFormEligibleForGeneration( + PasswordGenerationAgent* generation_agent, + blink::WebDocument document, + const char* new_password_id, + const char* cofirm_password_id); std::string CreateScriptToRegisterListeners( const char* const element_name,
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index f3e2a09a6..954961b 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2909,7 +2909,6 @@ "../browser/page_load_metrics/resource_tracker_unittest.cc", "../browser/password_manager/chrome_password_manager_client_unittest.cc", "../browser/password_manager/password_manager_internals_service_unittest.cc", - "../browser/password_manager/password_store_mac_unittest.cc", "../browser/password_manager/password_store_x_unittest.cc", "../browser/payments/payment_handler_permission_context_unittest.cc", "../browser/performance_manager/decorators/frozen_frame_aggregator_unittest.cc", @@ -3918,6 +3917,7 @@ "../browser/ui/ash/network/network_state_notifier_unittest.cc", "../browser/ui/ash/network/tether_notification_presenter_unittest.cc", "../browser/ui/ash/session_controller_client_impl_unittest.cc", + "../browser/ui/ash/tablet_mode_client_unittest.cc", "../browser/ui/ash/wallpaper_controller_client_unittest.cc", "../browser/ui/window_sizer/window_sizer_ash_unittest.cc", ]
diff --git a/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java b/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java index feb36ee..e598bf6 100644 --- a/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java +++ b/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsActivity.java
@@ -19,6 +19,7 @@ import org.chromium.chrome.browser.init.ChromeBrowserInitializer; import org.chromium.chrome.browser.init.EmptyBrowserParts; import org.chromium.content_public.browser.BrowserStartupController; +import org.chromium.native_test.NativeBrowserTest; import org.chromium.native_test.NativeBrowserTestActivity; import java.io.File; @@ -105,6 +106,11 @@ assert false; } + @Override + public void setContentMainCallbackForTests(Runnable completionCallback) { + assert false; + } + private boolean mStartupCompleted; }; ChromeBrowserInitializer.setBrowserStartupControllerForTesting(startupController); @@ -119,6 +125,10 @@ wind.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); wind.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); wind.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + + // TODO(danakj): Make startup async and inherit from ChromeTabbedActivity. + NativeBrowserTest.javaStartupTasksComplete(); + runTests(); } @Override
diff --git a/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java b/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java index 31265cf..72c60fc 100644 --- a/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java +++ b/chrome/test/android/browsertests_apk/src/org/chromium/android_browsertests_apk/ChromeBrowserTestsApplication.java
@@ -6,7 +6,6 @@ import android.content.Context; -import org.chromium.base.ApplicationStatus; import org.chromium.base.PathUtils; import org.chromium.chrome.browser.GlobalDiscardableReferencePool; import org.chromium.chrome.browser.metrics.UmaUtils; @@ -35,8 +34,6 @@ super.attachBaseContext(base); if (isBrowserProcess) { - ApplicationStatus.initialize(this); - // Test-only stuff, see also NativeUnitTest.java. PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); }
diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc index 993ee27..f8af975 100644 --- a/chrome/test/base/chrome_render_view_test.cc +++ b/chrome/test/base/chrome_render_view_test.cc
@@ -13,8 +13,8 @@ #include "chrome/test/base/chrome_unit_test_suite.h" #include "components/autofill/content/renderer/autofill_agent.h" #include "components/autofill/content/renderer/password_autofill_agent.h" +#include "components/autofill/content/renderer/password_generation_agent.h" #include "components/autofill/content/renderer/test_password_autofill_agent.h" -#include "components/autofill/content/renderer/test_password_generation_agent.h" #include "components/spellcheck/renderer/spellcheck.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "content/public/browser/native_web_keyboard_event.h" @@ -124,7 +124,7 @@ // create another set. password_autofill_agent_ = new autofill::TestPasswordAutofillAgent( view_->GetMainRenderFrame(), &associated_interfaces_); - password_generation_ = new autofill::TestPasswordGenerationAgent( + password_generation_ = new autofill::PasswordGenerationAgent( view_->GetMainRenderFrame(), password_autofill_agent_, &associated_interfaces_); autofill_agent_ = new NiceMock<MockAutofillAgent>(
diff --git a/chrome/test/base/chrome_render_view_test.h b/chrome/test/base/chrome_render_view_test.h index 04f6350..c997b5dd 100644 --- a/chrome/test/base/chrome_render_view_test.h +++ b/chrome/test/base/chrome_render_view_test.h
@@ -18,7 +18,7 @@ namespace autofill { class AutofillAgent; class TestPasswordAutofillAgent; -class TestPasswordGenerationAgent; +class PasswordGenerationAgent; } class ChromeRenderViewTest : public content::RenderViewTest { @@ -46,7 +46,7 @@ void WaitForAutofillDidAssociateFormControl(); autofill::TestPasswordAutofillAgent* password_autofill_agent_; - autofill::TestPasswordGenerationAgent* password_generation_; + autofill::PasswordGenerationAgent* password_generation_; autofill::AutofillAgent* autofill_agent_; std::unique_ptr<service_manager::BinderRegistry> registry_;
diff --git a/chrome/test/base/test_launcher_utils.cc b/chrome/test/base/test_launcher_utils.cc index a1abde2..f64744a 100644 --- a/chrome/test/base/test_launcher_utils.cc +++ b/chrome/test/base/test_launcher_utils.cc
@@ -75,11 +75,6 @@ // This is a Browser test. command_line->AppendSwitchASCII(switches::kTestType, "browser"); - // Some browser tests produce pixel results and compare them. Use an sRGB - // color profile to ensure that the machine's color profile does not affect - // the results. - command_line->AppendSwitchASCII(switches::kForceDisplayColorProfile, "srgb"); - if (open_about_blank_on_launch && command_line->GetArgs().empty()) command_line->AppendArg(url::kAboutBlankURL); }
diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc index 5f0fa51d..1abfca51 100644 --- a/chromecast/browser/cast_browser_main_parts.cc +++ b/chromecast/browser/cast_browser_main_parts.cc
@@ -62,6 +62,7 @@ #include "content/public/browser/storage_partition.h" #include "content/public/browser/system_connector.h" #include "content/public/common/content_switches.h" +#include "content/public/common/main_function_params.h" #include "gpu/command_buffer/service/gpu_switches.h" #include "media/base/media.h" #include "media/base/media_switches.h" @@ -622,6 +623,12 @@ cast_content_browser_client_->CreateGeneralAudienceBrowsingService(); cast_browser_process_->cast_service()->Start(); + + if (parameters_.ui_task) { + parameters_.ui_task->Run(); + delete parameters_.ui_task; + run_message_loop_ = false; + } } #if defined(OS_ANDROID) @@ -648,24 +655,18 @@ NOTREACHED(); return true; #else - base::RunLoop run_loop; - base::Closure quit_closure(run_loop.QuitClosure()); + if (run_message_loop_) { + base::RunLoop run_loop; + base::Closure quit_closure(run_loop.QuitClosure()); #if !defined(OS_FUCHSIA) - // Fuchsia doesn't have signals. - RegisterClosureOnSignal(quit_closure); + // Fuchsia doesn't have signals. + RegisterClosureOnSignal(quit_closure); #endif // !defined(OS_FUCHSIA) - // If parameters_.ui_task is not NULL, we are running browser tests. - if (parameters_.ui_task) { - base::MessageLoopCurrent message_loop = - base::MessageLoopCurrentForUI::Get(); - message_loop->task_runner()->PostTask(FROM_HERE, *parameters_.ui_task); - message_loop->task_runner()->PostTask(FROM_HERE, quit_closure); + run_loop.Run(); } - run_loop.Run(); - #if !defined(OS_FUCHSIA) // Once the main loop has stopped running, we give the browser process a few // seconds to stop cast service and finalize all resources. If a hang occurs
diff --git a/chromecast/browser/cast_browser_main_parts.h b/chromecast/browser/cast_browser_main_parts.h index ba5009c..650a1c4 100644 --- a/chromecast/browser/cast_browser_main_parts.h +++ b/chromecast/browser/cast_browser_main_parts.h
@@ -14,7 +14,6 @@ #include "chromecast/chromecast_buildflags.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_main_parts.h" -#include "content/public/common/main_function_params.h" #if defined(OS_ANDROID) #include "base/timer/timer.h" @@ -22,6 +21,10 @@ class PrefService; +namespace content { +struct MainFunctionParams; +} + namespace extensions { class ExtensionsClient; class ExtensionsBrowserClient; @@ -92,7 +95,7 @@ private: std::unique_ptr<CastBrowserProcess> cast_browser_process_; - const content::MainFunctionParams parameters_; // For running browser tests. + const content::MainFunctionParams& parameters_; // For running browser tests. // Caches a pointer of the CastContentBrowserClient. CastContentBrowserClient* const cast_content_browser_client_ = nullptr; URLRequestContextFactory* const url_request_context_factory_; @@ -134,6 +137,8 @@ std::unique_ptr<WaylandServerController> wayland_server_controller_; #endif + bool run_message_loop_ = true; + DISALLOW_COPY_AND_ASSIGN(CastBrowserMainParts); };
diff --git a/components/BUILD.gn b/components/BUILD.gn index 1e3f6d6..7478218 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn
@@ -357,10 +357,15 @@ if (enable_print_preview) { deps += [ "//components/pwg_encoder:unit_tests" ] } - if (safe_browsing_mode == 1 || safe_browsing_mode == 3) { - deps += [ "//components/safe_browsing/db:unit_tests_desktop" ] + if (safe_browsing_mode == 1) { + deps += [ + "//components/safe_browsing:verdict_cache_manager_unittest", + "//components/safe_browsing/db:unit_tests_desktop", + ] } else if (safe_browsing_mode == 2) { deps += [ "//components/safe_browsing/android:unit_tests_mobile" ] + } else if (safe_browsing_mode == 3) { + deps += [ "//components/safe_browsing/db:unit_tests_desktop" ] } if (!is_ios) {
diff --git a/components/autofill/content/common/autofill_agent.mojom b/components/autofill/content/common/autofill_agent.mojom index 6912ff39..2081278 100644 --- a/components/autofill/content/common/autofill_agent.mojom +++ b/components/autofill/content/common/autofill_agent.mojom
@@ -115,17 +115,7 @@ // non-empty PasswordGenerationUIData. UserTriggeredGeneratePassword() => (PasswordGenerationUIData? data); - // Tells the renderer that this password form is not blacklisted. A form can - // be blacklisted if a user chooses "never save passwords for this site". - FormNotBlacklisted(PasswordForm form); - - // Sent when Autofill manager gets the query response from the Autofill server - // and there are fields classified for password generation in the response. - // TODO(https://crbug.com/866444): Remove this when PasswordGenerationAgent - // refactoring is finished. - FoundFormsEligibleForGeneration(array<PasswordFormGenerationData> forms); - // Tells the renderer that a password can be generated on the fields // identified by |form|. - FoundFormEligibleForGeneration(NewPasswordFormGenerationData form); + FoundFormEligibleForGeneration(PasswordFormGenerationData form); };
diff --git a/components/autofill/content/renderer/BUILD.gn b/components/autofill/content/renderer/BUILD.gn index e71d0e4..5031108 100644 --- a/components/autofill/content/renderer/BUILD.gn +++ b/components/autofill/content/renderer/BUILD.gn
@@ -66,8 +66,6 @@ sources = [ "test_password_autofill_agent.cc", "test_password_autofill_agent.h", - "test_password_generation_agent.cc", - "test_password_generation_agent.h", ] public_deps = [
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index 4811ce08..5bb8668 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -849,8 +849,6 @@ // whole page doesn't have to be loaded. ProcessForms(); password_autofill_agent_->OnDynamicFormsSeen(); - if (password_generation_agent_) - password_generation_agent_->OnDynamicFormsSeen(); } void AutofillAgent::DidCompleteFocusChangeInFrame() {
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index 7ceb573..e3773b50 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc
@@ -1544,6 +1544,13 @@ } auto element = node.ToConst<WebElement>(); + if (element.IsFormControlElement() && + form_util::IsTextAreaElement(element.ToConst<WebFormControlElement>())) { + focus_state_notifier_.FocusedInputChanged( + FocusedFieldType::kFillableTextArea); + return; + } + auto* input_element = ToWebInputElement(&element); if (!input_element) { focus_state_notifier_.FocusedInputChanged( @@ -1555,12 +1562,15 @@ if (input_element->IsTextField() && IsElementEditable(*input_element)) { focused_input_element_ = *input_element; - if (input_element->IsPasswordFieldForAutofill()) + WebString type = input_element->GetAttribute("type"); + if (!type.IsNull() && type == "search") + focused_field_type = FocusedFieldType::kFillableSearchField; + else if (input_element->IsPasswordFieldForAutofill()) focused_field_type = FocusedFieldType::kFillablePasswordField; else if (base::Contains(web_input_to_password_info_, *input_element)) focused_field_type = FocusedFieldType::kFillableUsernameField; else - focused_field_type = FocusedFieldType::kFillableTextField; + focused_field_type = FocusedFieldType::kFillableNonSearchField; } focus_state_notifier_.FocusedInputChanged(focused_field_type);
diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc index 6d034d8..314b059f 100644 --- a/components/autofill/content/renderer/password_generation_agent.cc +++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -50,41 +50,6 @@ using autofill::form_util::GetTextDirectionForElement; using Logger = autofill::SavePasswordProgressLogger; -// Returns pairs of |PasswordForm| and corresponding |WebFormElement| for all -// <form>s in the frame and for unowned <input>s. The method doesn't filter out -// invalid |PasswordForm|s. -std::vector<std::pair<std::unique_ptr<PasswordForm>, WebFormElement>> -GetAllPasswordFormsInFrame(PasswordAutofillAgent* password_agent, - WebLocalFrame* web_frame) { - blink::WebVector<WebFormElement> web_forms; - web_frame->GetDocument().Forms(web_forms); - std::vector<std::pair<std::unique_ptr<PasswordForm>, WebFormElement>> - all_forms; - for (const WebFormElement& web_form : web_forms) { - all_forms.emplace_back(std::make_pair( - password_agent->GetPasswordFormFromWebForm(web_form), web_form)); - } - all_forms.emplace_back( - std::make_pair(password_agent->GetPasswordFormFromUnownedInputElements(), - WebFormElement())); - return all_forms; -} - -// Returns true if we think that this form is for account creation. Password -// field(s) of the form are pushed back to |passwords|. -bool GetAccountCreationPasswordFields( - const std::vector<WebFormControlElement>& control_elements, - std::vector<WebInputElement>* passwords) { - for (const auto& control_element : control_elements) { - const WebInputElement* input_element = ToWebInputElement(&control_element); - if (input_element && input_element->IsTextField() && - input_element->IsPasswordFieldForAutofill()) { - passwords->push_back(*input_element); - } - } - return !passwords->empty(); -} - // Returns the renderer id of the next password field in |control_elements| // after |new_password|. This field is likely to be the confirmation field. // Returns FormFieldData::kNotSetFormControlRendererId if there is no such @@ -107,81 +72,6 @@ return FormFieldData::kNotSetFormControlRendererId; } -bool ContainsURL(const std::vector<GURL>& urls, const GURL& url) { - return base::Contains(urls, url); -} - -// Calculates the signature of |form| and searches it in |forms|. -const PasswordFormGenerationData* FindFormGenerationData( - const std::vector<PasswordFormGenerationData>& forms, - const PasswordForm& form) { - FormSignature form_signature = CalculateFormSignature(form.form_data); - for (const auto& form_it : forms) { - if (form_it.form_signature == form_signature) - return &form_it; - } - return nullptr; -} - -// Returns a vector of up to 2 password fields with autocomplete attribute set -// to "new-password". These will be filled with the generated password. -std::vector<WebInputElement> FindNewPasswordElementsMarkedBySite( - const std::vector<WebInputElement>& all_password_elements) { - std::vector<WebInputElement> passwords; - - auto is_new_password_field = [](const WebInputElement& element) { - return AutocompleteFlagForElement(element) == - AutocompleteFlag::NEW_PASSWORD; - }; - - auto field_iter = - std::find_if(all_password_elements.begin(), all_password_elements.end(), - is_new_password_field); - if (field_iter != all_password_elements.end()) { - passwords.push_back(*field_iter++); - field_iter = std::find_if(field_iter, all_password_elements.end(), - is_new_password_field); - if (field_iter != all_password_elements.end()) - passwords.push_back(*field_iter); - } - - return passwords; -} - -// Returns a vector of up to 2 password fields into which Chrome should fill the -// generated password. It assumes that |field_signature| describes the field -// where Chrome shows the password generation prompt. -std::vector<WebInputElement> FindPasswordElementsForGeneration( - const std::vector<WebInputElement>& all_password_elements, - const PasswordFormGenerationData& generation_data) { - auto generation_field_iter = all_password_elements.end(); - auto confirmation_field_iter = all_password_elements.end(); - for (auto iter = all_password_elements.begin(); - iter != all_password_elements.end(); ++iter) { - const WebInputElement& input = *iter; - FieldSignature signature = CalculateFieldSignatureByNameAndType( - input.NameForAutofill().Utf16(), - input.FormControlTypeForAutofill().Utf8()); - if (signature == generation_data.field_signature) { - generation_field_iter = iter; - } else if (generation_data.confirmation_field_signature && - signature == *generation_data.confirmation_field_signature) { - confirmation_field_iter = iter; - } - } - - std::vector<WebInputElement> passwords; - if (generation_field_iter != all_password_elements.end()) { - passwords.push_back(*generation_field_iter); - - if (confirmation_field_iter == all_password_elements.end()) - confirmation_field_iter = generation_field_iter + 1; - if (confirmation_field_iter != all_password_elements.end()) - passwords.push_back(*confirmation_field_iter); - } - return passwords; -} - void CopyElementValueToOtherInputElements( const WebInputElement* element, std::vector<WebInputElement>* elements) { @@ -195,32 +85,10 @@ } // namespace -// Contains information about a form for which generation is possible. -struct PasswordGenerationAgent::AccountCreationFormData { - PasswordForm form; - std::vector<blink::WebInputElement> password_elements; - - AccountCreationFormData(PasswordForm password_form, - std::vector<blink::WebInputElement> passwords) - : form(std::move(password_form)), - password_elements(std::move(passwords)) {} - AccountCreationFormData(AccountCreationFormData&& rhs) = default; - - ~AccountCreationFormData() = default; - - DISALLOW_COPY_AND_ASSIGN(AccountCreationFormData); -}; - // Contains information about generation status for an element for the // lifetime of the possible interaction. struct PasswordGenerationAgent::GenerationItemInfo { - GenerationItemInfo(const AccountCreationFormData& creation_form_data, - const blink::WebInputElement& generation_element) - : generation_element_(generation_element) { - form_ = creation_form_data.form; - password_elements_ = creation_form_data.password_elements; - } - GenerationItemInfo(blink::WebInputElement generation_element, + GenerationItemInfo(WebInputElement generation_element, PasswordForm form, std::vector<blink::WebInputElement> password_elements) : generation_element_(std::move(generation_element)), @@ -301,15 +169,6 @@ return; // Update stats for main frame navigation. if (!render_frame()->GetWebFrame()->Parent()) { - // Log statistics after navigation so that we only log once per page. - if (automatic_generation_form_data_ && - !automatic_generation_form_data_->password_elements.empty()) { - password_generation::LogPasswordGenerationEvent( - password_generation::SIGN_UP_DETECTED); - } else { - password_generation::LogPasswordGenerationEvent( - password_generation::NO_SIGN_UP_DETECTED); - } if (current_generation_item_) { if (current_generation_item_->password_edited_) { password_generation::LogPasswordGenerationEvent( @@ -325,10 +184,6 @@ } } } - possible_account_creation_forms_.clear(); - not_blacklisted_password_form_origins_.clear(); - generation_enabled_forms_.clear(); - automatic_generation_form_data_.reset(); automatic_generation_element_.Reset(); current_generation_item_.reset(); last_focused_password_element_.Reset(); @@ -341,26 +196,11 @@ GetPasswordGenerationDriver()->FrameWasScrolled(); } -void PasswordGenerationAgent::DidFinishDocumentLoad() { - FindPossibleGenerationForm(); -} - -void PasswordGenerationAgent::DidFinishLoad() { - // Since forms on some sites are available only at this event (but not at - // DidFinishDocumentLoad), again call FindPossibleGenerationForm to detect - // these forms (crbug.com/617893). - FindPossibleGenerationForm(); -} - void PasswordGenerationAgent::OnDestruct() { binding_.Close(); base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); } -void PasswordGenerationAgent::OnDynamicFormsSeen() { - FindPossibleGenerationForm(); -} - void PasswordGenerationAgent::OnFieldAutofilled( const WebInputElement& password_element) { if (current_generation_item_ && @@ -379,75 +219,6 @@ current_generation_item_->updating_other_password_fileds_; } -void PasswordGenerationAgent::FindPossibleGenerationForm() { - if (!enabled_ || !render_frame()) - return; - - // We don't want to generate passwords if the browser won't store or sync - // them. - if (!ShouldAnalyzeDocument()) - return; - - // If we have already found a signup form for this page, no need to continue. - if (automatic_generation_form_data_) - return; - - WebLocalFrame* web_frame = render_frame()->GetWebFrame(); - std::vector<std::pair<std::unique_ptr<PasswordForm>, WebFormElement>> - all_password_forms = - GetAllPasswordFormsInFrame(password_agent_, web_frame); - for (auto& form : all_password_forms) { - PasswordForm* password_form = form.first.get(); - // If we can't get a valid PasswordForm, we skip this form because the - // the password won't get saved even if we generate it. - if (!password_form) { - LogMessage(Logger::STRING_GENERATION_RENDERER_INVALID_PASSWORD_FORM); - continue; - } - - // Do not generate password for GAIA since it is used to retrieve the - // generated paswords. - GURL realm(password_form->signon_realm); - if (realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) - continue; - - std::vector<WebInputElement> passwords; - const WebFormElement& web_form = form.second; - if (GetAccountCreationPasswordFields( - web_form.IsNull() - ? form_util::GetUnownedFormFieldElements( - web_frame->GetDocument().All(), nullptr) - : form_util::ExtractAutofillableElementsInForm(web_form), - &passwords)) { - possible_account_creation_forms_.emplace_back(std::move(*form.first), - std::move(passwords)); - } - } - - if (!possible_account_creation_forms_.empty()) { - LogNumber( - Logger::STRING_GENERATION_RENDERER_POSSIBLE_ACCOUNT_CREATION_FORMS, - possible_account_creation_forms_.size()); - DetermineGenerationElement(); - } -} - -bool PasswordGenerationAgent::ShouldAnalyzeDocument() { - // Make sure that this frame is allowed to use password manager. Generating a - // password that can't be saved is a bad idea. - if (!render_frame() || !password_agent_->FrameCanAccessPasswordManager()) { - LogMessage(Logger::STRING_GENERATION_RENDERER_NO_PASSWORD_MANAGER_ACCESS); - return false; - } - - return true; -} - -void PasswordGenerationAgent::FormNotBlacklisted(const PasswordForm& form) { - not_blacklisted_password_form_origins_.push_back(form.origin); - DetermineGenerationElement(); -} - void PasswordGenerationAgent::GeneratedPasswordAccepted( const base::string16& password) { // static cast is workaround for linker error. @@ -512,15 +283,8 @@ return password_form; } -void PasswordGenerationAgent::FoundFormsEligibleForGeneration( - const std::vector<PasswordFormGenerationData>& forms) { - generation_enabled_forms_.insert(generation_enabled_forms_.end(), - forms.begin(), forms.end()); - DetermineGenerationElement(); -} - void PasswordGenerationAgent::FoundFormEligibleForGeneration( - const NewPasswordFormGenerationData& form) { + const PasswordFormGenerationData& form) { generation_enabled_fields_[form.new_password_renderer_id] = form; if (mark_generation_element_) { @@ -561,80 +325,6 @@ } } -void PasswordGenerationAgent::DetermineGenerationElement() { - if (automatic_generation_form_data_) { - LogMessage(Logger::STRING_GENERATION_RENDERER_FORM_ALREADY_FOUND); - return; - } - - // Make sure local heuristics have identified a possible account creation - // form. - if (possible_account_creation_forms_.empty()) { - LogMessage(Logger::STRING_GENERATION_RENDERER_NO_POSSIBLE_CREATION_FORMS); - return; - } - - // Note that no messages will be sent if this feature is disabled - // (e.g. password saving is disabled). - for (auto& possible_form_data : possible_account_creation_forms_) { - PasswordForm* possible_password_form = &possible_form_data.form; - std::vector<WebInputElement> password_elements; - if (!ContainsURL(not_blacklisted_password_form_origins_, - possible_password_form->origin)) { - LogMessage(Logger::STRING_GENERATION_RENDERER_NOT_BLACKLISTED); - continue; - } else { - const PasswordFormGenerationData* generation_data = - FindFormGenerationData(generation_enabled_forms_, - *possible_password_form); - if (generation_data) { - password_elements = FindPasswordElementsForGeneration( - possible_form_data.password_elements, *generation_data); - } else { - if (!possible_password_form->new_password_marked_by_site) { - LogMessage(Logger::STRING_GENERATION_RENDERER_NO_SERVER_SIGNAL); - continue; - } - - LogMessage(Logger::STRING_GENERATION_RENDERER_AUTOCOMPLETE_ATTRIBUTE); - password_generation::LogPasswordGenerationEvent( - password_generation::AUTOCOMPLETE_ATTRIBUTES_ENABLED_GENERATION); - - password_elements = FindNewPasswordElementsMarkedBySite( - possible_form_data.password_elements); - } - } - - LogMessage(Logger::STRING_GENERATION_RENDERER_ELIGIBLE_FORM_FOUND); - if (password_elements.empty()) { - // It might be if JavaScript changes field names. - LogMessage(Logger::STRING_GENERATION_RENDERER_NO_FIELD_FOUND); - return; - } - - automatic_generation_form_data_.reset(new AccountCreationFormData( - possible_form_data.form, std::move(password_elements))); - automatic_generation_element_ = - automatic_generation_form_data_->password_elements[0]; - if (mark_generation_element_) - automatic_generation_element_.SetAttribute("password_creation_field", - "1"); - automatic_generation_element_.SetAttribute("aria-autocomplete", "list"); - password_generation::LogPasswordGenerationEvent( - password_generation::GENERATION_AVAILABLE); - possible_account_creation_forms_.clear(); - if (!current_generation_item_) { - // If the manual generation hasn't started, set - // |automatic_generation_element_| as the current generation field. - current_generation_item_.reset(new GenerationItemInfo( - *automatic_generation_form_data_, automatic_generation_element_)); - } - GetPasswordGenerationDriver()->GenerationAvailableForForm( - automatic_generation_form_data_->form); - return; - } -} - bool PasswordGenerationAgent::SetUpUserTriggeredGeneration() { if (last_focused_password_element_.IsNull() || !render_frame()) return false;
diff --git a/components/autofill/content/renderer/password_generation_agent.h b/components/autofill/content/renderer/password_generation_agent.h index 791ae2e..22427d8c 100644 --- a/components/autofill/content/renderer/password_generation_agent.h +++ b/components/autofill/content/renderer/password_generation_agent.h
@@ -25,7 +25,6 @@ namespace autofill { struct PasswordForm; -struct PasswordFormGenerationData; class PasswordAutofillAgent; // This class is responsible for controlling communication for password @@ -51,12 +50,9 @@ void BindRequest(mojom::PasswordGenerationAgentAssociatedRequest request); // mojom::PasswordGenerationAgent: - void FormNotBlacklisted(const PasswordForm& form) override; void GeneratedPasswordAccepted(const base::string16& password) override; - void FoundFormsEligibleForGeneration( - const std::vector<PasswordFormGenerationData>& forms) override; void FoundFormEligibleForGeneration( - const NewPasswordFormGenerationData& form) override; + const PasswordFormGenerationData& form) override; // Sets |generation_element_| to the focused password field and responds back // if the generation was triggered successfully. void UserTriggeredGeneratePassword( @@ -76,9 +72,6 @@ // being called. void DidEndTextFieldEditing(const blink::WebInputElement& element); - // Called when new form controls are inserted. - void OnDynamicFormsSeen(); - // Called right before PasswordAutofillAgent filled |password_element|. void OnFieldAutofilled(const blink::WebInputElement& password_element); @@ -95,28 +88,18 @@ #endif protected: - // Returns true if the document for |render_frame()| is one that we should - // consider analyzing. Virtual so that it can be overriden during testing. - virtual bool ShouldAnalyzeDocument(); - // Use to force enable during testing. void set_enabled(bool enabled) { enabled_ = enabled; } private: - // Contains information about a form for which generation is possible. - struct AccountCreationFormData; // Contains information about generation status for an element for the // lifetime of the possible interaction. struct GenerationItemInfo; - typedef std::vector<AccountCreationFormData> AccountCreationFormDataList; - // RenderFrameObserver: void DidCommitProvisionalLoad(bool is_same_document_navigation, ui::PageTransition transition) override; void DidChangeScrollOffset() override; - void DidFinishDocumentLoad() override; - void DidFinishLoad() override; void OnDestruct() override; const mojom::PasswordManagerDriverAssociatedPtr& GetPasswordManagerDriver(); @@ -124,16 +107,6 @@ const mojom::PasswordGenerationDriverAssociatedPtr& GetPasswordGenerationDriver(); - // Helper function that will try and populate |password_elements_| and - // |possible_account_creation_form_|. - void FindPossibleGenerationForm(); - - // Helper function to decide if |possible_account_creation_forms_| contains - // password fields for an account creation form. Sets - // |automatic_generation_element_| to the field that we want to trigger the - // generation UI on. - void DetermineGenerationElement(); - // Helper function which takes care of the form processing and collecting the // information which is required to show the generation popup. Returns true if // all required information is collected. @@ -185,22 +158,6 @@ // If a form creating is failed, returns an empty unique_ptr. std::unique_ptr<PasswordForm> CreatePasswordFormToPresave(); - // Stores forms that are candidates for account creation. - AccountCreationFormDataList possible_account_creation_forms_; - - // Stores the origins of the password forms confirmed not to be blacklisted - // by the browser. A form can be blacklisted if a user chooses "never save - // passwords for this site". - std::vector<GURL> not_blacklisted_password_form_origins_; - - // Stores each password form for which the Autofill server classifies one of - // the form's fields as an ACCOUNT_CREATION_PASSWORD or NEW_PASSWORD. These - // forms will not be sent if the feature is disabled. - std::vector<autofill::PasswordFormGenerationData> generation_enabled_forms_; - - // Data for form which automatic generation is allowed on. - std::unique_ptr<AccountCreationFormData> automatic_generation_form_data_; - // Element where we want to trigger automatic password generation UI on. blink::WebInputElement automatic_generation_element_; @@ -215,7 +172,7 @@ // Contains correspondence between generaiton enabled element and data for // generation. - std::map<uint32_t, NewPasswordFormGenerationData> generation_enabled_fields_; + std::map<uint32_t, PasswordFormGenerationData> generation_enabled_fields_; // If this feature is enabled. Controlled by Finch. bool enabled_;
diff --git a/components/autofill/content/renderer/test_password_generation_agent.cc b/components/autofill/content/renderer/test_password_generation_agent.cc deleted file mode 100644 index 14b5017..0000000 --- a/components/autofill/content/renderer/test_password_generation_agent.cc +++ /dev/null
@@ -1,24 +0,0 @@ -// 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/autofill/content/renderer/test_password_generation_agent.h" - -namespace autofill { - -TestPasswordGenerationAgent::TestPasswordGenerationAgent( - content::RenderFrame* render_frame, - PasswordAutofillAgent* password_agent, - blink::AssociatedInterfaceRegistry* registry) - : PasswordGenerationAgent(render_frame, password_agent, registry) { - // Always enable when testing. - set_enabled(true); -} - -TestPasswordGenerationAgent::~TestPasswordGenerationAgent() {} - -bool TestPasswordGenerationAgent::ShouldAnalyzeDocument() { - return true; -} - -} // namespace autofill
diff --git a/components/autofill/content/renderer/test_password_generation_agent.h b/components/autofill/content/renderer/test_password_generation_agent.h deleted file mode 100644 index 5ae0e0c..0000000 --- a/components/autofill/content/renderer/test_password_generation_agent.h +++ /dev/null
@@ -1,33 +0,0 @@ -// 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_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_GENERATION_AGENT_H_ -#define COMPONENTS_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_GENERATION_AGENT_H_ - -#include <vector> - -#include "base/macros.h" -#include "components/autofill/content/renderer/password_generation_agent.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" - -namespace autofill { - -class TestPasswordGenerationAgent : public PasswordGenerationAgent { - public: - TestPasswordGenerationAgent(content::RenderFrame* render_frame, - PasswordAutofillAgent* password_agent, - blink::AssociatedInterfaceRegistry* registry); - ~TestPasswordGenerationAgent() override; - - // PasswordGenreationAgent implementation: - // Always return true to allow loading of data URLs. - bool ShouldAnalyzeDocument() override; - - private: - DISALLOW_COPY_AND_ASSIGN(TestPasswordGenerationAgent); -}; - -} // namespace autofill - -#endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_TEST_PASSWORD_AUTOFILL_AGENT_H_
diff --git a/components/autofill/core/common/autofill_util.cc b/components/autofill/core/common/autofill_util.cc index 3da190d5..e735f67 100644 --- a/components/autofill/core/common/autofill_util.cc +++ b/components/autofill/core/common/autofill_util.cc
@@ -213,7 +213,9 @@ } bool IsFillable(FocusedFieldType focused_field_type) { - return focused_field_type == FocusedFieldType::kFillableTextField || + return focused_field_type == FocusedFieldType::kFillableTextArea || + focused_field_type == FocusedFieldType::kFillableSearchField || + focused_field_type == FocusedFieldType::kFillableNonSearchField || focused_field_type == FocusedFieldType::kFillableUsernameField || focused_field_type == FocusedFieldType::kFillablePasswordField; }
diff --git a/components/autofill/core/common/mojom/autofill_types.mojom b/components/autofill/core/common/mojom/autofill_types.mojom index 015e1b91..21aa222b 100644 --- a/components/autofill/core/common/mojom/autofill_types.mojom +++ b/components/autofill/core/common/mojom/autofill_types.mojom
@@ -52,7 +52,9 @@ enum FocusedFieldType { kUnknown, kUnfillableElement, - kFillableTextField, + kFillableTextArea, + kFillableSearchField, + kFillableNonSearchField, kFillableUsernameField, kFillablePasswordField, }; @@ -203,14 +205,6 @@ // autofill::PasswordFormGenerationData struct PasswordFormGenerationData { - uint64 form_signature; - uint32 field_signature; - bool has_confirmation_field; - uint32 confirmation_field_signature; -}; - -// autofill::NewPasswordFormGenerationData -struct NewPasswordFormGenerationData { uint32 new_password_renderer_id; uint32 confirmation_password_renderer_id; };
diff --git a/components/autofill/core/common/mojom/autofill_types.typemap b/components/autofill/core/common/mojom/autofill_types.typemap index cbc980b..50a36fd 100644 --- a/components/autofill/core/common/mojom/autofill_types.typemap +++ b/components/autofill/core/common/mojom/autofill_types.typemap
@@ -32,7 +32,6 @@ "autofill.mojom.FormFieldData=autofill::FormFieldData", "autofill.mojom.FormFieldDataPredictions=autofill::FormFieldDataPredictions", "autofill.mojom.FormsPredictionsMap=autofill::FormsPredictionsMap", - "autofill.mojom.NewPasswordFormGenerationData=autofill::NewPasswordFormGenerationData", "autofill.mojom.PasswordAndRealm=autofill::PasswordAndRealm", "autofill.mojom.PasswordForm=autofill::PasswordForm", "autofill.mojom.PasswordFormFieldPredictionMap=autofill::PasswordFormFieldPredictionMap",
diff --git a/components/autofill/core/common/mojom/autofill_types_struct_traits.cc b/components/autofill/core/common/mojom/autofill_types_struct_traits.cc index ce270c55..f464ca1 100644 --- a/components/autofill/core/common/mojom/autofill_types_struct_traits.cc +++ b/components/autofill/core/common/mojom/autofill_types_struct_traits.cc
@@ -257,22 +257,6 @@ autofill::PasswordFormGenerationData>:: Read(autofill::mojom::PasswordFormGenerationDataDataView data, autofill::PasswordFormGenerationData* out) { - out->form_signature = data.form_signature(); - out->field_signature = data.field_signature(); - if (data.has_confirmation_field()) { - out->confirmation_field_signature.emplace( - data.confirmation_field_signature()); - } else { - DCHECK(!out->confirmation_field_signature); - } - return true; -} - -// static -bool StructTraits<autofill::mojom::NewPasswordFormGenerationDataDataView, - autofill::NewPasswordFormGenerationData>:: - Read(autofill::mojom::NewPasswordFormGenerationDataDataView data, - autofill::NewPasswordFormGenerationData* out) { out->new_password_renderer_id = data.new_password_renderer_id(); out->confirmation_password_renderer_id = data.confirmation_password_renderer_id();
diff --git a/components/autofill/core/common/mojom/autofill_types_struct_traits.h b/components/autofill/core/common/mojom/autofill_types_struct_traits.h index 67c55d80..98a32476 100644 --- a/components/autofill/core/common/mojom/autofill_types_struct_traits.h +++ b/components/autofill/core/common/mojom/autofill_types_struct_traits.h
@@ -368,45 +368,18 @@ template <> struct StructTraits<autofill::mojom::PasswordFormGenerationDataDataView, autofill::PasswordFormGenerationData> { - static uint64_t form_signature( - const autofill::PasswordFormGenerationData& r) { - return r.form_signature; - } - - static uint32_t field_signature( - const autofill::PasswordFormGenerationData& r) { - return r.field_signature; - } - - static bool has_confirmation_field( - const autofill::PasswordFormGenerationData& r) { - return r.confirmation_field_signature.has_value(); - } - - static uint32_t confirmation_field_signature( - const autofill::PasswordFormGenerationData& r) { - return r.confirmation_field_signature.value_or(0); - } - - static bool Read(autofill::mojom::PasswordFormGenerationDataDataView data, - autofill::PasswordFormGenerationData* out); -}; - -template <> -struct StructTraits<autofill::mojom::NewPasswordFormGenerationDataDataView, - autofill::NewPasswordFormGenerationData> { static uint32_t new_password_renderer_id( - const autofill::NewPasswordFormGenerationData& r) { + const autofill::PasswordFormGenerationData& r) { return r.new_password_renderer_id; } static uint32_t confirmation_password_renderer_id( - const autofill::NewPasswordFormGenerationData& r) { + const autofill::PasswordFormGenerationData& r) { return r.confirmation_password_renderer_id; } - static bool Read(autofill::mojom::NewPasswordFormGenerationDataDataView data, - autofill::NewPasswordFormGenerationData* out); + static bool Read(autofill::mojom::PasswordFormGenerationDataDataView data, + autofill::PasswordFormGenerationData* out); }; template <>
diff --git a/components/autofill/core/common/mojom/autofill_types_struct_traits_unittest.cc b/components/autofill/core/common/mojom/autofill_types_struct_traits_unittest.cc index 8071a635..46c71e04 100644 --- a/components/autofill/core/common/mojom/autofill_types_struct_traits_unittest.cc +++ b/components/autofill/core/common/mojom/autofill_types_struct_traits_unittest.cc
@@ -178,17 +178,6 @@ EXPECT_EQ(expected.wait_for_username, actual.wait_for_username); } -void CheckEqualPasswordFormGenerationData( - const PasswordFormGenerationData& expected, - const PasswordFormGenerationData& actual) { - EXPECT_EQ(expected.form_signature, actual.form_signature); - EXPECT_EQ(expected.field_signature, actual.field_signature); - ASSERT_EQ(expected.confirmation_field_signature.has_value(), - actual.confirmation_field_signature.has_value()); - EXPECT_EQ(expected.confirmation_field_signature.value(), - actual.confirmation_field_signature.value()); -} - void CheckEqualPassPasswordGenerationUIData( const password_generation::PasswordGenerationUIData& expected, const password_generation::PasswordGenerationUIData& actual) { @@ -246,12 +235,6 @@ std::move(callback).Run(s); } - void PassNewPasswordFormGenerationData( - const NewPasswordFormGenerationData& s, - PassNewPasswordFormGenerationDataCallback callback) override { - std::move(callback).Run(s); - } - void PassPasswordGenerationUIData( const password_generation::PasswordGenerationUIData& s, PassPasswordGenerationUIDataCallback callback) override { @@ -316,14 +299,6 @@ const PasswordFormGenerationData& expected, base::OnceClosure closure, const PasswordFormGenerationData& passed) { - CheckEqualPasswordFormGenerationData(expected, passed); - std::move(closure).Run(); -} - -void ExpectNewPasswordFormGenerationData( - const NewPasswordFormGenerationData& expected, - base::OnceClosure closure, - const NewPasswordFormGenerationData& passed) { EXPECT_EQ(expected.new_password_renderer_id, passed.new_password_renderer_id); EXPECT_EQ(expected.confirmation_password_renderer_id, passed.confirmation_password_renderer_id); @@ -440,34 +415,15 @@ loop.Run(); } -TEST_F(AutofillTypeTraitsTestImpl, PassPasswordFormGenerationData) { - FormData form; - test::CreateTestAddressFormData(&form); - FormSignature form_signature = CalculateFormSignature(form); - FieldSignature field_signature = - CalculateFieldSignatureForField(form.fields[0]); - FieldSignature confirmation_field_signature = - CalculateFieldSignatureForField(form.fields[1]); - PasswordFormGenerationData input(form_signature, field_signature); - input.confirmation_field_signature.emplace(confirmation_field_signature); - - base::RunLoop loop; - mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); - proxy->PassPasswordFormGenerationData( - input, base::BindOnce(&ExpectPasswordFormGenerationData, input, - loop.QuitClosure())); - loop.Run(); -} - -TEST_F(AutofillTypeTraitsTestImpl, NewPasswordFormGenerationData) { - NewPasswordFormGenerationData input; +TEST_F(AutofillTypeTraitsTestImpl, PasswordFormGenerationData) { + PasswordFormGenerationData input; input.new_password_renderer_id = 1234u, input.confirmation_password_renderer_id = 5789u; base::RunLoop loop; mojom::TypeTraitsTestPtr proxy = GetTypeTraitsTestProxy(); - proxy->PassNewPasswordFormGenerationData( - input, base::BindOnce(&ExpectNewPasswordFormGenerationData, input, + proxy->PassPasswordFormGenerationData( + input, base::BindOnce(&ExpectPasswordFormGenerationData, input, loop.QuitClosure())); loop.Run(); }
diff --git a/components/autofill/core/common/mojom/test_autofill_types.mojom b/components/autofill/core/common/mojom/test_autofill_types.mojom index b9c40d98..9f5be9e 100644 --- a/components/autofill/core/common/mojom/test_autofill_types.mojom +++ b/components/autofill/core/common/mojom/test_autofill_types.mojom
@@ -20,8 +20,6 @@ (FormsPredictionsMap passed); PassPasswordFormGenerationData(PasswordFormGenerationData s) => (PasswordFormGenerationData passed); - PassNewPasswordFormGenerationData(NewPasswordFormGenerationData s) => - (NewPasswordFormGenerationData passed); PassPasswordGenerationUIData(PasswordGenerationUIData s) => (PasswordGenerationUIData passed); };
diff --git a/components/autofill/core/common/password_form_generation_data.cc b/components/autofill/core/common/password_form_generation_data.cc index 4e10cbc..2b2c5a5 100644 --- a/components/autofill/core/common/password_form_generation_data.cc +++ b/components/autofill/core/common/password_form_generation_data.cc
@@ -11,28 +11,16 @@ PasswordFormGenerationData::PasswordFormGenerationData() = default; PasswordFormGenerationData::PasswordFormGenerationData( - FormSignature form_signature, - FieldSignature field_signature) - : form_signature(form_signature), field_signature(field_signature) {} - -PasswordFormGenerationData::PasswordFormGenerationData( const PasswordFormGenerationData& other) = default; -PasswordFormGenerationData::~PasswordFormGenerationData() = default; - -NewPasswordFormGenerationData::NewPasswordFormGenerationData() = default; - -NewPasswordFormGenerationData::NewPasswordFormGenerationData( - const NewPasswordFormGenerationData& other) = default; - -NewPasswordFormGenerationData::NewPasswordFormGenerationData( +PasswordFormGenerationData::PasswordFormGenerationData( uint32_t new_password_renderer_id, uint32_t confirmation_password_renderer_id) : new_password_renderer_id(new_password_renderer_id), confirmation_password_renderer_id(confirmation_password_renderer_id) {} #if defined(OS_IOS) -NewPasswordFormGenerationData::NewPasswordFormGenerationData( +PasswordFormGenerationData::PasswordFormGenerationData( base::string16 form_name, base::string16 new_password_element, base::string16 confirmation_password_element)
diff --git a/components/autofill/core/common/password_form_generation_data.h b/components/autofill/core/common/password_form_generation_data.h index f33ccbb1..2c084ea 100644 --- a/components/autofill/core/common/password_form_generation_data.h +++ b/components/autofill/core/common/password_form_generation_data.h
@@ -21,37 +21,13 @@ // which fields password should be generated. struct PasswordFormGenerationData { PasswordFormGenerationData(); - PasswordFormGenerationData(FormSignature form_signature, - FieldSignature field_signature); PasswordFormGenerationData(const PasswordFormGenerationData& other); - ~PasswordFormGenerationData(); - - // The unique signature of form where password should be generated - // (see components/autofill/core/browser/form_structure.h). - FormSignature form_signature; - - // The unique signature of field where password should be generated - // (see components/autofill/core/browser/autofill_field.h). - FieldSignature field_signature; - - // The unique signature of the confirmation field where the generated password - // should be copied to. - base::Optional<FieldSignature> confirmation_field_signature; -}; - -// Structure used for sending information from browser to renderer about on -// which fields password should be generated. -// TODO(https://crbug.com/866444): Remove old PasswordFormGenerationData and -// rename to PasswordFormGenerationData when the old parser is gone. -struct NewPasswordFormGenerationData { - NewPasswordFormGenerationData(); - NewPasswordFormGenerationData(const NewPasswordFormGenerationData& other); - NewPasswordFormGenerationData(uint32_t new_password_renderer_id, - uint32_t confirmation_password_renderer_id); + PasswordFormGenerationData(uint32_t new_password_renderer_id, + uint32_t confirmation_password_renderer_id); #if defined(OS_IOS) - NewPasswordFormGenerationData(base::string16 form_name, - base::string16 new_password_element, - base::string16 confirmation_password_element); + PasswordFormGenerationData(base::string16 form_name, + base::string16 new_password_element, + base::string16 confirmation_password_element); base::string16 form_name; base::string16 new_password_element;
diff --git a/components/content_settings/core/browser/cookie_settings.cc b/components/content_settings/core/browser/cookie_settings.cc index 2a31f93..44b4fc0 100644 --- a/components/content_settings/core/browser/cookie_settings.cc +++ b/components/content_settings/core/browser/cookie_settings.cc
@@ -183,10 +183,12 @@ prefs::kCookieControlsEnabled)); if (block_third_party_cookies_ != new_block_third_party_cookies) { - base::AutoLock auto_lock(lock_); - block_third_party_cookies_ = new_block_third_party_cookies; + { + base::AutoLock auto_lock(lock_); + block_third_party_cookies_ = new_block_third_party_cookies; + } for (Observer& obs : observers_) - obs.OnThirdPartyCookieBlockingChanged(block_third_party_cookies_); + obs.OnThirdPartyCookieBlockingChanged(new_block_third_party_cookies); } }
diff --git a/components/content_settings/core/browser/cookie_settings_unittest.cc b/components/content_settings/core/browser/cookie_settings_unittest.cc index d9cca79..4f2a18a99 100644 --- a/components/content_settings/core/browser/cookie_settings_unittest.cc +++ b/components/content_settings/core/browser/cookie_settings_unittest.cc
@@ -4,6 +4,7 @@ #include "components/content_settings/core/browser/cookie_settings.h" +#include "base/scoped_observer.h" #include "base/test/scoped_feature_list.h" #include "base/test/scoped_task_environment.h" #include "components/content_settings/core/browser/host_content_settings_map.h" @@ -19,6 +20,30 @@ namespace { +class CookieSettingsObserver : public CookieSettings::Observer { + public: + CookieSettingsObserver(CookieSettings* settings) + : settings_(settings), scoped_observer(this) { + scoped_observer.Add(settings); + } + + void OnThirdPartyCookieBlockingChanged( + bool block_third_party_cookies) override { + ASSERT_EQ(block_third_party_cookies, + settings_->ShouldBlockThirdPartyCookies()); + last_value_ = block_third_party_cookies; + } + + bool last_value() { return last_value_; } + + private: + CookieSettings* settings_; + bool last_value_ = false; + ScopedObserver<CookieSettings, CookieSettingsObserver> scoped_observer; + + DISALLOW_COPY_AND_ASSIGN(CookieSettingsObserver); +}; + class CookieSettingsTest : public testing::Test { public: CookieSettingsTest() @@ -383,6 +408,14 @@ EXPECT_TRUE( cookie_settings_->IsCookieAccessAllowed(kHttpsSite, kFirstPartySite)); } + +TEST_F(CookieSettingsTest, ThirdPartySettingObserver) { + CookieSettingsObserver observer(cookie_settings_.get()); + EXPECT_FALSE(observer.last_value()); + prefs_.SetBoolean(prefs::kBlockThirdPartyCookies, true); + EXPECT_TRUE(observer.last_value()); +} + } // namespace } // namespace content_settings
diff --git a/components/invalidation/impl/profile_identity_provider.cc b/components/invalidation/impl/profile_identity_provider.cc index ff26ade..d208585 100644 --- a/components/invalidation/impl/profile_identity_provider.cc +++ b/components/invalidation/impl/profile_identity_provider.cc
@@ -15,7 +15,7 @@ // IdentityManager and wraps an AccessTokenFetcher internally. class AccessTokenFetcherAdaptor : public ActiveAccountAccessTokenFetcher { public: - AccessTokenFetcherAdaptor(const std::string& active_account_id, + AccessTokenFetcherAdaptor(const CoreAccountId& active_account_id, const std::string& oauth_consumer_name, identity::IdentityManager* identity_manager, const identity::ScopeSet& scopes, @@ -35,7 +35,7 @@ }; AccessTokenFetcherAdaptor::AccessTokenFetcherAdaptor( - const std::string& active_account_id, + const CoreAccountId& active_account_id, const std::string& oauth_consumer_name, identity::IdentityManager* identity_manager, const identity::ScopeSet& scopes, @@ -68,7 +68,7 @@ identity_manager_->RemoveObserver(this); } -std::string ProfileIdentityProvider::GetActiveAccountId() { +CoreAccountId ProfileIdentityProvider::GetActiveAccountId() { return active_account_id_; } @@ -81,7 +81,7 @@ } void ProfileIdentityProvider::SetActiveAccountId( - const std::string& account_id) { + const CoreAccountId& account_id) { if (account_id == active_account_id_) return;
diff --git a/components/invalidation/impl/profile_identity_provider.h b/components/invalidation/impl/profile_identity_provider.h index ab7a0823..807bf1a 100644 --- a/components/invalidation/impl/profile_identity_provider.h +++ b/components/invalidation/impl/profile_identity_provider.h
@@ -20,7 +20,7 @@ ~ProfileIdentityProvider() override; // IdentityProvider: - std::string GetActiveAccountId() override; + CoreAccountId GetActiveAccountId() override; bool IsActiveAccountWithRefreshToken() override; std::unique_ptr<ActiveAccountAccessTokenFetcher> FetchAccessToken( const std::string& oauth_consumer_name, @@ -28,7 +28,7 @@ ActiveAccountAccessTokenCallback callback) override; void InvalidateAccessToken(const identity::ScopeSet& scopes, const std::string& access_token) override; - void SetActiveAccountId(const std::string& account_id) override; + void SetActiveAccountId(const CoreAccountId& account_id) override; // identity::IdentityManager::Observer: void OnRefreshTokenUpdatedForAccount( @@ -39,7 +39,7 @@ private: identity::IdentityManager* const identity_manager_; - std::string active_account_id_; + CoreAccountId active_account_id_; DISALLOW_COPY_AND_ASSIGN(ProfileIdentityProvider); };
diff --git a/components/invalidation/public/identity_provider.cc b/components/invalidation/public/identity_provider.cc index 1424cc1..0b9ec72 100644 --- a/components/invalidation/public/identity_provider.cc +++ b/components/invalidation/public/identity_provider.cc
@@ -23,7 +23,7 @@ IdentityProvider::IdentityProvider() {} void IdentityProvider::ProcessRefreshTokenUpdateForAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { if (account_id != GetActiveAccountId()) { diagnostic_info_.token_update_for_not_active_account_count++; return; @@ -34,7 +34,7 @@ } void IdentityProvider::ProcessRefreshTokenRemovalForAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { if (account_id != GetActiveAccountId()) { diagnostic_info_.token_removal_for_not_active_account_count++; return;
diff --git a/components/invalidation/public/identity_provider.h b/components/invalidation/public/identity_provider.h index 9b7b2b60..407c8cdf 100644 --- a/components/invalidation/public/identity_provider.h +++ b/components/invalidation/public/identity_provider.h
@@ -64,7 +64,7 @@ virtual ~IdentityProvider(); // Gets the active account's account ID. - virtual std::string GetActiveAccountId() = 0; + virtual CoreAccountId GetActiveAccountId() = 0; // Returns true iff (1) there is an active account and (2) that account has // a refresh token. @@ -84,7 +84,7 @@ const std::string& access_token) = 0; // Set the account id that should be registered for invalidations. - virtual void SetActiveAccountId(const std::string& account_id) = 0; + virtual void SetActiveAccountId(const CoreAccountId& account_id) = 0; void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); @@ -97,11 +97,11 @@ // Processes a refresh token update, firing the observer callback if // |account_id| is the active account. - void ProcessRefreshTokenUpdateForAccount(const std::string& account_id); + void ProcessRefreshTokenUpdateForAccount(const CoreAccountId& account_id); // Processes a refresh token removal, firing the observer callback if // |account_id| is the active account. - void ProcessRefreshTokenRemovalForAccount(const std::string& account_id); + void ProcessRefreshTokenRemovalForAccount(const CoreAccountId& account_id); // Fires an OnActiveAccountLogin notification. void FireOnActiveAccountLogin();
diff --git a/components/password_manager/content/browser/content_password_manager_driver.cc b/components/password_manager/content/browser/content_password_manager_driver.cc index d4245926..a3e3beb 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.cc +++ b/components/password_manager/content/browser/content_password_manager_driver.cc
@@ -104,21 +104,8 @@ autofill::MaybeClearPasswordValues(form_data)); } -void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) { - if (GetPasswordGenerationHelper()->IsGenerationEnabled( - /*log_debug_data=*/true)) { - GetPasswordGenerationAgent()->FormNotBlacklisted(form); - } -} - -void ContentPasswordManagerDriver::FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) { - GetPasswordGenerationAgent()->FoundFormsEligibleForGeneration(forms); -} - void ContentPasswordManagerDriver::FormEligibleForGenerationFound( - const autofill::NewPasswordFormGenerationData& form) { + const autofill::PasswordFormGenerationData& form) { if (GetPasswordGenerationHelper()->IsGenerationEnabled( /*log_debug_data=*/true)) { GetPasswordGenerationAgent()->FoundFormEligibleForGeneration(form);
diff --git a/components/password_manager/content/browser/content_password_manager_driver.h b/components/password_manager/content/browser/content_password_manager_driver.h index cb3eafd1..832cc5a 100644 --- a/components/password_manager/content/browser/content_password_manager_driver.h +++ b/components/password_manager/content/browser/content_password_manager_driver.h
@@ -54,12 +54,8 @@ // PasswordManagerDriver implementation. void FillPasswordForm( const autofill::PasswordFormFillData& form_data) override; - void AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) override; - void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) override; void FormEligibleForGenerationFound( - const autofill::NewPasswordFormGenerationData& form) override; + const autofill::PasswordFormGenerationData& form) override; void AutofillDataReceived( const std::map<autofill::FormData, autofill::PasswordFormFieldPredictionMap>& predictions)
diff --git a/components/password_manager/core/browser/BUILD.gn b/components/password_manager/core/browser/BUILD.gn index 487e65bd..f0fd7e7 100644 --- a/components/password_manager/core/browser/BUILD.gn +++ b/components/password_manager/core/browser/BUILD.gn
@@ -92,7 +92,6 @@ "import/password_csv_reader.h", "import/password_importer.cc", "import/password_importer.h", - "keychain_migration_status_mac.h", "log_manager.cc", "log_manager.h", "log_receiver.h", @@ -427,6 +426,7 @@ "//components/test/data/password_manager/login_db_v21.sql", "//components/test/data/password_manager/login_db_v22.sql", "//components/test/data/password_manager/login_db_v23.sql", + "//components/test/data/password_manager/login_db_v24.sql", "//components/test/data/password_manager/login_db_v2_broken.sql", "//components/test/data/password_manager/login_db_v3.sql", "//components/test/data/password_manager/login_db_v3_broken.sql",
diff --git a/components/password_manager/core/browser/keychain_migration_status_mac.h b/components/password_manager/core/browser/keychain_migration_status_mac.h deleted file mode 100644 index 7260a6a..0000000 --- a/components/password_manager/core/browser/keychain_migration_status_mac.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2015 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_PASSWORD_MANAGER_CORE_BROWSER_KEYCHAIN_MIGRATION_STATUS_MAC_H -#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_KEYCHAIN_MIGRATION_STATUS_MAC_H - -namespace password_manager { - -// Status of password migration from the Keychain. -// The enum is used to back a histogram, and should therefore be treated as -// append-only. -enum class MigrationStatus { - // Migration wasn't tried yet. - NOT_STARTED = 0, - - // Migration finished successfully. - MIGRATED, - - // Migration failed once. It should be tried again. - FAILED_ONCE, - - // Migration failed twice. It should not be tried again. - FAILED_TWICE, - - // Migration finished successfully. The Keychain was cleaned up. - MIGRATED_DELETED, - - // Best effort migration happened. Some passwords were inaccessible. - MIGRATED_PARTIALLY, - - // Gave up on migration as the passwords aren't accessible anyway after Chrome - // changes the certificate. - MIGRATION_STOPPED, - - MIGRATION_STATUS_COUNT, -}; - -} // namespace password_manager - -#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_KEYCHAIN_MIGRATION_STATUS_MAC_H
diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc index 48777084..3c6b171f 100644 --- a/components/password_manager/core/browser/login_database.cc +++ b/components/password_manager/core/browser/login_database.cc
@@ -54,7 +54,7 @@ namespace password_manager { // The current version number of the login database schema. -const int kCurrentVersionNumber = 23; +const int kCurrentVersionNumber = 24; // The oldest version of the schema such that a legacy Chrome client using that // version can still read/write the current database. const int kCompatibleVersionNumber = 19; @@ -516,6 +516,11 @@ // start clean from scratch. SealVersion(builders, /*expected_version=*/23u); + // Version 24. Version 23 could have some corruption in Sync metadata and + // hence we are migrating users on it by clearing their metadata to make Sync + // start clean from scratch. + SealVersion(builders, /*expected_version=*/24u); + DCHECK_EQ(static_cast<size_t>(COLUMN_NUM), builders.logins->NumberOfColumns()) << "Adjust LoginDatabaseTableColumns if you change column definitions " "here."; @@ -557,7 +562,7 @@ // Sync Metadata tables have been introduced in version 21. It is enough to // drop all data because Sync would populate the tables properly at startup. - if (current_version == 21 || current_version == 22) { + if (current_version == 21 || current_version == 22 || current_version == 23) { if (!ClearAllSyncMetadata(db)) return false; }
diff --git a/components/password_manager/core/browser/new_password_form_manager_unittest.cc b/components/password_manager/core/browser/new_password_form_manager_unittest.cc index a44d9d0..8b7aaf1 100644 --- a/components/password_manager/core/browser/new_password_form_manager_unittest.cc +++ b/components/password_manager/core/browser/new_password_form_manager_unittest.cc
@@ -38,9 +38,9 @@ using autofill::FormFieldData; using autofill::FormSignature; using autofill::FormStructure; -using autofill::NewPasswordFormGenerationData; using autofill::PasswordForm; using autofill::PasswordFormFillData; +using autofill::PasswordFormGenerationData; using autofill::ServerFieldType; using base::ASCIIToUTF16; using base::TestMockTimeTaskRunner; @@ -78,7 +78,7 @@ MOCK_METHOD1(FillPasswordForm, void(const PasswordFormFillData&)); MOCK_METHOD1(AllowPasswordGenerationForForm, void(const PasswordForm&)); MOCK_METHOD1(FormEligibleForGenerationFound, - void(const autofill::NewPasswordFormGenerationData&)); + void(const autofill::PasswordFormGenerationData&)); }; class MockAutofillDownloadManager : public autofill::AutofillDownloadManager { @@ -483,7 +483,7 @@ PasswordFormFillData fill_data; EXPECT_CALL(driver_, FillPasswordForm(_)).WillOnce(SaveArg<0>(&fill_data)); - NewPasswordFormGenerationData generation_data; + PasswordFormGenerationData generation_data; EXPECT_CALL(driver_, FormEligibleForGenerationFound(_)) .WillOnce(SaveArg<0>(&generation_data)); @@ -521,7 +521,7 @@ field.autocomplete_attribute = "new-password"; observed_form_.fields.push_back(field); - NewPasswordFormGenerationData generation_data; + PasswordFormGenerationData generation_data; EXPECT_CALL(driver_, FormEligibleForGenerationFound(_)) .WillOnce(SaveArg<0>(&generation_data));
diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc index 812e476..b376ace 100644 --- a/components/password_manager/core/browser/password_autofill_manager.cc +++ b/components/password_manager/core/browser/password_autofill_manager.cc
@@ -21,6 +21,7 @@ #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "components/autofill/core/browser/autofill_client.h" +#include "components/autofill/core/browser/autofill_driver.h" #include "components/autofill/core/browser/autofill_experiments.h" #include "components/autofill/core/browser/ui/popup_item_ids.h" #include "components/autofill/core/browser/ui/suggestion.h" @@ -205,14 +206,16 @@ if (identifier == autofill::POPUP_ITEM_ID_GENERATE_PASSWORD_ENTRY) { password_client_->GeneratePassword(); metrics_util::LogPasswordDropdownItemSelected( - PasswordDropdownSelectedOption::kGenerate); + PasswordDropdownSelectedOption::kGenerate, + password_client_->IsIncognito()); } else if (identifier == autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY) { password_client_->NavigateToManagePasswordsPage( ManagePasswordsReferrer::kPasswordDropdown); metrics_util::LogContextOfShowAllSavedPasswordsAccepted( metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_PASSWORD); metrics_util::LogPasswordDropdownItemSelected( - PasswordDropdownSelectedOption::kShowAll); + PasswordDropdownSelectedOption::kShowAll, + password_client_->IsIncognito()); if (password_client_ && password_client_->GetMetricsRecorder()) { using UserAction = @@ -222,7 +225,8 @@ } } else { metrics_util::LogPasswordDropdownItemSelected( - PasswordDropdownSelectedOption::kPassword); + PasswordDropdownSelectedOption::kPassword, + password_client_->IsIncognito()); bool success = FillSuggestion(GetUsernameFromSuggestion(value)); DCHECK(success); } @@ -308,7 +312,8 @@ } metrics_util::LogPasswordDropdownShown( - metrics_util::PasswordDropdownState::kStandard); + metrics_util::PasswordDropdownState::kStandard, + password_client_->IsIncognito()); autofill_client_->ShowAutofillPopup(bounds, text_direction, suggestions, false, autofill::PopupType::kPasswords, weak_ptr_factory_.GetWeakPtr()); @@ -356,7 +361,8 @@ } metrics_util::LogPasswordDropdownShown( - metrics_util::PasswordDropdownState::kStandardGenerate); + metrics_util::PasswordDropdownState::kStandardGenerate, + password_client_->IsIncognito()); autofill_client_->ShowAutofillPopup(bounds, text_direction, suggestions, false, autofill::PopupType::kPasswords, weak_ptr_factory_.GetWeakPtr());
diff --git a/components/password_manager/core/browser/password_form_filling.cc b/components/password_manager/core/browser/password_form_filling.cc index 9262fd7..e5359a8 100644 --- a/components/password_manager/core/browser/password_form_filling.cc +++ b/components/password_manager/core/browser/password_form_filling.cc
@@ -115,11 +115,6 @@ const bool new_parsing_enabled = base::FeatureList::IsEnabled(features::kNewPasswordFormParsing); - // No need to inform the renderer about form blacklisting. - // NewPasswordFormManager sends all needed information to the renderer. - if (!new_parsing_enabled && !is_blacklisted) - driver->AllowPasswordGenerationForForm(observed_form); - if (best_matches.empty()) { driver->InformNoSavedCredentials(); metrics_recorder->RecordFillEvent(
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc index e412d60..d785b395 100644 --- a/components/password_manager/core/browser/password_form_manager_unittest.cc +++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -294,8 +294,6 @@ MOCK_METHOD0(InformNoSavedCredentials, void()); MOCK_METHOD1(ShowInitialPasswordAccountSuggestions, void(const autofill::PasswordFormFillData&)); - MOCK_METHOD1(AllowPasswordGenerationForForm, - void(const autofill::PasswordForm&)); MockAutofillManager* mock_autofill_manager() { return &mock_autofill_manager_; @@ -1450,8 +1448,6 @@ // user chooses the main one, then the other possible usernames are dropped on // update. TEST_F(PasswordFormManagerTest, TestAlternateUsername_NoChange) { - EXPECT_CALL(*client()->mock_driver(), AllowPasswordGenerationForForm(_)); - PasswordForm saved_form = *saved_match(); saved_form.other_possible_usernames.push_back( ValueElementPair(ASCIIToUTF16("other_possible@gmail.com"), @@ -1482,22 +1478,6 @@ EXPECT_TRUE(saved_result.other_possible_usernames.empty()); } -TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage_NoCredentials) { - // First time sign-up attempt. Password store does not contain matching - // credentials. AllowPasswordGenerationForForm should be called to send the - // "not blacklisted" message. - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); - fake_form_fetcher()->NotifyFetchCompleted(); -} - -TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage_Credentials) { - // Signing up on a previously visited site. Credentials are found in the - // password store, and are not blacklisted. AllowPasswordGenerationForForm - // should be called to send the "not blacklisted" message. - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); - PasswordForm simulated_result = CreateSavedMatch(false); - SetNonFederatedAndNotifyFetchCompleted({&simulated_result}); -} TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage_DroppedCredentials) { @@ -1513,7 +1493,6 @@ client()->driver(), signup_form, std::make_unique<MockFormSaver>(), &fetcher); form_manager.Init(nullptr); - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); PasswordForm simulated_result = CreateSavedMatch(false); SetNonFederatedAndNotifyFetchCompleted(&fetcher, {&simulated_result}); } @@ -1651,8 +1630,6 @@ // Test that public-suffix-matched credentials score lower than same-origin // ones. TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) { - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); - PasswordForm base_match = CreateSavedMatch(false); base_match.origin = GURL("http://accounts.google.com/a/ServiceLoginAuth"); base_match.action = GURL("http://accounts.google.com/a/ServiceLogin"); @@ -1677,8 +1654,6 @@ } TEST_F(PasswordFormManagerTest, AndroidCredentialsAreAutofilled) { - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); - // Although Android-based credentials are treated similarly to PSL-matched // credentials in some respects, they should be autofilled as opposed to be // filled on username-select. @@ -1734,8 +1709,6 @@ const char kTestAndroidPassword1[] = "android-password-alpha"; const char kTestAndroidPassword2[] = "android-password-beta"; - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)); - // Suppose there is one login saved through the website, and two other coming // from Android: the first has the same username as the web-based credential, // so it should be suppressed, but the second has a different username, so it @@ -1923,8 +1896,6 @@ // user updates the password, then all of the stored passwords get updated as // long as they have the same password value. TEST_F(PasswordFormManagerTest, CorrectlyUpdatePasswordsWithSameUsername) { - EXPECT_CALL(*client()->mock_driver(), AllowPasswordGenerationForForm(_)); - PasswordForm first(*saved_match()); first.action = observed_form()->action; first.password_value = ASCIIToUTF16("first"); @@ -2065,8 +2036,6 @@ } TEST_F(PasswordFormManagerTest, CorrectlySavePasswordWithoutUsernameFields) { - EXPECT_CALL(*client()->mock_driver(), AllowPasswordGenerationForForm(_)); - fake_form_fetcher()->NotifyFetchCompleted(); PasswordForm login(*observed_form()); @@ -3986,18 +3955,6 @@ ::testing::UnorderedElementsAre(form_signature_1, form_signature_2)); } -TEST_F(PasswordFormManagerTest, - TestNotSendNotBlacklistedMessage_BlacklistedCredentials) { - // Signing up on a previously visited site. Credentials are found in the - // password store, but they are blacklisted. AllowPasswordGenerationForForm - // is not called. - EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_)) - .Times(0); - PasswordForm simulated_result = CreateSavedMatch(true); - fake_form_fetcher()->SetBlacklisted({&simulated_result}); - fake_form_fetcher()->NotifyFetchCompleted(); -} - TEST_F(PasswordFormManagerTest, FirstLoginVote) { PasswordForm old_without_username = *saved_match(); old_without_username.username_value.clear();
diff --git a/components/password_manager/core/browser/password_generation_frame_helper.cc b/components/password_manager/core/browser/password_generation_frame_helper.cc index d83c09a..83126ca 100644 --- a/components/password_manager/core/browser/password_generation_frame_helper.cc +++ b/components/password_manager/core/browser/password_generation_frame_helper.cc
@@ -5,11 +5,9 @@ #include "components/password_manager/core/browser/password_generation_frame_helper.h" #include "base/optional.h" -#include "components/autofill/core/browser/autofill_field.h" #include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/browser/proto/password_requirements.pb.h" -#include "components/autofill/core/common/password_form_generation_data.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/generation/password_generator.h" #include "components/password_manager/core/browser/password_manager.h" @@ -19,7 +17,6 @@ #include "components/password_manager/core/browser/password_requirements_service.h" #include "components/password_manager/core/common/password_manager_features.h" -using autofill::AutofillField; using autofill::FieldSignature; using autofill::FormSignature; using autofill::FormStructure; @@ -80,44 +77,6 @@ } } -void PasswordGenerationFrameHelper::DetectFormsEligibleForGeneration( - const std::vector<autofill::FormStructure*>& forms) { - if (base::FeatureList::IsEnabled(features::kNewPasswordFormParsing)) { - // NewPasswordFormManager sends this information to the renderer. - return; - } - // IsGenerationEnabled is called multiple times and it is sufficient to - // log debug data once. This is it! - if (!IsGenerationEnabled(/*log_debug_data=*/true)) - return; - - std::vector<autofill::PasswordFormGenerationData> - forms_eligible_for_generation; - for (const FormStructure* form : forms) { - const AutofillField* generation_field = nullptr; - const AutofillField* confirmation_field = nullptr; - for (const std::unique_ptr<AutofillField>& field : *form) { - if (field->server_type() == autofill::ACCOUNT_CREATION_PASSWORD || - field->server_type() == autofill::NEW_PASSWORD) { - generation_field = field.get(); - } else if (field->server_type() == autofill::CONFIRMATION_PASSWORD) { - confirmation_field = field.get(); - } - } - if (generation_field) { - autofill::PasswordFormGenerationData data( - form->form_signature(), generation_field->GetFieldSignature()); - if (confirmation_field != nullptr) { - data.confirmation_field_signature.emplace( - confirmation_field->GetFieldSignature()); - } - forms_eligible_for_generation.push_back(data); - } - } - if (!forms_eligible_for_generation.empty()) - driver_->FormsEligibleForGenerationFound(forms_eligible_for_generation); -} - // In order for password generation to be enabled, we need to make sure: // (1) Password sync is enabled, and // (2) Password saving is enabled.
diff --git a/components/password_manager/core/browser/password_generation_frame_helper.h b/components/password_manager/core/browser/password_generation_frame_helper.h index a53ec61..7ffa212 100644 --- a/components/password_manager/core/browser/password_generation_frame_helper.h +++ b/components/password_manager/core/browser/password_generation_frame_helper.h
@@ -45,12 +45,6 @@ void ProcessPasswordRequirements( const std::vector<autofill::FormStructure*>& forms); - // Detect account creation forms from forms with autofill type annotated. - // Will send a message to the renderer if we find a correctly annotated form - // and the feature is enabled. - void DetectFormsEligibleForGeneration( - const std::vector<autofill::FormStructure*>& forms); - // Determines current state of password generation // |log_debug_data| determines whether log entries are sent to the // autofill::SavePasswordProgressLogger.
diff --git a/components/password_manager/core/browser/password_generation_frame_helper_unittest.cc b/components/password_manager/core/browser/password_generation_frame_helper_unittest.cc index b239bc3..6311a08 100644 --- a/components/password_manager/core/browser/password_generation_frame_helper_unittest.cc +++ b/components/password_manager/core/browser/password_generation_frame_helper_unittest.cc
@@ -70,17 +70,6 @@ PasswordAutofillManager* GetPasswordAutofillManager() override { return &password_autofill_manager_; } - void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) override { - found_forms_eligible_for_generation_.insert( - found_forms_eligible_for_generation_.begin(), forms.begin(), - forms.end()); - } - - const std::vector<autofill::PasswordFormGenerationData>& - GetFoundEligibleForGenerationForms() { - return found_forms_eligible_for_generation_; - } MOCK_METHOD0(AllowToRunFormClassifier, void()); @@ -88,8 +77,6 @@ PasswordManager password_manager_; PasswordGenerationFrameHelper password_generation_manager_; PasswordAutofillManager password_autofill_manager_; - std::vector<autofill::PasswordFormGenerationData> - found_forms_eligible_for_generation_; }; PasswordRequirementsSpec GetDomainWideRequirements() { @@ -190,11 +177,6 @@ return GetGenerationHelper()->IsGenerationEnabled(true); } - void DetectFormsEligibleForGeneration( - const std::vector<autofill::FormStructure*>& forms) { - GetGenerationHelper()->DetectFormsEligibleForGeneration(forms); - } - base::test::ScopedTaskEnvironment task_environment_; std::unique_ptr<MockPasswordManagerClient> client_; }; @@ -354,117 +336,6 @@ } } -TEST_F(PasswordGenerationFrameHelperTest, DetectFormsEligibleForGeneration) { - // Setup so that IsGenerationEnabled() returns true. - EXPECT_CALL(*client_, IsSavingAndFillingEnabled(_)) - .WillRepeatedly(testing::Return(true)); - EXPECT_CALL(*client_, GetPasswordSyncState()) - .WillRepeatedly(testing::Return(SYNCING_NORMAL_ENCRYPTION)); - - base::test::ScopedFeatureList scoped_feature_list; - scoped_feature_list.InitWithFeatures( - /* enabled_features */ {}, - /* disabled_features*/ {features::kNewPasswordFormParsing, - features::kNewPasswordFormParsingForSaving, - features::kOnlyNewParser}); - - autofill::FormData login_form; - login_form.url = GURL("http://www.yahoo.com/login/"); - autofill::FormFieldData username; - username.label = ASCIIToUTF16("username"); - username.name = ASCIIToUTF16("login"); - username.form_control_type = "text"; - login_form.fields.push_back(username); - autofill::FormFieldData password; - password.label = ASCIIToUTF16("password"); - password.name = ASCIIToUTF16("password"); - password.form_control_type = "password"; - login_form.fields.push_back(password); - autofill::FormStructure form1(login_form); - std::vector<autofill::FormStructure*> forms; - forms.push_back(&form1); - - autofill::FormData account_creation_form; - account_creation_form.url = GURL("http://accounts.yahoo.com/"); - account_creation_form.action = GURL("http://accounts.yahoo.com/signup"); - account_creation_form.name = ASCIIToUTF16("account_creation_form"); - account_creation_form.fields.push_back(username); - account_creation_form.fields.push_back(password); - autofill::FormFieldData confirm_password; - confirm_password.label = ASCIIToUTF16("confirm_password"); - confirm_password.name = ASCIIToUTF16("confirm_password"); - confirm_password.form_control_type = "password"; - account_creation_form.fields.push_back(confirm_password); - autofill::FormSignature account_creation_form_signature = - autofill::CalculateFormSignature(account_creation_form); - autofill::FieldSignature account_creation_field_signature = - autofill::CalculateFieldSignatureForField(password); - autofill::FieldSignature confirmation_field_signature = - autofill::CalculateFieldSignatureForField(confirm_password); - autofill::FormStructure form2(account_creation_form); - forms.push_back(&form2); - - autofill::FormData change_password_form; - change_password_form.url = GURL("http://accounts.yahoo.com/"); - change_password_form.action = GURL("http://accounts.yahoo.com/change"); - change_password_form.name = ASCIIToUTF16("change_password_form"); - change_password_form.fields.push_back(password); - change_password_form.fields[0].name = ASCIIToUTF16("new_password"); - change_password_form.fields.push_back(confirm_password); - autofill::FormStructure form3(change_password_form); - autofill::FormSignature change_password_form_signature = - autofill::CalculateFormSignature(change_password_form); - autofill::FieldSignature change_password_field_signature = - autofill::CalculateFieldSignatureForField(change_password_form.fields[0]); - forms.push_back(&form3); - - // Simulate the server response to set the field types. - // The server response numbers mean: - // EMAIL_ADDRESS = 9 - // PASSWORD = 75 - // ACCOUNT_CREATION_PASSWORD = 76 - // NEW_PASSWORD = 88 - // CONFIRMATION_PASSWORD = 95 - autofill::AutofillQueryResponseContents response; - response.add_field()->set_overall_type_prediction(9); - response.add_field()->set_overall_type_prediction(75); - response.add_field()->set_overall_type_prediction(9); - response.add_field()->set_overall_type_prediction(76); - response.add_field()->set_overall_type_prediction(75); - response.add_field()->set_overall_type_prediction(88); - response.add_field()->set_overall_type_prediction(95); - - std::string response_string; - ASSERT_TRUE(response.SerializeToString(&response_string)); - autofill::FormStructure::ParseQueryResponse(response_string, forms, nullptr); - - DetectFormsEligibleForGeneration(forms); - EXPECT_EQ(2u, GetTestDriver()->GetFoundEligibleForGenerationForms().size()); - EXPECT_EQ( - account_creation_form_signature, - GetTestDriver()->GetFoundEligibleForGenerationForms()[0].form_signature); - EXPECT_EQ( - account_creation_field_signature, - GetTestDriver()->GetFoundEligibleForGenerationForms()[0].field_signature); - EXPECT_FALSE(GetTestDriver() - ->GetFoundEligibleForGenerationForms()[0] - .confirmation_field_signature.has_value()); - - EXPECT_EQ( - change_password_form_signature, - GetTestDriver()->GetFoundEligibleForGenerationForms()[1].form_signature); - EXPECT_EQ( - change_password_field_signature, - GetTestDriver()->GetFoundEligibleForGenerationForms()[1].field_signature); - ASSERT_TRUE(GetTestDriver() - ->GetFoundEligibleForGenerationForms()[1] - .confirmation_field_signature.has_value()); - EXPECT_EQ(confirmation_field_signature, - GetTestDriver() - ->GetFoundEligibleForGenerationForms()[1] - .confirmation_field_signature.value()); -} - TEST_F(PasswordGenerationFrameHelperTest, UpdatePasswordSyncStateIncognito) { // Disable password manager by going incognito. Even though password // syncing is enabled, generation should still be disabled.
diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc index dafc42b..c216045 100644 --- a/components/password_manager/core/browser/password_manager.cc +++ b/components/password_manager/core/browser/password_manager.cc
@@ -24,7 +24,6 @@ #include "components/autofill/core/common/save_password_progress_logger.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/form_saver_impl.h" -#include "components/password_manager/core/browser/keychain_migration_status_mac.h" #include "components/password_manager/core/browser/log_manager.h" #include "components/password_manager/core/browser/new_password_form_manager.h" #include "components/password_manager/core/browser/password_autofill_manager.h" @@ -113,16 +112,6 @@ return false; } -// Helper UMA reporting function for differences in URLs during form submission. -void RecordWhetherTargetDomainDiffers(const GURL& src, const GURL& target) { - bool target_domain_differs = - !net::registry_controlled_domains::SameDomainOrHost( - src, target, - net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); - UMA_HISTOGRAM_BOOLEAN("PasswordManager.SubmitNavigatesToDifferentDomain", - target_domain_differs); -} - bool IsSignupForm(const PasswordForm& form) { return !form.new_password_element.empty() && form.password_element.empty(); } @@ -374,9 +363,8 @@ 0.0); #if defined(OS_MACOSX) - registry->RegisterIntegerPref( - prefs::kKeychainMigrationStatus, - static_cast<int>(MigrationStatus::MIGRATED_DELETED)); + registry->RegisterIntegerPref(prefs::kKeychainMigrationStatus, + 4 /* MIGRATED_DELETED */); #endif registry->RegisterListPref(prefs::kPasswordHashDataList, PrefRegistry::NO_REGISTRATION_FLAGS); @@ -1185,7 +1173,6 @@ submitted_manager->GetMetricsRecorder()->LogSubmitPassed(); - RecordWhetherTargetDomainDiffers(main_frame_url_, client_->GetMainFrameURL()); UMA_HISTOGRAM_BOOLEAN( "PasswordManager.SuccessfulLoginHappened", submitted_manager->GetSubmittedForm()->origin.SchemeIsCryptographic());
diff --git a/components/password_manager/core/browser/password_manager_driver.h b/components/password_manager/core/browser/password_manager_driver.h index 3a4ce391..1b0f6a1 100644 --- a/components/password_manager/core/browser/password_manager_driver.h +++ b/components/password_manager/core/browser/password_manager_driver.h
@@ -18,8 +18,6 @@ namespace autofill { class AutofillDriver; struct FormData; -struct NewPasswordFormGenerationData; -struct PasswordForm; struct PasswordFormGenerationData; struct PasswordFormFillData; } // namespace autofill @@ -35,8 +33,8 @@ class PasswordManagerDriver : public base::SupportsWeakPtr<PasswordManagerDriver> { public: - PasswordManagerDriver() {} - virtual ~PasswordManagerDriver() {} + PasswordManagerDriver() = default; + virtual ~PasswordManagerDriver() = default; // Fills forms matching |form_data|. virtual void FillPasswordForm( @@ -47,19 +45,10 @@ // TODO(https://crbug.com/621355): Remove and observe FormFetcher instead. virtual void InformNoSavedCredentials() {} - // Informs the driver that |form| can be used for password generation. - virtual void AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) = 0; - - // Notifies the driver that |forms| were found on which password can be - // generated. - virtual void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) = 0; - // Notifies the driver that a password can be generated on the fields // identified by |form|. virtual void FormEligibleForGenerationFound( - const autofill::NewPasswordFormGenerationData& form) {} + const autofill::PasswordFormGenerationData& form) {} // Notifies the driver that username and password predictions from autofill // have been received.
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.cc b/components/password_manager/core/browser/password_manager_metrics_util.cc index c0a1b629..96939fd 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.cc +++ b/components/password_manager/core/browser/password_manager_metrics_util.cc
@@ -5,7 +5,7 @@ #include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "base/macros.h" -#include "base/metrics/histogram_macros.h" +#include "base/metrics/histogram_functions.h" #include "base/metrics/user_metrics.h" #include "base/numerics/safe_conversions.h" #include "base/rand_util.h" @@ -33,103 +33,102 @@ } void LogGeneralUIDismissalReason(UIDismissalReason reason) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.UIDismissalReason", - reason, - NUM_UI_RESPONSES); + base::UmaHistogramEnumeration("PasswordManager.UIDismissalReason", reason, + NUM_UI_RESPONSES); } void LogSaveUIDismissalReason(UIDismissalReason reason) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.SaveUIDismissalReason", reason, - NUM_UI_RESPONSES); + base::UmaHistogramEnumeration("PasswordManager.SaveUIDismissalReason", reason, + NUM_UI_RESPONSES); } void LogUpdateUIDismissalReason(UIDismissalReason reason) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.UpdateUIDismissalReason", reason, - NUM_UI_RESPONSES); + base::UmaHistogramEnumeration("PasswordManager.UpdateUIDismissalReason", + reason, NUM_UI_RESPONSES); } void LogUIDisplayDisposition(UIDisplayDisposition disposition) { - UMA_HISTOGRAM_ENUMERATION("PasswordBubble.DisplayDisposition", - disposition, - NUM_DISPLAY_DISPOSITIONS); + base::UmaHistogramEnumeration("PasswordBubble.DisplayDisposition", + disposition, NUM_DISPLAY_DISPOSITIONS); } void LogFormDataDeserializationStatus(FormDeserializationStatus status) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.FormDataDeserializationStatus", - status, NUM_DESERIALIZATION_STATUSES); + base::UmaHistogramEnumeration("PasswordManager.FormDataDeserializationStatus", + status, NUM_DESERIALIZATION_STATUSES); } void LogFilledCredentialIsFromAndroidApp(bool from_android) { - UMA_HISTOGRAM_BOOLEAN( - "PasswordManager.FilledCredentialWasFromAndroidApp", - from_android); + base::UmaHistogramBoolean("PasswordManager.FilledCredentialWasFromAndroidApp", + from_android); } void LogPasswordSyncState(PasswordSyncState state) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.PasswordSyncState", state, - NUM_SYNC_STATES); + base::UmaHistogramEnumeration("PasswordManager.PasswordSyncState", state, + NUM_SYNC_STATES); } void LogApplySyncChangesState(ApplySyncChangesState state) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.ApplySyncChangesState", state); + base::UmaHistogramEnumeration("PasswordManager.ApplySyncChangesState", state); } void LogPasswordGenerationSubmissionEvent(PasswordSubmissionEvent event) { - UMA_HISTOGRAM_ENUMERATION("PasswordGeneration.SubmissionEvent", event, - SUBMISSION_EVENT_ENUM_COUNT); + base::UmaHistogramEnumeration("PasswordGeneration.SubmissionEvent", event, + SUBMISSION_EVENT_ENUM_COUNT); } void LogPasswordGenerationAvailableSubmissionEvent( PasswordSubmissionEvent event) { - UMA_HISTOGRAM_ENUMERATION("PasswordGeneration.SubmissionAvailableEvent", - event, SUBMISSION_EVENT_ENUM_COUNT); + base::UmaHistogramEnumeration("PasswordGeneration.SubmissionAvailableEvent", + event, SUBMISSION_EVENT_ENUM_COUNT); } void LogAutoSigninPromoUserAction(AutoSigninPromoUserAction action) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.AutoSigninFirstRunDialog", action, - AUTO_SIGNIN_PROMO_ACTION_COUNT); + base::UmaHistogramEnumeration("PasswordManager.AutoSigninFirstRunDialog", + action, AUTO_SIGNIN_PROMO_ACTION_COUNT); } void LogAccountChooserUserActionOneAccount(AccountChooserUserAction action) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialogOneAccount", - action, ACCOUNT_CHOOSER_ACTION_COUNT); + base::UmaHistogramEnumeration( + "PasswordManager.AccountChooserDialogOneAccount", action, + ACCOUNT_CHOOSER_ACTION_COUNT); } void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.AccountChooserDialogMultipleAccounts", action, ACCOUNT_CHOOSER_ACTION_COUNT); } void LogShouldBlockPasswordForSameOriginButDifferentScheme(bool should_block) { - UMA_HISTOGRAM_BOOLEAN( + base::UmaHistogramBoolean( "PasswordManager.ShouldBlockPasswordForSameOriginButDifferentScheme", should_block); } void LogCountHttpMigratedPasswords(int count) { - UMA_HISTOGRAM_COUNTS_100("PasswordManager.HttpPasswordMigrationCount", count); + base::UmaHistogramCounts100("PasswordManager.HttpPasswordMigrationCount", + count); } void LogHttpPasswordMigrationMode(HttpPasswordMigrationMode mode) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.HttpPasswordMigrationMode", mode, - HTTP_PASSWORD_MIGRATION_MODE_COUNT); + base::UmaHistogramEnumeration("PasswordManager.HttpPasswordMigrationMode", + mode, HTTP_PASSWORD_MIGRATION_MODE_COUNT); } void LogCredentialManagerGetResult(CredentialManagerGetResult result, CredentialMediationRequirement mediation) { switch (mediation) { case CredentialMediationRequirement::kSilent: - UMA_HISTOGRAM_ENUMERATION("PasswordManager.MediationSilent", result, - CREDENTIAL_MANAGER_GET_COUNT); + base::UmaHistogramEnumeration("PasswordManager.MediationSilent", result, + CREDENTIAL_MANAGER_GET_COUNT); break; case CredentialMediationRequirement::kOptional: - UMA_HISTOGRAM_ENUMERATION("PasswordManager.MediationOptional", result, - CREDENTIAL_MANAGER_GET_COUNT); + base::UmaHistogramEnumeration("PasswordManager.MediationOptional", result, + CREDENTIAL_MANAGER_GET_COUNT); break; case CredentialMediationRequirement::kRequired: - UMA_HISTOGRAM_ENUMERATION("PasswordManager.MediationRequired", result, - CREDENTIAL_MANAGER_GET_COUNT); + base::UmaHistogramEnumeration("PasswordManager.MediationRequired", result, + CREDENTIAL_MANAGER_GET_COUNT); break; } } @@ -139,85 +138,93 @@ int number_matches, bool password_field_detected, PasswordType reused_password_type) { - UMA_HISTOGRAM_COUNTS_100("PasswordManager.PasswordReuse.PasswordLength", - password_length); - UMA_HISTOGRAM_COUNTS_1000("PasswordManager.PasswordReuse.TotalPasswords", - saved_passwords); - UMA_HISTOGRAM_COUNTS_1000("PasswordManager.PasswordReuse.NumberOfMatches", - number_matches); - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramCounts100("PasswordManager.PasswordReuse.PasswordLength", + password_length); + base::UmaHistogramCounts1000("PasswordManager.PasswordReuse.TotalPasswords", + saved_passwords); + base::UmaHistogramCounts1000("PasswordManager.PasswordReuse.NumberOfMatches", + number_matches); + base::UmaHistogramEnumeration( "PasswordManager.PasswordReuse.PasswordFieldDetected", password_field_detected ? HAS_PASSWORD_FIELD : NO_PASSWORD_FIELD, PASSWORD_REUSE_PASSWORD_FIELD_DETECTED_COUNT); - UMA_HISTOGRAM_ENUMERATION("PasswordManager.ReusedPasswordType", - reused_password_type, - PasswordType::PASSWORD_TYPE_COUNT); + base::UmaHistogramEnumeration("PasswordManager.ReusedPasswordType", + reused_password_type, + PasswordType::PASSWORD_TYPE_COUNT); } void LogContextOfShowAllSavedPasswordsShown( ShowAllSavedPasswordsContext context) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.ShowAllSavedPasswordsShownContext", - context, SHOW_ALL_SAVED_PASSWORDS_CONTEXT_COUNT); + base::UmaHistogramEnumeration( + "PasswordManager.ShowAllSavedPasswordsShownContext", context, + SHOW_ALL_SAVED_PASSWORDS_CONTEXT_COUNT); } void LogContextOfShowAllSavedPasswordsAccepted( ShowAllSavedPasswordsContext context) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.ShowAllSavedPasswordsAcceptedContext", context, SHOW_ALL_SAVED_PASSWORDS_CONTEXT_COUNT); } -void LogPasswordDropdownShown(PasswordDropdownState state) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.PasswordDropdownShown", state); +void LogPasswordDropdownShown(PasswordDropdownState state, + bool off_the_record) { + base::UmaHistogramEnumeration("PasswordManager.PasswordDropdownShown", state); + + base::UmaHistogramBoolean("PasswordManager.DropdownShown.OffTheRecord", + off_the_record); } -void LogPasswordDropdownItemSelected(PasswordDropdownSelectedOption type) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.PasswordDropdownItemSelected", - type); +void LogPasswordDropdownItemSelected(PasswordDropdownSelectedOption type, + bool off_the_record) { + base::UmaHistogramEnumeration("PasswordManager.PasswordDropdownItemSelected", + type); + base::UmaHistogramBoolean("PasswordManager.ItemSelected.OffTheRecord", + off_the_record); } void LogPasswordSuccessfulSubmissionIndicatorEvent( autofill::mojom::SubmissionIndicatorEvent event) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.SuccessfulSubmissionIndicatorEvent", event); } void LogPasswordAcceptedSaveUpdateSubmissionIndicatorEvent( autofill::mojom::SubmissionIndicatorEvent event) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.AcceptedSaveUpdateSubmissionIndicatorEvent", event); } void LogSubmittedFormFrame(SubmittedFormFrame frame) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.SubmittedFormFrame", frame, - SubmittedFormFrame::SUBMITTED_FORM_FRAME_COUNT); + base::UmaHistogramEnumeration("PasswordManager.SubmittedFormFrame", frame, + SubmittedFormFrame::SUBMITTED_FORM_FRAME_COUNT); } void LogDeleteUndecryptableLoginsReturnValue( DeleteCorruptedPasswordsResult result) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.DeleteUndecryptableLoginsReturnValue", result); } void LogDeleteCorruptedPasswordsResult(DeleteCorruptedPasswordsResult result) { - UMA_HISTOGRAM_ENUMERATION("PasswordManager.DeleteCorruptedPasswordsResult", - result); + base::UmaHistogramEnumeration( + "PasswordManager.DeleteCorruptedPasswordsResult", result); } #if defined(SYNC_PASSWORD_REUSE_DETECTION_ENABLED) void LogSyncPasswordHashChange(SyncPasswordHashChange event) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.SyncPasswordHashChange", event, SyncPasswordHashChange::SAVED_SYNC_PASSWORD_CHANGE_COUNT); } void LogIsSyncPasswordHashSaved(IsSyncPasswordHashSaved state, bool is_under_advanced_protection) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.IsSyncPasswordHashSaved", state, IsSyncPasswordHashSaved::IS_SYNC_PASSWORD_HASH_SAVED_COUNT); if (is_under_advanced_protection) { - UMA_HISTOGRAM_ENUMERATION( + base::UmaHistogramEnumeration( "PasswordManager.IsSyncPasswordHashSavedForAdvancedProtectionUser", state, IsSyncPasswordHashSaved::IS_SYNC_PASSWORD_HASH_SAVED_COUNT); } @@ -225,10 +232,11 @@ void LogProtectedPasswordHashCounts(size_t gaia_hash_count, size_t enterprise_hash_count) { - UMA_HISTOGRAM_COUNTS_100("PasswordManager.SavedGaiaPasswordHashCount", - static_cast<int>(gaia_hash_count)); - UMA_HISTOGRAM_COUNTS_100("PasswordManager.SavedEnterprisePasswordHashCount", - static_cast<int>(enterprise_hash_count)); + base::UmaHistogramCounts100("PasswordManager.SavedGaiaPasswordHashCount", + static_cast<int>(gaia_hash_count)); + base::UmaHistogramCounts100( + "PasswordManager.SavedEnterprisePasswordHashCount", + static_cast<int>(enterprise_hash_count)); } void LogProtectedPasswordReuse(PasswordType reused_password_type) {}
diff --git a/components/password_manager/core/browser/password_manager_metrics_util.h b/components/password_manager/core/browser/password_manager_metrics_util.h index 3e95ec6a..fe1984bd 100644 --- a/components/password_manager/core/browser/password_manager_metrics_util.h +++ b/components/password_manager/core/browser/password_manager_metrics_util.h
@@ -400,10 +400,11 @@ ShowAllSavedPasswordsContext context); // Log the type of the password dropdown when it's shown. -void LogPasswordDropdownShown(PasswordDropdownState state); +void LogPasswordDropdownShown(PasswordDropdownState state, bool off_the_record); // Log the type of the password dropdown suggestion when chosen. -void LogPasswordDropdownItemSelected(PasswordDropdownSelectedOption type); +void LogPasswordDropdownItemSelected(PasswordDropdownSelectedOption type, + bool off_the_record); // Log a password successful submission event. void LogPasswordSuccessfulSubmissionIndicatorEvent(
diff --git a/components/password_manager/core/browser/stub_password_manager_driver.cc b/components/password_manager/core/browser/stub_password_manager_driver.cc index 691c6a9..93c499a 100644 --- a/components/password_manager/core/browser/stub_password_manager_driver.cc +++ b/components/password_manager/core/browser/stub_password_manager_driver.cc
@@ -16,13 +16,6 @@ const autofill::PasswordFormFillData& form_data) { } -void StubPasswordManagerDriver::AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) { -} - -void StubPasswordManagerDriver::FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) {} - void StubPasswordManagerDriver::GeneratedPasswordAccepted( const base::string16& password) { }
diff --git a/components/password_manager/core/browser/stub_password_manager_driver.h b/components/password_manager/core/browser/stub_password_manager_driver.h index b281c5e1..b3e04fb 100644 --- a/components/password_manager/core/browser/stub_password_manager_driver.h +++ b/components/password_manager/core/browser/stub_password_manager_driver.h
@@ -21,10 +21,6 @@ // PasswordManagerDriver: void FillPasswordForm( const autofill::PasswordFormFillData& form_data) override; - void AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) override; - void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) override; void GeneratedPasswordAccepted(const base::string16& password) override; void FillSuggestion(const base::string16& username, const base::string16& password) override;
diff --git a/components/policy/core/common/schema.cc b/components/policy/core/common/schema.cc index 5e7eb49..c9413d1 100644 --- a/components/policy/core/common/schema.cc +++ b/components/policy/core/common/schema.cc
@@ -1370,7 +1370,11 @@ return true; } else if (value->is_list()) { base::Value::ListStorage& list = value->GetList(); - std::vector<size_t> drop_list; // Contains the indexes to drop. + // Instead of removing invalid list items afterwards, we push valid items + // forward in the list by overriding invalid items. The next free position + // is indicated by |write_index|, which gets increased for every valid item. + // At the end |list| is resized to |write_index|'s size. + size_t write_index = 0; for (size_t index = 0; index < list.size(); ++index) { base::Value& list_item = list[index]; std::string new_error; @@ -1385,13 +1389,15 @@ // Invalid list item was detected. if (!StrategyAllowInvalidOnTopLevel(strategy)) return false; - drop_list.push_back(index); + } else { + if (write_index != index) + list[write_index] = std::move(list_item); + ++write_index; } } - if (changed && !drop_list.empty()) + if (changed && write_index < list.size()) *changed = true; - for (size_t drop_index : drop_list) - list.erase(list.begin() + drop_index); + list.resize(write_index); return true; }
diff --git a/components/safe_browsing/BUILD.gn b/components/safe_browsing/BUILD.gn index 7d8a539..c4926a8c 100644 --- a/components/safe_browsing/BUILD.gn +++ b/components/safe_browsing/BUILD.gn
@@ -39,6 +39,7 @@ deps = [ ":features", ":ping_manager", + ":verdict_cache_manager", "//base:base", "//base:i18n", "//components/safe_browsing/common:common", @@ -109,3 +110,37 @@ "//content/public/browser", ] } + +source_set("verdict_cache_manager") { + sources = [ + "verdict_cache_manager.cc", + "verdict_cache_manager.h", + ] + + deps = [ + ":csd_proto", + "//base", + "//components/content_settings/core/browser", + "//components/history/core/browser", + "//components/safe_browsing/db:v4_protocol_manager_util", + "//content/public/browser", + "//url", + ] +} + +source_set("verdict_cache_manager_unittest") { + testonly = true + sources = [ + "verdict_cache_manager_unittest.cc", + ] + + deps = [ + ":csd_proto", + ":verdict_cache_manager", + "//base", + "//components/content_settings/core/browser", + "//components/sync_preferences:test_support", + "//content/test:test_support", + "//testing/gtest", + ] +}
diff --git a/components/safe_browsing/DEPS b/components/safe_browsing/DEPS index 58204e4..46c2a90 100644 --- a/components/safe_browsing/DEPS +++ b/components/safe_browsing/DEPS
@@ -1,7 +1,10 @@ include_rules = [ + "+components/content_settings/core/browser", + "+components/history/core/browser", "+components/security_interstitials/content", "+components/security_interstitials/core", "+components/sync/protocol", + "+components/sync_preferences/testing_pref_service_syncable.h", "+content/public/browser", "+content/public/common", "+content/public/test",
diff --git a/components/safe_browsing/password_protection/BUILD.gn b/components/safe_browsing/password_protection/BUILD.gn index 6025f637..c35f441 100644 --- a/components/safe_browsing/password_protection/BUILD.gn +++ b/components/safe_browsing/password_protection/BUILD.gn
@@ -77,6 +77,7 @@ "//components/password_manager/core/browser:browser", "//components/safe_browsing:csd_proto", "//components/safe_browsing:features", + "//components/safe_browsing:verdict_cache_manager", "//components/safe_browsing/common:interfaces", "//components/safe_browsing/db:test_database_manager", "//components/sync_preferences:test_support",
diff --git a/components/safe_browsing/password_protection/mock_password_protection_service.cc b/components/safe_browsing/password_protection/mock_password_protection_service.cc index 6d17c2d0..4e2f1f5c 100644 --- a/components/safe_browsing/password_protection/mock_password_protection_service.cc +++ b/components/safe_browsing/password_protection/mock_password_protection_service.cc
@@ -11,17 +11,15 @@ namespace safe_browsing { MockPasswordProtectionService::MockPasswordProtectionService() - : PasswordProtectionService(nullptr, nullptr, nullptr, nullptr) {} + : PasswordProtectionService(nullptr, nullptr, nullptr) {} MockPasswordProtectionService::MockPasswordProtectionService( const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - history::HistoryService* history_service, - scoped_refptr<HostContentSettingsMap> content_setting_map) + history::HistoryService* history_service) : PasswordProtectionService(database_manager, url_loader_factory, - history_service, - content_setting_map.get()) {} + history_service) {} MockPasswordProtectionService::~MockPasswordProtectionService() {}
diff --git a/components/safe_browsing/password_protection/mock_password_protection_service.h b/components/safe_browsing/password_protection/mock_password_protection_service.h index 03b2a30..beb74fa 100644 --- a/components/safe_browsing/password_protection/mock_password_protection_service.h +++ b/components/safe_browsing/password_protection/mock_password_protection_service.h
@@ -17,8 +17,7 @@ MockPasswordProtectionService( const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - history::HistoryService* history_service, - scoped_refptr<HostContentSettingsMap> content_setting_map); + history::HistoryService* history_service); ~MockPasswordProtectionService() override; // safe_browsing::PasswordProtectionService
diff --git a/components/safe_browsing/password_protection/password_protection_service.cc b/components/safe_browsing/password_protection/password_protection_service.cc index e00adaa..9d0456a7 100644 --- a/components/safe_browsing/password_protection/password_protection_service.cc +++ b/components/safe_browsing/password_protection/password_protection_service.cc
@@ -47,53 +47,19 @@ namespace { // Keys for storing password protection verdict into a DictionaryValue. -const char kCacheCreationTime[] = "cache_creation_time"; -const char kVerdictProto[] = "verdict_proto"; const int kRequestTimeoutMs = 10000; const char kPasswordProtectionRequestUrl[] = "https://sb-ssl.google.com/safebrowsing/clientreport/login"; -const char kPasswordOnFocusCacheKey[] = "password_on_focus_cache_key"; - -// Helper function to determine if the given origin matches content settings -// map's patterns. -bool OriginMatchPrimaryPattern( - const GURL& origin, - const ContentSettingsPattern& primary_pattern, - const ContentSettingsPattern& secondary_pattern_unused) { - return ContentSettingsPattern::FromURLNoWildcard(origin) == primary_pattern; -} - -// Returns the number of path segments in |cache_expression_path|. -// For example, return 0 for "/", since there is no path after the leading -// slash; return 3 for "/abc/def/gh.html". -size_t GetPathDepth(const std::string& cache_expression_path) { - return base::SplitString(base::StringPiece(cache_expression_path), "/", - base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY) - .size(); -} - -// Given a URL of either http or https scheme, return its http://hostname. -// e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com". -GURL GetHostNameWithHTTPScheme(const GURL& url) { - DCHECK(url.SchemeIsHTTPOrHTTPS()); - std::string result(url::kHttpScheme); - result.append(url::kStandardSchemeSeparator).append(url.host()); - return GURL(result); -} } // namespace PasswordProtectionService::PasswordProtectionService( const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - HistoryService* history_service, - HostContentSettingsMap* host_content_settings_map) - : stored_verdict_count_password_on_focus_(-1), - stored_verdict_count_password_entry_(-1), - database_manager_(database_manager), + HistoryService* history_service) + : database_manager_(database_manager), url_loader_factory_(url_loader_factory), history_service_observer_(this), - content_settings_(host_content_settings_map), weak_factory_(this) { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (history_service) @@ -137,200 +103,21 @@ IsWarningEnabled(); } -// We cache both types of pings under the same content settings type ( -// CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION). Since UNFAMILIAR_LOGIN_PAGE -// verdicts are only enabled on extended reporting users, we cache them one -// layer lower in the content setting DictionaryValue than PASSWORD_REUSE_EVENT -// verdicts. -// In other words, to cache a PASSWORD_REUSE_EVENT verdict we needs three levels -// of keys: (1) origin, (2) password type, (3) cache expression -// returned in verdict. -// To cache a UNFAMILIAR_LOGIN_PAGE, three levels of keys are used: -// (1) origin, (2) 2nd level key is always |kPasswordOnFocusCacheKey|, -// (3) cache expression. LoginReputationClientResponse::VerdictType PasswordProtectionService::GetCachedVerdict( const GURL& url, LoginReputationClientRequest::TriggerType trigger_type, ReusedPasswordType password_type, LoginReputationClientResponse* out_response) { - DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || - trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - - if (!url.is_valid() || !CanGetReputationOfURL(url)) - return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; - - GURL hostname = GetHostNameWithHTTPScheme(url); - std::unique_ptr<base::DictionaryValue> cache_dictionary = - base::DictionaryValue::From(content_settings_->GetWebsiteSetting( - hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, - std::string(), nullptr)); - - if (!cache_dictionary || cache_dictionary->empty()) - return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; - - base::Value* verdict_dictionary = nullptr; - if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { - // All UNFAMILIAR_LOGIN_PAGE verdicts (a.k.a password on focus ping) - // are cached under |kPasswordOnFocusCacheKey|. - verdict_dictionary = cache_dictionary->FindKey(kPasswordOnFocusCacheKey); - if (!verdict_dictionary) - return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; - } else { - verdict_dictionary = - cache_dictionary->FindKey(base::NumberToString(password_type)); - if (!verdict_dictionary) - return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; - } - - std::vector<std::string> paths; - GeneratePathVariantsWithoutQuery(url, &paths); - int max_path_depth = -1; - LoginReputationClientResponse::VerdictType most_matching_verdict = - LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; - // For all the verdicts of the same origin, we key them by |cache_expression|. - // Its corresponding value is a DictionaryValue contains its creation time and - // the serialized verdict proto. - for (const auto& item : verdict_dictionary->DictItems()) { - int verdict_received_time; - LoginReputationClientResponse verdict; - // Ignore any entry that we cannot parse. These invalid entries will be - // cleaned up during shutdown. - if (!ParseVerdictEntry(&item.second, &verdict_received_time, &verdict)) - continue; - // Since password protection content settings are keyed by origin, we only - // need to compare the path part of the cache_expression and the given url. - std::string cache_expression_path = - GetCacheExpressionPath(verdict.cache_expression()); - - // Finds the most specific match. - int path_depth = static_cast<int>(GetPathDepth(cache_expression_path)); - if (path_depth > max_path_depth && - PathVariantsMatchCacheExpression(paths, cache_expression_path)) { - max_path_depth = path_depth; - // If the most matching verdict is expired, set the result to - // VERDICT_TYPE_UNSPECIFIED. - most_matching_verdict = - IsCacheExpired(verdict_received_time, verdict.cache_duration_sec()) - ? LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED - : verdict.verdict_type(); - out_response->CopyFrom(verdict); - } - } - return most_matching_verdict; + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; } void PasswordProtectionService::CacheVerdict( const GURL& url, LoginReputationClientRequest::TriggerType trigger_type, ReusedPasswordType password_type, - LoginReputationClientResponse* verdict, - const base::Time& receive_time) { - DCHECK(verdict); - DCHECK(content_settings_); - DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || - trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - - if (!CanGetReputationOfURL(url) || IsIncognito()) { - return; - } - - GURL hostname = GetHostNameWithHTTPScheme(url); - int* stored_verdict_count = - trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE - ? &stored_verdict_count_password_on_focus_ - : &stored_verdict_count_password_entry_; - std::unique_ptr<base::DictionaryValue> cache_dictionary = - base::DictionaryValue::From(content_settings_->GetWebsiteSetting( - hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, - std::string(), nullptr)); - - if (!cache_dictionary || !cache_dictionary) - cache_dictionary = std::make_unique<base::DictionaryValue>(); - - std::unique_ptr<base::DictionaryValue> verdict_entry( - CreateDictionaryFromVerdict(verdict, receive_time)); - - base::Value* verdict_dictionary = nullptr; - if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { - // All UNFAMILIAR_LOGIN_PAGE verdicts (a.k.a password on focus ping) - // are cached under |kPasswordOnFocusCacheKey|. - verdict_dictionary = cache_dictionary->FindKeyOfType( - kPasswordOnFocusCacheKey, base::Value::Type::DICTIONARY); - if (!verdict_dictionary) { - verdict_dictionary = cache_dictionary->SetKey( - kPasswordOnFocusCacheKey, base::Value(base::Value::Type::DICTIONARY)); - } - } else { - std::string password_type_key = base::NumberToString(password_type); - verdict_dictionary = cache_dictionary->FindKeyOfType( - password_type_key, base::Value::Type::DICTIONARY); - if (!verdict_dictionary) { - verdict_dictionary = cache_dictionary->SetKey( - password_type_key, base::Value(base::Value::Type::DICTIONARY)); - } - } - - // Increases stored verdict count if we haven't seen this cache expression - // before. - if (!verdict_dictionary->FindKey(verdict->cache_expression())) - *stored_verdict_count = GetStoredVerdictCount(trigger_type) + 1; - - // If same cache_expression is already in this verdict_dictionary, we simply - // override it. - verdict_dictionary->SetKey( - verdict->cache_expression(), - base::Value::FromUniquePtrValue(std::move(verdict_entry))); - content_settings_->SetWebsiteSettingDefaultScope( - hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, - std::string(), std::move(cache_dictionary)); -} - -void PasswordProtectionService::CleanUpExpiredVerdicts() { - DCHECK(content_settings_); - - if (GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) <= 0 && - GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT) <= 0) - return; - - ContentSettingsForOneType password_protection_settings; - content_settings_->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - &password_protection_settings); - - for (const ContentSettingPatternSource& source : - password_protection_settings) { - GURL primary_pattern_url = GURL(source.primary_pattern.ToString()); - // Find all verdicts associated with this origin. - std::unique_ptr<base::DictionaryValue> cache_dictionary = - base::DictionaryValue::From(content_settings_->GetWebsiteSetting( - primary_pattern_url, GURL(), - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), nullptr)); - bool has_expired_password_on_focus_entry = RemoveExpiredVerdicts( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - cache_dictionary.get()); - bool has_expired_password_reuse_entry = RemoveExpiredVerdicts( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - cache_dictionary.get()); - - if (cache_dictionary->size() == 0u) { - content_settings_->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, base::Time(), - base::Time::Max(), - base::BindRepeating(&OriginMatchPrimaryPattern, primary_pattern_url)); - } else if (has_expired_password_on_focus_entry || - has_expired_password_reuse_entry) { - // Set the website setting of this origin with the updated - // |cache_dictionary|. - content_settings_->SetWebsiteSettingDefaultScope( - primary_pattern_url, GURL(), - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - std::move(cache_dictionary)); - } - } -} + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) {} void PasswordProtectionService::StartRequest( WebContents* web_contents, @@ -437,9 +224,11 @@ if (response) { if (outcome != RequestOutcome::RESPONSE_ALREADY_CACHED) { - CacheVerdict(request->main_frame_url(), request->trigger_type(), - request->reused_password_type(), response.get(), - base::Time::Now()); + if (response) { + CacheVerdict(request->main_frame_url(), request->trigger_type(), + request->reused_password_type(), *response, + base::Time::Now()); + } } if (ShouldShowModalWarning(request->trigger_type(), request->reused_password_type(), @@ -490,6 +279,11 @@ DCHECK(pending_requests_.empty()); } +int PasswordProtectionService::GetStoredVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type) { + return -1; +} + scoped_refptr<SafeBrowsingDatabaseManager> PasswordProtectionService::database_manager() { return database_manager_; @@ -502,47 +296,6 @@ return url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); } -int PasswordProtectionService::GetStoredVerdictCount( - LoginReputationClientRequest::TriggerType trigger_type) { - DCHECK(content_settings_); - DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || - trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - int* stored_verdict_count = - trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE - ? &stored_verdict_count_password_on_focus_ - : &stored_verdict_count_password_entry_; - // If we have already computed this, return its value. - if (*stored_verdict_count >= 0) - return *stored_verdict_count; - - ContentSettingsForOneType password_protection_settings; - content_settings_->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - &password_protection_settings); - stored_verdict_count_password_on_focus_ = 0; - stored_verdict_count_password_entry_ = 0; - if (password_protection_settings.empty()) - return 0; - - for (const ContentSettingPatternSource& source : - password_protection_settings) { - std::unique_ptr<base::DictionaryValue> cache_dictionary = - base::DictionaryValue::From(content_settings_->GetWebsiteSetting( - GURL(source.primary_pattern.ToString()), GURL(), - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), nullptr)); - if (cache_dictionary.get() && !cache_dictionary->empty()) { - for (const auto& item : cache_dictionary->DictItems()) { - if (item.first == base::StringPiece(kPasswordOnFocusCacheKey)) { - stored_verdict_count_password_on_focus_ += item.second.DictSize(); - } else { - stored_verdict_count_password_entry_ += item.second.DictSize(); - } - } - } - } - return *stored_verdict_count; -} - int PasswordProtectionService::GetRequestTimeoutInMS() { return kRequestTimeoutMs; } @@ -567,12 +320,6 @@ const history::DeletionInfo& deletion_info) { base::PostTaskWithTraits( FROM_HERE, {BrowserThread::UI}, - base::BindRepeating( - &PasswordProtectionService::RemoveContentSettingsOnURLsDeleted, - GetWeakPtr(), deletion_info.IsAllHistory(), - deletion_info.deleted_rows())); - base::PostTaskWithTraits( - FROM_HERE, {BrowserThread::UI}, base::BindRepeating(&PasswordProtectionService:: RemoveUnhandledSyncPasswordReuseOnURLsDeleted, GetWeakPtr(), deletion_info.IsAllHistory(), @@ -584,204 +331,6 @@ history_service_observer_.RemoveAll(); } -void PasswordProtectionService::RemoveContentSettingsOnURLsDeleted( - bool all_history, - const history::URLRows& deleted_rows) { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - DCHECK(content_settings_); - - if (all_history) { - content_settings_->ClearSettingsForOneType( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION); - stored_verdict_count_password_on_focus_ = 0; - stored_verdict_count_password_entry_ = 0; - return; - } - - // For now, if a URL is deleted from history, we simply remove all the - // cached verdicts of the same origin. This is a pretty aggressive deletion. - // We might revisit this logic later to decide if we want to only delete the - // cached verdict whose cache expression matches this URL. - for (const history::URLRow& row : deleted_rows) { - if (!row.url().SchemeIsHTTPOrHTTPS()) - continue; - - GURL url_key = GetHostNameWithHTTPScheme(row.url()); - stored_verdict_count_password_on_focus_ = - GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) - - GetVerdictCountForURL( - url_key, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); - stored_verdict_count_password_entry_ = - GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT) - - GetVerdictCountForURL( - url_key, LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - content_settings_->ClearSettingsForOneTypeWithPredicate( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, base::Time(), - base::Time::Max(), - base::BindRepeating(&OriginMatchPrimaryPattern, url_key)); - } -} - -int PasswordProtectionService::GetVerdictCountForURL( - const GURL& url, - LoginReputationClientRequest::TriggerType trigger_type) { - DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || - trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - std::unique_ptr<base::DictionaryValue> cache_dictionary = - base::DictionaryValue::From(content_settings_->GetWebsiteSetting( - url, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - nullptr)); - if (!cache_dictionary || cache_dictionary->empty()) - return 0; - - int verdict_cnt = 0; - if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { - base::Value* password_on_focus_dict = nullptr; - password_on_focus_dict = - cache_dictionary->FindKey(kPasswordOnFocusCacheKey); - verdict_cnt += - password_on_focus_dict ? password_on_focus_dict->DictSize() : 0; - } else { - for (const auto& item : cache_dictionary->DictItems()) { - if (item.first == kPasswordOnFocusCacheKey) - continue; - verdict_cnt += item.second.DictSize(); - } - } - return verdict_cnt; -} - -bool PasswordProtectionService::RemoveExpiredVerdicts( - LoginReputationClientRequest::TriggerType trigger_type, - base::DictionaryValue* cache_dictionary) { - DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || - trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); - if (!cache_dictionary || cache_dictionary->empty()) - return false; - - size_t verdicts_removed = 0; - std::vector<std::string> empty_keys; - for (auto item : cache_dictionary->DictItems()) { - if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE && - item.first == std::string(kPasswordOnFocusCacheKey)) { - size_t removed_cnt = RemoveExpiredEntries(&item.second); - verdicts_removed += removed_cnt; - stored_verdict_count_password_on_focus_ -= removed_cnt; - } else { - size_t removed_cnt = RemoveExpiredEntries(&item.second); - verdicts_removed += removed_cnt; - stored_verdict_count_password_entry_ -= removed_cnt; - } - - if (item.second.DictSize() == 0U) - empty_keys.push_back(item.first); - } - for (const auto& key : empty_keys) - cache_dictionary->RemoveKey(key); - - return verdicts_removed > 0U; -} - -size_t PasswordProtectionService::RemoveExpiredEntries( - base::Value* verdict_dictionary) { - std::vector<std::string> expired_keys; - for (const auto& item : verdict_dictionary->DictItems()) { - int verdict_received_time; - LoginReputationClientResponse verdict; - if (!PasswordProtectionService::ParseVerdictEntry( - &item.second, &verdict_received_time, &verdict) || - PasswordProtectionService::IsCacheExpired( - verdict_received_time, verdict.cache_duration_sec())) { - expired_keys.push_back(item.first); - } - } - - for (const std::string& key : expired_keys) - verdict_dictionary->RemoveKey(key); - - return expired_keys.size(); -} - -// static -bool PasswordProtectionService::ParseVerdictEntry( - base::Value* verdict_entry, - int* out_verdict_received_time, - LoginReputationClientResponse* out_verdict) { - std::string serialized_verdict_proto; - if (!verdict_entry || !verdict_entry->is_dict() || !out_verdict) - return false; - base::Value* cache_creation_time_value = - verdict_entry->FindKey(kCacheCreationTime); - - if (!cache_creation_time_value || !cache_creation_time_value->is_int()) - return false; - *out_verdict_received_time = cache_creation_time_value->GetInt(); - - base::Value* verdict_proto_value = verdict_entry->FindKey(kVerdictProto); - if (!verdict_proto_value || !verdict_proto_value->is_string()) - return false; - serialized_verdict_proto = verdict_proto_value->GetString(); - - return base::Base64Decode(serialized_verdict_proto, - &serialized_verdict_proto) && - out_verdict->ParseFromString(serialized_verdict_proto); -} - -bool PasswordProtectionService::PathVariantsMatchCacheExpression( - const std::vector<std::string>& generated_paths, - const std::string& cache_expression_path) { - return base::Contains(generated_paths, cache_expression_path); -} - -bool PasswordProtectionService::IsCacheExpired(int cache_creation_time, - int cache_duration) { - // Note that we assume client's clock is accurate or almost accurate. - return base::Time::Now().ToDoubleT() > - static_cast<double>(cache_creation_time + cache_duration); -} - -// Generate path variants of the given URL. -void PasswordProtectionService::GeneratePathVariantsWithoutQuery( - const GURL& url, - std::vector<std::string>* paths) { - std::string canonical_path; - V4ProtocolManagerUtil::CanonicalizeUrl(url, nullptr, &canonical_path, - nullptr); - V4ProtocolManagerUtil::GeneratePathVariantsToCheck(canonical_path, - std::string(), paths); -} - -// Return the path of the cache expression. e.g.: -// "www.google.com" -> "" -// "www.google.com/abc" -> "/abc" -// "foo.com/foo/bar/" -> "/foo/bar/" -std::string PasswordProtectionService::GetCacheExpressionPath( - const std::string& cache_expression) { - DCHECK(!cache_expression.empty()); - size_t first_slash_pos = cache_expression.find_first_of("/"); - if (first_slash_pos == std::string::npos) - return ""; - return cache_expression.substr(first_slash_pos); -} - -// Convert a LoginReputationClientResponse proto into a DictionaryValue. -std::unique_ptr<base::DictionaryValue> -PasswordProtectionService::CreateDictionaryFromVerdict( - const LoginReputationClientResponse* verdict, - const base::Time& receive_time) { - std::unique_ptr<base::DictionaryValue> result = - std::make_unique<base::DictionaryValue>(); - result->SetInteger(kCacheCreationTime, - static_cast<int>(receive_time.ToDoubleT())); - std::string serialized_proto(verdict->SerializeAsString()); - // Performs a base64 encoding on the serialized proto. - base::Base64Encode(serialized_proto, &serialized_proto); - result->SetString(kVerdictProto, serialized_proto); - return result; -} - std::unique_ptr<PasswordProtectionNavigationThrottle> PasswordProtectionService::MaybeCreateNavigationThrottle( content::NavigationHandle* navigation_handle) {
diff --git a/components/safe_browsing/password_protection/password_protection_service.h b/components/safe_browsing/password_protection/password_protection_service.h index 9153dd00..9ecfbd8 100644 --- a/components/safe_browsing/password_protection/password_protection_service.h +++ b/components/safe_browsing/password_protection/password_protection_service.h
@@ -60,12 +60,10 @@ // HostContentSettingsMap instance. class PasswordProtectionService : public history::HistoryServiceObserver { public: - PasswordProtectionService( const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - history::HistoryService* history_service, - HostContentSettingsMap* host_content_settings_map); + history::HistoryService* history_service); ~PasswordProtectionService() override; @@ -76,7 +74,7 @@ // Looks up |settings| to find the cached verdict response. If verdict is not // available or is expired, return VERDICT_TYPE_UNSPECIFIED. Can be called on // any thread. - LoginReputationClientResponse::VerdictType GetCachedVerdict( + virtual LoginReputationClientResponse::VerdictType GetCachedVerdict( const GURL& url, LoginReputationClientRequest::TriggerType trigger_type, ReusedPasswordType password_type, @@ -88,12 +86,9 @@ const GURL& url, LoginReputationClientRequest::TriggerType trigger_type, ReusedPasswordType password_type, - LoginReputationClientResponse* verdict, + const LoginReputationClientResponse& verdict, const base::Time& receive_time); - // Removes all the expired verdicts from cache. - void CleanUpExpiredVerdicts(); - // Creates an instance of PasswordProtectionRequest and call Start() on that // instance. This function also insert this request object in |requests_| for // record keeping. @@ -290,8 +285,6 @@ void CheckCsdWhitelistOnIOThread(const GURL& url, bool* check_result); - HostContentSettingsMap* content_settings() const { return content_settings_; } - void RemoveWarningRequestsByWebContents(content::WebContents* web_contents); bool IsModalWarningShowingInWebContents(content::WebContents* web_contents); @@ -323,51 +316,16 @@ void HistoryServiceBeingDeleted( history::HistoryService* history_service) override; - // Posted to UI thread by OnURLsDeleted(..). This function cleans up password - // protection content settings related to deleted URLs. - void RemoveContentSettingsOnURLsDeleted(bool all_history, - const history::URLRows& deleted_rows); - // Posted to UI thread by OnURLsDeleted(...). This function remove the related // entries in kSafeBrowsingUnhandledSyncPasswordReuses. virtual void RemoveUnhandledSyncPasswordReuseOnURLsDeleted( bool all_history, const history::URLRows& deleted_rows) = 0; - // Helper function called by RemoveContentSettingsOnURLsDeleted(..). It - // calculate the number of verdicts of |type| that associate with |url|. - int GetVerdictCountForURL(const GURL& url, - LoginReputationClientRequest::TriggerType type); - - // Remove verdict of |type| from |cache_dictionary|. Return false if no - // verdict removed, true otherwise. - bool RemoveExpiredVerdicts(LoginReputationClientRequest::TriggerType type, - base::DictionaryValue* cache_dictionary); - - // Helper function called by RemoveExpiredVerdicts(..). Returns the number of - // expired entries removed. - size_t RemoveExpiredEntries(base::Value* verdict_dictionary); - - static bool ParseVerdictEntry(base::Value* verdict_entry, - int* out_verdict_received_time, - LoginReputationClientResponse* out_verdict); - static bool PathVariantsMatchCacheExpression( const std::vector<std::string>& generated_paths, const std::string& cache_expression_path); - static bool IsCacheExpired(int cache_creation_time, int cache_duration); - - static void GeneratePathVariantsWithoutQuery(const GURL& url, - std::vector<std::string>* paths); - - static std::string GetCacheExpressionPath( - const std::string& cache_expression); - - static std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict( - const LoginReputationClientResponse* verdict, - const base::Time& receive_time); - void RecordNoPingingReason( LoginReputationClientRequest::TriggerType trigger_type, RequestOutcome reason, @@ -382,13 +340,6 @@ service_manager::InterfaceProvider* provider, mojom::PhishingDetectorPtr* phishing_detector); - // Number of verdict stored for this profile for password on focus pings. - int stored_verdict_count_password_on_focus_; - - // Number of verdict stored for this profile for protected password entry - // pings. - int stored_verdict_count_password_entry_; - scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; // The context we use to issue network requests. This request_context_getter @@ -406,9 +357,6 @@ ScopedObserver<history::HistoryService, history::HistoryServiceObserver> history_service_observer_; - // Content settings map associated with this instance. - HostContentSettingsMap* content_settings_; - // Weakptr can only cancel task if it is posted to the same thread. Therefore, // we need CancelableTaskTracker to cancel tasks posted to IO thread. base::CancelableTaskTracker tracker_;
diff --git a/components/safe_browsing/password_protection/password_protection_service_unittest.cc b/components/safe_browsing/password_protection/password_protection_service_unittest.cc index 05f503e..a6eb0bf0 100644 --- a/components/safe_browsing/password_protection/password_protection_service_unittest.cc +++ b/components/safe_browsing/password_protection/password_protection_service_unittest.cc
@@ -20,6 +20,7 @@ #include "components/safe_browsing/password_protection/mock_password_protection_service.h" #include "components/safe_browsing/password_protection/password_protection_request.h" #include "components/safe_browsing/proto/csd.pb.h" +#include "components/safe_browsing/verdict_cache_manager.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "content/public/browser/web_contents.h" #include "content/public/test/test_browser_context.h" @@ -101,8 +102,10 @@ scoped_refptr<HostContentSettingsMap> content_setting_map) : MockPasswordProtectionService(database_manager, url_loader_factory, - nullptr, - content_setting_map.get()) {} + nullptr), + cache_manager_( + std::make_unique<VerdictCacheManager>(nullptr, + content_setting_map.get())) {} void RequestFinished( PasswordProtectionRequest* request, @@ -139,11 +142,46 @@ test_api.ClearBinderForName(mojom::PhishingDetector::Name_); } + void CacheVerdict(const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + ReusedPasswordType password_type, + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) override { + if (!CanGetReputationOfURL(url) || IsIncognito()) + return; + + cache_manager_->CachePhishGuardVerdict(url, trigger_type, password_type, + verdict, receive_time); + } + + LoginReputationClientResponse::VerdictType GetCachedVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + LoginReputationClientResponse* out_response) override { + if (!url.is_valid() || !CanGetReputationOfURL(url)) + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + + return cache_manager_->GetCachedPhishGuardVerdict( + url, trigger_type, password_type, out_response); + } + + int GetStoredVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type) override { + return cache_manager_->GetStoredPhishGuardVerdictCount(trigger_type); + } + private: PasswordProtectionRequest* latest_request_; base::RunLoop run_loop_; std::unique_ptr<LoginReputationClientResponse> latest_response_; TestPhishingDetector test_phishing_detector_; + + // The TestPasswordProtectionService manages its own cache, rather than using + // the global one. + std::unique_ptr<VerdictCacheManager> cache_manager_; + DISALLOW_COPY_AND_ASSIGN(TestPasswordProtectionService); }; @@ -190,7 +228,10 @@ url_ = PasswordProtectionService::GetPasswordProtectionRequestUrl(); } - void TearDown() override { content_setting_map_->ShutdownOnUIThread(); } + void TearDown() override { + password_protection_service_.reset(); + content_setting_map_->ShutdownOnUIThread(); + } // Sets up |database_manager_| and |pending_requests_| as needed. void InitializeAndStartPasswordOnFocusRequest( @@ -228,15 +269,6 @@ request_->Start(); } - bool PathVariantsMatchCacheExpression(const GURL& url, - const std::string& cache_expression) { - std::vector<std::string> paths; - PasswordProtectionService::GeneratePathVariantsWithoutQuery(url, &paths); - return PasswordProtectionService::PathVariantsMatchCacheExpression( - paths, - PasswordProtectionService::GetCacheExpressionPath(cache_expression)); - } - void CacheVerdict(const GURL& url, LoginReputationClientRequest::TriggerType trigger, ReusedPasswordType password_type, @@ -247,8 +279,8 @@ ASSERT_FALSE(cache_expression.empty()); LoginReputationClientResponse response( CreateVerdictProto(verdict, cache_duration_sec, cache_expression)); - password_protection_service_->CacheVerdict( - url, trigger, password_type, &response, verdict_received_time); + password_protection_service_->CacheVerdict(url, trigger, password_type, + response, verdict_received_time); } void CacheInvalidVerdict(ReusedPasswordType password_type) { @@ -311,80 +343,6 @@ content::RenderViewHostTestEnabler rvh_test_enabler_; }; -TEST_P(PasswordProtectionServiceTest, TestParseInvalidVerdictEntry) { - std::unique_ptr<base::DictionaryValue> invalid_verdict_entry = - std::make_unique<base::DictionaryValue>(); - invalid_verdict_entry->SetString("cache_creation_time", "invalid_time"); - - int cache_creation_time; - LoginReputationClientResponse response; - // ParseVerdictEntry fails if input is empty. - EXPECT_FALSE(PasswordProtectionService::ParseVerdictEntry( - nullptr, &cache_creation_time, &response)); - - // ParseVerdictEntry fails if the input dict value is invalid. - EXPECT_FALSE(PasswordProtectionService::ParseVerdictEntry( - invalid_verdict_entry.get(), &cache_creation_time, &response)); -} - -TEST_P(PasswordProtectionServiceTest, TestParseValidVerdictEntry) { - base::Time expected_creation_time = base::Time::Now(); - LoginReputationClientResponse expected_verdict(CreateVerdictProto( - LoginReputationClientResponse::SAFE, 10 * kMinute, "test.com/foo")); - std::unique_ptr<base::DictionaryValue> valid_verdict_entry = - PasswordProtectionService::CreateDictionaryFromVerdict( - &expected_verdict, expected_creation_time); - - int actual_cache_creation_time; - LoginReputationClientResponse actual_verdict; - ASSERT_TRUE(PasswordProtectionService::ParseVerdictEntry( - valid_verdict_entry.get(), &actual_cache_creation_time, &actual_verdict)); - - EXPECT_EQ(static_cast<int>(expected_creation_time.ToDoubleT()), - actual_cache_creation_time); - EXPECT_EQ(expected_verdict.cache_duration_sec(), - actual_verdict.cache_duration_sec()); - EXPECT_EQ(expected_verdict.verdict_type(), actual_verdict.verdict_type()); - EXPECT_EQ(expected_verdict.cache_expression(), - actual_verdict.cache_expression()); -} - -TEST_P(PasswordProtectionServiceTest, TestPathVariantsMatchCacheExpression) { - // Cache expression without path. - std::string cache_expression_with_slash("google.com/"); - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("https://www.google.com"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("https://www.google.com"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("https://www.google.com/"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("https://www.google.com/"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("https://www.google.com/maps/local/"), cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("https://www.google.com/maps/local/"), cache_expression_with_slash)); - - // Cache expression with path. - cache_expression_with_slash = "evil.com/bad/"; - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("http://evil.com/bad/"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression(GURL("http://evil.com/bad/"), - cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/bad/index.html"), cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/bad/index.html"), cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/bad/foo/index.html"), cache_expression_with_slash)); - EXPECT_TRUE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/bad/foo/index.html"), cache_expression_with_slash)); - EXPECT_FALSE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/worse/index.html"), cache_expression_with_slash)); - EXPECT_FALSE(PathVariantsMatchCacheExpression( - GURL("http://evil.com/worse/index.html"), cache_expression_with_slash)); -} - TEST_P(PasswordProtectionServiceTest, TestCachePasswordReuseVerdicts) { ASSERT_EQ(0U, GetStoredVerdictCount( LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); @@ -664,84 +622,6 @@ PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, &actual_verdict)); } -TEST_P(PasswordProtectionServiceTest, TestRemoveCachedVerdictOnURLsDeleted) { - ASSERT_EQ(0U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - ASSERT_EQ(0U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); - // Prepare 5 verdicts. Three are for origin "http://foo.com", and the others - // are for "http://bar.com". - base::Time now = base::Time::Now(); - CacheVerdict(GURL("http://foo.com/abc/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::LOW_REPUTATION, 10 * kMinute, - "foo.com/abc/", now); - CacheVerdict(GURL("http://foo.com/abc/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::ENTERPRISE_PASSWORD, - LoginReputationClientResponse::LOW_REPUTATION, 10 * kMinute, - "foo.com/abc/", now); - CacheVerdict(GURL("http://bar.com/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::PHISHING, 10 * kMinute, "bar.com", - now); - ASSERT_EQ(3U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - - CacheVerdict(GURL("http://foo.com/abc/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, - LoginReputationClientResponse::LOW_REPUTATION, 10 * kMinute, - "foo.com/abc/", now); - CacheVerdict(GURL("http://bar.com/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, - LoginReputationClientResponse::PHISHING, 10 * kMinute, "bar.com", - now); - ASSERT_EQ(2U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); - - // Delete a bar.com URL. Corresponding content setting keyed on - // origin "http://bar.com" should be removed, - history::URLRows deleted_urls; - deleted_urls.push_back(history::URLRow(GURL("http://bar.com"))); - - // Delete an arbitrary data URL, to ensure the service is robust against - // filtering only http/s URLs. See crbug.com/709758. - deleted_urls.push_back(history::URLRow(GURL("data:text/html, <p>hellow"))); - - password_protection_service_->RemoveContentSettingsOnURLsDeleted( - false /* all_history */, deleted_urls); - EXPECT_EQ(2U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - EXPECT_EQ(1U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); - - LoginReputationClientResponse actual_verdict; - EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("http://bar.com"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &actual_verdict)); - EXPECT_EQ( - LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("http://bar.com"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, &actual_verdict)); - - // If delete all history. All password protection content settings should be - // gone. - password_protection_service_->RemoveContentSettingsOnURLsDeleted( - true /* all_history */, history::URLRows()); - EXPECT_EQ(0U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - EXPECT_EQ(0U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); -} - TEST_P(PasswordProtectionServiceTest, TestDoesNotCacheAboutBlank) { ASSERT_EQ(0U, GetStoredVerdictCount( LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); @@ -995,115 +875,6 @@ IsEmpty()); } -TEST_P(PasswordProtectionServiceTest, TestCleanUpExpiredVerdict) { - // Prepare 4 verdicts for PASSWORD_REUSE_EVENT with SIGN_IN_PASSWORD type: - // (1) "foo.com/abc/" valid - // (2) "foo.com/def/" expired - // (3) "bar.com/abc/" expired - // (4) "bar.com/def/" expired - base::Time now = base::Time::Now(); - CacheVerdict(GURL("https://foo.com/abc/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::LOW_REPUTATION, 10 * kMinute, - "foo.com/abc/", now); - CacheVerdict(GURL("https://foo.com/def/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::LOW_REPUTATION, 0, "foo.com/def/", - now); - CacheVerdict(GURL("https://bar.com/abc/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::PHISHING, 0, "bar.com/abc/", now); - CacheVerdict(GURL("https://bar.com/def/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, - LoginReputationClientResponse::PHISHING, 0, "bar.com/def/", now); - ASSERT_EQ(4U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - - // Prepare 2 verdicts for UNFAMILIAR_LOGIN_PAGE: - // (1) "bar.com/def/" valid - // (2) "bar.com/xyz/" expired - CacheVerdict(GURL("https://bar.com/def/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, - LoginReputationClientResponse::SAFE, 10 * kMinute, - "bar.com/def/", now); - CacheVerdict(GURL("https://bar.com/xyz/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, - LoginReputationClientResponse::PHISHING, 0, "bar.com/xyz/", now); - ASSERT_EQ(2U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); - - password_protection_service_->CleanUpExpiredVerdicts(); - - ASSERT_EQ(1U, GetStoredVerdictCount( - LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); - ASSERT_EQ(1U, GetStoredVerdictCount( - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); - LoginReputationClientResponse actual_verdict; - // Has cached PASSWORD_REUSE_EVENT verdict for foo.com/abc/. - EXPECT_EQ(LoginReputationClientResponse::LOW_REPUTATION, - password_protection_service_->GetCachedVerdict( - GURL("https://foo.com/abc/test.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &actual_verdict)); - // No cached PASSWORD_REUSE_EVENT verdict for foo.com/def. - EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("https://foo.com/def/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &actual_verdict)); - // No cached PASSWORD_REUSE_EVENT verdict for bar.com/abc. - EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("https://bar.com/abc/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &actual_verdict)); - // No cached PASSWORD_REUSE_EVENT verdict for bar.com/def. - EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("https://bar.com/def/index.jsp"), - LoginReputationClientRequest::PASSWORD_REUSE_EVENT, - PasswordReuseEvent::SIGN_IN_PASSWORD, &actual_verdict)); - - // Has cached UNFAMILIAR_LOGIN_PAGE verdict for bar.com/def. - EXPECT_EQ( - LoginReputationClientResponse::SAFE, - password_protection_service_->GetCachedVerdict( - GURL("https://bar.com/def/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, &actual_verdict)); - - // No cached UNFAMILIAR_LOGIN_PAGE verdict for bar.com/xyz. - EXPECT_EQ( - LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, - password_protection_service_->GetCachedVerdict( - GURL("https://bar.com/xyz/index.jsp"), - LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, - PasswordReuseEvent::REUSED_PASSWORD_TYPE_UNKNOWN, &actual_verdict)); -} - -TEST_P(PasswordProtectionServiceTest, - TestCleanUpExpiredVerdictWithInvalidEntry) { - CacheInvalidVerdict(PasswordReuseEvent::SIGN_IN_PASSWORD); - ContentSettingsForOneType password_protection_settings; - content_setting_map_->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - &password_protection_settings); - ASSERT_FALSE(password_protection_settings.empty()); - - password_protection_service_->CleanUpExpiredVerdicts(); - - content_setting_map_->GetSettingsForOneType( - CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), - &password_protection_settings); - EXPECT_TRUE(password_protection_settings.empty()); -} - TEST_P(PasswordProtectionServiceTest, VerifyPasswordOnFocusRequestProto) { // Set up valid response. LoginReputationClientResponse expected_response =
diff --git a/components/safe_browsing/verdict_cache_manager.cc b/components/safe_browsing/verdict_cache_manager.cc new file mode 100644 index 0000000..c57d056e --- /dev/null +++ b/components/safe_browsing/verdict_cache_manager.cc
@@ -0,0 +1,506 @@ +// Copyright 2019 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/safe_browsing/verdict_cache_manager.h" + +#include "base/base64.h" +#include "base/optional.h" +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" +#include "base/task/post_task.h" +#include "components/history/core/browser/history_service.h" +#include "components/history/core/browser/history_service_observer.h" +#include "components/safe_browsing/db/v4_protocol_manager_util.h" +#include "components/safe_browsing/proto/csd.pb.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" + +namespace safe_browsing { + +namespace { + +// Keys for storing password protection verdict into a DictionaryValue. +const char kCacheCreationTime[] = "cache_creation_time"; +const char kVerdictProto[] = "verdict_proto"; +const char kPasswordOnFocusCacheKey[] = "password_on_focus_cache_key"; + +// Given a URL of either http or https scheme, return its http://hostname. +// e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com". +GURL GetHostNameWithHTTPScheme(const GURL& url) { + DCHECK(url.SchemeIsHTTPOrHTTPS()); + std::string result(url::kHttpScheme); + result.append(url::kStandardSchemeSeparator).append(url.host()); + return GURL(result); +} + +// Convert a LoginReputationClientResponse proto into a DictionaryValue. +std::unique_ptr<base::DictionaryValue> CreateDictionaryFromVerdict( + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) { + std::unique_ptr<base::DictionaryValue> result = + std::make_unique<base::DictionaryValue>(); + result->SetInteger(kCacheCreationTime, + static_cast<int>(receive_time.ToDoubleT())); + std::string serialized_proto(verdict.SerializeAsString()); + // Performs a base64 encoding on the serialized proto. + base::Base64Encode(serialized_proto, &serialized_proto); + result->SetString(kVerdictProto, serialized_proto); + return result; +} + +// Generate path variants of the given URL. +void GeneratePathVariantsWithoutQuery(const GURL& url, + std::vector<std::string>* paths) { + std::string canonical_path; + V4ProtocolManagerUtil::CanonicalizeUrl(url, nullptr, &canonical_path, + nullptr); + V4ProtocolManagerUtil::GeneratePathVariantsToCheck(canonical_path, + std::string(), paths); +} + +bool ParseVerdictEntry(base::Value* verdict_entry, + int* out_verdict_received_time, + LoginReputationClientResponse* out_verdict) { + std::string serialized_verdict_proto; + if (!verdict_entry || !verdict_entry->is_dict() || !out_verdict) + return false; + base::Value* cache_creation_time_value = + verdict_entry->FindKey(kCacheCreationTime); + + if (!cache_creation_time_value || !cache_creation_time_value->is_int()) + return false; + *out_verdict_received_time = cache_creation_time_value->GetInt(); + + base::Value* verdict_proto_value = verdict_entry->FindKey(kVerdictProto); + if (!verdict_proto_value || !verdict_proto_value->is_string()) + return false; + serialized_verdict_proto = verdict_proto_value->GetString(); + + return base::Base64Decode(serialized_verdict_proto, + &serialized_verdict_proto) && + out_verdict->ParseFromString(serialized_verdict_proto); +} + +// Return the path of the cache expression. e.g.: +// "www.google.com" -> "" +// "www.google.com/abc" -> "/abc" +// "foo.com/foo/bar/" -> "/foo/bar/" +std::string GetCacheExpressionPath(const std::string& cache_expression) { + DCHECK(!cache_expression.empty()); + size_t first_slash_pos = cache_expression.find_first_of("/"); + if (first_slash_pos == std::string::npos) + return ""; + return cache_expression.substr(first_slash_pos); +} + +// Returns the number of path segments in |cache_expression_path|. +// For example, return 0 for "/", since there is no path after the leading +// slash; return 3 for "/abc/def/gh.html". +size_t GetPathDepth(const std::string& cache_expression_path) { + return base::SplitString(base::StringPiece(cache_expression_path), "/", + base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY) + .size(); +} + +bool PathVariantsMatchCacheExpression( + const std::vector<std::string>& generated_paths, + const std::string& cache_expression_path) { + return base::Contains(generated_paths, cache_expression_path); +} + +bool IsCacheExpired(int cache_creation_time, int cache_duration) { + // Note that we assume client's clock is accurate or almost accurate. + return base::Time::Now().ToDoubleT() > + static_cast<double>(cache_creation_time + cache_duration); +} + +size_t RemoveExpiredEntries(base::Value* verdict_dictionary) { + std::vector<std::string> expired_keys; + for (const auto& item : verdict_dictionary->DictItems()) { + int verdict_received_time; + LoginReputationClientResponse verdict; + if (!ParseVerdictEntry(&item.second, &verdict_received_time, &verdict) || + IsCacheExpired(verdict_received_time, verdict.cache_duration_sec())) { + expired_keys.push_back(item.first); + } + } + + for (const std::string& key : expired_keys) + verdict_dictionary->RemoveKey(key); + + return expired_keys.size(); +} + +// Helper function to determine if the given origin matches content settings +// map's patterns. +bool OriginMatchPrimaryPattern( + const GURL& origin, + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern_unused) { + return ContentSettingsPattern::FromURLNoWildcard(origin) == primary_pattern; +} + +} // namespace + +VerdictCacheManager::VerdictCacheManager( + history::HistoryService* history_service, + scoped_refptr<HostContentSettingsMap> content_settings) + : stored_verdict_count_password_on_focus_(base::nullopt), + stored_verdict_count_password_entry_(base::nullopt), + history_service_observer_(this), + content_settings_(content_settings), + weak_factory_(this) { + if (history_service) + history_service_observer_.Add(history_service); +} + +VerdictCacheManager::~VerdictCacheManager() { + CleanUpExpiredVerdicts(); + history_service_observer_.RemoveAll(); + weak_factory_.InvalidateWeakPtrs(); +} + +void VerdictCacheManager::CachePhishGuardVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + const LoginReputationClientResponse& verdict, + const base::Time& receive_time) { + DCHECK(content_settings_); + DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || + trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + + GURL hostname = GetHostNameWithHTTPScheme(url); + base::Optional<size_t>* stored_verdict_count = + trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE + ? &stored_verdict_count_password_on_focus_ + : &stored_verdict_count_password_entry_; + std::unique_ptr<base::DictionaryValue> cache_dictionary = + base::DictionaryValue::From(content_settings_->GetWebsiteSetting( + hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, + std::string(), nullptr)); + + if (!cache_dictionary || !cache_dictionary) + cache_dictionary = std::make_unique<base::DictionaryValue>(); + + std::unique_ptr<base::DictionaryValue> verdict_entry( + CreateDictionaryFromVerdict(verdict, receive_time)); + + base::Value* verdict_dictionary = nullptr; + if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { + // All UNFAMILIAR_LOGIN_PAGE verdicts (a.k.a password on focus ping) + // are cached under |kPasswordOnFocusCacheKey|. + verdict_dictionary = cache_dictionary->FindKeyOfType( + kPasswordOnFocusCacheKey, base::Value::Type::DICTIONARY); + if (!verdict_dictionary) { + verdict_dictionary = cache_dictionary->SetKey( + kPasswordOnFocusCacheKey, base::Value(base::Value::Type::DICTIONARY)); + } + } else { + std::string password_type_key = base::NumberToString(password_type); + verdict_dictionary = cache_dictionary->FindKeyOfType( + password_type_key, base::Value::Type::DICTIONARY); + if (!verdict_dictionary) { + verdict_dictionary = cache_dictionary->SetKey( + password_type_key, base::Value(base::Value::Type::DICTIONARY)); + } + } + + // Increases stored verdict count if we haven't seen this cache expression + // before. + if (!verdict_dictionary->FindKey(verdict.cache_expression())) + *stored_verdict_count = GetStoredPhishGuardVerdictCount(trigger_type) + 1; + + // If same cache_expression is already in this verdict_dictionary, we simply + // override it. + verdict_dictionary->SetKey( + verdict.cache_expression(), + base::Value::FromUniquePtrValue(std::move(verdict_entry))); + content_settings_->SetWebsiteSettingDefaultScope( + hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, + std::string(), std::move(cache_dictionary)); +} + +LoginReputationClientResponse::VerdictType +VerdictCacheManager::GetCachedPhishGuardVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + LoginReputationClientResponse* out_response) { + DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || + trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + + GURL hostname = GetHostNameWithHTTPScheme(url); + std::unique_ptr<base::DictionaryValue> cache_dictionary = + base::DictionaryValue::From(content_settings_->GetWebsiteSetting( + hostname, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, + std::string(), nullptr)); + + if (!cache_dictionary || cache_dictionary->empty()) + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + + base::Value* verdict_dictionary = nullptr; + if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { + // All UNFAMILIAR_LOGIN_PAGE verdicts (a.k.a password on focus ping) + // are cached under |kPasswordOnFocusCacheKey|. + verdict_dictionary = cache_dictionary->FindKey(kPasswordOnFocusCacheKey); + if (!verdict_dictionary) + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + } else { + verdict_dictionary = + cache_dictionary->FindKey(base::NumberToString(password_type)); + if (!verdict_dictionary) + return LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + } + + std::vector<std::string> paths; + GeneratePathVariantsWithoutQuery(url, &paths); + int max_path_depth = -1; + LoginReputationClientResponse::VerdictType most_matching_verdict = + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED; + // For all the verdicts of the same origin, we key them by |cache_expression|. + // Its corresponding value is a DictionaryValue contains its creation time and + // the serialized verdict proto. + for (const auto& item : verdict_dictionary->DictItems()) { + int verdict_received_time; + LoginReputationClientResponse verdict; + // Ignore any entry that we cannot parse. These invalid entries will be + // cleaned up during shutdown. + if (!ParseVerdictEntry(&item.second, &verdict_received_time, &verdict)) + continue; + // Since password protection content settings are keyed by origin, we only + // need to compare the path part of the cache_expression and the given url. + std::string cache_expression_path = + GetCacheExpressionPath(verdict.cache_expression()); + + // Finds the most specific match. + int path_depth = static_cast<int>(GetPathDepth(cache_expression_path)); + if (path_depth > max_path_depth && + PathVariantsMatchCacheExpression(paths, cache_expression_path)) { + max_path_depth = path_depth; + // If the most matching verdict is expired, set the result to + // VERDICT_TYPE_UNSPECIFIED. + most_matching_verdict = + IsCacheExpired(verdict_received_time, verdict.cache_duration_sec()) + ? LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED + : verdict.verdict_type(); + out_response->CopyFrom(verdict); + } + } + return most_matching_verdict; +} + +size_t VerdictCacheManager::GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type) { + DCHECK(content_settings_); + DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || + trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + base::Optional<size_t>* stored_verdict_count = + trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE + ? &stored_verdict_count_password_on_focus_ + : &stored_verdict_count_password_entry_; + // If we have already computed this, return its value. + if (stored_verdict_count->has_value()) + return stored_verdict_count->value(); + + ContentSettingsForOneType password_protection_settings; + content_settings_->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + &password_protection_settings); + stored_verdict_count_password_on_focus_ = 0; + stored_verdict_count_password_entry_ = 0; + if (password_protection_settings.empty()) + return 0; + + for (const ContentSettingPatternSource& source : + password_protection_settings) { + std::unique_ptr<base::DictionaryValue> cache_dictionary = + base::DictionaryValue::From(content_settings_->GetWebsiteSetting( + GURL(source.primary_pattern.ToString()), GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), nullptr)); + if (cache_dictionary.get() && !cache_dictionary->empty()) { + for (const auto& item : cache_dictionary->DictItems()) { + if (item.first == base::StringPiece(kPasswordOnFocusCacheKey)) { + stored_verdict_count_password_on_focus_.value() += + item.second.DictSize(); + } else { + stored_verdict_count_password_entry_.value() += + item.second.DictSize(); + } + } + } + } + + return stored_verdict_count->value(); +} + +void VerdictCacheManager::CleanUpExpiredVerdicts() { + DCHECK(content_settings_); + + if (GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) <= 0 && + GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT) <= 0) + return; + + ContentSettingsForOneType password_protection_settings; + content_settings_->GetSettingsForOneType( + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + &password_protection_settings); + + for (const ContentSettingPatternSource& source : + password_protection_settings) { + GURL primary_pattern_url = GURL(source.primary_pattern.ToString()); + // Find all verdicts associated with this origin. + std::unique_ptr<base::DictionaryValue> cache_dictionary = + base::DictionaryValue::From(content_settings_->GetWebsiteSetting( + primary_pattern_url, GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), nullptr)); + bool has_expired_password_on_focus_entry = RemoveExpiredVerdicts( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + cache_dictionary.get()); + bool has_expired_password_reuse_entry = RemoveExpiredVerdicts( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + cache_dictionary.get()); + + if (cache_dictionary->size() == 0u) { + content_settings_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, base::Time(), + base::Time::Max(), + base::BindRepeating(&OriginMatchPrimaryPattern, primary_pattern_url)); + } else if (has_expired_password_on_focus_entry || + has_expired_password_reuse_entry) { + // Set the website setting of this origin with the updated + // |cache_dictionary|. + content_settings_->SetWebsiteSettingDefaultScope( + primary_pattern_url, GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + std::move(cache_dictionary)); + } + } +} + +// Overridden from history::HistoryServiceObserver. +void VerdictCacheManager::OnURLsDeleted( + history::HistoryService* history_service, + const history::DeletionInfo& deletion_info) { + base::PostTaskWithTraits( + FROM_HERE, {content::BrowserThread::UI}, + base::BindRepeating( + &VerdictCacheManager::RemoveContentSettingsOnURLsDeleted, + GetWeakPtr(), deletion_info.IsAllHistory(), + deletion_info.deleted_rows())); +} + +// Overridden from history::HistoryServiceObserver. +void VerdictCacheManager::HistoryServiceBeingDeleted( + history::HistoryService* history_service) { + history_service_observer_.Remove(history_service); +} + +bool VerdictCacheManager::RemoveExpiredVerdicts( + LoginReputationClientRequest::TriggerType trigger_type, + base::DictionaryValue* cache_dictionary) { + DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || + trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + if (!cache_dictionary || cache_dictionary->empty()) + return false; + + size_t verdicts_removed = 0; + std::vector<std::string> empty_keys; + for (auto item : cache_dictionary->DictItems()) { + if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE && + item.first == std::string(kPasswordOnFocusCacheKey)) { + size_t removed_cnt = RemoveExpiredEntries(&item.second); + verdicts_removed += removed_cnt; + if (stored_verdict_count_password_on_focus_.has_value()) + stored_verdict_count_password_on_focus_.value() -= removed_cnt; + } else { + size_t removed_cnt = RemoveExpiredEntries(&item.second); + verdicts_removed += removed_cnt; + if (stored_verdict_count_password_entry_.has_value()) + stored_verdict_count_password_entry_.value() -= removed_cnt; + } + + if (item.second.DictSize() == 0U) + empty_keys.push_back(item.first); + } + for (const auto& key : empty_keys) + cache_dictionary->RemoveKey(key); + + return verdicts_removed > 0U; +} + +void VerdictCacheManager::RemoveContentSettingsOnURLsDeleted( + bool all_history, + const history::URLRows& deleted_rows) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(content_settings_); + + if (all_history) { + content_settings_->ClearSettingsForOneType( + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION); + stored_verdict_count_password_on_focus_ = 0; + stored_verdict_count_password_entry_ = 0; + return; + } + + // For now, if a URL is deleted from history, we simply remove all the + // cached verdicts of the same origin. This is a pretty aggressive deletion. + // We might revisit this logic later to decide if we want to only delete the + // cached verdict whose cache expression matches this URL. + for (const history::URLRow& row : deleted_rows) { + if (!row.url().SchemeIsHTTPOrHTTPS()) + continue; + + GURL url_key = GetHostNameWithHTTPScheme(row.url()); + stored_verdict_count_password_on_focus_ = + GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) - + GetVerdictCountForURL( + url_key, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE); + stored_verdict_count_password_entry_ = + GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT) - + GetVerdictCountForURL( + url_key, LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + content_settings_->ClearSettingsForOneTypeWithPredicate( + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, base::Time(), + base::Time::Max(), + base::BindRepeating(&OriginMatchPrimaryPattern, url_key)); + } +} + +size_t VerdictCacheManager::GetVerdictCountForURL( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type) { + DCHECK(trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE || + trigger_type == LoginReputationClientRequest::PASSWORD_REUSE_EVENT); + std::unique_ptr<base::DictionaryValue> cache_dictionary = + base::DictionaryValue::From(content_settings_->GetWebsiteSetting( + url, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + nullptr)); + if (!cache_dictionary || cache_dictionary->empty()) + return 0; + + int verdict_cnt = 0; + if (trigger_type == LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE) { + base::Value* password_on_focus_dict = nullptr; + password_on_focus_dict = + cache_dictionary->FindKey(kPasswordOnFocusCacheKey); + verdict_cnt += + password_on_focus_dict ? password_on_focus_dict->DictSize() : 0; + } else { + for (const auto& item : cache_dictionary->DictItems()) { + if (item.first == kPasswordOnFocusCacheKey) + continue; + verdict_cnt += item.second.DictSize(); + } + } + return verdict_cnt; +} + +} // namespace safe_browsing
diff --git a/components/safe_browsing/verdict_cache_manager.h b/components/safe_browsing/verdict_cache_manager.h new file mode 100644 index 0000000..7a826bfb --- /dev/null +++ b/components/safe_browsing/verdict_cache_manager.h
@@ -0,0 +1,117 @@ +// Copyright 2019 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_SAFE_BROWSING_VERDICT_CACHE_MANAGER_H_ +#define COMPONENTS_SAFE_BROWSING_VERDICT_CACHE_MANAGER_H_ + +#include "base/gtest_prod_util.h" +#include "base/memory/scoped_refptr.h" +#include "base/memory/weak_ptr.h" +#include "base/scoped_observer.h" +#include "base/time/time.h" +#include "base/values.h" +#include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/history/core/browser/history_service_observer.h" +#include "components/safe_browsing/proto/csd.pb.h" +#include "url/gurl.h" + +namespace history { +class HistoryService; +} + +class HostContentSettingsMap; + +namespace safe_browsing { + +class VerdictCacheManager : public history::HistoryServiceObserver { + public: + explicit VerdictCacheManager( + history::HistoryService* history_service, + scoped_refptr<HostContentSettingsMap> content_settings); + VerdictCacheManager(const VerdictCacheManager&) = delete; + VerdictCacheManager& operator=(const VerdictCacheManager&) = delete; + VerdictCacheManager(VerdictCacheManager&&) = delete; + VerdictCacheManager& operator=(const VerdictCacheManager&&) = delete; + + ~VerdictCacheManager() override; + + base::WeakPtr<VerdictCacheManager> GetWeakPtr() { + return weak_factory_.GetWeakPtr(); + } + + // Stores |verdict| in |settings| based on its |trigger_type|, |url|, + // reused |password_type|, |verdict| and |receive_time|. + void CachePhishGuardVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + const LoginReputationClientResponse& verdict, + const base::Time& receive_time); + + // Looks up |settings| to find the cached verdict response. If verdict is not + // available or is expired, return VERDICT_TYPE_UNSPECIFIED. Can be called on + // any thread. + LoginReputationClientResponse::VerdictType GetCachedPhishGuardVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + LoginReputationClientResponse* out_response); + + // Gets the total number of verdicts of the specified |trigger_type| we cached + // for this profile. This counts both expired and active verdicts. + size_t GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::TriggerType trigger_type); + + // Overridden from history::HistoryServiceObserver. + void OnURLsDeleted(history::HistoryService* history_service, + const history::DeletionInfo& deletion_info) override; + + void HistoryServiceBeingDeleted( + history::HistoryService* history_service) override; + + private: + FRIEND_TEST_ALL_PREFIXES(VerdictCacheManagerTest, TestCleanUpExpiredVerdict); + FRIEND_TEST_ALL_PREFIXES(VerdictCacheManagerTest, + TestCleanUpExpiredVerdictWithInvalidEntry); + FRIEND_TEST_ALL_PREFIXES(VerdictCacheManagerTest, + TestRemoveCachedVerdictOnURLsDeleted); + + // Removes all the expired verdicts from cache. + void CleanUpExpiredVerdicts(); + + // Helper method to remove content settings when URLs are deleted. If + // |all_history| is true, removes all cached verdicts. Otherwise it removes + // all verdicts associated with the deleted URLs in |deleted_rows|. + void RemoveContentSettingsOnURLsDeleted(bool all_history, + const history::URLRows& deleted_rows); + + bool RemoveExpiredVerdicts( + LoginReputationClientRequest::TriggerType trigger_type, + base::DictionaryValue* cache_dictionary); + + size_t GetVerdictCountForURL( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger_type); + + // Number of verdict stored for this profile for password on focus pings. + base::Optional<size_t> stored_verdict_count_password_on_focus_; + + // Number of verdict stored for this profile for protected password entry + // pings. + base::Optional<size_t> stored_verdict_count_password_entry_; + + ScopedObserver<history::HistoryService, history::HistoryServiceObserver> + history_service_observer_; + + // Content settings maps associated with this instance. + scoped_refptr<HostContentSettingsMap> content_settings_; + + base::WeakPtrFactory<VerdictCacheManager> weak_factory_; +}; + +} // namespace safe_browsing + +#endif // COMPONENTS_SAFE_BROWSING_VERDICT_CACHE_MANAGER_H_
diff --git a/components/safe_browsing/verdict_cache_manager_unittest.cc b/components/safe_browsing/verdict_cache_manager_unittest.cc new file mode 100644 index 0000000..3c407602 --- /dev/null +++ b/components/safe_browsing/verdict_cache_manager_unittest.cc
@@ -0,0 +1,455 @@ +// Copyright 2019 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/safe_browsing/verdict_cache_manager.h" + +#include "base/base64.h" +#include "base/memory/scoped_refptr.h" +#include "base/values.h" +#include "components/content_settings/core/browser/host_content_settings_map.h" +#include "components/safe_browsing/proto/csd.pb.h" +#include "components/sync_preferences/testing_pref_service_syncable.h" +#include "content/public/test/test_browser_thread_bundle.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace safe_browsing { + +class VerdictCacheManagerTest : public ::testing::Test { + public: + VerdictCacheManagerTest() {} + + void SetUp() override { + HostContentSettingsMap::RegisterProfilePrefs(test_pref_service_.registry()); + content_setting_map_ = new HostContentSettingsMap( + &test_pref_service_, false /* is_off_the_record */, + false /* store_last_modified */, + false /* migrate_requesting_and_top_level_origin_settings */); + cache_manager_ = std::make_unique<VerdictCacheManager>( + nullptr, content_setting_map_.get()); + } + + void TearDown() override { + cache_manager_.reset(); + content_setting_map_->ShutdownOnUIThread(); + } + + void CachePhishGuardVerdict( + const GURL& url, + LoginReputationClientRequest::TriggerType trigger, + LoginReputationClientRequest::PasswordReuseEvent::ReusedPasswordType + password_type, + LoginReputationClientResponse::VerdictType verdict, + int cache_duration_sec, + const std::string& cache_expression, + const base::Time& verdict_received_time) { + ASSERT_FALSE(cache_expression.empty()); + LoginReputationClientResponse response; + response.set_verdict_type(verdict); + response.set_cache_expression(cache_expression); + response.set_cache_duration_sec(cache_duration_sec); + cache_manager_->CachePhishGuardVerdict(url, trigger, password_type, + response, verdict_received_time); + } + + protected: + std::unique_ptr<VerdictCacheManager> cache_manager_; + scoped_refptr<HostContentSettingsMap> content_setting_map_; + + private: + content::TestBrowserThreadBundle thread_bundle_; + sync_preferences::TestingPrefServiceSyncable test_pref_service_; +}; + +TEST_F(VerdictCacheManagerTest, TestCanRetrieveCachedVerdict) { + GURL url("https://www.google.com/"); + + LoginReputationClientResponse cached_verdict; + cached_verdict.set_cache_expression("www.google.com/"); + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + EXPECT_EQ( + LoginReputationClientResponse::SAFE, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); +} + +TEST_F(VerdictCacheManagerTest, TestCacheSplitByTriggerType) { + GURL url("https://www.google.com/"); + + LoginReputationClientResponse cached_verdict; + cached_verdict.set_cache_expression("www.google.com/"); + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); +} + +TEST_F(VerdictCacheManagerTest, TestCacheSplitByPasswordType) { + GURL url("https://www.google.com/"); + + LoginReputationClientResponse cached_verdict; + cached_verdict.set_cache_expression("www.google.com/"); + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent::ENTERPRISE_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); +} + +TEST_F(VerdictCacheManagerTest, TestGetStoredPhishGuardVerdictCount) { + GURL url("https://www.google.com/"); + + LoginReputationClientResponse cached_verdict; + cached_verdict.set_cache_expression("www.google.com/"); + EXPECT_EQ(0u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::ENTERPRISE_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + EXPECT_EQ(1u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::ENTERPRISE_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + EXPECT_EQ(1u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + + CachePhishGuardVerdict( + url, LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::ENTERPRISE_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/path", + base::Time::Now()); + + EXPECT_EQ(2u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); +} + +TEST_F(VerdictCacheManagerTest, TestParseInvalidVerdictEntry) { + // Directly save an invalid cache entry. + LoginReputationClientResponse verdict; + verdict.set_verdict_type(LoginReputationClientResponse::SAFE); + verdict.set_cache_expression("www.google.com/"); + verdict.set_cache_duration_sec(60); + + std::string verdict_serialized; + verdict.SerializeToString(&verdict_serialized); + base::Base64Encode(verdict_serialized, &verdict_serialized); + + auto cache_dictionary = std::make_unique<base::DictionaryValue>(); + auto* verdict_dictionary = + cache_dictionary->SetKey("2", base::Value(base::Value::Type::DICTIONARY)); + auto* verdict_entry = verdict_dictionary->SetKey( + "www.google.com/", base::Value(base::Value::Type::DICTIONARY)); + verdict_entry->SetStringKey("cache_creation_time", "invalid_time"); + verdict_entry->SetStringKey("verdict_proto", verdict_serialized); + + content_setting_map_->SetWebsiteSettingDefaultScope( + GURL("http://www.google.com/"), GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + std::move(cache_dictionary)); + + LoginReputationClientResponse cached_verdict; + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://www.google.com/"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &cached_verdict)); +} + +TEST_F(VerdictCacheManagerTest, TestRemoveCachedVerdictOnURLsDeleted) { + ASSERT_EQ(0u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + ASSERT_EQ(0u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); + // Prepare 5 verdicts. Three are for origin "http://foo.com", and the others + // are for "http://bar.com". + base::Time now = base::Time::Now(); + CachePhishGuardVerdict( + GURL("http://foo.com/abc/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::LOW_REPUTATION, 600, "foo.com/abc/", now); + CachePhishGuardVerdict( + GURL("http://foo.com/abc/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::ENTERPRISE_PASSWORD, + LoginReputationClientResponse::LOW_REPUTATION, 600, "foo.com/abc/", now); + CachePhishGuardVerdict( + GURL("http://bar.com/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::PHISHING, 600, "bar.com", now); + ASSERT_EQ(3u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + + CachePhishGuardVerdict(GURL("http://foo.com/abc/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + LoginReputationClientResponse::LOW_REPUTATION, 600, + "foo.com/abc/", now); + CachePhishGuardVerdict(GURL("http://bar.com/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + LoginReputationClientResponse::PHISHING, 600, + "bar.com", now); + ASSERT_EQ(2u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); + + // Delete a bar.com URL. Corresponding content setting keyed on + // origin "http://bar.com" should be removed, + history::URLRows deleted_urls; + deleted_urls.push_back(history::URLRow(GURL("http://bar.com"))); + + // Delete an arbitrary data URL, to ensure the service is robust against + // filtering only http/s URLs. See crbug.com/709758. + deleted_urls.push_back(history::URLRow(GURL("data:text/html, <p>hellow"))); + + cache_manager_->RemoveContentSettingsOnURLsDeleted(false /* all_history */, + deleted_urls); + EXPECT_EQ(2u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + EXPECT_EQ(1u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); + + LoginReputationClientResponse actual_verdict; + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("http://bar.com"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &actual_verdict)); + EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("http://bar.com"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + &actual_verdict)); + + // If delete all history. All password protection content settings should be + // gone. + cache_manager_->RemoveContentSettingsOnURLsDeleted(true /* all_history */, + history::URLRows()); + EXPECT_EQ(0u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + EXPECT_EQ(0u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); +} + +TEST_F(VerdictCacheManagerTest, TestCleanUpExpiredVerdict) { + // Prepare 4 verdicts for PASSWORD_REUSE_EVENT with SIGN_IN_PASSWORD type: + // (1) "foo.com/abc/" valid + // (2) "foo.com/def/" expired + // (3) "bar.com/abc/" expired + // (4) "bar.com/def/" expired + base::Time now = base::Time::Now(); + CachePhishGuardVerdict( + GURL("https://foo.com/abc/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::LOW_REPUTATION, 600, "foo.com/abc/", now); + CachePhishGuardVerdict( + GURL("https://foo.com/def/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::LOW_REPUTATION, 0, "foo.com/def/", now); + CachePhishGuardVerdict( + GURL("https://bar.com/abc/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::PHISHING, 0, "bar.com/abc/", now); + CachePhishGuardVerdict( + GURL("https://bar.com/def/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::PHISHING, 0, "bar.com/def/", now); + ASSERT_EQ(4u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + + // Prepare 2 verdicts for UNFAMILIAR_LOGIN_PAGE: + // (1) "bar.com/def/" valid + // (2) "bar.com/xyz/" expired + CachePhishGuardVerdict(GURL("https://bar.com/def/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + LoginReputationClientResponse::SAFE, 600, + "bar.com/def/", now); + CachePhishGuardVerdict(GURL("https://bar.com/xyz/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + LoginReputationClientResponse::PHISHING, 0, + "bar.com/xyz/", now); + ASSERT_EQ(2u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); + + cache_manager_->CleanUpExpiredVerdicts(); + + ASSERT_EQ(1u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::PASSWORD_REUSE_EVENT)); + ASSERT_EQ(1u, cache_manager_->GetStoredPhishGuardVerdictCount( + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE)); + LoginReputationClientResponse actual_verdict; + // Has cached PASSWORD_REUSE_EVENT verdict for foo.com/abc/. + EXPECT_EQ( + LoginReputationClientResponse::LOW_REPUTATION, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://foo.com/abc/test.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &actual_verdict)); + // No cached PASSWORD_REUSE_EVENT verdict for foo.com/def. + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://foo.com/def/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &actual_verdict)); + // No cached PASSWORD_REUSE_EVENT verdict for bar.com/abc. + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://bar.com/abc/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &actual_verdict)); + // No cached PASSWORD_REUSE_EVENT verdict for bar.com/def. + EXPECT_EQ( + LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://bar.com/def/index.jsp"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + &actual_verdict)); + + // Has cached UNFAMILIAR_LOGIN_PAGE verdict for bar.com/def. + EXPECT_EQ(LoginReputationClientResponse::SAFE, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://bar.com/def/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + &actual_verdict)); + + // No cached UNFAMILIAR_LOGIN_PAGE verdict for bar.com/xyz. + EXPECT_EQ(LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED, + cache_manager_->GetCachedPhishGuardVerdict( + GURL("https://bar.com/xyz/index.jsp"), + LoginReputationClientRequest::UNFAMILIAR_LOGIN_PAGE, + LoginReputationClientRequest::PasswordReuseEvent:: + REUSED_PASSWORD_TYPE_UNKNOWN, + &actual_verdict)); +} + +TEST_F(VerdictCacheManagerTest, TestCleanUpExpiredVerdictWithInvalidEntry) { + // Directly save an invalid cache entry. + LoginReputationClientResponse verdict; + verdict.set_verdict_type(LoginReputationClientResponse::SAFE); + verdict.set_cache_expression("www.google.com/"); + verdict.set_cache_duration_sec(60); + + std::string verdict_serialized; + verdict.SerializeToString(&verdict_serialized); + base::Base64Encode(verdict_serialized, &verdict_serialized); + + auto cache_dictionary = std::make_unique<base::DictionaryValue>(); + auto* verdict_dictionary = + cache_dictionary->SetKey("2", base::Value(base::Value::Type::DICTIONARY)); + auto* verdict_entry = verdict_dictionary->SetKey( + "www.google.com/path", base::Value(base::Value::Type::DICTIONARY)); + verdict_entry->SetStringKey("cache_creation_time", "invalid_time"); + verdict_entry->SetStringKey("verdict_proto", verdict_serialized); + + content_setting_map_->SetWebsiteSettingDefaultScope( + GURL("http://www.google.com/"), GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, std::string(), + std::move(cache_dictionary)); + + // Save one valid entry + CachePhishGuardVerdict( + GURL("https://www.google.com"), + LoginReputationClientRequest::PASSWORD_REUSE_EVENT, + LoginReputationClientRequest::PasswordReuseEvent::SIGN_IN_PASSWORD, + LoginReputationClientResponse::SAFE, 60, "www.google.com/", + base::Time::Now()); + + // Verify we saved two entries under ReusedPasswordType SIGN_IN_PASSWORD + EXPECT_EQ(2U, + content_setting_map_ + ->GetWebsiteSetting(GURL("http://www.google.com/"), GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, + std::string(), nullptr) + ->FindDictKey("2") + ->DictSize()); + + cache_manager_->CleanUpExpiredVerdicts(); + + // One should have been cleaned up + EXPECT_EQ(1U, + content_setting_map_ + ->GetWebsiteSetting(GURL("http://www.google.com/"), GURL(), + CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, + std::string(), nullptr) + ->FindDictKey("2") + ->DictSize()); +} + +} // namespace safe_browsing
diff --git a/components/signin/core/browser/about_signin_internals.cc b/components/signin/core/browser/about_signin_internals.cc index 03ebfc0..e653933 100644 --- a/components/signin/core/browser/about_signin_internals.cc +++ b/components/signin/core/browser/about_signin_internals.cc
@@ -359,7 +359,7 @@ } void AboutSigninInternals::OnAccessTokenRequested( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) { TokenInfo* token = signin_status_.FindToken(account_id, consumer_id, scopes); @@ -374,7 +374,7 @@ } void AboutSigninInternals::OnAccessTokenRequestCompleted( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes, GoogleServiceAuthError error, @@ -393,7 +393,7 @@ } void AboutSigninInternals::OnRefreshTokenUpdatedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, bool is_refresh_token_valid, const std::string& source) { RefreshTokenEvent event; @@ -407,7 +407,7 @@ } void AboutSigninInternals::OnRefreshTokenRemovedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& source) { RefreshTokenEvent event; event.account_id = account_id; @@ -429,7 +429,7 @@ } void AboutSigninInternals::OnAccessTokenRemovedFromCache( - const std::string& account_id, + const CoreAccountId& account_id, const identity::ScopeSet& scopes) { for (const std::unique_ptr<TokenInfo>& token : signin_status_.token_info_map[account_id]) { @@ -576,7 +576,7 @@ AboutSigninInternals::SigninStatus::~SigninStatus() {} AboutSigninInternals::TokenInfo* AboutSigninInternals::SigninStatus::FindToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) { for (const std::unique_ptr<TokenInfo>& token : token_info_map[account_id]) { @@ -738,7 +738,7 @@ auto refresh_token_events_value = std::make_unique<base::ListValue>(); for (const auto& event : refresh_token_events) { auto entry = std::make_unique<base::DictionaryValue>(); - entry->SetString("accountId", event.account_id); + entry->SetString("accountId", event.account_id.id); entry->SetString("timestamp", base::TimeToISO8601(event.timestamp)); entry->SetString("type", event.GetTypeAsString()); entry->SetString("source", event.source);
diff --git a/components/signin/core/browser/about_signin_internals.h b/components/signin/core/browser/about_signin_internals.h index ccfd208..816e9b9 100644 --- a/components/signin/core/browser/about_signin_internals.h +++ b/components/signin/core/browser/about_signin_internals.h
@@ -131,7 +131,7 @@ std::string GetTypeAsString() const; const base::Time timestamp; - std::string account_id; + CoreAccountId account_id; RefreshTokenEventType type; std::string source; }; @@ -143,7 +143,7 @@ std::vector<TimedSigninStatusValue> timed_signin_fields; // Map account id to tokens associated to the account. - std::map<std::string, std::vector<std::unique_ptr<TokenInfo>>> + std::map<CoreAccountId, std::vector<std::unique_ptr<TokenInfo>>> token_info_map; // All the events that affected the refresh tokens. @@ -152,7 +152,7 @@ SigninStatus(); ~SigninStatus(); - TokenInfo* FindToken(const std::string& account_id, + TokenInfo* FindToken(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes); @@ -183,22 +183,22 @@ }; // IdentityManager::DiagnosticsObserver implementations. - void OnAccessTokenRequested(const std::string& account_id, + void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) override; - void OnAccessTokenRequestCompleted(const std::string& account_id, + void OnAccessTokenRequestCompleted(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes, GoogleServiceAuthError error, base::Time expiration_time) override; - void OnAccessTokenRemovedFromCache(const std::string& account_id, + void OnAccessTokenRemovedFromCache(const CoreAccountId& account_id, const identity::ScopeSet& scopes) override; void OnRefreshTokenUpdatedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, bool is_refresh_token_valid, const std::string& source) override; void OnRefreshTokenRemovedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& source) override; // IdentityManager::Observer implementations.
diff --git a/components/signin/core/browser/account_fetcher_service.cc b/components/signin/core/browser/account_fetcher_service.cc index 47b18aa..f712944 100644 --- a/components/signin/core/browser/account_fetcher_service.cc +++ b/components/signin/core/browser/account_fetcher_service.cc
@@ -34,12 +34,12 @@ const base::TimeDelta kRefreshFromTokenServiceDelay = base::TimeDelta::FromHours(24); -bool AccountSupportsUserInfo(const std::string& account_id) { +bool AccountSupportsUserInfo(const CoreAccountId& account_id) { // Supervised users use a specially scoped token which when used for general // purposes causes the token service to raise spurious auth errors. // TODO(treib): this string is also used in supervised_user_constants.cc. // Should put in a common place. - return account_id != "managed_user@localhost"; + return account_id.id != "managed_user@localhost"; } } // namespace
diff --git a/components/signin/core/browser/account_investigator.cc b/components/signin/core/browser/account_investigator.cc index eaa7f06..9222b36 100644 --- a/components/signin/core/browser/account_investigator.cc +++ b/components/signin/core/browser/account_investigator.cc
@@ -135,12 +135,12 @@ std::transform(std::begin(signed_in_accounts), std::end(signed_in_accounts), std::back_inserter(sorted_ids), [](const ListedAccount& account) { - return std::string(kSignedInHashPrefix) + account.id; + return std::string(kSignedInHashPrefix) + account.id.id; }); std::transform(std::begin(signed_out_accounts), std::end(signed_out_accounts), std::back_inserter(sorted_ids), [](const ListedAccount& account) { - return std::string(kSignedOutHashPrefix) + account.id; + return std::string(kSignedOutHashPrefix) + account.id.id; }); std::sort(sorted_ids.begin(), sorted_ids.end()); std::ostringstream stream;
diff --git a/components/signin/core/browser/account_reconcilor.cc b/components/signin/core/browser/account_reconcilor.cc index 8ba2bb3..c2ffa819 100644 --- a/components/signin/core/browser/account_reconcilor.cc +++ b/components/signin/core/browser/account_reconcilor.cc
@@ -405,8 +405,13 @@ // // Using Unretained is safe here because the CookieManagerService outlives // the AccountReconcilor. + // TODO(triploblastic): Remove this vector once account_reconcilor and + // related classes has been refactored to use CoreAccountId. + std::vector<CoreAccountId> accounts_to_send; + for (const auto& account : parameters.accounts_to_send) + accounts_to_send.push_back(CoreAccountId(account)); identity_manager_->GetAccountsCookieMutator()->SetAccountsInCookie( - parameters.accounts_to_send, delegate_->GetGaiaApiSource(), + accounts_to_send, delegate_->GetGaiaApiSource(), base::BindOnce(&AccountReconcilor::OnSetAccountsInCookieCompleted, base::Unretained(this))); } @@ -885,7 +890,7 @@ } void AccountReconcilor::OnAddAccountToCookieCompleted( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error) { VLOG(1) << "AccountReconcilor::OnAddAccountToCookieCompleted: " << "Account added: " << account_id << ", "
diff --git a/components/signin/core/browser/account_reconcilor.h b/components/signin/core/browser/account_reconcilor.h index 98011378..ba6e9ad6 100644 --- a/components/signin/core/browser/account_reconcilor.h +++ b/components/signin/core/browser/account_reconcilor.h
@@ -301,7 +301,7 @@ const std::vector<std::string>& chrome_accounts, std::vector<gaia::ListedAccount>&& gaia_accounts); - void OnAddAccountToCookieCompleted(const std::string& account_id, + void OnAddAccountToCookieCompleted(const CoreAccountId& account_id, const GoogleServiceAuthError& error); void OnSetAccountsInCookieCompleted(signin::SetAccountsInCookieResult result);
diff --git a/components/signin/core/browser/account_tracker_service.cc b/components/signin/core/browser/account_tracker_service.cc index d704a4b..4c2ed3d 100644 --- a/components/signin/core/browser/account_tracker_service.cc +++ b/components/signin/core/browser/account_tracker_service.cc
@@ -356,7 +356,7 @@ return false; for (const auto& pair : accounts_) { - if (pair.first != pair.second.gaia) + if (pair.first.id != pair.second.gaia) return false; } @@ -377,7 +377,7 @@ // Migration is required if at least one account is not keyed to its // gaia id. - migration_required |= (pair.first != pair.second.gaia); + migration_required |= (pair.first.id != pair.second.gaia); } return migration_required ? MIGRATION_IN_PROGRESS : MIGRATION_DONE;
diff --git a/components/signin/core/browser/gaia_cookie_manager_service.cc b/components/signin/core/browser/gaia_cookie_manager_service.cc index 372b737..3ea3e0a 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service.cc +++ b/components/signin/core/browser/gaia_cookie_manager_service.cc
@@ -164,7 +164,7 @@ GaiaCookieManagerService::GaiaCookieRequest::GaiaCookieRequest( GaiaCookieRequestType request_type, - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback callback) : request_type_(request_type), @@ -181,7 +181,8 @@ GaiaCookieManagerService::GaiaCookieRequest::operator=(GaiaCookieRequest&&) = default; -const std::string GaiaCookieManagerService::GaiaCookieRequest::GetAccountID() { +const CoreAccountId +GaiaCookieManagerService::GaiaCookieRequest::GetAccountID() { DCHECK_EQ(request_type_, GaiaCookieRequestType::ADD_ACCOUNT); DCHECK_EQ(0u, accounts_.size()); return account_id_; @@ -196,7 +197,7 @@ void GaiaCookieManagerService::GaiaCookieRequest:: RunAddAccountToCookieCompletedCallback( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error) { if (add_account_to_cookie_completed_callback_) std::move(add_account_to_cookie_completed_callback_).Run(account_id, error); @@ -205,7 +206,7 @@ // static GaiaCookieManagerService::GaiaCookieRequest GaiaCookieManagerService::GaiaCookieRequest::CreateAddAccountRequest( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback callback) { return GaiaCookieManagerService::GaiaCookieRequest( @@ -518,7 +519,7 @@ } void GaiaCookieManagerService::AddAccountToCookieInternal( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) { DCHECK(!account_id.empty()); @@ -540,7 +541,7 @@ } void GaiaCookieManagerService::AddAccountToCookie( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) { VLOG(1) << "GaiaCookieManagerService::AddAccountToCookie: " << account_id; @@ -550,7 +551,7 @@ } void GaiaCookieManagerService::AddAccountToCookieWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) { @@ -755,7 +756,7 @@ const std::string& uber_token) { if (error != GoogleServiceAuthError::AuthErrorNone()) { // Note that the UberToken fetcher already retries transient errors. - const std::string account_id = requests_.front().GetAccountID(); + const CoreAccountId account_id = requests_.front().GetAccountID(); VLOG(1) << "Failed to retrieve ubertoken" << " account=" << account_id << " error=" << error.ToString(); SignalAddToCookieComplete(requests_.begin(), error); @@ -784,7 +785,7 @@ } void GaiaCookieManagerService::OnMergeSessionSuccess(const std::string& data) { - const std::string account_id = requests_.front().GetAccountID(); + const CoreAccountId account_id = requests_.front().GetAccountID(); VLOG(1) << "MergeSession successful account=" << account_id; DCHECK(requests_.front().request_type() == GaiaCookieRequestType::ADD_ACCOUNT); @@ -802,7 +803,7 @@ const GoogleServiceAuthError& error) { DCHECK(requests_.front().request_type() == GaiaCookieRequestType::ADD_ACCOUNT); - const std::string account_id = requests_.front().GetAccountID(); + const CoreAccountId account_id = requests_.front().GetAccountID(); VLOG(1) << "Failed MergeSession" << " account=" << account_id << " error=" << error.ToString(); if (++fetcher_retries_ < kMaxFetcherRetries && error.IsTransientError()) { @@ -927,7 +928,7 @@ } void GaiaCookieManagerService::StartFetchingUbertoken() { - const std::string account_id = requests_.front().GetAccountID(); + const CoreAccountId account_id = requests_.front().GetAccountID(); VLOG(1) << "GaiaCookieManagerService::StartFetchingUbertoken account_id=" << requests_.front().GetAccountID(); uber_token_fetcher_ = std::make_unique<signin::UbertokenFetcherImpl>(
diff --git a/components/signin/core/browser/gaia_cookie_manager_service.h b/components/signin/core/browser/gaia_cookie_manager_service.h index 2cadfb1..cbeeb58 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service.h +++ b/components/signin/core/browser/gaia_cookie_manager_service.h
@@ -81,7 +81,7 @@ typedef base::OnceCallback<void(signin::SetAccountsInCookieResult)> SetAccountsInCookieCompletedCallback; - typedef base::OnceCallback<void(const std::string&, + typedef base::OnceCallback<void(const CoreAccountId&, const GoogleServiceAuthError&)> AddAccountToCookieCompletedCallback; @@ -104,17 +104,17 @@ } // For use in the Request of type ADD_ACCOUNT which must have exactly one // account_id. - const std::string GetAccountID(); + const CoreAccountId GetAccountID(); gaia::GaiaSource source() const { return source_; } void RunSetAccountsInCookieCompletedCallback( signin::SetAccountsInCookieResult result); void RunAddAccountToCookieCompletedCallback( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error); static GaiaCookieRequest CreateAddAccountRequest( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback callback); static GaiaCookieRequest CreateLogOutRequest(gaia::GaiaSource source); @@ -132,13 +132,13 @@ gaia::GaiaSource source, SetAccountsInCookieCompletedCallback callback); GaiaCookieRequest(GaiaCookieRequestType request_type, - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback callback); GaiaCookieRequestType request_type_; // For use in the request of type ADD_ACCOUNT. - std::string account_id_; + CoreAccountId account_id_; // For use in the request of type SET_ACCOUNT. std::vector<AccountIdGaiaIdPair> accounts_; gaia::GaiaSource source_; @@ -221,11 +221,11 @@ void Shutdown(); void AddAccountToCookie( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback); void AddAccountToCookieWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback); @@ -335,7 +335,7 @@ // Helper method for AddAccountToCookie* methods. void AddAccountToCookieInternal( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback);
diff --git a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc index 60a6773..6babf95 100644 --- a/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc +++ b/components/signin/core/browser/gaia_cookie_manager_service_unittest.cc
@@ -35,6 +35,10 @@ namespace { +const char kAccountId1[] = "acc1@gmail.com"; +const char kAccountId2[] = "acc2@gmail.com"; +const char kAccountId3[] = "acc3@gmail.com"; + using MockAddAccountToCookieCompletedCallback = base::MockCallback< GaiaCookieManagerService::AddAccountToCookieCompletedCallback>; @@ -112,7 +116,10 @@ class GaiaCookieManagerServiceTest : public testing::Test { public: GaiaCookieManagerServiceTest() - : no_error_(GoogleServiceAuthError::NONE), + : account_id1_(kAccountId1), + account_id2_(kAccountId2), + account_id3_(kAccountId3), + no_error_(GoogleServiceAuthError::NONE), error_(GoogleServiceAuthError::SERVICE_ERROR), canceled_(GoogleServiceAuthError::REQUEST_CANCELED) { AccountTrackerService::RegisterPrefs(pref_service_.registry()); @@ -215,6 +222,10 @@ return signin_client_->GetURLLoaderFactory(); } + const CoreAccountId account_id1_; + const CoreAccountId account_id2_; + const CoreAccountId account_id3_; + private: base::test::ScopedTaskEnvironment task_environment_; FakeOAuth2TokenService token_service_; @@ -236,10 +247,9 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc1@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token"); } @@ -252,9 +262,9 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, Run("acc1@gmail.com", error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionFailure(&helper, error()); // Persistent error incurs no further retries. @@ -269,10 +279,9 @@ signin_client()->set_are_signin_cookies_allowed(false); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc1@gmail.com", canceled())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, canceled())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); } @@ -288,10 +297,9 @@ EXPECT_CALL(helper, StartFetchingMergeSession()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc1@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionFailure(&helper, canceled()); DCHECK(helper.is_running()); @@ -313,10 +321,9 @@ EXPECT_CALL(helper, StartFetchingMergeSession()).Times(2); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc1@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionFailure(&helper, canceled()); DCHECK(helper.is_running()); @@ -337,9 +344,9 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, Run("acc1@gmail.com", error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id1_, error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateUbertokenFailure(&helper, error()); } @@ -352,14 +359,12 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1, add_account_to_cookie_completed2; - EXPECT_CALL(add_account_to_cookie_completed1, - Run("acc1@gmail.com", no_error())); - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, no_error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); SimulateMergeSessionSuccess(&helper, "token1"); SimulateMergeSessionSuccess(&helper, "token2"); @@ -373,13 +378,12 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1, add_account_to_cookie_completed2; - EXPECT_CALL(add_account_to_cookie_completed1, Run("acc1@gmail.com", error())); - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); SimulateMergeSessionFailure(&helper, error()); SimulateMergeSessionSuccess(&helper, "token2"); @@ -393,13 +397,12 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1, add_account_to_cookie_completed2; - EXPECT_CALL(add_account_to_cookie_completed1, Run("acc1@gmail.com", error())); - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); SimulateUbertokenFailure(&helper, error()); SimulateMergeSessionSuccess(&helper, "token2"); @@ -414,14 +417,14 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; EXPECT_CALL(add_account_to_cookie_completed, Run(_, no_error())).Times(4); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token1"); - helper.AddAccountToCookie("acc3@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id3_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token2"); @@ -441,10 +444,9 @@ EXPECT_CALL(helper, StartFetchingLogOut()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token1"); @@ -461,10 +463,9 @@ EXPECT_CALL(helper, StartFetchingLogOut()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token1"); @@ -482,10 +483,9 @@ EXPECT_CALL(helper, StartFetchingLogOut()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); @@ -502,15 +502,13 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1, add_account_to_cookie_completed2; - EXPECT_CALL(add_account_to_cookie_completed1, - Run("acc1@gmail.com", no_error())); - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", canceled())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, no_error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, canceled())); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); // The Log Out should prevent this AddAccount from being fetched. - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); @@ -526,10 +524,9 @@ EXPECT_CALL(helper, StartFetchingLogOut()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed; - EXPECT_CALL(add_account_to_cookie_completed, - Run("acc2@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed, Run(account_id2_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed.Get()); SimulateMergeSessionSuccess(&helper, "token1"); @@ -548,17 +545,15 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed2, add_account_to_cookie_completed3; - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", no_error())); - EXPECT_CALL(add_account_to_cookie_completed3, - Run("acc3@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, no_error())); + EXPECT_CALL(add_account_to_cookie_completed3, Run(account_id3_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); SimulateMergeSessionSuccess(&helper, "token1"); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); - helper.AddAccountToCookie("acc3@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id3_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed3.Get()); SimulateLogOutSuccess(&helper); @@ -575,19 +570,17 @@ MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed2, add_account_to_cookie_completed3; - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", no_error())); - EXPECT_CALL(add_account_to_cookie_completed3, - Run("acc3@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, no_error())); + EXPECT_CALL(add_account_to_cookie_completed3, Run(account_id3_, no_error())); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); SimulateMergeSessionSuccess(&helper, "token1"); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); // Second LogOut will never be fetched. helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); - helper.AddAccountToCookie("acc3@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id3_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed3.Get()); SimulateLogOutSuccess(&helper); @@ -601,27 +594,25 @@ // From the first Signin. MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1; - EXPECT_CALL(add_account_to_cookie_completed1, - Run("acc1@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, no_error())); // From the sign out and then re-sign in. EXPECT_CALL(helper, StartFetchingLogOut()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed3; - EXPECT_CALL(add_account_to_cookie_completed3, - Run("acc3@gmail.com", no_error())); + EXPECT_CALL(add_account_to_cookie_completed3, Run(account_id3_, no_error())); // Total sign in 2 times, not enforcing ordered sequences. EXPECT_CALL(helper, StartFetchingUbertoken()).Times(2); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); SimulateMergeSessionSuccess(&helper, "token1"); SimulateLogOutSuccess(&helper); - helper.AddAccountToCookie("acc3@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id3_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed3.Get()); SimulateMergeSessionSuccess(&helper, "token3"); } @@ -633,15 +624,13 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); MockAddAccountToCookieCompletedCallback add_account_to_cookie_completed1, add_account_to_cookie_completed2; - EXPECT_CALL(add_account_to_cookie_completed1, - Run("acc1@gmail.com", no_error())); - EXPECT_CALL(add_account_to_cookie_completed2, - Run("acc2@gmail.com", canceled())); + EXPECT_CALL(add_account_to_cookie_completed1, Run(account_id1_, no_error())); + EXPECT_CALL(add_account_to_cookie_completed2, Run(account_id2_, canceled())); EXPECT_CALL(helper, StartFetchingLogOut()); - helper.AddAccountToCookie("acc1@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id1_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed1.Get()); - helper.AddAccountToCookie("acc2@gmail.com", gaia::GaiaSource::kChrome, + helper.AddAccountToCookie(account_id2_, gaia::GaiaSource::kChrome, add_account_to_cookie_completed2.Get()); helper.LogOutAllAccounts(gaia::GaiaSource::kChrome); @@ -889,7 +878,7 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); helper.AddAccountToCookie( - "acc1@gmail.com", gaia::GaiaSource::kChrome, + account_id1_, gaia::GaiaSource::kChrome, GaiaCookieManagerService::AddAccountToCookieCompletedCallback()); ASSERT_FALSE(IsLoadPending()); @@ -915,7 +904,7 @@ EXPECT_CALL(helper, StartFetchingUbertoken()); helper.AddAccountToCookie( - "acc2@gmail.com", gaia::GaiaSource::kChrome, + account_id2_, gaia::GaiaSource::kChrome, GaiaCookieManagerService::AddAccountToCookieCompletedCallback()); // There is already a ExternalCCResultFetch underway. This will trigger // StartFetchingMergeSession.
diff --git a/components/signin/core/browser/primary_account_manager.cc b/components/signin/core/browser/primary_account_manager.cc index b604a4b..1ce779f 100644 --- a/components/signin/core/browser/primary_account_manager.cc +++ b/components/signin/core/browser/primary_account_manager.cc
@@ -203,7 +203,8 @@ DCHECK(pref_account_id.empty() || pref_account_id == account_id.id) << "account_id=" << account_id << " pref_account_id=" << pref_account_id; authenticated_account_id_ = account_id; - client_->GetPrefs()->SetString(prefs::kGoogleServicesAccountId, account_id); + client_->GetPrefs()->SetString(prefs::kGoogleServicesAccountId, + account_id.id); // This preference is set so that code on I/O thread has access to the // Gaia id of the signed in user. @@ -220,7 +221,7 @@ // user is signed in the corresponding preferences should match. Doing it here // as opposed to on signin allows us to catch the upgrade scenario. client_->GetPrefs()->SetString(prefs::kGoogleServicesLastAccountId, - account_id); + account_id.id); client_->GetPrefs()->SetString(prefs::kGoogleServicesLastUsername, info.email);
diff --git a/components/signin/core/browser/ubertoken_fetcher_impl.cc b/components/signin/core/browser/ubertoken_fetcher_impl.cc index 61501805..c915269 100644 --- a/components/signin/core/browser/ubertoken_fetcher_impl.cc +++ b/components/signin/core/browser/ubertoken_fetcher_impl.cc
@@ -31,7 +31,7 @@ const int UbertokenFetcherImpl::kMaxRetries = 3; UbertokenFetcherImpl::UbertokenFetcherImpl( - const std::string& account_id, + const CoreAccountId& account_id, OAuth2TokenService* token_service, CompletionCallback ubertoken_callback, gaia::GaiaSource source, @@ -47,7 +47,7 @@ is_bound_to_channel_id) {} UbertokenFetcherImpl::UbertokenFetcherImpl( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, OAuth2TokenService* token_service, CompletionCallback ubertoken_callback,
diff --git a/components/signin/core/browser/ubertoken_fetcher_impl.h b/components/signin/core/browser/ubertoken_fetcher_impl.h index 423e675f..ae5a0ee 100644 --- a/components/signin/core/browser/ubertoken_fetcher_impl.h +++ b/components/signin/core/browser/ubertoken_fetcher_impl.h
@@ -51,7 +51,7 @@ // sequentially for |account_id|. Uses a default GaiaAuthFetcherFactory which // returns base GaiaAuthFetcher instances. UbertokenFetcherImpl( - const std::string& account_id, + const CoreAccountId& account_id, OAuth2TokenService* token_service, CompletionCallback ubertoken_callback, gaia::GaiaSource source, @@ -59,13 +59,12 @@ bool is_bound_to_channel_id = true); // Constructs an instance and starts fetching the ubertoken for |account_id|. - UbertokenFetcherImpl( - const std::string& account_id, - const std::string& access_token, - OAuth2TokenService* token_service, - CompletionCallback ubertoken_callback, - GaiaAuthFetcherFactory factory, - bool is_bound_to_channel_id = true); + UbertokenFetcherImpl(const CoreAccountId& account_id, + const std::string& access_token, + OAuth2TokenService* token_service, + CompletionCallback ubertoken_callback, + GaiaAuthFetcherFactory factory, + bool is_bound_to_channel_id = true); ~UbertokenFetcherImpl() override; // Overriden from GaiaAuthConsumer @@ -92,7 +91,7 @@ GaiaAuthFetcherFactory gaia_auth_fetcher_factory_; std::unique_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; std::unique_ptr<OAuth2TokenService::Request> access_token_request_; - std::string account_id_; + CoreAccountId account_id_; std::string access_token_; int retry_number_; base::OneShotTimer retry_timer_;
diff --git a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java index 7d6bb18..4dd17dd2 100644 --- a/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java +++ b/components/test/android/browsertests_apk/src/org/chromium/components_browsertests_apk/ComponentsBrowserTestsApplication.java
@@ -6,7 +6,6 @@ import android.content.Context; -import org.chromium.base.ApplicationStatus; import org.chromium.base.PathUtils; import org.chromium.native_test.NativeBrowserTestApplication; @@ -21,8 +20,6 @@ super.attachBaseContext(base); if (isBrowserProcess()) { - ApplicationStatus.initialize(this); - // Test-only stuff, see also NativeUnitTest.java. PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); }
diff --git a/components/test/data/password_manager/login_db_v24.sql b/components/test/data/password_manager/login_db_v24.sql new file mode 100644 index 0000000..bfca9c6 --- /dev/null +++ b/components/test/data/password_manager/login_db_v24.sql
@@ -0,0 +1,122 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('last_compatible_version','19'); +INSERT INTO "meta" VALUES('version','24'); +CREATE TABLE logins ( +origin_url VARCHAR NOT NULL, +action_url VARCHAR, +username_element VARCHAR, +username_value VARCHAR, +password_element VARCHAR, +password_value BLOB, +submit_element VARCHAR, +signon_realm VARCHAR NOT NULL, +preferred INTEGER NOT NULL, +date_created INTEGER NOT NULL, +blacklisted_by_user INTEGER NOT NULL, +scheme INTEGER NOT NULL, +password_type INTEGER, +times_used INTEGER, +form_data BLOB, +date_synced INTEGER, +display_name VARCHAR, +icon_url VARCHAR, +federation_url VARCHAR, +skip_zero_click INTEGER, +generation_upload_status INTEGER, +possible_username_pairs BLOB, +id INTEGER, +UNIQUE (origin_url, username_element, username_value, password_element, signon_realm), +PRIMARY KEY (id)); +INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,preferred,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs) VALUES( +'https://accounts.google.com/ServiceLogin', /* origin_url */ +'https://accounts.google.com/ServiceLoginAuth', /* action_url */ +'Email', /* username_element */ +'theerikchen', /* username_value */ +'Passwd', /* password_element */ +X'', /* password_value */ +'', /* submit_element */ +'https://accounts.google.com/', /* signon_realm */ +1, /* preferred */ +13047429345000000, /* date_created */ +0, /* blacklisted_by_user */ +0, /* scheme */ +0, /* password_type */ +1, /* times_used */ +X'18000000020000000000000000000000000000000000000000000000', /* form_data */ +0, /* date_synced */ +'', /* display_name */ +'', /* icon_url */ +'', /* federation_url */ +1, /* skip_zero_click */ +0, /* generation_upload_status */ +X'00000000' /* possible_username_pairs */ +); +INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,preferred,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs) VALUES( +'https://accounts.google.com/ServiceLogin', /* origin_url */ +'https://accounts.google.com/ServiceLoginAuth', /* action_url */ +'Email', /* username_element */ +'theerikchen2', /* username_value */ +'Passwd', /* password_element */ +X'', /* password_value */ +'non-empty', /* submit_element */ +'https://accounts.google.com/', /* signon_realm */ +1, /* preferred */ +13047423600000000, /* date_created */ +0, /* blacklisted_by_user */ +0, /* scheme */ +0, /* password_type */ +1, /* times_used */ +X'18000000020000000000000000000000000000000000000000000000', /* form_data */ +0, /* date_synced */ +'', /* display_name */ +'https://www.google.com/icon', /* icon_url */ +'', /* federation_url */ +1, /* skip_zero_click */ +0, /* generation_upload_status */ +X'00000000' /* possible_username_pairs */ +); +INSERT INTO "logins" (origin_url,action_url,username_element,username_value,password_element,password_value,submit_element,signon_realm,preferred,date_created,blacklisted_by_user,scheme,password_type,times_used,form_data,date_synced,display_name,icon_url,federation_url,skip_zero_click,generation_upload_status,possible_username_pairs) VALUES( +'http://example.com', /* origin_url */ +'http://example.com/landing', /* action_url */ +'', /* username_element */ +'user', /* username_value */ +'', /* password_element */ +X'', /* password_value */ +'non-empty', /* submit_element */ +'http://example.com', /* signon_realm */ +1, /* preferred */ +13047423600000000, /* date_created */ +0, /* blacklisted_by_user */ +1, /* scheme */ +0, /* password_type */ +1, /* times_used */ +X'18000000020000000000000000000000000000000000000000000000', /* form_data */ +0, /* date_synced */ +'', /* display_name */ +'https://www.google.com/icon', /* icon_url */ +'', /* federation_url */ +1, /* skip_zero_click */ +0, /* generation_upload_status */ +X'00000000' /* possible_username_pairs */ +); +CREATE INDEX logins_signon ON logins (signon_realm); +CREATE TABLE stats ( +origin_domain VARCHAR NOT NULL, +username_value VARCHAR, +dismissal_count INTEGER, +update_time INTEGER NOT NULL, +UNIQUE(origin_domain, username_value)); +CREATE INDEX stats_origin ON stats(origin_domain); +CREATE TABLE sync_entities_metadata ( + storage_key INTEGER, + metadata VARCHAR NOT NULL, + PRIMARY KEY (storage_key) +); +CREATE TABLE sync_model_metadata ( + id INTEGER, + metadata VARCHAR NOT NULL, + PRIMARY KEY (id) +); +COMMIT;
diff --git a/components/user_manager/fake_user_manager.cc b/components/user_manager/fake_user_manager.cc index ce001af..97883d1 100644 --- a/components/user_manager/fake_user_manager.cc +++ b/components/user_manager/fake_user_manager.cc
@@ -65,6 +65,14 @@ return user; } +const user_manager::User* FakeUserManager::AddPublicAccountUser( + const AccountId& account_id) { + user_manager::User* user = + user_manager::User::CreatePublicAccountUserForTesting(account_id); + users_.push_back(user); + return user; +} + void FakeUserManager::RemoveUserFromList(const AccountId& account_id) { const UserList::iterator it = std::find_if( users_.begin(), users_.end(), [&account_id](const User* user) {
diff --git a/components/user_manager/fake_user_manager.h b/components/user_manager/fake_user_manager.h index dd26835..ea7d0bf 100644 --- a/components/user_manager/fake_user_manager.h +++ b/components/user_manager/fake_user_manager.h
@@ -34,6 +34,11 @@ const User* AddUserWithAffiliation(const AccountId& account_id, bool is_affiliated); + // Create and add a new public account. Created user is not affiliated with + // the domain, that owns the device. + virtual const user_manager::User* AddPublicAccountUser( + const AccountId& account_id); + void set_local_state(PrefService* local_state) { local_state_ = local_state; } // UserManager overrides.
diff --git a/components/viz/service/display_embedder/skia_output_surface_impl.cc b/components/viz/service/display_embedder/skia_output_surface_impl.cc index e9540cfc..6d373c6 100644 --- a/components/viz/service/display_embedder/skia_output_surface_impl.cc +++ b/components/viz/service/display_embedder/skia_output_surface_impl.cc
@@ -529,19 +529,15 @@ bool mipmap, sk_sp<SkColorSpace> color_space) { auto gr_context_thread_safe = impl_on_gpu_->GetGrContextThreadSafeProxy(); - constexpr uint32_t flags = 0; + auto cache_max_resource_bytes = impl_on_gpu_->max_resource_cache_bytes(); // LegacyFontHost will get LCD text and skia figures out what type to use. - SkSurfaceProps surface_props(flags, SkSurfaceProps::kLegacyFontHost_InitType); - int msaa_sample_count = 0; + SkSurfaceProps surface_props(0 /*flags */, + SkSurfaceProps::kLegacyFontHost_InitType); SkColorType color_type = ResourceFormatToClosestSkColorType(true /* gpu_compositing */, format); SkImageInfo image_info = SkImageInfo::Make(surface_size.width(), surface_size.height(), color_type, kPremul_SkAlphaType, std::move(color_space)); - - // TODO(penghuang): Figure out how to choose the right size. - constexpr size_t kCacheMaxResourceBytes = 90 * 1024 * 1024; - GrBackendFormat backend_format; if (!is_using_vulkan_) { const auto* version_info = impl_on_gpu_->gl_version_info(); @@ -557,7 +553,7 @@ #endif } auto characterization = gr_context_thread_safe->createCharacterization( - kCacheMaxResourceBytes, image_info, backend_format, msaa_sample_count, + cache_max_resource_bytes, image_info, backend_format, 0 /* sampleCount */, kTopLeft_GrSurfaceOrigin, surface_props, mipmap); DCHECK(characterization.isValid()); return characterization;
diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc index 95cff29..38e45c1 100644 --- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc +++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.cc
@@ -573,6 +573,7 @@ InitializeForVulkan(); else InitializeForGL(); + max_resource_cache_bytes_ = context_state_->max_resource_cache_bytes(); } SkiaOutputSurfaceImplOnGpu::~SkiaOutputSurfaceImplOnGpu() { @@ -759,13 +760,16 @@ PullTextureUpdates(std::move(sync_tokens)); auto& offscreen = offscreen_surfaces_[id]; - SkSurfaceCharacterization characterization; - if (!offscreen.surface() || - !offscreen.surface()->characterize(&characterization) || - characterization != ddl->characterization()) { + if (!offscreen.surface()) { offscreen.set_surface(SkSurface::MakeRenderTarget( gr_context(), ddl->characterization(), SkBudgeted::kNo)); DCHECK(offscreen.surface()); + } else { +#if DCHECK_IS_ON() + SkSurfaceCharacterization characterization; + DCHECK(offscreen.surface()->characterize(&characterization) && + characterization == ddl->characterization()); +#endif } { base::Optional<gpu::raster::GrShaderCache::ScopedCacheUse> cache_use;
diff --git a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h index 148959f0..a1146d65 100644 --- a/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h +++ b/components/viz/service/display_embedder/skia_output_surface_impl_on_gpu.h
@@ -135,7 +135,7 @@ sk_sp<GrContextThreadSafeProxy> GetGrContextThreadSafeProxy(); const gl::GLVersionInfo* gl_version_info() const { return gl_version_info_; } - + size_t max_resource_cache_bytes() const { return max_resource_cache_bytes_; } void ReleaseImageContexts( std::vector<std::unique_ptr<ImageContext>> image_contexts); @@ -202,6 +202,7 @@ scoped_refptr<gl::GLSurface> gl_surface_; scoped_refptr<gpu::SharedContextState> context_state_; const gl::GLVersionInfo* gl_version_info_ = nullptr; + size_t max_resource_cache_bytes_ = 0u; std::unique_ptr<SkiaOutputDevice> output_device_;
diff --git a/content/DEPS b/content/DEPS index 087194fd..6b12bcdf 100644 --- a/content/DEPS +++ b/content/DEPS
@@ -135,4 +135,9 @@ # (it is part of //components/variations:test_support target). "+components/variations/variations_params_manager.h", ], + + # Dependencies specific for fuzz targets and other fuzzing-related code. + ".*fuzz.*": [ + "+third_party/libFuzzer/src/utils", # This contains FuzzedDataProvider. + ] }
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index cb30b4fb..4f7203c 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -1714,6 +1714,8 @@ "scheduler/browser_ui_thread_scheduler.h", "scheduler/responsiveness/calculator.cc", "scheduler/responsiveness/calculator.h", + "scheduler/responsiveness/jank_monitor.cc", + "scheduler/responsiveness/jank_monitor.h", "scheduler/responsiveness/message_loop_observer.cc", "scheduler/responsiveness/message_loop_observer.h", "scheduler/responsiveness/metric_source.cc",
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index d18d386..3a0d53c 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc
@@ -1514,12 +1514,6 @@ // Android's main message loop is the Java message loop. NOTREACHED(); #else - DCHECK(base::MessageLoopCurrentForUI::IsSet()); - if (parameters_.ui_task) { - base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, - *parameters_.ui_task); - } - base::RunLoop run_loop; parts_->PreDefaultMainMessageLoopRun(run_loop.QuitClosure()); run_loop.Run();
diff --git a/content/browser/renderer_host/input/fling_controller.cc b/content/browser/renderer_host/input/fling_controller.cc index 4131a5f..2fa90a1 100644 --- a/content/browser/renderer_host/input/fling_controller.cc +++ b/content/browser/renderer_host/input/fling_controller.cc
@@ -306,6 +306,7 @@ << "Fling controller doesn't handle flings with source device:" << static_cast<int>(current_fling_parameters_.source_device); } + fling_booster_.ObserveProgressFling(current_fling_parameters_.velocity); } void FlingController::GenerateAndSendFlingEndEvents() {
diff --git a/content/browser/renderer_host/input/fling_controller_unittest.cc b/content/browser/renderer_host/input/fling_controller_unittest.cc index c9f2f2d0..20420789 100644 --- a/content/browser/renderer_host/input/fling_controller_unittest.cc +++ b/content/browser/renderer_host/input/fling_controller_unittest.cc
@@ -531,6 +531,34 @@ EXPECT_GT(fling_controller_->CurrentFlingVelocity().x(), 1000); } +// Ensure that once a fling finishes, the next fling doesn't get boosted. +TEST_P(FlingControllerTest, ControllerDoesntBoostFinishedFling) { + SimulateFlingStart(blink::WebGestureDevice::kTouchscreen, + gfx::Vector2dF(1000, 0)); + EXPECT_TRUE(FlingInProgress()); + AdvanceTime(); + ProgressFling(NowTicks()); + + // Fast forward so that the fling ends. + double time_to_advance_ms = 1000.0; + AdvanceTime(time_to_advance_ms); + ProgressFling(NowTicks()); + ASSERT_EQ(WebInputEvent::kGestureScrollEnd, last_sent_gesture_.GetType()) + << "Unexpected Last Sent Gesture: " + << WebInputEvent::GetName(last_sent_gesture_.GetType()); + EXPECT_EQ(fling_controller_->CurrentFlingVelocity().x(), 0); + EXPECT_FALSE(FlingInProgress()); + + // Now send a new fling that would have been boosted had it occurred during + // the previous fling. Ensure it isn't boosted. + AdvanceTime(); + SimulateFlingCancel(blink::WebGestureDevice::kTouchscreen); + SimulateFlingStart(blink::WebGestureDevice::kTouchscreen, + gfx::Vector2dF(1000, 0), /*wait_before_processing=*/false); + EXPECT_TRUE(FlingInProgress()); + EXPECT_EQ(fling_controller_->CurrentFlingVelocity().x(), 1000); +} + TEST_P(FlingControllerTest, ControllerNotifiesTheClientAfterFlingStart) { SimulateFlingStart(blink::WebGestureDevice::kTouchscreen, gfx::Vector2dF(1000, 0)); @@ -562,8 +590,7 @@ EXPECT_TRUE(FlingInProgress()); EXPECT_EQ(fling_controller_->CurrentFlingVelocity().x(), 2000); - // Now cancel the fling. The GFC won't get suppressed by fling booster since - // autoscroll fling doesn't have boosting. + // Now cancel the fling. SimulateFlingCancel(blink::WebGestureDevice::kSyntheticAutoscroll); EXPECT_FALSE(FlingInProgress()); }
diff --git a/content/browser/scheduler/responsiveness/jank_monitor.cc b/content/browser/scheduler/responsiveness/jank_monitor.cc new file mode 100644 index 0000000..dbfe34f --- /dev/null +++ b/content/browser/scheduler/responsiveness/jank_monitor.cc
@@ -0,0 +1,315 @@ +// Copyright 2019 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/browser/scheduler/responsiveness/jank_monitor.h" + +#include "base/compiler_specific.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" +#include "ui/base/ui_base_features.h" + +namespace content { +namespace responsiveness { + +// Interval of the monitor performing jankiness checks against the watched +// threads. +static constexpr int64_t kMonitorCheckIntervalMs = 500; +// A task running for longer than |kJankThresholdMs| is considered janky. +static constexpr int64_t kJankThresholdMs = 1000; +// The threshold (10 sec) for shutting down the monitor timer, in microseconds. +static constexpr int64_t kInactivityThresholdUs = + 10 * base::TimeTicks::kMicrosecondsPerSecond; + +JankMonitor::Observer::~Observer() = default; + +JankMonitor::JankMonitor() + : timer_running_(false), + janky_task_id_(nullptr), + last_activity_time_us_(0) { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DETACH_FROM_SEQUENCE(monitor_sequence_checker_); +} + +JankMonitor::~JankMonitor() = default; + +void JankMonitor::AddObserver(Observer* observer) { + base::AutoLock auto_lock(observers_lock_); + observers_.AddObserver(observer); +} + +void JankMonitor::RemoveObserver(Observer* observer) { + base::AutoLock auto_lock(observers_lock_); + observers_.RemoveObserver(observer); +} + +void JankMonitor::SetUp() { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + metric_source_ = CreateMetricSource(); + metric_source_->SetUp(); + + monitor_task_runner_ = CreateMonitorTaskRunner(); + ui_thread_exec_state_ = std::make_unique<ThreadExecutionState>(); +} + +void JankMonitor::Destroy() { + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + // This holds a reference to |this| until |metric_source_| finishes async + // shutdown. + base::ScopedClosureRunner finish_destroy_metric_source(base::BindOnce( + &JankMonitor::FinishDestroyMetricSource, base::RetainedRef(this))); + metric_source_->Destroy(std::move(finish_destroy_metric_source)); + + // This holds another reference to |this| until the monitor thread finishes + // shutdown. + monitor_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&JankMonitor::DestroyOnMonitorThread, + base::RetainedRef(this))); +} + +void JankMonitor::FinishDestroyMetricSource() { + // Destruction of MetricSource takes place on the UI thread. + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + + metric_source_ = nullptr; +} + +void JankMonitor::SetUpOnIOThread() { + io_thread_exec_state_ = std::make_unique<ThreadExecutionState>(); +} + +void JankMonitor::TearDownOnUIThread() { + ui_thread_exec_state_ = nullptr; +} + +void JankMonitor::TearDownOnIOThread() { + io_thread_exec_state_ = nullptr; +} + +void JankMonitor::WillRunTaskOnUIThread(const base::PendingTask* task) { + DCHECK(ui_thread_exec_state_); + WillRunTaskOrEvent(ui_thread_exec_state_.get(), task); +} + +void JankMonitor::DidRunTaskOnUIThread(const base::PendingTask* task) { + DCHECK(ui_thread_exec_state_); + DidRunTaskOrEvent(ui_thread_exec_state_.get(), task); +} + +void JankMonitor::WillRunTaskOnIOThread(const base::PendingTask* task) { + DCHECK(io_thread_exec_state_); + WillRunTaskOrEvent(io_thread_exec_state_.get(), task); +} + +void JankMonitor::DidRunTaskOnIOThread(const base::PendingTask* task) { + DCHECK(io_thread_exec_state_); + DidRunTaskOrEvent(io_thread_exec_state_.get(), task); +} + +void JankMonitor::WillRunEventOnUIThread(const void* opaque_identifier) { + DCHECK(ui_thread_exec_state_); + WillRunTaskOrEvent(ui_thread_exec_state_.get(), opaque_identifier); +} + +void JankMonitor::DidRunEventOnUIThread(const void* opaque_identifier) { + DCHECK(ui_thread_exec_state_); + DidRunTaskOrEvent(ui_thread_exec_state_.get(), opaque_identifier); +} + +void JankMonitor::WillRunTaskOrEvent(ThreadExecutionState* thread_exec_state, + const void* opaque_identifier) { + thread_exec_state->WillRunTaskOrEvent(opaque_identifier); + if (!timer_running_) { + monitor_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&JankMonitor::StartTimerIfNecessary, + base::RetainedRef(this))); + } +} + +void JankMonitor::DidRunTaskOrEvent(ThreadExecutionState* thread_exec_state, + const void* opaque_identifier) { + thread_exec_state->DidRunTaskOrEvent(opaque_identifier); + NotifyJankStopIfNecessary(opaque_identifier); + + // This might lead to concurrent writes to |last_activity_time_us_|. Either + // write is fine, and we don't require it to be monotonically increasing. + last_activity_time_us_ = + (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); +} + +void JankMonitor::StartTimerIfNecessary() { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + DCHECK_EQ(timer_.IsRunning(), timer_running_); + + // Already running. Maybe both UI and IO threads saw the timer stopped, and + // one attempt has already succeeded. + if (timer_.IsRunning()) + return; + + static base::TimeDelta monitor_check_interval = + base::TimeDelta::FromMilliseconds(kMonitorCheckIntervalMs); + // RepeatingClosure bound to the timer doesn't hold a ref to |this| because + // the ref will only be released on timer destruction. + timer_.Start(FROM_HERE, monitor_check_interval, + base::BindRepeating(&JankMonitor::OnCheckJankiness, + base::Unretained(this))); + timer_running_ = true; +} + +void JankMonitor::StopTimerIfIdle() { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + DCHECK(timer_.IsRunning()); + + auto now_us = (base::TimeTicks::Now() - base::TimeTicks()).InMicroseconds(); + if (now_us - last_activity_time_us_ < kInactivityThresholdUs) + return; + + timer_.Stop(); + timer_running_ = false; +} + +scoped_refptr<base::SequencedTaskRunner> +JankMonitor::CreateMonitorTaskRunner() { + return base::CreateSequencedTaskRunnerWithTraits({}); +} + +std::unique_ptr<MetricSource> JankMonitor::CreateMetricSource () { + return std::make_unique<MetricSource>(this); +} + +void JankMonitor::DestroyOnMonitorThread() { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + + timer_.AbandonAndStop(); + timer_running_ = false; +} + +bool JankMonitor::timer_running() const { + return timer_running_; +} + +void JankMonitor::OnCheckJankiness() { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + + if (janky_task_id_) { + return; + } + + auto task_id = ui_thread_exec_state_->CheckJankiness(); + if (task_id.has_value()) { + OnJankStarted(*task_id); + return; + } + + DCHECK(!janky_task_id_); + // Jankiness is checked in the order of UI, IO thread. + task_id = io_thread_exec_state_->CheckJankiness(); + if (task_id.has_value()) { + OnJankStarted(*task_id); + return; + } + + DCHECK(!janky_task_id_); + StopTimerIfIdle(); +} + +void JankMonitor::OnJankStarted(const void* opaque_identifier) { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + + janky_task_id_ = opaque_identifier; + + base::AutoLock auto_lock(observers_lock_); + for (Observer& observer : observers_) + observer.OnJankStarted(); +} + +void JankMonitor::OnJankStopped(const void* opaque_identifier) { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + DCHECK_NE(opaque_identifier, nullptr); + if (janky_task_id_ != opaque_identifier) + return; + + janky_task_id_ = nullptr; + + base::AutoLock auto_lock(observers_lock_); + for (Observer& observer : observers_) + observer.OnJankStopped(); +} + +void JankMonitor::NotifyJankStopIfNecessary(const void* opaque_identifier) { + if (LIKELY(!janky_task_id_ || janky_task_id_ != opaque_identifier)) { + // Most tasks are unlikely to be janky. + return; + } + + monitor_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&JankMonitor::OnJankStopped, + base::RetainedRef(this), opaque_identifier)); +} + +JankMonitor::ThreadExecutionState::TaskMetadata::~TaskMetadata() = default; + +JankMonitor::ThreadExecutionState::ThreadExecutionState() { + DETACH_FROM_SEQUENCE(monitor_sequence_checker_); +} + +JankMonitor::ThreadExecutionState::~ThreadExecutionState() = default; + +base::Optional<const void*> +JankMonitor::ThreadExecutionState::CheckJankiness() { + DCHECK_CALLED_ON_VALID_SEQUENCE(monitor_sequence_checker_); + + base::TimeTicks now = base::TimeTicks::Now(); + static base::TimeDelta jank_threshold = + base::TimeDelta::FromMilliseconds(kJankThresholdMs); + + base::AutoLock lock(lock_); + if (LIKELY(task_execution_metadata_.empty() || + (now - task_execution_metadata_.front().execution_start_time) < + jank_threshold)) { + // Most tasks are unlikely to be janky. + return base::nullopt; + } + + // Mark that the target thread is janky and notify the monitor thread. + return task_execution_metadata_.front().identifier; +} + +void JankMonitor::ThreadExecutionState::WillRunTaskOrEvent( + const void* opaque_identifier) { + AssertOnTargetThread(); + + base::TimeTicks now = base::TimeTicks::Now(); + + base::AutoLock lock(lock_); + task_execution_metadata_.emplace_back(now, opaque_identifier); +} + +void JankMonitor::ThreadExecutionState::DidRunTaskOrEvent( + const void* opaque_identifier) { + AssertOnTargetThread(); + + base::AutoLock lock(lock_); + if (UNLIKELY(task_execution_metadata_.empty()) || + opaque_identifier != task_execution_metadata_.back().identifier) { + // Mismatches can happen (e.g: on ozone/wayland when Paste button is pressed + // in context menus, among others). Simply ignore the mismatches for now. + // See https://crbug.com/929813 for the details of why the mismatch + // happens. +#if !defined(OS_CHROMEOS) && defined(OS_LINUX) && defined(USE_OZONE) + task_execution_metadata_.clear(); +#endif + return; + } + + task_execution_metadata_.pop_back(); +} + +void JankMonitor::ThreadExecutionState::AssertOnTargetThread() { + DCHECK_CALLED_ON_VALID_SEQUENCE(target_sequence_checker_); +} + +} // namespace responsiveness. +} // namespace content.
diff --git a/content/browser/scheduler/responsiveness/jank_monitor.h b/content/browser/scheduler/responsiveness/jank_monitor.h new file mode 100644 index 0000000..0d8773e --- /dev/null +++ b/content/browser/scheduler/responsiveness/jank_monitor.h
@@ -0,0 +1,211 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_SCHEDULER_RESPONSIVENESS_JANK_MONITOR_H_ +#define CONTENT_BROWSER_SCHEDULER_RESPONSIVENESS_JANK_MONITOR_H_ + +#include <atomic> + +#include "base/gtest_prod_util.h" +#include "base/observer_list.h" +#include "base/optional.h" +#include "base/sequence_checker.h" +#include "base/synchronization/lock.h" +#include "base/task/post_task.h" +#include "base/threading/thread.h" +#include "base/time/time.h" +#include "base/timer/timer.h" +#include "content/browser/scheduler/responsiveness/metric_source.h" + +namespace content { +namespace responsiveness { +// This class monitors the responsiveness of the browser to notify the presence +// of janks to its observers. A jank is defined as a task or native event +// running for longer than a threshold on the UI or IO thread. An observer of +// this class is notified through the Observer interface on jank starts/stops so +// the observer can take actions (e.g. gather system-wide profile to capture the +// jank) *before* the janky task finishes execution. Notifications are sent on a +// dedicated sequence internal to this class so the observer needs to be careful +// with threading. For example, access to browser-related objects requires +// posting a task to the UI thread. +// +// Internally, a timer (bound to the monitor sequence) is used to perform +// periodic checks to decide the presence of janks. When a jank is detected, the +// monitor notifies its observers that a jank has started (through the +// Observer::OnJankStarted() method). The start of a jank is imprecise w.r.t. +// the jank threshold. When a janky task has finished execution, the monitor +// notifies the observers ASAP (through the Observer::OnJankStopped() method). +// +// Usage example: +// +// class Profiler : public Observer { +// public: +// void OnJankStarted() override; // Start the profiler. +// void OnJankStopped() override; // Stop the profiler. +// } +// Profiler* profiler = ...; +// +// scoped_refptr<JankMonitor> monitor = base::MakeRefCounted<JankMonitor>(); +// monitor->SetUp(); +// monitor->AddObserver(profiler); +// +// (Then start receiving notifications in Profiler::OnJankStarted() and +// Profiler::OnJankStopped()). +class CONTENT_EXPORT JankMonitor + : public base::RefCountedThreadSafe<JankMonitor>, + public content::responsiveness::MetricSource::Delegate { + public: + // Interface for observing janky tasks from the monitor. Note that the + // callbacks are called *off* the UI thread. Post a task to the UI thread is + // necessary if you need to access browser-related objects. + class CONTENT_EXPORT Observer { + public: + virtual ~Observer(); + + virtual void OnJankStarted() = 0; + virtual void OnJankStopped() = 0; + }; + + JankMonitor(); + + void SetUp(); + void Destroy(); + + // AddObserver() and RemoveObserver() can be called on any sequence, but the + // notifications only take place on the monitor sequence. Note: do *not* call + // AddObserver() or RemoveObserver() synchronously in the observer callbacks, + // or undefined behavior will result. + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); + + protected: + friend class base::RefCountedThreadSafe<JankMonitor>; + ~JankMonitor() override; + + // MetricSource::Delegate implementation. + void SetUpOnIOThread() override; + void TearDownOnUIThread() override; + void TearDownOnIOThread() override; + + void WillRunTaskOnUIThread(const base::PendingTask* task) override; + void DidRunTaskOnUIThread(const base::PendingTask* task) override; + + void WillRunTaskOnIOThread(const base::PendingTask* task) override; + void DidRunTaskOnIOThread(const base::PendingTask* task) override; + + void WillRunEventOnUIThread(const void* opaque_identifier) override; + void DidRunEventOnUIThread(const void* opaque_identifier) override; + + // Exposed for tests + virtual void DestroyOnMonitorThread(); + virtual scoped_refptr<base::SequencedTaskRunner> CreateMonitorTaskRunner(); + virtual std::unique_ptr<MetricSource> CreateMetricSource(); + bool timer_running() const; + + private: + FRIEND_TEST_ALL_PREFIXES(JankinessJankMonitorTest, SetUpDestroy); + + class ThreadExecutionState final { + public: + ThreadExecutionState(); + ~ThreadExecutionState(); + + void WillRunTaskOrEvent(const void* opaque_identifier); + void DidRunTaskOrEvent(const void* opaque_identifier); + + // Checks the jankiness of the target thread. Returns the opaque identifier + // of the janky task or base::nullopt if the current task is not janky. + base::Optional<const void*> CheckJankiness(); + void AssertOnTargetThread(); + + private: + // Synchronizes the access between the target thread and the monitor thread. + base::Lock lock_; + + struct TaskMetadata { + TaskMetadata(base::TimeTicks execution_start_time, const void* identifier) + : execution_start_time(execution_start_time), + identifier(identifier) {} + ~TaskMetadata(); + + base::TimeTicks execution_start_time; + const void* identifier; + }; + std::vector<TaskMetadata> task_execution_metadata_; + + // Checks some methods are called on the monitor thread. + SEQUENCE_CHECKER(monitor_sequence_checker_); + // Checks some methods are called on the target thread. + SEQUENCE_CHECKER(target_sequence_checker_); + }; + + void FinishDestroyMetricSource(); + + void AddObserverOnMonitorThread(Observer* observer); + void RemoveObserverOnMonitorThread(Observer* observer); + + void WillRunTaskOrEvent(ThreadExecutionState* thread_exec_state, + const void* opaque_identifier); + void DidRunTaskOrEvent(ThreadExecutionState* thread_exec_state, + const void* opaque_identifier); + + // Called in WillRunTaskOrEvent() to start the timer to monitor janks if + // the timer is not running. + void StartTimerIfNecessary(); + // Stops the timer on inactivity for longer than a threshold. + void StopTimerIfIdle(); + + // Timer callback. + void OnCheckJankiness(); + + // Sends out notifications. + void OnJankStarted(const void* opaque_identifier); + void OnJankStopped(const void* opaque_identifier); + + // Call in DidRunTaskOrEvent() to for notification of jank stops. + void NotifyJankStopIfNecessary(const void* opaque_identifier); + + // The source that emits responsiveness events. + std::unique_ptr<content::responsiveness::MetricSource> metric_source_; + + std::unique_ptr<ThreadExecutionState> ui_thread_exec_state_; + std::unique_ptr<ThreadExecutionState> io_thread_exec_state_; + + // The timer that runs on the monitor sequence to perform periodic check of + // janks. + base::RepeatingTimer timer_; + + // |timer_running_| is equivalent to timer_.IsRunning() except that it is + // thread-safe. It is checked in WillRunTaskOrEvent() (from UI or IO thread) + // to start the timer if necessary. Always updated on the monitor thread to + // mirror the result of timer_.IsRunning(). + std::atomic_bool timer_running_; + + // The opaque identifier of the janky task. Updated on the monitor thread when + // a janky task is detected. Checked when a task finishes running on UI or IO + // thread to notify observers (from the monitor thread) that the jank has + // stopped. + std::atomic<const void*> janky_task_id_; + + // The timestamp of last activity on either UI or IO thread. Checked on the + // monitor thread for stopping the timer on inactivity. Updated on UI or IO + // thread in DidRunTaskOrEvent(). + std::atomic<int64_t> last_activity_time_us_; + + // Use a dedicated sequence for watching jankiness. + scoped_refptr<base::SequencedTaskRunner> monitor_task_runner_; + + // The lock synchronizes access the |observers| from AddObserver(), + // RemoveObserver(), OnJankStarted() and OnJankStopped(). + base::Lock observers_lock_; + base::ObserverList<Observer>::Unchecked observers_; + + // Checks some methods are called on the monitor thread. + SEQUENCE_CHECKER(monitor_sequence_checker_); +}; + +} // namespace responsiveness. +} // namespace content. + +#endif // CONTENT_BROWSER_SCHEDULER_RESPONSIVENESS_JANK_MONITOR_H_
diff --git a/content/browser/scheduler/responsiveness/jank_monitor_unittest.cc b/content/browser/scheduler/responsiveness/jank_monitor_unittest.cc new file mode 100644 index 0000000..a3953d4 --- /dev/null +++ b/content/browser/scheduler/responsiveness/jank_monitor_unittest.cc
@@ -0,0 +1,322 @@ +// Copyright 2019 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/browser/scheduler/responsiveness/jank_monitor.h" + +#include "base/callback.h" +#include "base/test/bind_test_util.h" +#include "base/test/test_mock_time_task_runner.h" +#include "content/browser/scheduler/responsiveness/native_event_observer.h" +#include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace content { +namespace responsiveness { + +class TestObserver : public JankMonitor::Observer { + public: + void OnJankStarted() override { jank_started_called_++; } + void OnJankStopped() override { jank_stopped_called_++; } + + int jank_started_called() { return jank_started_called_; } + int jank_stopped_called() { return jank_stopped_called_; } + + private: + int jank_started_called_ = 0; + int jank_stopped_called_ = 0; +}; + +class TestMetricSource : public MetricSource { + public: + TestMetricSource(Delegate* delegate) + : MetricSource(delegate) {} + ~TestMetricSource() override {} + + std::unique_ptr<NativeEventObserver> CreateNativeEventObserver() override { + return nullptr; + } +}; + +class TestJankMonitor : public JankMonitor { + public: + TestJankMonitor() {} + + bool destroy_on_monitor_thread_called() { + return destroy_on_monitor_thread_called_; + } + + void SetOnDestroyedCallback(base::OnceClosure on_destroyed) { + on_destroyed_ = std::move(on_destroyed); + } + + void RunMonitorThreadUntilIdle() { mock_task_runner_->RunUntilIdle(); } + void FastForwardMonitorThreadBy(base::TimeDelta delta) { + mock_task_runner_->FastForwardBy(delta); + } + + using JankMonitor::timer_running; + + protected: + friend class base::RefCounted<TestJankMonitor>; + + ~TestJankMonitor() override { + if (on_destroyed_) + std::move(on_destroyed_).Run(); + } + + std::unique_ptr<MetricSource> CreateMetricSource() override { + return std::make_unique<TestMetricSource>(this); + } + + void DestroyOnMonitorThread() override { + destroy_on_monitor_thread_called_ = true; + JankMonitor::DestroyOnMonitorThread(); + } + + scoped_refptr<base::SequencedTaskRunner> CreateMonitorTaskRunner() override { + mock_task_runner_ = base::MakeRefCounted<base::TestMockTimeTaskRunner>(); + return mock_task_runner_; + } + + private: + bool destroy_on_monitor_thread_called_ = false; + base::OnceClosure on_destroyed_; + scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; +}; + +class JankMonitorTest : public testing::Test { + public: + JankMonitorTest() + : test_browser_thread_bundle_( + base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME, + base::test::ScopedTaskEnvironment::NowSource:: + MAIN_THREAD_MOCK_TIME) {} + ~JankMonitorTest() override {} + + void SetUp() override { + monitor_ = base::MakeRefCounted<TestJankMonitor>(); + monitor_->SetUp(); + monitor_->AddObserver(&test_observer_); + RunAllThreadsUntilIdle(); + } + + void TearDown() override { + if (!monitor_) // Already teared down. + return; + monitor_->Destroy(); + RunAllThreadsUntilIdle(); + monitor_ = nullptr; + } + + protected: + void RunAllThreadsUntilIdle() { + test_browser_thread_bundle_.RunUntilIdle(); + monitor_->RunMonitorThreadUntilIdle(); + test_browser_thread_bundle_.RunUntilIdle(); + } + + void FastForwardAllThreadsByMs(int time_delta_ms) { + auto delta = base::TimeDelta::FromMilliseconds(time_delta_ms); + test_browser_thread_bundle_.FastForwardBy(delta); + monitor_->FastForwardMonitorThreadBy(delta); + } + + content::TestBrowserThreadBundle test_browser_thread_bundle_; + scoped_refptr<TestJankMonitor> monitor_; + TestObserver test_observer_; + int expected_jank_started_ = 0; + int expected_jank_stopped_ = 0; +}; + +// Test life cycle management of the jank monitor: DestroyOnMonitorThread() +// and dtor. +TEST_F(JankMonitorTest, LifeCycle) { + bool monitor_destroyed = false; + auto closure = + base::BindLambdaForTesting([&]() { monitor_destroyed = true; }); + monitor_->SetOnDestroyedCallback(std::move(closure)); + + EXPECT_FALSE(monitor_->destroy_on_monitor_thread_called()); + + // Test that the monitor thread is destroyed. + monitor_->Destroy(); + RunAllThreadsUntilIdle(); + EXPECT_TRUE(monitor_->destroy_on_monitor_thread_called()); + + // Release the last reference to TestJankMonitor. Check that it doesn't leak. + monitor_ = nullptr; + EXPECT_TRUE(monitor_destroyed); +} + +#define VALIDATE_TEST_OBSERVER_CALLS() \ + do { \ + EXPECT_EQ(test_observer_.jank_started_called(), expected_jank_started_); \ + EXPECT_EQ(test_observer_.jank_stopped_called(), expected_jank_stopped_); \ + } while (0) + +// Test monitor with UI thread janks. +TEST_F(JankMonitorTest, JankUIThread) { + auto janky_task = [&]() { + VALIDATE_TEST_OBSERVER_CALLS(); + // This is a janky task that runs for 1.5 seconds. + expected_jank_started_++; + FastForwardAllThreadsByMs(1500); + RunAllThreadsUntilIdle(); + + // Monitor should observe that the jank has started. + VALIDATE_TEST_OBSERVER_CALLS(); + expected_jank_stopped_++; + }; + + // Post a janky task to the UI thread. Number of callback calls should be + // incremented by 1. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting(janky_task)); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); + + // Post a non janky task. Number of callback calls should remain the same. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::DoNothing()); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); + + // Post a janky task again. Monitor thread timer should fire again. Number of + // callback calls should be incremented by 1 again. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting(janky_task)); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); +} + +// Test monitor with an IO thread jank. +TEST_F(JankMonitorTest, JankIOThread) { + auto janky_task = [&]() { + VALIDATE_TEST_OBSERVER_CALLS(); + + // This is a janky task that runs for 1.5 seconds. + expected_jank_started_++; + FastForwardAllThreadsByMs(1500); + RunAllThreadsUntilIdle(); + + // Monitor should observe that the jank has started. + VALIDATE_TEST_OBSERVER_CALLS(); + + expected_jank_stopped_++; + }; + + // Post a janky task to the IO thread. This should increment the number of + // callback calls by 1. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, + base::BindLambdaForTesting(janky_task)); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); +} + +// Test monitor with a reentrant UI thread task. The reentrant task shouldn't +// be reported by the monitor. +TEST_F(JankMonitorTest, JankUIThreadReentrant) { + auto janky_task = [&]() { + VALIDATE_TEST_OBSERVER_CALLS(); + + // This is a janky task that runs for 1.5 seconds. + expected_jank_started_++; + FastForwardAllThreadsByMs(1500); + RunAllThreadsUntilIdle(); + + // Monitor should observe that the jank has started. + VALIDATE_TEST_OBSERVER_CALLS(); + + auto nested_janky_task = [&]() { + // This also janks the current thread. + FastForwardAllThreadsByMs(1500); + + // The callback shouldn't be called. + VALIDATE_TEST_OBSERVER_CALLS(); + }; + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting(nested_janky_task)); + // Spin a nested run loop to run |nested_janky_task|. + base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).RunUntilIdle(); + expected_jank_stopped_++; + }; + + // Post a janky task to the UI thread. Number of callback calls should be + // incremented by 1. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting(janky_task)); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); +} + +// Test monitor with overlapping janks on both threads. Only the jank started +// first should be reported. +TEST_F(JankMonitorTest, JankUIAndIOThread) { + auto janky_task_ui = [&]() { + expected_jank_started_++; + + // This should trigger the monitor. TestJankMonitor::OnJankStarted() should + // be called once. + FastForwardAllThreadsByMs(1500); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); + + // The IO thread is also janky. + auto janky_task_io = [&]() { + // This is a janky task that runs for 1.5 seconds, but shouldn't trigger + // the monitor. + FastForwardAllThreadsByMs(1500); + RunAllThreadsUntilIdle(); + VALIDATE_TEST_OBSERVER_CALLS(); + + // Monitor should observe that the jank has started. + }; + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, + base::BindLambdaForTesting(janky_task_io)); + RunAllThreadsUntilIdle(); + // TestJankMonitor::OnJankStopped() shouldn't be called. + VALIDATE_TEST_OBSERVER_CALLS(); + + FastForwardAllThreadsByMs(500); + expected_jank_stopped_++; + }; + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindLambdaForTesting(janky_task_ui)); + RunAllThreadsUntilIdle(); + // Expect that TestJankMonitor::OnJankStopped() was called. + VALIDATE_TEST_OBSERVER_CALLS(); +} + +// Test stopping monitor timer when there is no activity and starting monitor +// timer on new activity. +TEST_F(JankMonitorTest, StartStopTimer) { + // Activity on the UI thread - timer should be running. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, + base::BindOnce(base::DoNothing::Once())); + RunAllThreadsUntilIdle(); + EXPECT_TRUE(monitor_->timer_running()); + + // 11 seconds passed with no activity - timer should be stopped. + FastForwardAllThreadsByMs(11 * 1000); + RunAllThreadsUntilIdle(); + EXPECT_FALSE(monitor_->timer_running()); + + // Activity on IO thread - timer should be restarted. + base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO}, + base::BindOnce(base::DoNothing::Once())); + RunAllThreadsUntilIdle(); + EXPECT_TRUE(monitor_->timer_running()); + + // 11 seconds passed with no activity - timer should be stopped. + FastForwardAllThreadsByMs(11 * 1000); + RunAllThreadsUntilIdle(); + EXPECT_FALSE(monitor_->timer_running()); +} + +#undef VALIDATE_TEST_OBSERVER_CALLS + +} // namespace responsiveness. +} // namespace content.
diff --git a/content/browser/speech/audio_encoder_fuzzer.cc b/content/browser/speech/audio_encoder_fuzzer.cc index bd05b40..f8cf9d8 100644 --- a/content/browser/speech/audio_encoder_fuzzer.cc +++ b/content/browser/speech/audio_encoder_fuzzer.cc
@@ -5,8 +5,8 @@ #include <stddef.h> #include <stdint.h> -#include "base/test/fuzzed_data_provider.h" #include "content/browser/speech/audio_encoder.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" using content::AudioChunk; @@ -17,7 +17,7 @@ const int kAudioPacketIntervalMs = 100; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider provider(data, size); + FuzzedDataProvider provider(data, size); content::AudioEncoder encoder(kDefaultConfigSampleRate, kDefaultConfigBitsPerSample);
diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc index 67e8c17..05c42bb 100644 --- a/content/browser/web_contents/web_contents_impl_browsertest.cc +++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
@@ -2941,7 +2941,8 @@ SetBrowserClientForTesting(old_client); } -IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, SetPageFrozen) { +// DISABLED: frquent timeout crbug.com/978028 +IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, DISABLED_SetPageFrozen) { EXPECT_TRUE(embedded_test_server()->Start()); GURL test_url = embedded_test_server()->GetURL("/pause_schedule_task.html");
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc index 3fdeea8..58a0d6bb 100644 --- a/content/child/runtime_features.cc +++ b/content/child/runtime_features.cc
@@ -66,9 +66,6 @@ WebRuntimeFeatures::EnableBlinkHeapIncrementalMarking( base::FeatureList::IsEnabled(features::kBlinkHeapIncrementalMarking)); - WebRuntimeFeatures::EnableBlinkHeapUnifiedGCScheduling( - base::FeatureList::IsEnabled(features::kBlinkHeapUnifiedGCScheduling)); - if (base::FeatureList::IsEnabled(features::kBloatedRendererDetection)) WebRuntimeFeatures::EnableBloatedRendererDetection(true); @@ -541,6 +538,9 @@ WebRuntimeFeatures::EnableConsolidatedMovementXY( base::FeatureList::IsEnabled(features::kConsolidatedMovementXY)); + + WebRuntimeFeatures::EnableStreamsNative( + base::FeatureList::IsEnabled(blink::features::kStreamsNative)); } } // namespace
diff --git a/content/public/android/java/src/org/chromium/content/browser/BrowserStartupControllerImpl.java b/content/public/android/java/src/org/chromium/content/browser/BrowserStartupControllerImpl.java index b906955..7a219cb 100644 --- a/content/public/android/java/src/org/chromium/content/browser/BrowserStartupControllerImpl.java +++ b/content/public/android/java/src/org/chromium/content/browser/BrowserStartupControllerImpl.java
@@ -108,6 +108,10 @@ private int mLibraryProcessType; + // Tests may inject a method to be run instead of calling ContentMain() in order for them to + // initialize the C++ system via another means. + private Runnable mContentMainCallbackForTests; + // Browser start up type. If the type is |BROWSER_START_TYPE_SERVICE_MANAGER_ONLY|, start up // will be paused after ServiceManager is launched. Additional request to launch the full // browser process is needed to fully complete the startup process. Callbacks will executed @@ -276,15 +280,29 @@ * Start the browser process by calling ContentMain.start(). */ int contentStart() { - boolean startServiceManagerOnly = - mCurrentBrowserStartType == BrowserStartType.SERVICE_MANAGER_ONLY; - int result = contentMainStart(startServiceManagerOnly); + int result = 0; + if (mContentMainCallbackForTests == null) { + boolean startServiceManagerOnly = + mCurrentBrowserStartType == BrowserStartType.SERVICE_MANAGER_ONLY; + result = contentMainStart(startServiceManagerOnly); + // No need to launch the full browser again if we are launching full browser now. + if (!startServiceManagerOnly) mLaunchFullBrowserAfterServiceManagerStart = false; + } else { + assert mCurrentBrowserStartType == BrowserStartType.FULL_BROWSER; + // Run the injected Runnable instead of ContentMain(). + mContentMainCallbackForTests.run(); + mLaunchFullBrowserAfterServiceManagerStart = false; + } mHasCalledContentStart = true; - // No need to launch the full browser again if we are launching full browser now. - if (!startServiceManagerOnly) mLaunchFullBrowserAfterServiceManagerStart = false; return result; } + @Override + public void setContentMainCallbackForTests(Runnable r) { + assert !mHasCalledContentStart; + mContentMainCallbackForTests = r; + } + /** * Wrap ContentMain.start() for testing. */
diff --git a/content/public/android/java/src/org/chromium/content_public/browser/BrowserStartupController.java b/content/public/android/java/src/org/chromium/content_public/browser/BrowserStartupController.java index e6049e9..be2bc04 100644 --- a/content/public/android/java/src/org/chromium/content_public/browser/BrowserStartupController.java +++ b/content/public/android/java/src/org/chromium/content_public/browser/BrowserStartupController.java
@@ -83,7 +83,13 @@ void addStartupCompletedObserver(StartupCallback callback); /** - * Initialization needed for tests. Mainly used by content browsertests. + * Initialization needed for tests. Mainly used by browsertests. */ void initChromiumBrowserProcessForTests(); + + /** + * Set a callback that will be run in place of calling ContentMain(). For tests to + * define their own way of initializing the C++ system. + */ + void setContentMainCallbackForTests(Runnable r); }
diff --git a/content/public/common/content_features.cc b/content/public/common/content_features.cc index 333ce5b..60f3f67 100644 --- a/content/public/common/content_features.cc +++ b/content/public/common/content_features.cc
@@ -42,7 +42,7 @@ // Creates audio output and input streams using the audio service. const base::Feature kAudioServiceAudioStreams{ "AudioServiceAudioStreams", -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if defined(OS_LINUX) base::FEATURE_ENABLED_BY_DEFAULT #else base::FEATURE_DISABLED_BY_DEFAULT @@ -76,9 +76,6 @@ const base::Feature kBlinkHeapIncrementalMarking{ "BlinkHeapIncrementalMarking", base::FEATURE_ENABLED_BY_DEFAULT}; -const base::Feature kBlinkHeapUnifiedGCScheduling{ - "BlinkHeapUnifiedGCScheduling", base::FEATURE_DISABLED_BY_DEFAULT}; - // Enable bloated renderer detection. const base::Feature kBloatedRendererDetection{ "BloatedRendererDetection", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/content/public/common/content_features.h b/content/public/common/content_features.h index 0af9f7c..93a5f858 100644 --- a/content/public/common/content_features.h +++ b/content/public/common/content_features.h
@@ -29,7 +29,6 @@ CONTENT_EXPORT extern const base::Feature kBackgroundFetch; CONTENT_EXPORT extern const base::Feature kBackForwardCache; CONTENT_EXPORT extern const base::Feature kBlinkHeapIncrementalMarking; -CONTENT_EXPORT extern const base::Feature kBlinkHeapUnifiedGCScheduling; CONTENT_EXPORT extern const base::Feature kBloatedRendererDetection; CONTENT_EXPORT extern const base::Feature kBlockCredentialedSubresources; CONTENT_EXPORT extern const base::Feature kBundledHTTPExchanges;
diff --git a/content/public/test/DEPS b/content/public/test/DEPS index 09d4d4d..3f5ae1e9 100644 --- a/content/public/test/DEPS +++ b/content/public/test/DEPS
@@ -11,6 +11,7 @@ "+services/audio/public/mojom", "+services/network", "+services/service_manager", + "+testing/android/native_test/native_browser_test_support.h", "+ui/ozone/public", "+ui/views/test", "+v8/include/v8.h",
diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc index 822d325..bd932fc 100644 --- a/content/public/test/browser_test_base.cc +++ b/content/public/test/browser_test_base.cc
@@ -73,6 +73,7 @@ #include "content/common/url_schemes.h" #include "content/public/app/content_main_delegate.h" #include "content/public/common/content_paths.h" +#include "testing/android/native_test/native_browser_test_support.h" #include "ui/base/ui_base_paths.h" #ifdef V8_USE_EXTERNAL_STARTUP_DATA @@ -351,9 +352,6 @@ // FeatureList::SetInstance, which expects no instance to exist. base::FeatureList::ClearInstanceForTesting(); - auto ui_task = std::make_unique<base::Closure>(base::Bind( - &BrowserTestBase::ProxyRunTestOnMainThreadLoop, base::Unretained(this))); - auto created_main_parts_closure = std::make_unique<CreatedMainPartsClosure>(base::Bind( &BrowserTestBase::CreatedBrowserMainParts, base::Unretained(this))); @@ -420,6 +418,18 @@ // to BrowserMain() if it did not run it (or equivalent) itself. On Android, // RunProcess() will return 0 so we don't have to fallback to BrowserMain(). { + // This loop will wait until Java completes async initializion and the test + // is ready to run. We must allow nestable tasks so that tasks posted to the + // UI thread run as well. The loop is created before RunProcess() so that + // the StartupTaskRunner tasks will be nested inside this loop and able to + // run. + base::RunLoop loop{base::RunLoop::Type::kNestableTasksAllowed}; + + auto ui_task = std::make_unique<base::Closure>( + base::Bind(&BrowserTestBase::WaitUntilJavaIsReady, + base::Unretained(this), loop.QuitClosure())); + + // The MainFunctionParams must out-live all the startup tasks running. MainFunctionParams params(*command_line); params.ui_task = ui_task.release(); params.created_main_parts_closure = created_main_parts_closure.release(); @@ -427,6 +437,19 @@ // Passing "" as the process type to indicate the browser process. int exit_code = delegate->RunProcess("", params); DCHECK_EQ(exit_code, 0); + + // Waits for Java to finish initialization, then we can run the test. + loop.Run(); + + // The BrowserMainLoop startup tasks will call DisallowUnresponsiveTasks(). + // So when we run the ProxyRunTestOnMainThreadLoop() we no longer can block, + // but tests should be allowed to. So we undo that blocking inside here. + base::ScopedAllowUnresponsiveTasksForTesting allow_unresponsive; + // Runs the test now that the Java setup is complete. This must be called + // directly from the same call stack as RUN_ALL_TESTS(), it may not be + // inside a posted task, or it would prevent NonNestable tasks from running + // inside tests. + ProxyRunTestOnMainThreadLoop(); } { @@ -443,6 +466,8 @@ // for the test harness to be able to delete temp dirs. base::ThreadRestrictions::SetIOAllowed(true); #else + auto ui_task = std::make_unique<base::Closure>(base::Bind( + &BrowserTestBase::ProxyRunTestOnMainThreadLoop, base::Unretained(this))); GetContentMainParams()->ui_task = ui_task.release(); GetContentMainParams()->created_main_parts_closure = created_main_parts_closure.release(); @@ -470,7 +495,7 @@ GetSystemConnector()->BindInterface(mojom::kNetworkServiceName, &network_service_test); - base::RunLoop run_loop{base::RunLoop::Type::kNestableTasksAllowed}; + base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); network_service_test.set_connection_error_handler(run_loop.QuitClosure()); network_service_test->SimulateCrash(); @@ -484,6 +509,22 @@ InitializeNetworkProcess(); } +#if defined(OS_ANDROID) +void BrowserTestBase::WaitUntilJavaIsReady(base::OnceClosure quit_closure) { + if (testing::android::JavaAsyncStartupTasksCompleteForBrowserTests()) { + std::move(quit_closure).Run(); + return; + } + + base::PostDelayedTask( + FROM_HERE, + base::BindOnce(&BrowserTestBase::WaitUntilJavaIsReady, + base::Unretained(this), std::move(quit_closure)), + base::TimeDelta::FromMilliseconds(100)); + return; +} +#endif + void BrowserTestBase::ProxyRunTestOnMainThreadLoop() { #if defined(OS_POSIX) g_browser_process_pid = base::GetCurrentProcId();
diff --git a/content/public/test/browser_test_base.h b/content/public/test/browser_test_base.h index 30f04ae..4f6790f 100644 --- a/content/public/test/browser_test_base.h +++ b/content/public/test/browser_test_base.h
@@ -154,6 +154,12 @@ void SetInitialWebContents(WebContents* web_contents); private: +#if defined(OS_ANDROID) + // Android browser tests need to wait for async initialization in Java code. + // This waits for those to complete before we can continue with the test. + void WaitUntilJavaIsReady(base::OnceClosure quit_closure); +#endif + // Performs a bunch of setup, and then runs the browser test body. void ProxyRunTestOnMainThreadLoop(); // When using the network process, update the host resolver rules that were
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc index 30bde476d..17384942 100644 --- a/content/renderer/render_process_impl.cc +++ b/content/renderer/render_process_impl.cc
@@ -154,9 +154,6 @@ "--no-harmony-sharedarraybuffer"); } - SetV8FlagIfFeature(features::kBlinkHeapUnifiedGCScheduling, - "--global-gc-scheduling"); - SetV8FlagIfNotFeature(features::kWebAssemblyTrapHandler, "--no-wasm-trap-handler"); #if defined(OS_LINUX) && defined(ARCH_CPU_X86_64)
diff --git a/content/shell/android/browsertests/OWNERS b/content/shell/android/browsertests/OWNERS new file mode 100644 index 0000000..b15086ee --- /dev/null +++ b/content/shell/android/browsertests/OWNERS
@@ -0,0 +1,4 @@ +jbudorick@chromium.org + +# COMPONENT: Test>Android +# OS: Android
diff --git a/content/shell/android/browsertests/src/org/chromium/content_shell/browsertests/ContentShellBrowserTestActivity.java b/content/shell/android/browsertests/src/org/chromium/content_shell/browsertests/ContentShellBrowserTestActivity.java index f572731b..41780dab 100644 --- a/content/shell/android/browsertests/src/org/chromium/content_shell/browsertests/ContentShellBrowserTestActivity.java +++ b/content/shell/android/browsertests/src/org/chromium/content_shell/browsertests/ContentShellBrowserTestActivity.java
@@ -13,7 +13,9 @@ import org.chromium.base.library_loader.LibraryProcessType; import org.chromium.base.library_loader.ProcessInitException; import org.chromium.content_public.browser.BrowserStartupController; +import org.chromium.content_public.browser.BrowserStartupController.StartupCallback; import org.chromium.content_shell.ShellManager; +import org.chromium.native_test.NativeBrowserTest; import org.chromium.native_test.NativeBrowserTestActivity; import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.WindowAndroid; @@ -40,8 +42,6 @@ Log.e(TAG, "Cannot load content_browsertests.", e); System.exit(-1); } - BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER) - .initChromiumBrowserProcessForTests(); setContentView(getTestActivityViewId()); mShellManager = (ShellManager) findViewById(getShellManagerViewId()); @@ -52,6 +52,33 @@ wind.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); wind.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); wind.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + + BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER) + .setContentMainCallbackForTests(() -> { + // This jumps into C++ to set up and run the test harness. The test harness runs + // ContentMain()-equivalent code, and then waits for javaStartupTasksComplete() + // to be called. + runTests(); + }); + try { + BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER) + .startBrowserProcessesAsync(false, false, new StartupCallback() { + @Override + public void onSuccess() { + // The C++ test harness is running thanks to runTests() above, but it + // waits for Java initialization to complete. This tells C++ that it may + // continue now to finish running the tests. + NativeBrowserTest.javaStartupTasksComplete(); + } + @Override + public void onFailure() { + throw new RuntimeException("Failed to startBrowserProcessesAsync()"); + } + }); + } catch (ProcessInitException e) { + Log.e(TAG, "Unable to load native library.", e); + System.exit(-1); + } } protected abstract int getTestActivityViewId();
diff --git a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java index 708b2ed..d50ae20 100644 --- a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java +++ b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsApplication.java
@@ -6,7 +6,6 @@ import android.content.Context; -import org.chromium.base.ApplicationStatus; import org.chromium.base.PathUtils; import org.chromium.native_test.NativeBrowserTestApplication; @@ -21,8 +20,6 @@ super.attachBaseContext(base); if (isBrowserProcess()) { - ApplicationStatus.initialize(this); - // Test-only stuff, see also NativeUnitTest.java. PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); }
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 4b4f70a..3b96460 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -440,6 +440,7 @@ deps += [ "//content/shell:android_shell_descriptors", "//mojo/public/java/system:native_support", + "//testing/android/native_test:native_browser_test_support", ] } else { sources += [ @@ -1722,6 +1723,7 @@ "../browser/scheduler/browser_task_queues_unittest.cc", "../browser/scheduler/browser_ui_thread_scheduler_unittest.cc", "../browser/scheduler/responsiveness/calculator_unittest.cc", + "../browser/scheduler/responsiveness/jank_monitor_unittest.cc", "../browser/scheduler/responsiveness/metric_source_unittest.cc", "../browser/scheduler/responsiveness/watcher_unittest.cc", "../browser/screen_orientation/screen_orientation_provider_unittest.cc",
diff --git a/content/test/data/fuzzer_dictionaries/merkle_integrity_source_stream_fuzzer.dict b/content/test/data/fuzzer_dictionaries/merkle_integrity_source_stream_fuzzer.dict index 87687fc..3e60047a 100644 --- a/content/test/data/fuzzer_dictionaries/merkle_integrity_source_stream_fuzzer.dict +++ b/content/test/data/fuzzer_dictionaries/merkle_integrity_source_stream_fuzzer.dict
@@ -8,7 +8,7 @@ # The header version of the hash. "mi-sha256=QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkI\\ " -# base::FuzzedDataProvider separator. +# FuzzedDataProvider separator. "\\ " # Use a 16-byte record size if you don't have better ideas.
diff --git a/content/test/fuzzer/merkle_integrity_source_stream_fuzzer.cc b/content/test/fuzzer/merkle_integrity_source_stream_fuzzer.cc index 5b63bfd..544b63c6 100644 --- a/content/test/fuzzer/merkle_integrity_source_stream_fuzzer.cc +++ b/content/test/fuzzer/merkle_integrity_source_stream_fuzzer.cc
@@ -8,17 +8,17 @@ #include "base/logging.h" #include "base/memory/scoped_refptr.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/io_buffer.h" #include "net/base/test_completion_callback.h" #include "net/filter/fuzzed_source_stream.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for MerkleIntegritySourceStream // // |data| contains a header prefix, and then is used to build a // FuzzedSourceStream. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::string header = data_provider.ConsumeRandomLengthString(256); net::TestCompletionCallback callback;
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index bd3b910..551372d 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h
@@ -1406,6 +1406,10 @@ DECLARATIVENETREQUEST_GETMATCHEDRULES = 1343, DECLARATIVENETREQUEST_SETACTIONCOUNTASBADGETEXT = 1344, BLUETOOTHPRIVATE_RECORDDEVICESELECTION = 1345, + LOGIN_LAUNCHMANAGEDGUESTSESSION = 1346, + LOGIN_EXITCURRENTSESSION = 1347, + LOGIN_ISRUNNINGINLOGINPROFILE = 1348, + LOGIN_FETCHDATAFORNEXTLOGINATTEMPT = 1349, // Last entry: Add new entries above, then run: // python tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY
diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h index e93b37e..671a3d2 100644 --- a/extensions/common/permissions/api_permission.h +++ b/extensions/common/permissions/api_permission.h
@@ -261,6 +261,7 @@ kLoginScreenUi = 217, kDeclarativeNetRequestFeedback = 218, kTransientBackground = 219, + kLogin = 220, // Last entry: Add new entries above and ensure to update the // "ExtensionPermission3" enum in tools/metrics/histograms/enums.xml // (by running update_extension_permission.py).
diff --git a/extensions/common/permissions/extensions_api_permissions.cc b/extensions/common/permissions/extensions_api_permissions.cc index 935c149..21789e75 100644 --- a/extensions/common/permissions/extensions_api_permissions.cc +++ b/extensions/common/permissions/extensions_api_permissions.cc
@@ -78,6 +78,7 @@ {APIPermission::kLockScreen, "lockScreen"}, {APIPermission::kLockWindowFullscreenPrivate, "lockWindowFullscreenPrivate", APIPermissionInfo::kFlagCannotBeOptional}, + {APIPermission::kLogin, "login"}, {APIPermission::kLoginScreenUi, "loginScreenUi"}, {APIPermission::kMediaPerceptionPrivate, "mediaPerceptionPrivate"}, {APIPermission::kMetricsPrivate, "metricsPrivate",
diff --git a/fuchsia/cipd/README.md b/fuchsia/cipd/README.md new file mode 100644 index 0000000..63f1d3f --- /dev/null +++ b/fuchsia/cipd/README.md
@@ -0,0 +1,33 @@ +# CIPD recipes + +The `//fuchsia/cipd` target generates a number of YAML files which are used to +produce archives that are uploaded to CIPD. The generated YAML files are stored +under the output directory, under the path `gen/fuchsia/cipd/`. + +## Arguments + +The YAML recipes require certain parameters to be passed in, using the CIPD +"pkg-var" system. + +`targetarch` - The ID of the target architecture (amd64, arm64) must be passed +in as a pkg-var so that the packages can be archived at the appropriate location +in the CIPD package hierarchy. + +`outdir` - The fully qualified path to the build output directory. + +## Example usage + +To create a CIPD package, run the following command from the build output +directory. In this example, "http.yaml" is being built for arm64: + +``` +$ cipd create --pkg-def gen/fuchsia/cipd/http/http.yaml + -pkg-var targetarch:arm64 + -pkg-var outdir:`pwd` + -ref latest + -tag version:$(cat gen/fuchsia/cipd/build_id.txt) +``` + +The most recent package can be discovered by searching for the "latest" ref: + +`$ cipd describe chromium/fuchsia/$PACKAGE_NAME-$TARGET_ARCH -version latest`
diff --git a/fuchsia/cipd/castrunner.yaml b/fuchsia/cipd/castrunner.yaml deleted file mode 100644 index 5ddc2cd0b..0000000 --- a/fuchsia/cipd/castrunner.yaml +++ /dev/null
@@ -1,33 +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. - -# Creates a package for the Cast application Runner. -# Note that the web.ContextProvider package is required by the Cast Runner. -# The ID of the target architecture (amd64, arm64) must be passed in as -# a pkg-var so that the packages can be archived at the appropriate location -# in the CIPD package hierarchy. -# -# pkg-var arguments: -# outdir: A fully qualified path to the build output directory. -# targetarch: The target architecture, either "amd64" or "arm64". -# -# To create a CIPD package, run the following command from the build output -# directory. -# -# $ cipd create --pkg-def ../../fuchsia/cipd/castrunner.yaml \ -# -pkg-var targetarch:$TARGET_ARCH \ -# -pkg-var outdir:`pwd` \ -# -ref latest \ -# -tag version:$(cat fuchsia_artifacts/build_id.txt) -# -# The most recent package can be discovered by searching for the "latest" ref: -# -# $ cipd describe chromium/fuchsia/castrunner-$TARGET_ARCH -version latest - -package: chromium/fuchsia/castrunner-${targetarch} -description: Prebuilt Cast application Runner binaries for Fuchsia. -root: ${outdir}/fuchsia_artifacts -data: - - file: cast_runner.far - - file: LICENSE
diff --git a/fuchsia/cipd/debug_symbols.yaml b/fuchsia/cipd/debug_symbols.yaml deleted file mode 100644 index 04c6f89..0000000 --- a/fuchsia/cipd/debug_symbols.yaml +++ /dev/null
@@ -1,29 +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. - -# Creates a package of archived debugging symbols for Chromium engine, -# Web Runner, Cast Runner, and the HTTP FIDL service. -# -# pkg-var arguments: -# outdir: A fully qualified path to the build output directory. -# targetarch: The target architecture, either "amd64" or "arm64". -# -# To create a CIPD package, run the following command from the build output -# directory. -# -# $ cipd create --pkg-def ../../fuchsia/cipd/debug_symbols.yaml \ -# -pkg-var targetarch:$TARGET_ARCH \ -# -pkg-var outdir:`pwd` \ -# -ref latest \ -# -tag version:$(cat symbol_artifacts/build_id.txt) - -package: chromium/fuchsia/debug-symbols-${targetarch} -description: Debugging symbols for prebuilt binaries from Chromium. -root: ${outdir}/symbol_artifacts -data: - - file: cast_runner.symbols.tar.bz2 - - file: chromium.symbols.tar.bz2 - - file: http.symbols.tar.bz2 - - file: web_runner.symbols.tar.bz2 - - file: LICENSE
diff --git a/fuchsia/cipd/http.yaml b/fuchsia/cipd/http.yaml deleted file mode 100644 index 702c6fa..0000000 --- a/fuchsia/cipd/http.yaml +++ /dev/null
@@ -1,32 +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. - -# Creates a package for the HTTP service binary. -# The ID of the target architecture (amd64, arm64) must be passed in as -# a pkg-var so that the packages can be archived at the appropriate location -# in the CIPD package hierarchy. -# -# pkg-var arguments: -# outdir: A fully qualified path to the build output directory. -# targetarch: The target architecture, either "amd64" or "arm64". -# -# To create a CIPD package, run the following command from the build output -# directory. -# -# $ cipd create --pkg-def ../../fuchsia/cipd/http.yaml \ -# -pkg-var targetarch:$TARGET_ARCH \ -# -pkg-var outdir:`pwd` \ -# -ref latest \ -# -tag version:$(cat fuchsia_artifacts/build_id.txt) -# -# The most recent package can be discovered by searching for the "latest" ref: -# -# $ cipd describe chromium/fuchsia/http-$TARGET_ARCH -version latest - -package: chromium/fuchsia/http-${targetarch} -description: Prebuilt HTTP service binary for Fuchsia. -root: ${outdir}/fuchsia_artifacts -data: - - file: http.far - - file: LICENSE
diff --git a/fuchsia/cipd/webrunner.yaml b/fuchsia/cipd/webrunner.yaml deleted file mode 100644 index 9b82992..0000000 --- a/fuchsia/cipd/webrunner.yaml +++ /dev/null
@@ -1,33 +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. - -# Creates a package for the WebRunner and Chromium service binaries. -# The ID of the target architecture (amd64, arm64) must be passed in as -# a pkg-var so that the packages can be archived at the appropriate location -# in the CIPD package hierarchy. -# -# pkg-var arguments: -# outdir: A fully qualified path to the build output directory. -# targetarch: The target architecture, either "amd64" or "arm64". -# -# To create a CIPD package, run the following command from the build output -# directory. -# -# $ cipd create --pkg-def ../../fuchsia/cipd/webrunner.yaml \ -# -pkg-var targetarch:$TARGET_ARCH \ -# -pkg-var outdir:`pwd` \ -# -ref latest \ -# -tag version:$(cat fuchsia_artifacts/build_id.txt) -# -# The most recent package can be discovered by searching for the "latest" ref: -# -# $ cipd describe chromium/fuchsia/webrunner-$TARGET_ARCH -version latest - -package: chromium/fuchsia/webrunner-${targetarch} -description: Prebuilt Chrome and Web Runner binaries for Fuchsia. -root: ${outdir}/fuchsia_artifacts -data: - - file: chromium.far - - file: web_runner.far - - file: LICENSE
diff --git a/fuchsia/engine/browser/web_engine_browser_main_parts.cc b/fuchsia/engine/browser/web_engine_browser_main_parts.cc index e93f67b..fafc7ea 100644 --- a/fuchsia/engine/browser/web_engine_browser_main_parts.cc +++ b/fuchsia/engine/browser/web_engine_browser_main_parts.cc
@@ -6,12 +6,14 @@ #include <utility> +#include "base/bind_helpers.h" #include "base/command_line.h" #include "base/files/file_util.h" #include "base/fuchsia/fuchsia_logging.h" #include "base/logging.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/render_frame_host.h" +#include "content/public/common/main_function_params.h" #include "fuchsia/engine/browser/context_impl.h" #include "fuchsia/engine/browser/web_engine_browser_context.h" #include "fuchsia/engine/browser/web_engine_devtools_socket_factory.h" @@ -21,8 +23,9 @@ #include "ui/ozone/public/ozone_platform.h" WebEngineBrowserMainParts::WebEngineBrowserMainParts( + const content::MainFunctionParams& parameters, fidl::InterfaceRequest<fuchsia::web::Context> request) - : request_(std::move(request)) {} + : parameters_(parameters), request_(std::move(request)) {} WebEngineBrowserMainParts::~WebEngineBrowserMainParts() { display::Screen::SetScreenInstance(nullptr); @@ -73,6 +76,16 @@ // Context and Frames can implement their own JS injection policy at a higher // level. content::RenderFrameHost::AllowInjectingJavaScript(); + + if (parameters_.ui_task) { + // Since the main loop won't run, there is nothing to quit in the + // |context_binding_| error handler. + quit_closure_ = base::DoNothing::Once(); + + parameters_.ui_task->Run(); + delete parameters_.ui_task; + run_message_loop_ = false; + } } void WebEngineBrowserMainParts::PreDefaultMainMessageLoopRun( @@ -80,6 +93,10 @@ quit_closure_ = std::move(quit_closure); } +bool WebEngineBrowserMainParts::MainMessageLoopRun(int* result_code) { + return !run_message_loop_; +} + void WebEngineBrowserMainParts::PostMainMessageLoopRun() { // The service and its binding should have already been released by the error // handler.
diff --git a/fuchsia/engine/browser/web_engine_browser_main_parts.h b/fuchsia/engine/browser/web_engine_browser_main_parts.h index 49db75f0..4672609 100644 --- a/fuchsia/engine/browser/web_engine_browser_main_parts.h +++ b/fuchsia/engine/browser/web_engine_browser_main_parts.h
@@ -19,9 +19,14 @@ class Screen; } +namespace content { +struct MainFunctionParams; +} + class WebEngineBrowserMainParts : public content::BrowserMainParts { public: explicit WebEngineBrowserMainParts( + const content::MainFunctionParams& parameters, fidl::InterfaceRequest<fuchsia::web::Context> request); ~WebEngineBrowserMainParts() override; @@ -32,11 +37,14 @@ // content::BrowserMainParts overrides. void PreMainMessageLoopRun() override; void PreDefaultMainMessageLoopRun(base::OnceClosure quit_closure) override; + bool MainMessageLoopRun(int* result_code) override; void PostMainMessageLoopRun() override; ContextImpl* context_for_test() const { return context_service_.get(); } private: + const content::MainFunctionParams& parameters_; + fidl::InterfaceRequest<fuchsia::web::Context> request_; std::unique_ptr<display::Screen> screen_; @@ -44,6 +52,7 @@ std::unique_ptr<ContextImpl> context_service_; std::unique_ptr<fidl::Binding<fuchsia::web::Context>> context_binding_; + bool run_message_loop_ = true; base::OnceClosure quit_closure_; DISALLOW_COPY_AND_ASSIGN(WebEngineBrowserMainParts);
diff --git a/fuchsia/engine/browser/web_engine_content_browser_client.cc b/fuchsia/engine/browser/web_engine_content_browser_client.cc index 2b33e1a..8fe5c17 100644 --- a/fuchsia/engine/browser/web_engine_content_browser_client.cc +++ b/fuchsia/engine/browser/web_engine_content_browser_client.cc
@@ -23,8 +23,8 @@ WebEngineContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { DCHECK(request_); - auto browser_main_parts = - std::make_unique<WebEngineBrowserMainParts>(std::move(request_)); + auto browser_main_parts = std::make_unique<WebEngineBrowserMainParts>( + parameters, std::move(request_)); main_parts_ = browser_main_parts.get();
diff --git a/fuchsia/engine/test/web_engine_browser_test.cc b/fuchsia/engine/test/web_engine_browser_test.cc index 246945f..9aecf84 100644 --- a/fuchsia/engine/test/web_engine_browser_test.cc +++ b/fuchsia/engine/test/web_engine_browser_test.cc
@@ -7,6 +7,7 @@ #include <fuchsia/web/cpp/fidl.h> #include "base/fuchsia/fuchsia_logging.h" +#include "base/run_loop.h" #include "fuchsia/engine/browser/web_engine_browser_context.h" #include "fuchsia/engine/browser/web_engine_browser_main_parts.h" #include "fuchsia/engine/browser/web_engine_content_browser_client.h" @@ -34,13 +35,20 @@ } } +void WebEngineBrowserTest::TearDownOnMainThread() { + navigation_listener_bindings_.CloseAll(); +} + void WebEngineBrowserTest::PostRunTestOnMainThread() { // Unbind the Context while the message loops are still alive. context_.Unbind(); -} -void WebEngineBrowserTest::TearDownOnMainThread() { - navigation_listener_bindings_.CloseAll(); + // Shutting down the context needs to run connection error handlers + // etc which normally are what causes the main loop to exit. Since in + // tests we are not running a main loop indefinitely, we want to let those + // things run, just as they would in production, before shutting down. This + // makes the main loop run until breaking the connection completes. + base::RunLoop().RunUntilIdle(); } fuchsia::web::FramePtr WebEngineBrowserTest::CreateFrame(
diff --git a/google_apis/gaia/fake_oauth2_token_service.cc b/google_apis/gaia/fake_oauth2_token_service.cc index 0704ab2c..019f4b2 100644 --- a/google_apis/gaia/fake_oauth2_token_service.cc +++ b/google_apis/gaia/fake_oauth2_token_service.cc
@@ -37,16 +37,16 @@ pending_requests_.push_back(pending_request); } -void FakeOAuth2TokenService::AddAccount(const std::string& account_id) { +void FakeOAuth2TokenService::AddAccount(const CoreAccountId& account_id) { GetDelegate()->UpdateCredentials(account_id, "fake_refresh_token"); } -void FakeOAuth2TokenService::RemoveAccount(const std::string& account_id) { +void FakeOAuth2TokenService::RemoveAccount(const CoreAccountId& account_id) { GetDelegate()->RevokeCredentials(account_id); } void FakeOAuth2TokenService::IssueAllTokensForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2AccessTokenConsumer::TokenResponse& token_response) { // Walk the requests and notify the callbacks. // Using a copy of pending requests to make sure a new token request triggered @@ -63,7 +63,7 @@ } void FakeOAuth2TokenService::IssueErrorForAllPendingRequestsForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& auth_error) { // Walk the requests and notify the callbacks. // Using a copy of pending requests to make sure retrying a request in
diff --git a/google_apis/gaia/fake_oauth2_token_service.h b/google_apis/gaia/fake_oauth2_token_service.h index 1e8f96aa..f3b4985 100644 --- a/google_apis/gaia/fake_oauth2_token_service.h +++ b/google_apis/gaia/fake_oauth2_token_service.h
@@ -20,16 +20,16 @@ FakeOAuth2TokenService(); ~FakeOAuth2TokenService() override; - void AddAccount(const std::string& account_id); - void RemoveAccount(const std::string& account_id); + void AddAccount(const CoreAccountId& account_id); + void RemoveAccount(const CoreAccountId& account_id); // Helper routines to issue tokens for pending requests or complete them with // error. void IssueAllTokensForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2AccessTokenConsumer::TokenResponse& token_response); void IssueErrorForAllPendingRequestsForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& auth_error); void InvalidateTokenForMultilogin(const CoreAccountId& account_id, @@ -58,7 +58,7 @@ PendingRequest(const PendingRequest& other); ~PendingRequest(); - std::string account_id; + CoreAccountId account_id; std::string client_id; std::string client_secret; ScopeSet scopes;
diff --git a/google_apis/gaia/gaia_auth_util.h b/google_apis/gaia/gaia_auth_util.h index c6af6322..a8c60d8 100644 --- a/google_apis/gaia/gaia_auth_util.h +++ b/google_apis/gaia/gaia_auth_util.h
@@ -9,6 +9,8 @@ #include <utility> #include <vector> +#include "google_apis/gaia/core_account_id.h" + class GURL; namespace gaia { @@ -16,7 +18,8 @@ struct ListedAccount { // The account's ID, as per Chrome, will be determined in the // CookieManagerService. - std::string id; + // TODO(triploblastic): Rename the id field to account_id. + CoreAccountId id; std::string email; std::string gaia_id; std::string raw_email;
diff --git a/google_apis/gaia/oauth2_access_token_manager.cc b/google_apis/gaia/oauth2_access_token_manager.cc index cb41f11e..1f425dd 100644 --- a/google_apis/gaia/oauth2_access_token_manager.cc +++ b/google_apis/gaia/oauth2_access_token_manager.cc
@@ -52,7 +52,7 @@ // done. static std::unique_ptr<OAuth2AccessTokenManager::Fetcher> CreateAndStart( OAuth2AccessTokenManager* oauth2_access_token_manager, - const std::string& account_id, + const CoreAccountId& account_id, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, const std::string& client_id, const std::string& client_secret, @@ -76,7 +76,7 @@ const OAuth2TokenService::ScopeSet& GetScopeSet() const; const std::string& GetClientId() const; - const std::string& GetAccountId() const; + const CoreAccountId& GetAccountId() const; // The error result from this fetcher. const GoogleServiceAuthError& error() const { return error_; } @@ -89,7 +89,7 @@ private: Fetcher(OAuth2AccessTokenManager* oauth2_access_token_manager, - const std::string& account_id, + const CoreAccountId& account_id, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, const std::string& client_id, const std::string& client_secret, @@ -112,7 +112,7 @@ // OnGetTokenFailure/OnGetTokenSuccess (whichever comes first). OAuth2AccessTokenManager* const oauth2_access_token_manager_; scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; - const std::string account_id_; + const CoreAccountId account_id_; const OAuth2TokenService::ScopeSet scopes_; std::vector<base::WeakPtr<OAuth2TokenService::RequestImpl>> waiting_requests_; @@ -137,7 +137,7 @@ std::unique_ptr<OAuth2AccessTokenManager::Fetcher> OAuth2AccessTokenManager::Fetcher::CreateAndStart( OAuth2AccessTokenManager* oauth2_access_token_manager, - const std::string& account_id, + const CoreAccountId& account_id, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, const std::string& client_id, const std::string& client_secret, @@ -153,7 +153,7 @@ OAuth2AccessTokenManager::Fetcher::Fetcher( OAuth2AccessTokenManager* oauth2_access_token_manager, - const std::string& account_id, + const CoreAccountId& account_id, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, const std::string& client_id, const std::string& client_secret, @@ -305,7 +305,7 @@ return client_id_; } -const std::string& OAuth2AccessTokenManager::Fetcher::GetAccountId() const { +const CoreAccountId& OAuth2AccessTokenManager::Fetcher::GetAccountId() const { return account_id_; }
diff --git a/google_apis/gaia/oauth2_token_service.cc b/google_apis/gaia/oauth2_token_service.cc index a790bf2..749c9f0 100644 --- a/google_apis/gaia/oauth2_token_service.cc +++ b/google_apis/gaia/oauth2_token_service.cc
@@ -25,12 +25,9 @@ OAuth2TokenService::RequestParameters::RequestParameters( const std::string& client_id, - const std::string& account_id, + const CoreAccountId& account_id, const ScopeSet& scopes) - : client_id(client_id), - account_id(account_id), - scopes(scopes) { -} + : client_id(client_id), account_id(account_id), scopes(scopes) {} OAuth2TokenService::RequestParameters::RequestParameters( const RequestParameters& other) = default; @@ -54,17 +51,15 @@ } OAuth2TokenService::RequestImpl::RequestImpl( - const std::string& account_id, + const CoreAccountId& account_id, OAuth2TokenService::Consumer* consumer) - : account_id_(account_id), - consumer_(consumer) { -} + : account_id_(account_id), consumer_(consumer) {} OAuth2TokenService::RequestImpl::~RequestImpl() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } -std::string OAuth2TokenService::RequestImpl::GetAccountId() const { +CoreAccountId OAuth2TokenService::RequestImpl::GetAccountId() const { return account_id_; }
diff --git a/google_apis/gaia/oauth2_token_service.h b/google_apis/gaia/oauth2_token_service.h index bc5301a..b32b785d0 100644 --- a/google_apis/gaia/oauth2_token_service.h +++ b/google_apis/gaia/oauth2_token_service.h
@@ -65,7 +65,8 @@ class Request { public: virtual ~Request(); - virtual std::string GetAccountId() const = 0; + virtual CoreAccountId GetAccountId() const = 0; + protected: Request(); }; @@ -93,7 +94,7 @@ // The parameters used to fetch an OAuth2 access token. struct RequestParameters { RequestParameters(const std::string& client_id, - const std::string& account_id, + const CoreAccountId& account_id, const ScopeSet& scopes); RequestParameters(const RequestParameters& other); ~RequestParameters(); @@ -102,7 +103,7 @@ // OAuth2 client id. std::string client_id; // Account id for which the request is made. - std::string account_id; + CoreAccountId account_id; // URL scopes for the requested access token. ScopeSet scopes; }; @@ -245,11 +246,11 @@ public Request { public: // |consumer| is required to outlive this. - RequestImpl(const std::string& account_id, Consumer* consumer); + RequestImpl(const CoreAccountId& account_id, Consumer* consumer); ~RequestImpl() override; // Overridden from Request: - std::string GetAccountId() const override; + CoreAccountId GetAccountId() const override; std::string GetConsumerId() const; @@ -260,7 +261,7 @@ private: // |consumer_| to call back when this request completes. - const std::string account_id_; + const CoreAccountId account_id_; Consumer* const consumer_; SEQUENCE_CHECKER(sequence_checker_); @@ -326,13 +327,6 @@ // |StartRequest| method. scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() const; - // Returns a currently valid OAuth2 access token for the given set of scopes, - // or NULL if none have been cached. Note the user of this method should - // ensure no entry with the same |client_scopes| is added before the usage of - // the returned entry is done. - const OAuth2AccessTokenConsumer::TokenResponse* GetCachedTokenResponse( - const RequestParameters& client_scopes); - std::unique_ptr<OAuth2TokenServiceDelegate> delegate_; // The depth of batch changes.
diff --git a/google_apis/gaia/oauth2_token_service_delegate_unittest.cc b/google_apis/gaia/oauth2_token_service_delegate_unittest.cc index ca3e65e..7254bbd 100644 --- a/google_apis/gaia/oauth2_token_service_delegate_unittest.cc +++ b/google_apis/gaia/oauth2_token_service_delegate_unittest.cc
@@ -40,8 +40,8 @@ GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS))) .Times(0); - const std::string account_id1 = "account_id1"; - const std::string account_id2 = "account_id2"; + const CoreAccountId account_id1("account_id1"); + const CoreAccountId account_id2("account_id2"); delegate.UpdateCredentials(account_id1, "refresh_token1"); delegate.UpdateCredentials(account_id2, "refresh_token2");
diff --git a/google_apis/gaia/oauth2_token_service_request.cc b/google_apis/gaia/oauth2_token_service_request.cc index 22ef1d68..41d22256 100644 --- a/google_apis/gaia/oauth2_token_service_request.cc +++ b/google_apis/gaia/oauth2_token_service_request.cc
@@ -152,12 +152,13 @@ class RequestCore : public OAuth2TokenServiceRequest::Core, public OAuth2TokenService::Consumer { public: - RequestCore(OAuth2TokenServiceRequest* owner, - const scoped_refptr< - OAuth2TokenServiceRequest::TokenServiceProvider>& provider, - OAuth2TokenService::Consumer* consumer, - const std::string& account_id, - const OAuth2TokenService::ScopeSet& scopes); + RequestCore( + OAuth2TokenServiceRequest* owner, + const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& + provider, + OAuth2TokenService::Consumer* consumer, + const CoreAccountId& account_id, + const OAuth2TokenService::ScopeSet& scopes); // OAuth2TokenService::Consumer. Must be called on the token service thread. void OnGetTokenSuccess( @@ -181,7 +182,7 @@ void InformOwnerOnGetTokenFailure(GoogleServiceAuthError error); OAuth2TokenService::Consumer* const consumer_; - std::string account_id_; + CoreAccountId account_id_; OAuth2TokenService::ScopeSet scopes_; // OAuth2TokenService request for fetching OAuth2 access token; it should be @@ -196,7 +197,7 @@ const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& provider, OAuth2TokenService::Consumer* consumer, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes) : OAuth2TokenServiceRequest::Core(owner, provider), OAuth2TokenService::Consumer("oauth2_token_service"), @@ -260,12 +261,13 @@ // An implementation of Core for invalidating an access token. class InvalidateCore : public OAuth2TokenServiceRequest::Core { public: - InvalidateCore(OAuth2TokenServiceRequest* owner, - const scoped_refptr< - OAuth2TokenServiceRequest::TokenServiceProvider>& provider, - const std::string& access_token, - const std::string& account_id, - const OAuth2TokenService::ScopeSet& scopes); + InvalidateCore( + OAuth2TokenServiceRequest* owner, + const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& + provider, + const std::string& access_token, + const CoreAccountId& account_id, + const OAuth2TokenService::ScopeSet& scopes); private: friend class base::RefCountedThreadSafe<InvalidateCore>; @@ -278,7 +280,7 @@ void StopOnTokenServiceThread() override; std::string access_token_; - std::string account_id_; + CoreAccountId account_id_; OAuth2TokenService::ScopeSet scopes_; DISALLOW_COPY_AND_ASSIGN(InvalidateCore); @@ -289,7 +291,7 @@ const scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider>& provider, const std::string& access_token, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes) : OAuth2TokenServiceRequest::Core(owner, provider), access_token_(access_token), @@ -319,7 +321,7 @@ std::unique_ptr<OAuth2TokenServiceRequest> OAuth2TokenServiceRequest::CreateAndStart( const scoped_refptr<TokenServiceProvider>& provider, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes, OAuth2TokenService::Consumer* consumer) { std::unique_ptr<OAuth2TokenServiceRequest> request( @@ -333,7 +335,7 @@ // static void OAuth2TokenServiceRequest::InvalidateToken( const scoped_refptr<TokenServiceProvider>& provider, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes, const std::string& access_token) { std::unique_ptr<OAuth2TokenServiceRequest> request( @@ -348,12 +350,12 @@ core_->Stop(); } -std::string OAuth2TokenServiceRequest::GetAccountId() const { +CoreAccountId OAuth2TokenServiceRequest::GetAccountId() const { return account_id_; } OAuth2TokenServiceRequest::OAuth2TokenServiceRequest( - const std::string& account_id) + const CoreAccountId& account_id) : account_id_(account_id) { DCHECK(!account_id_.empty()); }
diff --git a/google_apis/gaia/oauth2_token_service_request.h b/google_apis/gaia/oauth2_token_service_request.h index 1ce0325..061a794 100644 --- a/google_apis/gaia/oauth2_token_service_request.h +++ b/google_apis/gaia/oauth2_token_service_request.h
@@ -70,7 +70,7 @@ // may be populated with the fetched results. static std::unique_ptr<OAuth2TokenServiceRequest> CreateAndStart( const scoped_refptr<TokenServiceProvider>& provider, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes, OAuth2TokenService::Consumer* consumer); @@ -83,21 +83,21 @@ // |scopes| must not be empty. static void InvalidateToken( const scoped_refptr<TokenServiceProvider>& provider, - const std::string& account_id, + const CoreAccountId& account_id, const OAuth2TokenService::ScopeSet& scopes, const std::string& access_token); ~OAuth2TokenServiceRequest() override; // OAuth2TokenService::Request. - std::string GetAccountId() const override; + CoreAccountId GetAccountId() const override; private: - OAuth2TokenServiceRequest(const std::string& account_id); + OAuth2TokenServiceRequest(const CoreAccountId& account_id); void StartWithCore(const scoped_refptr<Core>& core); - const std::string account_id_; + const CoreAccountId account_id_; scoped_refptr<Core> core_; SEQUENCE_CHECKER(sequence_checker_);
diff --git a/google_apis/gaia/oauth2_token_service_request_unittest.cc b/google_apis/gaia/oauth2_token_service_request_unittest.cc index 264873c..96ffb30d 100644 --- a/google_apis/gaia/oauth2_token_service_request_unittest.cc +++ b/google_apis/gaia/oauth2_token_service_request_unittest.cc
@@ -23,7 +23,7 @@ namespace { const char kAccessToken[] = "access_token"; -const char kAccountId[] = "test_user@gmail.com"; +const char kAccountIdString[] = "test_user@gmail.com"; const char kScope[] = "SCOPE"; class TestingOAuth2TokenServiceConsumer : public OAuth2TokenService::Consumer { @@ -158,6 +158,7 @@ class OAuth2TokenServiceRequestTest : public testing::Test { public: + OAuth2TokenServiceRequestTest() : kAccountId_(kAccountIdString) {} void SetUp() override; void TearDown() override; @@ -178,6 +179,7 @@ OAuth2TokenService* token_service_; }; + const CoreAccountId kAccountId_; base::MessageLoop ui_loop_; OAuth2TokenService::ScopeSet scopes_; std::unique_ptr<MockOAuth2TokenService> oauth2_service_; @@ -188,7 +190,7 @@ void OAuth2TokenServiceRequestTest::SetUp() { scopes_.insert(kScope); oauth2_service_.reset(new MockOAuth2TokenService); - oauth2_service_->AddAccount(kAccountId); + oauth2_service_->AddAccount(kAccountId_); provider_ = new Provider(base::ThreadTaskRunnerHandle::Get(), oauth2_service_.get()); } @@ -221,7 +223,7 @@ GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE), std::string(), base::Time(), std::string()); std::unique_ptr<OAuth2TokenServiceRequest> request( - OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId, + OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId_, scopes_, &consumer_)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, consumer_.num_get_token_success_); @@ -233,7 +235,7 @@ TEST_F(OAuth2TokenServiceRequestTest, CreateAndStart_Success) { std::unique_ptr<OAuth2TokenServiceRequest> request( - OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId, + OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId_, scopes_, &consumer_)); base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, consumer_.num_get_token_success_); @@ -245,7 +247,7 @@ TEST_F(OAuth2TokenServiceRequestTest, CreateAndStart_DestroyRequestBeforeCompletes) { std::unique_ptr<OAuth2TokenServiceRequest> request( - OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId, + OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId_, scopes_, &consumer_)); request.reset(); base::RunLoop().RunUntilIdle(); @@ -257,7 +259,7 @@ TEST_F(OAuth2TokenServiceRequestTest, CreateAndStart_DestroyRequestAfterCompletes) { std::unique_ptr<OAuth2TokenServiceRequest> request( - OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId, + OAuth2TokenServiceRequest::CreateAndStart(provider_.get(), kAccountId_, scopes_, &consumer_)); base::RunLoop().RunUntilIdle(); request.reset(); @@ -268,8 +270,8 @@ } TEST_F(OAuth2TokenServiceRequestTest, InvalidateToken) { - OAuth2TokenServiceRequest::InvalidateToken( - provider_.get(), kAccountId, scopes_, kAccessToken); + OAuth2TokenServiceRequest::InvalidateToken(provider_.get(), kAccountId_, + scopes_, kAccessToken); base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, consumer_.num_get_token_success_); EXPECT_EQ(0, consumer_.num_get_token_failure_);
diff --git a/google_apis/gaia/oauth2_token_service_unittest.cc b/google_apis/gaia/oauth2_token_service_unittest.cc index 4f8a516..a7d7e25d 100644 --- a/google_apis/gaia/oauth2_token_service_unittest.cc +++ b/google_apis/gaia/oauth2_token_service_unittest.cc
@@ -30,11 +30,9 @@ class RetryingTestingOAuth2TokenServiceConsumer : public TestingOAuth2TokenServiceConsumer { public: - RetryingTestingOAuth2TokenServiceConsumer( - OAuth2TokenService* oauth2_service, - const std::string& account_id) - : oauth2_service_(oauth2_service), - account_id_(account_id) {} + RetryingTestingOAuth2TokenServiceConsumer(OAuth2TokenService* oauth2_service, + const CoreAccountId& account_id) + : oauth2_service_(oauth2_service), account_id_(account_id) {} ~RetryingTestingOAuth2TokenServiceConsumer() override {} void OnGetTokenFailure(const OAuth2TokenService::Request* request, @@ -49,7 +47,7 @@ int retry_counter_ = 2; OAuth2TokenService* oauth2_service_; - std::string account_id_; + CoreAccountId account_id_; std::unique_ptr<OAuth2TokenService::Request> request_; }; @@ -67,7 +65,7 @@ void CancelAllRequestsForTest() { CancelAllRequests(); } - void CancelRequestsForAccountForTest(const std::string& account_id) { + void CancelRequestsForAccountForTest(const CoreAccountId& account_id) { CancelRequestsForAccount(account_id); } @@ -116,7 +114,7 @@ test_url_loader_factory_ = delegate->test_url_loader_factory(); oauth2_service_ = std::make_unique<TestOAuth2TokenService>(std::move(delegate)); - account_id_ = "test_user@gmail.com"; + account_id_ = CoreAccountId("test_user@gmail.com"); } void TearDown() override { @@ -164,7 +162,7 @@ EXPECT_TRUE(accounts.empty()); // Load tokens from disk. - oauth2_service_->GetDelegate()->LoadCredentials(""); + oauth2_service_->GetDelegate()->LoadCredentials(CoreAccountId()); // |account_id_| should now be visible in the accounts. accounts = oauth2_service_->GetAccounts(); @@ -468,7 +466,7 @@ token_service.GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_, "refreshToken"); - const std::string account_id_2 = "account_id_2"; + const CoreAccountId account_id_2("account_id_2"); token_service.GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_2, "refreshToken"); token_service.GetFakeOAuth2TokenServiceDelegate()->UpdateAuthError( @@ -496,7 +494,8 @@ std::unique_ptr<OAuth2TokenService::Request> request2( token_service.StartRequestForMultilogin(account_id_2, &consumer)); std::unique_ptr<OAuth2TokenService::Request> request3( - token_service.StartRequestForMultilogin("unknown_account", &consumer)); + token_service.StartRequestForMultilogin(CoreAccountId("unknown_account"), + &consumer)); base::RunLoop().RunUntilIdle(); } @@ -567,7 +566,7 @@ token_service.GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_, "refreshToken"); - const std::string account_id_2 = "account_id_2"; + const CoreAccountId account_id_2("account_id_2"); token_service.GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_2, "refreshToken2"); token_service.InvalidateTokenForMultilogin(account_id_, "refreshToken"); @@ -596,7 +595,7 @@ oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_, "refreshToken"); - const std::string account_id_2 = "account_id_2"; + const CoreAccountId account_id_2("account_id_2"); oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_2, "refreshToken2"); ; @@ -674,9 +673,9 @@ std::unique_ptr<OAuth2TokenService::Request> request( oauth2_service_->StartRequest(account_id_, OAuth2TokenService::ScopeSet(), &consumer_)); - + const CoreAccountId account_id_2("account_id_2"); oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( - "account_id_2", "refreshToken2"); + account_id_2, "refreshToken2"); std::unique_ptr<OAuth2TokenService::Request> request2( oauth2_service_->StartRequest(account_id_, OAuth2TokenService::ScopeSet(), &consumer_)); @@ -706,7 +705,7 @@ std::unique_ptr<OAuth2TokenService::Request> request2( oauth2_service_->StartRequest(account_id_, scope_set_2, &consumer_)); - std::string account_id_2("account_id_2"); + const CoreAccountId account_id_2("account_id_2"); oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( account_id_2, "refreshToken2"); std::unique_ptr<OAuth2TokenService::Request> request3( @@ -769,15 +768,17 @@ OAuth2TokenService::ScopeSet set_1; set_1.insert("1"); + const CoreAccountId account_id0("0"); + const CoreAccountId account_id1("1"); OAuth2TokenService::RequestParameters params[] = { - OAuth2TokenService::RequestParameters("0", "0", set_0), - OAuth2TokenService::RequestParameters("0", "0", set_1), - OAuth2TokenService::RequestParameters("0", "1", set_0), - OAuth2TokenService::RequestParameters("0", "1", set_1), - OAuth2TokenService::RequestParameters("1", "0", set_0), - OAuth2TokenService::RequestParameters("1", "0", set_1), - OAuth2TokenService::RequestParameters("1", "1", set_0), - OAuth2TokenService::RequestParameters("1", "1", set_1), + OAuth2TokenService::RequestParameters("0", account_id0, set_0), + OAuth2TokenService::RequestParameters("0", account_id0, set_1), + OAuth2TokenService::RequestParameters("0", account_id1, set_0), + OAuth2TokenService::RequestParameters("0", account_id1, set_1), + OAuth2TokenService::RequestParameters("1", account_id0, set_0), + OAuth2TokenService::RequestParameters("1", account_id0, set_1), + OAuth2TokenService::RequestParameters("1", account_id1, set_0), + OAuth2TokenService::RequestParameters("1", account_id1, set_1), }; for (size_t i = 0; i < base::size(params); i++) { @@ -797,13 +798,13 @@ } TEST_F(OAuth2TokenServiceTest, UpdateClearsCache) { - std::string kEmail = "test@gmail.com"; + const CoreAccountId account_id("test@gmail.com"); std::set<std::string> scope_list; scope_list.insert("scope"); oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( - kEmail, "refreshToken"); + account_id, "refreshToken"); std::unique_ptr<OAuth2TokenService::Request> request( - oauth2_service_->StartRequest(kEmail, scope_list, &consumer_)); + oauth2_service_->StartRequest(account_id, scope_list, &consumer_)); SimulateOAuthTokenResponse(GetValidTokenResponse("token", 3600)); base::RunLoop().RunUntilIdle(); @@ -816,9 +817,9 @@ EXPECT_EQ(0, (int)oauth2_service_->token_cache().size()); oauth2_service_->GetFakeOAuth2TokenServiceDelegate()->UpdateCredentials( - kEmail, "refreshToken"); + account_id, "refreshToken"); SimulateOAuthTokenResponse(GetValidTokenResponse("another token", 3600)); - request = oauth2_service_->StartRequest(kEmail, scope_list, &consumer_); + request = oauth2_service_->StartRequest(account_id, scope_list, &consumer_); base::RunLoop().RunUntilIdle(); EXPECT_EQ(2, consumer_.number_of_successful_tokens_); EXPECT_EQ(0, consumer_.number_of_errors_);
diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn index fe1e9b4..26a144c 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn
@@ -392,7 +392,6 @@ "//ui/platform_window", "//ui/platform_window:platform_impls", ] - sources += [ "command_buffer/service/swap_chain_factory_dxgi_unittest.cc" ] } if (use_dawn) {
diff --git a/gpu/command_buffer/service/shared_context_state.cc b/gpu/command_buffer/service/shared_context_state.cc index a9d31cc..86f5d21 100644 --- a/gpu/command_buffer/service/shared_context_state.cc +++ b/gpu/command_buffer/service/shared_context_state.cc
@@ -51,6 +51,8 @@ real_context_(std::move(context)), surface_(std::move(surface)), weak_ptr_factory_(this) { + raster::DetermineGrCacheLimitsFromAvailableMemory( + &max_resource_cache_bytes_, &glyph_cache_max_texture_bytes_); if (GrContextIsVulkan()) { #if BUILDFLAG(ENABLE_VULKAN) gr_context_ = vk_context_provider_->GetGrContext(); @@ -143,23 +145,21 @@ options.fDriverBugWorkarounds = GrDriverBugWorkarounds(workarounds.ToIntSet()); options.fDisableCoverageCountingPaths = true; - size_t max_resource_cache_bytes = 0u; - raster::DetermineGrCacheLimitsFromAvailableMemory( - &max_resource_cache_bytes, &glyph_cache_max_texture_bytes_); options.fGlyphCacheTextureMaximumBytes = glyph_cache_max_texture_bytes_; options.fPersistentCache = cache; options.fAvoidStencilBuffers = workarounds.avoid_stencil_buffers; options.fDisallowGLSLBinaryCaching = workarounds.disable_program_disk_cache; owned_gr_context_ = GrContext::MakeGL(std::move(interface), options); gr_context_ = owned_gr_context_.get(); - if (!gr_context_) { - LOG(ERROR) << "OOP raster support disabled: GrContext creation " - "failed."; - } else { - constexpr int kMaxGaneshResourceCacheCount = 16384; - gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, - max_resource_cache_bytes); - } + } + + if (!gr_context_) { + LOG(ERROR) << "OOP raster support disabled: GrContext creation " + "failed."; + } else { + constexpr int kMaxGaneshResourceCacheCount = 16384; + gr_context_->setResourceCacheLimits(kMaxGaneshResourceCacheCount, + max_resource_cache_bytes_); } transfer_cache_ = std::make_unique<ServiceTransferCache>(); }
diff --git a/gpu/command_buffer/service/shared_context_state.h b/gpu/command_buffer/service/shared_context_state.h index 56b335e..c0c6dcf 100644 --- a/gpu/command_buffer/service/shared_context_state.h +++ b/gpu/command_buffer/service/shared_context_state.h
@@ -104,6 +104,7 @@ std::vector<uint8_t>* scratch_deserialization_buffer() { return &scratch_deserialization_buffer_; } + size_t max_resource_cache_bytes() const { return max_resource_cache_bytes_; } size_t glyph_cache_max_texture_bytes() const { return glyph_cache_max_texture_bytes_; } @@ -173,6 +174,7 @@ gl::ProgressReporter* progress_reporter_ = nullptr; sk_sp<GrContext> owned_gr_context_; std::unique_ptr<ServiceTransferCache> transfer_cache_; + size_t max_resource_cache_bytes_ = 0u; size_t glyph_cache_max_texture_bytes_ = 0u; std::vector<uint8_t> scratch_deserialization_buffer_;
diff --git a/gpu/command_buffer/service/swap_chain_factory_dxgi.cc b/gpu/command_buffer/service/swap_chain_factory_dxgi.cc index 0001acf..f67a7d2 100644 --- a/gpu/command_buffer/service/swap_chain_factory_dxgi.cc +++ b/gpu/command_buffer/service/swap_chain_factory_dxgi.cc
@@ -229,15 +229,15 @@ gl::GLImage* image; unsigned target = GL_TEXTURE_2D; + gles2::Texture::ImageState image_state; if (texture_) { - gles2::Texture::ImageState image_state; image = texture_->GetLevelImage(target, 0, &image_state); - DCHECK_EQ(image_state, gles2::Texture::BOUND); } else { DCHECK(texture_passthrough_); image = texture_passthrough_->GetLevelImage(target, 0); } DCHECK(image); + DCHECK_EQ(image_state, gles2::Texture::BOUND); if (!image->BindTexImage(target)) { DLOG(ERROR) << "Failed to rebind texture to new surface."; @@ -314,10 +314,6 @@ auto image = base::MakeRefCounted<gl::GLImageDXGISwapChain>( size, viz::BufferFormat(format), d3d11_texture, swap_chain); - if (!image->Initialize()) { - DLOG(ERROR) << "Failed to create EGL image"; - return nullptr; - } if (!image->BindTexImage(target)) { DLOG(ERROR) << "Failed to bind image to swap chain D3D11 texture."; return nullptr; @@ -397,7 +393,7 @@ desc.Stereo = FALSE; desc.SampleDesc.Count = 1; desc.BufferCount = 2; - desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; desc.Scaling = DXGI_SCALING_STRETCH; desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; desc.Flags = 0;
diff --git a/gpu/command_buffer/service/swap_chain_factory_dxgi.h b/gpu/command_buffer/service/swap_chain_factory_dxgi.h index f384efa..ba21b19 100644 --- a/gpu/command_buffer/service/swap_chain_factory_dxgi.h +++ b/gpu/command_buffer/service/swap_chain_factory_dxgi.h
@@ -28,7 +28,7 @@ explicit SwapChainFactoryDXGI(bool use_passthrough); ~SwapChainFactoryDXGI(); - struct GPU_GLES2_EXPORT SwapChainBackings { + struct SwapChainBackings { SwapChainBackings(std::unique_ptr<SharedImageBacking> front_buffer, std::unique_ptr<SharedImageBacking> back_buffer); ~SwapChainBackings();
diff --git a/gpu/command_buffer/service/swap_chain_factory_dxgi_unittest.cc b/gpu/command_buffer/service/swap_chain_factory_dxgi_unittest.cc deleted file mode 100644 index 33216f3..0000000 --- a/gpu/command_buffer/service/swap_chain_factory_dxgi_unittest.cc +++ /dev/null
@@ -1,274 +0,0 @@ -// Copyright 2019 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 "gpu/command_buffer/service/swap_chain_factory_dxgi.h" - -#include <memory> -#include <utility> - -#include "base/bind_helpers.h" -#include "gpu/command_buffer/common/shared_image_usage.h" -#include "gpu/command_buffer/service/service_utils.h" -#include "gpu/command_buffer/service/shared_context_state.h" -#include "gpu/command_buffer/service/shared_image_factory.h" -#include "gpu/command_buffer/service/shared_image_manager.h" -#include "gpu/command_buffer/service/shared_image_representation.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_image_dxgi_swap_chain.h" -#include "ui/gl/gl_surface.h" -#include "ui/gl/init/gl_factory.h" - -namespace gpu { -namespace { - -class SwapChainFactoryDXGITest : public testing::Test { - public: - void SetUp() override { - surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); - ASSERT_TRUE(surface_); - context_ = gl::init::CreateGLContext(nullptr, surface_.get(), - gl::GLContextAttribs()); - ASSERT_TRUE(context_); - bool result = context_->MakeCurrent(surface_.get()); - ASSERT_TRUE(result); - - memory_type_tracker_ = std::make_unique<MemoryTypeTracker>(nullptr); - shared_image_representation_factory_ = - std::make_unique<SharedImageRepresentationFactory>( - &shared_image_manager_, nullptr); - } - - protected: - bool UsesPassthrough() const { - return gles2::PassthroughCommandDecoderSupported(); - } - void CreateAndPresentSwapChain(bool uses_passthrough_texture); - - scoped_refptr<gl::GLSurface> surface_; - scoped_refptr<gl::GLContext> context_; - SharedImageManager shared_image_manager_; - std::unique_ptr<MemoryTypeTracker> memory_type_tracker_; - std::unique_ptr<SharedImageRepresentationFactory> - shared_image_representation_factory_; -}; - -void SwapChainFactoryDXGITest::CreateAndPresentSwapChain( - bool uses_passthrough_texture) { - std::unique_ptr<SwapChainFactoryDXGI> swap_chain_factory_ = - std::make_unique<SwapChainFactoryDXGI>(uses_passthrough_texture); - auto front_buffer_mailbox = Mailbox::GenerateForSharedImage(); - auto back_buffer_mailbox = Mailbox::GenerateForSharedImage(); - auto format = viz::RGBA_8888; - gfx::Size size(1, 1); - auto color_space = gfx::ColorSpace::CreateSRGB(); - uint32_t usage = gpu::SHARED_IMAGE_USAGE_GLES2 | - gpu::SHARED_IMAGE_USAGE_GLES2_FRAMEBUFFER_HINT | - gpu::SHARED_IMAGE_USAGE_DISPLAY | - gpu::SHARED_IMAGE_USAGE_SCANOUT; - - auto backings = swap_chain_factory_->CreateSwapChain( - front_buffer_mailbox, back_buffer_mailbox, format, size, color_space, - usage); - ASSERT_TRUE(backings.front_buffer); - ASSERT_TRUE(backings.back_buffer); - - GLenum expected_target = GL_TEXTURE_2D; - Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture; - scoped_refptr<gles2::TexturePassthrough> back_passthrough_texture; - gles2::Texture* back_texture; - gl::GLImageDXGISwapChain* back_image; - gl::GLImageDXGISwapChain* front_image; - - std::unique_ptr<SharedImageRepresentationFactoryRef> back_factory_ref = - shared_image_manager_.Register(std::move(backings.back_buffer), - memory_type_tracker_.get()); - std::unique_ptr<SharedImageRepresentationFactoryRef> front_factory_ref = - shared_image_manager_.Register(std::move(backings.front_buffer), - memory_type_tracker_.get()); - - if (uses_passthrough_texture) { - auto back_gl_representation = - shared_image_representation_factory_->ProduceGLTexturePassthrough( - back_buffer_mailbox); - ASSERT_TRUE(back_gl_representation); - back_passthrough_texture = back_gl_representation->GetTexturePassthrough(); - EXPECT_TRUE(back_passthrough_texture); - EXPECT_EQ(TextureBase::Type::kPassthrough, - back_passthrough_texture->GetType()); - EXPECT_EQ(expected_target, back_passthrough_texture->target()); - back_gl_representation.reset(); - - back_image = gl::GLImageDXGISwapChain::FromGLImage( - back_passthrough_texture->GetLevelImage( - back_passthrough_texture->target(), 0)); - ASSERT_TRUE(back_image); - - auto front_gl_representation = - shared_image_representation_factory_->ProduceGLTexturePassthrough( - front_buffer_mailbox); - ASSERT_TRUE(front_gl_representation); - auto front_passthrough_texture = - front_gl_representation->GetTexturePassthrough(); - EXPECT_TRUE(front_passthrough_texture); - EXPECT_EQ(TextureBase::Type::kPassthrough, - front_passthrough_texture->GetType()); - EXPECT_EQ(expected_target, front_passthrough_texture->target()); - front_gl_representation.reset(); - - front_image = gl::GLImageDXGISwapChain::FromGLImage( - front_passthrough_texture->GetLevelImage( - front_passthrough_texture->target(), 0)); - ASSERT_TRUE(front_image); - front_passthrough_texture.reset(); - } else { - auto back_gl_representation = - shared_image_representation_factory_->ProduceGLTexture( - back_buffer_mailbox); - ASSERT_TRUE(back_gl_representation); - back_texture = back_gl_representation->GetTexture(); - EXPECT_TRUE(back_texture); - EXPECT_EQ(TextureBase::Type::kValidated, back_texture->GetType()); - EXPECT_EQ(expected_target, back_texture->target()); - // Ensures that back buffer is explicitly cleared. - EXPECT_TRUE(back_texture->IsLevelCleared(back_texture->target(), 0)); - back_gl_representation.reset(); - - gles2::Texture::ImageState image_state; - back_image = gl::GLImageDXGISwapChain::FromGLImage( - back_texture->GetLevelImage(back_texture->target(), 0, &image_state)); - ASSERT_TRUE(back_image); - EXPECT_EQ(gles2::Texture::BOUND, image_state); - - auto front_gl_representation = - shared_image_representation_factory_->ProduceGLTexture( - front_buffer_mailbox); - ASSERT_TRUE(front_gl_representation); - gles2::Texture* front_texture = front_gl_representation->GetTexture(); - EXPECT_TRUE(front_texture); - EXPECT_EQ(TextureBase::Type::kValidated, front_texture->GetType()); - EXPECT_EQ(expected_target, front_texture->target()); - // Ensures that front buffer is explicitly cleared. - EXPECT_TRUE(front_texture->IsLevelCleared(front_texture->target(), 0)); - front_gl_representation.reset(); - - front_image = gl::GLImageDXGISwapChain::FromGLImage( - front_texture->GetLevelImage(front_texture->target(), 0, &image_state)); - ASSERT_TRUE(front_image); - EXPECT_EQ(gles2::Texture::BOUND, image_state); - } - - EXPECT_EQ(S_OK, back_image->swap_chain()->GetBuffer( - 0 /* buffer_index */, IID_PPV_ARGS(&d3d11_texture))); - EXPECT_TRUE(d3d11_texture); - EXPECT_EQ(d3d11_texture, back_image->texture()); - d3d11_texture.Reset(); - - EXPECT_EQ(S_OK, front_image->swap_chain()->GetBuffer( - 1 /* buffer_index */, IID_PPV_ARGS(&d3d11_texture))); - EXPECT_TRUE(d3d11_texture); - EXPECT_EQ(d3d11_texture, front_image->texture()); - d3d11_texture.Reset(); - - GLenum target; - GLuint service_id; - if (uses_passthrough_texture) { - target = back_passthrough_texture->target(); - service_id = back_passthrough_texture->service_id(); - back_passthrough_texture.reset(); - } else { - target = back_texture->target(); - service_id = back_texture->service_id(); - } - - // Create an FBO. - GLuint fbo = 0; - gl::GLApi* api = gl::g_current_gl_context; - api->glGenFramebuffersEXTFn(1, &fbo); - api->glBindFramebufferEXTFn(GL_FRAMEBUFFER, fbo); - api->glBindTextureFn(target, service_id); - ASSERT_EQ(api->glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); - - // Attach the texture to FBO. - api->glFramebufferTexture2DEXTFn(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, - service_id, 0); - EXPECT_EQ(api->glCheckFramebufferStatusEXTFn(GL_FRAMEBUFFER), - static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE)); - ASSERT_EQ(api->glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); - - api->glViewportFn(0, 0, size.width(), size.height()); - // Set the clear color to green. - api->glClearColorFn(0.0f, 1.0f, 0.0f, 1.0f); - api->glClearFn(GL_COLOR_BUFFER_BIT); - ASSERT_EQ(api->glGetErrorFn(), static_cast<GLenum>(GL_NO_ERROR)); - - { - GLubyte pixel_color[4]; - const uint8_t expected_color[4] = {0, 255, 0, 255}; - // Checks if rendering to back buffer was successful. - api->glReadPixelsFn(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); - EXPECT_EQ(expected_color[0], pixel_color[0]); - EXPECT_EQ(expected_color[1], pixel_color[1]); - EXPECT_EQ(expected_color[2], pixel_color[2]); - EXPECT_EQ(expected_color[3], pixel_color[3]); - } - - back_factory_ref->PresentSwapChain(); - - // TODO(ashithasantosh): Check contents of front buffer. - { - GLubyte pixel_color[4]; - const uint8_t expected_color[4] = {0, 0, 0, 255}; - // After present, back buffer should now have a clear texture. - api->glReadPixelsFn(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel_color); - EXPECT_EQ(expected_color[0], pixel_color[0]); - EXPECT_EQ(expected_color[1], pixel_color[1]); - EXPECT_EQ(expected_color[2], pixel_color[2]); - EXPECT_EQ(expected_color[3], pixel_color[3]); - } - api->glDeleteFramebuffersEXTFn(1, &fbo); -} - -TEST_F(SwapChainFactoryDXGITest, InvalidFormat) { - std::unique_ptr<SwapChainFactoryDXGI> swap_chain_factory_ = - std::make_unique<SwapChainFactoryDXGI>(false /* use_passthrough */); - auto front_buffer_mailbox = Mailbox::GenerateForSharedImage(); - auto back_buffer_mailbox = Mailbox::GenerateForSharedImage(); - gfx::Size size(1, 1); - auto color_space = gfx::ColorSpace::CreateSRGB(); - uint32_t usage = gpu::SHARED_IMAGE_USAGE_SCANOUT; - { - auto valid_format = viz::RGBA_8888; - auto backings = swap_chain_factory_->CreateSwapChain( - front_buffer_mailbox, back_buffer_mailbox, valid_format, size, - color_space, usage); - EXPECT_TRUE(backings.front_buffer); - EXPECT_TRUE(backings.back_buffer); - backings.front_buffer->Destroy(); - backings.back_buffer->Destroy(); - } - { - auto invalid_format = viz::BGRA_8888; - auto backings = swap_chain_factory_->CreateSwapChain( - front_buffer_mailbox, back_buffer_mailbox, invalid_format, size, - color_space, usage); - EXPECT_FALSE(backings.front_buffer); - EXPECT_FALSE(backings.back_buffer); - } -} - -TEST_F(SwapChainFactoryDXGITest, CreateAndPresentSwapChain) { - if (UsesPassthrough()) - return; - CreateAndPresentSwapChain(false /* uses_passthrough_texture */); -} - -TEST_F(SwapChainFactoryDXGITest, CreateAndPresentSwapChain_PassthroughTexture) { - if (!UsesPassthrough()) - return; - CreateAndPresentSwapChain(true /* uses_passthrough_texture */); -} - -} // anonymous namespace -} // namespace gpu
diff --git a/headless/lib/browser/headless_browser_main_parts.cc b/headless/lib/browser/headless_browser_main_parts.cc index ac457478..2278ea2 100644 --- a/headless/lib/browser/headless_browser_main_parts.cc +++ b/headless/lib/browser/headless_browser_main_parts.cc
@@ -11,8 +11,10 @@ namespace headless { -HeadlessBrowserMainParts::HeadlessBrowserMainParts(HeadlessBrowserImpl* browser) - : browser_(browser) {} +HeadlessBrowserMainParts::HeadlessBrowserMainParts( + const content::MainFunctionParams& parameters, + HeadlessBrowserImpl* browser) + : parameters_(parameters), browser_(browser) {} HeadlessBrowserMainParts::~HeadlessBrowserMainParts() = default; @@ -22,6 +24,13 @@ devtools_http_handler_started_ = true; } browser_->PlatformInitialize(); + browser_->RunOnStartCallback(); + + if (parameters_.ui_task) { + parameters_.ui_task->Run(); + delete parameters_.ui_task; + run_message_loop_ = false; + } } void HeadlessBrowserMainParts::PreDefaultMainMessageLoopRun( @@ -29,6 +38,10 @@ quit_main_message_loop_ = std::move(quit_closure); } +bool HeadlessBrowserMainParts::MainMessageLoopRun(int* result_code) { + return !run_message_loop_; +} + void HeadlessBrowserMainParts::PostMainMessageLoopRun() { if (devtools_http_handler_started_) { StopLocalDevToolsHttpHandler();
diff --git a/headless/lib/browser/headless_browser_main_parts.h b/headless/lib/browser/headless_browser_main_parts.h index f396a74f..2331a0a8 100644 --- a/headless/lib/browser/headless_browser_main_parts.h +++ b/headless/lib/browser/headless_browser_main_parts.h
@@ -9,6 +9,7 @@ #include "base/files/file_path.h" #include "content/public/browser/browser_main_parts.h" +#include "content/public/common/main_function_params.h" #include "headless/public/headless_browser.h" namespace headless { @@ -17,12 +18,15 @@ class HeadlessBrowserMainParts : public content::BrowserMainParts { public: - explicit HeadlessBrowserMainParts(HeadlessBrowserImpl* browser); + explicit HeadlessBrowserMainParts( + const content::MainFunctionParams& parameters, + HeadlessBrowserImpl* browser); ~HeadlessBrowserMainParts() override; // content::BrowserMainParts implementation: void PreMainMessageLoopRun() override; void PreDefaultMainMessageLoopRun(base::OnceClosure quit_closure) override; + bool MainMessageLoopRun(int* result_code) override; void PostMainMessageLoopRun() override; #if defined(OS_MACOSX) void PreMainMessageLoopStart() override; @@ -31,8 +35,10 @@ void QuitMainMessageLoop(); private: + const content::MainFunctionParams parameters_; // For running browser tests. HeadlessBrowserImpl* browser_; // Not owned. + bool run_message_loop_ = true; bool devtools_http_handler_started_ = false; base::OnceClosure quit_main_message_loop_;
diff --git a/headless/lib/browser/headless_content_browser_client.cc b/headless/lib/browser/headless_content_browser_client.cc index 6839764..e9039ab6 100644 --- a/headless/lib/browser/headless_content_browser_client.cc +++ b/headless/lib/browser/headless_content_browser_client.cc
@@ -120,9 +120,9 @@ std::unique_ptr<content::BrowserMainParts> HeadlessContentBrowserClient::CreateBrowserMainParts( - const content::MainFunctionParams&) { + const content::MainFunctionParams& parameters) { auto browser_main_parts = - std::make_unique<HeadlessBrowserMainParts>(browser_); + std::make_unique<HeadlessBrowserMainParts>(parameters, browser_); browser_->set_browser_main_parts(browser_main_parts.get());
diff --git a/headless/lib/headless_content_main_delegate.cc b/headless/lib/headless_content_main_delegate.cc index 20de0f1..3bbf129 100644 --- a/headless/lib/headless_content_main_delegate.cc +++ b/headless/lib/headless_content_main_delegate.cc
@@ -315,7 +315,6 @@ DCHECK_LT(exit_code, 0) << "content::BrowserMainRunner::Initialize failed in " "HeadlessContentMainDelegate::RunProcess"; - browser_->RunOnStartCallback(); browser_runner->Run(); browser_runner->Shutdown(); browser_.reset();
diff --git a/infra/config/luci-scheduler.cfg b/infra/config/luci-scheduler.cfg index 830368ab..d1684b7 100644 --- a/infra/config/luci-scheduler.cfg +++ b/infra/config/luci-scheduler.cfg
@@ -374,6 +374,7 @@ triggers: "win-archive-dbg" triggers: "win-jumbo-rel" triggers: "win-archive-rel" + triggers: "win-celab-builder-rel" triggers: "win-pixel-builder-rel" triggers: "win32-arm64-rel" triggers: "win32-archive-dbg"
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index 1e22a9b0..459123c 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -1883,9 +1883,15 @@ <message name="IDS_IOS_TOOLS_MENU_HISTORY" desc="The Tools menu item for opening the navigation history menu"> History </message> +<message name="IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_SEARCH" desc="The iOS menu item for opening a new incognito tab and doing a new search in that tab." meaning="Do a new search in a new incognito tab"> +Incognito Search +</message> <message name="IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB" desc="The iOS menu item for opening a new incognito tab [iOS only]" meaning="Tools menu entry to create a new Incognito tab. [Length: Unlimited]"> New Incognito Tab </message> +<message name="IDS_IOS_TOOLS_MENU_NEW_SEARCH" desc="The iOS menu item for opening a new tab and doing a new search in that tab." meaning="Do a new search in a new tab"> +New Search +</message> <message name="IDS_IOS_TOOLS_MENU_NEW_TAB" desc="The iOS menu item for opening a new tab [iOS only]" meaning="Tools menu entry to create a new tab. [Length: Unlimited]"> New Tab </message>
diff --git a/ios/chrome/browser/about_flags.mm b/ios/chrome/browser/about_flags.mm index 4577443..99b5095 100644 --- a/ios/chrome/browser/about_flags.mm +++ b/ios/chrome/browser/about_flags.mm
@@ -581,6 +581,9 @@ flag_descriptions::kSendTabToSelfHistoryName, flag_descriptions::kSendTabToSelfHistoryDescription, flags_ui::kOsIos, FEATURE_VALUE_TYPE(send_tab_to_self::kSendTabToSelfHistory)}, + {"toolbar-new-tab-button", flag_descriptions::kToolbarNewTabButtonName, + flag_descriptions::kToolbarNewTabButtonDescription, flags_ui::kOsIos, + FEATURE_VALUE_TYPE(kToolbarNewTabButton)}, }; // Add all switches from experimental flags to |command_line|.
diff --git a/ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.cc b/ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.cc index b5d64b0..1d84c98a 100644 --- a/ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.cc +++ b/ios/chrome/browser/browser_state/chrome_browser_state_manager_impl.cc
@@ -18,8 +18,6 @@ #include "base/threading/scoped_blocking_call.h" #include "components/password_manager/core/browser/password_store.h" #include "components/prefs/pref_service.h" -#include "components/signin/core/browser/account_fetcher_service.h" -#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/ios/browser/active_state_manager.h" #include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/browser_state/browser_state_info_cache.h"
diff --git a/ios/chrome/browser/ios_chrome_flag_descriptions.cc b/ios/chrome/browser/ios_chrome_flag_descriptions.cc index a351350..efa0aea 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.cc +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.cc
@@ -416,6 +416,11 @@ "When enabled, the toolbars and their fullscreen animations will be " "managed by the toolbar container coordinator rather than BVC."; +const char kToolbarNewTabButtonName[] = + "Enable New Tab button in the bottom toolbar"; +const char kToolbarNewTabButtonDescription[] = + "When enabled, the bottom toolbar middle button opens a new tab"; + const char kTranslateManualTriggerName[] = "Enable manual translate trigger"; const char kTranslateManualTriggerDescription[] = "Show a menu item in the popup menu that triggers page translation.";
diff --git a/ios/chrome/browser/ios_chrome_flag_descriptions.h b/ios/chrome/browser/ios_chrome_flag_descriptions.h index 46e41f1..6379bbc 100644 --- a/ios/chrome/browser/ios_chrome_flag_descriptions.h +++ b/ios/chrome/browser/ios_chrome_flag_descriptions.h
@@ -354,6 +354,11 @@ extern const char kToolbarContainerName[]; extern const char kToolbarContainerDescription[]; +// Title and description for the flag to enable the new tab button in the +// toolbar. +extern const char kToolbarNewTabButtonName[]; +extern const char kToolbarNewTabButtonDescription[]; + // Title and description for the flag to control manual translate trigger. extern const char kTranslateManualTriggerName[]; extern const char kTranslateManualTriggerDescription[];
diff --git a/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h b/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h index 64c07e7..9e6131675 100644 --- a/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h +++ b/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h
@@ -11,7 +11,6 @@ #include "components/password_manager/core/browser/password_manager_driver.h" namespace autofill { -struct PasswordForm; struct PasswordFormFillData; } // namespace autofill @@ -42,7 +41,7 @@ // Informs delegate of form for password generation found. - (void)formEligibleForGenerationFound: - (const autofill::NewPasswordFormGenerationData&)form; + (const autofill::PasswordFormGenerationData&)form; @end @@ -58,12 +57,8 @@ void FillPasswordForm( const autofill::PasswordFormFillData& form_data) override; void InformNoSavedCredentials() override; - void AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) override; - void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) override; void FormEligibleForGenerationFound( - const autofill::NewPasswordFormGenerationData& form) override; + const autofill::PasswordFormGenerationData& form) override; void GeneratedPasswordAccepted(const base::string16& password) override; void FillSuggestion(const base::string16& username, const base::string16& password) override;
diff --git a/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.mm b/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.mm index 194a658..eec5d9b 100644 --- a/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.mm +++ b/ios/chrome/browser/passwords/ios_chrome_password_manager_driver.mm
@@ -32,11 +32,8 @@ [delegate_ onNoSavedCredentials]; } -void IOSChromePasswordManagerDriver::FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) {} - void IOSChromePasswordManagerDriver::FormEligibleForGenerationFound( - const autofill::NewPasswordFormGenerationData& form) { + const autofill::PasswordFormGenerationData& form) { if (GetPasswordGenerationHelper() && GetPasswordGenerationHelper()->IsGenerationEnabled( /*log_debug_data*/ true)) { @@ -80,10 +77,6 @@ return [delegate_ passwordManager]; } -void IOSChromePasswordManagerDriver::AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) { -} - PasswordAutofillManager* IOSChromePasswordManagerDriver::GetPasswordAutofillManager() { // TODO(crbug.com/341877): Use PasswordAutofillManager to implement password
diff --git a/ios/chrome/browser/passwords/password_controller.mm b/ios/chrome/browser/passwords/password_controller.mm index cb1d517..7b1f411 100644 --- a/ios/chrome/browser/passwords/password_controller.mm +++ b/ios/chrome/browser/passwords/password_controller.mm
@@ -75,7 +75,7 @@ #endif using autofill::FormData; -using autofill::NewPasswordFormGenerationData; +using autofill::PasswordFormGenerationData; using autofill::PasswordForm; using base::SysNSStringToUTF16; using base::SysUTF16ToNSString; @@ -201,7 +201,7 @@ std::unique_ptr<autofill::PasswordForm> _pendingAutoSigninPasswordForm; // Form data for password generation on this page. - std::map<base::string16, NewPasswordFormGenerationData> _formGenerationData; + std::map<base::string16, PasswordFormGenerationData> _formGenerationData; } - (instancetype)initWithWebState:(web::WebState*)webState { @@ -578,8 +578,7 @@ return _passwordGenerationHelper.get(); } -- (void)formEligibleForGenerationFound: - (const NewPasswordFormGenerationData&)form { +- (void)formEligibleForGenerationFound:(const PasswordFormGenerationData&)form { _formGenerationData[form.form_name] = form; } @@ -729,7 +728,7 @@ return NO; if (![fieldType isEqualToString:@"password"]) return NO; - const NewPasswordFormGenerationData* generation_data = + const PasswordFormGenerationData* generation_data = [self getFormForGenerationFromFormName:formName]; if (!generation_data) return NO; @@ -743,7 +742,7 @@ return NO; } -- (const NewPasswordFormGenerationData*)getFormForGenerationFromFormName: +- (const PasswordFormGenerationData*)getFormForGenerationFromFormName: (NSString*)formName { const base::string16 name = SysNSStringToUTF16(formName); if (_formGenerationData.find(name) != _formGenerationData.end()) { @@ -854,7 +853,7 @@ - (void)injectGeneratedPasswordForFormName:(NSString*)formName generatedPassword:(NSString*)generatedPassword completionHandler:(void (^)())completionHandler { - const autofill::NewPasswordFormGenerationData* generation_data = + const autofill::PasswordFormGenerationData* generation_data = [self getFormForGenerationFromFormName:formName]; if (!generation_data) return;
diff --git a/ios/chrome/browser/tabs/tab.h b/ios/chrome/browser/tabs/tab.h index af10c42..ed1038c 100644 --- a/ios/chrome/browser/tabs/tab.h +++ b/ios/chrome/browser/tabs/tab.h
@@ -33,9 +33,6 @@ - (instancetype)init NS_UNAVAILABLE; -// Dismisses all modals owned by the tab. -- (void)dismissModals; - @end #endif // IOS_CHROME_BROWSER_TABS_TAB_H_
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm index 196ec030c..c083ac54 100644 --- a/ios/chrome/browser/tabs/tab.mm +++ b/ios/chrome/browser/tabs/tab.mm
@@ -62,12 +62,6 @@ return _webStateImpl; } -#pragma mark - Public API - -- (void)dismissModals { - [self.webController dismissModals]; -} - #pragma mark - CRWWebStateObserver protocol - (void)webStateDestroyed:(web::WebState*)webState {
diff --git a/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm index 595d8c5..d60d31c3 100644 --- a/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm +++ b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm
@@ -26,7 +26,7 @@ // Rectangle for the popover alert. Only used when |_anchorMode| is VIEW. CGRect _rect; // View for the popovert alert. Only used when |_anchorMode| is VIEW. - UIView* _view; + __weak UIView* _view; // Bar button item for the popover alert. Only used when |_anchorMode| is // BAR_BUTTON_ITEM.
diff --git a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm index dc634a7..532e3d8 100644 --- a/ios/chrome/browser/ui/browser_view/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view/browser_view_controller.mm
@@ -1315,7 +1315,6 @@ _voiceSearchController->DismissMicPermissionsHelp(); web::WebState* webState = self.currentWebState; - [self.tabModel.currentTab dismissModals]; if (webState) { if (self.isNTPActiveForCurrentWebState) {
diff --git a/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm b/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm index 0fc666b0..a62e7397 100644 --- a/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm +++ b/ios/chrome/browser/ui/omnibox/omnibox_mediator.mm
@@ -149,7 +149,7 @@ // The code below mimics that in OmniboxPopupMediator. self.faviconLoader->FaviconForPageUrl( pageURL, kOmniboxIconSize, kOmniboxIconSize, - /*fallback_to_google_server=*/YES, handleFaviconResult); + /*fallback_to_google_server=*/false, handleFaviconResult); } // Loads a favicon for the current default search engine.
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm index f14e90d..d0e6f0a 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm
@@ -187,7 +187,7 @@ self.faviconLoader->FaviconForPageUrl( pageURL, kOmniboxIconSize, kOmniboxIconSize, - /*fallback_to_google_server=*/YES, ^(FaviconAttributes* attributes) { + /*fallback_to_google_server=*/false, ^(FaviconAttributes* attributes) { if (attributes.faviconImage && !attributes.usesDefaultImage) completion(attributes.faviconImage); });
diff --git a/ios/chrome/browser/ui/popup_menu/BUILD.gn b/ios/chrome/browser/ui/popup_menu/BUILD.gn index eddff42..d3710774 100644 --- a/ios/chrome/browser/ui/popup_menu/BUILD.gn +++ b/ios/chrome/browser/ui/popup_menu/BUILD.gn
@@ -33,6 +33,7 @@ "resources:popup_menu_report_an_issue", "resources:popup_menu_request_desktop_site", "resources:popup_menu_request_mobile_site", + "resources:popup_menu_search", "resources:popup_menu_settings", "resources:popup_menu_site_information", "resources:popup_menu_stop", @@ -66,6 +67,7 @@ "//ios/chrome/browser/ui/popup_menu/public/cells", "//ios/chrome/browser/ui/presenters", "//ios/chrome/browser/ui/reading_list", + "//ios/chrome/browser/ui/toolbar/public:feature_flags", "//ios/chrome/browser/ui/util", "//ios/chrome/browser/web_state_list", "//ios/public/provider/chrome/browser",
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.mm index c6b04a19..ad008fa 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_action_handler.mm
@@ -156,6 +156,20 @@ RecordAction(UserMetricsAction("MobileMenuVoiceSearch")); [self.dispatcher startVoiceSearch]; break; + case PopupMenuActionSearch: { + RecordAction(UserMetricsAction("MobileMenuSearch")); + OpenNewTabCommand* command = [OpenNewTabCommand commandWithIncognito:NO]; + command.shouldFocusOmnibox = YES; + [self.dispatcher openURLInNewTab:command]; + break; + } + case PopupMenuActionIncognitoSearch: { + RecordAction(UserMetricsAction("MobileMenuIncognitoSearch")); + OpenNewTabCommand* command = [OpenNewTabCommand commandWithIncognito:YES]; + command.shouldFocusOmnibox = YES; + [self.dispatcher openURLInNewTab:command]; + break; + } case PopupMenuActionQRCodeSearch: RecordAction(UserMetricsAction("MobileMenuScanQRCode")); [self.dispatcher showQRScanner];
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_constants.h b/ios/chrome/browser/ui/popup_menu/popup_menu_constants.h index 8b8af06..8398184ab 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_constants.h +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_constants.h
@@ -60,6 +60,12 @@ extern NSString* const kToolsMenuPasteAndGo; // Voice Search item accessibility Identifier. extern NSString* const kToolsMenuVoiceSearch; +// TODO(crbug.com/974751): Check if this is still used. +// Search item accessibility Identifier. +extern NSString* const kToolsMenuSearch; +// TODO(crbug.com/974751): Check if this is still used. +// Incognito Search item accessibility Identifier. +extern NSString* const kToolsMenuIncognitoSearch; // QR Code Search item accessibility Identifier. extern NSString* const kToolsMenuQRCodeSearch; // Copied Image Search item accessibility Identifier.
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_constants.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_constants.mm index ef9f5e4..cca5ca4 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_constants.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_constants.mm
@@ -38,5 +38,7 @@ NSString* const kToolsMenuSiteInformation = @"kToolsMenuSiteInformation"; NSString* const kToolsMenuPasteAndGo = @"kToolsMenuPasteAndGo"; NSString* const kToolsMenuVoiceSearch = @"kToolsMenuVoiceSearch"; +NSString* const kToolsMenuSearch = @"kToolsMenuSearch"; +NSString* const kToolsMenuIncognitoSearch = @"kToolsMenuIncognitoSearch"; NSString* const kToolsMenuQRCodeSearch = @"kToolsMenuQRCodeSearch"; NSString* const kToolsMenuCopiedImageSearch = @"kToolsMenuCopiedImageSearch";
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm index 89e1dad..4baa2e1 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.mm
@@ -25,6 +25,7 @@ #import "ios/chrome/browser/ui/popup_menu/public/popup_menu_presenter_delegate.h" #import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h" #import "ios/chrome/browser/ui/presenters/contained_presenter_delegate.h" +#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/util/layout_guide_names.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -121,7 +122,11 @@ } - (void)showSearchButtonPopup { - base::RecordAction(base::UserMetricsAction("MobileToolbarShowSearchMenu")); + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + base::RecordAction(base::UserMetricsAction("MobileToolbarShowNewTabMenu")); + } else { + base::RecordAction(base::UserMetricsAction("MobileToolbarShowSearchMenu")); + } [self presentPopupOfType:PopupMenuTypeSearch fromNamedGuide:kSearchButtonGuide]; }
diff --git a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm index 185eaf1..23d01ad 100644 --- a/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm +++ b/ios/chrome/browser/ui/popup_menu/popup_menu_mediator.mm
@@ -34,6 +34,7 @@ #import "ios/chrome/browser/ui/popup_menu/public/popup_menu_consumer.h" #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notification_delegate.h" #import "ios/chrome/browser/ui/reading_list/reading_list_menu_notifier.h" +#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" @@ -661,10 +662,13 @@ - (void)createSearchMenuItems { NSMutableArray* items = [NSMutableArray array]; + // The consumer is expecting an array of arrays of items. Each sub array + // represent a section in the popup menu. Having one sub array means having + // all the items in the same section. + PopupMenuToolsItem* copiedContentItem = nil; if (base::FeatureList::IsEnabled(kCopiedContentBehavior)) { ClipboardRecentContent* clipboardRecentContent = ClipboardRecentContent::GetInstance(); - PopupMenuToolsItem* copiedContentItem = nil; if (search_engines::SupportsSearchByImage(self.templateURLService) && clipboardRecentContent->GetRecentImageFromClipboard()) { @@ -681,30 +685,49 @@ IDS_IOS_TOOLS_MENU_SEARCH_COPIED_TEXT, PopupMenuActionPasteAndGo, @"popup_menu_paste_and_go", kToolsMenuPasteAndGo); } - - if (copiedContentItem) { - [items addObject:copiedContentItem]; - } } else { NSString* pasteboardString = [UIPasteboard generalPasteboard].string; if (pasteboardString) { - PopupMenuToolsItem* pasteAndGo = CreateTableViewItem( + copiedContentItem = CreateTableViewItem( IDS_IOS_TOOLS_MENU_PASTE_AND_GO, PopupMenuActionPasteAndGo, @"popup_menu_paste_and_go", kToolsMenuPasteAndGo); - [items addObject:pasteAndGo]; + } + } + if (copiedContentItem) { + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + [items addObject:@[ copiedContentItem ]]; + } else { + [items addObject:copiedContentItem]; } } PopupMenuToolsItem* QRCodeSearch = CreateTableViewItem( IDS_IOS_TOOLS_MENU_QR_SCANNER, PopupMenuActionQRCodeSearch, @"popup_menu_qr_scanner", kToolsMenuQRCodeSearch); - [items addObject:QRCodeSearch]; PopupMenuToolsItem* voiceSearch = CreateTableViewItem( IDS_IOS_TOOLS_MENU_VOICE_SEARCH, PopupMenuActionVoiceSearch, @"popup_menu_voice_search", kToolsMenuVoiceSearch); - [items addObject:voiceSearch]; + PopupMenuToolsItem* newSearch = + CreateTableViewItem(IDS_IOS_TOOLS_MENU_NEW_SEARCH, PopupMenuActionSearch, + @"popup_menu_search", kToolsMenuSearch); + PopupMenuToolsItem* newIncognitoSearch = CreateTableViewItem( + IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_SEARCH, PopupMenuActionIncognitoSearch, + @"popup_menu_new_incognito_tab", kToolsMenuIncognitoSearch); - self.items = @[ items ]; + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + [items addObject:@[ + newSearch, newIncognitoSearch, voiceSearch, QRCodeSearch + ]]; + } else { + [items addObject:QRCodeSearch]; + [items addObject:voiceSearch]; + } + + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + self.items = items; + } else { + self.items = @[ items ]; + } } // Creates the menu items for the tools menu.
diff --git a/ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h b/ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h index cdb5b766..19c379c 100644 --- a/ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h +++ b/ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h
@@ -34,6 +34,10 @@ PopupMenuActionNavigate, PopupMenuActionPasteAndGo, PopupMenuActionVoiceSearch, + // TODO(crbug.com/974751): Check if this is still used. + PopupMenuActionSearch, + // TODO(crbug.com/974751): Check if this is still used. + PopupMenuActionIncognitoSearch, PopupMenuActionQRCodeSearch, PopupMenuActionSearchCopiedImage, // Language selection popup menu
diff --git a/ios/chrome/browser/ui/popup_menu/resources/BUILD.gn b/ios/chrome/browser/ui/popup_menu/resources/BUILD.gn index d4be342..963e3200b 100644 --- a/ios/chrome/browser/ui/popup_menu/resources/BUILD.gn +++ b/ios/chrome/browser/ui/popup_menu/resources/BUILD.gn
@@ -4,6 +4,14 @@ import("//build/config/ios/asset_catalog.gni") +imageset("popup_menu_search") { + sources = [ + "popup_menu_search.imageset/Contents.json", + "popup_menu_search.imageset/popup_menu_search@2x.png", + "popup_menu_search.imageset/popup_menu_search@3x.png", + ] +} + imageset("popup_menu_paste_and_go") { sources = [ "popup_menu_paste_and_go.imageset/Contents.json",
diff --git a/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/Contents.json b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/Contents.json new file mode 100644 index 0000000..b4f50a4 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/Contents.json
@@ -0,0 +1,22 @@ +{ + "images": [ + { + "idiom": "universal", + "scale": "1x" + }, + { + "idiom": "universal", + "scale": "2x", + "filename": "popup_menu_search@2x.png" + }, + { + "idiom": "universal", + "scale": "3x", + "filename": "popup_menu_search@3x.png" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +}
diff --git a/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@2x.png b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@2x.png new file mode 100644 index 0000000..faaa842 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@2x.png Binary files differ
diff --git a/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@3x.png b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@3x.png new file mode 100644 index 0000000..32ecd03 --- /dev/null +++ b/ios/chrome/browser/ui/popup_menu/resources/popup_menu_search.imageset/popup_menu_search@3x.png Binary files differ
diff --git a/ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.mm b/ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.mm index 5b38d434..b5ce23e 100644 --- a/ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.mm +++ b/ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.mm
@@ -113,6 +113,8 @@ self.actionHandler = [[ToolbarButtonActionsHandler alloc] init]; self.actionHandler.dispatcher = self.dispatcher; + self.actionHandler.browserState = self.browserState; + self.actionHandler.webStateList = self.webStateList; ToolbarButtonFactory* buttonFactory = [[ToolbarButtonFactory alloc] initWithStyle:style];
diff --git a/ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.mm b/ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.mm index 5d0c932b..37494859 100644 --- a/ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.mm +++ b/ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.mm
@@ -217,6 +217,8 @@ } - (void)setSearchIcon:(UIImage*)searchIcon { + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) + return; [self.view.searchButton setImage:searchIcon forState:UIControlStateNormal]; }
diff --git a/ios/chrome/browser/ui/toolbar/buttons/BUILD.gn b/ios/chrome/browser/ui/toolbar/buttons/BUILD.gn index 7090b0e..7a94671 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/BUILD.gn +++ b/ios/chrome/browser/ui/toolbar/buttons/BUILD.gn
@@ -29,6 +29,7 @@ "resources:toolbar_bookmark", "resources:toolbar_bookmark_active", "resources:toolbar_forward", + "resources:toolbar_new_tab_page", "resources:toolbar_reload", "resources:toolbar_search", "resources:toolbar_share", @@ -38,15 +39,19 @@ "//components/strings", "//ios/chrome/app/strings", "//ios/chrome/app/theme", + "//ios/chrome/browser", + "//ios/chrome/browser/browser_state", "//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/content_suggestions:content_suggestions_constant", "//ios/chrome/browser/ui/toolbar/public", "//ios/chrome/browser/ui/toolbar/public:feature_flags", "//ios/chrome/browser/ui/util", + "//ios/chrome/browser/web_state_list", "//ios/chrome/common/ui_util", "//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser/images", "//ios/third_party/material_components_ios", + "//ios/web/public", "//ui/base", ] libs = [ "UIKit.framework" ]
diff --git a/ios/chrome/browser/ui/toolbar/buttons/resources/BUILD.gn b/ios/chrome/browser/ui/toolbar/buttons/resources/BUILD.gn index 5b71800..6e2d4f8b 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/resources/BUILD.gn +++ b/ios/chrome/browser/ui/toolbar/buttons/resources/BUILD.gn
@@ -4,6 +4,14 @@ import("//build/config/ios/asset_catalog.gni") +imageset("toolbar_new_tab_page") { + sources = [ + "toolbar_new_tab_page.imageset/Contents.json", + "toolbar_new_tab_page.imageset/toolbar_new_tab_page@2x.png", + "toolbar_new_tab_page.imageset/toolbar_new_tab_page@3x.png", + ] +} + imageset("toolbar_stop") { sources = [ "toolbar_stop.imageset/Contents.json",
diff --git a/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/Contents.json b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/Contents.json new file mode 100644 index 0000000..ca2fa182 --- /dev/null +++ b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/Contents.json
@@ -0,0 +1,22 @@ +{ + "images": [ + { + "idiom": "universal", + "scale": "1x" + }, + { + "idiom": "universal", + "scale": "2x", + "filename": "toolbar_new_tab_page@2x.png" + }, + { + "idiom": "universal", + "scale": "3x", + "filename": "toolbar_new_tab_page@3x.png" + } + ], + "info": { + "version": 1, + "author": "xcode" + } +}
diff --git a/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@2x.png b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@2x.png new file mode 100644 index 0000000..b8a8929 --- /dev/null +++ b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@2x.png Binary files differ
diff --git a/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@3x.png b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@3x.png new file mode 100644 index 0000000..49b30a7 --- /dev/null +++ b/ios/chrome/browser/ui/toolbar/buttons/resources/toolbar_new_tab_page.imageset/toolbar_new_tab_page@3x.png Binary files differ
diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.h b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.h index a201ceb..dd43ac7 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.h +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.h
@@ -7,9 +7,13 @@ #import <Foundation/Foundation.h> +namespace ios { +class ChromeBrowserState; +} @protocol ApplicationCommands; @protocol BrowserCommands; @protocol OmniboxFocuser; +class WebStateList; // Handler for the actions associated with the different toolbar buttons. @interface ToolbarButtonActionsHandler : NSObject @@ -19,6 +23,12 @@ id<ApplicationCommands, BrowserCommands, OmniboxFocuser> dispatcher; +// WebStateList used to insert new tab. +@property(nonatomic, assign) WebStateList* webStateList; + +// BrowserState used to create new tab. +@property(nonatomic, assign) ios::ChromeBrowserState* browserState; + // Action when the back button is tapped. - (void)backAction;
diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.mm b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.mm index 3b38b97..f9b357310a 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.mm +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.mm
@@ -4,9 +4,17 @@ #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_button_actions_handler.h" +#include "ios/chrome/browser/browser_state/chrome_browser_state.h" +#include "ios/chrome/browser/chrome_url_constants.h" #import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h" +#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h" +#import "ios/chrome/browser/web_state_list/web_state_list.h" +#include "ios/chrome/browser/web_state_list/web_state_opener.h" +#import "ios/web/public/navigation_manager.h" +#import "ios/web/public/web_state/web_state.h" +#include "url/gurl.h" #if !defined(__has_feature) || !__has_feature(objc_arc) #error "This file requires ARC support." @@ -52,7 +60,22 @@ - (void)searchAction { [self.dispatcher closeFindInPage]; - [self.dispatcher focusOmniboxFromSearchButton]; + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + web::WebState::CreateParams params(self.browserState); + std::unique_ptr<web::WebState> webState = web::WebState::Create(params); + + GURL newTabURL(kChromeUINewTabURL); + web::NavigationManager::WebLoadParams loadParams(newTabURL); + loadParams.transition_type = ui::PAGE_TRANSITION_TYPED; + webState->GetNavigationManager()->LoadURLWithParams(loadParams); + + self.webStateList->InsertWebState( + self.webStateList->count(), std::move(webState), + (WebStateList::INSERT_FORCE_INDEX | WebStateList::INSERT_ACTIVATE), + WebStateOpener()); + } else { + [self.dispatcher focusOmniboxFromSearchButton]; + } } - (void)cancelOmniboxFocusAction {
diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.mm b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.mm index 7c2b5d1..aba5248 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.mm +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_button_factory.mm
@@ -12,6 +12,7 @@ #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_tools_menu_button.h" +#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" #import "ios/chrome/browser/ui/util/rtl_geometry.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h" @@ -166,13 +167,32 @@ } - (ToolbarButton*)searchButton { - ToolbarSearchButton* searchButton = [ToolbarSearchButton - toolbarButtonWithImage:[UIImage imageNamed:@"toolbar_search"]]; + UIImage* buttonImage = nil; + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + buttonImage = [UIImage imageNamed:@"toolbar_new_tab_page"]; + } else { + buttonImage = [UIImage imageNamed:@"toolbar_search"]; + } + ToolbarSearchButton* searchButton = + [ToolbarSearchButton toolbarButtonWithImage:buttonImage]; - [self configureButton:searchButton width:kSearchButtonWidth]; [searchButton addTarget:self.actionHandler action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside]; + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + BOOL isIncognito = self.style == INCOGNITO; + + [self configureButton:searchButton width:kAdaptiveToolbarButtonWidth]; + + searchButton.accessibilityLabel = l10n_util::GetNSString( + isIncognito ? IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB + : IDS_IOS_TOOLS_MENU_NEW_TAB); + } else { + [self configureButton:searchButton width:kSearchButtonWidth]; + + searchButton.accessibilityLabel = + l10n_util::GetNSString(IDS_IOS_TOOLBAR_SEARCH); + } searchButton.accessibilityLabel = l10n_util::GetNSString(IDS_IOS_TOOLBAR_SEARCH);
diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.mm b/ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.mm index ab8ff7f..dc8c1a95 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.mm +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.mm
@@ -5,6 +5,7 @@ #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_search_button.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h" +#import "ios/chrome/browser/ui/toolbar/public/features.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h" @@ -55,8 +56,13 @@ AddSameCenterConstraints(self, spotlightView); [spotlightView.heightAnchor constraintEqualToConstant:kSpotlightHeight] .active = YES; - [self.widthAnchor constraintEqualToAnchor:spotlightView.widthAnchor].active = - YES; + if (base::FeatureList::IsEnabled(kToolbarNewTabButton)) { + [spotlightView.widthAnchor constraintEqualToConstant:kSpotlightHeight] + .active = YES; + } else { + [self.widthAnchor constraintEqualToAnchor:spotlightView.widthAnchor] + .active = YES; + } self.spotlightView = spotlightView; }
diff --git a/ios/chrome/browser/ui/toolbar/public/features.h b/ios/chrome/browser/ui/toolbar/public/features.h index 3f839365..cee15e7 100644 --- a/ios/chrome/browser/ui/toolbar/public/features.h +++ b/ios/chrome/browser/ui/toolbar/public/features.h
@@ -9,6 +9,8 @@ #include "base/feature_list.h" +extern const base::Feature kToolbarNewTabButton; + // Enum for the different icons for the search button. typedef NS_ENUM(NSUInteger, ToolbarSearchButtonIcon) { ToolbarSearchButtonIconGrey,
diff --git a/ios/chrome/browser/ui/toolbar/public/features.mm b/ios/chrome/browser/ui/toolbar/public/features.mm index c73c5e7b..35acad7 100644 --- a/ios/chrome/browser/ui/toolbar/public/features.mm +++ b/ios/chrome/browser/ui/toolbar/public/features.mm
@@ -11,6 +11,9 @@ #error "This file requires ARC support." #endif +const base::Feature kToolbarNewTabButton{"ToolbarNewTabButton", + base::FEATURE_DISABLED_BY_DEFAULT}; + const base::Feature kIconForSearchButtonFeature{ "IconForSearchButtonFeature", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/ios/web/public/deprecated/crw_native_content.h b/ios/web/public/deprecated/crw_native_content.h index a2e3fa5..084fc61 100644 --- a/ios/web/public/deprecated/crw_native_content.h +++ b/ios/web/public/deprecated/crw_native_content.h
@@ -55,10 +55,6 @@ - (void)executeJavaScript:(NSString*)script completionHandler:(void (^)(id, NSError*))handler; -// Dismisses any outstanding modal interaction elements (e.g. modal view -// controllers, context menus, etc). -- (void)dismissModals; - // A native content controller should do any clean up at this time when // WebController closes. - (void)close;
diff --git a/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.h b/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.h index 040facd8..c1bbbe9 100644 --- a/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.h +++ b/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.h
@@ -73,10 +73,6 @@ // Notifies the CRWNativeContent that it has been hidden. - (void)wasHidden; -// Dismisses any outstanding modal interaction elements (e.g. modal view -// controllers, context menus, etc). -- (void)dismissModals; - // A native content controller should do any clean up at this time when // WebController closes. - (void)close;
diff --git a/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.mm b/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.mm index 3728959..f5fbf490 100644 --- a/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.mm +++ b/ios/web/web_state/ui/controller/crw_legacy_native_content_controller.mm
@@ -193,11 +193,6 @@ } } -- (void)dismissModals { - if ([self.nativeController respondsToSelector:@selector(dismissModals)]) - [self.nativeController dismissModals]; -} - - (void)close { self.nativeProvider = nil; if ([self.nativeController respondsToSelector:@selector(close)])
diff --git a/ios/web/web_state/ui/crw_web_controller.h b/ios/web/web_state/ui/crw_web_controller.h index 91731447..8c0f6fa08 100644 --- a/ios/web/web_state/ui/crw_web_controller.h +++ b/ios/web/web_state/ui/crw_web_controller.h
@@ -105,9 +105,6 @@ // Please reconsider before using this method. - (void)removeWebView; -// Dismisses all modals owned by the web view or native view. -- (void)dismissModals; - // Call when the CRWWebController needs go away. Caller must reset the delegate // before calling. - (void)close;
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index 5ab4fcb..dd71b3f 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -616,10 +616,6 @@ [_containerView clearTransientContentView]; } -- (void)dismissModals { - [self.legacyNativeController dismissModals]; -} - // Caller must reset the delegate before calling. - (void)close { self.webStateImpl->CancelDialogs();
diff --git a/ios/web_view/internal/passwords/web_view_password_manager_driver.h b/ios/web_view/internal/passwords/web_view_password_manager_driver.h index fb5fd72..1a28e29 100644 --- a/ios/web_view/internal/passwords/web_view_password_manager_driver.h +++ b/ios/web_view/internal/passwords/web_view_password_manager_driver.h
@@ -11,7 +11,6 @@ #include "components/password_manager/core/browser/password_manager_driver.h" namespace autofill { -struct PasswordForm; struct PasswordFormFillData; } // namespace autofill @@ -49,10 +48,6 @@ void FillPasswordForm( const autofill::PasswordFormFillData& form_data) override; void InformNoSavedCredentials() override; - void AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) override; - void FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) override; void GeneratedPasswordAccepted(const base::string16& password) override; void FillSuggestion(const base::string16& username, const base::string16& password) override;
diff --git a/ios/web_view/internal/passwords/web_view_password_manager_driver.mm b/ios/web_view/internal/passwords/web_view_password_manager_driver.mm index 44dbf0a0..89e1f07b 100644 --- a/ios/web_view/internal/passwords/web_view_password_manager_driver.mm +++ b/ios/web_view/internal/passwords/web_view_password_manager_driver.mm
@@ -32,11 +32,6 @@ [delegate_ informNoSavedCredentials]; } -void WebViewPasswordManagerDriver::FormsEligibleForGenerationFound( - const std::vector<autofill::PasswordFormGenerationData>& forms) { - // Password generation is not supported. -} - void WebViewPasswordManagerDriver::GeneratedPasswordAccepted( const base::string16& password) { NOTIMPLEMENTED(); @@ -70,9 +65,6 @@ return [delegate_ passwordManager]; } -void WebViewPasswordManagerDriver::AllowPasswordGenerationForForm( - const autofill::PasswordForm& form) {} - PasswordAutofillManager* WebViewPasswordManagerDriver::GetPasswordAutofillManager() { return nullptr;
diff --git a/media/capture/video/chromeos/camera_device_delegate.cc b/media/capture/video/chromeos/camera_device_delegate.cc index 05a7d5a..176cae3 100644 --- a/media/capture/video/chromeos/camera_device_delegate.cc +++ b/media/capture/video/chromeos/camera_device_delegate.cc
@@ -240,13 +240,15 @@ device_close_callback_ = std::move(device_close_callback); device_context_->SetState(CameraDeviceContext::State::kStopping); - if (!device_ops_.is_bound()) { - // The device delegate is in the process of opening the camera device. - return; + if (device_ops_.is_bound()) { + device_ops_->Close( + base::BindOnce(&CameraDeviceDelegate::OnClosed, GetWeakPtr())); } - request_manager_->StopPreview(base::NullCallback()); - device_ops_->Close( - base::BindOnce(&CameraDeviceDelegate::OnClosed, GetWeakPtr())); + // |request_manager_| might be still uninitialized if StopAndDeAllocate() is + // called before the device is opened. + if (request_manager_) { + request_manager_->StopPreview(base::NullCallback()); + } } void CameraDeviceDelegate::TakePhoto(
diff --git a/media/capture/video/chromeos/camera_device_delegate_unittest.cc b/media/capture/video/chromeos/camera_device_delegate_unittest.cc index 875d077..6fa474bd 100644 --- a/media/capture/video/chromeos/camera_device_delegate_unittest.cc +++ b/media/capture/video/chromeos/camera_device_delegate_unittest.cc
@@ -508,6 +508,60 @@ ResetDevice(); } +// Test that the camera device delegate closes properly when StopAndDeAllocate() +// is called when the device is opening. The timeline is roughly: +// 1. AllocateAndStart() +// 2. Async IPC call OpenDevice() started +// 3. StopAndDeAllocate() +// 4. Async IPC call OpenDevice() finished +TEST_F(CameraDeviceDelegateTest, StopBeforeOpened) { + auto* mock_client = ResetDeviceContext(); + mock_client->SetQuitCb(BindToCurrentLoop(base::BindOnce( + &CameraDeviceDelegateTest::QuitRunLoop, base::Unretained(this)))); + SetUpExpectationForHalDelegate(); + + AllocateDevice(); + + device_delegate_thread_.task_runner()->PostTask( + FROM_HERE, base::BindOnce(&CameraDeviceDelegate::AllocateAndStart, + camera_device_delegate_->GetWeakPtr(), + GetDefaultCaptureParams(), + base::Unretained(device_context_.get()))); + + base::WaitableEvent stop_posted; + auto open_device_quit_loop_cb = + [&](int32_t camera_id, + cros::mojom::Camera3DeviceOpsRequest& device_ops_request, + base::OnceCallback<void(int32_t)>& callback) { + QuitRunLoop(); + // Make sure StopAndDeAllocate() is called before the device opened + // callback. + stop_posted.Wait(); + OpenMockCameraDevice(camera_id, device_ops_request, callback); + }; + EXPECT_CALL(mock_camera_module_, DoOpenDevice(0, _, _)) + .Times(1) + .WillOnce(Invoke(open_device_quit_loop_cb)); + + // Wait until the QuitRunLoop() call in |mock_camera_module_->OpenDevice()|. + DoLoop(); + + SetUpExpectationForClose(); + + base::WaitableEvent device_closed; + device_delegate_thread_.task_runner()->PostTask( + FROM_HERE, + base::BindOnce(&CameraDeviceDelegate::StopAndDeAllocate, + camera_device_delegate_->GetWeakPtr(), + base::BindOnce(&base::WaitableEvent::Signal, + base::Unretained(&device_closed)))); + stop_posted.Signal(); + EXPECT_TRUE(device_closed.TimedWait(base::TimeDelta::FromSeconds(3))); + EXPECT_EQ(CameraDeviceContext::State::kStopped, GetState()); + + ResetDevice(); +} + // Test that the camera device delegate closes properly when StopAndDeAllocate // is called right after the device is initialized. TEST_F(CameraDeviceDelegateTest, StopAfterInitialized) {
diff --git a/mojo/public/java/system/BUILD.gn b/mojo/public/java/system/BUILD.gn index cc70e425..c493a9db 100644 --- a/mojo/public/java/system/BUILD.gn +++ b/mojo/public/java/system/BUILD.gn
@@ -21,8 +21,6 @@ public_deps = [ ":system_impl_java_jni_headers", ] - - jni_package = "mojo" } generate_jni("system_impl_java_jni_headers") { @@ -31,8 +29,6 @@ "src/org/chromium/mojo/system/impl/CoreImpl.java", "src/org/chromium/mojo/system/impl/WatcherImpl.java", ] - - jni_package = "mojo" } source_set("native_support") {
diff --git a/mojo/public/java/system/base_run_loop.cc b/mojo/public/java/system/base_run_loop.cc index a39f2db..012ce48c 100644 --- a/mojo/public/java/system/base_run_loop.cc +++ b/mojo/public/java/system/base_run_loop.cc
@@ -11,7 +11,7 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/task/single_thread_task_executor.h" -#include "jni/BaseRunLoop_jni.h" +#include "mojo/public/java/system/system_impl_java_jni_headers/BaseRunLoop_jni.h" using base::android::JavaParamRef;
diff --git a/mojo/public/java/system/core_impl.cc b/mojo/public/java/system/core_impl.cc index 33f0576a..97278a0 100644 --- a/mojo/public/java/system/core_impl.cc +++ b/mojo/public/java/system/core_impl.cc
@@ -8,9 +8,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/scoped_java_ref.h" -#include "jni/CoreImpl_jni.h" #include "mojo/public/c/system/core.h" #include "mojo/public/cpp/system/message_pipe.h" +#include "mojo/public/java/system/system_impl_java_jni_headers/CoreImpl_jni.h" namespace mojo { namespace android {
diff --git a/mojo/public/java/system/javatests/mojo_test_rule.cc b/mojo/public/java/system/javatests/mojo_test_rule.cc index 4ac9fc9..52e2b04 100644 --- a/mojo/public/java/system/javatests/mojo_test_rule.cc +++ b/mojo/public/java/system/javatests/mojo_test_rule.cc
@@ -13,8 +13,8 @@ #include "base/task/single_thread_task_executor.h" #include "base/test/test_support_android.h" #include "base/threading/thread_task_runner_handle.h" -#include "jni/MojoTestRule_jni.h" #include "mojo/core/embedder/embedder.h" +#include "mojo/public/java/system/jni_headers/MojoTestRule_jni.h" using base::android::JavaParamRef;
diff --git a/mojo/public/java/system/javatests/validation_test_util.cc b/mojo/public/java/system/javatests/validation_test_util.cc index 7aa1098e..7c3c0a6 100644 --- a/mojo/public/java/system/javatests/validation_test_util.cc +++ b/mojo/public/java/system/javatests/validation_test_util.cc
@@ -9,8 +9,8 @@ #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/test/test_support_android.h" -#include "jni/ValidationTestUtil_jni.h" #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h" +#include "mojo/public/java/system/jni_headers/ValidationTestUtil_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/mojo/public/java/system/watcher_impl.cc b/mojo/public/java/system/watcher_impl.cc index 3619648..e251d2e6 100644 --- a/mojo/public/java/system/watcher_impl.cc +++ b/mojo/public/java/system/watcher_impl.cc
@@ -8,9 +8,9 @@ #include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/bind.h" -#include "jni/WatcherImpl_jni.h" #include "mojo/public/cpp/system/handle.h" #include "mojo/public/cpp/system/simple_watcher.h" +#include "mojo/public/java/system/system_impl_java_jni_headers/WatcherImpl_jni.h" namespace mojo { namespace android {
diff --git a/net/BUILD.gn b/net/BUILD.gn index 9ce7011dd3..bc07121 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn
@@ -1533,8 +1533,6 @@ "third_party/quiche/src/quic/core/qpack/qpack_instruction_encoder.h", "third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.cc", "third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h", - "third_party/quiche/src/quic/core/qpack/qpack_progressive_encoder.cc", - "third_party/quiche/src/quic/core/qpack/qpack_progressive_encoder.h", "third_party/quiche/src/quic/core/qpack/qpack_receive_stream.cc", "third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h", "third_party/quiche/src/quic/core/qpack/qpack_send_stream.cc",
diff --git a/net/DEPS b/net/DEPS index 291fa1a..5b608efb 100644 --- a/net/DEPS +++ b/net/DEPS
@@ -69,9 +69,10 @@ "+base/i18n", ], - # Needed for fuzz targets written using libprotobuf-mutator library. + # Dependencies specific for fuzz targets and other fuzzing-related code. ".*fuzz.*": [ - "+third_party/libprotobuf-mutator", + "+third_party/libFuzzer/src/utils", # This contains FuzzedDataProvider. + "+third_party/libprotobuf-mutator", # This is needed for LPM-based fuzzers. ] }
diff --git a/net/cert/crl_set_fuzzer.cc b/net/cert/crl_set_fuzzer.cc index ef186183..3b83709 100644 --- a/net/cert/crl_set_fuzzer.cc +++ b/net/cert/crl_set_fuzzer.cc
@@ -5,14 +5,14 @@ #include <stddef.h> #include <stdint.h> -#include "base/test/fuzzed_data_provider.h" #include "net/cert/crl_set.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size < 32 + 32 + 20) return 0; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::string spki_hash = data_provider.ConsumeBytesAsString(32); std::string issuer_hash = data_provider.ConsumeBytesAsString(32); size_t serial_length = data_provider.ConsumeIntegralInRange(4, 19);
diff --git a/net/cert/internal/verify_name_match_fuzzer.cc b/net/cert/internal/verify_name_match_fuzzer.cc index 03c7e9c..a22d3f9 100644 --- a/net/cert/internal/verify_name_match_fuzzer.cc +++ b/net/cert/internal/verify_name_match_fuzzer.cc
@@ -9,17 +9,19 @@ #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/der/input.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data(data, size); + FuzzedDataProvider fuzzed_data(data, size); // Intentionally using uint16_t here to avoid empty |second_part|. size_t first_part_size = fuzzed_data.ConsumeIntegral<uint16_t>(); - std::vector<uint8_t> first_part = fuzzed_data.ConsumeBytes(first_part_size); - std::vector<uint8_t> second_part = fuzzed_data.ConsumeRemainingBytes(); + std::vector<uint8_t> first_part = + fuzzed_data.ConsumeBytes<uint8_t>(first_part_size); + std::vector<uint8_t> second_part = + fuzzed_data.ConsumeRemainingBytes<uint8_t>(); net::der::Input in1(first_part.data(), first_part.size()); net::der::Input in2(second_part.data(), second_part.size());
diff --git a/net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.cc b/net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.cc index d948e59f..a289c7f1 100644 --- a/net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.cc +++ b/net/cert/internal/verify_name_match_verifynameinsubtree_fuzzer.cc
@@ -9,17 +9,19 @@ #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/der/input.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data(data, size); + FuzzedDataProvider fuzzed_data(data, size); // Intentionally using uint16_t here to avoid empty |second_part|. size_t first_part_size = fuzzed_data.ConsumeIntegral<uint16_t>(); - std::vector<uint8_t> first_part = fuzzed_data.ConsumeBytes(first_part_size); - std::vector<uint8_t> second_part = fuzzed_data.ConsumeRemainingBytes(); + std::vector<uint8_t> first_part = + fuzzed_data.ConsumeBytes<uint8_t>(first_part_size); + std::vector<uint8_t> second_part = + fuzzed_data.ConsumeRemainingBytes<uint8_t>(); net::der::Input in1(first_part.data(), first_part.size()); net::der::Input in2(second_part.data(), second_part.size());
diff --git a/net/cookies/parse_cookie_line_fuzzer.cc b/net/cookies/parse_cookie_line_fuzzer.cc index beb8401..a8aaf00 100644 --- a/net/cookies/parse_cookie_line_fuzzer.cc +++ b/net/cookies/parse_cookie_line_fuzzer.cc
@@ -6,10 +6,10 @@ #include <stdint.h> #include "base/logging.h" -#include "base/test/fuzzed_data_provider.h" #include "net/cookies/parsed_cookie.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" -const std::string GetArbitraryString(base::FuzzedDataProvider* data_provider) { +const std::string GetArbitraryString(FuzzedDataProvider* data_provider) { // Adding a fudge factor to kMaxCookieSize so that both branches of the bounds // detection code will be tested. return data_provider->ConsumeRandomLengthString( @@ -18,7 +18,7 @@ // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); const std::string cookie_line = GetArbitraryString(&data_provider); net::ParsedCookie parsed_cookie(cookie_line);
diff --git a/net/dns/fuzzed_host_resolver_util.cc b/net/dns/fuzzed_host_resolver_util.cc index ab59eef4..b547c5a 100644 --- a/net/dns/fuzzed_host_resolver_util.cc +++ b/net/dns/fuzzed_host_resolver_util.cc
@@ -18,7 +18,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/single_thread_task_runner.h" -#include "base/test/fuzzed_data_provider.h" #include "base/threading/thread_task_runner_handle.h" #include "net/base/address_list.h" #include "net/base/completion_once_callback.h" @@ -39,18 +38,19 @@ #include "net/log/net_log_with_source.h" #include "net/socket/datagram_server_socket.h" #include "net/socket/fuzzed_socket_factory.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { namespace { // Returns a fuzzed non-zero port number. -uint16_t FuzzPort(base::FuzzedDataProvider* data_provider) { +uint16_t FuzzPort(FuzzedDataProvider* data_provider) { return data_provider->ConsumeIntegral<uint16_t>(); } // Returns a fuzzed IPv4 address. Can return invalid / reserved addresses. -IPAddress FuzzIPv4Address(base::FuzzedDataProvider* data_provider) { +IPAddress FuzzIPv4Address(FuzzedDataProvider* data_provider) { return IPAddress(data_provider->ConsumeIntegral<uint8_t>(), data_provider->ConsumeIntegral<uint8_t>(), data_provider->ConsumeIntegral<uint8_t>(), @@ -58,7 +58,7 @@ } // Returns a fuzzed IPv6 address. Can return invalid / reserved addresses. -IPAddress FuzzIPv6Address(base::FuzzedDataProvider* data_provider) { +IPAddress FuzzIPv6Address(FuzzedDataProvider* data_provider) { return IPAddress(data_provider->ConsumeIntegral<uint8_t>(), data_provider->ConsumeIntegral<uint8_t>(), data_provider->ConsumeIntegral<uint8_t>(), @@ -79,7 +79,7 @@ // Returns a fuzzed address, which can be either IPv4 or IPv6. Can return // invalid / reserved addresses. -IPAddress FuzzIPAddress(base::FuzzedDataProvider* data_provider) { +IPAddress FuzzIPAddress(FuzzedDataProvider* data_provider) { if (data_provider->ConsumeBool()) return FuzzIPv4Address(data_provider); return FuzzIPv6Address(data_provider); @@ -93,7 +93,7 @@ // happen if a request is issued but the code never waits for the result // before the test ends. explicit FuzzedHostResolverProc( - base::WeakPtr<base::FuzzedDataProvider> data_provider) + base::WeakPtr<FuzzedDataProvider> data_provider) : HostResolverProc(nullptr), data_provider_(data_provider), network_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} @@ -151,7 +151,7 @@ private: ~FuzzedHostResolverProc() override = default; - base::WeakPtr<base::FuzzedDataProvider> data_provider_; + base::WeakPtr<FuzzedDataProvider> data_provider_; // Just used for thread-safety checks. scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; @@ -172,7 +172,7 @@ // RecvFrom calls. class FuzzedMdnsSocket : public DatagramServerSocket { public: - explicit FuzzedMdnsSocket(base::FuzzedDataProvider* data_provider) + explicit FuzzedMdnsSocket(FuzzedDataProvider* data_provider) : data_provider_(data_provider), local_address_(FuzzIPAddress(data_provider_), 5353), weak_factory_(this) {} @@ -277,7 +277,7 @@ std::move(callback).Run(data_provider_->PickValueInArray(kMdnsErrors)); } - base::FuzzedDataProvider* const data_provider_; + FuzzedDataProvider* const data_provider_; const IPEndPoint local_address_; const NetLogWithSource net_log_; @@ -286,7 +286,7 @@ class FuzzedMdnsSocketFactory : public MDnsSocketFactory { public: - explicit FuzzedMdnsSocketFactory(base::FuzzedDataProvider* data_provider) + explicit FuzzedMdnsSocketFactory(FuzzedDataProvider* data_provider) : data_provider_(data_provider) {} void CreateSockets( @@ -297,7 +297,7 @@ } private: - base::FuzzedDataProvider* const data_provider_; + FuzzedDataProvider* const data_provider_; }; class FuzzedHostResolverManager : public HostResolverManager { @@ -305,7 +305,7 @@ // |data_provider| and |net_log| must outlive the FuzzedHostResolver. FuzzedHostResolverManager(const HostResolver::ManagerOptions& options, NetLog* net_log, - base::FuzzedDataProvider* data_provider) + FuzzedDataProvider* data_provider) : HostResolverManager(options, net_log), data_provider_(data_provider), is_ipv6_reachable_(data_provider->ConsumeBool()), @@ -348,7 +348,7 @@ SetHaveOnlyLoopbackAddresses(data_provider_->ConsumeBool()); } - base::FuzzedDataProvider* const data_provider_; + FuzzedDataProvider* const data_provider_; // Fixed value to be returned by IsIPv6Reachable. const bool is_ipv6_reachable_; @@ -358,7 +358,7 @@ NetLog* const net_log_; - base::WeakPtrFactory<base::FuzzedDataProvider> data_provider_weak_factory_; + base::WeakPtrFactory<FuzzedDataProvider> data_provider_weak_factory_; DISALLOW_COPY_AND_ASSIGN(FuzzedHostResolverManager); }; @@ -424,7 +424,7 @@ std::unique_ptr<DnsClient> dns_client = DnsClient::CreateClientForTesting( net_log_, &socket_factory_, - base::Bind(&base::FuzzedDataProvider::ConsumeIntegralInRange<int32_t>, + base::Bind(&FuzzedDataProvider::ConsumeIntegralInRange<int32_t>, base::Unretained(data_provider_))); dns_client->SetConfig(config); HostResolverManager::SetDnsClientForTesting(std::move(dns_client)); @@ -435,7 +435,7 @@ std::unique_ptr<ContextHostResolver> CreateFuzzedContextHostResolver( const HostResolver::ManagerOptions& options, NetLog* net_log, - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, bool enable_caching) { // FuzzedHostResolverManager only handles fuzzing DnsClient when enabled // through SetDnsClientEnabled().
diff --git a/net/dns/fuzzed_host_resolver_util.h b/net/dns/fuzzed_host_resolver_util.h index 5f6fbb1..11ac006 100644 --- a/net/dns/fuzzed_host_resolver_util.h +++ b/net/dns/fuzzed_host_resolver_util.h
@@ -9,9 +9,7 @@ #include "net/dns/host_resolver.h" -namespace base { class FuzzedDataProvider; -} namespace net { @@ -38,7 +36,7 @@ std::unique_ptr<ContextHostResolver> CreateFuzzedContextHostResolver( const HostResolver::ManagerOptions& options, NetLog* net_log, - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, bool enable_caching); } // namespace net
diff --git a/net/dns/host_resolver_manager_fuzzer.cc b/net/dns/host_resolver_manager_fuzzer.cc index ca19d4f..0606e0a 100644 --- a/net/dns/host_resolver_manager_fuzzer.cc +++ b/net/dns/host_resolver_manager_fuzzer.cc
@@ -11,7 +11,6 @@ #include "base/bind.h" #include "base/logging.h" #include "base/run_loop.h" -#include "base/test/fuzzed_data_provider.h" #include "base/test/scoped_task_environment.h" #include "net/base/address_family.h" #include "net/base/address_list.h" @@ -23,6 +22,7 @@ #include "net/log/net_log_with_source.h" #include "net/log/test_net_log.h" #include "net/net_buildflags.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace { @@ -32,7 +32,7 @@ class DnsRequest { public: DnsRequest(net::HostResolver* host_resolver, - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, std::vector<std::unique_ptr<DnsRequest>>* dns_requests) : host_resolver_(host_resolver), data_provider_(data_provider), @@ -44,7 +44,7 @@ // doesn't complete synchronously, adds it to |dns_requests|. static void CreateRequest( net::HostResolver* host_resolver, - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, std::vector<std::unique_ptr<DnsRequest>>* dns_requests) { std::unique_ptr<DnsRequest> dns_request( new DnsRequest(host_resolver, data_provider, dns_requests)); @@ -56,7 +56,7 @@ // If |dns_requests| is non-empty, waits for a randomly chosen one of the // requests to complete and removes it from |dns_requests|. static void WaitForRequestComplete( - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, std::vector<std::unique_ptr<DnsRequest>>* dns_requests) { if (dns_requests->empty()) return; @@ -75,7 +75,7 @@ // complete, just removes it from the list. static void CancelRequest( net::HostResolver* host_resolver, - base::FuzzedDataProvider* data_provider, + FuzzedDataProvider* data_provider, std::vector<std::unique_ptr<DnsRequest>>* dns_requests) { if (dns_requests->empty()) return; @@ -176,7 +176,7 @@ void Cancel() { request_.reset(); } net::HostResolver* host_resolver_; - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; std::vector<std::unique_ptr<DnsRequest>>* dns_requests_; // Non-null only while running. @@ -199,7 +199,7 @@ // async resolver while lookups are active as a result of the change. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::TestNetLog net_log; net::HostResolver::ManagerOptions options;
diff --git a/net/filter/brotli_source_stream_fuzzer.cc b/net/filter/brotli_source_stream_fuzzer.cc index ef3f4a0..7305a18 100644 --- a/net/filter/brotli_source_stream_fuzzer.cc +++ b/net/filter/brotli_source_stream_fuzzer.cc
@@ -6,18 +6,18 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/io_buffer.h" #include "net/base/test_completion_callback.h" #include "net/filter/fuzzed_source_stream.h" #include "net/filter/source_stream.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for BrotliSourceStream. // // |data| is used to create a FuzzedSourceStream. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { net::TestCompletionCallback callback; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::unique_ptr<net::FuzzedSourceStream> fuzzed_source_stream( new net::FuzzedSourceStream(&data_provider)); std::unique_ptr<net::SourceStream> brotli_stream =
diff --git a/net/filter/fuzzed_source_stream.cc b/net/filter/fuzzed_source_stream.cc index 6a711d0e..bfe9c98 100644 --- a/net/filter/fuzzed_source_stream.cc +++ b/net/filter/fuzzed_source_stream.cc
@@ -9,10 +9,10 @@ #include <utility> #include "base/bind.h" -#include "base/test/fuzzed_data_provider.h" #include "base/threading/thread_task_runner_handle.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -23,7 +23,7 @@ } // namespace -FuzzedSourceStream::FuzzedSourceStream(base::FuzzedDataProvider* data_provider) +FuzzedSourceStream::FuzzedSourceStream(FuzzedDataProvider* data_provider) : SourceStream(SourceStream::TYPE_NONE), data_provider_(data_provider), read_pending_(false),
diff --git a/net/filter/fuzzed_source_stream.h b/net/filter/fuzzed_source_stream.h index 4b26829..fea1ee3 100644 --- a/net/filter/fuzzed_source_stream.h +++ b/net/filter/fuzzed_source_stream.h
@@ -12,9 +12,7 @@ #include "net/base/completion_once_callback.h" #include "net/filter/source_stream.h" -namespace base { class FuzzedDataProvider; -} // namespace base namespace net { @@ -26,7 +24,7 @@ public: // |data_provider| is used to determine behavior of the FuzzedSourceStream. // It must remain valid until after the FuzzedSocket is destroyed. - explicit FuzzedSourceStream(base::FuzzedDataProvider* data_provider); + explicit FuzzedSourceStream(FuzzedDataProvider* data_provider); ~FuzzedSourceStream() override; // SourceStream implementation @@ -41,7 +39,7 @@ scoped_refptr<IOBuffer> read_buf, int result); - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; // Whether there is a pending Read(). bool read_pending_;
diff --git a/net/filter/gzip_source_stream_fuzzer.cc b/net/filter/gzip_source_stream_fuzzer.cc index 1fde1d8a..a6dd834 100644 --- a/net/filter/gzip_source_stream_fuzzer.cc +++ b/net/filter/gzip_source_stream_fuzzer.cc
@@ -8,17 +8,17 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/io_buffer.h" #include "net/base/test_completion_callback.h" #include "net/filter/fuzzed_source_stream.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for GzipSourceStream. // // |data| is used to create a FuzzedSourceStream. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { net::TestCompletionCallback callback; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::unique_ptr<net::FuzzedSourceStream> fuzzed_source_stream( new net::FuzzedSourceStream(&data_provider));
diff --git a/net/http/http_proxy_client_socket_fuzzer.cc b/net/http/http_proxy_client_socket_fuzzer.cc index 57a50f6..45c36cc 100644 --- a/net/http/http_proxy_client_socket_fuzzer.cc +++ b/net/http/http_proxy_client_socket_fuzzer.cc
@@ -12,7 +12,6 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/address_list.h" #include "net/base/auth.h" #include "net/base/host_port_pair.h" @@ -26,6 +25,7 @@ #include "net/socket/fuzzed_socket.h" #include "net/socket/next_proto.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for HttpProxyClientSocket only tests establishing a connection when // using the proxy as a tunnel. @@ -36,7 +36,7 @@ // Use a test NetLog, to exercise logging code. net::TestNetLog test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::TestCompletionCallback callback; std::unique_ptr<net::FuzzedSocket> fuzzed_socket(
diff --git a/net/http/http_stream_parser_fuzzer.cc b/net/http/http_stream_parser_fuzzer.cc index 1cfcb270..3f99250d 100644 --- a/net/http/http_stream_parser_fuzzer.cc +++ b/net/http/http_stream_parser_fuzzer.cc
@@ -15,7 +15,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" @@ -25,6 +24,7 @@ #include "net/log/test_net_log.h" #include "net/socket/fuzzed_socket.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" #include "url/gurl.h" // Fuzzer for HttpStreamParser. @@ -33,7 +33,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { net::TestCompletionCallback callback; net::BoundTestNetLog bound_test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::FuzzedSocket fuzzed_socket(&data_provider, bound_test_net_log.bound().net_log()); CHECK_EQ(net::OK, fuzzed_socket.Connect(callback.callback()));
diff --git a/net/ntlm/ntlm_client_fuzzer.cc b/net/ntlm/ntlm_client_fuzzer.cc index 89977fd..0990e3c 100644 --- a/net/ntlm/ntlm_client_fuzzer.cc +++ b/net/ntlm/ntlm_client_fuzzer.cc
@@ -9,20 +9,19 @@ #include <vector> #include "base/containers/span.h" -#include "base/test/fuzzed_data_provider.h" #include "net/ntlm/ntlm_client.h" #include "net/ntlm/ntlm_test_data.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" -base::string16 ConsumeRandomLengthString16( - base::FuzzedDataProvider& data_provider, - size_t max_chars) { +base::string16 ConsumeRandomLengthString16(FuzzedDataProvider& data_provider, + size_t max_chars) { std::string bytes = data_provider.ConsumeRandomLengthString(max_chars * 2); return base::string16(reinterpret_cast<const base::char16*>(bytes.data()), bytes.size() / 2); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fdp(data, size); + FuzzedDataProvider fdp(data, size); bool is_v2 = fdp.ConsumeBool(); uint64_t client_time = fdp.ConsumeIntegral<uint64_t>(); net::ntlm::NtlmClient client((net::ntlm::NtlmFeatures(is_v2))); @@ -41,7 +40,8 @@ std::string channel_bindings = fdp.ConsumeRandomLengthString(150); std::string spn = fdp.ConsumeRandomLengthString(net::ntlm::kMaxFqdnLen + 5 + 1); - std::vector<uint8_t> challenge_msg_bytes = fdp.ConsumeRemainingBytes(); + std::vector<uint8_t> challenge_msg_bytes = + fdp.ConsumeRemainingBytes<uint8_t>(); client.GenerateAuthenticateMessage( domain, username, password, hostname, channel_bindings, spn, client_time,
diff --git a/net/quic/platform/impl/quic_fuzzed_data_provider_impl.h b/net/quic/platform/impl/quic_fuzzed_data_provider_impl.h index 4689fef3..bfd3ab8 100644 --- a/net/quic/platform/impl/quic_fuzzed_data_provider_impl.h +++ b/net/quic/platform/impl/quic_fuzzed_data_provider_impl.h
@@ -5,11 +5,11 @@ #ifndef NET_QUIC_PLATFORM_IMPL_QUIC_FUZZED_DATA_PROVIDER_IMPL_H_ #define NET_QUIC_PLATFORM_IMPL_QUIC_FUZZED_DATA_PROVIDER_IMPL_H_ -#include "base/test/fuzzed_data_provider.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace quic { -using QuicFuzzedDataProviderImpl = base::FuzzedDataProvider; +using QuicFuzzedDataProviderImpl = FuzzedDataProvider; } // namespace quic
diff --git a/net/quic/quic_chromium_client_session.cc b/net/quic/quic_chromium_client_session.cc index c4d824cc..fee046c6 100644 --- a/net/quic/quic_chromium_client_session.cc +++ b/net/quic/quic_chromium_client_session.cc
@@ -1588,10 +1588,11 @@ } void QuicChromiumClientSession::OnConnectionClosed( - quic::QuicErrorCode error, - const std::string& error_details, + const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source) { DCHECK(!connection()->connected()); + const quic::QuicErrorCode error = frame.quic_error_code; + const std::string& error_details = frame.error_details; logger_->OnConnectionClosed(error, error_details, source); RecordConnectionCloseErrorCode(error, source, session_key_.host(), @@ -1711,7 +1712,7 @@ base::UmaHistogramSparse("Net.QuicSession.QuicVersion", connection()->transport_version()); NotifyFactoryOfSessionGoingAway(); - quic::QuicSession::OnConnectionClosed(error, error_details, source); + quic::QuicSession::OnConnectionClosed(frame, source); if (!callback_.is_null()) { std::move(callback_).Run(ERR_QUIC_PROTOCOL_ERROR);
diff --git a/net/quic/quic_chromium_client_session.h b/net/quic/quic_chromium_client_session.h index ea47921..f944038 100644 --- a/net/quic/quic_chromium_client_session.h +++ b/net/quic/quic_chromium_client_session.h
@@ -494,8 +494,7 @@ const quic::ProofVerifyDetails& verify_details) override; // quic::QuicConnectionVisitorInterface methods: - void OnConnectionClosed(quic::QuicErrorCode error, - const std::string& error_details, + void OnConnectionClosed(const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source) override; void OnSuccessfulVersionNegotiation( const quic::ParsedQuicVersion& version) override;
diff --git a/net/quic/quic_chromium_client_stream_test.cc b/net/quic/quic_chromium_client_stream_test.cc index 9081d74..f696e42 100644 --- a/net/quic/quic_chromium_client_stream_test.cc +++ b/net/quic/quic_chromium_client_stream_test.cc
@@ -55,9 +55,8 @@ } // From quic::QuicSession. - MOCK_METHOD3(OnConnectionClosed, - void(quic::QuicErrorCode error, - const std::string& error_details, + MOCK_METHOD2(OnConnectionClosed, + void(const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source)); MOCK_METHOD1(CreateIncomingStream, quic::QuicSpdyStream*(quic::QuicStreamId id));
diff --git a/net/quic/quic_flags_list.h b/net/quic/quic_flags_list.h index c3e89c24..5512dd6 100644 --- a/net/quic/quic_flags_list.h +++ b/net/quic/quic_flags_list.h
@@ -164,12 +164,6 @@ // ACK frame are sent and processed. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_send_timestamps, false) -// If true, dispatcher passes in a single version when creating a server -// connection, such that version negotiation is not supported in connection. -QUIC_FLAG(bool, - FLAGS_quic_restart_flag_quic_no_server_conn_ver_negotiation2, - true) - // When in STARTUP and recovery, do not add bytes_acked to QUIC BBR's CWND in // CalculateCongestionWindow() QUIC_FLAG( @@ -191,13 +185,6 @@ // If true, QuicEpollClock::Now() will monotonically increase. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_monotonic_epoll_clock, false) -// If true, a client connection would be closed when a version negotiation -// packet is received. It would be the higher layer's responsibility to do the -// reconnection. -QUIC_FLAG(bool, - FLAGS_quic_reloadable_flag_quic_no_client_conn_ver_negotiation, - true) - // If true, public reset packets sent from GFE will include a kEPID tag. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_fix_spurious_ack_alarm, false) @@ -218,29 +205,10 @@ // If true, disable QUIC version 39. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_disable_version_39, false) -// If true, use one loss algorithm per encryption level. -QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_use_uber_loss_algorithm, true) - -// If true, QuicReceivedPacketManager decides when to send ACKs. -QUIC_FLAG(bool, - FLAGS_quic_reloadable_flag_quic_rpm_decides_when_to_send_acks, - true) - // In QUIC, do not close connection if received an in-order ACK with decreased // largest_acked. QUIC_FLAG(bool, FLAGS_quic_reloadable_flag_quic_tolerate_reneging, true) -QUIC_FLAG( - bool, - FLAGS_quic_reloadable_flag_quic_validate_packet_number_post_decryption, - true) - -// If this flag and quic_rpm_decides_when_to_send_acks is true, use uber -// received packet manager instead of the single received packet manager. -QUIC_FLAG(bool, - FLAGS_quic_reloadable_flag_quic_use_uber_received_packet_manager, - true) - // If true and using Leto for QUIC shared-key calculations, GFE will react to a // failure to contact Leto by sending a REJ containing a fallback ServerConfig, // allowing the client to continue the handshake. @@ -298,9 +266,7 @@ // When true, QuicConnectionId will allocate long connection IDs on the heap // instead of inline in the object. -QUIC_FLAG(bool, - FLAGS_quic_restart_flag_quic_use_allocated_connection_ids, - false) +QUIC_FLAG(bool, FLAGS_quic_restart_flag_quic_use_allocated_connection_ids, true) // If enabled, do not call OnStreamFrame() with empty frame after receiving // empty or too large headers with FIN.
diff --git a/net/quic/quic_stream_factory_fuzzer.cc b/net/quic/quic_stream_factory_fuzzer.cc index b91b834..5c5d5aa 100644 --- a/net/quic/quic_stream_factory_fuzzer.cc +++ b/net/quic/quic_stream_factory_fuzzer.cc
@@ -4,8 +4,6 @@ #include "net/quic/quic_stream_factory.h" -#include "base/test/fuzzed_data_provider.h" - #include "base/stl_util.h" #include "net/base/network_isolation_key.h" #include "net/base/test_completion_callback.h" @@ -28,6 +26,7 @@ #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" #include "net/third_party/quiche/src/quic/test_tools/mock_random.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -83,7 +82,7 @@ static struct Env* env = new Env(); extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::unique_ptr<ContextHostResolver> host_resolver = CreateFuzzedContextHostResolver(HostResolver::ManagerOptions(), nullptr,
diff --git a/net/quic/quic_test_packet_printer.cc b/net/quic/quic_test_packet_printer.cc index b748544..bc76d7d 100644 --- a/net/quic/quic_test_packet_printer.cc +++ b/net/quic/quic_test_packet_printer.cc
@@ -24,8 +24,7 @@ *output_ << "OnError: " << QuicErrorCodeToString(framer->error()) << " detail: " << framer->detailed_error() << "\n"; } - bool OnProtocolVersionMismatch(ParsedQuicVersion received_version, - PacketHeaderFormat form) override { + bool OnProtocolVersionMismatch(ParsedQuicVersion received_version) override { framer_->set_version(received_version); *output_ << "OnProtocolVersionMismatch: " << ParsedQuicVersionToString(received_version) << "\n";
diff --git a/net/quic/quic_transport_parameters_fuzzer.cc b/net/quic/quic_transport_parameters_fuzzer.cc index 91d95fca..3fe7a56 100644 --- a/net/quic/quic_transport_parameters_fuzzer.cc +++ b/net/quic/quic_transport_parameters_fuzzer.cc
@@ -7,16 +7,17 @@ #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); auto perspective = data_provider.ConsumeBool() ? quic::Perspective::IS_CLIENT : quic::Perspective::IS_SERVER; quic::TransportParameters transport_parameters; - std::vector<uint8_t> remaining_bytes = data_provider.ConsumeRemainingBytes(); + std::vector<uint8_t> remaining_bytes = + data_provider.ConsumeRemainingBytes<uint8_t>(); quic::ParseTransportParameters(remaining_bytes.data(), remaining_bytes.size(), perspective, &transport_parameters); return 0;
diff --git a/net/server/http_server_fuzzer.cc b/net/server/http_server_fuzzer.cc index 53e0899..e8c57af 100644 --- a/net/server/http_server_fuzzer.cc +++ b/net/server/http_server_fuzzer.cc
@@ -5,18 +5,18 @@ #include "base/logging.h" #include "base/macros.h" #include "base/run_loop.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/net_errors.h" #include "net/log/test_net_log.h" #include "net/server/http_server.h" #include "net/socket/fuzzed_server_socket.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace { class WaitTillHttpCloseDelegate : public net::HttpServer::Delegate { public: - WaitTillHttpCloseDelegate(base::FuzzedDataProvider* data_provider, + WaitTillHttpCloseDelegate(FuzzedDataProvider* data_provider, const base::Closure& done_closure) : server_(nullptr), data_provider_(data_provider), @@ -81,7 +81,7 @@ }; net::HttpServer* server_; - base::FuzzedDataProvider* const data_provider_; + FuzzedDataProvider* const data_provider_; base::Closure done_closure_; const uint8_t action_flags_; @@ -95,7 +95,7 @@ // |data| is used to create a FuzzedServerSocket. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { net::TestNetLog test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); std::unique_ptr<net::ServerSocket> server_socket( std::make_unique<net::FuzzedServerSocket>(&data_provider, &test_net_log));
diff --git a/net/socket/fuzzed_datagram_client_socket.cc b/net/socket/fuzzed_datagram_client_socket.cc index 6b011f8..aea50374 100644 --- a/net/socket/fuzzed_datagram_client_socket.cc +++ b/net/socket/fuzzed_datagram_client_socket.cc
@@ -11,12 +11,12 @@ #include "base/location.h" #include "base/logging.h" #include "base/strings/string_piece.h" -#include "base/test/fuzzed_data_provider.h" #include "base/threading/thread_task_runner_handle.h" #include "net/base/io_buffer.h" #include "net/base/ip_address.h" #include "net/base/net_errors.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -29,7 +29,7 @@ ERR_MSG_TOO_BIG}; FuzzedDatagramClientSocket::FuzzedDatagramClientSocket( - base::FuzzedDataProvider* data_provider) + FuzzedDataProvider* data_provider) : data_provider_(data_provider), weak_factory_(this) {} FuzzedDatagramClientSocket::~FuzzedDatagramClientSocket() = default;
diff --git a/net/socket/fuzzed_datagram_client_socket.h b/net/socket/fuzzed_datagram_client_socket.h index 62c68db..9659bec 100644 --- a/net/socket/fuzzed_datagram_client_socket.h +++ b/net/socket/fuzzed_datagram_client_socket.h
@@ -16,9 +16,7 @@ #include "net/log/net_log_with_source.h" #include "net/traffic_annotation/network_traffic_annotation.h" -namespace base { class FuzzedDataProvider; -} namespace net { @@ -30,7 +28,7 @@ class FuzzedDatagramClientSocket : public DatagramClientSocket { public: // |data_provider| must outlive the created socket. - explicit FuzzedDatagramClientSocket(base::FuzzedDataProvider* data_provider); + explicit FuzzedDatagramClientSocket(FuzzedDataProvider* data_provider); ~FuzzedDatagramClientSocket() override; // DatagramClientSocket implementation: @@ -83,7 +81,7 @@ void OnReadComplete(net::CompletionOnceCallback callback, int result); void OnWriteComplete(net::CompletionOnceCallback callback, int result); - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; bool connected_ = false; bool read_pending_ = false;
diff --git a/net/socket/fuzzed_server_socket.cc b/net/socket/fuzzed_server_socket.cc index cffa433d..7e2d4b9 100644 --- a/net/socket/fuzzed_server_socket.cc +++ b/net/socket/fuzzed_server_socket.cc
@@ -13,7 +13,7 @@ namespace net { -FuzzedServerSocket::FuzzedServerSocket(base::FuzzedDataProvider* data_provider, +FuzzedServerSocket::FuzzedServerSocket(FuzzedDataProvider* data_provider, net::NetLog* net_log) : data_provider_(data_provider), net_log_(net_log),
diff --git a/net/socket/fuzzed_server_socket.h b/net/socket/fuzzed_server_socket.h index 0d9cd16..006fa85 100644 --- a/net/socket/fuzzed_server_socket.h +++ b/net/socket/fuzzed_server_socket.h
@@ -16,9 +16,7 @@ #include "net/base/ip_endpoint.h" #include "net/socket/server_socket.h" -namespace base { class FuzzedDataProvider; -} namespace net { @@ -34,8 +32,7 @@ // |data_provider| is used as to determine behavior of the socket. It // must remain valid until after both this object and the StreamSocket // produced by Accept are destroyed. - FuzzedServerSocket(base::FuzzedDataProvider* data_provider, - net::NetLog* net_log); + FuzzedServerSocket(FuzzedDataProvider* data_provider, net::NetLog* net_log); ~FuzzedServerSocket() override; int Listen(const IPEndPoint& address, int backlog) override; @@ -48,7 +45,7 @@ void DispatchAccept(std::unique_ptr<StreamSocket>* socket, CompletionOnceCallback callback); - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; net::NetLog* net_log_; IPEndPoint listening_on_;
diff --git a/net/socket/fuzzed_socket.cc b/net/socket/fuzzed_socket.cc index b974d9c4..a71a6d5 100644 --- a/net/socket/fuzzed_socket.cc +++ b/net/socket/fuzzed_socket.cc
@@ -9,11 +9,11 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/test/fuzzed_data_provider.h" #include "base/threading/thread_task_runner_handle.h" #include "net/base/io_buffer.h" #include "net/log/net_log_source_type.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -36,7 +36,7 @@ } // namespace -FuzzedSocket::FuzzedSocket(base::FuzzedDataProvider* data_provider, +FuzzedSocket::FuzzedSocket(FuzzedDataProvider* data_provider, net::NetLog* net_log) : data_provider_(data_provider), net_log_(NetLogWithSource::Make(net_log, NetLogSourceType::SOCKET)),
diff --git a/net/socket/fuzzed_socket.h b/net/socket/fuzzed_socket.h index abe5961..63d069e 100644 --- a/net/socket/fuzzed_socket.h +++ b/net/socket/fuzzed_socket.h
@@ -17,9 +17,7 @@ #include "net/socket/transport_client_socket.h" #include "net/traffic_annotation/network_traffic_annotation.h" -namespace base { class FuzzedDataProvider; -} namespace net { @@ -43,7 +41,7 @@ public: // |data_provider| is used as to determine behavior of the FuzzedSocket. It // must remain valid until after the FuzzedSocket is destroyed. - FuzzedSocket(base::FuzzedDataProvider* data_provider, net::NetLog* net_log); + FuzzedSocket(FuzzedDataProvider* data_provider, net::NetLog* net_log); ~FuzzedSocket() override; // If set to true, the socket will fuzz the result of the Connect() call. @@ -104,7 +102,7 @@ // See https://crbug.com/823012 bool ForceSync() const; - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; // If true, the result of the Connect() call is fuzzed - it can succeed or // fail with a variety of connection errors, and it can complete synchronously
diff --git a/net/socket/fuzzed_socket_factory.cc b/net/socket/fuzzed_socket_factory.cc index 7736fa4..31d776a 100644 --- a/net/socket/fuzzed_socket_factory.cc +++ b/net/socket/fuzzed_socket_factory.cc
@@ -5,7 +5,6 @@ #include "net/socket/fuzzed_socket_factory.h" #include "base/logging.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/address_list.h" #include "net/base/ip_endpoint.h" #include "net/base/net_errors.h" @@ -16,6 +15,7 @@ #include "net/socket/fuzzed_socket.h" #include "net/socket/ssl_client_socket.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -105,8 +105,7 @@ } // namespace -FuzzedSocketFactory::FuzzedSocketFactory( - base::FuzzedDataProvider* data_provider) +FuzzedSocketFactory::FuzzedSocketFactory(FuzzedDataProvider* data_provider) : data_provider_(data_provider), fuzz_connect_result_(true) {} FuzzedSocketFactory::~FuzzedSocketFactory() = default;
diff --git a/net/socket/fuzzed_socket_factory.h b/net/socket/fuzzed_socket_factory.h index 4002d006..28fc0a2 100644 --- a/net/socket/fuzzed_socket_factory.h +++ b/net/socket/fuzzed_socket_factory.h
@@ -11,9 +11,7 @@ #include "base/macros.h" #include "net/socket/client_socket_factory.h" -namespace base { class FuzzedDataProvider; -} namespace net { @@ -33,7 +31,7 @@ // creates. Other objects can also continue to consume |data_provider|, as // long as their calls into it are made on the CLientSocketFactory's thread // and the calls are deterministic. - explicit FuzzedSocketFactory(base::FuzzedDataProvider* data_provider); + explicit FuzzedSocketFactory(FuzzedDataProvider* data_provider); ~FuzzedSocketFactory() override; std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( @@ -70,7 +68,7 @@ void set_fuzz_connect_result(bool v) { fuzz_connect_result_ = v; } private: - base::FuzzedDataProvider* data_provider_; + FuzzedDataProvider* data_provider_; bool fuzz_connect_result_; DISALLOW_COPY_AND_ASSIGN(FuzzedSocketFactory);
diff --git a/net/socket/socks5_client_socket_fuzzer.cc b/net/socket/socks5_client_socket_fuzzer.cc index ad2a9a92..a2fb1cc5 100644 --- a/net/socket/socks5_client_socket_fuzzer.cc +++ b/net/socket/socks5_client_socket_fuzzer.cc
@@ -8,7 +8,7 @@ #include <memory> #include "base/logging.h" -#include "base/test/fuzzed_data_provider.h" + #include "net/base/address_list.h" #include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" @@ -16,6 +16,7 @@ #include "net/socket/fuzzed_socket.h" #include "net/socket/socks5_client_socket.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for Socks5ClientSocket. Only covers the SOCKS5 greeet and // handshake. @@ -26,7 +27,7 @@ // Use a test NetLog, to exercise logging code. net::TestNetLog test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::TestCompletionCallback callback; std::unique_ptr<net::FuzzedSocket> fuzzed_socket(
diff --git a/net/socket/socks_client_socket_fuzzer.cc b/net/socket/socks_client_socket_fuzzer.cc index 6f300f9..be5764c 100644 --- a/net/socket/socks_client_socket_fuzzer.cc +++ b/net/socket/socks_client_socket_fuzzer.cc
@@ -8,7 +8,6 @@ #include <memory> #include "base/logging.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/address_list.h" #include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" @@ -18,6 +17,7 @@ #include "net/socket/fuzzed_socket.h" #include "net/socket/socks_client_socket.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Fuzzer for SocksClientSocket. Only covers the SOCKS4 handshake. // @@ -27,7 +27,7 @@ // Use a test NetLog, to exercise logging code. net::TestNetLog test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); // Determine if the DNS lookup returns synchronously or asynchronously, // succeeds or fails, and returns an IPv4 or IPv6 address.
diff --git a/net/spdy/fuzzing/hpack_decoder_fuzzer.cc b/net/spdy/fuzzing/hpack_decoder_fuzzer.cc index 16df5e0..1c481d6 100644 --- a/net/spdy/fuzzing/hpack_decoder_fuzzer.cc +++ b/net/spdy/fuzzing/hpack_decoder_fuzzer.cc
@@ -8,8 +8,8 @@ #include <list> #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_decoder.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { @@ -17,7 +17,7 @@ if (size < 4) return 0; - base::FuzzedDataProvider fuzzed_data_provider(data, size); + FuzzedDataProvider fuzzed_data_provider(data, size); size_t max_string_size = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 10 * size); http2::HpackDecoder decoder(http2::HpackDecoderNoOpListener::NoOpListener(),
diff --git a/net/spdy/fuzzing/http2_frame_decoder_fuzzer.cc b/net/spdy/fuzzing/http2_frame_decoder_fuzzer.cc index f89de197..3941773 100644 --- a/net/spdy/fuzzing/http2_frame_decoder_fuzzer.cc +++ b/net/spdy/fuzzing/http2_frame_decoder_fuzzer.cc
@@ -8,12 +8,12 @@ #include <list> #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data_provider(data, size); + FuzzedDataProvider fuzzed_data_provider(data, size); http2::Http2FrameDecoder decoder; // Store all chunks in a function scope list, as the API requires the caller
diff --git a/net/spdy/spdy_session_fuzzer.cc b/net/spdy/spdy_session_fuzzer.cc index 417cd9a..8f42b451 100644 --- a/net/spdy/spdy_session_fuzzer.cc +++ b/net/spdy/spdy_session_fuzzer.cc
@@ -5,7 +5,6 @@ #include "base/logging.h" #include "base/run_loop.h" #include "base/stl_util.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/host_port_pair.h" #include "net/base/net_errors.h" #include "net/base/request_priority.h" @@ -19,6 +18,7 @@ #include "net/spdy/spdy_test_util_common.h" #include "net/ssl/ssl_config.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace { @@ -59,7 +59,7 @@ class FuzzedSocketFactoryWithMockSSLData : public FuzzedSocketFactory { public: explicit FuzzedSocketFactoryWithMockSSLData( - base::FuzzedDataProvider* data_provider); + FuzzedDataProvider* data_provider); void AddSSLSocketDataProvider(SSLSocketDataProvider* socket); @@ -74,7 +74,7 @@ }; FuzzedSocketFactoryWithMockSSLData::FuzzedSocketFactoryWithMockSSLData( - base::FuzzedDataProvider* data_provider) + FuzzedDataProvider* data_provider) : FuzzedSocketFactory(data_provider) {} void FuzzedSocketFactoryWithMockSSLData::AddSSLSocketDataProvider( @@ -102,7 +102,7 @@ // |data| is used to create a FuzzedServerSocket. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { net::BoundTestNetLog bound_test_net_log; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::FuzzedSocketFactoryWithMockSSLData socket_factory(&data_provider); socket_factory.set_fuzz_connect_result(false);
diff --git a/net/third_party/uri_template/uri_template_fuzzer.cc b/net/third_party/uri_template/uri_template_fuzzer.cc index e444a0f..148dbbad 100644 --- a/net/third_party/uri_template/uri_template_fuzzer.cc +++ b/net/third_party/uri_template/uri_template_fuzzer.cc
@@ -4,11 +4,11 @@ #include "net/third_party/uri_template/uri_template.h" -#include "base/test/fuzzed_data_provider.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data(data, size); + FuzzedDataProvider fuzzed_data(data, size); std::string uri_template = fuzzed_data.ConsumeRandomLengthString(256); // Construct a map containing variable names and corresponding values. std::unordered_map<std::string, std::string> parameters;
diff --git a/net/url_request/url_request_data_job_fuzzer.cc b/net/url_request/url_request_data_job_fuzzer.cc index 1d119c9..0bf92f81 100644 --- a/net/url_request/url_request_data_job_fuzzer.cc +++ b/net/url_request/url_request_data_job_fuzzer.cc
@@ -9,7 +9,6 @@ #include "base/memory/singleton.h" #include "base/run_loop.h" -#include "base/test/fuzzed_data_provider.h" #include "base/threading/thread_task_runner_handle.h" #include "net/http/http_request_headers.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" @@ -17,6 +16,7 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_test_util.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace { @@ -43,7 +43,7 @@ } int CreateAndReadFromDataURLRequest(const uint8_t* data, size_t size) { - base::FuzzedDataProvider provider(data, size); + FuzzedDataProvider provider(data, size); read_lengths_.clear(); // Allocate an IOBuffer with fuzzed size.
diff --git a/net/url_request/url_request_ftp_fuzzer.cc b/net/url_request/url_request_ftp_fuzzer.cc index e0f16dc..f2a9e8cf 100644 --- a/net/url_request/url_request_ftp_fuzzer.cc +++ b/net/url_request/url_request_ftp_fuzzer.cc
@@ -7,7 +7,6 @@ #include "base/macros.h" #include "base/run_loop.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/request_priority.h" #include "net/dns/context_host_resolver.h" #include "net/dns/fuzzed_host_resolver_util.h" @@ -22,6 +21,7 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_test_util.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" #include "url/gurl.h" namespace { @@ -54,7 +54,7 @@ // Integration fuzzer for URLRequestFtpJob. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::TestURLRequestContext url_request_context(true); net::FuzzedSocketFactory fuzzed_socket_factory(&data_provider); url_request_context.set_client_socket_factory(&fuzzed_socket_factory);
diff --git a/net/url_request/url_request_fuzzer.cc b/net/url_request/url_request_fuzzer.cc index a8fb3ab..e53ac14 100644 --- a/net/url_request/url_request_fuzzer.cc +++ b/net/url_request/url_request_fuzzer.cc
@@ -10,13 +10,13 @@ #include <memory> #include "base/run_loop.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/request_priority.h" #include "net/socket/fuzzed_socket_factory.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_test_util.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" #include "url/gurl.h" @@ -35,7 +35,7 @@ if (size > kMaxInputSize) return 0; - base::FuzzedDataProvider data_provider(data, size); + FuzzedDataProvider data_provider(data, size); net::TestURLRequestContext url_request_context(true); net::FuzzedSocketFactory fuzzed_socket_factory(&data_provider); url_request_context.set_client_socket_factory(&fuzzed_socket_factory);
diff --git a/net/websockets/websocket_deflate_stream_fuzzer.cc b/net/websockets/websocket_deflate_stream_fuzzer.cc index 195ad38..3c20868 100644 --- a/net/websockets/websocket_deflate_stream_fuzzer.cc +++ b/net/websockets/websocket_deflate_stream_fuzzer.cc
@@ -12,7 +12,6 @@ #include "base/memory/scoped_refptr.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" -#include "base/test/fuzzed_data_provider.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "net/websockets/websocket_deflate_parameters.h" @@ -22,6 +21,7 @@ #include "net/websockets/websocket_extension.h" #include "net/websockets/websocket_frame.h" #include "net/websockets/websocket_stream.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" namespace net { @@ -43,7 +43,7 @@ class WebSocketFuzzedStream final : public WebSocketStream { public: - explicit WebSocketFuzzedStream(base::FuzzedDataProvider* fuzzed_data_provider) + explicit WebSocketFuzzedStream(FuzzedDataProvider* fuzzed_data_provider) : fuzzed_data_provider_(fuzzed_data_provider) {} int ReadFrames(std::vector<std::unique_ptr<WebSocketFrame>>* frames, @@ -90,11 +90,11 @@ return frame; } - base::FuzzedDataProvider* fuzzed_data_provider_; + FuzzedDataProvider* fuzzed_data_provider_; }; void WebSocketDeflateStreamFuzz(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data_provider(data, size); + FuzzedDataProvider fuzzed_data_provider(data, size); uint8_t flags = fuzzed_data_provider.ConsumeIntegral<uint8_t>(); bool server_no_context_takeover = flags & 0x1; bool client_no_context_takeover = (flags >> 1) & 0x1;
diff --git a/net/websockets/websocket_frame_parser_fuzzer.cc b/net/websockets/websocket_frame_parser_fuzzer.cc index 90c5d92bc..acb3db3f 100644 --- a/net/websockets/websocket_frame_parser_fuzzer.cc +++ b/net/websockets/websocket_frame_parser_fuzzer.cc
@@ -7,12 +7,12 @@ #include <vector> -#include "base/test/fuzzed_data_provider.h" #include "net/websockets/websocket_frame_parser.h" +#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h" // Entry point for LibFuzzer. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - base::FuzzedDataProvider fuzzed_data_provider(data, size); + FuzzedDataProvider fuzzed_data_provider(data, size); net::WebSocketFrameParser parser; std::vector<std::unique_ptr<net::WebSocketFrameChunk>> frame_chunks; while (fuzzed_data_provider.remaining_bytes() > 0) {
diff --git a/services/identity/public/cpp/access_token_fetcher.cc b/services/identity/public/cpp/access_token_fetcher.cc index 89e2802..d6e16f2 100644 --- a/services/identity/public/cpp/access_token_fetcher.cc +++ b/services/identity/public/cpp/access_token_fetcher.cc
@@ -11,7 +11,7 @@ namespace identity { -AccessTokenFetcher::AccessTokenFetcher(const std::string& account_id, +AccessTokenFetcher::AccessTokenFetcher(const CoreAccountId& account_id, const std::string& oauth_consumer_name, OAuth2TokenService* token_service, const identity::ScopeSet& scopes, @@ -26,7 +26,7 @@ mode) {} AccessTokenFetcher::AccessTokenFetcher( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& oauth_consumer_name, OAuth2TokenService* token_service, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, @@ -43,7 +43,7 @@ std::move(callback), mode) {} -AccessTokenFetcher::AccessTokenFetcher(const std::string& account_id, +AccessTokenFetcher::AccessTokenFetcher(const CoreAccountId& account_id, const std::string client_id, const std::string client_secret, const std::string& oauth_consumer_name, @@ -62,7 +62,7 @@ mode) {} AccessTokenFetcher::AccessTokenFetcher( - const std::string& account_id, + const CoreAccountId& account_id, const std::string client_id, const std::string client_secret, const std::string& oauth_consumer_name,
diff --git a/services/identity/public/cpp/access_token_fetcher.h b/services/identity/public/cpp/access_token_fetcher.h index 8ed681d..a9ad344 100644 --- a/services/identity/public/cpp/access_token_fetcher.h +++ b/services/identity/public/cpp/access_token_fetcher.h
@@ -50,7 +50,7 @@ // OAuth2 access token for |account_id| and |scopes|. The |callback| is called // once the request completes (successful or not). If the AccessTokenFetcher // is destroyed before the process completes, the callback is not called. - AccessTokenFetcher(const std::string& account_id, + AccessTokenFetcher(const CoreAccountId& account_id, const std::string& oauth_consumer_name, OAuth2TokenService* token_service, const identity::ScopeSet& scopes, @@ -63,7 +63,7 @@ // once the request completes (successful or not). If the AccessTokenFetcher // is destroyed before the process completes, the callback is not called. AccessTokenFetcher( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& oauth_consumer_name, OAuth2TokenService* token_service, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, @@ -74,7 +74,7 @@ // Instantiates a fetcher and immediately starts the process of obtaining an // OAuth2 access token for |account_id| and |scopes| using both the // |client_id| and |client_secret| to identify the OAuth client app. - AccessTokenFetcher(const std::string& account_id, + AccessTokenFetcher(const CoreAccountId& account_id, const std::string client_id, const std::string client_secret, const std::string& oauth_consumer_name, @@ -87,7 +87,7 @@ private: AccessTokenFetcher( - const std::string& account_id, + const CoreAccountId& account_id, const std::string client_id, const std::string client_secret, const std::string& oauth_consumer_name, @@ -120,7 +120,7 @@ void RunCallbackAndMaybeDie(GoogleServiceAuthError error, AccessTokenInfo access_token_info); - const std::string account_id_; + const CoreAccountId account_id_; const std::string client_id_; const std::string client_secret_; OAuth2TokenService* token_service_;
diff --git a/services/identity/public/cpp/accounts_cookie_mutator.h b/services/identity/public/cpp/accounts_cookie_mutator.h index 3c5d851d..4a68144 100644 --- a/services/identity/public/cpp/accounts_cookie_mutator.h +++ b/services/identity/public/cpp/accounts_cookie_mutator.h
@@ -9,6 +9,7 @@ #include <vector> #include "base/macros.h" +#include "google_apis/gaia/core_account_id.h" #include "google_apis/gaia/gaia_auth_fetcher.h" #include "google_apis/gaia/google_service_auth_error.h" @@ -25,14 +26,14 @@ AccountsCookieMutator() = default; virtual ~AccountsCookieMutator() = default; - typedef base::OnceCallback<void(const std::string& account_id, + typedef base::OnceCallback<void(const CoreAccountId& account_id, const GoogleServiceAuthError& error)> AddAccountToCookieCompletedCallback; // Adds an account identified by |account_id| to the cookie responsible for // tracking the list of logged-in Google sessions across the web. virtual void AddAccountToCookie( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) = 0; @@ -40,7 +41,7 @@ // cookie responsible for tracking the list of logged-in Google sessions // across the web. virtual void AddAccountToCookieWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) = 0; @@ -54,7 +55,7 @@ // not have refresh tokens, the operation will fail with a // GoogleServiceAuthError::USER_NOT_SIGNED_UP error. virtual void SetAccountsInCookie( - const std::vector<std::string>& account_ids, + const std::vector<CoreAccountId>& account_ids, gaia::GaiaSource source, base::OnceCallback<void(signin::SetAccountsInCookieResult)> set_accounts_in_cookies_completed_callback) = 0;
diff --git a/services/identity/public/cpp/accounts_cookie_mutator_impl.cc b/services/identity/public/cpp/accounts_cookie_mutator_impl.cc index a503873..6874343 100644 --- a/services/identity/public/cpp/accounts_cookie_mutator_impl.cc +++ b/services/identity/public/cpp/accounts_cookie_mutator_impl.cc
@@ -22,7 +22,7 @@ AccountsCookieMutatorImpl::~AccountsCookieMutatorImpl() {} void AccountsCookieMutatorImpl::AddAccountToCookie( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) { gaia_cookie_manager_service_->AddAccountToCookie( @@ -30,7 +30,7 @@ } void AccountsCookieMutatorImpl::AddAccountToCookieWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) { @@ -39,13 +39,12 @@ } void AccountsCookieMutatorImpl::SetAccountsInCookie( - const std::vector<std::string>& account_ids, + const std::vector<CoreAccountId>& account_ids, gaia::GaiaSource source, base::OnceCallback<void(signin::SetAccountsInCookieResult)> set_accounts_in_cookies_completed_callback) { - std::vector<std::pair<CoreAccountId, std::string>> accounts; - for (const auto& id : account_ids) { - CoreAccountId account_id(id); + std::vector<GaiaCookieManagerService::AccountIdGaiaIdPair> accounts; + for (const auto& account_id : account_ids) { accounts.push_back(make_pair( account_id, account_tracker_service_->GetAccountInfo(account_id).gaia)); }
diff --git a/services/identity/public/cpp/accounts_cookie_mutator_impl.h b/services/identity/public/cpp/accounts_cookie_mutator_impl.h index b457e56..33d459a0 100644 --- a/services/identity/public/cpp/accounts_cookie_mutator_impl.h +++ b/services/identity/public/cpp/accounts_cookie_mutator_impl.h
@@ -29,18 +29,18 @@ ~AccountsCookieMutatorImpl() override; void AddAccountToCookie( - const std::string& account_id, + const CoreAccountId& account_id, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) override; void AddAccountToCookieWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& access_token, gaia::GaiaSource source, AddAccountToCookieCompletedCallback completion_callback) override; void SetAccountsInCookie( - const std::vector<std::string>& account_ids, + const std::vector<CoreAccountId>& account_ids, gaia::GaiaSource source, base::OnceCallback<void(signin::SetAccountsInCookieResult)> set_accounts_in_cookies_completed_callback) override;
diff --git a/services/identity/public/cpp/accounts_cookie_mutator_unittest.cc b/services/identity/public/cpp/accounts_cookie_mutator_unittest.cc index 2511f20..06c5b19 100644 --- a/services/identity/public/cpp/accounts_cookie_mutator_unittest.cc +++ b/services/identity/public/cpp/accounts_cookie_mutator_unittest.cc
@@ -154,8 +154,9 @@ base::RunLoop run_loop; std::string account_id_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_id_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; run_loop.Quit(); @@ -182,8 +183,9 @@ base::RunLoop run_loop; std::string account_id_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_id_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; run_loop.Quit(); @@ -213,8 +215,9 @@ base::RunLoop run_loop; std::string account_id_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_id_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; run_loop.Quit(); @@ -242,8 +245,9 @@ base::RunLoop run_loop; std::string account_id_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_id_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; run_loop.Quit(); @@ -268,8 +272,8 @@ AccountsCookiesMutatorAction::kSetAccountsInCookie); base::RunLoop run_loop; - std::vector<std::string> accounts_ids = {kTestUnavailableAccountId, - kTestOtherUnavailableAccountId}; + std::vector<CoreAccountId> accounts_ids = {kTestUnavailableAccountId, + kTestOtherUnavailableAccountId}; accounts_cookie_mutator()->SetAccountsInCookie( accounts_ids, gaia::GaiaSource::kChrome, base::BindOnce( @@ -292,8 +296,8 @@ std::string account_id = AddAcountWithRefreshToken(kTestAccountEmail); base::RunLoop run_loop; - std::vector<std::string> accounts_ids = {account_id, - kTestUnavailableAccountId}; + std::vector<CoreAccountId> accounts_ids = {account_id, + kTestUnavailableAccountId}; accounts_cookie_mutator()->SetAccountsInCookie( accounts_ids, gaia::GaiaSource::kChrome, base::BindOnce( @@ -318,7 +322,7 @@ std::string other_account_id = AddAcountWithRefreshToken(kTestOtherAccountEmail); base::RunLoop run_loop; - std::vector<std::string> accounts_ids = {account_id, other_account_id}; + std::vector<CoreAccountId> accounts_ids = {account_id, other_account_id}; accounts_cookie_mutator()->SetAccountsInCookie( accounts_ids, gaia::GaiaSource::kChrome, base::BindOnce(
diff --git a/services/identity/public/cpp/accounts_mutator.h b/services/identity/public/cpp/accounts_mutator.h index 047b4e58..cc4d26f8 100644 --- a/services/identity/public/cpp/accounts_mutator.h +++ b/services/identity/public/cpp/accounts_mutator.h
@@ -11,6 +11,7 @@ #include "base/optional.h" #include "components/signin/core/browser/signin_buildflags.h" #include "components/signin/core/browser/signin_metrics.h" +#include "google_apis/gaia/core_account_id.h" namespace identity { @@ -23,7 +24,7 @@ // Updates the information of the account associated with |gaia_id|, first // adding that account to the system if it is not known. - virtual std::string AddOrUpdateAccount( + virtual CoreAccountId AddOrUpdateAccount( const std::string& gaia_id, const std::string& email, const std::string& refresh_token, @@ -32,14 +33,14 @@ // Updates the information about account identified by |account_id|. virtual void UpdateAccountInfo( - const std::string& account_id, + const CoreAccountId& account_id, base::Optional<bool> is_child_account, base::Optional<bool> is_under_advanced_protection) = 0; // Removes the account given by |account_id|. Also revokes the token // server-side if needed. virtual void RemoveAccount( - const std::string& account_id, + const CoreAccountId& account_id, signin_metrics::SourceForRefreshTokenOperation source) = 0; // Removes all accounts. @@ -60,7 +61,7 @@ // this mutator. The device ID of the current mutator is not moved to the // target mutator. virtual void MoveAccount(AccountsMutator* target, - const std::string& account_id) = 0; + const CoreAccountId& account_id) = 0; #endif // Updates the refresh token for the supervised user.
diff --git a/services/identity/public/cpp/accounts_mutator_impl.cc b/services/identity/public/cpp/accounts_mutator_impl.cc index deaf63a..2e17776 100644 --- a/services/identity/public/cpp/accounts_mutator_impl.cc +++ b/services/identity/public/cpp/accounts_mutator_impl.cc
@@ -35,13 +35,13 @@ AccountsMutatorImpl::~AccountsMutatorImpl() {} -std::string AccountsMutatorImpl::AddOrUpdateAccount( +CoreAccountId AccountsMutatorImpl::AddOrUpdateAccount( const std::string& gaia_id, const std::string& email, const std::string& refresh_token, bool is_under_advanced_protection, signin_metrics::SourceForRefreshTokenOperation source) { - std::string account_id = + CoreAccountId account_id = account_tracker_service_->SeedAccountInfo(gaia_id, email); account_tracker_service_->SetIsAdvancedProtectionAccount( account_id, is_under_advanced_protection); @@ -51,7 +51,7 @@ } void AccountsMutatorImpl::UpdateAccountInfo( - const std::string& account_id, + const CoreAccountId& account_id, base::Optional<bool> is_child_account, base::Optional<bool> is_under_advanced_protection) { if (is_child_account.has_value()) { @@ -66,7 +66,7 @@ } void AccountsMutatorImpl::RemoveAccount( - const std::string& account_id, + const CoreAccountId& account_id, signin_metrics::SourceForRefreshTokenOperation source) { token_service_->RevokeCredentials(account_id, source); } @@ -88,7 +88,7 @@ #if BUILDFLAG(ENABLE_DICE_SUPPORT) void AccountsMutatorImpl::MoveAccount(AccountsMutator* target, - const std::string& account_id) { + const CoreAccountId& account_id) { AccountInfo account_info = account_tracker_service_->GetAccountInfo(account_id); DCHECK(!account_info.account_id.empty()); @@ -108,7 +108,7 @@ void AccountsMutatorImpl::LegacySetRefreshTokenForSupervisedUser( const std::string& refresh_token) { token_service_->UpdateCredentials( - "managed_user@localhost", refresh_token, + CoreAccountId("managed_user@localhost"), refresh_token, signin_metrics::SourceForRefreshTokenOperation::kSupervisedUser_InitSync); }
diff --git a/services/identity/public/cpp/accounts_mutator_impl.h b/services/identity/public/cpp/accounts_mutator_impl.h index c5bdfd3..a4f58ab1 100644 --- a/services/identity/public/cpp/accounts_mutator_impl.h +++ b/services/identity/public/cpp/accounts_mutator_impl.h
@@ -11,6 +11,7 @@ #include "build/buildflag.h" #include "components/signin/core/browser/signin_buildflags.h" #include "components/signin/core/browser/signin_metrics.h" +#include "google_apis/gaia/core_account_id.h" #include "services/identity/public/cpp/accounts_mutator.h" class AccountTrackerService; @@ -30,18 +31,18 @@ ~AccountsMutatorImpl() override; // AccountsMutator: - std::string AddOrUpdateAccount( + CoreAccountId AddOrUpdateAccount( const std::string& gaia_id, const std::string& email, const std::string& refresh_token, bool is_under_advanced_protection, signin_metrics::SourceForRefreshTokenOperation source) override; void UpdateAccountInfo( - const std::string& account_id, + const CoreAccountId& account_id, base::Optional<bool> is_child_account, base::Optional<bool> is_under_advanced_protection) override; void RemoveAccount( - const std::string& account_id, + const CoreAccountId& account_id, signin_metrics::SourceForRefreshTokenOperation source) override; void RemoveAllAccounts( signin_metrics::SourceForRefreshTokenOperation source) override; @@ -50,7 +51,7 @@ #if BUILDFLAG(ENABLE_DICE_SUPPORT) void MoveAccount(AccountsMutator* target, - const std::string& account_id) override; + const CoreAccountId& account_id) override; #endif void LegacySetRefreshTokenForSupervisedUser(
diff --git a/services/identity/public/cpp/accounts_mutator_unittest.cc b/services/identity/public/cpp/accounts_mutator_unittest.cc index 9874096..44ea178 100644 --- a/services/identity/public/cpp/accounts_mutator_unittest.cc +++ b/services/identity/public/cpp/accounts_mutator_unittest.cc
@@ -57,7 +57,7 @@ private: // identity::IdentityManager::DiagnosticsObserver: void OnRefreshTokenUpdatedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, bool is_refresh_token_valid, const std::string& source) override { token_updator_account_id_ = account_id; @@ -66,7 +66,7 @@ } void OnRefreshTokenRemovedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& source) override { token_remover_account_id_ = account_id; token_remover_source_ = source;
diff --git a/services/identity/public/cpp/identity_manager.cc b/services/identity/public/cpp/identity_manager.cc index a8133ec0..0588040 100644 --- a/services/identity/public/cpp/identity_manager.cc +++ b/services/identity/public/cpp/identity_manager.cc
@@ -402,7 +402,7 @@ #if !defined(OS_IOS) && !defined(OS_ANDROID) void IdentityManager::DeprecatedLoadCredentialsForSupervisedUser( - const std::string& primary_account_id) { + const CoreAccountId& primary_account_id) { token_service_->LoadCredentials(primary_account_id); } #endif
diff --git a/services/identity/public/cpp/identity_manager.h b/services/identity/public/cpp/identity_manager.h index 4dbc919..26d0e89 100644 --- a/services/identity/public/cpp/identity_manager.h +++ b/services/identity/public/cpp/identity_manager.h
@@ -296,33 +296,33 @@ DiagnosticsObserver& operator=(const DiagnosticsObserver&) = delete; // Called when receiving request for access token. - virtual void OnAccessTokenRequested(const std::string& account_id, + virtual void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const ScopeSet& scopes) {} // Called when an access token request is completed. Contains diagnostic // information about the access token request. - virtual void OnAccessTokenRequestCompleted(const std::string& account_id, + virtual void OnAccessTokenRequestCompleted(const CoreAccountId& account_id, const std::string& consumer_id, const ScopeSet& scopes, GoogleServiceAuthError error, base::Time expiration_time) {} // Called when an access token was removed. - virtual void OnAccessTokenRemovedFromCache(const std::string& account_id, + virtual void OnAccessTokenRemovedFromCache(const CoreAccountId& account_id, const ScopeSet& scopes) {} // Called when a new refresh token is available. Contains diagnostic // information about the source of the operation. virtual void OnRefreshTokenUpdatedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, bool is_refresh_token_valid, const std::string& source) {} // Called when a refresh token is removed. Contains diagnostic information // about the source that initiated the revokation operation. virtual void OnRefreshTokenRemovedForAccountFromSource( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& source) {} }; @@ -386,7 +386,7 @@ // TODO(https://crbug.com/860492): Remove this method when supervised users // support is eliminated. void DeprecatedLoadCredentialsForSupervisedUser( - const std::string& primary_account_id); + const CoreAccountId& primary_account_id); #endif // Returns pointer to the object used to obtain diagnostics about the internal
diff --git a/services/identity/public/cpp/identity_manager_unittest.cc b/services/identity/public/cpp/identity_manager_unittest.cc index 517ff9b..84682c7 100644 --- a/services/identity/public/cpp/identity_manager_unittest.cc +++ b/services/identity/public/cpp/identity_manager_unittest.cc
@@ -167,7 +167,7 @@ private: // IdentityManager::DiagnosticsObserver: - void OnAccessTokenRequested(const std::string& account_id, + void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) override { token_requestor_account_id_ = account_id; @@ -178,13 +178,13 @@ std::move(on_access_token_requested_callback_).Run(); } - void OnAccessTokenRemovedFromCache(const std::string& account_id, + void OnAccessTokenRemovedFromCache(const CoreAccountId& account_id, const ScopeSet& scopes) override { token_remover_account_id_ = account_id; token_remover_scopes_ = scopes; } - void OnAccessTokenRequestCompleted(const std::string& account_id, + void OnAccessTokenRequestCompleted(const CoreAccountId& account_id, const std::string& consumer_id, const ScopeSet& scopes, GoogleServiceAuthError error, @@ -1766,8 +1766,9 @@ std::string account_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; }); @@ -1788,8 +1789,9 @@ std::string account_from_add_account_to_cookie_completed_callback; GoogleServiceAuthError error_from_add_account_to_cookie_completed_callback; - auto completion_callback = base::BindLambdaForTesting( - [&](const std::string& account_id, const GoogleServiceAuthError& error) { + auto completion_callback = + base::BindLambdaForTesting([&](const CoreAccountId& account_id, + const GoogleServiceAuthError& error) { account_from_add_account_to_cookie_completed_callback = account_id; error_from_add_account_to_cookie_completed_callback = error; });
diff --git a/services/identity/public/cpp/identity_test_environment.cc b/services/identity/public/cpp/identity_test_environment.cc index 801b254..cad9b36 100644 --- a/services/identity/public/cpp/identity_test_environment.cc +++ b/services/identity/public/cpp/identity_test_environment.cc
@@ -295,23 +295,23 @@ } void IdentityTestEnvironment::SetRefreshTokenForAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { return identity::SetRefreshTokenForAccount(identity_manager(), account_id); } void IdentityTestEnvironment::SetInvalidRefreshTokenForAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { return identity::SetInvalidRefreshTokenForAccount(identity_manager(), account_id); } void IdentityTestEnvironment::RemoveRefreshTokenForAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { return identity::RemoveRefreshTokenForAccount(identity_manager(), account_id); } void IdentityTestEnvironment::UpdatePersistentErrorOfRefreshTokenForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& auth_error) { return identity::UpdatePersistentErrorOfRefreshTokenForAccount( identity_manager(), account_id, auth_error); @@ -341,7 +341,7 @@ void IdentityTestEnvironment:: WaitForAccessTokenRequestIfNecessaryAndRespondWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& token, const base::Time& expiration, const std::string& id_token) { @@ -372,7 +372,7 @@ void IdentityTestEnvironment:: WaitForAccessTokenRequestIfNecessaryAndRespondWithError( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error) { WaitForAccessTokenRequestIfNecessary(account_id); fake_token_service()->IssueErrorForAllPendingRequestsForAccount(account_id, @@ -395,7 +395,7 @@ AccessTokenRequestState&& other) = default; void IdentityTestEnvironment::OnAccessTokenRequested( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) { // Post a task to handle this access token request in order to support the @@ -410,7 +410,7 @@ } void IdentityTestEnvironment::HandleOnAccessTokenRequested( - std::string account_id) { + CoreAccountId account_id) { if (on_access_token_requested_callback_) { std::move(on_access_token_requested_callback_).Run(); return; @@ -435,7 +435,7 @@ } void IdentityTestEnvironment::WaitForAccessTokenRequestIfNecessary( - base::Optional<std::string> account_id) { + base::Optional<CoreAccountId> account_id) { // Handle HandleOnAccessTokenRequested getting called before // WaitForAccessTokenRequestIfNecessary. if (account_id) { @@ -500,7 +500,7 @@ } void IdentityTestEnvironment::SimulateSuccessfulFetchOfAccountInfo( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& email, const std::string& gaia, const std::string& hosted_domain,
diff --git a/services/identity/public/cpp/identity_test_environment.h b/services/identity/public/cpp/identity_test_environment.h index ffbedbab..8c49998 100644 --- a/services/identity/public/cpp/identity_test_environment.h +++ b/services/identity/public/cpp/identity_test_environment.h
@@ -139,24 +139,24 @@ // are loaded. After updating the token, blocks until the update is processed // by |identity_manager|. NOTE: See disclaimer at top of file re: direct // usage. - void SetRefreshTokenForAccount(const std::string& account_id); + void SetRefreshTokenForAccount(const CoreAccountId& account_id); // Sets a special invalid refresh token for the given account (which must // already be available). Before updating the refresh token, blocks until // refresh tokens are loaded. After updating the token, blocks until the // update is processed by |identity_manager|. NOTE: See disclaimer at top of // file re: direct usage. - void SetInvalidRefreshTokenForAccount(const std::string& account_id); + void SetInvalidRefreshTokenForAccount(const CoreAccountId& account_id); // Removes any refresh token that is present for the given account. Blocks // until the refresh token is removed. // NOTE: See disclaimer at top of file re: direct usage. - void RemoveRefreshTokenForAccount(const std::string& account_id); + void RemoveRefreshTokenForAccount(const CoreAccountId& account_id); // Updates the persistent auth error set on |account_id| which must be a known // account, i.e., an account with a refresh token. void UpdatePersistentErrorOfRefreshTokenForAccount( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& auth_error); // Puts the given accounts into the Gaia cookie, replacing any previous @@ -197,7 +197,7 @@ // requests are handled synchronously or asynchronously in the production // code. void WaitForAccessTokenRequestIfNecessaryAndRespondWithToken( - const std::string& account_id, + const CoreAccountId& account_id, const std::string& token, const base::Time& expiration, const std::string& id_token = std::string()); @@ -233,7 +233,7 @@ // requests are handled synchronously or asynchronously in the production // code. void WaitForAccessTokenRequestIfNecessaryAndRespondWithError( - const std::string& account_id, + const CoreAccountId& account_id, const GoogleServiceAuthError& error); // Sets a callback that will be invoked on the next incoming access token @@ -268,7 +268,7 @@ // Simulate account fetching using AccountTrackerService without sending // network requests. - void SimulateSuccessfulFetchOfAccountInfo(const std::string& account_id, + void SimulateSuccessfulFetchOfAccountInfo(const CoreAccountId& account_id, const std::string& email, const std::string& gaia, const std::string& hosted_domain, @@ -318,7 +318,7 @@ IdentityTestEnvironment(IdentityManager* identity_manager); // IdentityManager::DiagnosticsObserver: - void OnAccessTokenRequested(const std::string& account_id, + void OnAccessTokenRequested(const CoreAccountId& account_id, const std::string& consumer_id, const identity::ScopeSet& scopes) override; @@ -326,14 +326,14 @@ // |account_id|. Invokes |on_access_token_request_callback_| if the latter // is non-null *and* either |*pending_access_token_requester_| equals // |account_id| or |pending_access_token_requester_| is empty. - void HandleOnAccessTokenRequested(std::string account_id); + void HandleOnAccessTokenRequested(CoreAccountId account_id); // If a token request for |account_id| (or any account if nullopt) has already // been made and not matched by a different call, returns immediately. // Otherwise and runs a nested runloop until a matching access token request // is observed. void WaitForAccessTokenRequestIfNecessary( - base::Optional<std::string> account_id); + base::Optional<CoreAccountId> account_id); // Returns the FakeProfileOAuth2TokenService owned by IdentityManager. FakeProfileOAuth2TokenService* fake_token_service();
diff --git a/services/identity/public/cpp/primary_account_mutator.h b/services/identity/public/cpp/primary_account_mutator.h index 2094a8c9..b474abf1 100644 --- a/services/identity/public/cpp/primary_account_mutator.h +++ b/services/identity/public/cpp/primary_account_mutator.h
@@ -9,6 +9,7 @@ #include "base/callback_forward.h" #include "components/signin/core/browser/signin_metrics.h" +#include "google_apis/gaia/core_account_id.h" namespace identity { @@ -48,7 +49,7 @@ // - the account username is allowed by policy, // - there is not already a primary account set, // - the account is known by the IdentityManager. - virtual bool SetPrimaryAccount(const std::string& account_id) = 0; + virtual bool SetPrimaryAccount(const CoreAccountId& account_id) = 0; // Clears the primary account, and returns whether the operation // succeeded or not. Depending on |action|, the other accounts
diff --git a/services/identity/public/cpp/primary_account_mutator_impl.cc b/services/identity/public/cpp/primary_account_mutator_impl.cc index c8f6917..a159b01 100644 --- a/services/identity/public/cpp/primary_account_mutator_impl.cc +++ b/services/identity/public/cpp/primary_account_mutator_impl.cc
@@ -29,7 +29,7 @@ #if !defined(OS_CHROMEOS) bool PrimaryAccountMutatorImpl::SetPrimaryAccount( - const std::string& account_id) { + const CoreAccountId& account_id) { if (!pref_service_->GetBoolean(prefs::kSigninAllowed)) return false;
diff --git a/services/identity/public/cpp/primary_account_mutator_impl.h b/services/identity/public/cpp/primary_account_mutator_impl.h index 19a0a85..b0163dc 100644 --- a/services/identity/public/cpp/primary_account_mutator_impl.h +++ b/services/identity/public/cpp/primary_account_mutator_impl.h
@@ -26,7 +26,7 @@ // PrimaryAccountMutator implementation. #if !defined(OS_CHROMEOS) - bool SetPrimaryAccount(const std::string& account_id) override; + bool SetPrimaryAccount(const CoreAccountId& account_id) override; bool ClearPrimaryAccount( ClearAccountsAction action, signin_metrics::ProfileSignout source_metric,
diff --git a/testing/android/native_test/BUILD.gn b/testing/android/native_test/BUILD.gn index 15a0b12..17dcf61 100644 --- a/testing/android/native_test/BUILD.gn +++ b/testing/android/native_test/BUILD.gn
@@ -23,6 +23,17 @@ ] } +source_set("native_browser_test_support") { + testonly = true + sources = [ + "native_browser_test_support.cc", + "native_browser_test_support.h", + ] + deps = [ + ":native_browser_test_jni_headers", + ] +} + source_set("native_test_native_code") { testonly = true sources = [ @@ -70,3 +81,10 @@ "java/src/org/chromium/native_test/NativeTest.java", ] } + +generate_jni("native_browser_test_jni_headers") { + sources = [ + "java/src/org/chromium/native_test/NativeBrowserTest.java", + ] + jni_package = "native_browser_test" +}
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java index c1a3afb1..b615680 100644 --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTest.java
@@ -60,4 +60,14 @@ Log.e(TAG, "Failed to remove %s", privateDataDirectory.getAbsolutePath()); } } + + /** + * To be called when the browser tests Activity has completed any asynchronous + * initialization and is ready for the test to run. This informs C++ to run the test. + */ + public static void javaStartupTasksComplete() { + nativeJavaStartupTasksCompleteForBrowserTests(); + } + + private static native void nativeJavaStartupTasksCompleteForBrowserTests(); }
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestActivity.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestActivity.java index 61ac642a..0e3f245f0 100644 --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestActivity.java +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestActivity.java
@@ -41,9 +41,6 @@ mStarted = true; NativeBrowserTest.deletePrivateDataDirectory(getPrivateDataDirectory()); initializeBrowserProcess(); - // TODO(danakj): Move to ContentShellBrowserTestActivity when async - // initialization is done there. - runTests(); } protected void runTests() {
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestApplication.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestApplication.java index 708dbcb6..3a9f63d 100644 --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestApplication.java +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeBrowserTestApplication.java
@@ -7,7 +7,9 @@ import android.app.Application; import android.content.Context; +import org.chromium.base.ApplicationStatus; import org.chromium.base.BuildConfig; +import org.chromium.base.CommandLine; import org.chromium.base.ContextUtils; import org.chromium.base.multidex.ChromiumMultiDexInstaller; @@ -19,12 +21,15 @@ protected void attachBaseContext(Context base) { super.attachBaseContext(base); ContextUtils.initApplicationContext(this); - if (isMainProcess() || isBrowserProcess()) { // We need secondary dex in order to run EmbeddedTestServer in a // privileged process. if (BuildConfig.IS_MULTIDEX_ENABLED) ChromiumMultiDexInstaller.install(this); } + if (isBrowserProcess()) { + CommandLine.init(new String[] {}); + ApplicationStatus.initialize(this); + } } protected static boolean isMainProcess() {
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeTest.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeTest.java index d161758..c24864e 100644 --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeTest.java +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeTest.java
@@ -12,10 +12,8 @@ import android.os.Handler; import android.os.Process; -import org.chromium.base.CommandLine; import org.chromium.base.Log; import org.chromium.base.annotations.JNINamespace; -import org.chromium.base.multidex.ChromiumMultiDexInstaller; import org.chromium.base.test.util.UrlUtils; import org.chromium.test.reporter.TestStatusReporter; @@ -67,12 +65,10 @@ } public void preCreate(Activity activity) { - ChromiumMultiDexInstaller.install(activity); + // Empty, but subclasses override. } public void postCreate(Activity activity) { - CommandLine.init(new String[]{}); - parseArgumentsFromIntent(activity, activity.getIntent()); mReporter = new TestStatusReporter(activity); mReporter.testRunStarted(Process.myPid());
diff --git a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestApplication.java b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestApplication.java index c5f29d48..ca2fc1d 100644 --- a/testing/android/native_test/java/src/org/chromium/native_test/NativeTestApplication.java +++ b/testing/android/native_test/java/src/org/chromium/native_test/NativeTestApplication.java
@@ -8,6 +8,7 @@ import android.content.Context; import org.chromium.base.BuildConfig; +import org.chromium.base.CommandLine; import org.chromium.base.multidex.ChromiumMultiDexInstaller; /** @@ -18,6 +19,7 @@ protected void attachBaseContext(Context base) { super.attachBaseContext(base); assert getBaseContext() != null; + CommandLine.init(new String[] {}); if (BuildConfig.IS_MULTIDEX_ENABLED) { ChromiumMultiDexInstaller.install(this); }
diff --git a/testing/android/native_test/native_browser_test_support.cc b/testing/android/native_test/native_browser_test_support.cc new file mode 100644 index 0000000..dba4764 --- /dev/null +++ b/testing/android/native_test/native_browser_test_support.cc
@@ -0,0 +1,35 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This class sets up the environment for running the native tests inside an +// android application. It outputs (to a fifo) markers identifying the +// START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, +// etc. +// These markers are read by the test runner script to generate test results. +// It installs signal handlers to detect crashes. + +#include "jni/NativeBrowserTest_jni.h" + +namespace testing { +namespace android { + +namespace { + +// Java calls to set this true when async startup tasks are done for browser +// tests. +bool g_java_startup_tasks_complete = false; + +} // namespace + +void JNI_NativeBrowserTest_JavaStartupTasksCompleteForBrowserTests( + JNIEnv* env) { + g_java_startup_tasks_complete = true; +} + +bool JavaAsyncStartupTasksCompleteForBrowserTests() { + return g_java_startup_tasks_complete; +} + +} // namespace android +} // namespace testing
diff --git a/testing/android/native_test/native_browser_test_support.h b/testing/android/native_test/native_browser_test_support.h new file mode 100644 index 0000000..be10ad9 --- /dev/null +++ b/testing/android/native_test/native_browser_test_support.h
@@ -0,0 +1,21 @@ +// Copyright 2019 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 TESTING_ANDROID_NATIVE_TEST_NATIVE_BROWSER_TEST_SUPPORT_H_ +#define TESTING_ANDROID_NATIVE_TEST_NATIVE_BROWSER_TEST_SUPPORT_H_ + +#include <jni.h> + +namespace testing { +namespace android { + +// Android browser tests must wait for Java async initialization tasks to run +// before running the test. This function returns true in the browser process +// once they are done. +bool JavaAsyncStartupTasksCompleteForBrowserTests(); + +} // namespace android +} // namespace testing + +#endif // TESTING_ANDROID_NATIVE_TEST_NATIVE_BROWSER_TEST_SUPPORT_H_
diff --git a/testing/android/native_test/native_test_launcher.cc b/testing/android/native_test/native_test_launcher.cc index 2cd5475..d8ca168 100644 --- a/testing/android/native_test/native_test_launcher.cc +++ b/testing/android/native_test/native_test_launcher.cc
@@ -25,6 +25,7 @@ #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/test/test_support_android.h" +#include "base/threading/thread_restrictions.h" #include "gtest/gtest.h" #include "testing/android/native_test/main_runner.h" #include "testing/android/native_test/native_test_jni_headers/NativeTest_jni.h" @@ -76,6 +77,8 @@ const JavaParamRef<jstring>& jstdout_file_path, const JavaParamRef<jobject>& app_context, const JavaParamRef<jstring>& jtest_data_dir) { + base::ScopedAllowBlockingForTesting allow; + // Command line initialized basically, will be fully initialized later. static const char* const kInitialArgv[] = { "ChromeTestActivity" }; base::CommandLine::Init(base::size(kInitialArgv), kInitialArgv);
diff --git a/testing/buildbot/filters/gpu.skiarenderer_vulkan_content_browsertests.filter b/testing/buildbot/filters/gpu.skiarenderer_vulkan_content_browsertests.filter index 2144092f..685d28c8 100644 --- a/testing/buildbot/filters/gpu.skiarenderer_vulkan_content_browsertests.filter +++ b/testing/buildbot/filters/gpu.skiarenderer_vulkan_content_browsertests.filter
@@ -61,6 +61,7 @@ -TouchActionBrowserTest.PanYMainThreadJanky/1 -TouchSelectionControllerClientAndroidSiteIsolationTest.BasicSelectionIsolatedIframe -WebContentsImplBrowserTest.PopupWindowBrowserNavResumeLoad +-WebContentsImplBrowserTest.SetPageFrozen -WebRtcBrowserTest.CanSetupH264VideoCallOnSupportedDevice -WebRtcCaptureFromElementBrowserTest.CaptureFromCanvas2DHandlesContextLoss -WebRtcCaptureFromElementBrowserTest.VerifyCanvasCaptureOffscreenCanvasFrames
diff --git a/testing/libfuzzer/getting_started.md b/testing/libfuzzer/getting_started.md index 918723f..aec1f4b 100644 --- a/testing/libfuzzer/getting_started.md +++ b/testing/libfuzzer/getting_started.md
@@ -302,8 +302,10 @@ } ``` -There is [base::FuzzedDataProvider] class that might be helpful for writing -fuzz targets using that approach. +There is [FuzzedDataProvider] class that might be helpful for writing fuzz +targets using that approach. In order to use it, add +`#include "third_party/libFuzzer/src/utils/FuzzedDataProvider.h"` to your fuzz +target source file. ## Submitting Fuzz Target to ClusterFuzz @@ -335,5 +337,5 @@ [Build Config]: reference.md#Builder-configurations [its own documentation]: http://llvm.org/docs/LibFuzzer.html#output [Getting Started with libprotobuf-mutator in Chromium]: libprotobuf-mutator.md -[base::FuzzedDataProvider]: https://cs.chromium.org/chromium/src/base/test/fuzzed_data_provider.h +[FuzzedDataProvider]: https://cs.chromium.org/chromium/src/third_party/libFuzzer/src/utils/FuzzedDataProvider.h [code coverage report]: efficient_fuzzer.md#Code-Coverage
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 83850b6e..14f9458 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -563,8 +563,7 @@ }, { "platforms": [ - "android", - "chromeos" + "android" ], "experiments": [ {
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc index 09c91f8..adc29e7 100644 --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc
@@ -310,5 +310,10 @@ const base::Feature kCanvasAlwaysDeferral{"CanvasAlwaysDeferral", base::FEATURE_ENABLED_BY_DEFAULT}; +// Use the new C++ implementation of WHATWG Streams. See +// https://crbug.com/977500. +const base::Feature kStreamsNative{"StreamsNative", + base::FEATURE_DISABLED_BY_DEFAULT}; + } // namespace features } // namespace blink
diff --git a/third_party/blink/public/BUILD.gn b/third_party/blink/public/BUILD.gn index c38996e..8b488778 100644 --- a/third_party/blink/public/BUILD.gn +++ b/third_party/blink/public/BUILD.gn
@@ -266,7 +266,6 @@ "platform/web_media_player_client.h", "platform/web_media_player_encrypted_media_client.h", "platform/web_media_player_source.h", - "platform/web_media_recorder_handler_client.h", "platform/web_media_source.h", "platform/web_media_stream.h", "platform/web_media_stream_center.h",
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h index 0f64ee7..01704ac 100644 --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h
@@ -92,6 +92,8 @@ BLINK_COMMON_EXPORT extern const base::Feature kCanvasAlwaysDeferral; +BLINK_COMMON_EXPORT extern const base::Feature kStreamsNative; + } // namespace features } // namespace blink
diff --git a/third_party/blink/public/mojom/web_feature/web_feature.mojom b/third_party/blink/public/mojom/web_feature/web_feature.mojom index b4c58258..e793faf8 100644 --- a/third_party/blink/public/mojom/web_feature/web_feature.mojom +++ b/third_party/blink/public/mojom/web_feature/web_feature.mojom
@@ -2316,6 +2316,8 @@ kLargestContentfulPaintExplicitlyRequested = 2927, kPageLifecycleTransitionsOptIn = 2928, kPageLifecycleTransitionsOptOut = 2929, + kPeriodicBackgroundSync = 2930, + kPeriodicBackgroundSyncRegister = 2931, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/blink/public/platform/web_media_recorder_handler_client.h b/third_party/blink/public/platform/web_media_recorder_handler_client.h deleted file mode 100644 index 0879095..0000000 --- a/third_party/blink/public/platform/web_media_recorder_handler_client.h +++ /dev/null
@@ -1,27 +0,0 @@ -// Copyright 2015 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 THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEDIA_RECORDER_HANDLER_CLIENT_H_ -#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEDIA_RECORDER_HANDLER_CLIENT_H_ - -#include "third_party/blink/public/platform/web_common.h" - -namespace blink { - -class WebString; - -// Interface used by a MediaRecorder to get errors and recorded data delivered. -class WebMediaRecorderHandlerClient { - public: - virtual void WriteData(const char* data, - size_t length, - bool last_inslice, - double timecode) = 0; - - virtual void OnError(const WebString& message) = 0; -}; - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_MEDIA_RECORDER_HANDLER_CLIENT_H_
diff --git a/third_party/blink/public/platform/web_runtime_features.h b/third_party/blink/public/platform/web_runtime_features.h index d06553df..8086ac23 100644 --- a/third_party/blink/public/platform/web_runtime_features.h +++ b/third_party/blink/public/platform/web_runtime_features.h
@@ -85,7 +85,6 @@ BLINK_PLATFORM_EXPORT static void EnableAutomaticLazyImageLoading(bool); BLINK_PLATFORM_EXPORT static void EnableBackgroundFetch(bool); BLINK_PLATFORM_EXPORT static void EnableBlinkHeapIncrementalMarking(bool); - BLINK_PLATFORM_EXPORT static void EnableBlinkHeapUnifiedGCScheduling(bool); BLINK_PLATFORM_EXPORT static void EnableBloatedRendererDetection(bool); BLINK_PLATFORM_EXPORT static void EnableBlockingFocusWithoutUserActivation( bool); @@ -246,6 +245,7 @@ BLINK_PLATFORM_EXPORT static void EnablePauseExecutionContextOnBackgroundFreeze(bool); BLINK_PLATFORM_EXPORT static void EnableConsolidatedMovementXY(bool); + BLINK_PLATFORM_EXPORT static void EnableStreamsNative(bool); private: WebRuntimeFeatures();
diff --git a/third_party/blink/renderer/core/dom/first_letter_pseudo_element.cc b/third_party/blink/renderer/core/dom/first_letter_pseudo_element.cc index de00395c..a1e641f 100644 --- a/third_party/blink/renderer/core/dom/first_letter_pseudo_element.cc +++ b/third_party/blink/renderer/core/dom/first_letter_pseudo_element.cc
@@ -101,7 +101,7 @@ LayoutObject* parent_layout_object = nullptr; // If we are looking at a first letter element then we need to find the - // first letter text layoutObject from the parent node, and not ourselves. + // first letter text LayoutObject from the parent node, and not ourselves. if (element.IsFirstLetterPseudoElement()) { parent_layout_object = element.ParentOrShadowHostElement()->GetLayoutObject(); @@ -147,9 +147,16 @@ first_letter_text_layout_object->NextSibling(); } else if (first_letter_text_layout_object->IsListMarker() || first_letter_text_layout_object == marker) { - first_letter_text_layout_object = - first_letter_text_layout_object->NextInPreOrderAfterChildren( - parent_layout_object); + // The list item marker may have out-of-flow siblings inside an anonymous + // block. Skip them to make sure we leave the anonymous block before + // continuing looking for the first letter text. + do { + first_letter_text_layout_object = + first_letter_text_layout_object->NextInPreOrderAfterChildren( + parent_layout_object); + } while ( + first_letter_text_layout_object && + first_letter_text_layout_object->IsFloatingOrOutOfFlowPositioned()); } else if (first_letter_text_layout_object ->IsFloatingOrOutOfFlowPositioned()) { if (first_letter_text_layout_object->Style()->StyleType() == @@ -261,14 +268,26 @@ void FirstLetterPseudoElement::AttachLayoutTree(AttachContext& context) { LayoutText* first_letter_text = FirstLetterPseudoElement::FirstLetterTextLayoutObject(*this); + // The FirstLetterPseudoElement should have been removed in + // Element::UpdateFirstLetterPseudoElement(). However if there existed a first + // letter before updating it, the layout tree will be different after + // DetachLayoutTree() called right before this method. + // If there is a bug in FirstLetterTextLayoutObject(), we might end up with + // null here. DCHECKing here, but handling the null pointer below to avoid + // crashes. + DCHECK(first_letter_text); + AttachContext first_letter_context(context); first_letter_context.next_sibling = first_letter_text; first_letter_context.next_sibling_valid = true; - first_letter_context.parent = first_letter_text->Parent(); - if (first_letter_context.parent->ForceLegacyLayout()) - first_letter_context.force_legacy_layout = true; + if (first_letter_text) { + first_letter_context.parent = first_letter_text->Parent(); + if (first_letter_context.parent->ForceLegacyLayout()) + first_letter_context.force_legacy_layout = true; + } PseudoElement::AttachLayoutTree(first_letter_context); - AttachFirstLetterTextLayoutObjects(first_letter_text); + if (first_letter_text) + AttachFirstLetterTextLayoutObjects(first_letter_text); } void FirstLetterPseudoElement::DetachLayoutTree(bool performing_reattach) {
diff --git a/third_party/blink/renderer/core/html/resources/html.css b/third_party/blink/renderer/core/html/resources/html.css index d4c2d23..5c5b650 100644 --- a/third_party/blink/renderer/core/html/resources/html.css +++ b/third_party/blink/renderer/core/html/resources/html.css
@@ -532,7 +532,7 @@ input::-internal-input-suggested, textarea::-internal-input-suggested { - font-family: system-ui !important; + font: -webkit-small-control !important; } input[type="password" i] {
diff --git a/third_party/blink/renderer/core/html/resources/win.css b/third_party/blink/renderer/core/html/resources/win.css index e3d49d1..1ea7fd3e 100644 --- a/third_party/blink/renderer/core/html/resources/win.css +++ b/third_party/blink/renderer/core/html/resources/win.css
@@ -107,3 +107,7 @@ /* Same as native_theme_base. */ border-color: #a9a9a9; } + +textarea::-internal-input-suggested { + font-family: monospace !important; +}
diff --git a/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc b/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc index 62b0109..2cad50e 100644 --- a/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc
@@ -173,13 +173,16 @@ return constraints_obj; } +static bool IsUsingLayerLists(const cc::Layer* root) { + return root->layer_tree_host() && + root->layer_tree_host()->IsUsingLayerLists(); +} + static std::unique_ptr<protocol::LayerTree::Layer> BuildObjectForLayer( const cc::Layer* root, const cc::Layer* layer, bool report_wheel_event_listeners) { - bool using_layer_list = - RuntimeEnabledFeatures::CompositeAfterPaintEnabled() || - RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled(); + bool is_using_layer_lists = IsUsingLayerLists(root); // When the front-end doesn't show internal layers, it will use the the first // DrawsContent layer as the root of the shown layer tree. This doesn't work @@ -187,13 +190,13 @@ // all DrawsContent layers. We have to cheat the front-end by setting // drawsContent to true for the root layer. bool draws_content = - (using_layer_list && root == layer) || layer->DrawsContent(); + (is_using_layer_lists && root == layer) || layer->DrawsContent(); std::unique_ptr<protocol::LayerTree::Layer> layer_object = protocol::LayerTree::Layer::create() .setLayerId(IdForLayer(layer)) - .setOffsetX(using_layer_list ? 0 : layer->position().x()) - .setOffsetY(using_layer_list ? 0 : layer->position().y()) + .setOffsetX(is_using_layer_lists ? 0 : layer->position().x()) + .setOffsetY(is_using_layer_lists ? 0 : layer->position().y()) .setWidth(layer->bounds().width()) .setHeight(layer->bounds().height()) .setPaintCount(layer->paint_count()) @@ -208,7 +211,7 @@ gfx::Transform transform; gfx::Point3F transform_origin; - if (using_layer_list) { + if (is_using_layer_lists) { transform = layer->ScreenSpaceTransform(); } else { transform = layer->transform(); @@ -235,6 +238,7 @@ } layer_object->setAnchorZ(transform_origin.z()); } + std::unique_ptr<Array<protocol::LayerTree::ScrollRect>> scroll_rects = BuildScrollRectsForLayer(layer, report_wheel_event_listeners); if (scroll_rects) @@ -348,6 +352,11 @@ root_frame, cc::EventListenerClass::kMouseWheel) == cc::EventListenerProperties::kBlocking; + // Update layers' ScreenSpaceTransform() which will be used during + // GatherLayers(). + if (IsUsingLayerLists(root_layer)) + root_layer->layer_tree_host()->UpdateLayers(); + GatherLayers(root_layer, layers, have_blocking_wheel_event_handlers, scrolling_layer_id); return layers;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index 17410fb..159a809 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
@@ -465,13 +465,14 @@ // |previous_inflow_position| and |BreakToken()|. scoped_refptr<const NGInlineBreakToken> previous_inline_break_token; + NGBlockChildIterator child_iterator(Node().FirstChild(), BreakToken()); + // If this layout is blocked by a display-lock, then we pretend this node has - // no children. Due to this, we skip layout on these children. - NGBlockChildIterator child_iterator( - Node().LayoutBlockedByDisplayLock(DisplayLockContext::kChildren) - ? NGBlockNode(nullptr) - : Node().FirstChild(), - BreakToken()); + // no children and that there are no break tokens. Due to this, we skip layout + // on these children. + if (Node().LayoutBlockedByDisplayLock(DisplayLockContext::kChildren)) + child_iterator = NGBlockChildIterator(NGBlockNode(nullptr), nullptr); + for (auto entry = child_iterator.NextChild(); NGLayoutInputNode child = entry.node; entry = child_iterator.NextChild(previous_inline_break_token.get())) {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index 5c8487a0..b0c718a 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc
@@ -1038,8 +1038,16 @@ // If |SetCachedLayoutResult| did not update cached |LayoutResult|, // |NeedsLayout()| flag should not be cleared. - if (needed_layout && layout_result != box_->GetCachedLayoutResult()) { - box_->SetNeedsLayout(layout_invalidation_reason::kUnknown); + if (needed_layout) { + if (constraint_space.IsIntermediateLayout()) { + DCHECK_NE(layout_result, box_->GetCachedLayoutResult()); + box_->SetNeedsLayout(layout_invalidation_reason::kUnknown); + } else if (layout_result != box_->GetCachedLayoutResult()) { + // TODO(kojii): If we failed to update CachedLayoutResult for other + // reasons, we'd like to review it. + NOTREACHED(); + box_->SetNeedsLayout(layout_invalidation_reason::kUnknown); + } } } else if (layout_result) { // OOF-positioned nodes have a two-tier cache, and their layout results
diff --git a/third_party/blink/renderer/core/origin_trials/navigation_origin_trial_features.cc b/third_party/blink/renderer/core/origin_trials/navigation_origin_trial_features.cc index bed5f86..cc313e1 100644 --- a/third_party/blink/renderer/core/origin_trials/navigation_origin_trial_features.cc +++ b/third_party/blink/renderer/core/origin_trials/navigation_origin_trial_features.cc
@@ -18,7 +18,8 @@ HashSet<OriginTrialFeature>, navigation_origin_trial_features, ({// Enable the kOriginTrialsSampleAPINavigation feature as a navigation // feature, for tests. - OriginTrialFeature::kOriginTrialsSampleAPINavigation})); + OriginTrialFeature::kOriginTrialsSampleAPINavigation, + OriginTrialFeature::kTextFragmentIdentifiers})); return navigation_origin_trial_features; }
diff --git a/third_party/blink/renderer/core/page/scrolling/fragment_anchor.cc b/third_party/blink/renderer/core/page/scrolling/fragment_anchor.cc index efd857b..2c238008 100644 --- a/third_party/blink/renderer/core/page/scrolling/fragment_anchor.cc +++ b/third_party/blink/renderer/core/page/scrolling/fragment_anchor.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/page/scrolling/fragment_anchor.h" +#include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/page/scrolling/element_fragment_anchor.h" #include "third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" @@ -17,7 +18,8 @@ anchor = ElementFragmentAnchor::TryCreate(url, frame); if (!anchor) { - if (RuntimeEnabledFeatures::TextFragmentIdentifiersEnabled()) { + if (RuntimeEnabledFeatures::TextFragmentIdentifiersEnabled( + frame.GetDocument())) { anchor = TextFragmentAnchor::TryCreate(url, frame, same_document_navigation); }
diff --git a/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.cc b/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.cc index 0e86521..d32b7b43 100644 --- a/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.cc +++ b/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor.cc
@@ -106,7 +106,7 @@ { // FindMatch might cause scrolling and set user_scrolled_ so reset it when // it's done. - base::AutoReset<bool>(&user_scrolled_, user_scrolled_); + base::AutoReset<bool> reset_user_scrolled(&user_scrolled_, user_scrolled_); metrics_->ResetMatchCount(); for (auto& finder : text_fragment_finders_) @@ -173,8 +173,8 @@ PhysicalRect scrolled_bounding_box = node.GetLayoutObject()->ScrollRectToVisible( bounding_box, - WebScrollIntoViewParams(ScrollAlignment::kAlignCenterIfNeeded, - ScrollAlignment::kAlignCenterIfNeeded, + WebScrollIntoViewParams(ScrollAlignment::kAlignCenterAlways, + ScrollAlignment::kAlignCenterAlways, kProgrammaticScroll)); did_scroll_into_view_ = true; metrics_->DidScroll();
diff --git a/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor_test.cc b/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor_test.cc index 2fe53ff..6b0f866 100644 --- a/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/text_fragment_anchor_test.cc
@@ -1035,6 +1035,49 @@ EXPECT_TRUE(GetDocument().Markers().Markers().IsEmpty()); } +// Test that the fragment anchor stays centered in view throughout loading. +TEST_F(TextFragmentAnchorTest, TargetStaysInView) { + SimRequest main_request("https://example.com/test.html#targetText=test", + "text/html"); + SimRequest image_request("https://example.com/image.svg", "image/svg+xml"); + LoadURL("https://example.com/test.html#targetText=test"); + main_request.Complete(R"HTML( + <!DOCTYPE html> + <style> + p { + margin-top: 1000px; + } + </style> + <img src="image.svg"> + <p id="text">test</p> + )HTML"); + Compositor().PaintFrame(); + RunAsyncMatchingTasks(); + + ScrollOffset first_scroll_offset = LayoutViewport()->GetScrollOffset(); + ASSERT_NE(ScrollOffset(), first_scroll_offset); + + Element& p = *GetDocument().getElementById("text"); + IntRect first_bounding_rect = BoundingRectInFrame(p); + EXPECT_TRUE(ViewportRect().Contains(first_bounding_rect)); + + // Load an image that pushes the target text out of view + image_request.Complete(R"SVG( + <svg xmlns="http://www.w3.org/2000/svg" width="200" height="2000"> + <rect fill="green" width="200" height="2000"/> + </svg> + )SVG"); + Compositor().BeginFrame(); + RunAsyncMatchingTasks(); + + // Ensure the target text is still in view and stayed centered + ASSERT_NE(first_scroll_offset, LayoutViewport()->GetScrollOffset()); + EXPECT_TRUE(ViewportRect().Contains(BoundingRectInFrame(p))); + EXPECT_EQ(first_bounding_rect, BoundingRectInFrame(p)); + + EXPECT_EQ(1u, GetDocument().Markers().Markers().size()); +} + } // namespace } // namespace blink
diff --git a/third_party/blink/renderer/core/testing/internals.cc b/third_party/blink/renderer/core/testing/internals.cc index 59043da3..5e8fec6 100644 --- a/third_party/blink/renderer/core/testing/internals.cc +++ b/third_party/blink/renderer/core/testing/internals.cc
@@ -173,6 +173,7 @@ #include "third_party/blink/renderer/platform/loader/fetch/resource_load_priority.h" #include "third_party/blink/renderer/platform/network/network_state_notifier.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" +#include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h" #include "third_party/blink/renderer/platform/text/layout_locale.h" #include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" @@ -3469,4 +3470,17 @@ resolver->Resolve(resource_load_priority); } +String Internals::getDocumentAgentId(Document* document) { + // Sounds like there's no notion of "process ID" in Blink, but the main + // thread's thread ID serves for that purpose. + PlatformThreadId process_id = Thread::MainThread()->ThreadId(); + + uintptr_t agent_address = reinterpret_cast<uintptr_t>(document->GetAgent()); + + // This serializes a pointer as a decimal number, which is a bit ugly, but + // it works. Is there any utility to dump a number in a hexadecimal form? + // I couldn't find one in WTF. + return String::Number(process_id) + ":" + String::Number(agent_address); +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/testing/internals.h b/third_party/blink/renderer/core/testing/internals.h index a42abd8..9b6c58b 100644 --- a/third_party/blink/renderer/core/testing/internals.h +++ b/third_party/blink/renderer/core/testing/internals.h
@@ -597,6 +597,8 @@ void setDeviceEmulationScale(float scale, ExceptionState&); + String getDocumentAgentId(Document*); + private: Document* ContextDocument() const; Vector<String> IconURLs(Document*, int icon_types_mask) const;
diff --git a/third_party/blink/renderer/core/testing/internals.idl b/third_party/blink/renderer/core/testing/internals.idl index f9a7aab..af80e6d 100644 --- a/third_party/blink/renderer/core/testing/internals.idl +++ b/third_party/blink/renderer/core/testing/internals.idl
@@ -433,4 +433,10 @@ // Sets the scale for devtools device emulation. [RaisesException] void setDeviceEmulationScale(float scale); + + // Return a string that identifies |document|'s WindowAgent. You can use it + // to distinguish different Agent instances (perhaps in a remote process). + // The returned string is composed of the process ID and the memory address + // of the Agent object. + DOMString getDocumentAgentId(Document document); };
diff --git a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc index 2e67eea6..ece20fa 100644 --- a/third_party/blink/renderer/modules/accessibility/ax_node_object.cc +++ b/third_party/blink/renderer/modules/accessibility/ax_node_object.cc
@@ -1194,9 +1194,9 @@ // See ARIA specification regarding grid/treegrid and readonly. if (IsTableCellLikeRole()) { AXObject* row = ParentObjectUnignored(); - if (row->IsTableRowLikeRole()) { + if (row && row->IsTableRowLikeRole()) { AXObject* table = row->ParentObjectUnignored(); - if (table->IsTableLikeRole() && + if (table && table->IsTableLikeRole() && (table->RoleValue() == ax::mojom::Role::kGrid || table->RoleValue() == ax::mojom::Role::kTreeGrid)) { if (table->Restriction() == kRestrictionReadOnly)
diff --git a/third_party/blink/renderer/modules/background_sync/BUILD.gn b/third_party/blink/renderer/modules/background_sync/BUILD.gn index 6b48fec..cb3108ea 100644 --- a/third_party/blink/renderer/modules/background_sync/BUILD.gn +++ b/third_party/blink/renderer/modules/background_sync/BUILD.gn
@@ -8,6 +8,8 @@ sources = [ "periodic_sync_event.cc", "periodic_sync_event.h", + "periodic_sync_manager.cc", + "periodic_sync_manager.h", "service_worker_global_scope_sync.h", "service_worker_registration_sync.cc", "service_worker_registration_sync.h",
diff --git a/third_party/blink/renderer/modules/background_sync/background_sync_options.idl b/third_party/blink/renderer/modules/background_sync/background_sync_options.idl new file mode 100644 index 0000000..54eb76d --- /dev/null +++ b/third_party/blink/renderer/modules/background_sync/background_sync_options.idl
@@ -0,0 +1,10 @@ +// Copyright 2019 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. + +// TODO(crbug.com/925297): Link to spec. +// Explainer: https://github.com/beverloo/periodic-background-sync + +dictionary BackgroundSyncOptions { + [EnforceRange] unsigned long long minInterval = 0; +};
diff --git a/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.cc b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.cc new file mode 100644 index 0000000..7799d56 --- /dev/null +++ b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.cc
@@ -0,0 +1,97 @@ +// Copyright 2019 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 "third_party/blink/renderer/modules/background_sync/periodic_sync_manager.h" + +#include "third_party/blink/public/platform/interface_provider.h" +#include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/renderer/bindings/core/v8/script_promise.h" +#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" +#include "third_party/blink/renderer/core/dom/dom_exception.h" +#include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/modules/background_sync/background_sync_options.h" +#include "third_party/blink/renderer/modules/service_worker/service_worker_registration.h" + +namespace blink { + +PeriodicSyncManager::PeriodicSyncManager( + ServiceWorkerRegistration* registration, + scoped_refptr<base::SequencedTaskRunner> task_runner) + : registration_(registration), task_runner_(std::move(task_runner)) { + DCHECK(registration_); +} + +ScriptPromise PeriodicSyncManager::registerPeriodicSync( + ScriptState* script_state, + const String& tag, + const BackgroundSyncOptions* options) { + if (!registration_->active()) { + return ScriptPromise::RejectWithDOMException( + script_state, MakeGarbageCollected<DOMException>( + DOMExceptionCode::kInvalidStateError, + "Registration failed - no active Service Worker")); + } + + auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); + ScriptPromise promise = resolver->Promise(); + + mojom::blink::SyncRegistrationOptionsPtr sync_registration = + mojom::blink::SyncRegistrationOptions::New(tag, options->minInterval()); + + GetBackgroundSyncServicePtr()->Register( + std::move(sync_registration), registration_->RegistrationId(), + WTF::Bind(&PeriodicSyncManager::RegisterCallback, WrapPersistent(this), + WrapPersistent(resolver))); + + return promise; +} + +const mojom::blink::PeriodicBackgroundSyncServicePtr& +PeriodicSyncManager::GetBackgroundSyncServicePtr() { + if (!background_sync_service_.get()) { + Platform::Current()->GetInterfaceProvider()->GetInterface( + mojo::MakeRequest(&background_sync_service_)); + } + return background_sync_service_; +} + +void PeriodicSyncManager::RegisterCallback( + ScriptPromiseResolver* resolver, + mojom::blink::BackgroundSyncError error, + mojom::blink::SyncRegistrationOptionsPtr options) { + switch (error) { + case mojom::blink::BackgroundSyncError::NONE: + resolver->Resolve(); + break; + case mojom::blink::BackgroundSyncError::NOT_FOUND: + NOTREACHED(); + break; + case mojom::blink::BackgroundSyncError::STORAGE: + resolver->Reject(MakeGarbageCollected<DOMException>( + DOMExceptionCode::kUnknownError, + "Periodic Background Sync is disabled.")); + break; + case mojom::blink::BackgroundSyncError::NOT_ALLOWED: + resolver->Reject(MakeGarbageCollected<DOMException>( + DOMExceptionCode::kInvalidAccessError, + "Attempted to register a sync event without a " + "window or registration tag too long.")); + break; + case mojom::blink::BackgroundSyncError::PERMISSION_DENIED: + resolver->Reject(MakeGarbageCollected<DOMException>( + DOMExceptionCode::kNotAllowedError, "Permission denied.")); + break; + case mojom::blink::BackgroundSyncError::NO_SERVICE_WORKER: + resolver->Reject(MakeGarbageCollected<DOMException>( + DOMExceptionCode::kUnknownError, "No service worker is active.")); + break; + } +} + +void PeriodicSyncManager::Trace(blink::Visitor* visitor) { + visitor->Trace(registration_); + ScriptWrappable::Trace(visitor); +} + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.h b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.h new file mode 100644 index 0000000..a61fc8c5 --- /dev/null +++ b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.h
@@ -0,0 +1,62 @@ +// Copyright 2019 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 THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_SYNC_PERIODIC_SYNC_MANAGER_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_SYNC_PERIODIC_SYNC_MANAGER_H_ + +#include "base/memory/scoped_refptr.h" +#include "base/sequenced_task_runner.h" +#include "third_party/blink/public/mojom/background_sync/background_sync.mojom-blink.h" +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" +#include "third_party/blink/renderer/platform/wtf/vector.h" + +namespace blink { + +class BackgroundSyncOptions; +class ScriptPromise; +class ScriptPromiseResolver; +class ScriptState; +class ServiceWorkerRegistration; + +class PeriodicSyncManager final : public ScriptWrappable { + DEFINE_WRAPPERTYPEINFO(); + + public: + static PeriodicSyncManager* Create( + ServiceWorkerRegistration* registration, + scoped_refptr<base::SequencedTaskRunner> task_runner) { + return MakeGarbageCollected<PeriodicSyncManager>(registration, + std::move(task_runner)); + } + + PeriodicSyncManager(ServiceWorkerRegistration* registration, + scoped_refptr<base::SequencedTaskRunner> task_runner); + + // IDL exposed interface + ScriptPromise registerPeriodicSync(ScriptState* script_state, + const String& tag, + const BackgroundSyncOptions* options); + + void Trace(blink::Visitor* visitor) override; + + private: + // Returns an initialized PeriodicBackgroundSyncServicePtr. A connection with + // the the browser's BackgroundSyncService is created the first time this + // method is called. + const mojom::blink::PeriodicBackgroundSyncServicePtr& + GetBackgroundSyncServicePtr(); + + // Callbacks + void RegisterCallback(ScriptPromiseResolver* resolver, + mojom::blink::BackgroundSyncError error, + mojom::blink::SyncRegistrationOptionsPtr options); + + Member<ServiceWorkerRegistration> registration_; + scoped_refptr<base::SequencedTaskRunner> task_runner_; + mojom::blink::PeriodicBackgroundSyncServicePtr background_sync_service_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_BACKGROUND_SYNC_PERIODIC_SYNC_MANAGER_H_
diff --git a/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.idl b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.idl new file mode 100644 index 0000000..2937412f --- /dev/null +++ b/third_party/blink/renderer/modules/background_sync/periodic_sync_manager.idl
@@ -0,0 +1,13 @@ +// Copyright 2019 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. + +// TODO(crbug.com/925297): Link to spec. +// Explainer: https://github.com/beverloo/periodic-background-sync + +[ + Exposed=(Window,Worker), + RuntimeEnabled=PeriodicBackgroundSync +] interface PeriodicSyncManager { + [MeasureAs=PeriodicBackgroundSyncRegister,CallWith=ScriptState,ImplementedAs=registerPeriodicSync] Promise<void> register(DOMString tag, optional BackgroundSyncOptions options); +};
diff --git a/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.h b/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.h index 73d84c2..dd5386d 100644 --- a/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.h +++ b/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.h
@@ -11,6 +11,7 @@ class ServiceWorkerGlobalScopeSync { public: + DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(periodicsync, kPeriodicsync) DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(sync, kSync) };
diff --git a/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.idl b/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.idl index 517376a..c929413 100644 --- a/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.idl +++ b/third_party/blink/renderer/modules/background_sync/service_worker_global_scope_sync.idl
@@ -6,4 +6,5 @@ ImplementedAs=ServiceWorkerGlobalScopeSync ] partial interface ServiceWorkerGlobalScope { attribute EventHandler onsync; + [RuntimeEnabled=PeriodicBackgroundSync] attribute EventHandler onperiodicsync; };
diff --git a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.cc b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.cc index d7bb8b1..b4c312b 100644 --- a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.cc +++ b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.h" +#include "third_party/blink/renderer/modules/background_sync/periodic_sync_manager.h" #include "third_party/blink/renderer/modules/background_sync/sync_manager.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_registration.h" @@ -46,9 +47,25 @@ return sync_manager_.Get(); } +PeriodicSyncManager* ServiceWorkerRegistrationSync::periodicSync( + ServiceWorkerRegistration& registration) { + return ServiceWorkerRegistrationSync::From(registration).periodicSync(); +} + +PeriodicSyncManager* ServiceWorkerRegistrationSync::periodicSync() { + if (!periodic_sync_manager_) { + ExecutionContext* execution_context = registration_->GetExecutionContext(); + periodic_sync_manager_ = PeriodicSyncManager::Create( + registration_, + execution_context->GetTaskRunner(TaskType::kInternalIPC)); + } + return periodic_sync_manager_.Get(); +} + void ServiceWorkerRegistrationSync::Trace(blink::Visitor* visitor) { visitor->Trace(registration_); visitor->Trace(sync_manager_); + visitor->Trace(periodic_sync_manager_); Supplement<ServiceWorkerRegistration>::Trace(visitor); }
diff --git a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.h b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.h index 8c71ad8..6c3c435e 100644 --- a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.h +++ b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.h
@@ -12,6 +12,7 @@ namespace blink { +class PeriodicSyncManager; class SyncManager; class ServiceWorkerRegistration; @@ -23,11 +24,18 @@ public: static const char kSupplementName[]; - explicit ServiceWorkerRegistrationSync(ServiceWorkerRegistration*); - virtual ~ServiceWorkerRegistrationSync(); - static ServiceWorkerRegistrationSync& From(ServiceWorkerRegistration&); + static ServiceWorkerRegistrationSync& From( + ServiceWorkerRegistration& registration); - static SyncManager* sync(ServiceWorkerRegistration&); + static PeriodicSyncManager* periodicSync( + ServiceWorkerRegistration& registration); + static SyncManager* sync(ServiceWorkerRegistration& registration); + + explicit ServiceWorkerRegistrationSync( + ServiceWorkerRegistration* registration); + virtual ~ServiceWorkerRegistrationSync(); + + PeriodicSyncManager* periodicSync(); SyncManager* sync(); void Trace(blink::Visitor*) override; @@ -35,6 +43,7 @@ private: Member<ServiceWorkerRegistration> registration_; Member<SyncManager> sync_manager_; + Member<PeriodicSyncManager> periodic_sync_manager_; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationSync); };
diff --git a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.idl b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.idl index 030feaa..43c6625 100644 --- a/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.idl +++ b/third_party/blink/renderer/modules/background_sync/service_worker_registration_sync.idl
@@ -6,5 +6,6 @@ Exposed=(Window,Worker), ImplementedAs=ServiceWorkerRegistrationSync ] partial interface ServiceWorkerRegistration { + [MeasureAs=PeriodicBackgroundSync, RuntimeEnabled=PeriodicBackgroundSync] readonly attribute PeriodicSyncManager periodicSync; [MeasureAs=BackgroundSync] readonly attribute SyncManager sync; };
diff --git a/third_party/blink/renderer/modules/csspaint/paint_rendering_context_2d.cc b/third_party/blink/renderer/modules/csspaint/paint_rendering_context_2d.cc index 9aff2b7..185b40a 100644 --- a/third_party/blink/renderer/modules/csspaint/paint_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/csspaint/paint_rendering_context_2d.cc
@@ -26,7 +26,6 @@ Canvas()->clear(context_settings->alpha() ? SK_ColorTRANSPARENT : SK_ColorBLACK); did_record_draw_commands_in_paint_recorder_ = true; - Canvas()->scale(zoom, zoom); } void PaintRenderingContext2D::InitializePaintRecorder() { @@ -37,6 +36,7 @@ // Always save an initial frame, to support resetting the top level matrix // and clip. + canvas->scale(effective_zoom_, effective_zoom_); canvas->save(); did_record_draw_commands_in_paint_recorder_ = false;
diff --git a/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client_test.cc b/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client_test.cc index c60672d..1cf70725 100644 --- a/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client_test.cc +++ b/third_party/blink/renderer/modules/csspaint/paint_worklet_proxy_client_test.cc
@@ -376,50 +376,4 @@ &RunAllDefinitionsMustBeRegisteredBeforePostingTestOnWorklet); } -void RunAllGlobalScopesMustBeCreatedTestOnWorklet( - WorkerThread* thread, - PaintWorkletProxyClient* proxy_client, - scoped_refptr<PaintWorkletPaintDispatcher> dispatcher, - base::WaitableEvent* waitable_event) { - for (size_t i = 0; i < PaintWorklet::kNumGlobalScopesPerThread; i++) { - proxy_client->AddGlobalScope(To<WorkletGlobalScope>(thread->GlobalScope())); - } - - EXPECT_EQ(proxy_client->GetGlobalScopesForTesting().size(), - PaintWorklet::kNumGlobalScopesPerThread); - - waitable_event->Signal(); -} - -TEST_F(PaintWorkletProxyClientTest, AllGlobalScopesMustBeCreated) { - ScopedOffMainThreadCSSPaintForTest off_main_thread_css_paint(true); - - std::unique_ptr<WorkerThread> worklet_thread = - CreateThreadAndProvidePaintWorkletProxyClient( - &GetDocument(), reporting_proxy_.get(), proxy_client_); - - EXPECT_TRUE(proxy_client_->GetGlobalScopesForTesting().IsEmpty()); - - base::WaitableEvent waitable_event; - PostCrossThreadTask( - *worklet_thread->GetTaskRunner(TaskType::kInternalTest), FROM_HERE, - CrossThreadBindOnce( - &RunAllGlobalScopesMustBeCreatedTestOnWorklet, - CrossThreadUnretained(worklet_thread.get()), - CrossThreadPersistent<PaintWorkletProxyClient>(proxy_client_), - dispatcher_, CrossThreadUnretained(&waitable_event))); - waitable_event.Wait(); - - paint_worklet_->SetProxyClientForTesting(proxy_client_); - while (paint_worklet_->NeedsToCreateGlobalScopeForTesting()) { - paint_worklet_->AddGlobalScopeForTesting(); - } - - EXPECT_EQ(paint_worklet_->GetGlobalScopesForTesting().size(), - 2 * PaintWorklet::kNumGlobalScopesPerThread); - - worklet_thread->Terminate(); - worklet_thread->WaitForShutdownForTesting(); -} - } // namespace blink
diff --git a/third_party/blink/renderer/modules/csspaint/paint_worklet_test.cc b/third_party/blink/renderer/modules/csspaint/paint_worklet_test.cc index 7b7eec0..c9fd510 100644 --- a/third_party/blink/renderer/modules/csspaint/paint_worklet_test.cc +++ b/third_party/blink/renderer/modules/csspaint/paint_worklet_test.cc
@@ -201,4 +201,41 @@ EXPECT_TRUE(generator->HasAlpha()); } +class OffThreadPaintWorkletTest : public PageTestBase, + public ::testing::WithParamInterface<bool> { + public: + OffThreadPaintWorkletTest() : off_main_thread_css_paint_(GetParam()) {} + + private: + ScopedOffMainThreadCSSPaintForTest off_main_thread_css_paint_; +}; + +INSTANTIATE_TEST_SUITE_P(, OffThreadPaintWorkletTest, ::testing::Bool()); + +TEST_P(OffThreadPaintWorkletTest, AllGlobalScopesMustBeCreated) { + PaintWorklet* paint_worklet_to_test = + MakeGarbageCollected<PaintWorklet>(&GetFrame()); + + EXPECT_TRUE(paint_worklet_to_test->GetGlobalScopesForTesting().IsEmpty()); + + scoped_refptr<PaintWorkletPaintDispatcher> dispatcher = + base::MakeRefCounted<PaintWorkletPaintDispatcher>(); + Persistent<PaintWorkletProxyClient> proxy_client = + MakeGarbageCollected<PaintWorkletProxyClient>(1, paint_worklet_to_test, + dispatcher); + paint_worklet_to_test->SetProxyClientForTesting(proxy_client); + + while (paint_worklet_to_test->NeedsToCreateGlobalScopeForTesting()) { + paint_worklet_to_test->AddGlobalScopeForTesting(); + } + + if (RuntimeEnabledFeatures::OffMainThreadCSSPaintEnabled()) { + EXPECT_EQ(paint_worklet_to_test->GetGlobalScopesForTesting().size(), + 2 * PaintWorklet::kNumGlobalScopesPerThread); + } else { + EXPECT_EQ(paint_worklet_to_test->GetGlobalScopesForTesting().size(), + PaintWorklet::kNumGlobalScopesPerThread); + } +} + } // namespace blink
diff --git a/third_party/blink/renderer/modules/mediarecorder/BUILD.gn b/third_party/blink/renderer/modules/mediarecorder/BUILD.gn index 832d6976..61e1a244 100644 --- a/third_party/blink/renderer/modules/mediarecorder/BUILD.gn +++ b/third_party/blink/renderer/modules/mediarecorder/BUILD.gn
@@ -27,6 +27,7 @@ "media_recorder.h", "media_recorder_handler.cc", "media_recorder_handler.h", + "media_recorder_handler_client.h", "vea_encoder.cc", "vea_encoder.h", "video_track_recorder.cc",
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc index 934867060..b3b34ac4 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc
@@ -352,7 +352,7 @@ timecode); } -void MediaRecorder::OnError(const WebString& message) { +void MediaRecorder::OnError(const String& message) { DLOG(ERROR) << message.Ascii(); StopRecording(); ScheduleDispatchEvent(Event::Create(event_type_names::kError));
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder.h b/third_party/blink/renderer/modules/mediarecorder/media_recorder.h index f57dc2b..7ca2d702 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder.h +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder.h
@@ -6,11 +6,11 @@ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_MEDIA_RECORDER_H_ #include <memory> -#include "third_party/blink/public/platform/web_media_recorder_handler_client.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/core/dom/events/event_target.h" #include "third_party/blink/renderer/modules/event_target_modules.h" #include "third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h" +#include "third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h" #include "third_party/blink/renderer/modules/mediarecorder/media_recorder_options.h" #include "third_party/blink/renderer/modules/mediastream/media_stream.h" #include "third_party/blink/renderer/modules/modules_export.h" @@ -23,7 +23,7 @@ class MODULES_EXPORT MediaRecorder final : public EventTargetWithInlineData, - public WebMediaRecorderHandlerClient, + public MediaRecorderHandlerClient, public ActiveScriptWrappable<MediaRecorder>, public ContextLifecycleObserver { USING_GARBAGE_COLLECTED_MIXIN(MediaRecorder); @@ -78,12 +78,12 @@ // ScriptWrappable bool HasPendingActivity() const final { return !stopped_; } - // WebMediaRecorderHandlerClient + // MediaRecorderHandlerClient void WriteData(const char* data, size_t length, bool last_in_slice, double timecode) override; - void OnError(const WebString& message) override; + void OnError(const String& message) override; void Trace(blink::Visitor* visitor) override;
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc index de7d317..ad9ab68 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.cc
@@ -21,9 +21,9 @@ #include "third_party/blink/public/platform/modules/mediastream/media_stream_audio_track.h" #include "third_party/blink/public/platform/modules/mediastream/web_platform_media_stream_track.h" #include "third_party/blink/public/platform/modules/mediastream/webrtc_uma_histograms.h" -#include "third_party/blink/public/platform/web_media_recorder_handler_client.h" #include "third_party/blink/public/platform/web_media_stream_source.h" #include "third_party/blink/renderer/modules/mediarecorder/buildflags.h" +#include "third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h" #include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" @@ -180,7 +180,7 @@ return true; } -bool MediaRecorderHandler::Initialize(WebMediaRecorderHandlerClient* client, +bool MediaRecorderHandler::Initialize(MediaRecorderHandlerClient* client, const WebMediaStream& media_stream, const String& type, const String& codecs,
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h index 6ed56c8..cc8b605 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h
@@ -31,7 +31,7 @@ struct WebMediaCapabilitiesInfo; struct WebMediaConfiguration; -class WebMediaRecorderHandlerClient; +class MediaRecorderHandlerClient; // MediaRecorderHandler orchestrates the creation, lifetime management and // mapping between: @@ -59,7 +59,7 @@ // encoding." // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods bool CanSupportMimeType(const String& type, const String& web_codecs); - bool Initialize(WebMediaRecorderHandlerClient* client, + bool Initialize(MediaRecorderHandlerClient* client, const WebMediaStream& media_stream, const String& type, const String& codecs, @@ -127,7 +127,7 @@ WebVector<WebMediaStreamTrack> audio_tracks_; // |client_| is a weak pointer, and is valid for the lifetime of this object. - WebMediaRecorderHandlerClient* client_; + MediaRecorderHandlerClient* client_; Vector<std::unique_ptr<VideoTrackRecorder>> video_recorders_; Vector<std::unique_ptr<AudioTrackRecorder>> audio_recorders_;
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h new file mode 100644 index 0000000..9346dcb --- /dev/null +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h
@@ -0,0 +1,27 @@ +// Copyright 2015 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 THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_MEDIA_RECORDER_HANDLER_CLIENT_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_MEDIA_RECORDER_HANDLER_CLIENT_H_ + +namespace WTF { +class String; +} + +namespace blink { + +// Interface used by a MediaRecorder to get errors and recorded data delivered. +class MediaRecorderHandlerClient { + public: + virtual void WriteData(const char* data, + size_t length, + bool last_inslice, + double timecode) = 0; + + virtual void OnError(const String& message) = 0; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIARECORDER_MEDIA_RECORDER_HANDLER_CLIENT_H_
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_unittest.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_unittest.cc index 80a3061..daab2c80 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_unittest.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_unittest.cc
@@ -15,9 +15,9 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h" -#include "third_party/blink/public/platform/web_media_recorder_handler_client.h" #include "third_party/blink/public/web/modules/mediastream/mock_media_stream_registry.h" #include "third_party/blink/renderer/modules/mediarecorder/media_recorder_handler.h" +#include "third_party/blink/renderer/modules/mediarecorder/media_recorder_handler_client.h" #include "third_party/blink/renderer/platform/heap/thread_state.h" #include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" @@ -71,11 +71,11 @@ }; class MediaRecorderHandlerTest : public TestWithParam<MediaRecorderTestParams>, - public blink::WebMediaRecorderHandlerClient { + public MediaRecorderHandlerClient { public: MediaRecorderHandlerTest() : media_recorder_handler_(new MediaRecorderHandler( - blink::scheduler::GetSingleThreadTaskRunnerForTesting())), + scheduler::GetSingleThreadTaskRunnerForTesting())), audio_source_(kTestAudioChannels, 440 /* freq */, kTestAudioSampleRate) { @@ -90,7 +90,7 @@ } MOCK_METHOD4(WriteData, void(const char*, size_t, bool, double)); - MOCK_METHOD1(OnError, void(const WebString& message)); + MOCK_METHOD1(OnError, void(const String& message)); bool recording() const { return media_recorder_handler_->recording_; } bool hasVideoRecorders() const { @@ -135,7 +135,7 @@ ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform_; - blink::MockMediaStreamRegistry registry_; + MockMediaStreamRegistry registry_; // The Class under test. Needs to be scoped_ptr to force its destruction. std::unique_ptr<MediaRecorderHandler> media_recorder_handler_;
diff --git a/third_party/blink/renderer/modules/modules_idl_files.gni b/third_party/blink/renderer/modules/modules_idl_files.gni index 60fa8a5..8916dcb 100644 --- a/third_party/blink/renderer/modules/modules_idl_files.gni +++ b/third_party/blink/renderer/modules/modules_idl_files.gni
@@ -72,6 +72,7 @@ "background_fetch/background_fetch_update_ui_event.idl", "background_sync/sync_event.idl", "background_sync/periodic_sync_event.idl", + "background_sync/periodic_sync_manager.idl", "background_sync/sync_manager.idl", "badging/experimental_badge.idl", "battery/battery_manager.idl", @@ -553,6 +554,7 @@ "background_fetch/background_fetch_event_init.idl", "background_fetch/background_fetch_options.idl", "background_fetch/background_fetch_ui_options.idl", + "background_sync/background_sync_options.idl", "background_sync/sync_event_init.idl", "background_sync/periodic_sync_event_init.idl", "bluetooth/bluetooth_advertising_event_init.idl",
diff --git a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_crypto_config_factory_impl.cc b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_crypto_config_factory_impl.cc index 5f06990..a42741b8 100644 --- a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_crypto_config_factory_impl.cc +++ b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_crypto_config_factory_impl.cc
@@ -5,8 +5,6 @@ #include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" #include "third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_crypto_config_factory_impl.h" namespace blink {
diff --git a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.cc b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.cc index 1bdf4a1e..fa1b7ee5 100644 --- a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.cc +++ b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.cc
@@ -585,11 +585,12 @@ } void P2PQuicTransportImpl::OnConnectionClosed( - quic::QuicErrorCode error, - const std::string& error_details, + const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - quic::QuicSession::OnConnectionClosed(error, error_details, source); + const quic::QuicErrorCode error = frame.quic_error_code; + const std::string& error_details = frame.error_details; + quic::QuicSession::OnConnectionClosed(frame, source); if (error != quic::QuicErrorCode::QUIC_CONNECTION_CANCELLED) { delegate_->OnConnectionFailed( error_details, source == quic::ConnectionCloseSource::FROM_PEER);
diff --git a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.h b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.h index fb5fe633..55d18f3 100644 --- a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.h +++ b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_impl.h
@@ -120,8 +120,7 @@ const quic::ProofVerifyDetails& verify_details) override {} // quic::QuicConnectionVisitorInterface overrides. - void OnConnectionClosed(quic::QuicErrorCode error, - const std::string& error_details, + void OnConnectionClosed(const quic::QuicConnectionCloseFrame& frame, quic::ConnectionCloseSource source) override; bool ShouldKeepConnectionAlive() const override;
diff --git a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_test.cc b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_test.cc index 3a14de1..91714348 100644 --- a/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_test.cc +++ b/third_party/blink/renderer/modules/peerconnection/adapters/p2p_quic_transport_test.cc
@@ -14,8 +14,6 @@ #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" #include "net/third_party/quiche/src/quic/core/quic_server_id.h" #include "net/third_party/quiche/src/quic/core/quic_session.h" -#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h" -#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_span.h" #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h"
diff --git a/third_party/blink/renderer/platform/exported/web_runtime_features.cc b/third_party/blink/renderer/platform/exported/web_runtime_features.cc index e261a81..4176da04 100644 --- a/third_party/blink/renderer/platform/exported/web_runtime_features.cc +++ b/third_party/blink/renderer/platform/exported/web_runtime_features.cc
@@ -39,10 +39,6 @@ RuntimeEnabledFeatures::SetHeapIncrementalMarkingEnabled(enable); } -void WebRuntimeFeatures::EnableBlinkHeapUnifiedGCScheduling(bool enable) { - RuntimeEnabledFeatures::SetHeapUnifiedGCSchedulingEnabled(enable); -} - void WebRuntimeFeatures::EnableBloatedRendererDetection(bool enable) { RuntimeEnabledFeatures::SetBloatedRendererDetectionEnabled(enable); } @@ -699,4 +695,8 @@ RuntimeEnabledFeatures::SetConsolidatedMovementXYEnabled(enable); } +void WebRuntimeFeatures::EnableStreamsNative(bool enable) { + RuntimeEnabledFeatures::SetStreamsNativeEnabled(enable); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/heap/heap_compact.cc b/third_party/blink/renderer/platform/heap/heap_compact.cc index b56d29090..fb48aba2 100644 --- a/third_party/blink/renderer/platform/heap/heap_compact.cc +++ b/third_party/blink/renderer/platform/heap/heap_compact.cc
@@ -265,7 +265,9 @@ MovableReference object = it.first; MovableReference* slot = it.second; // Record name on stack. - const char* name = fixup_names_.find(slot)->second; + auto name_it = fixup_names_.find(slot); + CHECK(fixup_names_.end() != name_it); + const char* name = name_it->second; size_t len = strlen(name); if (len > kMaxNameLen) len = kMaxNameLen; @@ -399,10 +401,11 @@ } void HeapCompact::Initialize(ThreadState* state) { - DCHECK(RuntimeEnabledFeatures::HeapCompactionEnabled()); + CHECK(RuntimeEnabledFeatures::HeapCompactionEnabled()); + CHECK(!do_compact_); + CHECK(!fixups_); LOG_HEAP_COMPACTION() << "Compacting: free=" << free_list_size_; do_compact_ = true; - fixups_.reset(); gc_count_since_last_compaction_ = 0; force_for_next_gc_ = false; }
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index 6aa5944..29f9b8d 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -698,7 +698,7 @@ name: "HeapIncrementalMarkingStress" }, { - name: "HeapUnifiedGCScheduling" + name: "HeapUnifiedGCScheduling", }, { name: "HrefTranslate", @@ -1166,6 +1166,7 @@ { name: "PeriodicBackgroundSync", settable_from_internals: true, + status: "test", }, { name: "PerMethodCanMakePaymentQuota", @@ -1481,6 +1482,7 @@ }, { name: "TextFragmentIdentifiers", + origin_trial_feature_name: "TextFragmentIdentifiers", status: "experimental", }, {
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 6b77f63e..bdc5f84 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -4768,9 +4768,11 @@ crbug.com/716320 external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success-and-failure.html [ Failure Timeout ] crbug.com/716320 external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.html [ Failure Timeout ] +crbug.com/798572 external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel-success.html [ Failure Timeout ] crbug.com/874302 virtual/sharedarraybuffer/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success-and-failure.html [ Timeout ] crbug.com/874302 virtual/sharedarraybuffer/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/broadcastchannel-success.html [ Timeout ] +crbug.com/798572 virtual/sharedarraybuffer/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel-success.html [ Failure Timeout ] crbug.com/874302 external/wpt/wasm/serialization/module/broadcastchannel-success-and-failure.html [ Timeout ] crbug.com/874302 external/wpt/wasm/serialization/module/broadcastchannel-success.html [ Timeout ] @@ -6129,9 +6131,6 @@ crbug.com/974334 [ Mac ] external/wpt/html/cross-origin/usecredentials.tentative.html [ Failure ] # Flaky on Linux -crbug.com/973769 [ Linux ] media/controls/controls-cast-do-not-fade-out.html [ Pass Timeout ] - -# Flaky on Linux crbug.com/974660 [ Linux ] http/tests/devtools/elements/highlight/highlight-node-vertical-rl.js [ Pass Failure ] # Sheriff 2019-06-19 @@ -6148,3 +6147,6 @@ crbug.com/974710 [ Win7 ] http/tests/security/isolatedWorld/bypass-main-world-csp-iframes.html [ Pass Failure ] crbug.com/974710 [ Win7 ] virtual/blink-cors/http/tests/security/isolatedWorld/bypass-main-world-csp-iframes.html [ Pass Failure ] crbug.com/974710 [ Win7 ] virtual/isolated_world_csp/http/tests/security/isolatedWorld/bypass-main-world-csp-iframes.html [ Pass Failure ] + +# Sheriff 2019-06-24 +crbug.com/978000 inspector-protocol/page/setWebLifecycleState.js [ Pass Timeout ]
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json index 0d22592..c6cc45ce8 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json
@@ -59969,6 +59969,18 @@ {} ] ], + "css/css-pseudo/first-letter-list-item-dynamic-001.html": [ + [ + "css/css-pseudo/first-letter-list-item-dynamic-001.html", + [ + [ + "/css/css-pseudo/first-letter-list-item-dynamic-001-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-pseudo/first-letter-opacity-float-001.html": [ [ "css/css-pseudo/first-letter-opacity-float-001.html", @@ -70905,6 +70917,174 @@ {} ] ], + "css/css-text/white-space/pre-wrap-leading-spaces-001.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-001.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-002.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-002.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-003.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-003.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-004.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-004.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-005.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-005.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-006.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-006.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-007.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-007.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-008.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-008.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-009.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-009.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-010.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-010.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-011.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-011.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-012.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-012.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-013.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-013.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/white-space/pre-wrap-leading-spaces-014.html": [ + [ + "css/css-text/white-space/pre-wrap-leading-spaces-014.html", + [ + [ + "/css/css-text/white-space/reference/white-space-break-spaces-005-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-text/white-space/tab-stop-threshold-001.html": [ [ "css/css-text/white-space/tab-stop-threshold-001.html", @@ -138260,6 +138440,9 @@ "css/css-pseudo/first-letter-block-to-inline-ref.html": [ [] ], + "css/css-pseudo/first-letter-list-item-dynamic-001-ref.html": [ + [] + ], "css/css-pseudo/first-letter-opacity-float-001-ref.html": [ [] ], @@ -164087,39 +164270,9 @@ "resources/webidl2/.travis.yml": [ [] ], - "resources/webidl2/CHANGELOG.md": [ - [] - ], - "resources/webidl2/LICENSE": [ - [] - ], - "resources/webidl2/README.md": [ - [] - ], - "resources/webidl2/checker/index.html": [ - [] - ], - "resources/webidl2/coverage.html": [ - [] - ], - "resources/webidl2/index.js": [ - [] - ], "resources/webidl2/lib/webidl2.js": [ [] ], - "resources/webidl2/lib/webidl2.js.headers": [ - [] - ], - "resources/webidl2/lib/writer.js": [ - [] - ], - "resources/webidl2/package-lock.json": [ - [] - ], - "resources/webidl2/package.json": [ - [] - ], "screen-capture/META.yml": [ [] ], @@ -282337,6 +282490,12 @@ {} ] ], + "svg/scripted/script-runs-in-shadow-tree.html": [ + [ + "svg/scripted/script-runs-in-shadow-tree.html", + {} + ] + ], "svg/scripted/text-attrs-dxdy-have-length.svg": [ [ "svg/scripted/text-attrs-dxdy-have-length.svg", @@ -365216,6 +365375,14 @@ "683d2a77662149be28c581c5de6651e776653d65", "testharness" ], + "css/css-pseudo/first-letter-list-item-dynamic-001-ref.html": [ + "26d50ade6259326ee40b99d0cc2739ee77cf2e1f", + "support" + ], + "css/css-pseudo/first-letter-list-item-dynamic-001.html": [ + "f990cd2bb716aafff143f99889d2be61c72b6171", + "reftest" + ], "css/css-pseudo/first-letter-opacity-float-001-ref.html": [ "38c230045bd0cbec0d94da16b27fd56aa58456a1", "support" @@ -375324,6 +375491,62 @@ "af29b0505e0eefbab09b011798c0dd6136598cca", "reftest" ], + "css/css-text/white-space/pre-wrap-leading-spaces-001.html": [ + "6d17921e17c28664533f3e091de9a8075770b544", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-002.html": [ + "082bce78c4ff56dd4b5af1c60a51c04a0df070c2", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-003.html": [ + "2bdef018e72250cd8672ea89fe16cb26971bad7a", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-004.html": [ + "ea409af2ab9da5c6a651f0c937bba5905bcd7b7e", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-005.html": [ + "ccf613051ffa661fc2ba60c563b5fba3d2b09f7d", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-006.html": [ + "cff928c2fd537b4f2db6ed282882c9a14f795452", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-007.html": [ + "ca27b98c2f68940287fc61d4f24709af196ced10", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-008.html": [ + "7331142c2ea0cf56441bd98504610b6ae3150f79", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-009.html": [ + "e2786419c1a56466fc3850fd371bdac45203fdf3", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-010.html": [ + "b1b14ea3afbabbce55996cdcc47a9995a4c5e418", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-011.html": [ + "6167e9ce4538f64baa0a81cd498838be3c759664", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-012.html": [ + "657cd89d89fbbee229ed481d71b73766ff76c0b0", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-013.html": [ + "476f76398daaaa962f09ad5e67f949b529bf8802", + "reftest" + ], + "css/css-text/white-space/pre-wrap-leading-spaces-014.html": [ + "ab2759fdc7b094fa9f4012b557abc27fb6bf8ffd", + "reftest" + ], "css/css-text/white-space/reference/control-chars-000-ref.html": [ "9d5fcb27147a8c53e410d08511cb5035b612f80c", "support" @@ -436165,7 +436388,7 @@ "testharness" ], "lint.whitelist": [ - "9966d7c307b5520ab251d69f231526df762dc4ba", + "ee1e7b5da433cbe81646a03e5c917dad2d07eb56", "support" ], "loading/preloader-css-import-no-quote.tentative.html": [ @@ -460128,50 +460351,10 @@ "6e5919de39a312330fd1abf64237c4b6ad10c56b", "support" ], - "resources/webidl2/CHANGELOG.md": [ - "91e22275e0700e1f553148c7f5414d7ccaf0fe33", - "support" - ], - "resources/webidl2/LICENSE": [ - "fd21d439b09a8d08d1562553e46b9c993c46c103", - "support" - ], - "resources/webidl2/README.md": [ - "9a8f3f8e9c1dfbe897e8a6d8267cf89ec00cb20a", - "support" - ], - "resources/webidl2/checker/index.html": [ - "9897d8572f22a0e66ba6c4704606d94fb66bba59", - "support" - ], - "resources/webidl2/coverage.html": [ - "46e7ed324ec2c832efc2b9af80fa7c9082f68645", - "support" - ], - "resources/webidl2/index.js": [ - "09f9eb46aa78f48692ee3d976dad3a7bb174b148", - "support" - ], "resources/webidl2/lib/webidl2.js": [ "ef519c09df6d6da812fcbba57c7ca0f475af1ed5", "support" ], - "resources/webidl2/lib/webidl2.js.headers": [ - "6805c323df5a975231648b830e33ce183c3cbbd3", - "support" - ], - "resources/webidl2/lib/writer.js": [ - "b3097a6f8a74e4cdeaf71f688ece20423c238a0d", - "support" - ], - "resources/webidl2/package-lock.json": [ - "b0581037fe943423f4f09bceabbef0f8828d6fc3", - "support" - ], - "resources/webidl2/package.json": [ - "92faccafa813fb607f5be73a07cda7f7079d63d5", - "support" - ], "screen-capture/META.yml": [ "47882d3275f1cc928555045b2def8fc90f6bcdb0", "support" @@ -467520,6 +467703,10 @@ "786290a158b99a727bf26c4a30556246d30af8dc", "reftest" ], + "svg/scripted/script-runs-in-shadow-tree.html": [ + "d3a896fb93da55973f31fc574b13a6ad62bd1e94", + "testharness" + ], "svg/scripted/text-attrs-dxdy-have-length.svg": [ "a5f07e29a11ad0279b4645059f50573e76f909cc", "testharness" @@ -478653,7 +478840,7 @@ "support" ], "webrtc-identity/RTCPeerConnection-peerIdentity.https-expected.txt": [ - "36044e3bec02381b5105dfabffe91aabe08d5e1b", + "2fa5f9b57a2a34aed34e34fc55a9a086221ece91", "support" ], "webrtc-identity/RTCPeerConnection-peerIdentity.https.html": [ @@ -481789,19 +481976,19 @@ "reftest" ], "webvtt/rendering/cues-with-video/processing-model/2_tracks-ref.html": [ - "1a46c4d83f8dab463739d1928c4fd87d4975f2bb", + "fa969b1ab08ed393425c38b19b1b1f54a31e341c", "support" ], "webvtt/rendering/cues-with-video/processing-model/2_tracks.html": [ - "f422d73d6d767b4de5f296e9b67eb8072b0e43cc", + "7648d876928dad228e3e84a2afa4a5ab8276773f", "reftest" ], "webvtt/rendering/cues-with-video/processing-model/3_tracks-ref.html": [ - "bec3c0557ca557457f113c95a79cc3132899c373", + "9fc52199fd01b5662e5db2a9a527a446bbe748cd", "support" ], "webvtt/rendering/cues-with-video/processing-model/3_tracks.html": [ - "809e173b46db0f2c3c65a708ad841703602c40f9", + "c0d5c161cb918ee6738199f8b5220861b0401805", "reftest" ], "webvtt/rendering/cues-with-video/processing-model/align_center-ref.html": [
diff --git a/third_party/blink/web_tests/external/wpt/BackgroundSync/periodicsync.https.window.js b/third_party/blink/web_tests/external/wpt/BackgroundSync/periodicsync.https.window.js new file mode 100644 index 0000000..4c8d2eb5 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/BackgroundSync/periodicsync.https.window.js
@@ -0,0 +1,23 @@ +// META: script=/common/get-host-info.sub.js +// META: script=/service-workers/service-worker/resources/test-helpers.sub.js + +'use strict' + +promise_test(async test => { + const script = 'service_workers/sw.js'; + const scope = 'service_workers/' + location.pathname; + + const serviceWorkerRegistration = + await service_worker_unregister_and_register(test, script, scope); + + assert_equals( + serviceWorkerRegistration.active, null, + 'There must not be an activated worker'); + + await promise_rejects( + test, new DOMException('', 'InvalidStateError'), + serviceWorkerRegistration.periodicSync.register( + 'test_tag'), + 'register() must reject on pending and installing workers'); +}, 'Periodic Background Sync requires an activated Service Worker'); +
diff --git a/third_party/blink/web_tests/external/wpt/BackgroundSync/service_workers/sw.js b/third_party/blink/web_tests/external/wpt/BackgroundSync/service_workers/sw.js new file mode 100644 index 0000000..ea2bab2 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/BackgroundSync/service_workers/sw.js
@@ -0,0 +1,20 @@ +// The source to post setup and completion results to. +let source = null; + +function sendMessageToDocument(msg) { + source.postMessage(msg); +} + +// Notify the document that the SW is registered and ready. +self.addEventListener('message', event => { + source = event.source; + sendMessageToDocument('ready'); +}); + +self.addEventListener('sync', event => { + sendMessageToDocument('sync event received!'); +}); + +self.addEventListener('periodicsync', event => { + sendMessageToDocument('periodicsync event received!'); +});
diff --git a/third_party/blink/web_tests/external/wpt/README.md b/third_party/blink/web_tests/external/wpt/README.md index d4d6032d..8f5a2d99 100644 --- a/third_party/blink/web_tests/external/wpt/README.md +++ b/third_party/blink/web_tests/external/wpt/README.md
@@ -46,7 +46,7 @@ And on Windows (this must be run in a PowerShell session with Administrator privileges): -```bash +```powershell python wpt make-hosts-file | Out-File $env:systemroot\System32\drivers\etc\hosts -Encoding ascii -Append ```
diff --git a/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001-ref.html b/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001-ref.html new file mode 100644 index 0000000..26d50ad --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001-ref.html
@@ -0,0 +1,4 @@ +<!doctype html> +<title>CSS Test Reference</title> +<p>The X below should be green.</p> +<div style="color:green">X</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001.html b/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001.html new file mode 100644 index 0000000..f990cd2b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-pseudo/first-letter-list-item-dynamic-001.html
@@ -0,0 +1,24 @@ +<!doctype html> +<title>CSS Test: Move ::first-letter text node (required: list item, float, fixed, contenteditable).</title> +<link rel="match" href="first-letter-list-item-dynamic-001-ref.html"> +<link rel="help" href="https://drafts.csswg.org/css-pseudo/#first-letter-pseudo"> +<link rel="help" href="https://crbug.com/977044"> +<style> + #outer { + display: list-item; + overflow: auto; /* Triggers a crash in Blink see link to issue 977044 */ + } + #outer::first-letter { + float: left; + color: green; + } + #fixed { position: fixed; } + #inner { float: left; } +</style> +<p>The X below should be green.</p> +<div id="outer" contenteditable="true">X<div id="fixed"></div><div id="inner"></div></div> +<script> + document.body.offsetTop; + inner.appendChild(outer.removeChild(outer.firstChild)); + inner.removeAttribute("id"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/incrementer-iframe-messagechannel.html b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/incrementer-iframe-messagechannel.html new file mode 100644 index 0000000..6f3f284a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/incrementer-iframe-messagechannel.html
@@ -0,0 +1,10 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>A test page that messes with a given SharedArrayBuffer via MessageChannel</title> +<script src="test-incrementer.js"></script> + +<script> + const channel = new MessageChannel(); + window.parent.postMessage(channel.port2, '*', [channel.port2]); + setupDestinationIncrementer(channel.port1, channel.port1); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel-success.html b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel-success.html new file mode 100644 index 0000000..9814531 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel-success.html
@@ -0,0 +1,23 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Structured cloning of SharedArrayBuffers into windows using MessageChannel</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#structuredserialize"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/test-incrementer.js"></script> + +<div id="log"></div> + +<script> +promise_test(t => { + return new Promise(resolve => { + const iframe = document.createElement("iframe"); + window.onmessage = t.step_func((message) => { + // data will be a MessagePort + resolve(testSharingViaIncrementerScript(t, message.data, "window", message.data, "iframe")); + }); + iframe.src = "resources/incrementer-iframe-messagechannel.html"; + document.body.appendChild(iframe); + }); +}, "postMessaging to a same-origin iframe via MessageChannel allows them to see each others' modifications"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/resources/idlharness.js b/third_party/blink/web_tests/external/wpt/resources/idlharness.js index c7a0409..cb294c07 100644 --- a/third_party/blink/web_tests/external/wpt/resources/idlharness.js +++ b/third_party/blink/web_tests/external/wpt/resources/idlharness.js
@@ -586,7 +586,7 @@ // sequence types if (type.generic == "sequence" || type.generic == "FrozenArray") { - return this.is_json_type(idlType); + return this.is_json_type(idlType[0]); } if (typeof idlType != "string") { throw new Error("Unexpected type " + JSON.stringify(idlType)); } @@ -694,11 +694,11 @@ result = new Set(result); } if (exposed && exposed.length) { - var set = exposed[0].rhs.value; + const { rhs } = exposed[0]; // Could be a list or a string. - if (typeof set == "string") { - set = [ set ]; - } + const set = rhs.type === "identifier-list" ? + rhs.value.map(id => id.value) : + [ rhs.value ]; result = new Set(set); } if (result && result.has("Worker")) { @@ -984,7 +984,7 @@ // Nothing we can do. return; } - this.assert_type_is(value[0], type.idlType); + this.assert_type_is(value[0], type.idlType[0]); return; } @@ -1004,11 +1004,11 @@ // Nothing we can do. return; } - this.assert_type_is(value[0], type.idlType); + this.assert_type_is(value[0], type.idlType[0]); return; } - type = type.idlType; + type = Array.isArray(type.idlType) ? type.idlType[0] : type.idlType; switch(type) { @@ -1225,7 +1225,7 @@ this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); }); if (this.has_extended_attribute("Unforgeable")) { this.members - .filter(function(m) { return !m["static"] && (m.type == "attribute" || m.type == "operation"); }) + .filter(function(m) { return m.special !== "static" && (m.type == "attribute" || m.type == "operation"); }) .forEach(function(m) { return m.isUnforgeable = true; }); } @@ -1376,7 +1376,7 @@ if (I.has_default_to_json_regular_operation()) { isDefault = true; I.members.forEach(function(m) { - if (!m.static && m.type == "attribute" && I.array.is_json_type(m.idlType)) { + if (m.special !== "static" && m.type == "attribute" && I.array.is_json_type(m.idlType)) { map.set(m.name, m.idlType); } }); @@ -1647,7 +1647,7 @@ } var aliases; if (rhs.type === "identifier-list") { - aliases = rhs.value; + aliases = rhs.value.map(id => id.value); } else { // rhs.type === identifier aliases = [ rhs.value ]; } @@ -2190,7 +2190,7 @@ assert_own_property(this.get_interface_object(), "prototype", 'interface "' + this.name + '" does not have own property "prototype"'); - if (member["static"]) { + if (member.special === "static") { assert_own_property(this.get_interface_object(), member.name, "The interface object must have a property " + format_value(member.name)); @@ -2307,7 +2307,7 @@ var memberHolderObject; // "* If the operation is static, then the property exists on the // interface object." - if (member["static"]) { + if (member.special === "static") { assert_own_property(this.get_interface_object(), member.name, "interface object missing static operation"); memberHolderObject = this.get_interface_object(); @@ -2400,7 +2400,7 @@ // check for globals, since otherwise we'll invoke window.close(). And we // have to skip this test for anything that on the proto chain of "self", // since that does in fact have implicit-this behavior. - if (!member["static"]) { + if (member.special !== "static") { var cb; if (!this.is_global() && memberHolderObject[member.name] != self[member.name]) @@ -2571,7 +2571,7 @@ { this.test_member_attribute(member); } - if (member.stringifier) { + if (member.special === "stringifier") { this.test_member_stringifier(member); } break; @@ -2586,7 +2586,7 @@ { this.test_member_operation(member); } - } else if (member.stringifier) { + } else if (member.special === "stringifier") { this.test_member_stringifier(member); } break; @@ -2756,7 +2756,7 @@ { assert_equals(exception, null, "Unexpected exception when evaluating object"); assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - if (!member["static"]) { + if (member.special !== "static") { if (!this.is_global()) { assert_inherits(obj, member.name); } else { @@ -2806,7 +2806,7 @@ assert_equals(exception, null, "Unexpected exception when evaluating object"); assert_equals(typeof obj, expected_typeof, "wrong typeof object"); var fn; - if (!member["static"]) { + if (member.special !== "static") { if (!this.is_global() && !member.isUnforgeable) { assert_inherits(obj, member.name); } else { @@ -2849,7 +2849,7 @@ // default stringifer return true; } - if (this.members.some(function(member) { return member.stringifier; })) { + if (this.members.some(function(member) { return member.special === "stringifier"; })) { return true; } if (this.base && @@ -2903,7 +2903,7 @@ assert_equals(typeof desc.get, "function", "getter must be Function"); // "If the attribute is a regular attribute, then:" - if (!member["static"]) { + if (member.special !== "static") { // "If O is not a platform object that implements I, then: // "If the attribute was specified with the [LenientThis] extended // attribute, then return undefined. @@ -2953,7 +2953,7 @@ assert_equals(typeof desc.set, "function", "setter must be function for PutForwards, Replaceable, or non-readonly attributes"); // "If the attribute is a regular attribute, then:" - if (!member["static"]) { + if (member.special !== "static") { // "If /validThis/ is false and the attribute was not specified // with the [LenientThis] extended attribute, then throw a // TypeError." @@ -2991,7 +2991,7 @@ * We just forward all properties to this object without modification, * except for special extAttrs handling. */ - for (var k in obj) + for (var k in obj.toJSON()) { this[k] = obj[k]; } @@ -3006,8 +3006,12 @@ IdlInterfaceMember.prototype = Object.create(IdlObject.prototype); +IdlInterfaceMember.prototype.toJSON = function() { + return this; +}; + IdlInterfaceMember.prototype.is_to_json_regular_operation = function() { - return this.type == "operation" && !this.static && this.name == "toJSON"; + return this.type == "operation" && this.special !== "static" && this.name == "toJSON"; }; /// Internal helper functions ///
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/CHANGELOG.md b/third_party/blink/web_tests/external/wpt/resources/webidl2/CHANGELOG.md deleted file mode 100644 index 91e2227..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/CHANGELOG.md +++ /dev/null
@@ -1,292 +0,0 @@ -# Change Log - -## [v10.2.1](https://github.com/w3c/webidl2.js/tree/v10.2.1) (2018-03-09) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.2.0...v10.2.1) - -**Merged pull requests:** - -- Optimise tokenisation and whitespace skipping [\#139](https://github.com/w3c/webidl2.js/pull/139) ([ricea](https://github.com/ricea)) -- refactor: small syntax changes [\#137](https://github.com/w3c/webidl2.js/pull/137) ([saschanaz](https://github.com/saschanaz)) - -## [v10.2.0](https://github.com/w3c/webidl2.js/tree/v10.2.0) (2018-01-30) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.1.0...v10.2.0) - -**Merged pull requests:** - -- Type on union idlType [\#135](https://github.com/w3c/webidl2.js/pull/135) ([saschanaz](https://github.com/saschanaz)) -- feat: add argument/return type [\#134](https://github.com/w3c/webidl2.js/pull/134) ([saschanaz](https://github.com/saschanaz)) -- feat: add dictionary/typedef-type [\#133](https://github.com/w3c/webidl2.js/pull/133) ([saschanaz](https://github.com/saschanaz)) -- feat: add const-type for idlTypes [\#132](https://github.com/w3c/webidl2.js/pull/132) ([saschanaz](https://github.com/saschanaz)) -- feat: add types on idlTypes [\#131](https://github.com/w3c/webidl2.js/pull/131) ([saschanaz](https://github.com/saschanaz)) -- Auto acquisition for parser result changes [\#130](https://github.com/w3c/webidl2.js/pull/130) ([saschanaz](https://github.com/saschanaz)) - -## [v10.1.0](https://github.com/w3c/webidl2.js/tree/v10.1.0) (2018-01-19) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.0.0...v10.1.0) - -**Closed issues:** - -- Support `raises` and `setraises` [\#128](https://github.com/w3c/webidl2.js/issues/128) -- Support `legacycaller` [\#127](https://github.com/w3c/webidl2.js/issues/127) -- Improve "No semicolon after enum" message [\#119](https://github.com/w3c/webidl2.js/issues/119) - -**Merged pull requests:** - -- Let error messages include the current definition name [\#129](https://github.com/w3c/webidl2.js/pull/129) ([saschanaz](https://github.com/saschanaz)) - -## [v10.0.0](https://github.com/w3c/webidl2.js/tree/v10.0.0) (2017-12-20) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v9.0.0...v10.0.0) - -**Closed issues:** - -- Always return an array for idlType, etc. [\#113](https://github.com/w3c/webidl2.js/issues/113) -- Maintain writer.js or not? [\#109](https://github.com/w3c/webidl2.js/issues/109) - -**Merged pull requests:** - -- Remove typeExtAttrs from docs [\#124](https://github.com/w3c/webidl2.js/pull/124) ([saschanaz](https://github.com/saschanaz)) -- Remove iterator documentation [\#123](https://github.com/w3c/webidl2.js/pull/123) ([saschanaz](https://github.com/saschanaz)) -- Maintain writer.js [\#122](https://github.com/w3c/webidl2.js/pull/122) ([saschanaz](https://github.com/saschanaz)) -- BREAKING CHANGE: remove deprecated iterator operation [\#121](https://github.com/w3c/webidl2.js/pull/121) ([saschanaz](https://github.com/saschanaz)) -- Use for-of on tests [\#120](https://github.com/w3c/webidl2.js/pull/120) ([saschanaz](https://github.com/saschanaz)) -- docs\(README\): iterables ildType is always array [\#118](https://github.com/w3c/webidl2.js/pull/118) ([marcoscaceres](https://github.com/marcoscaceres)) - -## [v9.0.0](https://github.com/w3c/webidl2.js/tree/v9.0.0) (2017-11-30) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.1.0...v9.0.0) - -**Closed issues:** - -- Code quality [\#116](https://github.com/w3c/webidl2.js/issues/116) -- Unable to parse HTMLAllCollection interface [\#114](https://github.com/w3c/webidl2.js/issues/114) -- Add support for mixin syntax [\#112](https://github.com/w3c/webidl2.js/issues/112) -- Whitespace issues [\#111](https://github.com/w3c/webidl2.js/issues/111) - -**Merged pull requests:** - -- Consistent array type for iterable.idlType [\#117](https://github.com/w3c/webidl2.js/pull/117) ([saschanaz](https://github.com/saschanaz)) -- Revert "chore: drop Node 6 support \(\#102\)" [\#115](https://github.com/w3c/webidl2.js/pull/115) ([TimothyGu](https://github.com/TimothyGu)) - -## [v8.1.0](https://github.com/w3c/webidl2.js/tree/v8.1.0) (2017-11-03) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.1...v8.1.0) - -**Closed issues:** - -- Extended Attributes `rhs` should always be there [\#96](https://github.com/w3c/webidl2.js/issues/96) - -**Merged pull requests:** - -- Always add rhs property [\#110](https://github.com/w3c/webidl2.js/pull/110) ([saschanaz](https://github.com/saschanaz)) - -## [v8.0.1](https://github.com/w3c/webidl2.js/tree/v8.0.1) (2017-11-03) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.0...v8.0.1) - -**Fixed bugs:** - -- Comment order parsing bug [\#107](https://github.com/w3c/webidl2.js/issues/107) - -**Merged pull requests:** - -- Remove m postfix from all\_ws\(\) [\#108](https://github.com/w3c/webidl2.js/pull/108) ([saschanaz](https://github.com/saschanaz)) - -## [v8.0.0](https://github.com/w3c/webidl2.js/tree/v8.0.0) (2017-11-03) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v7.0.0...v8.0.0) - -**Closed issues:** - -- Remove creators support [\#100](https://github.com/w3c/webidl2.js/issues/100) -- Add mixin support [\#92](https://github.com/w3c/webidl2.js/issues/92) - -**Merged pull requests:** - -- Support mixins + includes statements [\#105](https://github.com/w3c/webidl2.js/pull/105) ([saschanaz](https://github.com/saschanaz)) -- chore: drop Node 6 support [\#102](https://github.com/w3c/webidl2.js/pull/102) ([marcoscaceres](https://github.com/marcoscaceres)) -- BREAKING CHANGE: drop creator support [\#101](https://github.com/w3c/webidl2.js/pull/101) ([saschanaz](https://github.com/saschanaz)) -- Normalize some whitespace to pass wpt's lint [\#99](https://github.com/w3c/webidl2.js/pull/99) ([foolip](https://github.com/foolip)) - -## [v7.0.0](https://github.com/w3c/webidl2.js/tree/v7.0.0) (2017-10-27) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.1.0...v7.0.0) - -**Closed issues:** - -- Type conversion on default values is destructive [\#94](https://github.com/w3c/webidl2.js/issues/94) -- extended attribute structure missing type [\#89](https://github.com/w3c/webidl2.js/issues/89) - -**Merged pull requests:** - -- BREAKING CHANGE: argument + default types should be string [\#95](https://github.com/w3c/webidl2.js/pull/95) ([marcoscaceres](https://github.com/marcoscaceres)) - -## [v6.1.0](https://github.com/w3c/webidl2.js/tree/v6.1.0) (2017-10-23) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.0.1...v6.1.0) - -**Merged pull requests:** - -- feat: give extended attributes a type [\#90](https://github.com/w3c/webidl2.js/pull/90) ([marcoscaceres](https://github.com/marcoscaceres)) - -## [v6.0.1](https://github.com/w3c/webidl2.js/tree/v6.0.1) (2017-10-18) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v6.0.0...v6.0.1) - -**Closed issues:** - -- Enum values should be objects [\#86](https://github.com/w3c/webidl2.js/issues/86) - -**Merged pull requests:** - -- Use ES2015 syntax for tests [\#88](https://github.com/w3c/webidl2.js/pull/88) ([saschanaz](https://github.com/saschanaz)) - -## [v6.0.0](https://github.com/w3c/webidl2.js/tree/v6.0.0) (2017-10-17) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v5.0.0...v6.0.0) - -**Merged pull requests:** - -- BREAKING CHANGE: ret enum value as object [\#87](https://github.com/w3c/webidl2.js/pull/87) ([marcoscaceres](https://github.com/marcoscaceres)) - -## [v5.0.0](https://github.com/w3c/webidl2.js/tree/v5.0.0) (2017-10-17) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.2.0...v5.0.0) - -**Closed issues:** - -- Unable to parse annotated types in generics [\#83](https://github.com/w3c/webidl2.js/issues/83) -- Drop support for Node 4, move to 6 LTS [\#82](https://github.com/w3c/webidl2.js/issues/82) - -**Merged pull requests:** - -- BREAKING CHANGE: Use ES2015 syntax [\#84](https://github.com/w3c/webidl2.js/pull/84) ([saschanaz](https://github.com/saschanaz)) - -## [v4.2.0](https://github.com/w3c/webidl2.js/tree/v4.2.0) (2017-10-16) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.1.0...v4.2.0) - -**Closed issues:** - -- Remove legacy caller support [\#78](https://github.com/w3c/webidl2.js/issues/78) -- Should report error for using duplicate names [\#77](https://github.com/w3c/webidl2.js/issues/77) - -**Merged pull requests:** - -- Check duplicated names [\#80](https://github.com/w3c/webidl2.js/pull/80) ([saschanaz](https://github.com/saschanaz)) -- Remove legacycaller [\#79](https://github.com/w3c/webidl2.js/pull/79) ([saschanaz](https://github.com/saschanaz)) -- Add "sequence" property to IDL Type AST definition [\#76](https://github.com/w3c/webidl2.js/pull/76) ([lerouche](https://github.com/lerouche)) - -## [v4.1.0](https://github.com/w3c/webidl2.js/tree/v4.1.0) (2017-07-04) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.0.0...v4.1.0) - -**Closed issues:** - -- Parsing error for annonated inner types of generic types [\#71](https://github.com/w3c/webidl2.js/issues/71) - -**Merged pull requests:** - -- Support TypeWithExtendedAttributes on generics [\#75](https://github.com/w3c/webidl2.js/pull/75) ([saschanaz](https://github.com/saschanaz)) - -## [v4.0.0](https://github.com/w3c/webidl2.js/tree/v4.0.0) (2017-06-27) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.2...v4.0.0) - -**Closed issues:** - -- Remove serializer-related productions [\#73](https://github.com/w3c/webidl2.js/issues/73) -- Records don't seem to be working right [\#72](https://github.com/w3c/webidl2.js/issues/72) -- Document namespace member output [\#59](https://github.com/w3c/webidl2.js/issues/59) - -**Merged pull requests:** - -- BREAKING CHANGE: remove serializers \(closes \#73\) [\#74](https://github.com/w3c/webidl2.js/pull/74) ([marcoscaceres](https://github.com/marcoscaceres)) -- Add documentation for namespaces [\#70](https://github.com/w3c/webidl2.js/pull/70) ([saschanaz](https://github.com/saschanaz)) - -## [v3.0.2](https://github.com/w3c/webidl2.js/tree/v3.0.2) (2017-05-29) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.1...v3.0.2) - -**Closed issues:** - -- Whitespace issues [\#64](https://github.com/w3c/webidl2.js/issues/64) - -**Merged pull requests:** - -- Test for latest LTS/stable node versions [\#69](https://github.com/w3c/webidl2.js/pull/69) ([saschanaz](https://github.com/saschanaz)) - -## [v3.0.1](https://github.com/w3c/webidl2.js/tree/v3.0.1) (2017-05-18) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.4.0...v3.0.1) - -**Closed issues:** - -- Is array syntax dead? [\#66](https://github.com/w3c/webidl2.js/issues/66) -- Remove exceptions support [\#65](https://github.com/w3c/webidl2.js/issues/65) - -**Merged pull requests:** - -- Fix whitespace error on parsing extended attributes [\#68](https://github.com/w3c/webidl2.js/pull/68) ([saschanaz](https://github.com/saschanaz)) -- Remove deprecated IDL arrays and exceptions [\#67](https://github.com/w3c/webidl2.js/pull/67) ([saschanaz](https://github.com/saschanaz)) - -## [v2.4.0](https://github.com/w3c/webidl2.js/tree/v2.4.0) (2017-04-12) -[Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.1.0...v2.4.0) - -**Closed issues:** - -- Add support for Annotated Types [\#60](https://github.com/w3c/webidl2.js/issues/60) -- Question: Convert WebIDL -\> Javascript [\#56](https://github.com/w3c/webidl2.js/issues/56) -- Get Robin to give us push permissions on npm [\#54](https://github.com/w3c/webidl2.js/issues/54) -- Add support for records [\#53](https://github.com/w3c/webidl2.js/issues/53) -- module not supported? [\#52](https://github.com/w3c/webidl2.js/issues/52) -- Add support for namespaces [\#51](https://github.com/w3c/webidl2.js/issues/51) -- Export is not AMD compatible [\#48](https://github.com/w3c/webidl2.js/issues/48) -- Can't represent large constants [\#21](https://github.com/w3c/webidl2.js/issues/21) - -**Merged pull requests:** - -- Update webidl2.js [\#63](https://github.com/w3c/webidl2.js/pull/63) ([tqeto](https://github.com/tqeto)) -- Remove support for MapClass \(no longer valid in WebIDL\) [\#62](https://github.com/w3c/webidl2.js/pull/62) ([dontcallmedom](https://github.com/dontcallmedom)) -- Add support for annotated types [\#61](https://github.com/w3c/webidl2.js/pull/61) ([dontcallmedom](https://github.com/dontcallmedom)) -- Support namespaces [\#58](https://github.com/w3c/webidl2.js/pull/58) ([saschanaz](https://github.com/saschanaz)) -- Add support for records [\#57](https://github.com/w3c/webidl2.js/pull/57) ([TimothyGu](https://github.com/TimothyGu)) -- Refactor [\#50](https://github.com/w3c/webidl2.js/pull/50) ([marcoscaceres](https://github.com/marcoscaceres)) -- feat\(lib\): add AMD export support \(closes \#48\) [\#49](https://github.com/w3c/webidl2.js/pull/49) ([marcoscaceres](https://github.com/marcoscaceres)) - -## [v2.1.0](https://github.com/w3c/webidl2.js/tree/v2.1.0) (2016-08-12) -**Closed issues:** - -- Exception when parsing test/syntax/idl/typedef.widl [\#46](https://github.com/w3c/webidl2.js/issues/46) -- Wrong jsondiffpatch location [\#42](https://github.com/w3c/webidl2.js/issues/42) -- 'npm install' fails on building microtime [\#40](https://github.com/w3c/webidl2.js/issues/40) -- Can't represent union types in typedefs [\#38](https://github.com/w3c/webidl2.js/issues/38) -- tokenise\(\) assumes a specific property enumeration order [\#27](https://github.com/w3c/webidl2.js/issues/27) -- Add support for iterable\<\>, maplike\<\>, setlike\<\> declarations [\#24](https://github.com/w3c/webidl2.js/issues/24) -- WebIDL2 fails to parse `attribute Promise\<DOMString\>\[\] baz` [\#19](https://github.com/w3c/webidl2.js/issues/19) -- Support for ExtendedAttributeIdentList \(current editor's draft\) [\#18](https://github.com/w3c/webidl2.js/issues/18) -- No Licensing Information [\#17](https://github.com/w3c/webidl2.js/issues/17) -- how to regenerate w3c idl files ? [\#14](https://github.com/w3c/webidl2.js/issues/14) -- What is lib/writer.js [\#13](https://github.com/w3c/webidl2.js/issues/13) -- Numerous tests are failing [\#7](https://github.com/w3c/webidl2.js/issues/7) -- Add support for missing types in ServiceWorker [\#5](https://github.com/w3c/webidl2.js/issues/5) -- How can I parse just a function? [\#3](https://github.com/w3c/webidl2.js/issues/3) -- Parser throws on nullable array of nullable array [\#2](https://github.com/w3c/webidl2.js/issues/2) -- Parser throws on nullable array of any [\#1](https://github.com/w3c/webidl2.js/issues/1) - -**Merged pull requests:** - -- Fix "default": undefined [\#47](https://github.com/w3c/webidl2.js/pull/47) ([mkwtys](https://github.com/mkwtys)) -- Replace expect.js with expct [\#45](https://github.com/w3c/webidl2.js/pull/45) ([halton](https://github.com/halton)) -- Correct jsondiffpatch location. [\#44](https://github.com/w3c/webidl2.js/pull/44) ([halton](https://github.com/halton)) -- Bump microtime to 2.1.1 [\#43](https://github.com/w3c/webidl2.js/pull/43) ([halton](https://github.com/halton)) -- Expand writer support [\#39](https://github.com/w3c/webidl2.js/pull/39) ([markandrus](https://github.com/markandrus)) -- Accept wider \(but still incomplete\) set of allowed syntax for extended attributes [\#37](https://github.com/w3c/webidl2.js/pull/37) ([mlogan](https://github.com/mlogan)) -- Add test for callback with multiple arguments. [\#36](https://github.com/w3c/webidl2.js/pull/36) ([tobie](https://github.com/tobie)) -- Iterables [\#34](https://github.com/w3c/webidl2.js/pull/34) ([motiz88](https://github.com/motiz88)) -- Allow trailing comma in enum value lists, per spec [\#33](https://github.com/w3c/webidl2.js/pull/33) ([motiz88](https://github.com/motiz88)) -- Allow typedefs within interfaces \(behind an opt-in flag\) [\#32](https://github.com/w3c/webidl2.js/pull/32) ([motiz88](https://github.com/motiz88)) -- In draft [\#31](https://github.com/w3c/webidl2.js/pull/31) ([othree](https://github.com/othree)) -- Add support for extended attributes identifier lists [\#29](https://github.com/w3c/webidl2.js/pull/29) ([tobie](https://github.com/tobie)) -- Make `attribute Promise\<T\>\[\] attr;` work. [\#26](https://github.com/w3c/webidl2.js/pull/26) ([jyasskin](https://github.com/jyasskin)) -- Parse required dictionary fields. [\#25](https://github.com/w3c/webidl2.js/pull/25) ([jyasskin](https://github.com/jyasskin)) -- Define the WebIDL2 property on self rather than window. [\#23](https://github.com/w3c/webidl2.js/pull/23) ([Ms2ger](https://github.com/Ms2ger)) -- Teach WebIDL2 to parse \[\] default values. [\#22](https://github.com/w3c/webidl2.js/pull/22) ([jyasskin](https://github.com/jyasskin)) -- Support ID list in extended attributes [\#20](https://github.com/w3c/webidl2.js/pull/20) ([othree](https://github.com/othree)) -- Make sure that `sequence` property of idl types is set to false if the type is actually `sequence`. [\#16](https://github.com/w3c/webidl2.js/pull/16) ([tobie](https://github.com/tobie)) -- Parametrized [\#15](https://github.com/w3c/webidl2.js/pull/15) ([tobie](https://github.com/tobie)) -- Add promise support [\#12](https://github.com/w3c/webidl2.js/pull/12) ([tobie](https://github.com/tobie)) -- Remove broken coverage support from travis for now. [\#11](https://github.com/w3c/webidl2.js/pull/11) ([tobie](https://github.com/tobie)) -- Add support for \[MapClass\(type, type\)\]. [\#10](https://github.com/w3c/webidl2.js/pull/10) ([tobie](https://github.com/tobie)) -- Incorporate tests from widlproc\[1\] and remove dependency on said project. [\#9](https://github.com/w3c/webidl2.js/pull/9) ([tobie](https://github.com/tobie)) -- README incorrectly recommended updating the widlproc submodule. [\#8](https://github.com/w3c/webidl2.js/pull/8) ([tobie](https://github.com/tobie)) -- Fix bug where instrumented version of webidl2 was loaded. [\#6](https://github.com/w3c/webidl2.js/pull/6) ([tobie](https://github.com/tobie)) -- Use https:// instead of git:// [\#4](https://github.com/w3c/webidl2.js/pull/4) ([Manishearth](https://github.com/Manishearth)) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/LICENSE b/third_party/blink/web_tests/external/wpt/resources/webidl2/LICENSE deleted file mode 100644 index fd21d43..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/LICENSE +++ /dev/null
@@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Robin Berjon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/README.md b/third_party/blink/web_tests/external/wpt/resources/webidl2/README.md deleted file mode 100644 index 9a8f3f8..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/README.md +++ /dev/null
@@ -1,629 +0,0 @@ - -# WebIDL 2 - -[](http://badge.fury.io/js/webidl2) - -## Purpose - -This is a parser for the [WebIDL](http://dev.w3.org/2006/webapi/WebIDL/) language. If -you don't know what that is, then you probably don't need it. It is meant to be used -both in Node and in the browser (the parser likely works in other JS environments, but -not the test suite). - -## Installation - -Just the usual. For Node: - -```Bash -npm install webidl2 -``` - -In the browser: - -```HTML -<script src='webidl2.js'></script> -``` - -## Documentation - -The API to WebIDL2 is trivial: you parse a string of WebIDL and it returns a syntax tree. - -### Parsing - -In Node, that happens with: - -```JS -var WebIDL2 = require("webidl2"); -var tree = WebIDL2.parse("string of WebIDL"); -``` - -In the browser: -```HTML -<script src='webidl2.js'></script> -<script> - var tree = WebIDL2.parse("string of WebIDL"); -</script> -``` - -### Errors - -When there is a syntax error in the WebIDL, it throws an exception object with the following -properties: - -* `message`: the error message -* `line`: the line at which the error occurred. -* `input`: a short peek at the text at the point where the error happened -* `tokens`: the five tokens at the point of error, as understood by the tokeniser - (this is the same content as `input`, but seen from the tokeniser's point of view) - -The exception also has a `toString()` method that hopefully should produce a decent -error message. - -### AST (Abstract Syntax Tree) - -The `parse()` method returns a tree object representing the parse tree of the IDL. -Comment and white space are not represented in the AST. - -The root of this object is always an array of definitions (where definitions are -any of interfaces, dictionaries, callbacks, etc. — anything that can occur at the root -of the IDL). - -### IDL Type - -This structure is used in many other places (operation return types, argument types, etc.). -It captures a WebIDL type with a number of options. Types look like this and are typically -attached to a field called `idlType`: - -```JS -{ - "type": "attribute-type", - "generic": null, - "idlType": "unsigned short", - "nullable": false, - "union": false, - "extAttrs": [...] -} -``` - -Where the fields are as follows: - -* `type`: String indicating where this type is used. Can be `null` if not applicable. -* `generic`: String indicating the generic type (e.g. "Promise", "sequence"). `null` - otherwise. -* `idlType`: Can be different things depending on context. In most cases, this will just - be a string with the type name. But the reason this field isn't called "typeName" is - because it can take more complex values. If the type is a union, then this contains an - array of the types it unites. If it is a generic type, it contains the IDL type - description for the type in the sequence, the eventual value of the promise, etc. -* `nullable`: Boolean indicating whether this is nullable or not. -* `union`: Boolean indicating whether this is a union type or not. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Interface - -Interfaces look like this: - -```JS -{ - "type": "interface", - "name": "Animal", - "partial": false, - "members": [...], - "inheritance": null, - "extAttrs": [...] -}, { - "type": "interface", - "name": "Human", - "partial": false, - "members": [...], - "inheritance": "Animal", - "extAttrs": [...] -} -``` - -The fields are as follows: - -* `type`: Always "interface". -* `name`: The name of the interface. -* `partial`: A boolean indicating whether it's a partial interface. -* `members`: An array of interface members (attributes, operations, etc.). Empty if there are none. -* `inheritance`: A string giving the name of an interface this one inherits from, `null` otherwise. - **NOTE**: In v1 this was an array, but multiple inheritance is no longer supported so this didn't make - sense. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Interface mixins - -Interfaces mixins look like this: - -```JS -{ - "type": "interface mixin", - "name": "Animal", - "partial": false, - "members": [...], - "extAttrs": [...] -}, { - "type": "interface mixin", - "name": "Human", - "partial": false, - "members": [...], - "extAttrs": [...] -} -``` - -The fields are as follows: - -* `type`: Always "interface mixin". -* `name`: The name of the interface mixin. -* `partial`: A boolean indicating whether it's a partial interface mixin. -* `members`: An array of interface members (attributes, operations, etc.). Empty if there are none. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Namespace - -Namespaces look like this: - -```JS -{ - "type": "namespace", - "name": "Console", - "partial": false, - "members": [...], - "extAttrs": [...] -} -``` - -The fields are as follows: - -* `type`: Always "namespace". -* `name`: The name of the namespace. -* `partial`: A boolean indicating whether it's a partial namespace. -* `members`: An array of namespace members (attributes and operations). Empty if there are none. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Callback Interfaces - -These are captured by the same structure as [Interfaces](#interface) except that -their `type` field is "callback interface". - -### Callback - -A callback looks like this: - -```JS -{ - "type": "callback", - "name": "AsyncOperationCallback", - "idlType": { - "type": "return-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "void", - "extAttrs": [] - }, - "arguments": [...], - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "callback". -* `name`: The name of the callback. -* `idlType`: An [IDL Type](#idl-type) describing what the callback returns. -* `arguments`: A list of [arguments](#arguments), as in function paramters. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Dictionary - -A dictionary looks like this: - -```JS -{ - "type": "dictionary", - "name": "PaintOptions", - "partial": false, - "members": [{ - "type": "field", - "name": "fillPattern", - "required": false, - "idlType": { - "type": "dictionary-type", - "sequence": false, - "generic": null, - "nullable": true, - "union": false, - "idlType": "DOMString", - "extAttrs": [...] - }, - "extAttrs": [], - "default": { - "type": "string", - "value": "black" - } - }], - "inheritance": null, - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "dictionary". -* `name`: The dictionary name. -* `partial`: Boolean indicating whether it's a partial dictionary. -* `members`: An array of members (see below). -* `inheritance`: A string indicating which dictionary is being inherited from, `null` otherwise. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -All the members are fields as follows: - -* `type`: Always "field". -* `name`: The name of the field. -* `required`: Boolean indicating whether this is a [required](https://heycam.github.io/webidl/#required-dictionary-member) field. -* `idlType`: An [IDL Type](#idl-type) describing what field's type. -* `extAttrs`: A list of [extended attributes](#extended-attributes). -* `default`: A [default value](#default-and-const-values), absent if there is none. - -### Enum - -An enum looks like this: - -```JS -{ - "type": "enum", - "name": "MealType", - "values": [ - { "type": "string", "value": "rice" }, - { "type": "string", "value": "noodles" }, - { "type": "string", "value": "other" } - ], - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "enum". -* `name`: The enum's name. -* `values`: An array of values. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Typedef - -A typedef looks like this: - -```JS -{ - "type": "typedef", - "idlType": { - "type": "typedef-type", - "sequence": true, - "generic": "sequence", - "nullable": false, - "union": false, - "idlType": { - "type": "typedef-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "Point", - "extAttrs": [...] - }, - "extAttrs": [...] - }, - "name": "PointSequence", - "extAttrs": [] -} -``` - - -The fields are as follows: - -* `type`: Always "typedef". -* `name`: The typedef's name. -* `idlType`: An [IDL Type](#idl-type) describing what typedef's type. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Implements - -An implements definition looks like this: - -```JS -{ - "type": "implements", - "target": "Node", - "implements": "EventTarget", - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "implements". -* `target`: The interface that implements another. -* `implements`: The interface that is being implemented by the target. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Includes - -An includes definition looks like this: - -```JS -{ - "type": "includes", - "target": "Node", - "includes": "EventTarget", - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "includes". -* `target`: The interface that includes an interface mixin. -* `includes`: The interface mixin that is being included by the target. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Operation Member - -An operation looks like this: -```JS -{ - "type": "operation", - "getter": false, - "setter": false, - "deleter": false, - "static": false, - "stringifier": false, - "idlType": { - "type": "return-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "void", - "extAttrs": [] - }, - "name": "intersection", - "arguments": [{ - "optional": false, - "variadic": true, - "extAttrs": [], - "idlType": { - "type": "argument-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long", - "extAttrs": [...] - }, - "name": "ints" - }], - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "operation". -* `getter`: True if a getter operation. -* `setter`: True if a setter operation. -* `deleter`: True if a deleter operation. -* `static`: True if a static operation. -* `stringifier`: True if a stringifier operation. -* `idlType`: An [IDL Type](#idl-type) of what the operation returns. If a stringifier, may be absent. -* `name`: The name of the operation. If a stringifier, may be `null`. -* `arguments`: An array of [arguments](#arguments) for the operation. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Attribute Member - -An attribute member looks like this: - -```JS -{ - "type": "attribute", - "static": false, - "stringifier": false, - "inherit": false, - "readonly": false, - "idlType": { - "type": "attribute-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "RegExp", - "extAttrs": [...] - }, - "name": "regexp", - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "attribute". -* `name`: The attribute's name. -* `static`: True if it's a static attribute. -* `stringifier`: True if it's a stringifier attribute. -* `inherit`: True if it's an inherit attribute. -* `readonly`: True if it's a read-only attribute. -* `idlType`: An [IDL Type](#idl-type) for the attribute. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Constant Member - -A constant member looks like this: - -```JS -{ - "type": "const", - "nullable": false, - "idlType": { - "type": "const-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "boolean" - "extAttrs": [] - }, - "name": "DEBUG", - "value": { - "type": "boolean", - "value": false - }, - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always "const". -* `nullable`: Whether its type is nullable. -* `idlType`: An [IDL Type](#idl-type) of the constant that represents a simple type, the type name. -* `name`: The name of the constant. -* `value`: The constant value as described by [Const Values](#default-and-const-values) -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Arguments - -The arguments (e.g. for an operation) look like this: - -```JS -{ - "arguments": [{ - "optional": false, - "variadic": true, - "extAttrs": [], - "idlType": { - "type": "argument-type", - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long", - "extAttrs": [...] - }, - "name": "ints" - }] -} -``` - -The fields are as follows: - -* `optional`: True if the argument is optional. -* `variadic`: True if the argument is variadic. -* `idlType`: An [IDL Type](#idl-type) describing the type of the argument. -* `name`: The argument's name. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - -### Extended Attributes - -Extended attributes are arrays of items that look like this: - -```JS -{ - "extAttrs": [{ - "name": "TreatNullAs", - "arguments": null, - "type": "extended-attribute", - "rhs": { - "type": "identifier", - "value": "EmptyString" - } - }] -} -``` - -The fields are as follows: - -* `name`: The extended attribute's name. -* `arguments`: If the extended attribute takes arguments (e.g. `[Foo()]`) or if - its right-hand side does (e.g. `[NamedConstructor=Name(DOMString blah)]`) they - are listed here. Note that an empty arguments list will produce an empty array, - whereas the lack thereof will yield a `null`. If there is an `rhs` field then - they are the right-hand side's arguments, otherwise they apply to the extended - attribute directly. -* `type`: Always `"extended-attribute"`. -* `rhs`: If there is a right-hand side, this will capture its `type` (which can be - "identifier" or "identifier-list") and its `value`. - -### Default and Const Values - -Dictionary fields and operation arguments can take default values, and constants take -values, all of which have the following fields: - -* `type`: One of string, number, boolean, null, Infinity, NaN, or sequence. - -For string, number, boolean, and sequence: - -* `value`: The value of the given type, as a string. For sequence, the only possible value is `[]`. - -For Infinity: - -* `negative`: Boolean indicating whether this is negative Infinity or not. - -### `iterable<>`, `legacyiterable<>`, `maplike<>`, `setlike<>` declarations - -These appear as members of interfaces that look like this: - -```JS -{ - "type": "maplike", // or "legacyiterable" / "iterable" / "setlike" - "idlType": /* One or two types */ , - "readonly": false, // only for maplike and setlike - "extAttrs": [] -} -``` - -The fields are as follows: - -* `type`: Always one of "iterable", "legacyiterable", "maplike" or "setlike". -* `idlType`: An array with one or more [IDL Types](#idl-type) representing the declared type arguments. -* `readonly`: Whether the maplike or setlike is declared as read only. -* `extAttrs`: A list of [extended attributes](#extended-attributes). - - -## Testing - -### Running - -The test runs with mocha and expect.js. Normally, running mocha in the root directory -should be enough once you're set up. - -### Coverage - -Current test coverage, as documented in `coverage.html`, is 95%. You can run your own -coverage analysis with: - -```Bash -jscoverage lib lib-cov -``` - -That will create the lib-cov directory with instrumented code; the test suite knows -to use that if needed. You can then run the tests with: - -```Bash -JSCOV=1 mocha --reporter html-cov > coverage.html -``` - -Note that I've been getting weirdly overescaped results from the html-cov reporter, -so you might wish to try this instead: - -```Bash -JSCOV=1 mocha --reporter html-cov | sed "s/</</g" | sed "s/>/>/g" | sed "s/"/\"/g" > coverage.html -``` -### Browser tests - -In order to test in the browser, get inside `test/web` and run `make-web-tests.js`. This -will generate a `browser-tests.html` file that you can open in a browser. As of this -writing tests pass in the latest Firefox, Chrome, Opera, and Safari. Testing on IE -and older versions will happen progressively.
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/checker/index.html b/third_party/blink/web_tests/external/wpt/resources/webidl2/checker/index.html deleted file mode 100644 index 9897d8572..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/checker/index.html +++ /dev/null
@@ -1,55 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -<title>WebIDL 2 Checker</title> - -<script src='../lib/webidl2.js'></script> -<script> -let parserResult = undefined; - -function formatParserOutput() { - const outputEl = document.getElementById('webidl-checker-output'); - if (parserResult) { - const prettyPrintEl = document.getElementById('pretty-print'); - outputEl.innerText = JSON.stringify(parserResult, null, prettyPrintEl.checked ? 2 : null); - } else { - outputEl.innerText = ''; - } -} - -function checkWebIDL(textToCheck) { - const validation = document.getElementById('webidl-checker-validation'); - parserResult = null; - try { - parserResult = WebIDL2.parse(textToCheck); - validation.innerText = 'WebIDL parsed successfully!'; - } catch (e) { - validation.innerText = 'Exception while parsing WebIDL. See JavaScript console for more details.\n\n' + e.toString(); - // Pass it along to the JavaScript console. - throw e; - } finally { - formatParserOutput(); - } -} -</script> -<style> -textarea { - font-family: monospace; -} -</style> -</head> -<body> -<h2>WebIDL Checker</h2> -<p>This is an online checker for WebIDL built on the <a href="https://github.com/w3c/webidl2.js">webidl2.js</a> project.</p> -<p>Enter your WebIDL to check below:</p> -<textarea id='webidl-to-check' rows='20' cols='80'></textarea> -<br> -<input type='button' value='Check WebIDL' onclick='checkWebIDL(document.getElementById("webidl-to-check").value)'> -<p>Validation results:</p> -<textarea id='webidl-checker-validation' rows='20' cols='80'></textarea> -<p>Parser output:</p> -<textarea id='webidl-checker-output' rows='20' cols='80'></textarea> -<br> -<input type='checkbox' id='pretty-print' checked='true' onchange='formatParserOutput()'>Pretty Print -</body> -</html>
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/coverage.html b/third_party/blink/web_tests/external/wpt/resources/webidl2/coverage.html deleted file mode 100644 index 46e7ed3..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/coverage.html +++ /dev/null
@@ -1,341 +0,0 @@ -<!DOCTYPE html><html><head><title>Coverage</title><script> - -headings = []; - -onload = function(){ - headings = document.querySelectorAll('h2'); -}; - -onscroll = function(e){ - var heading = find(window.scrollY); - if (!heading) return; - var links = document.querySelectorAll('#menu a') - , link; - - for (var i = 0, len = links.length; i < len; ++i) { - link = links[i]; - link.className = link.getAttribute('href') == '#' + heading.id - ? 'active' - : ''; - } -}; - -function find(y) { - var i = headings.length - , heading; - - while (i--) { - heading = headings[i]; - if (y >= heading.offsetTop) { - return heading; - } - } -} -</script> -<style> - -body { - font: 14px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif; - margin: 0; - color: #2C2C2C; - border-top: 2px solid #ddd; -} - -#coverage { - padding: 60px; -} - -h1 a { - color: inherit; - font-weight: inherit; -} - -h1 a:hover { - text-decoration: none; -} - -.onload h1 { - opacity: 1; -} - -h2 { - width: 80%; - margin-top: 80px; - margin-bottom: 0; - font-weight: 100; - letter-spacing: 1px; - border-bottom: 1px solid #eee; -} - -a { - color: #8A6343; - font-weight: bold; - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -ul { - margin-top: 20px; - padding: 0 15px; - width: 100%; -} - -ul li { - float: left; - width: 40%; - margin-top: 5px; - margin-right: 60px; - list-style: none; - border-bottom: 1px solid #eee; - padding: 5px 0; - font-size: 12px; -} - -ul::after { - content: '.'; - height: 0; - display: block; - visibility: hidden; - clear: both; -} - -code { - font: 12px monaco, monospace; -} - -pre { - margin: 30px; - padding: 30px; - border: 1px solid #eee; - border-bottom-color: #ddd; - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - -webkit-box-shadow: inset 0 0 10px #eee; - -moz-box-shadow: inset 0 0 10px #eee; - overflow-x: auto; -} - -img { - margin: 30px; - padding: 1px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - -webkit-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888; - -moz-box-shadow: 0 3px 10px #dedede, 0 1px 5px #888; - max-width: 100%; -} - -footer { - background: #eee; - width: 100%; - padding: 50px 0; - text-align: right; - border-top: 1px solid #ddd; -} - -footer span { - display: block; - margin-right: 30px; - color: #888; - font-size: 12px; -} - -#menu { - position: fixed; - font-size: 12px; - overflow-y: auto; - top: 0; - right: 0; - margin: 0; - height: 100%; - padding: 15px 0; - text-align: right; - border-left: 1px solid #eee; - -moz-box-shadow: 0 0 2px #888 - , inset 5px 0 20px rgba(0,0,0,.5) - , inset 5px 0 3px rgba(0,0,0,.3); - -webkit-box-shadow: 0 0 2px #888 - , inset 5px 0 20px rgba(0,0,0,.5) - , inset 5px 0 3px rgba(0,0,0,.3); - -webkit-font-smoothing: antialiased; - background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAABelBMVEUjJSU6OzshIyM5OjoqKy02NjgsLS01NTYjJCUzNTUgISMlJSc0NTUvMDA6PDwlJyg1NjYoKis2NjYrLS02ODkpKyw0NDYrLC04ODovLzA4Ojo0NDUtLy86OjwjIyU4OTosLS82ODgtLS8hIyQvMTEnKCooKSsrKy0qLCwkJSUnKCkrLCwpKiwwMjIxMzMqLC0tLS0pKissLC00NTYwMDIwMTQpKysoKSovMDEtLzA2OTkxMzUrKywvLy8qKyszNTY5OzsqKiw6OjswMDExNDUoKiozNDUvMDIyNDY1Njg2Njk5OTozMzU0NjY4ODkiIyUiIyQ4OTkuMDEmKCowMjQwMTErLS4qKywwMTMhIiMpKiopKy0tLjAkJScxNDQvLzExNDYyNDQmKCk5OTslJig5OjskJSYxMzQrLS8gISIwMTIoKCk1NTUlJSUnJygwMDA4ODgiIiMhISI8PDw6Ojo5OTkpKSojIyQ7OzsyMjIpKSssLCw6Ozw1NjlrfLakAAAg2UlEQVR42jR6i3ea6rYvPgANIAhVXh8WvkQlioUiFlFcBtAmoiRNdzxqu9p0J7vrdK29zuPeex77nnvO/35n1r1ndHRktI0jTOacv/l7lCBK5UqVpOha/YxmWK7BC4TQFKVXrbYsnimqxuuMVlOQ0XltWjUdCwRJ1M+tC1KudOs9q6+da2adUewG0SC0SwELfHtgDds93VEuydEbl3QMWeNoYkR7b/0x1ZRobGI3mLwzAhePqTAwhg6aogjNsGy7/jwQ4rkdqe7CWLxF8k9LfMVFyRS7VJqtkrW8Vt/bkR8FZJao16ipknbC3Yw2lM7laO6HBEOadEZ2tpf65c4v8e3u7FyU6qbiNNyCuzXZ6pawgnwgmrpTT/Q7w2EZmiIJ0dzWDI7mhQ80IfRnMu2kzA5r5r1pIFoia+/d93HRYp1GV8TbrkWoU/+jdI0Ff6yGwTjT1Hn8J+8m1rKpGiYPuNiHnMtNMIv+zpsk84MYTNW1/+DpwXLvckdOCMYowVNPREe0QlM8xRHXXFhcNDzupwsSmb5pH+0t0RP2Qk+QtI7F1Qm6JRC6ZPBtPq/dq/kH+jxtCljn9TIpW6rQIgmSVyj6lPICIw4N/taka41PFUInth0je9+jO6Kt1G4/a7V2LEgG02B0pHVuCZrgltSKMuIl5SyufUv9mYuQi+mFgzbBEtFo2g+Dh4sSTrLNu8JPh00sQydpb00tqXBvqRN7Q7kqzcnIxCGnvZt/WmJacoOEO6Dcn8Qre03pOCSQxbMOXUuDNx9SxuLz4W1I18gvjViQ67zV0rxdWL8Te/TQkuo8STS41DR48W7L6YP2uWIqiUV8rd6Gbf/rnegKZeG8TpAM6afhGze9JAOxbLjsnUXEbrZ9vLYd7MT32cPF5mKKxmjy7huaoD9n62GOxni3iIJwv0IzZAZjdZkUtolCNLVfYZNaquFjGszVVf+J0vrz4CawoKdHnOzb0NMH7CDBOybfYNJ4rfeMyFNjkFYVTzMFs87rnPGXLUOeNKRVc0LnU7/UIgelzsy3CMuth0YfvnY0wsD3vODUL3eJcKqHQpm8yM3XZQWJxO6Un9iYloyyLpOwN2obHy6W6gbpcb44XmyC+mg+itAcaprGcrwZCqMj/GmtKn0zPvpTz/Cv1dw21XwP3cRupg3H3MF/S71eTKj1YrdwKdc2Mw0fRmb2sFf8lW3aU6JbIZSEPqvXvjM7G/aApyXlXeqKfMq0g/Su3rUGJPSPrtGElgknrZM3xUXqsAP6zMCNVn5u8aJnSNpJv2uru7t2jfRziW2+GuhqfldUNbPk71olwo+46ePUo1U3WKk/e5YK07F/wGRgcpODmQnIlVeHCWBE4puBi2jq28UKpqiN1/4UOrGz59TNYrrQHtd+11sG40BGD+pXdelNqGOg4NXe8W4eacJV/NS9/2Umtym6WQqveqR9xdCMElpxnbkalM4Vf9uaEcWZaKdyibEIjWKxJZPN95niCL3GiaXyssIrHxoLkqkzLCXULN46/f2h3tQJgyip+Tk9EAjJ9aJshq7t8X45aowSKspMSvPf7r9R8yxNptIaHS5ozuEm6luPDApugyNP8OaqiQ4BjaequXA54SLC83eHIY2r+CZp4409Xqw8Aa2oI7XkCrQi+in0w5AqF/kLNrcUz+qkl/lAobY1jSnx5OJNhyXIz3qfNFlXc0TKaglNwdWkWYt9QQ1Kr6W8zue21iNrdJk+N5oCr2O9nEtWKC7IS5J/zdDEYrmnAYfg6agCy+qcgz7ZofeDc4PbUWSvkshWuAc7OjiUyLkj+RAtdlwXJcjxdpkTTHDhK8lBCi8+JtvDVL1W6elmOM++YS0LuSlaP1oUvAeiW3cFnvTr8EbTz1tsSMYdGeZe40sRWu5uAfj7q+ZoKv2FNQ0p5XY1lmlcigHZqTPpabufEVrNuNPi165w3uCVQJHyJqmSJ7ZHnguqwtCmwViIJijj04ba2JNYtB+yORf5gg1/9t9iw4vUpeqiunSAbf+IBdj/b+iG2qrHvuNP0Vd/+ThVZT/lrvHYjjgDbbyxaqgHNM2uhxa1GW3UedZYhMMwM4mQhltouK+IV4NdbIQNM+8Yv311RZk9kT4tiYR4LkyFcuPpdcjuhUuFqBAWRZa11lcZ3gEBlXywsNhrt+plISZP5DlsV9l4EgY6J3yZPTUcMrgaWAT3oI79eSbGEbcJpr6BD8kyDiVt+G0/hXosQN4NFXKlfWIfsIs0BHODVok1/IGnKFHJYIquh8Xo+2+bkQNTGgWmN/fZ0Y33LSj6lr1GyV7mWIKg7ZTRZPGuhF/zjRNcQ1UPtSYgnWQxSs0yrVhwNDcdGMNSNe2JT3WuzbAM3HykyAajS3Uphf6STKEqxLas9EnmnhA/lyj9Uj+JoY7SVgVmGLl46Rm2u98sbkap2lzAdKBG4r6LgulQOSSjQv1GWdQ0jtDUK/mAaqM1Uqjpu4k3Rvfvxv7YTxLSK+wN3E5jVIzmF23uZ7hiH/sVP49D7tvoKp4S8b1LuvRlivVB/algbhcFITYVXvDpLzpDfplR2uD5V4XJFxpjmIpLc9Y5sB2TpBRix7Bme6GZIq+06v3XzNeTcA4obQIKxrnT4C2JpOqD92dbmSX8MGazly5EsZVMvSU1f4RZwyu8iQXbVdeLlZrjuTT1jrY1uk5c7iZ7RsvhhluqAkq4JpVQAg7RJFtSu+xgJ8Pv6O1j5DkLxT8mkbfyRW5DrQmG7hiDIjCgBsADbjuof6YHLGeV6a5Q1Smx9joUXPpdaaDx97A/Wq00oJkdR7ZYuQRfS533JtxO1erduqWOYIt3wh0wpbLuCNIYkwxbswbikCUu2CDCS+Q+7rgVtfRcm+SOcdKPRlZ/rE7wNVUEE39KTS5uvUKN1PUnkloPkyzhyGQ8qkouEjJ3H/VXdqG6asSRiw3ecMlBvDDt8dDhBHXMwZ2Cajzjr7/76T+IavqPYvz6r7//E/3X3+N//h/0QozbjPgPiir69P/8X3/9F/yv8b/827/++98WItPu5/Hvwd8YPf5bp/2/lX/T/+Of/0MJ/lYTa+L/Ef+d9vN/3/2T6P/+jyTzu/evf6U7vxN7B6pJkRtAF6jUr8I+P8RsP/ptGhfqFk+pQ/DgAy6NJtRYJdXmp4gK7WLqLKJ+MaKhGjOojvL+SnIWrkpy0SLHDe4QuyNzaEA15mLMCcmE8Em+4HdOihW4/ZWuppJEmzeAwcDtv7MuLc9y2V5atvxXNe3S4DUMt5/Qy2LM9kSYKiVWBuKlfp4nxTntpuW03JbIlkiRvBXmT23g1I2OYe6IizUHPIq6zm6mbfsbteKmi/sg9J+ocQBMctGFO7iljo8TPN+z3jxw4do+ZwfqoR9dkNTKHyM305GpTkfhcHexVkPVGEbUOjuo9f0UMPHBFlGEx0SLvJvVRKTwW7PSew5oPme+E42+frJa9cGt2njS3dK5kIif2eYbhuSEQXEqMVfUjhGIuin0G0/W5ezJyJQy3SpMLai4M0JUWb5u1k9tny5bd1pPwYBpQuDCXZl62xg4CdVEAtflXHs6JKmP/pH6mOl796Lgopj0o8d5kKh00hxG3OSdEE/QBo9Hgr8JJqAeLDwJohG5j/DGh61Rc/+tf22/8kEnxHNCEjo0ElvvGfESZkqmz2BDcKV1H1buSkhkdg7p1IMGs2s17nYjpblrWuE2K9WEO/hcRp5e9oOF/QBmOaDtgil+oaU6szPrdwW65fOB0KUTsVUn7LFU7J8e6cxJIl9+FHw5MQMzuQJ+4oxMH3iW/5GK+hWuG0T+gTLs+fAjdtUd58TmIUq04EeyRCYCjkldow234aIgR5bqwrtZosZ+6YEqAmDqatJ9lWasz4IquKALPtd92hGI3Z2BdzzZue+REl1Om4DIWD+RrtUTOJLI+S0jHowXXdAxsGLSd40zYNuEUlOGhrwL6c7tcOtUOvpJCP7QBQS19H+GvZn05ewjlVLz+IGKoC9TyfQjLMBNmXCuqqtTdOSukZW48B0HqgSTCBrBnlFvF4CG2Su7yFzqmJFURK3UmTT3ru050r0ptUpMilYnBJWfl2Bv6kPlUuE1kxxpdzui9AubsR2N2boVSu81OulAwBqoSr1LZ0LLYOomyZHmjqnXlP72s8LnDouEJjtodBvdHaG1jMySYO7crWd90MpCRyCG14vb5IE7Arupw/y/RcCm/Tm3zK6zYj8PYNaGldiUfkB/LHWcmf2lVM+mwyU27a0qq2tscrQ/vzBjN26DnntIrOyGizzXK35yKQdYnUABkyN4saz3WD/viF+eCcsXnIajdWYJWaYHRstIis9CS+tqnFGmz2j5uzfr3Z4prqgK4XOT/PyftvjZqIm8lhkfxJ7Ol3CJF1piYBGAG8wtAk56Drw1YwmOpcz+NdfkSpSLplRXLXHL0Rquj6YW/gabqgK7Dgr6NwtH0B/AN7XrN+MVJ6AmXmUuqmQulrNNYPmH0RoDogydOKLo/QbfYNARSQQKISRCzRXU+q9WWJFL3LZW6u34CkeG97xC0NNGaJ0bvK6SnZS3zPskr5EtuCgjMWR5o2x5BqhKmDWJPRe7JMEOyRb5uUKlHaGVtq5ivSOaSliSXp9SQm2qk8MRJh10MAp9QQ2H5t59J8rjiwSZtoIfMGjlLPVNdYl/LBR0AO6WLGDmkLkIPRE45Y9MftdAK/yNu1Hn6tzOQTesgQ+8fSzB19wO91vCnO23vOWQdwJ63SJrYjdfKFW6W281PKs2k8iT9ai1cgJ4sa3xqdvmtxR8/+D1B8AKc2u+6JftryRhMWSQtoSBgIyyQGyxcnELuAasXN12oSriU4RMz1DD6RL0TSV+om7i1Yt+jEE/jnawM8cX/UhN4nkiv/w9eALrzNhXuQfOzFL0Fi6SjF7/4Qn8rLYBoa85cvgAnkCEBP+HPbEnquVXCZsMS/yzYw2Vru60P/+nJPYKkzZFjmbykzUoEqV836T5q3fP/L383dF82tx18/AZgZczMAgyeWYKmSZIqtHL+e+O4ZRcq9VI3g/qPeCoiK4pcgEqdbS0S/Be54sbVQOuJVPNBblIghzeasNu7h/g+Sz1IdhI5lCwq1nUb3Ji4OCIcqQZqtqJ5w7rXrg/DA9IgVmEGhDgGecEwnCTHffXcXs0V3OCEVzYDKS1vp/oX+ng+6XVU86UjA6FMO2RXOOOrqY1GgPvrAk9HV/BXtCu5RuwF8qgdGDLsBcui4E33ymdBip1X8uKyhIWT8qNRDsXz+gvO9UiEC0d8RG4Tf2x8H4slljgHtCBcxHLTWOYJm5H/fCPCzOgf9qgOUxTRZ0Pc6ha5yLuLVT9ntvIa6gacE99mCovdUumTQdRP4RPsS9129eEe2uSvvGh0bV4Y3QPPhPZMqhZWSMa5R0Hc1SGO4IVOQc0FrirlibTVfKRrYkD8kz3b+X65/QkUNaZdrdl3mCap0Hf3YcCw/LiouJYNbqz88UqeDYv93yO7vvXtgl4XCyAO4ODkY6W+83+LZU//p3/zXNGGrUKClCiOnL27iJZbNWDF02XXAOeFlB7IaADoMH1Yqr+UP9biyZDEa/iJt4MDeIz6GKTdLVBfWGVtRN4fdT2rgReX8UXwF2zOrradm4J0nyTgdPnai3RvzpZvCKDUqjOwD/QA6EDaMCLewX6QWYVnHY1sx1bd8ovYnPm1ZvPH+rE20lWjOCnZ66/xDt0QAl15FjfBcZp+i9OU0RNPQ0t3x2pSNWo8eiYudwsnuP1Hq6iH1LJCJynkYsfgJ0p3pF6SoQk2l+jqE8CPk+ziGJRSKjs+W5AO185umPdkYzlK4wl7TC9NxyyDP7ZoyYVoXiuS6SjnInlLWrwz1i8bGTKXX0AVQWkSfIlglW3zRJRJ8bg5VgE6ZEnqNu9B++0GNQvDQJvFize4ESNKBJP+8vA3LM4AX5SIBq08Mob+7QMTCZx4nwP/64+4BnlZC+8WtlP/CXw6t1PwMwkJ3jhP1FiXLhDF/3I6FGUzO2DSi9ABxKyyL9paZxSEz40ZCPQToDAJu1959k7QdbVxgB4icsu2s4zsTPJhcEDo+N1GX4zSk/wriRh8AqwL62972i9HJHd1ydaLXVzvKvOfGGw5RVcUVMiKXFH4APdkQU/dc5BX0YfKTNZYXCW9mb8bc8mufoQP6BbdQmT99ZjoYfr/go4TgQX9IDgztim7wyFeGMfbNaeqj8Dzs38pgcqwSv2hbqB3oSGKWKy+sesY7p57wAHldqE6NDudk/W7s/zjrK4rZFlFvaGxnSZdHbc1y47qDN6xkoK8O3bfr2j41dlJZ71rB4dlDqapPFa8N6xBrprUdtenUCHwxKNhw1uuTBh+9uU45k4REpQABN2bAO9DSLqoIL26gNroWgup5pUMxHUNSq4Gyz47vBPvilpo5f9OYI2ddAqTqmnxXERxQJ3UK8fHbVE9HagHi3+tqNRoNsArdmAxHA5LwtQo9ZAaNKUTljnokljo2x8scqVpEEIPc01fPCdHOCg0DeWBz8D5TVAAfx8aRH5X2ZYNI3ebKDZdeJ+oBDAxmRqJ30Eh2/DaeAy5diVNMpEDmXiPDsGTzBLXy8eVDdJoIafgx/gxMyQi454QrW56nCyeELgSuNNEmYkflF+t3CZQOVRWjKhIuCclmQSlAXT3+4JGG75B4t/5hQ+ldMP4LsAW6z3XmU6IJJwpnGVnsgUZhoY1fZlwTR8wSU7xRejf2uCx9Z5trVTRRJP9KnEb134dEieil6eCOGWgboI7xsqsqM99jfJLTePjygKlH2CVxxsse9QRzTBFjD/Kjqitr/CCTBt/SJ6nLxz7cKP9pFqBpp0lN5y+adKNsZjrPuroemZauH9aTTFD3EKHW8S55XBLFQAt1jgxTQCTwxmx/JyfsZDN1RroN3VaxpSenpIX7K+ZbL8VdlQDcI4Cbzg3QJLa9yVqNxUelu+EtxLVqeekaAvSJkO6sSVqbUajxqhKshNpvZqoeApF0k/0P0ikkwUcbdwc4A1ejN7Oo0O15kG7hTMoK3hZRBCX7YYeLW0wvcXx/18n/u37yLgzBYVBUvORGli+sfRcX/74uD6P4hq+7xu54TlWJLFzT63uwUDwuEDdOjJQqx7JV+ZjaEAPi7t0MMrR4Q8Rkf18uxD6RK0RKh0hL8YU+DeL97i4pa5ZSyAfXKwZRS/8gXcxdZXm62RBDj8U3sN8x95b5PpPs/mCBKYvpaA50pN5Ct/499AFTtwQ5vgeSh+NHrKIi4NVpwM/XzRaNfJD856lPE6M21zWPguFsH7jbLVyEDfRmt4VwrhCJ5VTYmcSPfGgO5clfN+vbaDZ7sakU5+2vZ2WCDY031NxJarVytfDDVtiafcTGO2rJ/taoL3zChN2qmjxofczTOYQPPVQPh0JVtYgdUQINcSiNEEy58UdYXX1MpWUCEBx7LbcGtAm8XWRQTVOaoV3ySri4RShhs/B/0m4jX6OAwXOvcA09bNSG4czEGv/Wey6V/jbTCNTW6awXdNTcA1GsPe1E9fZdGl7R0vyoVpIdJtfC6d32NNErrvq/R+d65VG+YOwRXppXxOCYyGNSf1K3x6VxAW/vtz4EC1SgCOSPdN62sLsoIzuDfg8GwZAbquVO8HIuFP/ToVoeUB7nnwMF35a1wK1tI6fkrqFKhQdeJpwyls0pIy8AZde3/6LUUbFaYJthyUJSU/kqDXTLQElnn0Jr4B2RVghNrmNmoEn7pXIeshPguXVsvwoTdmClq49JJU3LWhHyWTrJL9bRP6VKv3tZoA/th77p5Jw++OEENvyvWy/pNeExiDUVQaXIRGh8xySZTI36yueFaSXo1uJY0RnXYgEOoWWOJHeaVuX/bGNhHsh2yinznl/++NJcE9j6fBPRcBdq9hb8awNw8U7Bl6GM7x69EDOIIbX/npZ++amlHR9L/35mE/2Ss4gb0xCcY4VyTFLRE796vHysLAamqcyO+aFQyJIDBNslbH2/MrAvZiSEIedc/cqjmv4fbda2pXbv+F5a2szSsdkm9noiNURXt8edUhGUF6fSZWd1IJaXKFwD+49R6eCXD4Bkef7j9tRtNMVgW8BhRz/Qpy1TmeYk0doyjZoJSbePOReVHgkFsCFuQJ+Lgc4BxeAsK/cOiNDRmdNw0ctYhn/nQ498dYI5znzGLoJi1rav7Cn88rL3wLePVtDK5gl77Tki3gHEsIAQ2+IKgarj7Y8W1IQzV5V9N+0TjLqbg68WfKcOmBCOj3JkwJhVIkwDhc+JorXuZEPMEh0vvH3x7iqf+VAwXgd4diZiaJD1zHL9Snx6Wfg4IugreyhabQkcir+y5XgDtdx3Avs7lkeeCBwDvZoTUCXx5QrZkcEqWfYEiEYRs/EphmRALSNGR1Iclgdr5VFoELpzF4++f35w3/j0t5ucW3n2ch4PQCLuUXupsPRR7UA5FjSKrMtPcKAZJfagO4lGE7FH3YKMjorpK0ZxAv+i2JkJhtAMWWWFej4RhPR/cJ3DxwocCvXDi4SGZU4cu+K32XndiFWgopAl+0GApcwf1XvymJcFs39jExIBO4yUjU9MExBLQYc9H+W7+IgdESPRpciT+rKZPebVtaVq+1GYO/5xTAL3HASjNTGIgMvdjWbgc7JvdE1zIFpuC0U9ESiZyzBixzxWxj4Kwh8My34q+FK3KNLtmsA1qyrmKSNQOXCPUZd+ONelBTvFoUI/CYsqa/RhtKiyMf2CgSFqEPk59Y3uqnlZ8gFpswfSYyko23yVZYxzKGxGm49Zqxg1l8oz5Ra9XaRwHkuxepmgyhm0SoNy2KlbcEqK+9QqS9PNx9Ihm9U7gsR55SSJ1FBDNnkuWKxIZ0SDpXuOGwZdoUbOMDPHP4vBAgz2VlSEJAHZGJVbYIg7l/FO5KfIVvxC8pPPxMGcNMoevFDeStt2iqztE10n2TA4dgJH76YS9HDhKHD3iCx6ieFX84BAI3QQnngh76f5ruPQVbr5qZmck/5UjDc26lfrOvUBWy0Ogl8bCoOkMOns81TnC3cuUS9KW8+9A+fe3XYZOFUPG1u5epSSmDLw0s5s2F0W30ANeo+zJkJQz9SPZgzwYpEoktofhGVfmLOAB20boCbW1QWq/NpET/hnMecw/uSyAH4NJc3ECOU4nnkK1fj3S/i5dwb3R7k00AqQQUwt7Ie1qV0aY/VQX0J8hLPy7eBNXMHYZYDNxHZ2Qh6AuXJxq+AeRec/Q+JLhZV6hpXwQEzw7bf5v9uUf2vpq3qlhmy0IIGTkwYdCfSAFmqbdo+3XvDTDjFJde0mbeQLcn2n31xaAqJ0ixO/CLsT4I4G4DoncVTgRGNBtsCcjISWT+oeXZ4Iedw/8OsJI1aPnNKLX/60VvcZb94uasRxCkqlPQ11u1Sa2hHvB80WQENxVyzjns0/PiEByyil21Te6oisk3mNCEMrhouCFO3yEZTHHOCMy9eb/4Tmi8cVf3Lf7P53SY2hX3PSN033As3ETIMLHWumWEO9JXHA2y2SIBlIPpLGG2qvNsCIlIr+B1SWAqRKm2w6Blf7U+zCSBwJrfHG5i8J5Gax/cVonMlon7aHJX/gSvucIncRP93XCqkv7D8IFKFsLiBgHqUpXhE3pYjEcV1dk/JD9zFVCfEaQIVX8Jmfz7IIofcBKQ4OaG+C3xC2veX9CD+iAFXDNaGg9eTVxvkbJRJlW4Nk9Wk13kn696jWppRDe/8pDrYMO9ZyxZ98ReKSz9kWKLLyk2zCZgAniCkLJVX3n1M9DYbomyahWiv/KixRIV9hj/oFz87I+HLznbPTjpa+D+bZQnMuRsljTpv90vQUt/pK7jCFnA30B/jtroSF2/m/gpWn1aQs5WeA6ghzF8SdqWI20fghdSeDOCSCmLgTkfaGgGDmw7nHFkRzGtag57IHS2na06I+gzEphXo1w/Zx2BM/jKL2nZoFjHggtFQjYi8nSVRSXIE58RPbBObXk7uuIL9+rs/5Zo7suJInEUxgsiZZAWS25iBtpEiZeBgDtghEoAE0sjcayNq85M4tbu/LF5h51335PsGzQ09O875+vUS89lkWMyNOFoip2PuyWyMP/iU2XIZdfCCJNDjebDoBLQdpy7QQZC7s9c0wjHJervQNDu2jWzBW5MSAJMr7bP+Iv92BkS/GGgzjEn7MF1IRKFwwzbjbS4/slGOmhx9cZrFu7HSEefojNv3r0UaKfKOWzXsq1zEugbzlMDFsacRJJI/iJlK3vtkZ+PLZIVMFlKA32wbq2Kd5T0uCLZ1CPkAfCdzkz2EYscjDcZq2AWfziN2covN4kXE1lQXPPLTNM1xx3tbiepcO/t3SWm4w87qfh99SL0ZnY+LKFPLPeXVM2mIIoVWt+9Nk0I7nY4O79iGYqxZ8RVz289an6NVdJWnSKZvJQCAuHNiVaDxPAFoH392t9wot5t0/qmU95eEWNbU2udUW5sN9JVqcYlvAIfLeYC33oUzzxZgSktsv21mA7Uly1FA5VnoJFh6N244Wmv3YJGFv/TCPryaw+ZORlpZjQdq/2DYXr3EZskfed0G61P09ipTKmlTQ1067Rg5+PAk5FlQ9e0SWbGf2B/08kqymOTMVOznsALHHNFH4LFRKl2F/NOiYFl9khNHnSu9Ak5sq26Ynl/i2fdTle29Y1ugqmR5Yj4YT9pvslFyYCbw0mNFr5rVQm1LvkG27QMq9ph3t8fmn6r6SQ4oSbr5tz+J1kIawGzDxb6VYOvvWhobDTXfBeNv3b4aNm5XUinsCGqG2q/45m3+LoCOsddFceYhRx1Tsss9PLdPfJdErFMjYd3gddjiP0+XQjcRadZP6bwNLySvunFf20Czy6JqdEW2a96KxdYdOryBv1BjbuUq2yCHeh+6sk7fGmmPi50pe/1l5TyPe5oHW9oPnhPswLyf2TFDdCyYlhwBCstv5C1HwlW7xWoGT9XZt4qVj5WryLPLLD6h/5cMLEjWzgCeAIKNsLak92aBqBsHl4AJwl2N4jfvbSkBExGimv0nFvv09uDScQbjx+w4kPQjgjlW+g9ws9VEJvI2k8N6XxVu0uIwovgTFdunG24gBtaDi+y1YLQwZ8mwbip5fVlO3k0n0AEr/ETbtu8Vjkm+nNSiEb7X/3fMjBL5A8PdgG+/FnbexbFFExmEfetXAnisEKy5z44WVPpQZjSy/jzeGn4yDRsFGqhh87QPaDBWhlo37IFbe/C0xynS91d2tP/AJoJS0sVF6iwAAAAAElFTkSuQmCC"); -} - -#menu::after { - display: block; - content: ''; - padding-top: 80px; -} - -#logo { - position: fixed; - bottom: 10px; - right: 10px; - background: rgba(255,255,255,.1); - font-size: 11px; - display: block; - width: 20px; - height: 20px; - line-height: 20px; - text-align: center; - -webkit-border-radius: 20px; - -moz-border-radius: 20px; - -webkit-box-shadow: 0 0 3px rgba(0,0,0,.2); - -moz-box-shadow: 0 0 3px rgba(0,0,0,.2); - color: inherit; -} - -#menu li a { - display: block; - color: white; - padding: 0 35px 0 25px; - -webkit-transition: background 300ms; - -moz-transition: background 300ms; -} - -#menu li { - position: relative; - list-style: none; -} - -#menu a:hover, -#menu a.active { - text-decoration: none; - background: rgba(255,255,255,.1); -} - -#menu li:hover .cov { - opacity: 1; -} - -#menu li .dirname { - opacity: .60; - padding-right: 2px; -} - -#menu li .basename { - opacity: 1; -} - -#menu .cov { - background: rgba(0,0,0,.4); - position: absolute; - top: 0; - right: 8px; - font-size: 9px; - opacity: .6; - text-align: left; - width: 17px; - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - padding: 2px 3px; - text-align: center; -} - -#stats:nth-child(2n) { - display: inline-block; - margin-top: 15px; - border: 1px solid #eee; - padding: 10px; - -webkit-box-shadow: inset 0 0 2px #eee; - -moz-box-shadow: inset 0 0 2px #eee; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; -} - -#stats div { - float: left; - padding: 0 5px; -} - -#stats::after { - display: block; - content: ''; - clear: both; -} - -#stats .sloc::after { - content: ' SLOC'; - color: #b6b6b6; -} - -#stats .percentage::after { - content: ' coverage'; - color: #b6b6b6; -} - -#stats .hits, -#stats .misses { - display: none; -} - -.high { - color: #00d4b4; -} -.medium { - color: #e87d0d; -} -.low { - color: #d4081a; -} -.terrible { - color: #d4081a; - font-weight: bold; -} - -table { - width: 80%; - margin-top: 10px; - border-collapse: collapse; - border: 1px solid #cbcbcb; - color: #363636; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; -} - -table thead { - display: none; -} - -table td.line, -table td.hits { - width: 20px; - background: #eaeaea; - text-align: center; - font-size: 11px; - padding: 0 10px; - color: #949494; -} - -table td.hits { - width: 10px; - padding: 2px 5px; - color: rgba(0,0,0,.2); - background: #f0f0f0; -} - -tr.miss td.line, -tr.miss td.hits { - background: #e6c3c7; -} - -tr.miss td { - background: #f8d5d8; -} - -td.source { - padding-left: 15px; - line-height: 15px; - white-space: pre; - font: 12px monaco, monospace; -} - -code .comment { color: #ddd } -code .init { color: #2F6FAD } -code .string { color: #5890AD } -code .keyword { color: #8A6343 } -code .number { color: #2F6FAD } -</style></head><body><div id="coverage"><h1 id="overview">Coverage</h1><div id="menu"><li><a href="#overview">overview</a></li><li><span class="cov high">95</span><a href="#webidl2.js"><span class="basename">webidl2.js</span></a></li><a id="logo" href="http://visionmedia.github.com/mocha/">m</a></div><div id="stats" class="high"><div class="percentage">95%</div><div class="sloc">572</div><div class="hits">548</div><div class="misses">24</div></div><div id="files"><div class="file"><h2 id="webidl2.js">webidl2.js</h2><div id="stats" class="high"><div class="percentage">95%</div><div class="sloc">572</div><div class="hits">548</div><div class="misses">24</div></div><table id="source"><thead><tr><th>Line</th><th>Hits</th><th>Source</th></tr></thead><tbody><tr><td class="line">1</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">2</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">3</td><td class="hits">1</td><td class="source"><span class="k">(</span><span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">4</td><td class="hits">1</td><td class="source"> <span class="k">var</span> tokenise <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>str<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">5</td><td class="hits">47</td><td class="source"> <span class="k">var</span> tokens <span class="k">=</span> <span class="k">[]</span></td></tr><tr><td class="line">6</td><td class="hits"></td><td class="source"> <span class="k">,</span> re <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">7</td><td class="hits"></td><td class="source"> <span class="s">"float"</span><span class="k">:</span> <span class="s">/^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/</span></td></tr><tr><td class="line">8</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"integer"</span><span class="k">:</span> <span class="s">/^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/</span></td></tr><tr><td class="line">9</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"identifier"</span><span class="k">:</span> <span class="s">/^[A-Z_a-z][0-9A-Z_a-z]*/</span></td></tr><tr><td class="line">10</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"string"</span><span class="k">:</span> <span class="s">/^"[^"]*"/</span></td></tr><tr><td class="line">11</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"whitespace"</span><span class="k">:</span> <span class="s">/^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/</span></td></tr><tr><td class="line">12</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"other"</span><span class="k">:</span> <span class="s">/^[^\t\n\r 0-9A-Z_a-z]/</span></td></tr><tr><td class="line">13</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">14</td><td class="hits"></td><td class="source"> <span class="k">,</span> types <span class="k">=</span> <span class="k">[]</span></td></tr><tr><td class="line">15</td><td class="hits"></td><td class="source"> <span class="k">;</span></td></tr><tr class="hit"> <td class="line">16</td><td class="hits">329</td><td class="source"> <span class="k">for</span> <span class="k">(</span><span class="k">var</span> k <span class="k">in</span> re<span class="k">)</span> types<span class="k">.</span>push<span class="k">(</span>k<span class="k">);</span></td></tr><tr class="hit"> <td class="line">17</td><td class="hits">47</td><td class="source"> <span class="k">while</span> <span class="k">(</span>str<span class="k">.</span>length <span class="k">></span> <span class="s">0</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">18</td><td class="hits">2914</td><td class="source"> <span class="k">var</span> matched <span class="k">=</span> <span class="k">false</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">19</td><td class="hits">2914</td><td class="source"> <span class="k">for</span> <span class="k">(</span><span class="k">var</span> i <span class="k">=</span> <span class="s">0</span><span class="k">,</span> n <span class="k">=</span> types<span class="k">.</span>length<span class="k">;</span> i <span class="k"><</span> n<span class="k">;</span> i<span class="k">++)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">20</td><td class="hits">13325</td><td class="source"> <span class="k">var</span> type <span class="k">=</span> types<span class="k">[</span>i<span class="k">];</span></td></tr><tr class="hit"> <td class="line">21</td><td class="hits">13325</td><td class="source"> str <span class="k">=</span> str<span class="k">.</span>replace<span class="k">(</span>re<span class="k">[</span>type<span class="k">],</span> <span class="k">function</span> <span class="k">(</span>tok<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">22</td><td class="hits">2914</td><td class="source"> tokens<span class="k">.</span>push<span class="k">(</span><span class="k">{</span> type<span class="k">:</span> type<span class="k">,</span> value<span class="k">:</span> tok <span class="k">}</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">23</td><td class="hits">2914</td><td class="source"> matched <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">24</td><td class="hits">2914</td><td class="source"> <span class="k">return</span> <span class="s">""</span><span class="k">;</span></td></tr><tr><td class="line">25</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">26</td><td class="hits">16239</td><td class="source"> <span class="k">if</span> <span class="k">(</span>matched<span class="k">)</span> <span class="k">break</span><span class="k">;</span></td></tr><tr><td class="line">27</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">28</td><td class="hits">5828</td><td class="source"> <span class="k">if</span> <span class="k">(</span>matched<span class="k">)</span> <span class="k">continue</span><span class="k">;</span></td></tr><tr class="miss"> <td class="line">29</td><td class="hits">0</td><td class="source"> <span class="k">throw</span> <span class="k">new</span> Error<span class="k">(</span><span class="s">"Token stream not progressing"</span><span class="k">);</span></td></tr><tr><td class="line">30</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">31</td><td class="hits">47</td><td class="source"> <span class="k">return</span> tokens<span class="k">;</span></td></tr><tr><td class="line">32</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">33</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">34</td><td class="hits">1</td><td class="source"> <span class="k">var</span> parse <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>tokens<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">35</td><td class="hits">47</td><td class="source"> <span class="k">var</span> line <span class="k">=</span> <span class="s">1</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">36</td><td class="hits">47</td><td class="source"> tokens <span class="k">=</span> tokens<span class="k">.</span>slice<span class="k">();</span></td></tr><tr><td class="line">37</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">38</td><td class="hits">47</td><td class="source"> <span class="k">var</span> FLOAT <span class="k">=</span> <span class="s">"float"</span></td></tr><tr><td class="line">39</td><td class="hits"></td><td class="source"> <span class="k">,</span> INT <span class="k">=</span> <span class="s">"integer"</span></td></tr><tr><td class="line">40</td><td class="hits"></td><td class="source"> <span class="k">,</span> ID <span class="k">=</span> <span class="s">"identifier"</span></td></tr><tr><td class="line">41</td><td class="hits"></td><td class="source"> <span class="k">,</span> STR <span class="k">=</span> <span class="s">"string"</span></td></tr><tr><td class="line">42</td><td class="hits"></td><td class="source"> <span class="k">,</span> OTHER <span class="k">=</span> <span class="s">"other"</span></td></tr><tr><td class="line">43</td><td class="hits"></td><td class="source"> <span class="k">;</span></td></tr><tr><td class="line">44</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">45</td><td class="hits">47</td><td class="source"> <span class="k">var</span> WebIDLParseError <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>str<span class="k">,</span> line<span class="k">,</span> input<span class="k">,</span> tokens<span class="k">)</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">46</td><td class="hits">0</td><td class="source"> <span class="k">this</span><span class="k">.</span>message <span class="k">=</span> str<span class="k">;</span></td></tr><tr class="miss"> <td class="line">47</td><td class="hits">0</td><td class="source"> <span class="k">this</span><span class="k">.</span>line <span class="k">=</span> line<span class="k">;</span></td></tr><tr class="miss"> <td class="line">48</td><td class="hits">0</td><td class="source"> <span class="k">this</span><span class="k">.</span>input <span class="k">=</span> input<span class="k">;</span></td></tr><tr class="miss"> <td class="line">49</td><td class="hits">0</td><td class="source"> <span class="k">this</span><span class="k">.</span>tokens <span class="k">=</span> tokens<span class="k">;</span></td></tr><tr><td class="line">50</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">51</td><td class="hits">47</td><td class="source"> WebIDLParseError<span class="k">.</span>prototype<span class="k">.</span>toString <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">52</td><td class="hits">0</td><td class="source"> <span class="k">return</span> <span class="k">this</span><span class="k">.</span>message <span class="k">+</span> <span class="s">", line "</span> <span class="k">+</span> <span class="k">this</span><span class="k">.</span>line <span class="k">+</span> <span class="s">" (tokens: '"</span> <span class="k">+</span> <span class="k">this</span><span class="k">.</span>input <span class="k">+</span> <span class="s">"')</span><span class="t">\n</span><span class="s">"</span> <span class="k">+</span></td></tr><tr><td class="line">53</td><td class="hits"></td><td class="source"> JSON<span class="k">.</span>stringify<span class="k">(</span><span class="k">this</span><span class="k">.</span>tokens<span class="k">,</span> <span class="k">null</span><span class="k">,</span> <span class="s">4</span><span class="k">);</span></td></tr><tr><td class="line">54</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">55</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">56</td><td class="hits">47</td><td class="source"> <span class="k">var</span> error <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>str<span class="k">)</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">57</td><td class="hits">0</td><td class="source"> <span class="k">var</span> tok <span class="k">=</span> <span class="s">""</span><span class="k">,</span> numTokens <span class="k">=</span> <span class="s">0</span><span class="k">,</span> maxTokens <span class="k">=</span> <span class="s">5</span><span class="k">;</span></td></tr><tr class="miss"> <td class="line">58</td><td class="hits">0</td><td class="source"> <span class="k">while</span> <span class="k">(</span>numTokens <span class="k"><</span> maxTokens <span class="k">&&</span> tokens<span class="k">.</span>length <span class="k">></span> numTokens<span class="k">)</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">59</td><td class="hits">0</td><td class="source"> tok <span class="k">+=</span> tokens<span class="k">[</span>numTokens<span class="k">].</span>value<span class="k">;</span></td></tr><tr class="miss"> <td class="line">60</td><td class="hits">0</td><td class="source"> numTokens<span class="k">++;</span></td></tr><tr><td class="line">61</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="miss"> <td class="line">62</td><td class="hits">0</td><td class="source"> <span class="k">throw</span> <span class="k">new</span> WebIDLParseError<span class="k">(</span>str<span class="k">,</span> line<span class="k">,</span> tok<span class="k">,</span> tokens<span class="k">.</span>slice<span class="k">(</span><span class="s">0</span><span class="k">,</span> <span class="s">5</span><span class="k">));</span></td></tr><tr><td class="line">63</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">64</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">65</td><td class="hits">47</td><td class="source"> <span class="k">var</span> last_token <span class="k">=</span> <span class="k">null</span><span class="k">;</span></td></tr><tr><td class="line">66</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">67</td><td class="hits">47</td><td class="source"> <span class="k">var</span> consume <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>type<span class="k">,</span> value<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">68</td><td class="hits">8778</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>tokens<span class="k">.</span>length <span class="k">||</span> tokens<span class="k">[</span><span class="s">0</span><span class="k">].</span>type <span class="k">!==</span> type<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">69</td><td class="hits">5470</td><td class="source"> <span class="k">if</span> <span class="k">(</span><span class="k">typeof</span> value <span class="k">===</span> <span class="s">"undefined"</span> <span class="k">||</span> tokens<span class="k">[</span><span class="s">0</span><span class="k">].</span>value <span class="k">===</span> value<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">70</td><td class="hits">1738</td><td class="source"> last_token <span class="k">=</span> tokens<span class="k">.</span>shift<span class="k">();</span></td></tr><tr class="hit"> <td class="line">71</td><td class="hits">1738</td><td class="source"> <span class="k">return</span> last_token<span class="k">;</span></td></tr><tr><td class="line">72</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">73</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">74</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">75</td><td class="hits">47</td><td class="source"> <span class="k">var</span> ws <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">76</td><td class="hits">6961</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>tokens<span class="k">.</span>length<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr><td class="line">77</td><td class="hits"></td><td class="source"> <span class="c">// console.log("tokens.length", tokens.length, tokens[0]);</span></td></tr><tr class="hit"> <td class="line">78</td><td class="hits">6115</td><td class="source"> <span class="k">if</span> <span class="k">(</span>tokens<span class="k">[</span><span class="s">0</span><span class="k">].</span>type <span class="k">===</span> <span class="s">"whitespace"</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">79</td><td class="hits">1172</td><td class="source"> <span class="k">var</span> t <span class="k">=</span> tokens<span class="k">.</span>shift<span class="k">();</span></td></tr><tr class="hit"> <td class="line">80</td><td class="hits">2294</td><td class="source"> t<span class="k">.</span>value<span class="k">.</span>replace<span class="k">(</span><span class="s">/\n/g</span><span class="k">,</span> <span class="k">function</span> <span class="k">(</span>m<span class="k">)</span> <span class="k">{</span> line<span class="k">++;</span> <span class="k">return</span> m<span class="k">;</span> <span class="k">}</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">81</td><td class="hits">1172</td><td class="source"> <span class="k">return</span> t<span class="k">;</span></td></tr><tr><td class="line">82</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">83</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">84</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">85</td><td class="hits">47</td><td class="source"> <span class="k">var</span> all_ws <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">86</td><td class="hits">5366</td><td class="source"> <span class="k">var</span> t <span class="k">=</span> <span class="k">{</span> type<span class="k">:</span> <span class="s">"whitespace"</span><span class="k">,</span> value<span class="k">:</span> <span class="s">""</span> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">87</td><td class="hits">5366</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">88</td><td class="hits">6538</td><td class="source"> <span class="k">var</span> w <span class="k">=</span> ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">89</td><td class="hits">11904</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>w<span class="k">)</span> <span class="k">break</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">90</td><td class="hits">1172</td><td class="source"> t<span class="k">.</span>value <span class="k">+=</span> w<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">91</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">92</td><td class="hits">6538</td><td class="source"> <span class="k">if</span> <span class="k">(</span>t<span class="k">.</span>value<span class="k">.</span>length <span class="k">></span> <span class="s">0</span><span class="k">)</span> <span class="k">return</span> t<span class="k">;</span></td></tr><tr><td class="line">93</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">94</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">95</td><td class="hits">47</td><td class="source"> <span class="k">var</span> integer_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">96</td><td class="hits">273</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="s">""</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">97</td><td class="hits">273</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">98</td><td class="hits">312</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"unsigned"</span><span class="k">))</span> ret <span class="k">=</span> <span class="s">"unsigned "</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">99</td><td class="hits">273</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">100</td><td class="hits">287</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"short"</span><span class="k">))</span> <span class="k">return</span> ret <span class="k">+</span> <span class="s">"short"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">101</td><td class="hits">259</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"long"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">102</td><td class="hits">41</td><td class="source"> ret <span class="k">+=</span> <span class="s">"long"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">103</td><td class="hits">41</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">104</td><td class="hits">43</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"long"</span><span class="k">))</span> <span class="k">return</span> ret <span class="k">+</span> <span class="s">" long"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">105</td><td class="hits">39</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">106</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">107</td><td class="hits">218</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">)</span> error<span class="k">(</span><span class="s">"Failed to parse integer type"</span><span class="k">);</span></td></tr><tr><td class="line">108</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">109</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">110</td><td class="hits">47</td><td class="source"> <span class="k">var</span> float_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">111</td><td class="hits">218</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="s">""</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">112</td><td class="hits">218</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">113</td><td class="hits">222</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"unrestricted"</span><span class="k">))</span> ret <span class="k">=</span> <span class="s">"unrestricted "</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">114</td><td class="hits">218</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">115</td><td class="hits">257</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"float"</span><span class="k">))</span> <span class="k">return</span> ret <span class="k">+</span> <span class="s">"float"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">116</td><td class="hits">182</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"double"</span><span class="k">))</span> <span class="k">return</span> ret <span class="k">+</span> <span class="s">"double"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">117</td><td class="hits">176</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">)</span> error<span class="k">(</span><span class="s">"Failed to parse float type"</span><span class="k">);</span></td></tr><tr><td class="line">118</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">119</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">120</td><td class="hits">47</td><td class="source"> <span class="k">var</span> primitive_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">121</td><td class="hits">273</td><td class="source"> <span class="k">var</span> num_type <span class="k">=</span> integer_type<span class="k">()</span> <span class="k">||</span> float_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">122</td><td class="hits">370</td><td class="source"> <span class="k">if</span> <span class="k">(</span>num_type<span class="k">)</span> <span class="k">return</span> num_type<span class="k">;</span></td></tr><tr class="hit"> <td class="line">123</td><td class="hits">176</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">124</td><td class="hits">186</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"boolean"</span><span class="k">))</span> <span class="k">return</span> <span class="s">"boolean"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">125</td><td class="hits">167</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"byte"</span><span class="k">))</span> <span class="k">return</span> <span class="s">"byte"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">126</td><td class="hits">168</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"octet"</span><span class="k">))</span> <span class="k">return</span> <span class="s">"octet"</span><span class="k">;</span></td></tr><tr><td class="line">127</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">128</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">129</td><td class="hits">47</td><td class="source"> <span class="k">var</span> const_value <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">130</td><td class="hits">17</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"true"</span><span class="k">))</span> <span class="k">return</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">131</td><td class="hits">19</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"false"</span><span class="k">))</span> <span class="k">return</span> <span class="k">false</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">132</td><td class="hits">17</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"null"</span><span class="k">))</span> <span class="k">return</span> <span class="k">null</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">133</td><td class="hits">14</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"Infinity"</span><span class="k">))</span> <span class="k">return</span> Infinity<span class="k">;</span></td></tr><tr class="hit"> <td class="line">134</td><td class="hits">13</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"NaN"</span><span class="k">))</span> <span class="k">return</span> NaN<span class="k">;</span></td></tr><tr class="hit"> <td class="line">135</td><td class="hits">11</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> consume<span class="k">(</span>FLOAT<span class="k">)</span> <span class="k">||</span> consume<span class="k">(</span>INT<span class="k">);</span></td></tr><tr class="hit"> <td class="line">136</td><td class="hits">19</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">)</span> <span class="k">return</span> <span class="s">1</span> <span class="k">*</span> ret<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">137</td><td class="hits">3</td><td class="source"> <span class="k">var</span> tok <span class="k">=</span> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"-"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">138</td><td class="hits">3</td><td class="source"> <span class="k">if</span> <span class="k">(</span>tok<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">139</td><td class="hits">2</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"Infinity"</span><span class="k">))</span> <span class="k">return</span> <span class="k">-</span>Infinity<span class="k">;</span></td></tr><tr class="miss"> <td class="line">140</td><td class="hits">0</td><td class="source"> <span class="k">else</span> tokens<span class="k">.</span>unshift<span class="k">(</span>tok<span class="k">);</span></td></tr><tr><td class="line">141</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">142</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">143</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">144</td><td class="hits">47</td><td class="source"> <span class="k">var</span> type_suffix <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>obj<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">145</td><td class="hits">249</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">146</td><td class="hits">263</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">147</td><td class="hits">263</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"?"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">148</td><td class="hits">11</td><td class="source"> <span class="k">if</span> <span class="k">(</span>obj<span class="k">.</span>nullable<span class="k">)</span> error<span class="k">(</span><span class="s">"Can't nullable more than once"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">149</td><td class="hits">11</td><td class="source"> obj<span class="k">.</span>nullable <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr><td class="line">150</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">151</td><td class="hits">252</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"["</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">152</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">153</td><td class="hits">3</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"]"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated array type"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">154</td><td class="hits">5</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>obj<span class="k">.</span>array<span class="k">)</span> obj<span class="k">.</span>array <span class="k">=</span> <span class="s">1</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">155</td><td class="hits">1</td><td class="source"> <span class="k">else</span> obj<span class="k">.</span>array<span class="k">++;</span></td></tr><tr><td class="line">156</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">157</td><td class="hits">249</td><td class="source"> <span class="k">else</span> <span class="k">return</span><span class="k">;</span></td></tr><tr><td class="line">158</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">159</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">160</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">161</td><td class="hits">47</td><td class="source"> <span class="k">var</span> single_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">162</td><td class="hits">261</td><td class="source"> <span class="k">var</span> prim <span class="k">=</span> primitive_type<span class="k">()</span></td></tr><tr><td class="line">163</td><td class="hits"></td><td class="source"> <span class="k">,</span> ret <span class="k">=</span> <span class="k">{</span> sequence<span class="k">:</span> <span class="k">false</span><span class="k">,</span> nullable<span class="k">:</span> <span class="k">false</span><span class="k">,</span> array<span class="k">:</span> <span class="k">false</span><span class="k">,</span> union<span class="k">:</span> <span class="k">false</span> <span class="k">}</span></td></tr><tr><td class="line">164</td><td class="hits"></td><td class="source"> <span class="k">;</span></td></tr><tr class="hit"> <td class="line">165</td><td class="hits">261</td><td class="source"> <span class="k">if</span> <span class="k">(</span>prim<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">166</td><td class="hits">99</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> prim<span class="k">;</span></td></tr><tr><td class="line">167</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">168</td><td class="hits">162</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"sequence"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">169</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">170</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"<"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">171</td><td class="hits">0</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> <span class="s">"sequence"</span><span class="k">;</span></td></tr><tr><td class="line">172</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">173</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">174</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>sequence <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">175</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Error parsing sequence type"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">176</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">177</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">">"</span><span class="k">))</span> error<span class="k">(</span><span class="s">"Unterminated sequence"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">178</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">179</td><td class="hits">5</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"?"</span><span class="k">))</span> ret<span class="k">.</span>nullable <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">180</td><td class="hits">4</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">181</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">182</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">183</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">184</td><td class="hits">158</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">185</td><td class="hits">169</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>name<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">186</td><td class="hits">147</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">187</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">188</td><td class="hits">246</td><td class="source"> type_suffix<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">189</td><td class="hits">246</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">.</span>nullable <span class="k">&&</span> ret<span class="k">.</span>idlType <span class="k">===</span> <span class="s">"any"</span><span class="k">)</span> error<span class="k">(</span><span class="s">"Type any cannot be made nullable"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">190</td><td class="hits">246</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">191</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">192</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">193</td><td class="hits">47</td><td class="source"> <span class="k">var</span> union_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">194</td><td class="hits">11</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">195</td><td class="hits">19</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"("</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">196</td><td class="hits">3</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span> sequence<span class="k">:</span> <span class="k">false</span><span class="k">,</span> nullable<span class="k">:</span> <span class="k">false</span><span class="k">,</span> array<span class="k">:</span> <span class="k">false</span><span class="k">,</span> union<span class="k">:</span> <span class="k">true</span><span class="k">,</span> idlType<span class="k">:</span> <span class="k">[]</span> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">197</td><td class="hits">3</td><td class="source"> <span class="k">var</span> fst <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Union type with no content"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">198</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>idlType<span class="k">.</span>push<span class="k">(</span>fst<span class="k">);</span></td></tr><tr class="hit"> <td class="line">199</td><td class="hits">3</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">200</td><td class="hits">7</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">201</td><td class="hits">10</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"or"</span><span class="k">))</span> <span class="k">break</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">202</td><td class="hits">4</td><td class="source"> <span class="k">var</span> typ <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No type after 'or' in union type"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">203</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>idlType<span class="k">.</span>push<span class="k">(</span>typ<span class="k">);</span></td></tr><tr><td class="line">204</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">205</td><td class="hits">3</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">")"</span><span class="k">))</span> error<span class="k">(</span><span class="s">"Unterminated union type"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">206</td><td class="hits">3</td><td class="source"> type_suffix<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">207</td><td class="hits">3</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">208</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">209</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">210</td><td class="hits">47</td><td class="source"> <span class="k">var</span> type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">211</td><td class="hits">261</td><td class="source"> <span class="k">return</span> single_type<span class="k">()</span> <span class="k">||</span> union_type<span class="k">();</span></td></tr><tr><td class="line">212</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">213</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">214</td><td class="hits">47</td><td class="source"> <span class="k">var</span> argument <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">215</td><td class="hits">79</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span> optional<span class="k">:</span> <span class="k">false</span><span class="k">,</span> variadic<span class="k">:</span> <span class="k">false</span> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">216</td><td class="hits">79</td><td class="source"> ret<span class="k">.</span>extAttrs <span class="k">=</span> extended_attrs<span class="k">();</span></td></tr><tr class="hit"> <td class="line">217</td><td class="hits">79</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">218</td><td class="hits">79</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"optional"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">219</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>optional <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">220</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr><td class="line">221</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">222</td><td class="hits">79</td><td class="source"> ret<span class="k">.</span>type <span class="k">=</span> type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">223</td><td class="hits">87</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>ret<span class="k">.</span>type<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">224</td><td class="hits">71</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>ret<span class="k">.</span>optional<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">225</td><td class="hits">69</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">226</td><td class="hits">69</td><td class="source"> <span class="k">if</span> <span class="k">(</span>tokens<span class="k">.</span>length <span class="k">>=</span> <span class="s">3</span> <span class="k">&&</span></td></tr><tr><td class="line">227</td><td class="hits"></td><td class="source"> tokens<span class="k">[</span><span class="s">0</span><span class="k">].</span>type <span class="k">===</span> <span class="s">"other"</span> <span class="k">&&</span> tokens<span class="k">[</span><span class="s">0</span><span class="k">].</span>value <span class="k">===</span> <span class="s">"."</span> <span class="k">&&</span></td></tr><tr><td class="line">228</td><td class="hits"></td><td class="source"> tokens<span class="k">[</span><span class="s">1</span><span class="k">].</span>type <span class="k">===</span> <span class="s">"other"</span> <span class="k">&&</span> tokens<span class="k">[</span><span class="s">1</span><span class="k">].</span>value <span class="k">===</span> <span class="s">"."</span> <span class="k">&&</span></td></tr><tr><td class="line">229</td><td class="hits"></td><td class="source"> tokens<span class="k">[</span><span class="s">2</span><span class="k">].</span>type <span class="k">===</span> <span class="s">"other"</span> <span class="k">&&</span> tokens<span class="k">[</span><span class="s">2</span><span class="k">].</span>value <span class="k">===</span> <span class="s">"."</span></td></tr><tr><td class="line">230</td><td class="hits"></td><td class="source"> <span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">231</td><td class="hits">4</td><td class="source"> tokens<span class="k">.</span>shift<span class="k">();</span></td></tr><tr class="hit"> <td class="line">232</td><td class="hits">4</td><td class="source"> tokens<span class="k">.</span>shift<span class="k">();</span></td></tr><tr class="hit"> <td class="line">233</td><td class="hits">4</td><td class="source"> tokens<span class="k">.</span>shift<span class="k">();</span></td></tr><tr class="hit"> <td class="line">234</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>variadic <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr><td class="line">235</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">236</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">237</td><td class="hits">71</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">238</td><td class="hits">71</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name in argument"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">239</td><td class="hits">71</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">240</td><td class="hits">71</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">.</span>optional<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">241</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">242</td><td class="hits">2</td><td class="source"> ret<span class="k">[</span><span class="s">"default"</span><span class="k">]</span> <span class="k">=</span> default_<span class="k">();</span></td></tr><tr><td class="line">243</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">244</td><td class="hits">71</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">245</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">246</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">247</td><td class="hits">47</td><td class="source"> <span class="k">var</span> argument_list <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">248</td><td class="hits">59</td><td class="source"> <span class="k">var</span> arg <span class="k">=</span> argument<span class="k">(),</span> ret <span class="k">=</span> <span class="k">[];</span></td></tr><tr class="hit"> <td class="line">249</td><td class="hits">67</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>arg<span class="k">)</span> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr class="hit"> <td class="line">250</td><td class="hits">51</td><td class="source"> ret<span class="k">.</span>push<span class="k">(</span>arg<span class="k">);</span></td></tr><tr class="hit"> <td class="line">251</td><td class="hits">51</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">252</td><td class="hits">71</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">253</td><td class="hits">122</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">","</span><span class="k">))</span> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr class="hit"> <td class="line">254</td><td class="hits">20</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">255</td><td class="hits">20</td><td class="source"> <span class="k">var</span> nxt <span class="k">=</span> argument<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Trailing comma in arguments list"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">256</td><td class="hits">20</td><td class="source"> ret<span class="k">.</span>push<span class="k">(</span>nxt<span class="k">);</span></td></tr><tr><td class="line">257</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">258</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">259</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">260</td><td class="hits">47</td><td class="source"> <span class="k">var</span> simple_extended_attr <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">261</td><td class="hits">17</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">262</td><td class="hits">17</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">263</td><td class="hits">17</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>name<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">264</td><td class="hits">17</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">265</td><td class="hits"></td><td class="source"> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">266</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"arguments"</span><span class="k">:</span> <span class="k">null</span></td></tr><tr><td class="line">267</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">268</td><td class="hits">17</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">269</td><td class="hits">17</td><td class="source"> <span class="k">var</span> eq <span class="k">=</span> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">270</td><td class="hits">17</td><td class="source"> <span class="k">if</span> <span class="k">(</span>eq<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">271</td><td class="hits">5</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">272</td><td class="hits">5</td><td class="source"> ret<span class="k">.</span>rhs <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">273</td><td class="hits">5</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>ret<span class="k">.</span>rhs<span class="k">)</span> <span class="k">return</span> error<span class="k">(</span><span class="s">"No right hand side to extended attribute assignment"</span><span class="k">);</span></td></tr><tr><td class="line">274</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">275</td><td class="hits">17</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">276</td><td class="hits">17</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"("</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">277</td><td class="hits">2</td><td class="source"> ret<span class="k">[</span><span class="s">"arguments"</span><span class="k">]</span> <span class="k">=</span> argument_list<span class="k">();</span></td></tr><tr class="hit"> <td class="line">278</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">279</td><td class="hits">2</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">")"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unclosed argument in extended attribute"</span><span class="k">);</span></td></tr><tr><td class="line">280</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">281</td><td class="hits">17</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">282</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">283</td><td class="hits"></td><td class="source"> </td></tr><tr><td class="line">284</td><td class="hits"></td><td class="source"> <span class="c">// Note: we parse something simpler than the official syntax. It's all that ever</span></td></tr><tr><td class="line">285</td><td class="hits"></td><td class="source"> <span class="c">// seems to be used</span></td></tr><tr class="hit"> <td class="line">286</td><td class="hits">47</td><td class="source"> <span class="k">var</span> extended_attrs <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">287</td><td class="hits">415</td><td class="source"> <span class="k">var</span> eas <span class="k">=</span> <span class="k">[];</span></td></tr><tr class="hit"> <td class="line">288</td><td class="hits">415</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">289</td><td class="hits">815</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"["</span><span class="k">))</span> <span class="k">return</span> eas<span class="k">;</span></td></tr><tr class="hit"> <td class="line">290</td><td class="hits">15</td><td class="source"> eas<span class="k">[</span><span class="s">0</span><span class="k">]</span> <span class="k">=</span> simple_extended_attr<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Extended attribute with not content"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">291</td><td class="hits">15</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">292</td><td class="hits">15</td><td class="source"> <span class="k">while</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">","</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">293</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">294</td><td class="hits">2</td><td class="source"> eas<span class="k">.</span>push<span class="k">(</span>simple_extended_attr<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Trailing comma in extended attribute"</span><span class="k">));</span></td></tr><tr class="hit"> <td class="line">295</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr><td class="line">296</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">297</td><td class="hits">15</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"]"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No end of extended attribute"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">298</td><td class="hits">15</td><td class="source"> <span class="k">return</span> eas<span class="k">;</span></td></tr><tr><td class="line">299</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">300</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">301</td><td class="hits">47</td><td class="source"> <span class="k">var</span> default_ <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">302</td><td class="hits">11</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">303</td><td class="hits">11</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">304</td><td class="hits">5</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">305</td><td class="hits">5</td><td class="source"> <span class="k">var</span> def <span class="k">=</span> const_value<span class="k">();</span></td></tr><tr class="hit"> <td class="line">306</td><td class="hits">5</td><td class="source"> <span class="k">if</span> <span class="k">(</span><span class="k">typeof</span> def <span class="k">!==</span> <span class="s">"undefined"</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">307</td><td class="hits">3</td><td class="source"> <span class="k">return</span> def<span class="k">;</span></td></tr><tr><td class="line">308</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">309</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">310</td><td class="hits">2</td><td class="source"> <span class="k">var</span> str <span class="k">=</span> consume<span class="k">(</span>STR<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No value for default"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">311</td><td class="hits">2</td><td class="source"> <span class="k">return</span> str<span class="k">;</span></td></tr><tr><td class="line">312</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">313</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">314</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">315</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">316</td><td class="hits">47</td><td class="source"> <span class="k">var</span> const_ <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">317</td><td class="hits">180</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">318</td><td class="hits">348</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"const"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">319</td><td class="hits">12</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span> type<span class="k">:</span> <span class="s">"const"</span><span class="k">,</span> nullable<span class="k">:</span> <span class="k">false</span> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">320</td><td class="hits">12</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">321</td><td class="hits">12</td><td class="source"> <span class="k">var</span> typ <span class="k">=</span> primitive_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">322</td><td class="hits">12</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>typ<span class="k">)</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">323</td><td class="hits">0</td><td class="source"> typ <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No type for const"</span><span class="k">);</span></td></tr><tr class="miss"> <td class="line">324</td><td class="hits">0</td><td class="source"> typ <span class="k">=</span> typ<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">325</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">326</td><td class="hits">12</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> typ<span class="k">;</span></td></tr><tr class="hit"> <td class="line">327</td><td class="hits">12</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">328</td><td class="hits">12</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"?"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">329</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>nullable <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">330</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr><td class="line">331</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">332</td><td class="hits">12</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for const"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">333</td><td class="hits">12</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">334</td><td class="hits">12</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">335</td><td class="hits">12</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No value assignment for const"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">336</td><td class="hits">12</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">337</td><td class="hits">12</td><td class="source"> <span class="k">var</span> cnt <span class="k">=</span> const_value<span class="k">();</span></td></tr><tr class="hit"> <td class="line">338</td><td class="hits">24</td><td class="source"> <span class="k">if</span> <span class="k">(</span><span class="k">typeof</span> cnt <span class="k">!==</span> <span class="s">"undefined"</span><span class="k">)</span> ret<span class="k">.</span>value <span class="k">=</span> cnt<span class="k">;</span></td></tr><tr class="miss"> <td class="line">339</td><td class="hits">0</td><td class="source"> <span class="k">else</span> error<span class="k">(</span><span class="s">"No value for const"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">340</td><td class="hits">12</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">341</td><td class="hits">12</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated const"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">342</td><td class="hits">12</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">343</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">344</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">345</td><td class="hits">47</td><td class="source"> <span class="k">var</span> inheritance <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">346</td><td class="hits">89</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">347</td><td class="hits">89</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">":"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">348</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">349</td><td class="hits">9</td><td class="source"> <span class="k">var</span> inh <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error <span class="k">(</span><span class="s">"No type in inheritance"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">350</td><td class="hits">9</td><td class="source"> <span class="k">return</span> inh<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">351</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">352</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">353</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">354</td><td class="hits">47</td><td class="source"> <span class="k">var</span> operation_rest <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>ret<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">355</td><td class="hits">56</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">356</td><td class="hits">57</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>ret<span class="k">)</span> ret <span class="k">=</span> <span class="k">{}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">357</td><td class="hits">56</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">358</td><td class="hits">56</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name <span class="k">?</span> name<span class="k">.</span>value <span class="k">:</span> <span class="k">null</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">359</td><td class="hits">56</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">360</td><td class="hits">56</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"("</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Invalid operation"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">361</td><td class="hits">56</td><td class="source"> ret<span class="k">[</span><span class="s">"arguments"</span><span class="k">]</span> <span class="k">=</span> argument_list<span class="k">();</span></td></tr><tr class="hit"> <td class="line">362</td><td class="hits">56</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">363</td><td class="hits">56</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">")"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated operation"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">364</td><td class="hits">56</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">365</td><td class="hits">56</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated operation"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">366</td><td class="hits">56</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">367</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">368</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">369</td><td class="hits">47</td><td class="source"> <span class="k">var</span> callback <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">370</td><td class="hits">144</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">371</td><td class="hits">144</td><td class="source"> <span class="k">var</span> ret<span class="k">;</span></td></tr><tr class="hit"> <td class="line">372</td><td class="hits">286</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"callback"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">373</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">374</td><td class="hits">2</td><td class="source"> <span class="k">var</span> tok <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"interface"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">375</td><td class="hits">2</td><td class="source"> <span class="k">if</span> <span class="k">(</span>tok<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">376</td><td class="hits">1</td><td class="source"> tokens<span class="k">.</span>unshift<span class="k">(</span>tok<span class="k">);</span></td></tr><tr class="hit"> <td class="line">377</td><td class="hits">1</td><td class="source"> ret <span class="k">=</span> interface_<span class="k">();</span></td></tr><tr class="hit"> <td class="line">378</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>type <span class="k">=</span> <span class="s">"callback interface"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">379</td><td class="hits">1</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">380</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">381</td><td class="hits">1</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for callback"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">382</td><td class="hits">1</td><td class="source"> ret <span class="k">=</span> <span class="k">{</span> type<span class="k">:</span> <span class="s">"callback"</span><span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">383</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">384</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No assignment in callback"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">385</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">386</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">387</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">388</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"("</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No arguments in callback"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">389</td><td class="hits">1</td><td class="source"> ret<span class="k">[</span><span class="s">"arguments"</span><span class="k">]</span> <span class="k">=</span> argument_list<span class="k">();</span></td></tr><tr class="hit"> <td class="line">390</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">391</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">")"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated callback"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">392</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">393</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated callback"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">394</td><td class="hits">1</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">395</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">396</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">397</td><td class="hits">47</td><td class="source"> <span class="k">var</span> attribute <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">398</td><td class="hits">154</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">399</td><td class="hits">154</td><td class="source"> <span class="k">var</span> grabbed <span class="k">=</span> <span class="k">[]</span></td></tr><tr><td class="line">400</td><td class="hits"></td><td class="source"> <span class="k">,</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">401</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"attribute"</span></td></tr><tr><td class="line">402</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"static"</span><span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">403</td><td class="hits"></td><td class="source"> <span class="k">,</span> stringifier<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">404</td><td class="hits"></td><td class="source"> <span class="k">,</span> inherit<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">405</td><td class="hits"></td><td class="source"> <span class="k">,</span> readonly<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">406</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">407</td><td class="hits">154</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"static"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">408</td><td class="hits">2</td><td class="source"> ret<span class="k">[</span><span class="s">"static"</span><span class="k">]</span> <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">409</td><td class="hits">2</td><td class="source"> grabbed<span class="k">.</span>push<span class="k">(</span>last_token<span class="k">);</span></td></tr><tr><td class="line">410</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">411</td><td class="hits">152</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"stringifier"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">412</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>stringifier <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">413</td><td class="hits">4</td><td class="source"> grabbed<span class="k">.</span>push<span class="k">(</span>last_token<span class="k">);</span></td></tr><tr><td class="line">414</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">415</td><td class="hits">154</td><td class="source"> <span class="k">var</span> w <span class="k">=</span> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">416</td><td class="hits">159</td><td class="source"> <span class="k">if</span> <span class="k">(</span>w<span class="k">)</span> grabbed<span class="k">.</span>push<span class="k">(</span>w<span class="k">);</span></td></tr><tr class="hit"> <td class="line">417</td><td class="hits">154</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"inherit"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">418</td><td class="hits">1</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">[</span><span class="s">"static"</span><span class="k">]</span> <span class="k">||</span> ret<span class="k">.</span>stringifier<span class="k">)</span> error<span class="k">(</span><span class="s">"Cannot have a static or stringifier inherit"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">419</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>inherit <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">420</td><td class="hits">1</td><td class="source"> grabbed<span class="k">.</span>push<span class="k">(</span>last_token<span class="k">);</span></td></tr><tr class="hit"> <td class="line">421</td><td class="hits">1</td><td class="source"> <span class="k">var</span> w <span class="k">=</span> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">422</td><td class="hits">2</td><td class="source"> <span class="k">if</span> <span class="k">(</span>w<span class="k">)</span> grabbed<span class="k">.</span>push<span class="k">(</span>w<span class="k">);</span></td></tr><tr><td class="line">423</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">424</td><td class="hits">154</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"readonly"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">425</td><td class="hits">32</td><td class="source"> ret<span class="k">.</span>readonly <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">426</td><td class="hits">32</td><td class="source"> grabbed<span class="k">.</span>push<span class="k">(</span>last_token<span class="k">);</span></td></tr><tr class="hit"> <td class="line">427</td><td class="hits">32</td><td class="source"> <span class="k">var</span> w <span class="k">=</span> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">428</td><td class="hits">64</td><td class="source"> <span class="k">if</span> <span class="k">(</span>w<span class="k">)</span> grabbed<span class="k">.</span>push<span class="k">(</span>w<span class="k">);</span></td></tr><tr><td class="line">429</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">430</td><td class="hits">154</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"attribute"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">431</td><td class="hits">60</td><td class="source"> tokens <span class="k">=</span> grabbed<span class="k">.</span>concat<span class="k">(</span>tokens<span class="k">);</span></td></tr><tr class="hit"> <td class="line">432</td><td class="hits">60</td><td class="source"> <span class="k">return</span><span class="k">;</span></td></tr><tr><td class="line">433</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">434</td><td class="hits">94</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">435</td><td class="hits">94</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No type in attribute"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">436</td><td class="hits">94</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">.</span>idlType<span class="k">.</span>sequence<span class="k">)</span> error<span class="k">(</span><span class="s">"Attributes cannot accept sequence types"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">437</td><td class="hits">94</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">438</td><td class="hits">94</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name in attribute"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">439</td><td class="hits">94</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">440</td><td class="hits">94</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">441</td><td class="hits">94</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated attribute"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">442</td><td class="hits">94</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">443</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">444</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">445</td><td class="hits">47</td><td class="source"> <span class="k">var</span> return_type <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">446</td><td class="hits">61</td><td class="source"> <span class="k">var</span> typ <span class="k">=</span> type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">447</td><td class="hits">61</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>typ<span class="k">)</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">448</td><td class="hits">0</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"void"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">449</td><td class="hits">0</td><td class="source"> <span class="k">return</span> <span class="s">"void"</span><span class="k">;</span></td></tr><tr><td class="line">450</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="miss"> <td class="line">451</td><td class="hits">0</td><td class="source"> <span class="k">else</span> error<span class="k">(</span><span class="s">"No return type"</span><span class="k">);</span></td></tr><tr><td class="line">452</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">453</td><td class="hits">61</td><td class="source"> <span class="k">return</span> typ<span class="k">;</span></td></tr><tr><td class="line">454</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">455</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">456</td><td class="hits">47</td><td class="source"> <span class="k">var</span> operation <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">457</td><td class="hits">60</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">458</td><td class="hits">60</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">459</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"operation"</span></td></tr><tr><td class="line">460</td><td class="hits"></td><td class="source"> <span class="k">,</span> getter<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">461</td><td class="hits"></td><td class="source"> <span class="k">,</span> setter<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">462</td><td class="hits"></td><td class="source"> <span class="k">,</span> creator<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">463</td><td class="hits"></td><td class="source"> <span class="k">,</span> deleter<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">464</td><td class="hits"></td><td class="source"> <span class="k">,</span> legacycaller<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">465</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"static"</span><span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">466</td><td class="hits"></td><td class="source"> <span class="k">,</span> stringifier<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">467</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">468</td><td class="hits">60</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">469</td><td class="hits">78</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">470</td><td class="hits">87</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"getter"</span><span class="k">))</span> ret<span class="k">.</span>getter <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">471</td><td class="hits">74</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"setter"</span><span class="k">))</span> ret<span class="k">.</span>setter <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">472</td><td class="hits">65</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"creator"</span><span class="k">))</span> ret<span class="k">.</span>creator <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">473</td><td class="hits">65</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"deleter"</span><span class="k">))</span> ret<span class="k">.</span>deleter <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">474</td><td class="hits">62</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"legacycaller"</span><span class="k">))</span> ret<span class="k">.</span>legacycaller <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">475</td><td class="hits">60</td><td class="source"> <span class="k">else</span> <span class="k">break</span><span class="k">;</span></td></tr><tr><td class="line">476</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">477</td><td class="hits">60</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ret<span class="k">.</span>getter <span class="k">||</span> ret<span class="k">.</span>setter <span class="k">||</span> ret<span class="k">.</span>creator <span class="k">||</span> ret<span class="k">.</span>deleter <span class="k">||</span> ret<span class="k">.</span>legacycaller<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">478</td><td class="hits">17</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">479</td><td class="hits">17</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">480</td><td class="hits">17</td><td class="source"> operation_rest<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">481</td><td class="hits">17</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">482</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">483</td><td class="hits">43</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"static"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">484</td><td class="hits">1</td><td class="source"> ret<span class="k">[</span><span class="s">"static"</span><span class="k">]</span> <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">485</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">486</td><td class="hits">1</td><td class="source"> operation_rest<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">487</td><td class="hits">1</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">488</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">489</td><td class="hits">42</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"stringifier"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">490</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>stringifier <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">491</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">492</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">))</span> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr class="hit"> <td class="line">493</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">494</td><td class="hits">2</td><td class="source"> operation_rest<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">495</td><td class="hits">2</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">496</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">497</td><td class="hits">39</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">498</td><td class="hits">39</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">499</td><td class="hits">39</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"iterator"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">500</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">501</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>type <span class="k">=</span> <span class="s">"iterator"</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">502</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"object"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">503</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>iteratorObject <span class="k">=</span> <span class="s">"object"</span><span class="k">;</span></td></tr><tr><td class="line">504</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">505</td><td class="hits">3</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">506</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">507</td><td class="hits">2</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No right hand side in iterator"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">508</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>iteratorObject <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">509</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">510</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">511</td><td class="hits">4</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated iterator"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">512</td><td class="hits">4</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">513</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">514</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">515</td><td class="hits">35</td><td class="source"> operation_rest<span class="k">(</span>ret<span class="k">);</span></td></tr><tr class="hit"> <td class="line">516</td><td class="hits">35</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">517</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">518</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">519</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">520</td><td class="hits">47</td><td class="source"> <span class="k">var</span> identifiers <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>arr<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">521</td><td class="hits">5</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">522</td><td class="hits">11</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">523</td><td class="hits">11</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">","</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">524</td><td class="hits">6</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">525</td><td class="hits">6</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Trailing comma in identifiers list"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">526</td><td class="hits">6</td><td class="source"> arr<span class="k">.</span>push<span class="k">(</span>name<span class="k">.</span>value<span class="k">);</span></td></tr><tr><td class="line">527</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">528</td><td class="hits">5</td><td class="source"> <span class="k">else</span> <span class="k">break</span><span class="k">;</span></td></tr><tr><td class="line">529</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">530</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">531</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">532</td><td class="hits">47</td><td class="source"> <span class="k">var</span> serialiser <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">533</td><td class="hits">164</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">534</td><td class="hits">318</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"serializer"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">535</td><td class="hits">10</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span> type<span class="k">:</span> <span class="s">"serializer"</span> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">536</td><td class="hits">10</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">537</td><td class="hits">10</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"="</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">538</td><td class="hits">8</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">539</td><td class="hits">8</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"{"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">540</td><td class="hits">5</td><td class="source"> ret<span class="k">.</span>patternMap <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">541</td><td class="hits">5</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">542</td><td class="hits">5</td><td class="source"> <span class="k">var</span> id <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">543</td><td class="hits">5</td><td class="source"> <span class="k">if</span> <span class="k">(</span>id <span class="k">&&</span> id<span class="k">.</span>value <span class="k">===</span> <span class="s">"getter"</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">544</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[</span><span class="s">"getter"</span><span class="k">];</span></td></tr><tr><td class="line">545</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">546</td><td class="hits">4</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>id <span class="k">&&</span> id<span class="k">.</span>value <span class="k">===</span> <span class="s">"inherit"</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">547</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[</span><span class="s">"inherit"</span><span class="k">];</span></td></tr><tr class="hit"> <td class="line">548</td><td class="hits">2</td><td class="source"> identifiers<span class="k">(</span>ret<span class="k">.</span>names<span class="k">);</span></td></tr><tr><td class="line">549</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">550</td><td class="hits">2</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>id<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">551</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[</span>id<span class="k">.</span>value<span class="k">];</span></td></tr><tr class="hit"> <td class="line">552</td><td class="hits">2</td><td class="source"> identifiers<span class="k">(</span>ret<span class="k">.</span>names<span class="k">);</span></td></tr><tr><td class="line">553</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">554</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">555</td><td class="hits">0</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[];</span></td></tr><tr><td class="line">556</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">557</td><td class="hits">5</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">558</td><td class="hits">5</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"}"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated serializer pattern map"</span><span class="k">);</span></td></tr><tr><td class="line">559</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">560</td><td class="hits">3</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"["</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">561</td><td class="hits">2</td><td class="source"> ret<span class="k">.</span>patternList <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">562</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">563</td><td class="hits">2</td><td class="source"> <span class="k">var</span> id <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">564</td><td class="hits">2</td><td class="source"> <span class="k">if</span> <span class="k">(</span>id <span class="k">&&</span> id<span class="k">.</span>value <span class="k">===</span> <span class="s">"getter"</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">565</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[</span><span class="s">"getter"</span><span class="k">];</span></td></tr><tr><td class="line">566</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">567</td><td class="hits">1</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>id<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">568</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[</span>id<span class="k">.</span>value<span class="k">];</span></td></tr><tr class="hit"> <td class="line">569</td><td class="hits">1</td><td class="source"> identifiers<span class="k">(</span>ret<span class="k">.</span>names<span class="k">);</span></td></tr><tr><td class="line">570</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">571</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">572</td><td class="hits">0</td><td class="source"> ret<span class="k">.</span>names <span class="k">=</span> <span class="k">[];</span></td></tr><tr><td class="line">573</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">574</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">575</td><td class="hits">2</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"]"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated serializer pattern list"</span><span class="k">);</span></td></tr><tr><td class="line">576</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">577</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">578</td><td class="hits">1</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Invalid serializer"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">579</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr><td class="line">580</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">581</td><td class="hits">8</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">582</td><td class="hits">8</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated serializer"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">583</td><td class="hits">8</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">584</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">585</td><td class="hits">2</td><td class="source"> <span class="k">else</span> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr><td class="line">586</td><td class="hits"></td><td class="source"> <span class="c">// noop, just parsing</span></td></tr><tr><td class="line">587</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">588</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">589</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> return_type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">590</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">591</td><td class="hits">1</td><td class="source"> ret<span class="k">.</span>operation <span class="k">=</span> operation_rest<span class="k">();</span></td></tr><tr><td class="line">592</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">593</td><td class="hits">2</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">594</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">595</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">596</td><td class="hits">47</td><td class="source"> <span class="k">var</span> interface_ <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>isPartial<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">597</td><td class="hits">144</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">598</td><td class="hits">210</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"interface"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">599</td><td class="hits">78</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">600</td><td class="hits">78</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for interface"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">601</td><td class="hits">78</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">602</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"interface"</span></td></tr><tr><td class="line">603</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">604</td><td class="hits"></td><td class="source"> <span class="k">,</span> partial<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">605</td><td class="hits"></td><td class="source"> <span class="k">,</span> members<span class="k">:</span> <span class="k">[]</span></td></tr><tr><td class="line">606</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">607</td><td class="hits">155</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>isPartial<span class="k">)</span> ret<span class="k">.</span>inheritance <span class="k">=</span> inheritance<span class="k">()</span> <span class="k">||</span> <span class="k">null</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">608</td><td class="hits">78</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">609</td><td class="hits">78</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"{"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Bodyless interface"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">610</td><td class="hits">78</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">611</td><td class="hits">251</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">612</td><td class="hits">251</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"}"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">613</td><td class="hits">78</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">614</td><td class="hits">78</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Missing semicolon after interface"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">615</td><td class="hits">78</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">616</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">617</td><td class="hits">173</td><td class="source"> <span class="k">var</span> ea <span class="k">=</span> extended_attrs<span class="k">();</span></td></tr><tr class="hit"> <td class="line">618</td><td class="hits">173</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">619</td><td class="hits">173</td><td class="source"> <span class="k">var</span> cnt <span class="k">=</span> const_<span class="k">();</span></td></tr><tr class="hit"> <td class="line">620</td><td class="hits">173</td><td class="source"> <span class="k">if</span> <span class="k">(</span>cnt<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">621</td><td class="hits">9</td><td class="source"> cnt<span class="k">.</span>extAttrs <span class="k">=</span> ea<span class="k">;</span></td></tr><tr class="hit"> <td class="line">622</td><td class="hits">9</td><td class="source"> ret<span class="k">.</span>members<span class="k">.</span>push<span class="k">(</span>cnt<span class="k">);</span></td></tr><tr class="hit"> <td class="line">623</td><td class="hits">9</td><td class="source"> <span class="k">continue</span><span class="k">;</span></td></tr><tr><td class="line">624</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">625</td><td class="hits">164</td><td class="source"> <span class="k">var</span> mem <span class="k">=</span> serialiser<span class="k">()</span> <span class="k">||</span> attribute<span class="k">()</span> <span class="k">||</span> operation<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unknown member"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">626</td><td class="hits">164</td><td class="source"> mem<span class="k">.</span>extAttrs <span class="k">=</span> ea<span class="k">;</span></td></tr><tr class="hit"> <td class="line">627</td><td class="hits">164</td><td class="source"> ret<span class="k">.</span>members<span class="k">.</span>push<span class="k">(</span>mem<span class="k">);</span></td></tr><tr><td class="line">628</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">629</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">630</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">631</td><td class="hits">47</td><td class="source"> <span class="k">var</span> partial <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">632</td><td class="hits">66</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">633</td><td class="hits">130</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"partial"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">634</td><td class="hits">2</td><td class="source"> <span class="k">var</span> thing <span class="k">=</span> dictionary<span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">||</span> interface_<span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Partial doesn't apply to anything"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">635</td><td class="hits">2</td><td class="source"> thing<span class="k">.</span>partial <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">636</td><td class="hits">2</td><td class="source"> <span class="k">return</span> thing<span class="k">;</span></td></tr><tr><td class="line">637</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">638</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">639</td><td class="hits">47</td><td class="source"> <span class="k">var</span> dictionary <span class="k">=</span> <span class="k">function</span> <span class="k">(</span>isPartial<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">640</td><td class="hits">66</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">641</td><td class="hits">128</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"dictionary"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">642</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">643</td><td class="hits">4</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for dictionary"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">644</td><td class="hits">4</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">645</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"dictionary"</span></td></tr><tr><td class="line">646</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">647</td><td class="hits"></td><td class="source"> <span class="k">,</span> partial<span class="k">:</span> <span class="k">false</span></td></tr><tr><td class="line">648</td><td class="hits"></td><td class="source"> <span class="k">,</span> members<span class="k">:</span> <span class="k">[]</span></td></tr><tr><td class="line">649</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">650</td><td class="hits">7</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>isPartial<span class="k">)</span> ret<span class="k">.</span>inheritance <span class="k">=</span> inheritance<span class="k">()</span> <span class="k">||</span> <span class="k">null</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">651</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">652</td><td class="hits">4</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"{"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Bodyless dictionary"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">653</td><td class="hits">4</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">654</td><td class="hits">13</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">655</td><td class="hits">13</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"}"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">656</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">657</td><td class="hits">4</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Missing semicolon after dictionary"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">658</td><td class="hits">4</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">659</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">660</td><td class="hits">9</td><td class="source"> <span class="k">var</span> ea <span class="k">=</span> extended_attrs<span class="k">();</span></td></tr><tr class="hit"> <td class="line">661</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">662</td><td class="hits">9</td><td class="source"> <span class="k">var</span> typ <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No type for dictionary member"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">663</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">664</td><td class="hits">9</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for dictionary member"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">665</td><td class="hits">9</td><td class="source"> ret<span class="k">.</span>members<span class="k">.</span>push<span class="k">(</span><span class="k">{</span></td></tr><tr><td class="line">666</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"field"</span></td></tr><tr><td class="line">667</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">668</td><td class="hits"></td><td class="source"> <span class="k">,</span> idlType<span class="k">:</span> typ</td></tr><tr><td class="line">669</td><td class="hits"></td><td class="source"> <span class="k">,</span> extAttrs<span class="k">:</span> ea</td></tr><tr><td class="line">670</td><td class="hits"></td><td class="source"> <span class="k">,</span> <span class="s">"default"</span><span class="k">:</span> default_<span class="k">()</span></td></tr><tr><td class="line">671</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">672</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">673</td><td class="hits">9</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated dictionary member"</span><span class="k">);</span></td></tr><tr><td class="line">674</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">675</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">676</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">677</td><td class="hits">47</td><td class="source"> <span class="k">var</span> exception <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">678</td><td class="hits">61</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">679</td><td class="hits">113</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"exception"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">680</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">681</td><td class="hits">9</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for exception"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">682</td><td class="hits">9</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">683</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"exception"</span></td></tr><tr><td class="line">684</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">685</td><td class="hits"></td><td class="source"> <span class="k">,</span> members<span class="k">:</span> <span class="k">[]</span></td></tr><tr><td class="line">686</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">687</td><td class="hits">9</td><td class="source"> ret<span class="k">.</span>inheritance <span class="k">=</span> inheritance<span class="k">()</span> <span class="k">||</span> <span class="k">null</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">688</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">689</td><td class="hits">9</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"{"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Bodyless exception"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">690</td><td class="hits">9</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">691</td><td class="hits">16</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">692</td><td class="hits">16</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"}"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">693</td><td class="hits">9</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">694</td><td class="hits">9</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Missing semicolon after exception"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">695</td><td class="hits">9</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">696</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">697</td><td class="hits">7</td><td class="source"> <span class="k">var</span> ea <span class="k">=</span> extended_attrs<span class="k">();</span></td></tr><tr class="hit"> <td class="line">698</td><td class="hits">7</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">699</td><td class="hits">7</td><td class="source"> <span class="k">var</span> cnt <span class="k">=</span> const_<span class="k">();</span></td></tr><tr class="hit"> <td class="line">700</td><td class="hits">7</td><td class="source"> <span class="k">if</span> <span class="k">(</span>cnt<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">701</td><td class="hits">3</td><td class="source"> cnt<span class="k">.</span>extAttrs <span class="k">=</span> ea<span class="k">;</span></td></tr><tr class="hit"> <td class="line">702</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>members<span class="k">.</span>push<span class="k">(</span>cnt<span class="k">);</span></td></tr><tr><td class="line">703</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">704</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">705</td><td class="hits">4</td><td class="source"> <span class="k">var</span> typ <span class="k">=</span> type<span class="k">();</span></td></tr><tr class="hit"> <td class="line">706</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">707</td><td class="hits">4</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">708</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">709</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>typ <span class="k">||</span> <span class="k">!</span>name <span class="k">||</span> <span class="k">!</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">))</span> error<span class="k">(</span><span class="s">"Unknown member in exception body"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">710</td><td class="hits">4</td><td class="source"> ret<span class="k">.</span>members<span class="k">.</span>push<span class="k">(</span><span class="k">{</span></td></tr><tr><td class="line">711</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"field"</span></td></tr><tr><td class="line">712</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">713</td><td class="hits"></td><td class="source"> <span class="k">,</span> idlType<span class="k">:</span> typ</td></tr><tr><td class="line">714</td><td class="hits"></td><td class="source"> <span class="k">,</span> extAttrs<span class="k">:</span> ea</td></tr><tr><td class="line">715</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">);</span></td></tr><tr><td class="line">716</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">717</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">718</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">719</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">720</td><td class="hits">47</td><td class="source"> <span class="k">var</span> enum_ <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">721</td><td class="hits">52</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">722</td><td class="hits">103</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"enum"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">723</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">724</td><td class="hits">1</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name for enum"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">725</td><td class="hits">1</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">726</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"enum"</span></td></tr><tr><td class="line">727</td><td class="hits"></td><td class="source"> <span class="k">,</span> name<span class="k">:</span> name<span class="k">.</span>value</td></tr><tr><td class="line">728</td><td class="hits"></td><td class="source"> <span class="k">,</span> values<span class="k">:</span> <span class="k">[]</span></td></tr><tr><td class="line">729</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">730</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">731</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"{"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No curly for enum"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">732</td><td class="hits">1</td><td class="source"> <span class="k">var</span> saw_comma <span class="k">=</span> <span class="k">false</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">733</td><td class="hits">1</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">734</td><td class="hits">4</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">735</td><td class="hits">4</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">"}"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">736</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">737</td><td class="hits">1</td><td class="source"> <span class="k">if</span> <span class="k">(</span>saw_comma<span class="k">)</span> error<span class="k">(</span><span class="s">"Trailing comma in enum"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">738</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No semicolon after enum"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">739</td><td class="hits">1</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">740</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">741</td><td class="hits">3</td><td class="source"> <span class="k">var</span> val <span class="k">=</span> consume<span class="k">(</span>STR<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unexpected value in enum"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">742</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>values<span class="k">.</span>push<span class="k">(</span>val<span class="k">.</span>value<span class="k">.</span>replace<span class="k">(</span><span class="s">/"/g</span><span class="k">,</span> <span class="s">""</span><span class="k">));</span></td></tr><tr class="hit"> <td class="line">743</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">744</td><td class="hits">3</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">","</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">745</td><td class="hits">2</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">746</td><td class="hits">2</td><td class="source"> saw_comma <span class="k">=</span> <span class="k">true</span><span class="k">;</span></td></tr><tr><td class="line">747</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">748</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">749</td><td class="hits">1</td><td class="source"> saw_comma <span class="k">=</span> <span class="k">false</span><span class="k">;</span></td></tr><tr><td class="line">750</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">751</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">752</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">753</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">754</td><td class="hits">47</td><td class="source"> <span class="k">var</span> typedef <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">755</td><td class="hits">51</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">756</td><td class="hits">99</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"typedef"</span><span class="k">))</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">757</td><td class="hits">3</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">758</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"typedef"</span></td></tr><tr><td class="line">759</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">760</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">761</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>extAttrs <span class="k">=</span> extended_attrs<span class="k">();</span></td></tr><tr class="hit"> <td class="line">762</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">763</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>idlType <span class="k">=</span> type<span class="k">()</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No type in typedef"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">764</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">765</td><td class="hits">3</td><td class="source"> <span class="k">var</span> name <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No name in typedef"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">766</td><td class="hits">3</td><td class="source"> ret<span class="k">.</span>name <span class="k">=</span> name<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">767</td><td class="hits">3</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">768</td><td class="hits">3</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Unterminated typedef"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">769</td><td class="hits">3</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">770</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">771</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">772</td><td class="hits">47</td><td class="source"> <span class="k">var</span> implements_ <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">773</td><td class="hits">48</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">774</td><td class="hits">48</td><td class="source"> <span class="k">var</span> target <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">);</span></td></tr><tr class="hit"> <td class="line">775</td><td class="hits">95</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>target<span class="k">)</span> <span class="k">return</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">776</td><td class="hits">1</td><td class="source"> <span class="k">var</span> w <span class="k">=</span> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">777</td><td class="hits">1</td><td class="source"> <span class="k">if</span> <span class="k">(</span>consume<span class="k">(</span>ID<span class="k">,</span> <span class="s">"implements"</span><span class="k">))</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">778</td><td class="hits">1</td><td class="source"> <span class="k">var</span> ret <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">779</td><td class="hits"></td><td class="source"> type<span class="k">:</span> <span class="s">"implements"</span></td></tr><tr><td class="line">780</td><td class="hits"></td><td class="source"> <span class="k">,</span> target<span class="k">:</span> target<span class="k">.</span>value</td></tr><tr><td class="line">781</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">782</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">783</td><td class="hits">1</td><td class="source"> <span class="k">var</span> imp <span class="k">=</span> consume<span class="k">(</span>ID<span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"Incomplete implements statement"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">784</td><td class="hits">1</td><td class="source"> ret<span class="k">[</span><span class="s">"implements"</span><span class="k">]</span> <span class="k">=</span> imp<span class="k">.</span>value<span class="k">;</span></td></tr><tr class="hit"> <td class="line">785</td><td class="hits">1</td><td class="source"> all_ws<span class="k">();</span></td></tr><tr class="hit"> <td class="line">786</td><td class="hits">1</td><td class="source"> consume<span class="k">(</span>OTHER<span class="k">,</span> <span class="s">";"</span><span class="k">)</span> <span class="k">||</span> error<span class="k">(</span><span class="s">"No terminating ; for implements statement"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">787</td><td class="hits">1</td><td class="source"> <span class="k">return</span> ret<span class="k">;</span></td></tr><tr><td class="line">788</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">789</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr><td class="line">790</td><td class="hits"></td><td class="source"> <span class="c">// rollback</span></td></tr><tr class="miss"> <td class="line">791</td><td class="hits">0</td><td class="source"> tokens<span class="k">.</span>unshift<span class="k">(</span>w<span class="k">);</span></td></tr><tr class="miss"> <td class="line">792</td><td class="hits">0</td><td class="source"> tokens<span class="k">.</span>unshift<span class="k">(</span>target<span class="k">);</span></td></tr><tr><td class="line">793</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">794</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">795</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">796</td><td class="hits">47</td><td class="source"> <span class="k">var</span> definition <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">797</td><td class="hits">144</td><td class="source"> <span class="k">return</span> callback<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">798</td><td class="hits"></td><td class="source"> interface_<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">799</td><td class="hits"></td><td class="source"> partial<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">800</td><td class="hits"></td><td class="source"> dictionary<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">801</td><td class="hits"></td><td class="source"> exception<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">802</td><td class="hits"></td><td class="source"> enum_<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">803</td><td class="hits"></td><td class="source"> typedef<span class="k">()</span> <span class="k">||</span></td></tr><tr><td class="line">804</td><td class="hits"></td><td class="source"> implements_<span class="k">()</span></td></tr><tr><td class="line">805</td><td class="hits"></td><td class="source"> <span class="k">;</span></td></tr><tr><td class="line">806</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">807</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">808</td><td class="hits">47</td><td class="source"> <span class="k">var</span> definitions <span class="k">=</span> <span class="k">function</span> <span class="k">()</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">809</td><td class="hits">47</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>tokens<span class="k">.</span>length<span class="k">)</span> <span class="k">return</span> <span class="k">[];</span></td></tr><tr class="hit"> <td class="line">810</td><td class="hits">47</td><td class="source"> <span class="k">var</span> defs <span class="k">=</span> <span class="k">[];</span></td></tr><tr class="hit"> <td class="line">811</td><td class="hits">47</td><td class="source"> <span class="k">while</span> <span class="k">(</span><span class="k">true</span><span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">812</td><td class="hits">144</td><td class="source"> <span class="k">var</span> ea <span class="k">=</span> extended_attrs<span class="k">()</span></td></tr><tr><td class="line">813</td><td class="hits"></td><td class="source"> <span class="k">,</span> def <span class="k">=</span> definition<span class="k">();</span></td></tr><tr class="hit"> <td class="line">814</td><td class="hits">144</td><td class="source"> <span class="k">if</span> <span class="k">(!</span>def<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">815</td><td class="hits">47</td><td class="source"> <span class="k">if</span> <span class="k">(</span>ea<span class="k">.</span>length<span class="k">)</span> error<span class="k">(</span><span class="s">"Stray extended attributes"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">816</td><td class="hits">47</td><td class="source"> <span class="k">break</span><span class="k">;</span></td></tr><tr><td class="line">817</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">818</td><td class="hits">97</td><td class="source"> def<span class="k">.</span>extAttrs <span class="k">=</span> ea<span class="k">;</span></td></tr><tr class="hit"> <td class="line">819</td><td class="hits">97</td><td class="source"> defs<span class="k">.</span>push<span class="k">(</span>def<span class="k">);</span></td></tr><tr><td class="line">820</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr class="hit"> <td class="line">821</td><td class="hits">47</td><td class="source"> <span class="k">return</span> defs<span class="k">;</span></td></tr><tr><td class="line">822</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">823</td><td class="hits">47</td><td class="source"> <span class="k">var</span> res <span class="k">=</span> definitions<span class="k">();</span></td></tr><tr class="hit"> <td class="line">824</td><td class="hits">47</td><td class="source"> <span class="k">if</span> <span class="k">(</span>tokens<span class="k">.</span>length<span class="k">)</span> error<span class="k">(</span><span class="s">"Unrecognised tokens"</span><span class="k">);</span></td></tr><tr class="hit"> <td class="line">825</td><td class="hits">47</td><td class="source"> <span class="k">return</span> res<span class="k">;</span></td></tr><tr><td class="line">826</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr><td class="line">827</td><td class="hits"></td><td class="source"> </td></tr><tr class="hit"> <td class="line">828</td><td class="hits">1</td><td class="source"> <span class="k">var</span> obj <span class="k">=</span> <span class="k">{</span></td></tr><tr><td class="line">829</td><td class="hits"></td><td class="source"> parse<span class="k">:</span> <span class="k">function</span> <span class="k">(</span>str<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">830</td><td class="hits">47</td><td class="source"> <span class="k">var</span> tokens <span class="k">=</span> tokenise<span class="k">(</span>str<span class="k">);</span></td></tr><tr><td class="line">831</td><td class="hits"></td><td class="source"> <span class="c">// console.log(tokens);</span></td></tr><tr class="hit"> <td class="line">832</td><td class="hits">47</td><td class="source"> <span class="k">return</span> parse<span class="k">(</span>tokens<span class="k">);</span></td></tr><tr><td class="line">833</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">834</td><td class="hits"></td><td class="source"> <span class="k">}</span><span class="k">;</span></td></tr><tr class="hit"> <td class="line">835</td><td class="hits">1</td><td class="source"> <span class="k">if</span> <span class="k">(</span><span class="k">typeof</span> module <span class="k">!==</span> <span class="s">"undefined"</span> <span class="k">&&</span> module<span class="k">.</span>exports<span class="k">)</span> <span class="k">{</span></td></tr><tr class="hit"> <td class="line">836</td><td class="hits">1</td><td class="source"> module<span class="k">.</span>exports <span class="k">=</span> obj<span class="k">;</span></td></tr><tr><td class="line">837</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">838</td><td class="hits"></td><td class="source"> <span class="k">else</span> <span class="k">{</span></td></tr><tr class="miss"> <td class="line">839</td><td class="hits">0</td><td class="source"> window<span class="k">.</span>WebIDL2 <span class="k">=</span> obj<span class="k">;</span></td></tr><tr><td class="line">840</td><td class="hits"></td><td class="source"> <span class="k">}</span></td></tr><tr><td class="line">841</td><td class="hits"></td><td class="source"><span class="k">}</span><span class="k">());</span></td></tr></tbody></table></div></div></div></body></html>
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/index.js b/third_party/blink/web_tests/external/wpt/resources/webidl2/index.js deleted file mode 100644 index 09f9eb46..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/index.js +++ /dev/null
@@ -1 +0,0 @@ -module.exports = require("./lib/webidl2.js");
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js b/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js index ef519c0..d909c30 100644 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js +++ b/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js
@@ -1,970 +1,2036 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["WebIDL2"] = factory(); + else + root["WebIDL2"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + "use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _lib_webidl2_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return _lib_webidl2_js__WEBPACK_IMPORTED_MODULE_0__["parse"]; }); -(() => { - // These regular expressions use the sticky flag so they will only match at - // the current location (ie. the offset of lastIndex). - const tokenRe = { - // This expression uses a lookahead assertion to catch false matches - // against integers early. - "float": /-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y, - "integer": /-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y, - "identifier": /_?[A-Za-z][0-9A-Z_a-z-]*/y, - "string": /"[^"]*"/y, - "whitespace": /[\t\n\r ]+/y, - "comment": /((\/(\/.*|\*([^*]|\*[^\/])*\*\/)[\t\n\r ]*)+)/y, - "other": /[^\t\n\r 0-9A-Za-z]/y - }; +/* harmony import */ var _lib_writer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "write", function() { return _lib_writer_js__WEBPACK_IMPORTED_MODULE_1__["write"]; }); - const stringTypes = [ - "ByteString", - "DOMString", - "USVString" - ]; +/* harmony import */ var _lib_validator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "validate", function() { return _lib_validator_js__WEBPACK_IMPORTED_MODULE_2__["validate"]; }); - const argumentNameKeywords = [ - "attribute", - "callback", - "const", - "deleter", - "dictionary", - "enum", - "getter", - "includes", - "inherit", - "interface", - "iterable", - "maplike", - "namespace", - "partial", - "required", - "setlike", - "setter", - "static", - "stringifier", - "typedef", - "unrestricted" - ]; - const nonRegexTerminals = [ - "FrozenArray", - "Infinity", - "NaN", - "Promise", - "boolean", - "byte", - "double", - "false", - "float", - "implements", - "legacyiterable", - "long", - "mixin", - "null", - "octet", - "optional", - "or", - "readonly", - "record", - "sequence", - "short", - "true", - "unsigned", - "void" - ].concat(argumentNameKeywords, stringTypes); - const punctuations = [ - "(", - ")", - ",", - "-Infinity", - "...", - ":", - ";", - "<", - "=", - ">", - "?", - "[", - "]", - "{", - "}" - ]; - function tokenise(str) { - const tokens = []; - let lastIndex = 0; - let trivia = ""; - while (lastIndex < str.length) { - const nextChar = str.charAt(lastIndex); - let result = -1; - if (/[\t\n\r ]/.test(nextChar)) { - result = attemptTokenMatch("whitespace", { noFlushTrivia: true }); - } else if (nextChar === '/') { - result = attemptTokenMatch("comment", { noFlushTrivia: true }); + +/***/ }), +/* 1 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return parse; }); +/* harmony import */ var _productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var _tokeniser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3); +/* harmony import */ var _productions_array_base_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5); +/* harmony import */ var _productions_base_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6); +/* harmony import */ var _productions_token_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7); +/* harmony import */ var _productions_default_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8); +/* harmony import */ var _productions_enum_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9); +/* harmony import */ var _productions_includes_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(10); + + + + + + + + + + + +/** + * @param {Tokeniser} tokeniser + * @param {object} options + * @param {boolean} [options.concrete] + */ +function parseByTokens(tokeniser, options) { + const source = tokeniser.source; + + const DECIMAL = "decimal"; + const INT = "integer"; + const ID = "identifier"; + const STR = "string"; + + function error(str) { + tokeniser.error(str); + } + + function probe(type) { + return tokeniser.probe(type); + } + + function consume(...candidates) { + return tokeniser.consume(...candidates); + } + + function unconsume(position) { + return tokeniser.unconsume(position); + } + + function integer_type() { + const prefix = consume("unsigned"); + const base = consume("short", "long"); + if (base) { + const postfix = consume("long"); + return new Type({ source, tokens: { prefix, base, postfix } }); + } + if (prefix) error("Failed to parse integer type"); + } + + function float_type() { + const prefix = consume("unrestricted"); + const base = consume("float", "double"); + if (base) { + return new Type({ source, tokens: { prefix, base } }); + } + if (prefix) error("Failed to parse float type"); + } + + function primitive_type() { + const num_type = integer_type() || float_type(); + if (num_type) return num_type; + const base = consume("boolean", "byte", "octet"); + if (base) { + return new Type({ source, tokens: { base } }); + } + } + + function type_suffix(obj) { + const nullable = consume("?"); + if (nullable) { + obj.tokens.nullable = nullable; + } + if (probe("?")) error("Can't nullable more than once"); + } + + class Type extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + constructor({ source, tokens }) { + super({ source, tokens }); + Object.defineProperty(this, "subtype", { value: [] }); + this.extAttrs = []; + } + + get generic() { + return ""; + } + get nullable() { + return !!this.tokens.nullable; + } + get union() { + return false; + } + get idlType() { + if (this.subtype.length) { + return this.subtype; + } + // Adding prefixes/postfixes for "unrestricted float", etc. + const name = [ + this.tokens.prefix, + this.tokens.base, + this.tokens.postfix + ].filter(t => t).map(t => t.value).join(" "); + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(name); + } + } + + class GenericType extends Type { + static parse(typeName) { + const base = consume("FrozenArray", "Promise", "sequence", "record"); + if (!base) { + return; + } + const ret = new GenericType({ source, tokens: { base } }); + ret.tokens.open = consume("<") || error(`No opening bracket after ${base.type}`); + switch (base.type) { + case "Promise": { + if (probe("[")) error("Promise type cannot have extended attribute"); + const subtype = return_type(typeName) || error("Missing Promise subtype"); + ret.subtype.push(subtype); + break; + } + case "sequence": + case "FrozenArray": { + const subtype = type_with_extended_attributes(typeName) || error(`Missing ${base.type} subtype`); + ret.subtype.push(subtype); + break; + } + case "record": { + if (probe("[")) error("Record key cannot have extended attribute"); + const keyType = consume(..._tokeniser_js__WEBPACK_IMPORTED_MODULE_1__["stringTypes"]) || error(`Record key must be one of: ${_tokeniser_js__WEBPACK_IMPORTED_MODULE_1__["stringTypes"].join(", ")}`); + const keyIdlType = new Type({ source, tokens: { base: keyType }}); + keyIdlType.tokens.separator = consume(",") || error("Missing comma after record key type"); + keyIdlType.type = typeName; + const valueType = type_with_extended_attributes(typeName) || error("Error parsing generic type record"); + ret.subtype.push(keyIdlType, valueType); + break; + } + } + if (!ret.idlType) error(`Error parsing generic type ${base.type}`); + ret.tokens.close = consume(">") || error(`Missing closing bracket after ${base.type}`); + return ret; + } + + get generic() { + return this.tokens.base.value; + } + } + + function single_type(typeName) { + let ret = GenericType.parse(typeName) || primitive_type(); + if (!ret) { + const base = consume(ID, ..._tokeniser_js__WEBPACK_IMPORTED_MODULE_1__["stringTypes"]); + if (!base) { + return; + } + ret = new Type({ source, tokens: { base } }); + if (probe("<")) error(`Unsupported generic type ${base.value}`); + } + if (ret.generic === "Promise" && probe("?")) { + error("Promise type cannot be nullable"); + } + ret.type = typeName || null; + type_suffix(ret); + if (ret.nullable && ret.idlType === "any") error("Type `any` cannot be made nullable"); + return ret; + } + + class UnionType extends Type { + static parse(type) { + const tokens = {}; + tokens.open = consume("("); + if (!tokens.open) return; + const ret = new UnionType({ source, tokens }); + ret.type = type || null; + while (true) { + const typ = type_with_extended_attributes() || error("No type after open parenthesis or 'or' in union type"); + if (typ.idlType === "any") error("Type `any` cannot be included in a union type"); + ret.subtype.push(typ); + const or = consume("or"); + if (or) { + typ.tokens.separator = or; + } + else break; + } + if (ret.idlType.length < 2) { + error("At least two types are expected in a union type but found less"); + } + tokens.close = consume(")") || error("Unterminated union type"); + type_suffix(ret); + return ret; + } + + get union() { + return true; + } + } + + function type(typeName) { + return single_type(typeName) || UnionType.parse(typeName); + } + + function type_with_extended_attributes(typeName) { + const extAttrs = ExtendedAttributes.parse(); + const ret = type(typeName); + if (ret) ret.extAttrs = extAttrs; + return ret; + } + + class Argument extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const start_position = tokeniser.position; + const tokens = {}; + const ret = new Argument({ source, tokens }); + ret.extAttrs = ExtendedAttributes.parse(); + tokens.optional = consume("optional"); + ret.idlType = type_with_extended_attributes("argument-type"); + if (!ret.idlType) { + return unconsume(start_position); + } + if (!tokens.optional) { + tokens.variadic = consume("..."); + } + tokens.name = consume(ID, ..._tokeniser_js__WEBPACK_IMPORTED_MODULE_1__["argumentNameKeywords"]); + if (!tokens.name) { + return unconsume(start_position); + } + ret.default = tokens.optional ? _productions_default_js__WEBPACK_IMPORTED_MODULE_5__["Default"].parse(tokeniser) : null; + return ret; + } + + get optional() { + return !!this.tokens.optional; + } + get variadic() { + return !!this.tokens.variadic; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + } + + function argument_list() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["list"])(tokeniser, { parser: Argument.parse, listName: "arguments list" }); + } + + function identifiers() { + const ids = Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["list"])(tokeniser, { parser: _productions_token_js__WEBPACK_IMPORTED_MODULE_4__["Token"].parser(tokeniser, ID), listName: "identifier list" }); + if (!ids.length) { + error("Expected identifiers but none found"); + } + return ids; + } + + class ExtendedAttributeParameters extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const tokens = { assign: consume("=") }; + const ret = new ExtendedAttributeParameters({ source, tokens }); + if (tokens.assign) { + tokens.secondaryName = consume(ID, DECIMAL, INT, STR); + } + tokens.open = consume("("); + if (tokens.open) { + ret.list = ret.rhsType === "identifier-list" ? + // [Exposed=(Window,Worker)] + identifiers() : + // [NamedConstructor=Audio(DOMString src)] or [Constructor(DOMString str)] + argument_list(); + tokens.close = consume(")") || error("Unexpected token in extended attribute argument list"); + } else if (ret.hasRhs && !tokens.secondaryName) { + error("No right hand side to extended attribute assignment"); + } + return ret; + } + + get rhsType() { + return !this.tokens.assign ? null : + !this.tokens.secondaryName ? "identifier-list" : + this.tokens.secondaryName.type; + } + } + + class SimpleExtendedAttribute extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const name = consume(ID); + if (name) { + return new SimpleExtendedAttribute({ + tokens: { name }, + params: ExtendedAttributeParameters.parse() + }); + } + } + + constructor({ source, tokens, params }) { + super({ source, tokens }); + Object.defineProperty(this, "params", { value: params }); + } + + get type() { + return "extended-attribute"; + } + get name() { + return this.tokens.name.value; + } + get rhs() { + const { rhsType: type, tokens, list } = this.params; + if (!type) { + return null; + } + const value = type === "identifier-list" ? list : tokens.secondaryName.value; + return { type, value }; + } + get arguments() { + const { rhsType, list } = this.params; + if (!list || rhsType === "identifier-list") { + return []; + } + return list; + } + } + + // Note: we parse something simpler than the official syntax. It's all that ever + // seems to be used + class ExtendedAttributes extends _productions_array_base_js__WEBPACK_IMPORTED_MODULE_2__["ArrayBase"] { + static parse() { + const tokens = {}; + tokens.open = consume("["); + if (!tokens.open) return []; + const ret = new ExtendedAttributes({ source, tokens }); + ret.push(...Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["list"])(tokeniser, { + parser: SimpleExtendedAttribute.parse, + listName: "extended attribute" + })); + tokens.close = consume("]") || error("Unexpected form of extended attribute"); + if (!ret.length) { + error("Found an empty extended attribute"); + } + if (probe("[")) { + error("Illegal double extended attribute lists, consider merging them"); + } + return ret; + } + } + + class Constant extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const tokens = {}; + tokens.base = consume("const"); + if (!tokens.base) { + return; + } + let idlType = primitive_type(); + if (!idlType) { + const base = consume(ID) || error("No type for const"); + idlType = new Type({ source, tokens: { base } }); + } + if (probe("?")) { + error("Unexpected nullable constant type"); + } + idlType.type = "const-type"; + tokens.name = consume(ID) || error("No name for const"); + tokens.assign = consume("=") || error("No value assignment for const"); + tokens.value = Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["const_value"])(tokeniser) || error("No value for const"); + tokens.termination = consume(";") || error("Unterminated const"); + const ret = new Constant({ source, tokens }); + ret.idlType = idlType; + return ret; + } + + get type() { + return "const"; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + get value() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["const_data"])(this.tokens.value); + } + } + + class CallbackFunction extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse(base) { + const tokens = { base }; + const ret = new CallbackFunction({ source, tokens }); + tokens.name = consume(ID) || error("No name for callback"); + tokeniser.current = ret; + tokens.assign = consume("=") || error("No assignment in callback"); + ret.idlType = return_type() || error("Missing return type"); + tokens.open = consume("(") || error("No arguments in callback"); + ret.arguments = argument_list(); + tokens.close = consume(")") || error("Unterminated callback"); + tokens.termination = consume(";") || error("Unterminated callback"); + return ret; + } + + get type() { + return "callback"; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + } + + function callback() { + const callback = consume("callback"); + if (!callback) return; + const tok = consume("interface"); + if (tok) { + return Interface.parse(tok, { callback }); + } + return CallbackFunction.parse(callback); + } + + class Attribute extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse({ special, noInherit = false, readonly = false } = {}) { + const start_position = tokeniser.position; + const tokens = { special }; + const ret = new Attribute({ source, tokens }); + if (!special && !noInherit) { + tokens.special = consume("inherit"); + } + if (ret.special === "inherit" && probe("readonly")) { + error("Inherited attributes cannot be read-only"); + } + tokens.readonly = consume("readonly"); + if (readonly && !tokens.readonly && probe("attribute")) { + error("Attributes must be readonly in this context"); + } + tokens.base = consume("attribute"); + if (!tokens.base) { + unconsume(start_position); + return; + } + ret.idlType = type_with_extended_attributes("attribute-type") || error("No type in attribute"); + switch (ret.idlType.generic) { + case "sequence": + case "record": error(`Attributes cannot accept ${ret.idlType.generic} types`); + } + tokens.name = consume(ID, "required") || error("No name in attribute"); + tokens.termination = consume(";") || error("Unterminated attribute"); + return ret; + } + + get type() { + return "attribute"; + } + get special() { + if (!this.tokens.special) { + return ""; + } + return this.tokens.special.value; + } + get readonly() { + return !!this.tokens.readonly; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + } + + function return_type(typeName) { + const typ = type(typeName || "return-type"); + if (typ) { + return typ; + } + const voidToken = consume("void"); + if (voidToken) { + const ret = new Type({ source, tokens: { base: voidToken } }); + ret.type = "return-type"; + return ret; + } + } + + class Operation extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse({ special, regular } = {}) { + const tokens = { special }; + const ret = new Operation({ source, tokens }); + if (special && special.value === "stringifier") { + tokens.termination = consume(";"); + if (tokens.termination) { + ret.arguments = []; + return ret; + } + } + if (!special && !regular) { + tokens.special = consume("getter", "setter", "deleter"); + } + ret.idlType = return_type() || error("Missing return type"); + tokens.name = consume(ID); + tokens.open = consume("(") || error("Invalid operation"); + ret.arguments = argument_list(); + tokens.close = consume(")") || error("Unterminated operation"); + tokens.termination = consume(";") || error("Unterminated attribute"); + return ret; + } + + get type() { + return "operation"; + } + get name() { + const { name } = this.tokens; + if (!name) { + return ""; + } + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(name.value); + } + get special() { + if (!this.tokens.special) { + return ""; + } + return this.tokens.special.value; + } + } + + function static_member() { + const special = consume("static"); + if (!special) return; + const member = Attribute.parse({ special }) || + Operation.parse({ special }) || + error("No body in static member"); + return member; + } + + function stringifier() { + const special = consume("stringifier"); + if (!special) return; + const member = Attribute.parse({ special }) || + Operation.parse({ special }) || + error("Unterminated stringifier"); + return member; + } + + class IterableLike extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const start_position = tokeniser.position; + const tokens = {}; + const ret = new IterableLike({ source, tokens }); + tokens.readonly = consume("readonly"); + tokens.base = tokens.readonly ? + consume("maplike", "setlike") : + consume("iterable", "maplike", "setlike"); + if (!tokens.base) { + unconsume(start_position); + return; } - if (result !== -1) { - trivia += tokens.pop().value; - } else if (/[-0-9.]/.test(nextChar)) { - result = attemptTokenMatch("float"); - if (result === -1) { - result = attemptTokenMatch("integer"); + const { type } = ret; + const secondTypeRequired = type === "maplike"; + const secondTypeAllowed = secondTypeRequired || type === "iterable"; + + tokens.open = consume("<") || error(`Error parsing ${type} declaration`); + const first = type_with_extended_attributes() || error(`Error parsing ${type} declaration`); + ret.idlType = [first]; + if (secondTypeAllowed) { + first.tokens.separator = consume(","); + if (first.tokens.separator) { + ret.idlType.push(type_with_extended_attributes()); } - } else if (/[A-Z_a-z]/.test(nextChar)) { + else if (secondTypeRequired) + error(`Missing second type argument in ${type} declaration`); + } + tokens.close = consume(">") || error(`Unterminated ${type} declaration`); + tokens.termination = consume(";") || error(`Missing semicolon after ${type} declaration`); + + return ret; + } + + get type() { + return this.tokens.base.value; + } + get readonly() { + return !!this.tokens.readonly; + } + } + + function inheritance() { + const colon = consume(":"); + if (!colon) { + return {}; + } + const inheritance = consume(ID) || error("No type in inheritance"); + return { colon, inheritance }; + } + + class Container extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse(instance, { type, inheritable, allowedMembers }) { + const { tokens } = instance; + tokens.name = consume(ID) || error("No name for interface"); + tokeniser.current = instance; + if (inheritable) { + Object.assign(tokens, inheritance()); + } + tokens.open = consume("{") || error(`Bodyless ${type}`); + instance.members = []; + while (true) { + tokens.close = consume("}"); + if (tokens.close) { + tokens.termination = consume(";") || error(`Missing semicolon after ${type}`); + return instance; + } + const ea = ExtendedAttributes.parse(); + let mem; + for (const [parser, ...args] of allowedMembers) { + mem = parser(...args); + if (mem) { + break; + } + } + if (!mem) { + error("Unknown member"); + } + mem.extAttrs = ea; + instance.members.push(mem); + } + } + + get partial() { + return !!this.tokens.partial; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + get inheritance() { + if (!this.tokens.inheritance) { + return null; + } + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.inheritance.value); + } + } + + class Interface extends Container { + static parse(base, { callback = null, partial = null } = {}) { + const tokens = { callback, partial, base }; + return Container.parse(new Interface({ source, tokens }), { + type: "interface", + inheritable: !partial, + allowedMembers: [ + [Constant.parse], + [static_member], + [stringifier], + [IterableLike.parse], + [Attribute.parse], + [Operation.parse] + ] + }); + } + + get type() { + if (this.tokens.callback) { + return "callback interface"; + } + return "interface"; + } + } + + class Mixin extends Container { + static parse(base, { partial } = {}) { + const tokens = { partial, base }; + tokens.mixin = consume("mixin"); + if (!tokens.mixin) { + return; + } + return Container.parse(new Mixin({ source, tokens }), { + type: "interface mixin", + allowedMembers: [ + [Constant.parse], + [stringifier], + [Attribute.parse, { noInherit: true }], + [Operation.parse, { regular: true }] + ] + }); + } + + get type() { + return "interface mixin"; + } + } + + function interface_(opts) { + const base = consume("interface"); + if (!base) return; + const ret = Mixin.parse(base, opts) || + Interface.parse(base, opts) || + error("Interface has no proper body"); + return ret; + } + + class Namespace extends Container { + static parse({ partial } = {}) { + const tokens = { partial }; + tokens.base = consume("namespace"); + if (!tokens.base) { + return; + } + return Container.parse(new Namespace({ source, tokens }), { + type: "namespace", + allowedMembers: [ + [Attribute.parse, { noInherit: true, readonly: true }], + [Operation.parse, { regular: true }] + ] + }); + } + + get type() { + return "namespace"; + } + } + + function partial() { + const partial = consume("partial"); + if (!partial) return; + return Dictionary.parse({ partial }) || + interface_({ partial }) || + Namespace.parse({ partial }) || + error("Partial doesn't apply to anything"); + } + + class Dictionary extends Container { + static parse({ partial } = {}) { + const tokens = { partial }; + tokens.base = consume("dictionary"); + if (!tokens.base) { + return; + } + return Container.parse(new Dictionary({ source, tokens }), { + type: "dictionary", + inheritable: !partial, + allowedMembers: [ + [Field.parse], + ] + }); + } + + get type() { + return "dictionary"; + } + } + + class Field extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const tokens = {}; + const ret = new Field({ source, tokens }); + ret.extAttrs = ExtendedAttributes.parse(); + tokens.required = consume("required"); + ret.idlType = type_with_extended_attributes("dictionary-type") || error("No type for dictionary member"); + tokens.name = consume(ID) || error("No name for dictionary member"); + ret.default = _productions_default_js__WEBPACK_IMPORTED_MODULE_5__["Default"].parse(tokeniser); + if (tokens.required && ret.default) error("Required member must not have a default"); + tokens.termination = consume(";") || error("Unterminated dictionary member"); + return ret; + } + + get type() { + return "field"; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + get required() { + return !!this.tokens.required; + } + } + + class Typedef extends _productions_base_js__WEBPACK_IMPORTED_MODULE_3__["Base"] { + static parse() { + const tokens = {}; + const ret = new Typedef({ source, tokens }); + tokens.base = consume("typedef"); + if (!tokens.base) { + return; + } + ret.idlType = type_with_extended_attributes("typedef-type") || error("No type in typedef"); + tokens.name = consume(ID) || error("No name in typedef"); + tokeniser.current = ret; + tokens.termination = consume(";") || error("Unterminated typedef"); + return ret; + } + + get type() { + return "typedef"; + } + get name() { + return Object(_productions_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } + } + + function definition() { + return callback() || + interface_() || + partial() || + Dictionary.parse() || + _productions_enum_js__WEBPACK_IMPORTED_MODULE_6__["Enum"].parse(tokeniser) || + Typedef.parse() || + _productions_includes_js__WEBPACK_IMPORTED_MODULE_7__["Includes"].parse(tokeniser) || + Namespace.parse(); + } + + function definitions() { + if (!source.length) return []; + const defs = []; + while (true) { + const ea = ExtendedAttributes.parse(); + const def = definition(); + if (!def) { + if (ea.length) error("Stray extended attributes"); + break; + } + def.extAttrs = ea; + defs.push(def); + } + const eof = consume("eof"); + if (options.concrete) { + defs.push(eof); + } + return defs; + } + const res = definitions(); + if (tokeniser.position < source.length) error("Unrecognised tokens"); + return res; +} + +function parse(str, options = {}) { + const tokeniser = new _tokeniser_js__WEBPACK_IMPORTED_MODULE_1__["Tokeniser"](str); + return parseByTokens(tokeniser, options); +} + + +/***/ }), +/* 2 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unescape", function() { return unescape; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "list", function() { return list; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "const_value", function() { return const_value; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "const_data", function() { return const_data; }); +/** + * @param {string} identifier + */ +function unescape(identifier) { + return identifier.startsWith('_') ? identifier.slice(1) : identifier; +} + +/** + * Parses comma-separated list + * @param {import("../tokeniser").Tokeniser} tokeniser + * @param {object} args + * @param {Function} args.parser parser function for each item + * @param {boolean} [args.allowDangler] whether to allow dangling comma + * @param {string} [args.listName] the name to be shown on error messages + */ +function list(tokeniser, { parser, allowDangler, listName = "list" }) { + const first = parser(tokeniser); + if (!first) { + return []; + } + first.tokens.separator = tokeniser.consume(","); + const items = [first]; + while (first.tokens.separator) { + const item = parser(tokeniser); + if (!item) { + if (!allowDangler) { + tokeniser.error(`Trailing comma in ${listName}`); + } + break; + } + item.tokens.separator = tokeniser.consume(","); + items.push(item); + if (!item.tokens.separator) break; + } + return items; +} + +/** + * @param {import("../tokeniser").Tokeniser} tokeniser + */ +function const_value(tokeniser) { + return tokeniser.consume("true", "false", "Infinity", "-Infinity", "NaN", "decimal", "integer"); +} + +/** + * @param {object} token + * @param {string} token.type + * @param {string} token.value + */ +function const_data({ type, value }) { + switch (type) { + case "true": + case "false": + return { type: "boolean", value: type === "true" }; + case "Infinity": + case "-Infinity": + return { type: "Infinity", negative: type.startsWith("-") }; + case "[": + return { type: "sequence", value: [] }; + case "decimal": + case "integer": + return { type: "number", value }; + case "string": + return { type: "string", value: value.slice(1, -1) }; + default: + return { type }; + } +} + + +/***/ }), +/* 3 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stringTypes", function() { return stringTypes; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "argumentNameKeywords", function() { return argumentNameKeywords; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tokeniser", function() { return Tokeniser; }); +/* harmony import */ var _error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); + + +// These regular expressions use the sticky flag so they will only match at +// the current location (ie. the offset of lastIndex). +const tokenRe = { + // This expression uses a lookahead assertion to catch false matches + // against integers early. + "decimal": /-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y, + "integer": /-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y, + "identifier": /[_-]?[A-Za-z][0-9A-Z_a-z-]*/y, + "string": /"[^"]*"/y, + "whitespace": /[\t\n\r ]+/y, + "comment": /((\/(\/.*|\*([^*]|\*[^/])*\*\/)[\t\n\r ]*)+)/y, + "other": /[^\t\n\r 0-9A-Za-z]/y +}; + +const stringTypes = [ + "ByteString", + "DOMString", + "USVString" +]; + +const argumentNameKeywords = [ + "attribute", + "callback", + "const", + "deleter", + "dictionary", + "enum", + "getter", + "includes", + "inherit", + "interface", + "iterable", + "maplike", + "namespace", + "partial", + "required", + "setlike", + "setter", + "static", + "stringifier", + "typedef", + "unrestricted" +]; + +const nonRegexTerminals = [ + "-Infinity", + "FrozenArray", + "Infinity", + "NaN", + "Promise", + "boolean", + "byte", + "double", + "false", + "float", + "implements", + "legacyiterable", + "long", + "mixin", + "null", + "octet", + "optional", + "or", + "readonly", + "record", + "sequence", + "short", + "true", + "unsigned", + "void" +].concat(argumentNameKeywords, stringTypes); + +const punctuations = [ + "(", + ")", + ",", + "...", + ":", + ";", + "<", + "=", + ">", + "?", + "[", + "]", + "{", + "}" +]; + +/** + * @param {string} str + */ +function tokenise(str) { + const tokens = []; + let lastCharIndex = 0; + let trivia = ""; + let line = 1; + let index = 0; + while (lastCharIndex < str.length) { + const nextChar = str.charAt(lastCharIndex); + let result = -1; + + if (/[\t\n\r ]/.test(nextChar)) { + result = attemptTokenMatch("whitespace", { noFlushTrivia: true }); + } else if (nextChar === '/') { + result = attemptTokenMatch("comment", { noFlushTrivia: true }); + } + + if (result !== -1) { + const currentTrivia = tokens.pop().value; + line += (currentTrivia.match(/\n/g) || []).length; + trivia += currentTrivia; + index -= 1; + } else if (/[-0-9.A-Z_a-z]/.test(nextChar)) { + result = attemptTokenMatch("decimal"); + if (result === -1) { + result = attemptTokenMatch("integer"); + } + if (result === -1) { result = attemptTokenMatch("identifier"); const token = tokens[tokens.length - 1]; if (result !== -1 && nonRegexTerminals.includes(token.value)) { token.type = token.value; } - } else if (nextChar === '"') { - result = attemptTokenMatch("string"); } - - for (const punctuation of punctuations) { - if (str.startsWith(punctuation, lastIndex)) { - tokens.push({ type: punctuation, value: punctuation, trivia }); - trivia = ""; - lastIndex += punctuation.length; - result = lastIndex; - break; - } - } - - // other as the last try - if (result === -1) { - result = attemptTokenMatch("other"); - } - if (result === -1) { - throw new Error("Token stream not progressing"); - } - lastIndex = result; + } else if (nextChar === '"') { + result = attemptTokenMatch("string"); } - return tokens; - function attemptTokenMatch(type, { noFlushTrivia } = {}) { - const re = tokenRe[type]; - re.lastIndex = lastIndex; - const result = re.exec(str); - if (result) { - tokens.push({ type, value: result[0], trivia }); - if (!noFlushTrivia) { - trivia = ""; - } - return re.lastIndex; + for (const punctuation of punctuations) { + if (str.startsWith(punctuation, lastCharIndex)) { + tokens.push({ type: punctuation, value: punctuation, trivia, line, index }); + trivia = ""; + lastCharIndex += punctuation.length; + result = lastCharIndex; + break; } - return -1; + } + + // other as the last try + if (result === -1) { + result = attemptTokenMatch("other"); + } + if (result === -1) { + throw new Error("Token stream not progressing"); + } + lastCharIndex = result; + index += 1; + } + + // remaining trivia as eof + tokens.push({ + type: "eof", + value: "", + trivia + }); + + return tokens; + + /** + * @param {keyof tokenRe} type + * @param {object} [options] + * @param {boolean} [options.noFlushTrivia] + */ + function attemptTokenMatch(type, { noFlushTrivia } = {}) { + const re = tokenRe[type]; + re.lastIndex = lastCharIndex; + const result = re.exec(str); + if (result) { + tokens.push({ type, value: result[0], trivia, line, index }); + if (!noFlushTrivia) { + trivia = ""; + } + return re.lastIndex; + } + return -1; + } +} + +class Tokeniser { + /** + * @param {string} idl + */ + constructor(idl) { + this.source = tokenise(idl); + this.position = 0; + } + + /** + * @param {string} message + */ + error(message) { + throw new WebIDLParseError(Object(_error_js__WEBPACK_IMPORTED_MODULE_0__["syntaxError"])(this.source, this.position, this.current, message)); + } + + /** + * @param {string} type + */ + probe(type) { + return this.source.length > this.position && this.source[this.position].type === type; + } + + /** + * @param {...string} candidates + */ + consume(...candidates) { + for (const type of candidates) { + if (!this.probe(type)) continue; + const token = this.source[this.position]; + this.position++; + return token; } } - class WebIDLParseError { - constructor(str, line, input, tokens) { - this.message = str; - this.line = line; - this.input = input; - this.tokens = tokens; - } + /** + * @param {number} position + */ + unconsume(position) { + this.position = position; + } +} - toString() { - const escapedInput = JSON.stringify(this.input); - const tokens = JSON.stringify(this.tokens, null, 4); - return `${this.message}, line ${this.line} (tokens: ${escapedInput})\n${tokens}`; - } +class WebIDLParseError extends Error { + constructor({ message, line, input, tokens }) { + super(message); + this.name = "WebIDLParseError"; // not to be mangled + this.line = line; + this.input = input; + this.tokens = tokens; + } +} + + +/***/ }), +/* 4 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "syntaxError", function() { return syntaxError; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validationError", function() { return validationError; }); +/** + * @param {string} text + */ +function lastLine(text) { + const splitted = text.split("\n"); + return splitted[splitted.length - 1]; +} + +/** + * @param {string} message error message + * @param {"Syntax" | "Validation"} type error type + */ +function error(source, position, current, message, type) { + /** + * @param {number} count + */ + function sliceTokens(count) { + return count > 0 ? + source.slice(position, position + count) : + source.slice(Math.max(position + count, 0), position); } - function parse(tokens) { - let line = 1; - tokens = tokens.slice(); - const names = new Map(); - let current = null; - - const FLOAT = "float"; - const INT = "integer"; - const ID = "identifier"; - const STR = "string"; - const OTHER = "other"; - - const EMPTY_OPERATION = Object.freeze({ - type: "operation", - getter: false, - setter: false, - deleter: false, - static: false, - stringifier: false - }); - - const EMPTY_IDLTYPE = Object.freeze({ - generic: null, - nullable: false, - union: false, - idlType: null, - extAttrs: [] - }); - - function error(str) { - const maxTokens = 5; - const tok = tokens - .slice(consume_position, consume_position + maxTokens) - .map(t => t.trivia + t.value).join(""); - // Count newlines preceding the actual erroneous token - if (tokens.length) { - line += count(tokens[consume_position].trivia, "\n"); - } - - let message; - if (current) { - message = `Got an error during or right after parsing \`${current.partial ? "partial " : ""}${current.type} ${current.name}\`: ${str}` - } - else { - // throwing before any valid definition - message = `Got an error before parsing any named definition: ${str}`; - } - - throw new WebIDLParseError(message, line, tok, tokens.slice(0, maxTokens)); + function tokensToText(inputs, { precedes } = {}) { + const text = inputs.map(t => t.trivia + t.value).join(""); + const nextToken = source[position]; + if (nextToken.type === "eof") { + return text; } - - function sanitize_name(name, type) { - if (names.has(name)) { - error(`The name "${name}" of type "${names.get(name)}" is already seen`); - } - names.set(name, type); - return name; + if (precedes) { + return text + nextToken.trivia; } - - let consume_position = 0; - - function probe(type) { - return tokens.length > consume_position && tokens[consume_position].type === type; - } - - function consume(...candidates) { - // TODO: use const when Servo updates its JS engine - for (let type of candidates) { - if (!probe(type)) continue; - const token = tokens[consume_position]; - consume_position++; - line += count(token.trivia, "\n"); - return token; - } - } - - function unescape(identifier) { - return identifier.startsWith('_') ? identifier.slice(1) : identifier; - } - - function unconsume(position) { - while (consume_position > position) { - consume_position--; - line -= count(tokens[consume_position].trivia, "\n"); - } - } - - function count(str, char) { - let total = 0; - for (let i = str.indexOf(char); i !== -1; i = str.indexOf(char, i + 1)) { - ++total; - } - return total; - } - - function integer_type() { - let ret = ""; - if (consume("unsigned")) ret = "unsigned "; - if (consume("short")) return ret + "short"; - if (consume("long")) { - ret += "long"; - if (consume("long")) return ret + " long"; - return ret; - } - if (ret) error("Failed to parse integer type"); - } - - function float_type() { - let ret = ""; - if (consume("unrestricted")) ret = "unrestricted "; - if (consume("float")) return ret + "float"; - if (consume("double")) return ret + "double"; - if (ret) error("Failed to parse float type"); - } - - function primitive_type() { - const num_type = integer_type() || float_type(); - if (num_type) return num_type; - if (consume("boolean")) return "boolean"; - if (consume("byte")) return "byte"; - if (consume("octet")) return "octet"; - } - - function const_value() { - if (consume("true")) return { type: "boolean", value: true }; - if (consume("false")) return { type: "boolean", value: false }; - if (consume("null")) return { type: "null" }; - if (consume("Infinity")) return { type: "Infinity", negative: false }; - if (consume("-Infinity")) return { type: "Infinity", negative: true }; - if (consume("NaN")) return { type: "NaN" }; - const ret = consume(FLOAT, INT); - if (ret) return { type: "number", value: ret.value }; - } - - function type_suffix(obj) { - obj.nullable = !!consume("?"); - if (probe("?")) error("Can't nullable more than once"); - } - - function generic_type(typeName) { - const name = consume("FrozenArray", "Promise", "sequence", "record"); - if (!name) { - return; - } - const ret = { generic: name.type }; - consume("<") || error(`No opening bracket after ${name.type}`); - switch (name.type) { - case "Promise": - if (probe("[")) error("Promise type cannot have extended attribute"); - ret.idlType = return_type(typeName); - break; - case "sequence": - case "FrozenArray": - ret.idlType = type_with_extended_attributes(typeName); - break; - case "record": - if (probe("[")) error("Record key cannot have extended attribute"); - ret.idlType = []; - const keyType = consume(...stringTypes); - if (!keyType) error(`Record key must be a string type`); - ret.idlType.push(Object.assign({ type: typeName }, EMPTY_IDLTYPE, { idlType: keyType.value })); - consume(",") || error("Missing comma after record key type"); - const valueType = type_with_extended_attributes(typeName) || error("Error parsing generic type record"); - ret.idlType.push(valueType); - break; - } - if (!ret.idlType) error(`Error parsing generic type ${name.type}`); - consume(">") || error(`Missing closing bracket after ${name.type}`); - if (name.type === "Promise" && probe("?")) { - error("Promise type cannot be nullable"); - } - type_suffix(ret); - return ret; - } - - function single_type(typeName) { - const ret = Object.assign({ type: typeName || null }, EMPTY_IDLTYPE); - const generic = generic_type(typeName); - if (generic) { - return Object.assign(ret, generic); - } - const prim = primitive_type(); - let name; - if (prim) { - ret.idlType = prim; - } else if (name = consume(ID, ...stringTypes)) { - ret.idlType = name.value; - if (probe("<")) error(`Unsupported generic type ${name.value}`); - } else { - return; - } - type_suffix(ret); - if (ret.nullable && ret.idlType === "any") error("Type any cannot be made nullable"); - return ret; - } - - function union_type(typeName) { - if (!consume("(")) return; - const ret = Object.assign({ type: typeName || null }, EMPTY_IDLTYPE, { union: true, idlType: [] }); - do { - const typ = type_with_extended_attributes() || error("No type after open parenthesis or 'or' in union type"); - ret.idlType.push(typ); - } while (consume("or")); - if (ret.idlType.length < 2) { - error("At least two types are expected in a union type but found less"); - } - if (!consume(")")) error("Unterminated union type"); - type_suffix(ret); - return ret; - } - - function type(typeName) { - return single_type(typeName) || union_type(typeName); - } - - function type_with_extended_attributes(typeName) { - const extAttrs = extended_attrs(); - const ret = single_type(typeName) || union_type(typeName); - if (extAttrs.length && ret) ret.extAttrs = extAttrs; - return ret; - } - - function argument() { - const start_position = consume_position; - const ret = { optional: false, variadic: false, default: null }; - ret.extAttrs = extended_attrs(); - const opt_token = consume("optional"); - if (opt_token) { - ret.optional = true; - } - ret.idlType = type_with_extended_attributes("argument-type"); - if (!ret.idlType) { - unconsume(start_position); - return; - } - if (!ret.optional && consume("...")) { - ret.variadic = true; - } - const name = consume(ID, ...argumentNameKeywords); - if (!name) { - unconsume(start_position); - return; - } - ret.name = unescape(name.value); - ret.escapedName = name.value; - if (ret.optional) { - ret.default = default_() || null; - } - return ret; - } - - function argument_list() { - const ret = []; - const arg = argument(); - if (!arg) return ret; - ret.push(arg); - while (true) { - if (!consume(",")) return ret; - const nxt = argument() || error("Trailing comma in arguments list"); - ret.push(nxt); - } - } - - function simple_extended_attr() { - const name = consume(ID); - if (!name) return; - const ret = { - name: name.value, - arguments: null, - type: "extended-attribute", - rhs: null - }; - const eq = consume("="); - if (eq) { - ret.rhs = consume(ID, FLOAT, INT, STR); - if (ret.rhs) { - // No trivia exposure yet - ret.rhs.trivia = undefined; - } - } - if (consume("(")) { - if (eq && !ret.rhs) { - // [Exposed=(Window,Worker)] - ret.rhs = { - type: "identifier-list", - value: identifiers() - }; - } - else { - // [NamedConstructor=Audio(DOMString src)] or [Constructor(DOMString str)] - ret.arguments = argument_list(); - } - consume(")") || error("Unexpected token in extended attribute argument list"); - } - if (eq && !ret.rhs) error("No right hand side to extended attribute assignment"); - return ret; - } - - // Note: we parse something simpler than the official syntax. It's all that ever - // seems to be used - function extended_attrs() { - const eas = []; - if (!consume("[")) return eas; - eas[0] = simple_extended_attr() || error("Extended attribute with not content"); - while (consume(",")) { - eas.push(simple_extended_attr() || error("Trailing comma in extended attribute")); - } - consume("]") || error("No end of extended attribute"); - return eas; - } - - function default_() { - if (consume("=")) { - const def = const_value(); - if (def) { - return def; - } else if (consume("[")) { - if (!consume("]")) error("Default sequence value must be empty"); - return { type: "sequence", value: [] }; - } else { - const str = consume(STR) || error("No value for default"); - str.value = str.value.slice(1, -1); - // No trivia exposure yet - str.trivia = undefined; - return str; - } - } - } - - function const_() { - if (!consume("const")) return; - const ret = { type: "const", nullable: false }; - let typ = primitive_type(); - if (!typ) { - typ = consume(ID) || error("No type for const"); - typ = typ.value; - } - ret.idlType = Object.assign({ type: "const-type" }, EMPTY_IDLTYPE, { idlType: typ }); - type_suffix(ret); - const name = consume(ID) || error("No name for const"); - ret.name = name.value; - consume("=") || error("No value assignment for const"); - const cnt = const_value(); - if (cnt) ret.value = cnt; - else error("No value for const"); - consume(";") || error("Unterminated const"); - return ret; - } - - function inheritance() { - if (consume(":")) { - const inh = consume(ID) || error("No type in inheritance"); - return inh.value; - } - } - - function operation_rest(ret) { - if (!ret) ret = {}; - const name = consume(ID); - ret.name = name ? unescape(name.value) : null; - ret.escapedName = name ? name.value : null; - consume("(") || error("Invalid operation"); - ret.arguments = argument_list(); - consume(")") || error("Unterminated operation"); - consume(";") || error("Unterminated operation"); - return ret; - } - - function callback() { - let ret; - if (!consume("callback")) return; - const tok = consume("interface"); - if (tok) { - ret = interface_rest(false, "callback interface"); - return ret; - } - const name = consume(ID) || error("No name for callback"); - ret = current = { type: "callback", name: sanitize_name(name.value, "callback") }; - consume("=") || error("No assignment in callback"); - ret.idlType = return_type() || error("Missing return type"); - consume("(") || error("No arguments in callback"); - ret.arguments = argument_list(); - consume(")") || error("Unterminated callback"); - consume(";") || error("Unterminated callback"); - return ret; - } - - function attribute({ noInherit = false, readonly = false } = {}) { - const start_position = consume_position; - const ret = { - type: "attribute", - static: false, - stringifier: false, - inherit: false, - readonly: false - }; - if (!noInherit && consume("inherit")) { - ret.inherit = true; - } - if (consume("readonly")) { - ret.readonly = true; - } else if (readonly && probe("attribute")) { - error("Attributes must be readonly in this context"); - } - const rest = attribute_rest(ret); - if (!rest) { - unconsume(start_position); - } - return rest; - } - - function attribute_rest(ret) { - if (!consume("attribute")) { - return; - } - ret.idlType = type_with_extended_attributes("attribute-type") || error("No type in attribute"); - if (ret.idlType.generic === "sequence") error("Attributes cannot accept sequence types"); - if (ret.idlType.generic === "record") error("Attributes cannot accept record types"); - const name = consume(ID, "required") || error("No name in attribute"); - ret.name = unescape(name.value); - ret.escapedName = name.value; - consume(";") || error("Unterminated attribute"); - return ret; - } - - function return_type(typeName) { - const typ = type(typeName || "return-type"); - if (typ) { - return typ; - } - if (consume("void")) { - return Object.assign({ type: "return-type" }, EMPTY_IDLTYPE, { idlType: "void" }); - } - } - - function operation({ regular = false } = {}) { - const ret = Object.assign({}, EMPTY_OPERATION); - while (!regular) { - if (consume("getter")) ret.getter = true; - else if (consume("setter")) ret.setter = true; - else if (consume("deleter")) ret.deleter = true; - else break; - } - ret.idlType = return_type() || error("Missing return type"); - operation_rest(ret); - return ret; - } - - function static_member() { - if (!consume("static")) return; - const member = attribute({ noInherit: true }) || - operation({ regular: true }) || - error("No body in static member"); - member.static = true; - return member; - } - - function stringifier() { - if (!consume("stringifier")) return; - if (consume(";")) { - return Object.assign({}, EMPTY_OPERATION, { stringifier: true }); - } - const member = attribute({ noInherit: true }) || - operation({ regular: true }) || - error("Unterminated stringifier"); - member.stringifier = true; - return member; - } - - function identifiers() { - const arr = []; - const id = consume(ID); - if (id) { - arr.push(id.value); - } - else error("Expected identifiers but not found"); - while (true) { - if (consume(",")) { - const name = consume(ID) || error("Trailing comma in identifiers list"); - arr.push(name.value); - } else break; - } - return arr; - } - - function iterable_type() { - if (consume("iterable")) return "iterable"; - else if (consume("legacyiterable")) return "legacyiterable"; - else if (consume("maplike")) return "maplike"; - else if (consume("setlike")) return "setlike"; - else return; - } - - function readonly_iterable_type() { - if (consume("maplike")) return "maplike"; - else if (consume("setlike")) return "setlike"; - else return; - } - - function iterable() { - const start_position = consume_position; - const ret = { type: null, idlType: null, readonly: false }; - if (consume("readonly")) { - ret.readonly = true; - } - const consumeItType = ret.readonly ? readonly_iterable_type : iterable_type; - - const ittype = consumeItType(); - if (!ittype) { - unconsume(start_position); - return; - } - - const secondTypeRequired = ittype === "maplike"; - const secondTypeAllowed = secondTypeRequired || ittype === "iterable"; - ret.type = ittype; - if (ret.type !== 'maplike' && ret.type !== 'setlike') - delete ret.readonly; - if (consume("<")) { - ret.idlType = [type_with_extended_attributes()] || error(`Error parsing ${ittype} declaration`); - if (secondTypeAllowed) { - if (consume(",")) { - ret.idlType.push(type_with_extended_attributes()); - } - else if (secondTypeRequired) - error(`Missing second type argument in ${ittype} declaration`); - } - if (!consume(">")) error(`Unterminated ${ittype} declaration`); - if (!consume(";")) error(`Missing semicolon after ${ittype} declaration`); - } else - error(`Error parsing ${ittype} declaration`); - - return ret; - } - - function interface_rest(isPartial, typeName = "interface") { - const name = consume(ID) || error("No name for interface"); - const mems = []; - const ret = current = { - type: typeName, - name: isPartial ? name.value : sanitize_name(name.value, "interface"), - partial: isPartial, - members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - consume("{") || error("Bodyless interface"); - while (true) { - if (consume("}")) { - consume(";") || error("Missing semicolon after interface"); - return ret; - } - const ea = extended_attrs(); - const mem = const_() || - static_member() || - stringifier() || - iterable() || - attribute() || - operation() || - error("Unknown member"); - mem.extAttrs = ea; - ret.members.push(mem); - } - } - - function mixin_rest(isPartial) { - if (!consume("mixin")) return; - const name = consume(ID) || error("No name for interface mixin"); - const mems = []; - const ret = current = { - type: "interface mixin", - name: isPartial ? name.value : sanitize_name(name.value, "interface mixin"), - partial: isPartial, - members: mems - }; - consume("{") || error("Bodyless interface mixin"); - while (true) { - if (consume("}")) { - consume(";") || error("Missing semicolon after interface mixin"); - return ret; - } - const ea = extended_attrs(); - const mem = const_() || - stringifier() || - attribute({ noInherit: true }) || - operation({ regular: true }) || - error("Unknown member"); - mem.extAttrs = ea; - ret.members.push(mem); - } - } - - function interface_(isPartial) { - if (!consume("interface")) return; - return mixin_rest(isPartial) || - interface_rest(isPartial) || - error("Interface has no proper body"); - } - - function namespace(isPartial) { - if (!consume("namespace")) return; - const name = consume(ID) || error("No name for namespace"); - const mems = []; - const ret = current = { - type: "namespace", - name: isPartial ? name.value : sanitize_name(name.value, "namespace"), - partial: isPartial, - members: mems - }; - consume("{") || error("Bodyless namespace"); - while (true) { - if (consume("}")) { - consume(";") || error("Missing semicolon after namespace"); - return ret; - } - const ea = extended_attrs(); - const mem = attribute({ noInherit: true, readonly: true }) || - operation({ regular: true }) || - error("Unknown member"); - mem.extAttrs = ea; - ret.members.push(mem); - } - } - - function partial() { - if (!consume("partial")) return; - const thing = dictionary(true) || - interface_(true) || - namespace(true) || - error("Partial doesn't apply to anything"); - return thing; - } - - function dictionary(isPartial) { - if (!consume("dictionary")) return; - const name = consume(ID) || error("No name for dictionary"); - const mems = []; - const ret = current = { - type: "dictionary", - name: isPartial ? name.value : sanitize_name(name.value, "dictionary"), - partial: isPartial, - members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - consume("{") || error("Bodyless dictionary"); - while (true) { - if (consume("}")) { - consume(";") || error("Missing semicolon after dictionary"); - return ret; - } - const ea = extended_attrs(); - const required = consume("required"); - const typ = type_with_extended_attributes("dictionary-type") || error("No type for dictionary member"); - const name = consume(ID) || error("No name for dictionary member"); - const dflt = default_() || null; - if (required && dflt) error("Required member must not have a default"); - const member = { - type: "field", - name: unescape(name.value), - escapedName: name.value, - required: !!required, - idlType: typ, - extAttrs: ea, - default: dflt - }; - ret.members.push(member); - consume(";") || error("Unterminated dictionary member"); - } - } - - function enum_() { - if (!consume("enum")) return; - const name = consume(ID) || error("No name for enum"); - const vals = []; - const ret = current = { - type: "enum", - name: sanitize_name(name.value, "enum"), - values: vals - }; - consume("{") || error("No curly for enum"); - let value_expected = true; - while (true) { - if (consume("}")) { - if (!ret.values.length) error("No value in enum"); - consume(";") || error("No semicolon after enum"); - return ret; - } - else if (!value_expected) { - error("No comma between enum values"); - } - const val = consume(STR) || error("Unexpected value in enum"); - val.value = val.value.slice(1, -1); - // No trivia exposure yet - val.trivia = undefined; - ret.values.push(val); - value_expected = !!consume(","); - } - } - - function typedef() { - if (!consume("typedef")) return; - const ret = { - type: "typedef" - }; - ret.idlType = type_with_extended_attributes("typedef-type") || error("No type in typedef"); - const name = consume(ID) || error("No name in typedef"); - ret.name = sanitize_name(name.value, "typedef"); - current = ret; - consume(";") || error("Unterminated typedef"); - return ret; - } - - function implements_() { - const start_position = consume_position; - const target = consume(ID); - if (!target) return; - if (consume("implements")) { - const ret = { - type: "implements", - target: target.value - }; - const imp = consume(ID) || error("Incomplete implements statement"); - ret.implements = imp.value; - consume(";") || error("No terminating ; for implements statement"); - return ret; - } else { - // rollback - unconsume(start_position); - } - } - - function includes() { - const start_position = consume_position; - const target = consume(ID); - if (!target) return; - if (consume("includes")) { - const ret = { - type: "includes", - target: target.value - }; - const imp = consume(ID) || error("Incomplete includes statement"); - ret.includes = imp.value; - consume(";") || error("No terminating ; for includes statement"); - return ret; - } else { - // rollback - unconsume(start_position); - } - } - - function definition() { - return callback() || - interface_(false) || - partial() || - dictionary(false) || - enum_() || - typedef() || - implements_() || - includes() || - namespace(false); - } - - function definitions() { - if (!tokens.length) return []; - const defs = []; - while (true) { - const ea = extended_attrs(); - const def = definition(); - if (!def) { - if (ea.length) error("Stray extended attributes"); - break; - } - def.extAttrs = ea; - defs.push(def); - } - return defs; - } - const res = definitions(); - if (consume_position < tokens.length) error("Unrecognised tokens"); - return res; + return text.slice(nextToken.trivia.length); } - const obj = { - parse(str) { - const tokens = tokenise(str); - return parse(tokens); - } + const maxTokens = 5; // arbitrary but works well enough + const line = + source[position].type !== "eof" ? source[position].line : + source.length > 1 ? source[position - 1].line : + 1; + + const precedingLine = lastLine( + tokensToText(sliceTokens(-maxTokens), { precedes: true }) + ); + + const subsequentTokens = sliceTokens(maxTokens); + const subsequentText = tokensToText(subsequentTokens); + const sobsequentLine = subsequentText.split("\n")[0]; + + const spaced = " ".repeat(precedingLine.length) + "^ " + message; + const contextualMessage = precedingLine + sobsequentLine + "\n" + spaced; + + const contextType = type === "Syntax" ? "since" : "inside"; + const grammaticalContext = current ? `, ${contextType} \`${current.partial ? "partial " : ""}${current.type} ${current.name}\`` : ""; + return { + message: `${type} error at line ${line}${grammaticalContext}:\n${contextualMessage}`, + line, + input: subsequentText, + tokens: subsequentTokens }; +} - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = obj; - } else if (typeof define === 'function' && define.amd) { - define([], () => obj); - } else { - (self || window).WebIDL2 = obj; +/** + * @param {string} message error message + */ +function syntaxError(source, position, current, message) { + return error(source, position, current, message, "Syntax"); +} + +/** + * @param {string} message error message + */ +function validationError(source, token, current, message) { + return error(source, token.index, current, message, "Validation").message; +} + + +/***/ }), +/* 5 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayBase", function() { return ArrayBase; }); +class ArrayBase extends Array { + constructor({ source, tokens }) { + super(); + Object.defineProperties(this, { + source: { value: source }, + tokens: { value: tokens } + }); } -})(); +} + + +/***/ }), +/* 6 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return Base; }); +class Base { + constructor({ source, tokens }) { + Object.defineProperties(this, { + source: { value: source }, + tokens: { value: tokens } + }); + } + + toJSON() { + const json = { type: undefined, name: undefined, inheritance: undefined }; + let proto = this; + while (proto !== Object.prototype) { + const descMap = Object.getOwnPropertyDescriptors(proto); + for (const [key, value] of Object.entries(descMap)) { + if (value.enumerable || value.get) { + json[key] = this[key]; + } + } + proto = Object.getPrototypeOf(proto); + } + return json; + } +} + + +/***/ }), +/* 7 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Token", function() { return Token; }); +/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6); + + +class Token extends _base_js__WEBPACK_IMPORTED_MODULE_0__["Base"] { + /** + * @param {import("../tokeniser").Tokeniser} tokeniser + * @param {string} type + */ + static parser(tokeniser, type) { + return () => { + const value = tokeniser.consume(type); + if (value) { + return new Token({ source: tokeniser.source, tokens: { value } }); + } + }; + } + + get value() { + return this.tokens.value.value; + } +} + + +/***/ }), +/* 8 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Default", function() { return Default; }); +/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6); +/* harmony import */ var _helpers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2); + + + +class Default extends _base_js__WEBPACK_IMPORTED_MODULE_0__["Base"] { + /** + * @param {import("../tokeniser").Tokeniser} tokeniser + */ + static parse(tokeniser) { + const assign = tokeniser.consume("="); + if (!assign) { + return null; + } + const def = Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["const_value"])(tokeniser) || tokeniser.consume("string", "null", "[") || tokeniser.error("No value for default"); + const expression = [def]; + if (def.type === "[") { + const close = tokeniser.consume("]") || tokeniser.error("Default sequence value must be empty"); + expression.push(close); + } + return new Default({ source: tokeniser.source, tokens: { assign }, expression }); + } + + constructor({ source, tokens, expression }) { + super({ source, tokens }); + Object.defineProperty(this, "expression", { value: expression }); + } + + get type() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["const_data"])(this.expression[0]).type; + } + get value() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["const_data"])(this.expression[0]).value; + } + get negative() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["const_data"])(this.expression[0]).negative; + } +} + + +/***/ }), +/* 9 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Enum", function() { return Enum; }); +/* harmony import */ var _helpers_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2); +/* harmony import */ var _token_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7); +/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6); + + + + +class EnumValue extends _token_js__WEBPACK_IMPORTED_MODULE_1__["Token"] { + /** + * @param {import("../tokeniser").Tokeniser} tokeniser + */ + static parse(tokeniser) { + const value = tokeniser.consume("string"); + if (value) { + return new EnumValue({ source: tokeniser.source, tokens: { value } }); + } + } + + get type() { + return "enum-value"; + } + get value() { + return super.value.slice(1, -1); + } +} + +class Enum extends _base_js__WEBPACK_IMPORTED_MODULE_2__["Base"] { + /** + * @param {import("../tokeniser").Tokeniser} tokeniser + */ + static parse(tokeniser) { + const tokens = {}; + tokens.base = tokeniser.consume("enum"); + if (!tokens.base) { + return; + } + tokens.name = tokeniser.consume("identifier") || tokeniser.error("No name for enum"); + const ret = tokeniser.current = new Enum({ source: tokeniser.source, tokens }); + tokens.open = tokeniser.consume("{") || tokeniser.error("Bodyless enum"); + ret.values = Object(_helpers_js__WEBPACK_IMPORTED_MODULE_0__["list"])(tokeniser, { + parser: EnumValue.parse, + allowDangler: true, + listName: "enumeration" + }); + if (tokeniser.probe("string")) { + tokeniser.error("No comma between enum values"); + } + tokens.close = tokeniser.consume("}") || tokeniser.error("Unexpected value in enum"); + if (!ret.values.length) { + tokeniser.error("No value in enum"); + } + tokens.termination = tokeniser.consume(";") || tokeniser.error("No semicolon after enum"); + return ret; + } + + get type() { + return "enum"; + } + get name() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_0__["unescape"])(this.tokens.name.value); + } +} + + +/***/ }), +/* 10 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Includes", function() { return Includes; }); +/* harmony import */ var _base_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6); +/* harmony import */ var _helpers_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2); + + + +class Includes extends _base_js__WEBPACK_IMPORTED_MODULE_0__["Base"] { + /** + * @param {import("../tokeniser").Tokeniser} tokeniser + */ + static parse(tokeniser) { + const target = tokeniser.consume("identifier"); + if (!target) { + return; + } + const tokens = { target }; + tokens.includes = tokeniser.consume("includes"); + if (!tokens.includes) { + tokeniser.unconsume(target.index); + return; + } + tokens.mixin = tokeniser.consume("identifier") || tokeniser.error("Incomplete includes statement"); + tokens.termination = tokeniser.consume(";") || tokeniser.error("No terminating ; for includes statement"); + return new Includes({ source: tokeniser.source, tokens }); + } + + get type() { + return "includes"; + } + get target() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["unescape"])(this.tokens.target.value); + } + get includes() { + return Object(_helpers_js__WEBPACK_IMPORTED_MODULE_1__["unescape"])(this.tokens.mixin.value); + } +} + + +/***/ }), +/* 11 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "write", function() { return write; }); + + +function noop(arg) { + return arg; +} + +const templates = { + wrap: items => items.join(""), + trivia: noop, + name: noop, + reference: noop, + type: noop, + generic: noop, + inheritance: noop, + definition: noop, + extendedAttribute: noop, + extendedAttributeReference: noop +}; + +function write(ast, { templates: ts = templates } = {}) { + ts = Object.assign({}, templates, ts); + + function reference(raw, { unescaped, context }) { + if (!unescaped) { + unescaped = raw.startsWith("_") ? raw.slice(1) : raw; + } + return ts.reference(raw, unescaped, context); + } + + function token(t, wrapper = noop, ...args) { + if (!t) { + return ""; + } + const value = wrapper(t.value, ...args); + return ts.wrap([ts.trivia(t.trivia), value]); + } + + function reference_token(t, context) { + return token(t, reference, { context }); + } + + function name_token(t, arg) { + return token(t, ts.name, arg); + } + + function type_body(it) { + if (it.union || it.generic) { + return ts.wrap([ + token(it.tokens.base, ts.generic), + token(it.tokens.open), + ...it.subtype.map(type), + token(it.tokens.close) + ]); + } + const firstToken = it.tokens.prefix || it.tokens.base; + const prefix = it.tokens.prefix ? [ + it.tokens.prefix.value, + ts.trivia(it.tokens.base.trivia) + ] : []; + const ref = reference(ts.wrap([ + ...prefix, + it.tokens.base.value, + token(it.tokens.postfix) + ]), { unescaped: it.idlType, context: it }); + return ts.wrap([ts.trivia(firstToken.trivia), ref]); + } + function type(it) { + return ts.wrap([ + extended_attributes(it.extAttrs), + type_body(it), + token(it.tokens.nullable), + token(it.tokens.separator) + ]); + } + function default_(def) { + if (!def) { + return ""; + } + return ts.wrap([ + token(def.tokens.assign), + ...def.expression.map(t => token(t)) + ]); + } + function argument(arg) { + return ts.wrap([ + extended_attributes(arg.extAttrs), + token(arg.tokens.optional), + ts.type(type(arg.idlType)), + token(arg.tokens.variadic), + name_token(arg.tokens.name, { data: arg }), + default_(arg.default), + token(arg.tokens.separator) + ]); + } + function identifier(id, context) { + return ts.wrap([ + reference_token(id.tokens.value, context), + token(id.tokens.separator) + ]); + } + function make_ext_at(it) { + const { rhsType } = it.params; + return ts.wrap([ + ts.trivia(it.tokens.name.trivia), + ts.extendedAttribute(ts.wrap([ + ts.extendedAttributeReference(it.name), + token(it.params.tokens.assign), + reference_token(it.params.tokens.secondaryName, it), + token(it.params.tokens.open), + ...!it.params.list ? [] : + it.params.list.map( + rhsType === "identifier-list" ? id => identifier(id, it) : argument + ), + token(it.params.tokens.close) + ])), + token(it.tokens.separator) + ]); + } + function extended_attributes(eats) { + if (!eats.length) return ""; + return ts.wrap([ + token(eats.tokens.open), + ...eats.map(make_ext_at), + token(eats.tokens.close) + ]); + } + + function operation(it, parent) { + const body = it.idlType ? [ + ts.type(type(it.idlType)), + name_token(it.tokens.name, { data: it, parent }), + token(it.tokens.open), + ts.wrap(it.arguments.map(argument)), + token(it.tokens.close), + ] : []; + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.special), + ...body, + token(it.tokens.termination) + ]), { data: it, parent }); + } + + function attribute(it, parent) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.special), + token(it.tokens.readonly), + token(it.tokens.base), + ts.type(type(it.idlType)), + name_token(it.tokens.name, { data: it, parent }), + token(it.tokens.termination) + ]), { data: it, parent }); + } + + function inheritance(inh) { + if (!inh.tokens.inheritance) { + return ""; + } + return ts.wrap([ + token(inh.tokens.colon), + ts.trivia(inh.tokens.inheritance.trivia), + ts.inheritance(reference(inh.tokens.inheritance.value, { context: inh })) + ]); + } + + function container(it) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.callback), + token(it.tokens.partial), + token(it.tokens.base), + token(it.tokens.mixin), + name_token(it.tokens.name, { data: it }), + inheritance(it), + token(it.tokens.open), + iterate(it.members, it), + token(it.tokens.close), + token(it.tokens.termination) + ]), { data: it }); + } + + function field(it, parent) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.required), + ts.type(type(it.idlType)), + name_token(it.tokens.name, { data: it, parent }), + default_(it.default), + token(it.tokens.termination) + ]), { data: it, parent }); + } + function const_(it, parent) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.base), + ts.type(type(it.idlType)), + name_token(it.tokens.name, { data: it, parent }), + token(it.tokens.assign), + token(it.tokens.value), + token(it.tokens.termination) + ]), { data: it, parent }); + } + function typedef(it) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.base), + ts.type(type(it.idlType)), + name_token(it.tokens.name, { data: it }), + token(it.tokens.termination) + ]), { data: it }); + } + function includes(it) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + reference_token(it.tokens.target, it), + token(it.tokens.includes), + reference_token(it.tokens.mixin, it), + token(it.tokens.termination) + ]), { data: it }); + } + function callback(it) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.base), + name_token(it.tokens.name, { data: it }), + token(it.tokens.assign), + ts.type(type(it.idlType)), + token(it.tokens.open), + ...it.arguments.map(argument), + token(it.tokens.close), + token(it.tokens.termination), + ]), { data: it }); + } + function enum_(it) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.base), + name_token(it.tokens.name, { data: it }), + token(it.tokens.open), + iterate(it.values, it), + token(it.tokens.close), + token(it.tokens.termination) + ]), { data: it }); + } + function enum_value(v, parent) { + return ts.wrap([ + ts.trivia(v.tokens.value.trivia), + ts.definition( + ts.wrap(['"', ts.name(v.value, { data: v, parent }), '"']), + { data: v, parent } + ), + token(v.tokens.separator) + ]); + } + function iterable_like(it, parent) { + return ts.definition(ts.wrap([ + extended_attributes(it.extAttrs), + token(it.tokens.readonly), + token(it.tokens.base, ts.generic), + token(it.tokens.open), + ts.wrap(it.idlType.map(type)), + token(it.tokens.close), + token(it.tokens.termination) + ]), { data: it, parent }); + } + function eof(it) { + return ts.trivia(it.trivia); + } + + const table = { + interface: container, + "interface mixin": container, + namespace: container, + operation, + attribute, + dictionary: container, + field, + const: const_, + typedef, + includes, + callback, + enum: enum_, + "enum-value": enum_value, + iterable: iterable_like, + legacyiterable: iterable_like, + maplike: iterable_like, + setlike: iterable_like, + "callback interface": container, + eof + }; + function dispatch(it, parent) { + const dispatcher = table[it.type]; + if (!dispatcher) { + throw new Error(`Type "${it.type}" is unsupported`); + } + return table[it.type](it, parent); + } + function iterate(things, parent) { + if (!things) return; + const results = things.map(thing => dispatch(thing, parent)); + return ts.wrap(results); + } + return iterate(ast); +} + + +/***/ }), +/* 12 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "validate", function() { return validate; }); +/* harmony import */ var _error_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); + + + + +function groupDefinitions(all) { + const unique = new Map(); + const duplicates = new Set(); + const partials = new Map(); + for (const def of all) { + if (def.partial) { + const array = partials.get(def.name); + if (array) { + array.push(def); + } else { + partials.set(def.name, [def]); + } + continue; + } + if (!def.name) { + continue; + } + if (!unique.has(def.name)) { + unique.set(def.name, def); + } else { + duplicates.add(def); + } + } + return { all, unique, partials, duplicates }; +} + +function* checkDuplicatedNames({ unique, duplicates }) { + for (const dup of duplicates) { + const { name } = dup; + const message = `The name "${name}" of type "${unique.get(name).type}" was already seen`; + yield Object(_error_js__WEBPACK_IMPORTED_MODULE_0__["validationError"])(dup.source, dup.tokens.name, dup, message); + } +} + +function* checkInterfaceMemberDuplication(defs) { + const interfaces = [...defs.unique.values()].filter(def => def.type === "interface"); + const includesMap = getIncludesMap(); + + for (const i of interfaces) { + yield* forEachInterface(i); + } + + function* forEachInterface(i) { + const opNames = new Set(getOperations(i).map(op => op.name)); + const partials = defs.partials.get(i.name) || []; + const mixins = includesMap.get(i.name) || []; + for (const ext of [...partials, ...mixins]) { + const additions = getOperations(ext); + yield* forEachExtension(additions, opNames, ext, i); + for (const addition of additions) { + opNames.add(addition.name); + } + } + } + + function* forEachExtension(additions, existings, ext, base) { + for (const addition of additions) { + const { name } = addition; + if (name && existings.has(name)) { + const message = `The operation "${name}" has already been defined for the base interface "${base.name}" either in itself or in a mixin`; + yield Object(_error_js__WEBPACK_IMPORTED_MODULE_0__["validationError"])(ext.source, addition.tokens.name, ext, message); + } + } + } + + function getOperations(i) { + return i.members + .filter(({type}) => type === "operation"); + } + + function getIncludesMap() { + const map = new Map(); + const includes = defs.all.filter(def => def.type === "includes"); + for (const include of includes) { + const array = map.get(include.target); + const mixin = defs.unique.get(include.includes); + if (!mixin) { + continue; + } + if (array) { + array.push(mixin); + } else { + map.set(include.target, [mixin]); + } + } + return map; + } +} + +function validate(ast) { + const defs = groupDefinitions(ast); + return [ + ...checkDuplicatedNames(defs), + ...checkInterfaceMemberDuplication(defs) + ]; +} + + +/***/ }) +/******/ ]); +}); +//# sourceMappingURL=webidl2.js.map \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js.headers b/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js.headers deleted file mode 100644 index 6805c323..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/webidl2.js.headers +++ /dev/null
@@ -1 +0,0 @@ -Content-Type: text/javascript; charset=utf-8
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/writer.js b/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/writer.js deleted file mode 100644 index b3097a6..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/lib/writer.js +++ /dev/null
@@ -1,221 +0,0 @@ -"use strict"; - -(() => { - function write(ast, opt = {}) { - const noop = str => str; - const optNames = "type".split(" "); - const context = []; - for (const o of optNames) { - if (!opt[o]) opt[o] = noop; - } - - function literal(it) { - return it.value; - }; - function type(it) { - if (typeof it === "string") return opt.type(it); // XXX should maintain some context - let ret = extended_attributes(it.extAttrs); - if (it.union) ret += `(${it.idlType.map(type).join(" or ")})`; - else { - if (it.generic) ret += `${it.generic}<`; - if (Array.isArray(it.idlType)) ret += it.idlType.map(type).join(", "); - else ret += type(it.idlType); - if (it.generic) ret += ">"; - } - if (it.nullable) ret += "?"; - - return ret; - }; - function const_value(it) { - const tp = it.type; - if (tp === "boolean") return it.value ? "true" : "false"; - else if (tp === "null") return "null"; - else if (tp === "Infinity") return (it.negative ? "-" : "") + "Infinity"; - else if (tp === "NaN") return "NaN"; - else if (tp === "number") return it.value; - else if (tp === "sequence") return "[]"; - else return `"${it.value}"`; - }; - function argument(arg) { - let ret = extended_attributes(arg.extAttrs); - if (arg.optional) ret += "optional "; - ret += type(arg.idlType); - if (arg.variadic) ret += "..."; - ret += ` ${arg.escapedName}`; - if (arg.default) ret += ` = ${const_value(arg.default)}`; - return ret; - }; - function make_ext_at(it) { - context.unshift(it); - let ret = it.name; - if (it.rhs) { - if (it.rhs.type === "identifier-list") ret += `=(${it.rhs.value.join(",")})`; - else ret += `=${it.rhs.value}`; - } - if (it.arguments) ret += `(${it.arguments.length ? it.arguments.map(argument).join(",") : ""})`; - context.shift(); // XXX need to add more contexts, but not more than needed for ReSpec - return ret; - }; - function extended_attributes(eats) { - if (!eats || !eats.length) return ""; - return `[${eats.map(make_ext_at).join(", ")}]`; - }; - - const modifiers = "getter setter deleter stringifier static".split(" "); - function operation(it) { - let ret = extended_attributes(it.extAttrs); - if (it.stringifier && !it.idlType) return "stringifier;"; - for (const mod of modifiers) { - if (it[mod]) ret += mod + " "; - } - ret += type(it.idlType) + " "; - if (it.name) ret += it.escapedName; - ret += `(${it.arguments.map(argument).join(",")});`; - return ret; - }; - - function attribute(it) { - let ret = extended_attributes(it.extAttrs); - if (it.static) ret += "static "; - if (it.stringifier) ret += "stringifier "; - if (it.inherit) ret += "inherit "; - if (it.readonly) ret += "readonly "; - ret += `attribute ${type(it.idlType)} ${it.escapedName};`; - return ret; - }; - - function interface_(it) { - let ret = extended_attributes(it.extAttrs); - if (it.partial) ret += "partial "; - ret += `interface ${it.name} `; - if (it.inheritance) ret += `: ${it.inheritance} `; - ret += `{${iterate(it.members)}};`; - return ret; - }; - - function interface_mixin(it) { - let ret = extended_attributes(it.extAttrs); - if (it.partial) ret += "partial "; - ret += `interface mixin ${it.name} `; - ret += `{${iterate(it.members)}};`; - return ret; - } - - function namespace(it) { - let ret = extended_attributes(it.extAttrs); - if (it.partial) ret += "partial "; - ret += `namespace ${it.name} `; - ret += `{${iterate(it.members)}};`; - return ret; - } - - function dictionary(it) { - let ret = extended_attributes(it.extAttrs); - if (it.partial) ret += "partial "; - ret += `dictionary ${it.name} `; - if (it.inheritance) ret += `: ${it.inheritance} `; - ret += `{${iterate(it.members)}};`; - return ret; - }; - function field(it) { - let ret = extended_attributes(it.extAttrs); - if (it.required) ret += "required "; - ret += `${type(it.idlType)} ${it.escapedName}`; - if (it.default) ret += ` = ${const_value(it.default)}`; - ret += ";"; - return ret; - }; - function const_(it) { - const ret = extended_attributes(it.extAttrs); - return `${ret}const ${type(it.idlType)}${it.nullable ? "?" : ""} ${it.name} = ${const_value(it.value)};`; - }; - function typedef(it) { - let ret = extended_attributes(it.extAttrs); - ret += `typedef ${extended_attributes(it.typeExtAttrs)}`; - return `${ret}${type(it.idlType)} ${it.name};`; - }; - function implements_(it) { - const ret = extended_attributes(it.extAttrs); - return `${ret}${it.target} implements ${it.implements};`; - }; - function includes(it) { - const ret = extended_attributes(it.extAttrs); - return `${ret}${it.target} includes ${it.includes};`; - }; - function callback(it) { - const ret = extended_attributes(it.extAttrs); - return `${ret}callback ${it.name} = ${type(it.idlType)}(${it.arguments.map(argument).join(",")});`; - }; - function enum_(it) { - let ret = extended_attributes(it.extAttrs); - ret += `enum ${it.name} {`; - for (const v of it.values) { - ret += `"${v.value}",`; - } - return ret + "};"; - }; - function iterable(it) { - return `iterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`; - }; - function legacyiterable(it) { - return `legacyiterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`; - }; - function maplike(it) { - return `${it.readonly ? "readonly " : ""}maplike<${it.idlType.map(type).join(", ")}>;`; - }; - function setlike(it) { - return `${it.readonly ? "readonly " : ""}setlike<${type(it.idlType[0])}>;`; - }; - function callbackInterface(it) { - return `callback ${interface_(it)}`; - }; - - const table = { - interface: interface_, - "interface mixin": interface_mixin, - namespace, - operation, - attribute, - dictionary, - field, - const: const_, - typedef, - implements: implements_, - includes, - callback, - enum: enum_, - iterable, - legacyiterable, - maplike, - setlike, - "callback interface": callbackInterface - }; - function dispatch(it) { - const dispatcher = table[it.type]; - if (!dispatcher) { - throw new Error(`Type "${it.type}" is unsupported`) - } - return table[it.type](it); - }; - function iterate(things) { - if (!things) return; - let ret = ""; - for (const thing of things) ret += dispatch(thing); - return ret; - }; - return iterate(ast); - }; - - - const obj = { - write - }; - - if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { - module.exports = obj; - } else if (typeof define === 'function' && define.amd) { - define([], () => obj); - } else { - (self || window).WebIDL2Writer = obj; - } -})();
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/package-lock.json b/third_party/blink/web_tests/external/wpt/resources/webidl2/package-lock.json deleted file mode 100644 index b0581037..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/package-lock.json +++ /dev/null
@@ -1,700 +0,0 @@ -{ - "name": "webidl2", - "version": "13.0.3", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@babel/code-frame": { - "version": "7.0.0-beta.40", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz", - "integrity": "sha512-eVXQSbu/RimU6OKcK2/gDJVTFcxXJI4sHbIqw2mhwMZeQ2as/8AhS9DGkEDoHMBBNJZ5B0US63lF56x+KDcxiA==", - "dev": true, - "requires": { - "@babel/highlight": "7.0.0-beta.40" - } - }, - "@babel/highlight": { - "version": "7.0.0-beta.40", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.40.tgz", - "integrity": "sha512-mOhhTrzieV6VO7odgzFGFapiwRK0ei8RZRhfzHhb6cpX3QM8XXuCLXWjN8qBB7JReDdUR80V3LFfFrGUYevhNg==", - "dev": true, - "requires": { - "chalk": "^2.0.0", - "esutils": "^2.0.2", - "js-tokens": "^3.0.0" - } - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "chalk": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", - "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", - "dev": true, - "requires": { - "color-name": "^1.1.1" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "diff-match-patch": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.0.tgz", - "integrity": "sha1-HMPIOkkNZ/ldkeOfatHy4Ia2MEg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "^2.1.0" - } - }, - "expect": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-22.4.0.tgz", - "integrity": "sha512-Fiy862jT3qc70hwIHwwCBNISmaqBrfWKKrtqyMJ6iwZr+6KXtcnHojZFtd63TPRvRl8EQTJ+YXYy2lK6/6u+Hw==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "jest-diff": "^22.4.0", - "jest-get-type": "^22.1.0", - "jest-matcher-utils": "^22.4.0", - "jest-message-util": "^22.4.0", - "jest-regex-util": "^22.1.0" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, - "fill-range": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", - "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", - "dev": true, - "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^3.0.0", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, - "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "^2.0.0" - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - }, - "jest-diff": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-22.4.0.tgz", - "integrity": "sha512-+/t20WmnkOkB8MOaGaPziI8zWKxquMvYw4Ub+wOzi7AUhmpFXz43buWSxVoZo4J5RnCozpGbX3/FssjJ5KV9Nw==", - "dev": true, - "requires": { - "chalk": "^2.0.1", - "diff": "^3.2.0", - "jest-get-type": "^22.1.0", - "pretty-format": "^22.4.0" - } - }, - "jest-get-type": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.1.0.tgz", - "integrity": "sha512-nD97IVOlNP6fjIN5i7j5XRH+hFsHL7VlauBbzRvueaaUe70uohrkz7pL/N8lx/IAwZRTJ//wOdVgh85OgM7g3w==", - "dev": true - }, - "jest-matcher-utils": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-22.4.0.tgz", - "integrity": "sha512-03m3issxUXpWMwDYTfmL8hRNewUB0yCRTeXPm+eq058rZxLHD9f5NtSSO98CWHqe4UyISIxd9Ao9iDVjHWd2qg==", - "dev": true, - "requires": { - "chalk": "^2.0.1", - "jest-get-type": "^22.1.0", - "pretty-format": "^22.4.0" - } - }, - "jest-message-util": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-22.4.0.tgz", - "integrity": "sha512-eyCJB0T3hrlpFF2FqQoIB093OulP+1qvATQmD3IOgJgMGqPL6eYw8TbC5P/VCWPqKhGL51xvjIIhow5eZ2wHFw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0-beta.35", - "chalk": "^2.0.1", - "micromatch": "^2.3.11", - "slash": "^1.0.0", - "stack-utils": "^1.0.1" - } - }, - "jest-regex-util": { - "version": "22.1.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-22.1.0.tgz", - "integrity": "sha512-on0LqVS6Xeh69sw3d1RukVnur+lVOl3zkmb0Q54FHj9wHoq6dbtWqb3TSlnVUyx36hqjJhjgs/QLqs07Bzu72Q==", - "dev": true - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "jsondiffpatch": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/jsondiffpatch/-/jsondiffpatch-0.3.5.tgz", - "integrity": "sha512-v7eaGLDMCHXH+fsIaZhptEUJmS8EJpunq7IM4cc4vIT/kSRAkaZ6ZF4ebiNcyUelL0znbvj6o2B5Gh9v7Og0BQ==", - "dev": true, - "requires": { - "chalk": "^2.3.0", - "diff-match-patch": "^1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "math-random": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", - "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", - "dev": true - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mocha": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.4.tgz", - "integrity": "sha512-nMOpAPFosU1B4Ix1jdhx5e3q7XO55ic5a8cgYvW27CequcEY+BabS0kUVL1Cw1V5PuVHZWeNRWFLmEPexo79VA==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.11.0", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.3", - "he": "1.1.1", - "mkdirp": "0.5.1", - "supports-color": "4.4.0" - }, - "dependencies": { - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - } - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, - "pretty-format": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.0.tgz", - "integrity": "sha512-pvCxP2iODIIk9adXlo4S3GRj0BrJiil68kByAa1PrgG97c1tClh9dLMgp3Z6cHFZrclaABt0UH8PIhwHuFLqYA==", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0", - "ansi-styles": "^3.2.0" - } - }, - "randomatic": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.0.0.tgz", - "integrity": "sha512-VdxFOIEY3mNO5PtSRkkle/hPJDHvQhK21oa73K4yAc9qmp6N429gAyF1gZMOTMeS0/AYzaV/2Trcef+NaIonSA==", - "dev": true, - "requires": { - "is-number": "^4.0.0", - "kind-of": "^6.0.0", - "math-random": "^1.0.1" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } - }, - "regex-cache": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", - "dev": true, - "requires": { - "is-equal-shallow": "^0.1.3" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", - "dev": true - }, - "stack-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.1.tgz", - "integrity": "sha1-1PM6tU6OOHeLDKXP07OvsS22hiA=", - "dev": true - }, - "supports-color": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - } -}
diff --git a/third_party/blink/web_tests/external/wpt/resources/webidl2/package.json b/third_party/blink/web_tests/external/wpt/resources/webidl2/package.json deleted file mode 100644 index 92facca..0000000 --- a/third_party/blink/web_tests/external/wpt/resources/webidl2/package.json +++ /dev/null
@@ -1,27 +0,0 @@ -{ - "name": "webidl2", - "description": "A WebIDL Parser", - "version": "13.0.3", - "contributors": [ - "Robin Berjon <robin@berjon.com> (https://berjon.com)", - "Marcos Caceres <marcos@marcosc.com> (https://marcosc.com)", - "Kagami Sascha Rosylight <saschaplas@outlook.com>", - "Timothy Gu <timothygu99@gmail.com>" - ], - "license": "W3C", - "dependencies": {}, - "devDependencies": { - "expect": "22.4.0", - "jsondiffpatch": "0.3.5", - "mocha": "5.0.4" - }, - "scripts": { - "test": "mocha", - "acquire": "node test/util/acquire.js" - }, - "repository": "git://github.com/w3c/webidl2.js", - "main": "index.js", - "files": [ - "lib/*" - ] -}
diff --git a/third_party/blink/web_tests/external/wpt/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html b/third_party/blink/web_tests/external/wpt/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html index c87932e..b4ecc16a6 100644 --- a/third_party/blink/web_tests/external/wpt/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html +++ b/third_party/blink/web_tests/external/wpt/shadow-dom/scroll-to-the-fragment-in-shadow-tree.html
@@ -5,6 +5,7 @@ <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> <meta name="assert" content="An element inside a shadow tree should not be the indicated part of the document even if its ID is exactly equal to the decoded fragid or its name attribute is exactly equal to the fragid"> <link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#scroll-to-the-fragment-identifier"> +<meta name="viewport" content="width=device-width,initial-scale=1"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> </head>
diff --git a/third_party/blink/web_tests/external/wpt/svg/scripted/script-runs-in-shadow-tree.html b/third_party/blink/web_tests/external/wpt/svg/scripted/script-runs-in-shadow-tree.html new file mode 100644 index 0000000..9693db3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/svg/scripted/script-runs-in-shadow-tree.html
@@ -0,0 +1,15 @@ +<!doctype html> +<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> +<link rel="author" href="https://mozilla.org" title="Mozilla"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1555949"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="host"></div> +<script> + let svgScript = document.createElementNS("http://www.w3.org/2000/svg", "script"); + svgScript.innerHTML = "window.scriptRan = true"; + document.getElementById("host").attachShadow({ mode: "open" }).appendChild(svgScript); + test(function() { + assert_true(window.scriptRan); + }, "svg:script runs correctly in a shadow tree"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/tools/manifest/vcs.py b/third_party/blink/web_tests/external/wpt/tools/manifest/vcs.py index c810be1..d98ccf90 100644 --- a/third_party/blink/web_tests/external/wpt/tools/manifest/vcs.py +++ b/third_party/blink/web_tests/external/wpt/tools/manifest/vcs.py
@@ -168,7 +168,10 @@ try: if not rebuild: with open(self.path, 'r') as f: - data = json.load(f) + try: + data = json.load(f) + except ValueError: + pass data = self.check_valid(data) except IOError: pass
diff --git a/third_party/blink/web_tests/external/wpt/tools/serve/serve.py b/third_party/blink/web_tests/external/wpt/tools/serve/serve.py index 4563493..77675dbe 100644 --- a/third_party/blink/web_tests/external/wpt/tools/serve/serve.py +++ b/third_party/blink/web_tests/external/wpt/tools/serve/serve.py
@@ -575,13 +575,11 @@ class WebSocketDaemon(object): - def __init__(self, host, port, doc_root, handlers_root, log_level, bind_address, - ssl_config): + def __init__(self, host, port, doc_root, handlers_root, bind_address, ssl_config): self.host = host cmd_args = ["-p", port, "-d", doc_root, - "-w", handlers_root, - "--log-level", log_level] + "-w", handlers_root] if ssl_config is not None: # This is usually done through pywebsocket.main, however we're @@ -605,17 +603,6 @@ opts, args = pywebsocket._parse_args_and_config(cmd_args) opts.cgi_directories = [] opts.is_executable_method = None - - # Logging needs to be configured both before and after reloading, - # because some modules store loggers as global variables. - pywebsocket._configure_logging(opts) - # Ensure that when we start this in a new process we have the global - # lock in the logging module unlocked. - reload_module(logging) - release_mozlog_lock() - pywebsocket._configure_logging(opts) - # DO NOT LOG BEFORE THIS LINE. - self.server = pywebsocket.WebSocketServer(opts) ports = [item[0].getsockname()[1] for item in self.server._sockets] assert all(item == ports[0] for item in ports) @@ -662,21 +649,27 @@ def start_ws_server(host, port, paths, routes, bind_address, config, **kwargs): + # Ensure that when we start this in a new process we have the global lock + # in the logging module unlocked + reload_module(logging) + release_mozlog_lock() return WebSocketDaemon(host, str(port), repo_root, config.paths["ws_doc_root"], - config.log_level.lower(), bind_address, ssl_config=None) def start_wss_server(host, port, paths, routes, bind_address, config, **kwargs): + # Ensure that when we start this in a new process we have the global lock + # in the logging module unlocked + reload_module(logging) + release_mozlog_lock() return WebSocketDaemon(host, str(port), repo_root, config.paths["ws_doc_root"], - config.log_level.lower(), bind_address, config.ssl_config) @@ -849,6 +842,8 @@ global logger logger = config.logger set_logger(logger) + # Configure the root logger to cover third-party libraries. + logging.getLogger().setLevel(config.log_level) def handle_signal(signum, frame): logger.debug("Received signal %s. Shutting down.", signum)
diff --git a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks-ref.html b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks-ref.html index 1a46c4d8..fa969b1 100644 --- a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks-ref.html +++ b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks-ref.html
@@ -18,9 +18,9 @@ left: 0; right: 0; text-align: center; - font-family: sans-serif; } -.cue > span { +.cueText { + font-family: Ahem, sans-serif; background: rgba(0,0,0,0.8); color: white; } @@ -30,6 +30,9 @@ <source src="/media/white.webm" type="video/webm"> <source src="/media/white.mp4" type="video/mp4"> </video> - <span class="cue"><span>This is a <u>test subtitle</u><br>This is a test subtitle</span></span> + <span class="cue"> + <div><span class="cueText">This is a <u>test subtitle</u></span></div> + <div><span class="cueText">This is a test subtitle</span></div> + </span> </div> -</html> \ No newline at end of file +</html>
diff --git a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks.html b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks.html index f422d73d..7648d87 100644 --- a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks.html +++ b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/2_tracks.html
@@ -5,6 +5,9 @@ <style> html { overflow:hidden } body { margin:0 } +::cue { + font-family: Ahem, sans-serif; +} </style> <script src="/common/reftest-wait.js"></script> <video width="320" height="180" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
diff --git a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks-ref.html b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks-ref.html index bec3c05..9fc5219 100644 --- a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks-ref.html +++ b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks-ref.html
@@ -18,9 +18,9 @@ left: 0; right: 0; text-align: center; - font-family: sans-serif; } -.cue > span { +.cueText { + font-family: Ahem, sans-serif; background: rgba(0,0,0,0.8); color: white; } @@ -30,6 +30,10 @@ <source src="/media/white.webm" type="video/webm"> <source src="/media/white.mp4" type="video/mp4"> </video> - <span class="cue"><span>This is a <b>test subtitle</b><br>This is a <u>test subtitle</u><br>This is a test subtitle</span></span> + <span class="cue"> + <div><span class="cueText">This is a <b>test subtitle</b></span></div> + <div><span class="cueText">This is a <u>test subtitle</u></span></div> + <div><span class="cueText">This is a test subtitle</span></div> + </span> </div> -</html> \ No newline at end of file +</html>
diff --git a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks.html b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks.html index 809e173..c0d5c161 100644 --- a/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks.html +++ b/third_party/blink/web_tests/external/wpt/webvtt/rendering/cues-with-video/processing-model/3_tracks.html
@@ -5,6 +5,9 @@ <style> html { overflow:hidden } body { margin:0 } +::cue { + font-family: Ahem, sans-serif; +} </style> <script src="/common/reftest-wait.js"></script> <video width="320" height="180" autoplay onplaying="this.onplaying = null; this.pause(); takeScreenshot();">
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-expected.html new file mode 100644 index 0000000..e8f8fbed --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-expected.html
@@ -0,0 +1,6 @@ +<input id="input" value="hello" style="width: 99px" > +<script> +input.focus(); +input.setSelectionRange(0,0); +internals.setAutofilled(input, true); +</script>
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.html new file mode 100644 index 0000000..cac91c4f --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.html
@@ -0,0 +1 @@ +<input id="input" value="Springfield">
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.html new file mode 100644 index 0000000..cac91c4f --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.html
@@ -0,0 +1 @@ +<input id="input" value="Springfield">
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.html new file mode 100644 index 0000000..2a9bfb0 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.html
@@ -0,0 +1,6 @@ +<input id="input" maxlength="5" value="Miste"> +<script> +input.focus(); +input.setSelectionRange(0,0); +internals.setAutofilled(input, true); +</script>
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.html new file mode 100644 index 0000000..9d52433 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<script src="../../../resources/ahem.js"></script> +<input id="input" value="Guy WithAVeryLongLastNameThatCouldWrap" style="width: 99px;" > +<script> +input.focus(); +input.setSelectionRange(0,0); +internals.setAutofilled(input, true); +</script>
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value.html index 823862c..f0eff95 100644 --- a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value.html +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-very-long-value.html
@@ -1,6 +1,6 @@ <!DOCTYPE html> <script src="../../../resources/ahem.js"></script> -<input id="input" style="font: 20px Ahem"> +<input id="input"> <script> input.focus(); internals.setSuggestedValue(input, 'Guy WithAVeryLongLastNameThatCouldWrap');
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.html new file mode 100644 index 0000000..8d30029 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.html
@@ -0,0 +1,4 @@ +<input id="input" value="hello" style="width: 99px"> +<script> +internals.setAutofilled(input, true); +</script>
diff --git a/third_party/blink/web_tests/fast/forms/text/input-appearance-scroll-size.html b/third_party/blink/web_tests/fast/forms/text/input-appearance-scroll-size.html index f927f1a..70453fa 100644 --- a/third_party/blink/web_tests/fast/forms/text/input-appearance-scroll-size.html +++ b/third_party/blink/web_tests/fast/forms/text/input-appearance-scroll-size.html
@@ -4,12 +4,12 @@ <body> <p>An input element can have its scrollWidth/scrollHeight changed while being temporarily in preview state. This test ensures that these two values do not -depend on the configured font type (the preview always happens with system-ui +depend on the configured font type (the preview always happens with default font).</p> -<div><input id="referenceInput" style="font: 12px system-ui; width: 10px; height: 6px"></div> -<div><input id="modifiedInput" style="font: 12px Arial; width: 10px; height: 6px"></div> -<div><textarea id="referenceTextArea" style="font: 12px system-ui; width: 10px; height: 6px"></textarea></div> -<div><textarea id="modifiedTextArea" style="font: 12px Arial; width: 10px; height: 6px"></textarea></div> +<div><input id="referenceInput" style="width: 10px; height: 6px"></div> +<div><input id="modifiedInput" style="font: 12px Times; width: 10px; height: 6px"></div> +<div><textarea id="referenceTextArea" style="width: 10px; height: 6px"></textarea></div> +<div><textarea id="modifiedTextArea" style="font: 12px Times; width: 10px; height: 6px"></textarea></div> <script> test(() => { var reference = document.getElementById('referenceInput');
diff --git a/third_party/blink/web_tests/fast/forms/text/password-input-suggested-value-appearance-expected.html b/third_party/blink/web_tests/fast/forms/text/password-input-suggested-value-appearance-expected.html new file mode 100644 index 0000000..03fcf667 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/password-input-suggested-value-appearance-expected.html
@@ -0,0 +1,6 @@ +<input id="input" type="password" value="MyPassword" style="width: 99px" > +<script> +input.focus(); +input.setSelectionRange(0,0); +internals.setAutofilled(input, true); +</script>
diff --git a/third_party/blink/web_tests/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.html b/third_party/blink/web_tests/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.html new file mode 100644 index 0000000..7aef426 --- /dev/null +++ b/third_party/blink/web_tests/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.html
@@ -0,0 +1,6 @@ +<textarea id="textarea" maxlength="5">Miste</textarea> +<script> +textarea.focus(); +textarea.setSelectionRange(0,0); +internals.setAutofilled(textarea, true); +</script>
diff --git a/third_party/blink/web_tests/http/tests/background_fetch/block-cors-preflights.https.html b/third_party/blink/web_tests/http/tests/background_fetch/block-cors-preflights.https.html index 8c8cc5c..e27e08c 100644 --- a/third_party/blink/web_tests/http/tests/background_fetch/block-cors-preflights.https.html +++ b/third_party/blink/web_tests/http/tests/background_fetch/block-cors-preflights.https.html
@@ -4,6 +4,7 @@ <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/serviceworker/resources/test-helpers.js"></script> +<script src="/serviceworker/resources/shared-utils.js"></script> <script src="resources/utils.js"></script> <script> 'use strict';
diff --git a/third_party/blink/web_tests/http/tests/background_fetch/fetch.https.html b/third_party/blink/web_tests/http/tests/background_fetch/fetch.https.html index 50dfd3d5..52418b1a 100644 --- a/third_party/blink/web_tests/http/tests/background_fetch/fetch.https.html +++ b/third_party/blink/web_tests/http/tests/background_fetch/fetch.https.html
@@ -4,6 +4,7 @@ <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/serviceworker/resources/test-helpers.js"></script> +<script src="/serviceworker/resources/shared-utils.js"></script> <script src="resources/utils.js"></script> <script> 'use strict';
diff --git a/third_party/blink/web_tests/http/tests/background_fetch/resources/utils.js b/third_party/blink/web_tests/http/tests/background_fetch/resources/utils.js index b10e228..a6f951e 100644 --- a/third_party/blink/web_tests/http/tests/background_fetch/resources/utils.js +++ b/third_party/blink/web_tests/http/tests/background_fetch/resources/utils.js
@@ -1,18 +1,6 @@ 'use strict'; -// Depends on /serviceworker/resources/test-helpers.js -async function registerAndActivateServiceWorker(test) { - const script = 'resources/empty-worker.js'; - const scope = 'resources/scope' + location.pathname; - let serviceWorkerRegistration = - await service_worker_unregister_and_register(test, script, scope); - add_completion_callback(() => { - serviceWorkerRegistration.unregister(); - }); - await wait_for_state(test, serviceWorkerRegistration.installing, 'activated'); - return serviceWorkerRegistration; -} - +// Depends on /shared_utils.js function backgroundFetchTest(func, description) { promise_test(async t => { const serviceWorkerRegistration = await registerAndActivateServiceWorker(t);
diff --git a/third_party/blink/web_tests/http/tests/background_sync/chromium/resources/stop-worker-no-crash-worker.js b/third_party/blink/web_tests/http/tests/background_sync/chromium/resources/stop-worker-no-crash-worker.js index 152c959..bb559c8b 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/chromium/resources/stop-worker-no-crash-worker.js +++ b/third_party/blink/web_tests/http/tests/background_sync/chromium/resources/stop-worker-no-crash-worker.js
@@ -1,9 +1,14 @@ -self.addEventListener('sync', function(evt) { - // Keeps this event alive. - evt.waitUntil(new Promise(function() {})); +self.addEventListener('sync', event => { + // Keeps this event alive. + event.waitUntil(new Promise(function () { })); +}); + +self.addEventListener('periodicsync', event => { + // Keeps this event alive. + event.waitUntil(new Promise(function () { })); }); // We need this fetch handler to check the sanity of the SW using iframe(). -self.addEventListener('fetch', function(evt) { - evt.respondWith(new Response('')); +self.addEventListener('fetch', event => { + event.respondWith(new Response('')); });
diff --git a/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html b/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-with-registered-one-shot-sync-task.html similarity index 88% rename from third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html rename to third_party/blink/web_tests/http/tests/background_sync/chromium/stop-with-registered-one-shot-sync-task.html index 6f1cc6b..0c837ce 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html +++ b/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-with-registered-one-shot-sync-task.html
@@ -21,6 +21,6 @@ .then(_ => internals.terminateServiceWorker(registration.active)) .then(_ => with_iframe(scope)) // Check the sanity of the SW. .then(_ => service_worker_unregister(t, scope)); - }, 'Background Sync API should not cause crashes while stopping service ' + - 'worker'); + }, 'Background Sync API with registered one-shot sync tasks should not '+ + ' cause crashes while stopping service worker'); </script>
diff --git a/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html b/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-with-registered-periodic-sync-task.html similarity index 76% copy from third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html copy to third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-with-registered-periodic-sync-task.html index 6f1cc6b..451acdd6 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-no-crash.html +++ b/third_party/blink/web_tests/http/tests/background_sync/chromium/stop-worker-with-registered-periodic-sync-task.html
@@ -11,16 +11,16 @@ var scope = 'resources/stop-worker-no-crash-iframe.html'; var registration; - return PermissionsHelper.setPermission('background-sync', 'granted') + return PermissionsHelper.setPermission('periodic-background-sync', 'granted') .then(_ => service_worker_unregister_and_register(t, url, scope)) .then(reg => { registration = reg; return wait_for_state(t, registration.installing, 'activated'); }) - .then(_ => registration.sync.register('iframe-oneshot')) + .then(_ => registration.periodicSync.register('periodic', { minInterval: 1000 })) .then(_ => internals.terminateServiceWorker(registration.active)) .then(_ => with_iframe(scope)) // Check the sanity of the SW. .then(_ => service_worker_unregister(t, scope)); - }, 'Background Sync API should not cause crashes while stopping service ' + - 'worker'); +}, 'Background Sync API with registered periodic sync tasks should not ' + + 'crash while stopping service worker'); </script>
diff --git a/third_party/blink/web_tests/http/tests/background_sync/oneshot-register-failure-worker-not-activated.html b/third_party/blink/web_tests/http/tests/background_sync/oneshot-register-failure-worker-not-activated.html index cf7f113..6ffc84cc 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/oneshot-register-failure-worker-not-activated.html +++ b/third_party/blink/web_tests/http/tests/background_sync/oneshot-register-failure-worker-not-activated.html
@@ -10,8 +10,8 @@ <body> <script> async_test(function(test) { - var workerUrl = 'resources/empty_worker.js'; - var workerScope = 'resources/scope/' + location.pathname; + var workerUrl = '/resources/empty-worker.js'; + var workerScope = '/resources/scope/' + location.pathname; var swRegistration; PermissionsHelper.setPermission('background-sync', 'granted') .then(function() {
diff --git a/third_party/blink/web_tests/http/tests/background_sync/oneshot.html b/third_party/blink/web_tests/http/tests/background_sync/oneshot.html index 6e41671..35ac7db3 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/oneshot.html +++ b/third_party/blink/web_tests/http/tests/background_sync/oneshot.html
@@ -9,9 +9,9 @@ <script> promise_test(function(t) { - const url = 'resources/empty_worker.js'; + const url = '/resources/empty-worker.js'; const iframe_scope = 'oneshot.html'; - const scope = 'resources/scope/background_sync/' + iframe_scope; + const scope = '/resources/scope/background_sync/' + iframe_scope; var sync_manager; // This test verifies that registration of one-shots fails from an iframe. @@ -45,8 +45,8 @@ 'from an iframe'); promise_test(function(t) { - const url = 'resources/empty_worker.js'; - const scope = 'resources/scope/background_sync/oneshot-uncontrolled.html'; + const url = '/resources/empty-worker.js'; + const scope = '/resources/scope/background_sync/oneshot-uncontrolled.html'; var sync_manager; // This test verifies that one-shot syncs can be registered from uncontrolled
diff --git a/third_party/blink/web_tests/http/tests/background_sync/periodic-sync-register-fails-if-worker-not-activated.html b/third_party/blink/web_tests/http/tests/background_sync/periodic-sync-register-fails-if-worker-not-activated.html new file mode 100644 index 0000000..12884b59 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/background_sync/periodic-sync-register-fails-if-worker-not-activated.html
@@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html> + +<head> + <title>periodicSync.register() is rejected when the service worker is not active yet</title> + <script src="../resources/permissions-helper.js"></script> + <script src="../resources/testharness.js"></script> + <script src="../resources/testharnessreport.js"></script> + <script src="../serviceworker/resources/test-helpers.js"></script> +</head> + +<body> + <script> + async_test(test => { + const workerUrl = '/resources/empty-worker.js'; + const workerScope = '/resources/scope/' + location.pathname; + PermissionsHelper.setPermission('periodic-background-sync', 'granted') + .then(() => { + return service_worker_unregister_and_register( + test, workerUrl, workerScope); + }) + .then(serviceWorkerRegistration => { + assert_not_equals( + serviceWorkerRegistration.installing, null, + 'The worker should be installing'); + assert_equals( + serviceWorkerRegistration.active, null, + 'The worker should not be active yet'); + return serviceWorkerRegistration.periodicSync.register( + 'abcde', { minInterval: 1000 }); + }) + .then(periodicSyncRegistration => { + assert_unreached( + 'periodicSync.register() must not succeed without an active service worker'); + }, error => { + assert_equals(error.name, 'InvalidStateError'); + assert_equals( + error.message, 'Registration failed - no active Service Worker'); + return service_worker_unregister_and_done(test, workerScope); + }) + .catch(unreached_rejection(test)); + }, 'periodicSync.register() is rejected when the service worker is not active yet'); + </script> +</body> + +</html>
diff --git a/third_party/blink/web_tests/http/tests/background_sync/periodic_sync_tests.html b/third_party/blink/web_tests/http/tests/background_sync/periodic_sync_tests.html new file mode 100644 index 0000000..9a433f9 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/background_sync/periodic_sync_tests.html
@@ -0,0 +1,29 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Background Sync API: Verifies that Periodic Background Sync works + correctly.</title> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script src="../serviceworker/resources/test-helpers.js"></script> +<script src="/serviceworker/resources/shared-utils.js"></script> +<script src="../resources/permissions-helper.js"></script> +<script src="./resources/utils.js"></script> + +<script> + + periodicSyncTest(async (test, periodicSync) => { + await periodicSync.register('test'); + }, 'register succeeds when no options are provided'); + + periodicSyncTest(async (test, periodicSync) => { + await periodicSync.register('test', {}); + }, 'register succeeds when no minInterval is provided'); + + periodicSyncTest(async (test, periodicSync) => { + await promise_rejects( + test, new TypeError(), + periodicSync.register('test', { minInterval: -1000 }), + 'register should have thrown an error'); + }, 'register fails when invalid minInterval is provided'); + +</script> \ No newline at end of file
diff --git a/third_party/blink/web_tests/http/tests/background_sync/permission_denied.html b/third_party/blink/web_tests/http/tests/background_sync/permission_denied.html index 4ae3018..62895c9 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/permission_denied.html +++ b/third_party/blink/web_tests/http/tests/background_sync/permission_denied.html
@@ -9,8 +9,8 @@ <script> promise_test(test => { - const url = 'resources/empty_worker.js'; - const scope = 'resources/scope/' + location.pathname; + const url = '/resources/empty-worker.js'; + const scope = '/resources/scope/' + location.pathname; let sync_manager = null;
diff --git a/third_party/blink/web_tests/http/tests/background_sync/resources/empty_worker.js b/third_party/blink/web_tests/http/tests/background_sync/resources/empty_worker.js deleted file mode 100644 index b122278..0000000 --- a/third_party/blink/web_tests/http/tests/background_sync/resources/empty_worker.js +++ /dev/null
@@ -1 +0,0 @@ -// Do nothing. \ No newline at end of file
diff --git a/third_party/blink/web_tests/http/tests/background_sync/resources/utils.js b/third_party/blink/web_tests/http/tests/background_sync/resources/utils.js new file mode 100644 index 0000000..fc2e26c8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/background_sync/resources/utils.js
@@ -0,0 +1,12 @@ +'use strict'; + +// Depends on /shared_utils.js +function periodicSyncTest(func, description) { + promise_test(async test => { + await PermissionsHelper.setPermission( + 'periodic-background-sync', 'granted'); + const serviceWorkerRegistration = + await registerAndActivateServiceWorker(test); + return func(test, serviceWorkerRegistration.periodicSync); + }, description); +}
diff --git a/third_party/blink/web_tests/http/tests/background_sync/test-periodic-background-sync-permission.html b/third_party/blink/web_tests/http/tests/background_sync/test-periodic-background-sync-permission.html index 6917d0c..1935bf8e 100644 --- a/third_party/blink/web_tests/http/tests/background_sync/test-periodic-background-sync-permission.html +++ b/third_party/blink/web_tests/http/tests/background_sync/test-periodic-background-sync-permission.html
@@ -3,6 +3,7 @@ <title>Test Periodic Background Sync Permission.</title> <script src="../resources/testharness.js"></script> <script src="../resources/testharnessreport.js"></script> +<script src="../resources/permissions-helper.js"></script> <script> promise_test(test => {
diff --git a/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in-expected.html b/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in-expected.html new file mode 100644 index 0000000..1d983c78 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in-expected.html
@@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html> +<style> +html, body { margin: 0; padding: 0; } +</style> +<body> +<div> +<canvas id="output" width="200" height="200"></canvas> +</div> +<script> +var canvas = document.getElementById('output'); +var ctx = canvas.getContext('2d'); +ctx.fillStyle = 'green'; +ctx.fillRect(0, 0, 200, 200); +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in.html b/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in.html new file mode 100644 index 0000000..bea57b0 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/csspaint/canvas-zoom-in.html
@@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html> +<script src="./resources/test-runner-paint-worklet.js"></script> +<style> +html, body { margin: 0; padding: 0; } +#output { + width: 100px; + height: 100px; + background-image: paint(worklet); +} +</style> +<body> +<div id="output"></div> + +<script id="code" type="text/worklet"> +registerPaint('worklet', class { + paint(ctx, geom) { + ctx.fillStyle = 'green'; + ctx.fillRect(0, 0, geom.width, geom.height); + } +}); +</script> + +<script> + document.body.style.zoom = "200%"; + importPaintWorkletThenEndTest(document.getElementById('code').textContent); +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/http/tests/devtools/layers/layers-3d-view-hit-testing.js b/third_party/blink/web_tests/http/tests/devtools/layers/layers-3d-view-hit-testing.js index b59bcc4..bf7f0fe1 100644 --- a/third_party/blink/web_tests/http/tests/devtools/layers/layers-3d-view-hit-testing.js +++ b/third_party/blink/web_tests/http/tests/devtools/layers/layers-3d-view-hit-testing.js
@@ -5,6 +5,8 @@ (async function() { TestRunner.addResult(`Tests hit testing in Layers3DView\n`); await TestRunner.loadModule('layers_test_runner'); + await TestRunner.showPanel('layers'); + await TestRunner.loadHTML(` <div id="a" style="transform:translateZ(0px) translateY(60px) rotateZ(45deg);width:300px;height:300px;margin-left:100px; border: 1px solid black;"> <div id="b" style="transform:translateX(0px) translateY(0px) translateZ(0px) rotateX(45deg) rotateY(45deg);width:300px;height:300px; border: 1px solid black;"></div> @@ -18,8 +20,6 @@ const ButtonByEventType = {mousemove: -1, mousedown: 0, mouseup: 0}; await LayersTestRunner.requestLayers(); - await TestRunner.showPanel('layers'); - initLayers(); initSizes();
diff --git a/third_party/blink/web_tests/http/tests/background_fetch/resources/empty-worker.js b/third_party/blink/web_tests/http/tests/resources/empty-worker.js similarity index 100% rename from third_party/blink/web_tests/http/tests/background_fetch/resources/empty-worker.js rename to third_party/blink/web_tests/http/tests/resources/empty-worker.js
diff --git a/third_party/blink/web_tests/http/tests/security/agent-equality.html b/third_party/blink/web_tests/http/tests/security/agent-equality.html new file mode 100644 index 0000000..1636973 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/security/agent-equality.html
@@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> +<head> +<title>Agent Equality Test</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<script> +// This test checks whether the JavaScript agent is created in a proper +// granularity. See: +// https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-agent-formalism + +async_test(t => { + var iframe = document.createElement('iframe'); + iframe.src = + 'http://127.0.0.1:8000/security/resources/agent-equality-same-origin.html'; + + window.addEventListener( + 'message', + t.step_func(evt => { + t.add_cleanup(() => { document.body.removeChild(iframe); }); + assert_equals(evt.data.length, 3); + assert_equals(evt.data[0], evt.data[1]); + assert_equals(evt.data[0], evt.data[2]); + t.done(); + }), + {'once': true}); + + document.body.appendChild(iframe); +}, 'Same-origin documents must share the same agent.'); + +// TODO(yutak): Add more tests. +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/http/tests/security/resources/agent-equality-same-origin.html b/third_party/blink/web_tests/http/tests/security/resources/agent-equality-same-origin.html new file mode 100644 index 0000000..a9b20bd --- /dev/null +++ b/third_party/blink/web_tests/http/tests/security/resources/agent-equality-same-origin.html
@@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html> +<head> +<title>Same origin test</title> +</head> +<body> +<iframe id="sub1" src="http://127.0.0.1:8000/security/resources/empty.html"> +</iframe> +<iframe id="sub2" src="http://127.0.0.1:8000/security/resources/empty.html"> +</iframe> +<script> +// This file should be loaded as an iframe hosted on 127.0.0.1:8000. + +// This test creates two sibling subframes both located on 127.0.0.1:8000, and +// report the agent IDs of this document and two subframes. + +function run(evt) { + let sub1 = document.getElementById('sub1'); + let sub2 = document.getElementById('sub2'); + + let message = [ + internals.getDocumentAgentId(document), + internals.getDocumentAgentId(sub1.contentDocument), + internals.getDocumentAgentId(sub2.contentDocument) + ]; + + window.parent.postMessage(message, '*'); +} + +window.addEventListener('load', run, {'once': true}); +</script> +</body> +</html>
diff --git a/third_party/blink/web_tests/http/tests/serviceworker/resources/shared-utils.js b/third_party/blink/web_tests/http/tests/serviceworker/resources/shared-utils.js new file mode 100644 index 0000000..93c90bfe2 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/serviceworker/resources/shared-utils.js
@@ -0,0 +1,12 @@ +'use strict' + +// Depends on /serviceworker/resources/test-helpers.js +async function registerAndActivateServiceWorker(test) { + const script = '/resources/empty-worker.js'; + const scope = '/resources/scope' + location.pathname; + const serviceWorkerRegistration = + await service_worker_unregister_and_register(test, script, scope); + add_completion_callback(() => serviceWorkerRegistration.unregister()); + await wait_for_state(test, serviceWorkerRegistration.installing, 'activated'); + return serviceWorkerRegistration; +}
diff --git a/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt index 6d7b920..46530fa 100644 --- a/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt +++ b/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -1086,6 +1086,14 @@ getter name method constructor method toJSON +interface PeriodicSyncEvent : ExtendableEvent + attribute @@toStringTag + getter tag + method constructor +interface PeriodicSyncManager + attribute @@toStringTag + method constructor + method register interface PermissionStatus : EventTarget attribute @@toStringTag getter onchange @@ -1234,6 +1242,7 @@ getter navigationPreload getter onupdatefound getter paymentManager + getter periodicSync getter pushManager getter scope getter sync @@ -3667,6 +3676,7 @@ getter onnotificationclick getter onnotificationclose getter onpaymentrequest + getter onperiodicsync getter onpush getter onsync getter registration @@ -3688,6 +3698,7 @@ setter onnotificationclick setter onnotificationclose setter onpaymentrequest + setter onperiodicsync setter onpush setter onsync PASS Verify the interface of ServiceWorkerGlobalScope
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-expected.png deleted file mode 100644 index 27916cb..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png deleted file mode 100644 index bc6012dd..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png deleted file mode 100644 index bc6012dd..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 54fb80c5..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index f8552621..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png deleted file mode 100644 index 639ad18..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index c038964f..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 7cdc73f..0000000 --- a/third_party/blink/web_tests/platform/linux/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-expected.png deleted file mode 100644 index 30ea5b5..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png deleted file mode 100644 index 0e61c71..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png deleted file mode 100644 index 0e61c71..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index f76879e..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index 998da681..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png deleted file mode 100644 index 4dade790..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index f22a1edd..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index d68533d..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-expected.png deleted file mode 100644 index 6c2b505..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png deleted file mode 100644 index 0fca354..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png deleted file mode 100644 index 0fca354..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index cddd14f4..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index ce00c9c..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png deleted file mode 100644 index ad30d563..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index 68eb023..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 7c17f831..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index 582e8d7..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index c943b40..0000000 --- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-expected.png deleted file mode 100644 index 5d14614..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png deleted file mode 100644 index de1589d..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png deleted file mode 100644 index de1589d..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index edfff76..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index 655a48e..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png deleted file mode 100644 index 690a9708..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index d8b3992..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 6d5471288..0000000 --- a/third_party/blink/web_tests/platform/mac/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-expected.png deleted file mode 100644 index 0b43e7be..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png deleted file mode 100644 index e6de28dc..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-over-placeholder-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png deleted file mode 100644 index e6de28dc..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggested-value-when-underlying-placeholder-is-removed-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 5429c3d..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index df42b059..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png deleted file mode 100644 index 14a3face..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/input-appearance-autocomplete-with-initial-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/password-input-suggested-value-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/password-input-suggested-value-appearance-expected.png deleted file mode 100644 index d59d461..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/password-input-suggested-value-appearance-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png deleted file mode 100644 index 3a88be45..0000000 --- a/third_party/blink/web_tests/platform/win/fast/forms/text/textarea-appearance-autocomplete-suggestion-maxlength-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png deleted file mode 100644 index a1e8ee0..0000000 --- a/third_party/blink/web_tests/platform/win7/fast/forms/text/input-appearance-autocomplete-very-long-value-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt index 608b4ca..50a3a685 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -1024,6 +1024,10 @@ [Worker] getter name [Worker] method constructor [Worker] method toJSON +[Worker] interface PeriodicSyncManager +[Worker] attribute @@toStringTag +[Worker] method constructor +[Worker] method register [Worker] interface PermissionStatus : EventTarget [Worker] attribute @@toStringTag [Worker] getter onchange @@ -1178,6 +1182,7 @@ [Worker] getter navigationPreload [Worker] getter onupdatefound [Worker] getter paymentManager +[Worker] getter periodicSync [Worker] getter pushManager [Worker] getter scope [Worker] getter sync
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt index cb3cf6a7..f36f1b8 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -5527,6 +5527,10 @@ getter unloadEventStart method constructor method toJSON +interface PeriodicSyncManager + attribute @@toStringTag + method constructor + method register interface PeriodicWave attribute @@toStringTag method constructor @@ -7420,6 +7424,7 @@ getter navigationPreload getter onupdatefound getter paymentManager + getter periodicSync getter pushManager getter scope getter sync
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt index e367e63f..2397eaa 100644 --- a/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt +++ b/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -1006,6 +1006,10 @@ [Worker] getter name [Worker] method constructor [Worker] method toJSON +[Worker] interface PeriodicSyncManager +[Worker] attribute @@toStringTag +[Worker] method constructor +[Worker] method register [Worker] interface PermissionStatus : EventTarget [Worker] attribute @@toStringTag [Worker] getter onchange @@ -1141,6 +1145,7 @@ [Worker] getter navigationPreload [Worker] getter onupdatefound [Worker] getter paymentManager +[Worker] getter periodicSync [Worker] getter pushManager [Worker] getter scope [Worker] getter sync
diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index 3b8e5e9f..64a05d10 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn
@@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/compiler/compiler.gni") + if (current_cpu == "arm" || current_cpu == "arm64") { import("//build/config/arm.gni") } @@ -102,7 +104,7 @@ assert(false, "CPU detection requires the Android NDK") } } else if (!is_win && !is_clang) { - assert(!thin_lto_enable_optimizations, + assert(!use_thin_lto, "ThinLTO fails mixing different module-level targets") cflags_c = [ "-march=armv8-a+crc" ] }
diff --git a/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java b/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java index c529a24..c2418f0 100644 --- a/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java +++ b/tools/android/customtabs_benchmark/java/src/org/chromium/customtabs/test/MainActivity.java
@@ -188,7 +188,7 @@ startActivity(intent); } - private void launchChrome(final String url, final boolean warmup, String parallelUrl) { + private void launchChrome(String url, boolean warmup, String parallelUrl) { CustomTabsServiceConnection connection = new CustomTabsServiceConnection() { @Override public void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client) { @@ -278,6 +278,27 @@ return System.currentTimeMillis(); } + /** + * Holds immutable parameters of the benchmark that are not needed after launching an intent. + * + * There are a few parameters that need to be written to the CSV line, those better fit in the + * {@link CustomCallback}. + */ + private static class LaunchInfo { + public final String url; + public final String speculatedUrl; + public final String parallelUrl; + public final int timeoutSeconds; + + public LaunchInfo( + String url, String speculatedUrl, String parallelUrl, int timeoutSeconds) { + this.url = url; + this.speculatedUrl = speculatedUrl; + this.parallelUrl = parallelUrl; + this.timeoutSeconds = timeoutSeconds; + } + } + /** Start the second benchmark mode. * * NOTE: Methods below are for the second mode. @@ -308,46 +329,46 @@ Math.max(delayToMayLaunchUrl, PARALLEL_REQUEST_MIN_DELAY_AFTER_WARMUP); } - launchCustomTabs(packageName, speculatedUrl, url, warmup, skipLauncherActivity, - speculationMode, delayToMayLaunchUrl, delayToLaunchUrl, timeoutSeconds, - parallelUrl); + final CustomCallback cb = new CustomCallback(packageName, warmup, skipLauncherActivity, + speculationMode, delayToMayLaunchUrl, delayToLaunchUrl); + launchCustomTabs(cb, new LaunchInfo(url, speculatedUrl, parallelUrl, timeoutSeconds)); } private final class CustomCallback extends CustomTabsCallback { - private final String mPackageName; - private final boolean mWarmup; - private final boolean mSkipLauncherActivity; - private final String mSpeculationMode; - private final int mDelayToMayLaunchUrl; - private final int mDelayToLaunchUrl; - public boolean mWarmupCompleted; - private long mIntentSentMs = NONE; - private long mPageLoadStartedMs = NONE; - private long mPageLoadFinishedMs = NONE; - private long mFirstContentfulPaintMs = NONE; + public final String packageName; + public final boolean warmup; + public final boolean skipLauncherActivity; + public final String speculationMode; + public final int delayToMayLaunchUrl; + public final int delayToLaunchUrl; + public boolean warmupCompleted; + public long intentSentMs = NONE; + public long pageLoadStartedMs = NONE; + public long pageLoadFinishedMs = NONE; + public long firstContentfulPaintMs = NONE; public CustomCallback(String packageName, boolean warmup, boolean skipLauncherActivity, String speculationMode, int delayToMayLaunchUrl, int delayToLaunchUrl) { - mPackageName = packageName; - mWarmup = warmup; - mSkipLauncherActivity = skipLauncherActivity; - mSpeculationMode = speculationMode; - mDelayToMayLaunchUrl = delayToMayLaunchUrl; - mDelayToLaunchUrl = delayToLaunchUrl; + this.packageName = packageName; + this.warmup = warmup; + this.skipLauncherActivity = skipLauncherActivity; + this.speculationMode = speculationMode; + this.delayToMayLaunchUrl = delayToMayLaunchUrl; + this.delayToLaunchUrl = delayToLaunchUrl; } public void recordIntentHasBeenSent() { - mIntentSentMs = SystemClock.uptimeMillis(); + intentSentMs = SystemClock.uptimeMillis(); } @Override public void onNavigationEvent(int navigationEvent, Bundle extras) { switch (navigationEvent) { case CustomTabsCallback.NAVIGATION_STARTED: - mPageLoadStartedMs = SystemClock.uptimeMillis(); + pageLoadStartedMs = SystemClock.uptimeMillis(); break; case CustomTabsCallback.NAVIGATION_FINISHED: - mPageLoadFinishedMs = SystemClock.uptimeMillis(); + pageLoadFinishedMs = SystemClock.uptimeMillis(); break; default: break; @@ -358,7 +379,7 @@ @Override public void extraCallback(String callbackName, Bundle args) { if ("onWarmupCompleted".equals(callbackName)) { - mWarmupCompleted = true; + warmupCompleted = true; return; } @@ -370,25 +391,25 @@ long navigationStartMs = args.getLong("navigationStart", NONE); if (firstPaintMs == NONE || navigationStartMs == NONE) return; // Can be reported several times, only record the first one. - if (mFirstContentfulPaintMs == NONE) { - mFirstContentfulPaintMs = navigationStartMs + firstPaintMs; + if (firstContentfulPaintMs == NONE) { + firstContentfulPaintMs = navigationStartMs + firstPaintMs; } if (allSet()) logMetricsAndFinish(); } private boolean allSet() { - return mIntentSentMs != NONE && mPageLoadStartedMs != NONE - && mFirstContentfulPaintMs != NONE && mPageLoadFinishedMs != NONE; + return intentSentMs != NONE && pageLoadStartedMs != NONE + && firstContentfulPaintMs != NONE && pageLoadFinishedMs != NONE; } /** Outputs the available metrics, and die. Unavalaible metrics are set to -1. */ private void logMetricsAndFinish() { - String logLine = (mWarmup ? "1" : "0") + "," + (mSkipLauncherActivity ? "1" : "0") + "," - + mSpeculationMode + "," + mDelayToMayLaunchUrl + "," + mDelayToLaunchUrl + "," - + mIntentSentMs + "," + mPageLoadStartedMs + "," + mPageLoadFinishedMs + "," - + mFirstContentfulPaintMs; + String logLine = (warmup ? "1" : "0") + "," + (skipLauncherActivity ? "1" : "0") + "," + + speculationMode + "," + delayToMayLaunchUrl + "," + delayToLaunchUrl + "," + + intentSentMs + "," + pageLoadStartedMs + "," + pageLoadFinishedMs + "," + + firstContentfulPaintMs; Log.w(TAGCSV, logLine); - logMemory(mPackageName, "AfterMetrics"); + logMemory(packageName, "AfterMetrics"); MainActivity.this.finish(); } @@ -482,70 +503,54 @@ if (!ok) throw new RuntimeException("Cannot set the speculation mode"); } - private void onCustomTabsServiceConnected(CustomTabsClient client, final Uri speculatedUri, - final Uri uri, final CustomCallback cb, boolean warmup, boolean skipLauncherActivity, - String speculationMode, int delayToMayLaunchUrl, final int delayToLaunchUrl, - final int timeoutSeconds, final String packageName, final String parallelUrl) { + private void onCustomTabsServiceConnected( + CustomTabsClient client, CustomCallback cb, LaunchInfo launchInfo) { + logMemory(cb.packageName, "OnServiceConnected"); + final CustomTabsSession session = client.newSession(cb); final CustomTabsIntent intent = (new CustomTabsIntent.Builder(session)).build(); - - logMemory(packageName, "OnServiceConnected"); - IBinder sessionBinder = BundleCompat.getBinder(intent.intent.getExtras(), CustomTabsIntent.EXTRA_SESSION); assert sessionBinder != null; - forceSpeculationMode(client, sessionBinder, speculationMode); + forceSpeculationMode(client, sessionBinder, cb.speculationMode); - final Runnable launchRunnable = new Runnable() { - @Override - public void run() { - logMemory(packageName, "BeforeLaunch"); + final Runnable launchRunnable = () -> { + logMemory(cb.packageName, "BeforeLaunch"); - if (cb.mWarmupCompleted) { - maybePrepareParallelUrlRequest(parallelUrl, client, intent, sessionBinder); - } else { - Log.e(TAG, "not warmed up yet!"); - } - - intent.launchUrl(MainActivity.this, uri); - cb.recordIntentHasBeenSent(); - if (timeoutSeconds != NONE) cb.logMetricsAndFinishDelayed(timeoutSeconds * 1000); + if (cb.warmupCompleted) { + maybePrepareParallelUrlRequest( + launchInfo.parallelUrl, client, intent, sessionBinder); + } else { + Log.e(TAG, "not warmed up yet!"); } - }; - Runnable mayLaunchRunnable = new Runnable() { - @Override - public void run() { - logMemory(packageName, "BeforeMayLaunchUrl"); - session.mayLaunchUrl(speculatedUri, null, null); - mHandler.postDelayed(launchRunnable, delayToLaunchUrl); - } + + intent.launchUrl(MainActivity.this, Uri.parse(launchInfo.url)); + cb.recordIntentHasBeenSent(); + if (launchInfo.timeoutSeconds != NONE) + cb.logMetricsAndFinishDelayed(launchInfo.timeoutSeconds * 1000); }; - if (warmup) client.warmup(0); - if (delayToMayLaunchUrl != NONE) { - mHandler.postDelayed(mayLaunchRunnable, delayToMayLaunchUrl); + Runnable mayLaunchRunnable = () -> { + logMemory(cb.packageName, "BeforeMayLaunchUrl"); + session.mayLaunchUrl(Uri.parse(launchInfo.speculatedUrl), null, null); + mHandler.postDelayed(launchRunnable, cb.delayToLaunchUrl); + }; + + if (cb.warmup) client.warmup(0); + if (cb.delayToMayLaunchUrl != NONE) { + mHandler.postDelayed(mayLaunchRunnable, cb.delayToMayLaunchUrl); } else { - mHandler.postDelayed(launchRunnable, delayToLaunchUrl); + mHandler.postDelayed(launchRunnable, cb.delayToLaunchUrl); } } - private void launchCustomTabs(final String packageName, String speculatedUrl, String url, - final boolean warmup, final boolean skipLauncherActivity, final String speculationMode, - final int delayToMayLaunchUrl, final int delayToLaunchUrl, final int timeoutSeconds, - String parallelUrl) { - final CustomCallback cb = new CustomCallback(packageName, warmup, skipLauncherActivity, - speculationMode, delayToMayLaunchUrl, delayToLaunchUrl); - final Uri speculatedUri = Uri.parse(speculatedUrl); - final Uri uri = Uri.parse(url); + private void launchCustomTabs(CustomCallback cb, LaunchInfo launchInfo) { CustomTabsClient.bindCustomTabsService( - this, packageName, new CustomTabsServiceConnection() { + this, cb.packageName, new CustomTabsServiceConnection() { @Override public void onCustomTabsServiceConnected( ComponentName name, final CustomTabsClient client) { - MainActivity.this.onCustomTabsServiceConnected(client, speculatedUri, uri, - cb, warmup, skipLauncherActivity, speculationMode, - delayToMayLaunchUrl, delayToLaunchUrl, timeoutSeconds, packageName, - parallelUrl); + MainActivity.this.onCustomTabsServiceConnected(client, cb, launchInfo); } @Override
diff --git a/tools/infra/.style.yapf b/tools/infra/.style.yapf new file mode 100644 index 0000000..ef24bfc6 --- /dev/null +++ b/tools/infra/.style.yapf
@@ -0,0 +1,6 @@ +[style] +based_on_style = pep8 +column_limit = 80 +blank_line_before_nested_class_or_def = true +blank_line_before_module_docstring = true +indent_width = 2
diff --git a/tools/infra/PRESUBMIT.py b/tools/infra/PRESUBMIT.py index ea85a90..77e4c07 100644 --- a/tools/infra/PRESUBMIT.py +++ b/tools/infra/PRESUBMIT.py
@@ -10,15 +10,14 @@ def _CommonChecks(input_api, output_api): - commands = [] + results = [] + results.extend(input_api.canned_checks.RunPylint(input_api, output_api)) + commands = [] commands.extend(input_api.canned_checks.GetUnitTestsRecursively( input_api, output_api, input_api.os_path.join(input_api.PresubmitLocalPath()), whitelist=[r'.+_unittest\.py$'], blacklist=[])) - - results = [] - results.extend(input_api.RunTests(commands)) return results
diff --git a/tools/infra/clobber.py b/tools/infra/clobber.py new file mode 100755 index 0000000..9f493f6 --- /dev/null +++ b/tools/infra/clobber.py
@@ -0,0 +1,103 @@ +#!/usr/bin/env python +# Copyright 2019 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. + +"""Clobbers all builder caches for a specific builder. + +Note that this currently does not support windows. +""" + +from __future__ import print_function + +import argparse +import hashlib +import os +import subprocess +import sys + +_SRC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) +_SWARMING_CLIENT = os.path.join(_SRC_ROOT, 'tools', 'swarming_client', + 'swarming.py') +_SWARMING_SERVER = 'chromium-swarm.appspot.com' + + +def _get_bots(pool, cache): + cmd = [ + sys.executable, + _SWARMING_CLIENT, + 'bots', + '-b', + '-S', + _SWARMING_SERVER, + '-d', + 'caches', + cache, + '-d', + 'pool', + pool, + ] + return subprocess.check_output(cmd).splitlines() + + +def _trigger_clobber(pool, cache, bot, dry_run): + cmd = [ + sys.executable, + _SWARMING_CLIENT, + 'trigger', + '-S', + _SWARMING_SERVER, + '-d', + 'pool', + pool, + '-d', + 'id', + bot, + '--named-cache', + cache, + 'cache/builder', + '--priority=10', + '--raw-cmd', + '--', + # TODO(jbudorick): Generalize this for windows. + '/bin/rm', + '-rf', + 'cache/builder', + ] + if dry_run: + print('Would run `%s`' % ' '.join(cmd)) + else: + subprocess.check_call(cmd) + + +def main(raw_args): + parser = argparse.ArgumentParser() + parser.add_argument('--builder', required=True) + parser.add_argument('--pool', required=True, choices=['ci', 'try']) + parser.add_argument('-n', '--dry-run', action='store_true') + args = parser.parse_args(raw_args) + + # Matches http://bit.ly/2WZO33P + h = hashlib.sha256('chromium/%s/%s' % (args.pool, args.builder)) + cache_name = 'builder_%s_v2' % (h.hexdigest()) + swarming_pool = 'luci.chromium.%s' % args.pool + + bots = _get_bots(swarming_pool, cache_name) + + print('The following bots will be clobbered:') + print() + for bot in bots: + print(' %s' % bot) + print() + val = raw_input('Proceed? [Y/n] ') + if val and not val[0] in ('Y', 'y'): + print('Cancelled.') + return 1 + + for bot in bots: + _trigger_clobber(swarming_pool, cache_name, bot, args.dry_run) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:]))
diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml index 94844af9..b8ff890 100644 --- a/tools/metrics/actions/actions.xml +++ b/tools/metrics/actions/actions.xml
@@ -11805,6 +11805,14 @@ <description>User pressed 'History' in the app menu.</description> </action> +<action name="MobileMenuIncognitoSearch"> + <owner>gambard@chromium.org</owner> + <description> + The user tapped the "Incognito Search" button in the mobile menu + displayed when long pressing the New Tab button. + </description> +</action> + <action name="MobileMenuNewIncognitoTab"> <owner>aurimas@chromium.org</owner> <description>User pressed 'New incognito tab' in the app menu.</description> @@ -11891,6 +11899,14 @@ <description>User pressed 'Scan QR Code' in the app menu.</description> </action> +<action name="MobileMenuSearch"> + <owner>gambard@chromium.org</owner> + <description> + The user tapped the "New Search" button in the mobile menu + displayed when long pressing the New Tab button. + </description> +</action> + <action name="MobileMenuSearchCopiedImage"> <owner>rkgibson@google.com</owner> <description>User pressed 'Search Copied Image' in the app menu.</description> @@ -13061,6 +13077,13 @@ <description>Please enter the description of this user action.</description> </action> +<action name="MobileToolbarShowNewTabMenu"> + <owner>gambard@chromium.org</owner> + <description> + The user long-pressed on the NewTab button in the toolbar + </description> +</action> + <action name="MobileToolbarShowSearchMenu"> <owner>gambard@chromium.org</owner> <description>
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index ef1fd13..de495558 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -19773,6 +19773,10 @@ <int value="1343" label="DECLARATIVENETREQUEST_GETMATCHEDRULES"/> <int value="1344" label="DECLARATIVENETREQUEST_SETACTIONCOUNTASBADGETEXT"/> <int value="1345" label="BLUETOOTHPRIVATE_RECORDDEVICESELECTION"/> + <int value="1346" label="LOGIN_LAUNCHMANAGEDGUESTSESSION"/> + <int value="1347" label="LOGIN_EXITCURRENTSESSION"/> + <int value="1348" label="LOGIN_ISRUNNINGINLOGINPROFILE"/> + <int value="1349" label="LOGIN_FETCHDATAFORNEXTLOGINATTEMPT"/> </enum> <enum name="ExtensionIconState"> @@ -20305,6 +20309,7 @@ <int value="217" label="kLoginScreenUi"/> <int value="218" label="kDeclarativeNetRequestFeedback"/> <int value="219" label="kTransientBackground"/> + <int value="220" label="kLogin"/> </enum> <enum name="ExtensionServiceVerifyAllSuccess"> @@ -23712,6 +23717,8 @@ <int value="2927" label="LargestContentfulPaintExplicitlyRequested"/> <int value="2928" label="PageLifecycleTransitionsOptIn"/> <int value="2929" label="PageLifecycleTransitionsOptOut"/> + <int value="2930" label="PeriodicBackgroundSync"/> + <int value="2931" label="PeriodicBackgroundSyncRegister"/> </enum> <enum name="FeaturePolicyAllowlistType"> @@ -46830,6 +46837,9 @@ </enum> <enum name="PostSubmitNavigation"> + <obsolete> + Deprecated 06/2019. + </obsolete> <int value="0" label="Same domain"/> <int value="1" label="Different domain"/> </enum>
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 1103684..c78b82301 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml
@@ -3124,6 +3124,9 @@ <histogram name="Android.StrictMode.DownloadsDir" units="ms" expires_after="M77"> + <obsolete> + Removed from code June 2019. See https://crbug.com/508615 for context. + </obsolete> <owner>wnwen@chromium.org</owner> <owner>yfriedman@chromium.org</owner> <summary> @@ -3186,6 +3189,9 @@ <histogram name="Android.StrictMode.WebappAuthenticatorMac" units="ms" expires_after="M77"> + <obsolete> + Removed from code June 2019. + </obsolete> <owner>wnwen@chromium.org</owner> <owner>yfriedman@chromium.org</owner> <summary> @@ -3195,6 +3201,9 @@ </histogram> <histogram name="Android.StrictMode.WebappDir" units="ms" expires_after="M77"> + <obsolete> + Removed from code June 2019. + </obsolete> <owner>wnwen@chromium.org</owner> <owner>yfriedman@chromium.org</owner> <summary> @@ -3205,6 +3214,9 @@ <histogram name="Android.StrictMode.WebappSaveState" units="ms" expires_after="M77"> + <obsolete> + Removed from code June 2019. + </obsolete> <owner>wnwen@chromium.org</owner> <owner>yfriedman@chromium.org</owner> <summary> @@ -91172,7 +91184,7 @@ </histogram> <histogram name="PasswordManager.AcceptedSaveUpdateSubmissionIndicatorEvent" - enum="SubmissionIndicatorEvent" expires_after="M77"> + enum="SubmissionIndicatorEvent" expires_after="M85"> <owner>dvadym@chromium.org</owner> <owner>vasilii@chromium.org</owner> <summary> @@ -91720,6 +91732,16 @@ </summary> </histogram> +<histogram name="PasswordManager.DropdownShown.OffTheRecord" + expires_after="M85"> + <owner>rhalavati@chromium.org</owner> + <owner>chrome-privacy-core@google.com</owner> + <summary> + Records availability of password manager suggestions in regular and + off-the-record modes. + </summary> +</histogram> + <histogram name="PasswordManager.DynamicFormChanges" expires_after="M78"> <owner>battre@chromium.org</owner> <owner>dvadym@chromium.org</owner> @@ -91834,7 +91856,7 @@ </histogram> <histogram name="PasswordManager.Enabled" enum="BooleanEnabled" - expires_after="M77"> + expires_after="M85"> <owner>dvadym@chromium.org</owner> <owner>vasilii@chromium.org</owner> <summary> @@ -92167,6 +92189,15 @@ </summary> </histogram> +<histogram name="PasswordManager.ItemSelected.OffTheRecord" expires_after="M85"> + <owner>rhalavati@chromium.org</owner> + <owner>chrome-privacy-core@google.com</owner> + <summary> + Records selection of password manager suggestions in regular and + off-the-record modes. + </summary> +</histogram> + <histogram name="PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords"> <obsolete> @@ -92180,6 +92211,9 @@ </histogram> <histogram name="PasswordManager.KeychainMigration.NumFailedPasswords"> + <obsolete> + Deprecated as of 06/2019. + </obsolete> <owner>vasilii@chromium.org</owner> <summary> After migration from the Mac Keychain fails, records the number of passwords @@ -92189,6 +92223,9 @@ </histogram> <histogram name="PasswordManager.KeychainMigration.NumPasswordsOnFailure"> + <obsolete> + Deprecated as of 06/2019. + </obsolete> <owner>vasilii@chromium.org</owner> <summary> After migration from the Mac Keychain fails, records the number of passwords @@ -92199,6 +92236,9 @@ <histogram name="PasswordManager.KeychainMigration.Status" enum="KeychainMigrationStatus" expires_after="M77"> + <obsolete> + Deprecated as of 06/2019. + </obsolete> <owner>vasilii@chromium.org</owner> <summary> The status of passwords migration from the Keychain. It's recorded shortly @@ -93017,6 +93057,9 @@ <histogram name="PasswordManager.SubmitNavigatesToDifferentDomain" enum="PostSubmitNavigation" expires_after="M77"> + <obsolete> + Deprecated 06/2019. + </obsolete> <owner>dvadym@chromium.org</owner> <summary> Indicates whether submitting a password login form changes the registry @@ -93025,7 +93068,7 @@ </histogram> <histogram name="PasswordManager.SubmittedFormFrame" - enum="SubmittedPasswordFormFrame" expires_after="M77"> + enum="SubmittedPasswordFormFrame" expires_after="M85"> <owner>dvadym@chromium.org</owner> <owner>vasilii@chromium.org</owner> <summary> @@ -93067,7 +93110,7 @@ </histogram> <histogram name="PasswordManager.SuccessfulSubmissionIndicatorEvent" - enum="SubmissionIndicatorEvent"> + enum="SubmissionIndicatorEvent" expires_after="M85"> <owner>dvadym@chromium.org</owner> <owner>engedy@chromium.org</owner> <summary>
diff --git a/tools/perf/benchmarks/rendering.py b/tools/perf/benchmarks/rendering.py index 0328b090..2845667 100644 --- a/tools/perf/benchmarks/rendering.py +++ b/tools/perf/benchmarks/rendering.py
@@ -39,7 +39,9 @@ options = timeline_based_measurement.Options(category_filter) options.config.chrome_trace_config.EnableUMAHistograms( 'Event.Latency.ScrollBegin.Touch.TimeToScrollUpdateSwapBegin4', - 'Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin4') + 'Event.Latency.ScrollUpdate.Touch.TimeToScrollUpdateSwapBegin4', + 'Event.Latency.ScrollBegin.Wheel.TimeToScrollUpdateSwapBegin4', + 'Event.Latency.ScrollUpdate.Wheel.TimeToScrollUpdateSwapBegin4') options.SetTimelineBasedMetrics(['renderingMetric', 'umaMetric']) return options
diff --git a/tools/perf/expectations.config b/tools/perf/expectations.config index ed7fe47..d7e28d7 100644 --- a/tools/perf/expectations.config +++ b/tools/perf/expectations.config
@@ -189,6 +189,9 @@ crbug.com/865400 [ Pixel2_Webview ] loading.mobile/VoiceMemos_cold_3g [ Skip ] crbug.com/919191 [ Nexus5X_Webview ] loading.mobile/OLX_3g [ Skip ] +# Benchmark: media.desktop +crbug.com/978045 [ All ] media.desktop/mse.html?media=tulip2.vp9.webm [ Skip ] + # Benchmark: oilpan_gc_times.key_silk_cases crbug.com/446332 [ All ] oilpan_gc_times.key_silk_cases/slide_drawer [ Skip ] crbug.com/507865 [ All ] oilpan_gc_times.key_silk_cases/polymer_topeka [ Skip ]
diff --git a/ui/accessibility/platform/ax_platform_node_auralinux.cc b/ui/accessibility/platform/ax_platform_node_auralinux.cc index d076722..4d4869a7 100644 --- a/ui/accessibility/platform/ax_platform_node_auralinux.cc +++ b/ui/accessibility/platform/ax_platform_node_auralinux.cc
@@ -1769,6 +1769,9 @@ if (!obj) return nullptr; + if (index < 0 || index >= obj->GetChildCount()) + return nullptr; + AtkObject* result = obj->ChildAtIndex(index); if (result) g_object_ref(result);
diff --git a/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc b/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc index faab37bb..ae0050a 100644 --- a/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc
@@ -475,6 +475,18 @@ EXPECT_TRUE(ATK_IS_OBJECT(result)); EXPECT_EQ(result, root_obj); } + + // Test invalid indices. + AtkObject* result = atk_object_ref_accessible_child(root_obj, -1); + EXPECT_EQ(result, nullptr); + result = atk_object_ref_accessible_child(root_obj, -88); + EXPECT_EQ(result, nullptr); + result = atk_object_ref_accessible_child(root_obj, 3); + EXPECT_EQ(result, nullptr); + result = atk_object_ref_accessible_child(root_obj, 1000); + EXPECT_EQ(result, nullptr); + result = atk_object_ref_accessible_child(root_obj, 828282); + EXPECT_EQ(result, nullptr); } TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectIndexInParent) {
diff --git a/ui/android/BUILD.gn b/ui/android/BUILD.gn index ecc9d03..8c2b712 100644 --- a/ui/android/BUILD.gn +++ b/ui/android/BUILD.gn
@@ -111,7 +111,6 @@ "java/src/org/chromium/ui/resources/ResourceFactory.java", "java/src/org/chromium/ui/resources/ResourceManager.java", ] - jni_package = "ui_android" } java_cpp_enum("java_enums_srcjar") { @@ -275,6 +274,7 @@ "java/src/org/chromium/ui/interpolators/BakedBezierInterpolator.java", "java/src/org/chromium/ui/modaldialog/DialogDismissalCause.java", "java/src/org/chromium/ui/modaldialog/ModalDialogManager.java", + "java/src/org/chromium/ui/modaldialog/ModalDialogManagerHolder.java", "java/src/org/chromium/ui/modaldialog/ModalDialogProperties.java", "java/src/org/chromium/ui/modelutil/ForwardingListObservable.java", "java/src/org/chromium/ui/modelutil/LazyConstructionPropertyMcp.java",
diff --git a/ui/android/DEPS b/ui/android/DEPS index 0d168155..ffceb86 100644 --- a/ui/android/DEPS +++ b/ui/android/DEPS
@@ -12,7 +12,7 @@ "+components/viz/host", "+components/viz/service/frame_sinks", "+components/viz/service/surfaces", - "+jni", + "+ui/android/ui_android_jni_headers", "+services/viz/public/interfaces", "+skia/ext", "+third_party/blink/public/platform/web_cursor_info.h",
diff --git a/ui/android/display_android_manager.cc b/ui/android/display_android_manager.cc index 8509bd7b..f85b524 100644 --- a/ui/android/display_android_manager.cc +++ b/ui/android/display_android_manager.cc
@@ -9,8 +9,8 @@ #include "base/android/jni_android.h" #include "base/stl_util.h" -#include "jni/DisplayAndroidManager_jni.h" #include "ui/android/screen_android.h" +#include "ui/android/ui_android_jni_headers/DisplayAndroidManager_jni.h" #include "ui/android/window_android.h" #include "ui/display/display.h" #include "ui/gfx/icc_profile.h"
diff --git a/ui/android/event_forwarder.cc b/ui/android/event_forwarder.cc index 8f8d0f1..cd3643c 100644 --- a/ui/android/event_forwarder.cc +++ b/ui/android/event_forwarder.cc
@@ -5,7 +5,7 @@ #include "ui/android/event_forwarder.h" #include "base/android/jni_array.h" -#include "jni/EventForwarder_jni.h" +#include "ui/android/ui_android_jni_headers/EventForwarder_jni.h" #include "ui/android/window_android.h" #include "ui/base/ui_base_switches_util.h" #include "ui/events/android/drag_event_android.h"
diff --git a/ui/android/handle_view_resources.cc b/ui/android/handle_view_resources.cc index 3214121..6bfd487 100644 --- a/ui/android/handle_view_resources.cc +++ b/ui/android/handle_view_resources.cc
@@ -5,7 +5,7 @@ #include "ui/android/handle_view_resources.h" #include "base/trace_event/trace_event.h" -#include "jni/HandleViewResources_jni.h" +#include "ui/android/ui_android_jni_headers/HandleViewResources_jni.h" namespace {
diff --git a/ui/android/java/src/org/chromium/ui/modaldialog/ModalDialogManagerHolder.java b/ui/android/java/src/org/chromium/ui/modaldialog/ModalDialogManagerHolder.java new file mode 100644 index 0000000..7ffde56 --- /dev/null +++ b/ui/android/java/src/org/chromium/ui/modaldialog/ModalDialogManagerHolder.java
@@ -0,0 +1,15 @@ +// Copyright 2019 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.ui.modaldialog; + +/** + * Classes that hold an instance of {@link ModalDialogManager} should implement this interface. + */ +public interface ModalDialogManagerHolder { + /** + * @return The {@link ModalDialogManager} associated with this class + */ + ModalDialogManager getModalDialogManager(); +}
diff --git a/ui/android/overscroll_refresh_handler.cc b/ui/android/overscroll_refresh_handler.cc index ca1fcd7..1940b44 100644 --- a/ui/android/overscroll_refresh_handler.cc +++ b/ui/android/overscroll_refresh_handler.cc
@@ -5,7 +5,7 @@ #include "ui/android/overscroll_refresh_handler.h" #include "base/android/jni_android.h" -#include "jni/OverscrollRefreshHandler_jni.h" +#include "ui/android/ui_android_jni_headers/OverscrollRefreshHandler_jni.h" using base::android::AttachCurrentThread;
diff --git a/ui/android/resources/resource_factory.cc b/ui/android/resources/resource_factory.cc index aa322193..24c978ca 100644 --- a/ui/android/resources/resource_factory.cc +++ b/ui/android/resources/resource_factory.cc
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "jni/ResourceFactory_jni.h" #include "ui/android/resources/nine_patch_resource.h" +#include "ui/android/ui_android_jni_headers/ResourceFactory_jni.h" #include "ui/gfx/geometry/rect.h" using base::android::JavaParamRef;
diff --git a/ui/android/resources/resource_manager_impl.cc b/ui/android/resources/resource_manager_impl.cc index bc900780..586b0a5 100644 --- a/ui/android/resources/resource_manager_impl.cc +++ b/ui/android/resources/resource_manager_impl.cc
@@ -21,11 +21,11 @@ #include "base/trace_event/trace_event.h" #include "cc/resources/scoped_ui_resource.h" #include "cc/resources/ui_resource_manager.h" -#include "jni/ResourceManager_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkColorFilter.h" #include "ui/android/resources/ui_resource_provider.h" +#include "ui/android/ui_android_jni_headers/ResourceManager_jni.h" #include "ui/android/window_android.h" #include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/geometry/rect.h"
diff --git a/ui/android/view_android.cc b/ui/android/view_android.cc index 559cce1..e9b2fe54 100644 --- a/ui/android/view_android.cc +++ b/ui/android/view_android.cc
@@ -14,9 +14,9 @@ #include "base/stl_util.h" #include "cc/layers/layer.h" #include "components/viz/common/frame_sinks/copy_output_request.h" -#include "jni/ViewAndroidDelegate_jni.h" #include "third_party/blink/public/platform/web_cursor_info.h" #include "ui/android/event_forwarder.h" +#include "ui/android/ui_android_jni_headers/ViewAndroidDelegate_jni.h" #include "ui/android/window_android.h" #include "ui/base/layout.h" #include "ui/events/android/drag_event_android.h"
diff --git a/ui/android/window_android.cc b/ui/android/window_android.cc index d49b7fe..db967aa 100644 --- a/ui/android/window_android.cc +++ b/ui/android/window_android.cc
@@ -16,8 +16,8 @@ #include "base/stl_util.h" #include "components/viz/common/frame_sinks/begin_frame_args.h" #include "components/viz/common/frame_sinks/begin_frame_source.h" -#include "jni/WindowAndroid_jni.h" #include "ui/android/display_android_manager.h" +#include "ui/android/ui_android_jni_headers/WindowAndroid_jni.h" #include "ui/android/window_android_compositor.h" #include "ui/android/window_android_observer.h" #include "ui/base/ui_base_features.h"
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn index 087e27c..4cf72b162 100644 --- a/ui/base/BUILD.gn +++ b/ui/base/BUILD.gn
@@ -759,7 +759,6 @@ "../android/java/src/org/chromium/ui/base/SelectFileDialog.java", "../android/java/src/org/chromium/ui/base/TouchDevice.java", ] - jni_package = "base" } java_cpp_enum("ui_base_cursor_type_java_enums_srcjar") {
diff --git a/ui/base/DEPS b/ui/base/DEPS index 6a4ff03..4312bd3 100644 --- a/ui/base/DEPS +++ b/ui/base/DEPS
@@ -1,5 +1,5 @@ include_rules = [ - "+jni", + "+ui/base/ui_base_jni_headers", "+net", "+skia/ext", "+third_party/skia",
diff --git a/ui/base/clipboard/DEPS b/ui/base/clipboard/DEPS index 2d253fb..f2a2be9 100644 --- a/ui/base/clipboard/DEPS +++ b/ui/base/clipboard/DEPS
@@ -1,6 +1,6 @@ include_rules = [ "-ui/ozone/*", - "+jni", + "+ui/base/ui_base_jni_headers", "+third_party/mozilla", "+ui/ozone/public/ozone_platform.h", "+ui/ozone/public/platform_clipboard.h",
diff --git a/ui/base/clipboard/clipboard_android.cc b/ui/base/clipboard/clipboard_android.cc index 557cab5..f6addb85 100644 --- a/ui/base/clipboard/clipboard_android.cc +++ b/ui/base/clipboard/clipboard_android.cc
@@ -16,9 +16,9 @@ #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" #include "base/time/time.h" -#include "jni/Clipboard_jni.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/clipboard/clipboard_constants.h" +#include "ui/base/ui_base_jni_headers/Clipboard_jni.h" #include "ui/gfx/geometry/size.h" // TODO:(andrewhayden) Support additional formats in Android: Bitmap, URI, HTML,
diff --git a/ui/base/device_form_factor_android.cc b/ui/base/device_form_factor_android.cc index 0ac7221..82c4c9b3 100644 --- a/ui/base/device_form_factor_android.cc +++ b/ui/base/device_form_factor_android.cc
@@ -5,7 +5,7 @@ #include "ui/base/device_form_factor.h" #include "base/android/jni_android.h" -#include "jni/DeviceFormFactor_jni.h" +#include "ui/base/ui_base_jni_headers/DeviceFormFactor_jni.h" namespace ui {
diff --git a/ui/base/idle/DEPS b/ui/base/idle/DEPS index b145fbe..70c92dd 100644 --- a/ui/base/idle/DEPS +++ b/ui/base/idle/DEPS
@@ -1,5 +1,5 @@ include_rules = [ - "+jni", + "+ui/base/ui_base_jni_headers", "+chromeos/dbus/dbus_thread_manager.h", "+chromeos/dbus/session_manager", ]
diff --git a/ui/base/idle/idle_android.cc b/ui/base/idle/idle_android.cc index 40190e8..fd366ac4 100644 --- a/ui/base/idle/idle_android.cc +++ b/ui/base/idle/idle_android.cc
@@ -8,8 +8,8 @@ #include "base/android/scoped_java_ref.h" #include "base/logging.h" #include "base/memory/singleton.h" -#include "jni/IdleDetector_jni.h" #include "ui/base/idle/idle_internal.h" +#include "ui/base/ui_base_jni_headers/IdleDetector_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF8;
diff --git a/ui/base/l10n/DEPS b/ui/base/l10n/DEPS index c80012b5..b6c32ba 100644 --- a/ui/base/l10n/DEPS +++ b/ui/base/l10n/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+ui/base/ui_base_jni_headers", ]
diff --git a/ui/base/l10n/l10n_util_android.cc b/ui/base/l10n/l10n_util_android.cc index 9b43a7b2..6ef8c77 100644 --- a/ui/base/l10n/l10n_util_android.cc +++ b/ui/base/l10n/l10n_util_android.cc
@@ -13,9 +13,9 @@ #include "base/logging.h" #include "base/strings/string_util.h" #include "base/time/time.h" -#include "jni/LocalizationUtils_jni.h" #include "third_party/icu/source/common/unicode/uloc.h" #include "ui/base/l10n/time_format.h" +#include "ui/base/ui_base_jni_headers/LocalizationUtils_jni.h" using base::android::JavaParamRef; using base::android::ScopedJavaLocalRef;
diff --git a/ui/base/pointer/pointer_device_android.cc b/ui/base/pointer/pointer_device_android.cc index b2b55bf..2113c9ae 100644 --- a/ui/base/pointer/pointer_device_android.cc +++ b/ui/base/pointer/pointer_device_android.cc
@@ -6,7 +6,7 @@ #include "base/android/jni_array.h" #include "base/logging.h" -#include "jni/TouchDevice_jni.h" +#include "ui/base/ui_base_jni_headers/TouchDevice_jni.h" using base::android::AttachCurrentThread;
diff --git a/ui/base/resource/resource_bundle_android.cc b/ui/base/resource/resource_bundle_android.cc index 6686f17a..c7fb228 100644 --- a/ui/base/resource/resource_bundle_android.cc +++ b/ui/base/resource/resource_bundle_android.cc
@@ -9,10 +9,10 @@ #include "base/android/jni_string.h" #include "base/logging.h" #include "base/path_service.h" -#include "jni/ResourceBundle_jni.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/data_pack.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_jni_headers/ResourceBundle_jni.h" #include "ui/base/ui_base_paths.h" namespace ui {
diff --git a/ui/events/BUILD.gn b/ui/events/BUILD.gn index cebbd52..919cded 100644 --- a/ui/events/BUILD.gn +++ b/ui/events/BUILD.gn
@@ -652,12 +652,10 @@ if (is_android) { generate_jar_jni("motionevent_jni_headers") { - jni_package = "ui" classes = [ "android/view/MotionEvent.class" ] } generate_jar_jni("keyevent_jni_headers") { - jni_package = "ui" classes = [ "android/view/KeyEvent.class" ] } }
diff --git a/ui/events/android/DEPS b/ui/events/android/DEPS index c80012b5..eaf343a6 100644 --- a/ui/events/android/DEPS +++ b/ui/events/android/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+ui/events/motionevent_jni_headers", ]
diff --git a/ui/events/android/key_event_utils.cc b/ui/events/android/key_event_utils.cc index c4419b2..f7660dc9b 100644 --- a/ui/events/android/key_event_utils.cc +++ b/ui/events/android/key_event_utils.cc
@@ -4,7 +4,7 @@ #include "ui/events/android/key_event_utils.h" -#include "jni/KeyEvent_jni.h" +#include "ui/events/keyevent_jni_headers/KeyEvent_jni.h" namespace ui { namespace events {
diff --git a/ui/events/android/motion_event_android.cc b/ui/events/android/motion_event_android.cc index bcc6e62a..c5c13c7 100644 --- a/ui/events/android/motion_event_android.cc +++ b/ui/events/android/motion_event_android.cc
@@ -9,10 +9,10 @@ #include <cmath> #include "base/android/jni_android.h" -#include "jni/MotionEvent_jni.h" #include "ui/events/base_event_utils.h" #include "ui/events/event_constants.h" #include "ui/events/event_utils.h" +#include "ui/events/motionevent_jni_headers/MotionEvent_jni.h" using base::android::AttachCurrentThread; using base::android::ScopedJavaLocalRef;
diff --git a/ui/events/blink/fling_booster.cc b/ui/events/blink/fling_booster.cc index 39ab3ba7..edcc4df 100644 --- a/ui/events/blink/fling_booster.cc +++ b/ui/events/blink/fling_booster.cc
@@ -4,6 +4,8 @@ #include "ui/events/blink/fling_booster.h" +#include "base/trace_event/trace_event.h" + using blink::WebGestureEvent; using blink::WebInputEvent; @@ -31,21 +33,29 @@ DCHECK_EQ(blink::WebInputEvent::kGestureFlingStart, fling_start.GetType()); gfx::Vector2dF velocity(fling_start.data.fling_start.velocity_x, fling_start.data.fling_start.velocity_y); + TRACE_EVENT2("input", "FlingBooster::GetVelocityForFlingStart", "vx", + velocity.x(), "vy", velocity.y()); - if (ShouldBoostFling(fling_start)) - velocity += current_fling_velocity_; + if (ShouldBoostFling(fling_start)) { + velocity += previous_fling_starting_velocity_; + TRACE_EVENT_INSTANT2("input", "Boosted", TRACE_EVENT_SCOPE_THREAD, "vx", + velocity.x(), "vy", velocity.y()); + } Reset(); + previous_fling_starting_velocity_ = velocity; current_fling_velocity_ = velocity; source_device_ = fling_start.SourceDevice(); modifiers_ = fling_start.GetModifiers(); - return current_fling_velocity_; + return previous_fling_starting_velocity_; } void FlingBooster::ObserveGestureEvent(const WebGestureEvent& gesture_event) { - if (current_fling_velocity_.IsZero()) + TRACE_EVENT1("input", "FlingBooster::ObserveGestureEvent", "type", + WebInputEvent::GetName(gesture_event.GetType())); + if (previous_fling_starting_velocity_.IsZero()) return; // Gestures from a different source should prevent boosting. @@ -68,6 +78,7 @@ return; if (gesture_event.TimeStamp() > cutoff_time_for_boost_) { + TRACE_EVENT_INSTANT0("input", "Timeout", TRACE_EVENT_SCOPE_THREAD); Reset(); return; } @@ -76,7 +87,8 @@ // boost. gfx::Vector2dF delta(gesture_event.data.scroll_update.delta_x, gesture_event.data.scroll_update.delta_y); - if (gfx::DotProduct(current_fling_velocity_, delta) <= 0) { + if (gfx::DotProduct(previous_fling_starting_velocity_, delta) <= 0) { + TRACE_EVENT_INSTANT0("input", "Direction", TRACE_EVENT_SCOPE_THREAD); Reset(); return; } @@ -94,6 +106,7 @@ gfx::ScaleVector2d(delta, 1. / time_since_last_boost_event); if (scroll_velocity.LengthSquared() < kMinBoostTouchScrollSpeedSquare) { + TRACE_EVENT_INSTANT0("input", "Velocity", TRACE_EVENT_SCOPE_THREAD); Reset(); return; } @@ -111,6 +124,8 @@ } case WebInputEvent::kGestureFlingCancel: { if (gesture_event.data.fling_cancel.prevent_boosting) { + TRACE_EVENT_INSTANT0("input", "GFC PreventBoosting", + TRACE_EVENT_SCOPE_THREAD); Reset(); return; } @@ -125,36 +140,66 @@ } } +void FlingBooster::ObserveProgressFling( + const gfx::Vector2dF& current_velocity) { + TRACE_EVENT2("input", "FlingBooster::ObserveProgressFling", "vx", + current_velocity.x(), "vy", current_velocity.y()); + DCHECK(!previous_fling_starting_velocity_.IsZero()); + current_fling_velocity_ = current_velocity; +} + bool FlingBooster::ShouldBoostFling(const WebGestureEvent& fling_start_event) { DCHECK_EQ(WebInputEvent::kGestureFlingStart, fling_start_event.GetType()); - if (current_fling_velocity_.IsZero()) + if (previous_fling_starting_velocity_.IsZero()) { + TRACE_EVENT_INSTANT0("input", "No Boost - NoActiveFling", + TRACE_EVENT_SCOPE_THREAD); return false; + } - if (source_device_ != fling_start_event.SourceDevice()) + if (source_device_ != fling_start_event.SourceDevice()) { + TRACE_EVENT_INSTANT0("input", "No Boost - SourceDevice", + TRACE_EVENT_SCOPE_THREAD); return false; + } - if (modifiers_ != fling_start_event.GetModifiers()) + if (modifiers_ != fling_start_event.GetModifiers()) { + TRACE_EVENT_INSTANT0("input", "No Boost - Modifiers", + TRACE_EVENT_SCOPE_THREAD); return false; + } - if (cutoff_time_for_boost_.is_null()) + if (cutoff_time_for_boost_.is_null()) { + TRACE_EVENT_INSTANT0("input", "No Boost - CutoffTimeUnset", + TRACE_EVENT_SCOPE_THREAD); return false; + } - if (fling_start_event.TimeStamp() > cutoff_time_for_boost_) + if (fling_start_event.TimeStamp() > cutoff_time_for_boost_) { + TRACE_EVENT_INSTANT0("input", "No Boost - Timeout", + TRACE_EVENT_SCOPE_THREAD); return false; + } gfx::Vector2dF new_fling_velocity( fling_start_event.data.fling_start.velocity_x, fling_start_event.data.fling_start.velocity_y); - if (gfx::DotProduct(current_fling_velocity_, new_fling_velocity) <= 0) { + if (gfx::DotProduct(previous_fling_starting_velocity_, new_fling_velocity) <= + 0) { + TRACE_EVENT_INSTANT0("input", "No Boost - Direction", + TRACE_EVENT_SCOPE_THREAD); return false; } if (current_fling_velocity_.LengthSquared() < kMinBoostFlingSpeedSquare) { + TRACE_EVENT_INSTANT0("input", "No Boost - CurrentVelocity", + TRACE_EVENT_SCOPE_THREAD); return false; } if (new_fling_velocity.LengthSquared() < kMinBoostFlingSpeedSquare) { + TRACE_EVENT_INSTANT0("input", "No Boost - NewVelocity", + TRACE_EVENT_SCOPE_THREAD); return false; } @@ -162,7 +207,9 @@ } void FlingBooster::Reset() { + TRACE_EVENT0("input", "FlingBooster::Reset"); cutoff_time_for_boost_ = base::TimeTicks(); + previous_fling_starting_velocity_ = gfx::Vector2dF(); current_fling_velocity_ = gfx::Vector2dF(); source_device_ = blink::WebGestureDevice::kUninitialized; modifiers_ = 0;
diff --git a/ui/events/blink/fling_booster.h b/ui/events/blink/fling_booster.h index 112bd0a7..10f1e9c 100644 --- a/ui/events/blink/fling_booster.h +++ b/ui/events/blink/fling_booster.h
@@ -23,6 +23,7 @@ gfx::Vector2dF GetVelocityForFlingStart( const blink::WebGestureEvent& gesture_start); void ObserveGestureEvent(const blink::WebGestureEvent& gesture_event); + void ObserveProgressFling(const gfx::Vector2dF& current_velocity); private: bool ShouldBoostFling(const blink::WebGestureEvent& fling_start_event); @@ -34,8 +35,13 @@ // Note, however, that we'll extend this time as we see scroll updates. base::TimeTicks cutoff_time_for_boost_; - // Tracks velocity at fling start of the currently ongoing fling. When a new - // fling is started and we decide to boost, we'll add this velocity to it. + // Tracks the (possibly boosted) velocity used at the previous FlingStart. + // When a new fling is started and we decide to boost, we'll add this + // velocity to it. + gfx::Vector2dF previous_fling_starting_velocity_; + + // Tracks the current fling's velocity as it decays. We'll prevent boosting + // if this crosses the kMinBoostFlingSpeedSquare threshold. gfx::Vector2dF current_fling_velocity_; // These store the current active fling source device and modifier keys (e.g. @@ -46,7 +52,7 @@ int modifiers_ = 0; // Track the last timestamp we've seen a scroll update that we're evaluating - // as a boost. This is used to calculate the velocity; if it's to slow we'll + // as a boost. This is used to calculate the velocity; if it's too slow we'll // avoid boosting. base::TimeTicks previous_boosting_scroll_timestamp_;
diff --git a/ui/events/blink/fling_booster_unittest.cc b/ui/events/blink/fling_booster_unittest.cc index fce6110..8245579 100644 --- a/ui/events/blink/fling_booster_unittest.cc +++ b/ui/events/blink/fling_booster_unittest.cc
@@ -74,6 +74,12 @@ return scroll_update; } + WebGestureEvent CreateScrollEnd( + WebGestureDevice source_device = WebGestureDevice::kTouchscreen) { + return WebGestureEvent(WebInputEvent::kGestureScrollEnd, 0, event_time_, + source_device); + } + Vector2dF DeltaFromVelocity(Vector2dF velocity, TimeDelta delta) { float delta_seconds = static_cast<float>(delta.InSecondsF()); Vector2dF out = velocity; @@ -95,6 +101,7 @@ void SimulateBoostingScroll() { event_time_ += kEventDelta; fling_booster_.ObserveGestureEvent(CreateFlingCancel()); + fling_booster_.ObserveGestureEvent(CreateScrollEnd()); fling_booster_.ObserveGestureEvent(CreateScrollBegin(Vector2dF(0, 1))); // GestureScrollUpdates in the same direction and at sufficient speed should @@ -107,6 +114,12 @@ DeltaFromVelocity(Vector2dF(0, kMinBoostScrollSpeed), kEventDelta))); } + void ProgressFling(const Vector2dF& current_velocity, + const Vector2dF& delta) { + fling_booster_.ObserveGestureEvent(CreateScrollUpdate(delta)); + fling_booster_.ObserveProgressFling(current_velocity); + } + protected: base::TimeTicks event_time_ = base::TimeTicks() + TimeDelta::FromSeconds(100000); @@ -127,6 +140,21 @@ << "FlingStart with ongoing fling should be boosted"; } +TEST_F(FlingBoosterTest, FlingBoostProgressedFling) { + Vector2dF fling_velocity; + + fling_velocity = SendFlingStart(CreateFlingStart(Vector2dF(0, 1000))); + + event_time_ += kEventDelta; + ProgressFling(Vector2dF(0, kMinBoostFlingSpeed), Vector2dF(0, 20)); + + SimulateBoostingScroll(); + + fling_velocity = SendFlingStart(CreateFlingStart(Vector2dF(0, 1100))); + + EXPECT_EQ(Vector2dF(0, 2100), fling_velocity) << "Fling should be boosted"; +} + TEST_F(FlingBoosterTest, NoFlingBoostIfScrollDelayed) { Vector2dF fling_velocity; @@ -155,7 +183,7 @@ << "Boosting FlingStart too slow; fling shouldn't be boosted."; } -TEST_F(FlingBoosterTest, NoFlingBoostIfCurrentVelocityTooSlow) { +TEST_F(FlingBoosterTest, NoFlingBoostIfPreviousStartVelocityTooSlow) { Vector2dF fling_velocity; fling_velocity = @@ -164,6 +192,20 @@ SimulateBoostingScroll(); fling_velocity = SendFlingStart(CreateFlingStart(Vector2dF(0, 2000))); EXPECT_EQ(Vector2dF(0, 2000), fling_velocity) + << "Previous fling too slow and shouldn't be boosted."; +} + +TEST_F(FlingBoosterTest, NoFlingBoostIfCurrentVelocityTooSlow) { + Vector2dF fling_velocity; + + fling_velocity = SendFlingStart(CreateFlingStart(Vector2dF(0, 1000))); + + event_time_ += kEventDelta; + ProgressFling(Vector2dF(0, kMinBoostFlingSpeed - 1), Vector2dF(0, 20)); + + fling_velocity = SendFlingStart(CreateFlingStart(Vector2dF(0, 1100))); + + EXPECT_EQ(Vector2dF(0, 1100), fling_velocity) << "Existing fling too slow and shouldn't be boosted."; }
diff --git a/ui/events/devices/BUILD.gn b/ui/events/devices/BUILD.gn index 3c8bbd4..ec58431 100644 --- a/ui/events/devices/BUILD.gn +++ b/ui/events/devices/BUILD.gn
@@ -59,7 +59,6 @@ sources = [ "../../android/java/src/org/chromium/ui/events/devices/InputDeviceObserver.java", ] - jni_package = "events/devices" } }
diff --git a/ui/events/devices/DEPS b/ui/events/devices/DEPS index 1d2c11b..cd47b53a 100644 --- a/ui/events/devices/DEPS +++ b/ui/events/devices/DEPS
@@ -1,5 +1,5 @@ specific_include_rules = { "input_device_observer_android.cc": [ - "+jni", + "+ui/events/devices/ui_events_devices_jni_headers", ], }
diff --git a/ui/events/devices/input_device_observer_android.cc b/ui/events/devices/input_device_observer_android.cc index fe057e3..b33746b 100644 --- a/ui/events/devices/input_device_observer_android.cc +++ b/ui/events/devices/input_device_observer_android.cc
@@ -5,7 +5,7 @@ #include "ui/events/devices/input_device_observer_android.h" #include "base/memory/singleton.h" -#include "jni/InputDeviceObserver_jni.h" +#include "ui/events/devices/ui_events_devices_jni_headers/InputDeviceObserver_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index bf0e7c0..c75f747 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn
@@ -855,7 +855,6 @@ "../android/java/src/org/chromium/ui/gfx/BitmapHelper.java", "../android/java/src/org/chromium/ui/gfx/ViewConfigurationHelper.java", ] - jni_package = "gfx" } }
diff --git a/ui/gfx/android/DEPS b/ui/gfx/android/DEPS index c80012b5..841ceffd 100644 --- a/ui/gfx/android/DEPS +++ b/ui/gfx/android/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+ui/gfx/gfx_jni_headers", ]
diff --git a/ui/gfx/android/java_bitmap.cc b/ui/gfx/android/java_bitmap.cc index 96bcdb5..4ba2a556 100644 --- a/ui/gfx/android/java_bitmap.cc +++ b/ui/gfx/android/java_bitmap.cc
@@ -8,8 +8,8 @@ #include "base/android/jni_string.h" #include "base/logging.h" -#include "jni/BitmapHelper_jni.h" #include "ui/gfx/geometry/size.h" +#include "ui/gfx/gfx_jni_headers/BitmapHelper_jni.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF8ToJavaString;
diff --git a/ui/gfx/android/view_configuration.cc b/ui/gfx/android/view_configuration.cc index cc7b7690..49da336 100644 --- a/ui/gfx/android/view_configuration.cc +++ b/ui/gfx/android/view_configuration.cc
@@ -8,7 +8,7 @@ #include "base/lazy_instance.h" #include "base/macros.h" #include "base/synchronization/lock.h" -#include "jni/ViewConfigurationHelper_jni.h" +#include "ui/gfx/gfx_jni_headers/ViewConfigurationHelper_jni.h" using base::android::AttachCurrentThread; using base::android::JavaParamRef;
diff --git a/ui/gfx/animation/DEPS b/ui/gfx/animation/DEPS index c80012b5..841ceffd 100644 --- a/ui/gfx/animation/DEPS +++ b/ui/gfx/animation/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+ui/gfx/gfx_jni_headers", ]
diff --git a/ui/gfx/animation/animation_android.cc b/ui/gfx/animation/animation_android.cc index afa37e4..1637e2d 100644 --- a/ui/gfx/animation/animation_android.cc +++ b/ui/gfx/animation/animation_android.cc
@@ -5,7 +5,7 @@ #include "ui/gfx/animation/animation.h" #include "base/android/jni_android.h" -#include "jni/Animation_jni.h" +#include "ui/gfx/gfx_jni_headers/Animation_jni.h" using base::android::AttachCurrentThread;
diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn index 4a2cf135..78cdbc9 100644 --- a/ui/gl/BUILD.gn +++ b/ui/gl/BUILD.gn
@@ -590,7 +590,6 @@ if (is_android) { generate_jar_jni("surface_jni_headers") { - jni_package = "ui/gl" classes = [ "android/view/Surface.class" ] always_mangle = true } @@ -603,6 +602,5 @@ public_deps = [ ":surface_jni_headers", ] - jni_package = "ui/gl" } }
diff --git a/ui/gl/android/DEPS b/ui/gl/android/DEPS index c80012b5..10e66376 100644 --- a/ui/gl/android/DEPS +++ b/ui/gl/android/DEPS
@@ -1,3 +1,3 @@ include_rules = [ - "+jni", + "+ui/gl/gl_jni_headers", ]
diff --git a/ui/gl/android/scoped_java_surface.cc b/ui/gl/android/scoped_java_surface.cc index b88669c2..67df19a6 100644 --- a/ui/gl/android/scoped_java_surface.cc +++ b/ui/gl/android/scoped_java_surface.cc
@@ -5,8 +5,8 @@ #include "ui/gl/android/scoped_java_surface.h" #include "base/logging.h" -#include "jni/Surface_jni.h" #include "ui/gl/android/surface_texture.h" +#include "ui/gl/surface_jni_headers/Surface_jni.h" using base::android::ScopedJavaLocalRef;
diff --git a/ui/gl/android/surface_texture.cc b/ui/gl/android/surface_texture.cc index 6420765..eac4260 100644 --- a/ui/gl/android/surface_texture.cc +++ b/ui/gl/android/surface_texture.cc
@@ -10,10 +10,10 @@ #include "base/android/jni_android.h" #include "base/debug/crash_logging.h" #include "base/logging.h" -#include "jni/SurfaceTexturePlatformWrapper_jni.h" #include "ui/gl/android/scoped_java_surface.h" #include "ui/gl/android/surface_texture_listener.h" #include "ui/gl/gl_bindings.h" +#include "ui/gl/gl_jni_headers/SurfaceTexturePlatformWrapper_jni.h" namespace gl {
diff --git a/ui/gl/android/surface_texture_listener.cc b/ui/gl/android/surface_texture_listener.cc index 74be484..960713b 100644 --- a/ui/gl/android/surface_texture_listener.cc +++ b/ui/gl/android/surface_texture_listener.cc
@@ -9,7 +9,7 @@ #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" -#include "jni/SurfaceTextureListener_jni.h" +#include "ui/gl/gl_jni_headers/SurfaceTextureListener_jni.h" using base::android::JavaParamRef;
diff --git a/ui/gl/gl_image_dxgi_swap_chain.cc b/ui/gl/gl_image_dxgi_swap_chain.cc index 0ace826..08b1cc7 100644 --- a/ui/gl/gl_image_dxgi_swap_chain.cc +++ b/ui/gl/gl_image_dxgi_swap_chain.cc
@@ -7,15 +7,28 @@ #include "ui/gl/egl_util.h" #include "ui/gl/gl_bindings.h" -#ifndef EGL_ANGLE_image_d3d11_texture -#define EGL_D3D11_TEXTURE_ANGLE 0x3484 -#endif /* EGL_ANGLE_image_d3d11_texture */ +#ifndef EGL_ANGLE_d3d_texture_client_buffer +#define EGL_ANGLE_d3d_texture_client_buffer 1 +#define EGL_D3D_TEXTURE_ANGLE 0x33A3 +#endif /* EGL_ANGLE_d3d_texture_client_buffer */ namespace gl { namespace { +bool SwapChainSupportedBindFormat(gfx::BufferFormat format) { + switch (format) { + case gfx::BufferFormat::RGBA_8888: + case gfx::BufferFormat::RGBX_8888: + case gfx::BufferFormat::RGBA_F16: + return true; + default: + return false; + }; +} + bool SwapChainHasAlpha(gfx::BufferFormat format) { + DCHECK(SwapChainSupportedBindFormat(format)); switch (format) { case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_F16: @@ -28,6 +41,94 @@ }; } +EGLConfig ChooseCompatibleConfig(gfx::BufferFormat format, EGLDisplay display) { + DCHECK(SwapChainSupportedBindFormat(format)); + + const EGLint color_bits = format == gfx::BufferFormat::RGBA_F16 ? 16 : 8; + const EGLint buffer_bind_to_texture = SwapChainHasAlpha(format) + ? EGL_BIND_TO_TEXTURE_RGBA + : EGL_BIND_TO_TEXTURE_RGB; + const EGLint buffer_size = + color_bits * 3 + (SwapChainHasAlpha(format) ? color_bits : 0); + + std::vector<EGLint> attrib_list = { + EGL_RED_SIZE, color_bits, EGL_GREEN_SIZE, color_bits, + EGL_BLUE_SIZE, color_bits, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + buffer_bind_to_texture, EGL_TRUE, EGL_BUFFER_SIZE, buffer_size}; + // It is assumed that EGL_EXT_pixel_format_float extension is supported by + // ANGLE. + if (format == gfx::BufferFormat::RGBA_F16) { + attrib_list.push_back(EGL_COLOR_COMPONENT_TYPE_EXT); + attrib_list.push_back(EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT); + } + attrib_list.push_back(EGL_NONE); + + EGLint num_config = 0; + EGLBoolean result = + eglChooseConfig(display, attrib_list.data(), nullptr, 0, &num_config); + if (result != EGL_TRUE) + return nullptr; + std::vector<EGLConfig> all_configs(num_config); + result = eglChooseConfig(display, attrib_list.data(), all_configs.data(), + num_config, &num_config); + if (result != EGL_TRUE) + return nullptr; + for (EGLConfig config : all_configs) { + EGLint bits = 0; + // Ensures that the config chosen has requested number of bits. + if (!eglGetConfigAttrib(display, config, EGL_RED_SIZE, &bits) || + bits != color_bits) { + continue; + } + + if (!eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &bits) || + bits != color_bits) { + continue; + } + + if (!eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &bits) || + bits != color_bits) { + continue; + } + + if (SwapChainHasAlpha(format) && + (!eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &bits) || + bits != color_bits)) { + continue; + } + + return config; + } + return nullptr; +} + +EGLSurface CreatePbuffer(const Microsoft::WRL::ComPtr<ID3D11Texture2D>& texture, + gfx::BufferFormat format, + EGLConfig config, + EGLDisplay display, + unsigned target) { + DCHECK(SwapChainSupportedBindFormat(format)); + + D3D11_TEXTURE2D_DESC desc; + texture->GetDesc(&desc); + EGLint width = desc.Width; + EGLint height = desc.Height; + + EGLint pBufferAttributes[] = { + EGL_WIDTH, + width, + EGL_HEIGHT, + height, + EGL_TEXTURE_TARGET, + EGL_TEXTURE_2D, + EGL_TEXTURE_FORMAT, + SwapChainHasAlpha(format) ? EGL_TEXTURE_RGBA : EGL_TEXTURE_RGB, + EGL_NONE}; + + return eglCreatePbufferFromClientBuffer( + display, EGL_D3D_TEXTURE_ANGLE, texture.Get(), config, pBufferAttributes); +} + } // anonymous namespace GLImageDXGISwapChain::GLImageDXGISwapChain( @@ -35,29 +136,38 @@ gfx::BufferFormat buffer_format, Microsoft::WRL::ComPtr<ID3D11Texture2D> texture, Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain) - : GLImageEGL(size), + : size_(size), buffer_format_(buffer_format), texture_(texture), - swap_chain_(swap_chain) { + swap_chain_(swap_chain), + display_(eglGetCurrentDisplay()), + config_(ChooseCompatibleConfig(buffer_format, display_)) { DCHECK(texture_); DCHECK(swap_chain_); + DCHECK(config_); } -// static -GLImageDXGISwapChain* GLImageDXGISwapChain::FromGLImage(GLImage* image) { - if (!image || image->GetType() != Type::DXGI_SWAP_CHAIN) - return nullptr; - return static_cast<GLImageDXGISwapChain*>(image); +GLImage::BindOrCopy GLImageDXGISwapChain::ShouldBindOrCopy() { + return BIND; } -bool GLImageDXGISwapChain::Initialize() { +bool GLImageDXGISwapChain::BindTexImage(unsigned target) { + DestroySurface(); DCHECK(texture_); - const EGLint attribs[] = {EGL_NONE}; - return GLImageEGL::Initialize(EGL_NO_CONTEXT, EGL_D3D11_TEXTURE_ANGLE, - static_cast<EGLClientBuffer>(texture_.Get()), - attribs); + DCHECK_EQ(surface_, EGL_NO_SURFACE); + DCHECK(config_); + surface_ = CreatePbuffer(texture_, buffer_format_, config_, display_, target); + if (surface_ == EGL_NO_SURFACE) { + DLOG(ERROR) << "eglCreatePbufferSurface failed with error " + << ui::GetLastEGLErrorString(); + return false; + } + + return eglBindTexImage(display_, surface_, EGL_BACK_BUFFER) == EGL_TRUE; } +void GLImageDXGISwapChain::ReleaseTexImage(unsigned target) {} + bool GLImageDXGISwapChain::CopyTexImage(unsigned target) { return false; } @@ -74,6 +184,10 @@ return SwapChainHasAlpha(buffer_format_) ? GL_RGBA : GL_RGB; } +gfx::Size GLImageDXGISwapChain::GetSize() { + return size_; +} + void GLImageDXGISwapChain::OnMemoryDump( base::trace_event::ProcessMemoryDump* pmd, uint64_t process_tracing_id, @@ -95,6 +209,18 @@ return false; } -GLImageDXGISwapChain::~GLImageDXGISwapChain() {} +void GLImageDXGISwapChain::DestroySurface() { + if (surface_ != EGL_NO_SURFACE) { + if (!eglDestroySurface(display_, surface_)) { + DLOG(ERROR) << "eglDestroySurface failed with error " + << ui::GetLastEGLErrorString(); + } + surface_ = EGL_NO_SURFACE; + } +} + +GLImageDXGISwapChain::~GLImageDXGISwapChain() { + DestroySurface(); +} } // namespace gl
diff --git a/ui/gl/gl_image_dxgi_swap_chain.h b/ui/gl/gl_image_dxgi_swap_chain.h index 4a2f67f3..af9c93f 100644 --- a/ui/gl/gl_image_dxgi_swap_chain.h +++ b/ui/gl/gl_image_dxgi_swap_chain.h
@@ -11,30 +11,31 @@ #include <wrl/client.h> #include "ui/gfx/buffer_types.h" +#include "ui/gl/gl_bindings.h" #include "ui/gl/gl_export.h" -#include "ui/gl/gl_image_egl.h" +#include "ui/gl/gl_image.h" namespace gl { -class GL_EXPORT GLImageDXGISwapChain : public gl::GLImageEGL { +class GL_EXPORT GLImageDXGISwapChain : public gl::GLImage { public: GLImageDXGISwapChain(const gfx::Size& size, gfx::BufferFormat buffer_format, Microsoft::WRL::ComPtr<ID3D11Texture2D> texture, Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain); - // Safe downcast. Returns nullptr on failure. - static GLImageDXGISwapChain* FromGLImage(GLImage* image); - - bool Initialize(); - // GLImage implementation + BindOrCopy ShouldBindOrCopy() override; + // Destroys surface(if present), and binds image to new pixel buffer surface. + bool BindTexImage(unsigned target) override; + void ReleaseTexImage(unsigned target) override; bool CopyTexImage(unsigned target) override; bool CopyTexSubImage(unsigned target, const gfx::Point& offset, const gfx::Rect& rect) override; void Flush() override; unsigned GetInternalFormat() override; + gfx::Size GetSize() override; Type GetType() const override; void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, uint64_t process_tracing_id, @@ -47,19 +48,22 @@ bool enable_blend, std::unique_ptr<gfx::GpuFence> gpu_fence) override; - const Microsoft::WRL::ComPtr<ID3D11Texture2D>& texture() { return texture_; } - const Microsoft::WRL::ComPtr<IDXGISwapChain1>& swap_chain() { - return swap_chain_; - } + Microsoft::WRL::ComPtr<ID3D11Texture2D> texture() { return texture_; } protected: ~GLImageDXGISwapChain() override; private: + void DestroySurface(); + + const gfx::Size size_; const gfx::BufferFormat buffer_format_; + EGLSurface surface_ = nullptr; Microsoft::WRL::ComPtr<ID3D11Texture2D> texture_; // Required by Direct composition surface to pass swap chain handle to OS. Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_; + const EGLDisplay display_; + const EGLConfig config_; DISALLOW_COPY_AND_ASSIGN(GLImageDXGISwapChain); };
diff --git a/ui/shell_dialogs/DEPS b/ui/shell_dialogs/DEPS index 11d09a31a..8a94af5 100644 --- a/ui/shell_dialogs/DEPS +++ b/ui/shell_dialogs/DEPS
@@ -1,5 +1,5 @@ include_rules = [ - "+jni", + "+ui/base/ui_base_jni_headers", "+components/remote_cocoa", "+mojo/core/embedder", "+mojo/public/cpp/bindings",
diff --git a/ui/shell_dialogs/select_file_dialog_android.cc b/ui/shell_dialogs/select_file_dialog_android.cc index 9b4346c..9dbd5f0 100644 --- a/ui/shell_dialogs/select_file_dialog_android.cc +++ b/ui/shell_dialogs/select_file_dialog_android.cc
@@ -12,8 +12,8 @@ #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "jni/SelectFileDialog_jni.h" #include "ui/android/window_android.h" +#include "ui/base/ui_base_jni_headers/SelectFileDialog_jni.h" #include "ui/shell_dialogs/select_file_policy.h" #include "ui/shell_dialogs/selected_file_info.h"