diff --git a/DEPS b/DEPS index ccab5178..2c4d01f 100644 --- a/DEPS +++ b/DEPS
@@ -100,7 +100,7 @@ # 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': 'e5033ec9d57ace1014487b96e8439ff86831c4d4', + 'v8_revision': '2cf653be06593ee542932a6fde0f715d7dcf8bbe', # 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. @@ -120,7 +120,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': '0789714191b4b3109f7d5c415663090018e27577', + 'pdfium_revision': 'a7b65b85bba95fb8757cbd407fd38d71304128ab', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling openmax_dl # and whatever else without interference from each other. @@ -148,7 +148,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling freetype # and whatever else without interference from each other. - 'freetype_revision': '9e345c911714ed62250be13d03d72e25d91fbc77', + 'freetype_revision': 'd45d4b97e6a03cfe21a2952138cf6e970fc358e5', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling HarfBuzz # and whatever else without interference from each other. @@ -513,7 +513,7 @@ # For Linux and Chromium OS. 'src/third_party/cros_system_api': { - 'url': Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + '55139d2ab617e9eaf1521f21da4ad58397d0e202', + 'url': Var('chromium_git') + '/chromiumos/platform/system_api.git' + '@' + 'a9ac639b38af7ad3d745975ad850cbde73fbb7ee', 'condition': 'checkout_linux', },
diff --git a/android_webview/BUILD.gn b/android_webview/BUILD.gn index b18e6047..f07bc7f 100644 --- a/android_webview/BUILD.gn +++ b/android_webview/BUILD.gn
@@ -386,7 +386,6 @@ shared_library("libwebviewchromium") { deps = [ ":webview_entry_point", - "//build/config:exe_and_shlib_deps", ] configs -= [ "//build/config/android:hide_all_but_jni_onload" ] configs += [ "//build/config/android:hide_all_but_jni" ] @@ -419,7 +418,6 @@ shared_library("monochrome") { deps = [ ":webview_entry_point", - "//build/config:exe_and_shlib_deps", ] configs -= [ "//build/config/android:hide_all_but_jni_onload" ] configs += [ "//build/config/android:hide_all_but_jni" ]
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java index f4fe8d6..d7b0166 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java
@@ -630,7 +630,7 @@ /* reporting */ true)); } } finally { - TraceEvent.end("WebViewContentsClientAdapter.onRenderProcessGone"); + TraceEvent.end("WebViewContentsClientAdapter.onSafeBrowsingHit"); } }
diff --git a/android_webview/java/DEPS b/android_webview/java/DEPS index 4c9b336..b3dc856 100644 --- a/android_webview/java/DEPS +++ b/android_webview/java/DEPS
@@ -12,7 +12,6 @@ "+content/public/android/java/src/org/chromium/content_public", "!content/public/android/java/src/org/chromium/content/browser/ChildProcessCreationParams.java", "!content/public/android/java/src/org/chromium/content/browser/ChildProcessLauncherHelper.java", - "!content/public/android/java/src/org/chromium/content/browser/selection/HandleViewResources.java", "+device/gamepad/android/java", "+media/base/android/java",
diff --git a/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java b/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java index 12f998d..a8a2efcb 100644 --- a/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java +++ b/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java
@@ -23,12 +23,12 @@ import org.chromium.base.ObserverList; import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.JNINamespace; -import org.chromium.content.browser.selection.HandleViewResources; import org.chromium.content_public.browser.GestureListenerManager; import org.chromium.content_public.browser.GestureStateListener; import org.chromium.content_public.browser.WebContents; import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.display.DisplayAndroid.DisplayAndroidObserver; +import org.chromium.ui.resources.HandleViewResources; import org.chromium.ui.touch_selection.TouchHandleOrientation; import java.lang.reflect.InvocationTargetException;
diff --git a/android_webview/lib/aw_main_delegate.cc b/android_webview/lib/aw_main_delegate.cc index 6c1e400..37a62633 100644 --- a/android_webview/lib/aw_main_delegate.cc +++ b/android_webview/lib/aw_main_delegate.cc
@@ -35,6 +35,7 @@ #include "components/crash/content/app/breakpad_linux.h" #include "components/crash/core/common/crash_key.h" #include "components/safe_browsing/android/safe_browsing_api_handler_bridge.h" +#include "components/services/heap_profiling/public/cpp/allocator_shim.h" #include "components/spellcheck/spellcheck_buildflags.h" #include "content/public/browser/android/browser_media_player_manager_register.h" #include "content/public/browser/browser_main_runner.h" @@ -188,6 +189,14 @@ base::trace_event::TraceLog::GetInstance()->SetArgumentFilterPredicate( base::BindRepeating(&IsTraceEventArgsWhitelisted)); + // The TLS slot used by the memlog allocator shim needs to be initialized + // early to ensure that it gets assigned a low slot number. If it gets + // initialized too late, the glibc TLS system will require a malloc call in + // order to allocate storage for a higher slot number. Since malloc is hooked, + // this causes re-entrancy into the allocator shim, while the TLS object is + // partially-initialized, which the TLS object is supposed to protect again. + heap_profiling::InitTLSSlot(); + return false; }
diff --git a/android_webview/test/BUILD.gn b/android_webview/test/BUILD.gn index 7936993..2c7b117 100644 --- a/android_webview/test/BUILD.gn +++ b/android_webview/test/BUILD.gn
@@ -112,7 +112,6 @@ ldflags = [ "-Wl,-shared,-Bsymbolic" ] deps = [ "//android_webview:common", - "//build/config:exe_and_shlib_deps", "//components/heap_profiling:test_support", ] configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 106f34fe..15a2bfd 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -2033,7 +2033,6 @@ deps = [ ":ash_shell_lib_with_content", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//components/user_manager", "//content",
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index cc4a21b2..8223bce 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -1367,6 +1367,9 @@ <message name="IDS_ASH_POWER_BUTTON_MENU_LOCK_SCREEN_BUTTON" desc="Text shown on lock screen button in power button menu."> Lock screen </message> + <message name="IDS_ASH_POWER_BUTTON_MENU_FEEDBACK_BUTTON" desc="Text shown on feedback button in power button menu."> + Feedback + </message> <message name ="IDS_ASH_POWER_BUTTON_MENU_ACCESSIBLE" desc="The accessible name of the power button menu, may be spoken out loud."> Power </message>
diff --git a/ash/components/shortcut_viewer_strings.grdp b/ash/components/shortcut_viewer_strings.grdp index 1ee8445d..53f4eaa 100644 --- a/ash/components/shortcut_viewer_strings.grdp +++ b/ash/components/shortcut_viewer_strings.grdp
@@ -97,10 +97,10 @@ <!-- Shortcuts descriptions --> <message name="IDS_KSV_DESCRIPTION_TOGGLE_DOCKED_MAGNIFIER" desc="Description of the command in keyboard shortcut viewer."> - Toggle the Docked Magnifier on or off + Turn the docked magnifier on or off </message> <message name="IDS_KSV_DESCRIPTION_TOGGLE_FULLSCREEN_MAGNIFIER" desc="Description of the command in keyboard shortcut viewer."> - Toggle the Fullscreen Magnifier on or off + Turn the fullscreen magnifier on or off </message> <message name="IDS_KSV_DESCRIPTION_LOCK_SCREEN" desc="Description of the command in keyboard shortcut viewer."> Lock screen
diff --git a/ash/display/cros_display_config_unittest.cc b/ash/display/cros_display_config_unittest.cc index b720354..e2bb970 100644 --- a/ash/display/cros_display_config_unittest.cc +++ b/ash/display/cros_display_config_unittest.cc
@@ -396,15 +396,15 @@ const std::vector<double>& zoom_factors = info_0.available_display_zoom_factors; EXPECT_EQ(9u, zoom_factors.size()); - EXPECT_FLOAT_EQ(0.6, zoom_factors[0]); - EXPECT_FLOAT_EQ(0.7, zoom_factors[1]); - EXPECT_FLOAT_EQ(0.8, zoom_factors[2]); - EXPECT_FLOAT_EQ(0.9, zoom_factors[3]); - EXPECT_FLOAT_EQ(1.0, zoom_factors[4]); - EXPECT_FLOAT_EQ(1.1, zoom_factors[5]); - EXPECT_FLOAT_EQ(1.2, zoom_factors[6]); - EXPECT_FLOAT_EQ(1.3, zoom_factors[7]); - EXPECT_FLOAT_EQ(1.4, zoom_factors[8]); + EXPECT_FLOAT_EQ(0.90f, zoom_factors[0]); + EXPECT_FLOAT_EQ(0.95f, zoom_factors[1]); + EXPECT_FLOAT_EQ(1.f, zoom_factors[2]); + EXPECT_FLOAT_EQ(1.05f, zoom_factors[3]); + EXPECT_FLOAT_EQ(1.10f, zoom_factors[4]); + EXPECT_FLOAT_EQ(1.15f, zoom_factors[5]); + EXPECT_FLOAT_EQ(1.20f, zoom_factors[6]); + EXPECT_FLOAT_EQ(1.25f, zoom_factors[7]); + EXPECT_FLOAT_EQ(1.30f, zoom_factors[8]); } TEST_F(CrosDisplayConfigTest, SetDisplayPropertiesPrimary) {
diff --git a/ash/resources/vector_icons/BUILD.gn b/ash/resources/vector_icons/BUILD.gn index 92a6cd1..d4c8932 100644 --- a/ash/resources/vector_icons/BUILD.gn +++ b/ash/resources/vector_icons/BUILD.gn
@@ -155,6 +155,7 @@ "system_menu_volume_low.icon", "system_menu_volume_medium.icon", "system_menu_volume_mute.icon", + "system_power_button_menu_feedback.icon", "system_power_button_menu_lock_screen.icon", "system_power_button_menu_power_off.icon", "system_power_button_menu_sign_out.icon",
diff --git a/ash/resources/vector_icons/system_power_button_menu_feedback.icon b/ash/resources/vector_icons/system_power_button_menu_feedback.icon new file mode 100644 index 0000000..cd191196 --- /dev/null +++ b/ash/resources/vector_icons/system_power_button_menu_feedback.icon
@@ -0,0 +1,66 @@ +// 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. + +MOVE_TO, 40, 4, +LINE_TO, 8, 4, +CUBIC_TO, 5.8f, 4, 4.02f, 5.8f, 4.02f, 8, +LINE_TO, 4, 44, +LINE_TO, 12, 36, +LINE_TO, 40, 36, +CUBIC_TO, 42.2f, 36, 44, 34.2f, 44, 32, +LINE_TO, 44, 8, +CUBIC_TO, 44, 5.8f, 42.2f, 4, 40, 4, +CLOSE, +MOVE_TO, 40, 32, +LINE_TO, 10.34f, 32, +LINE_TO, 9.16f, 33.18f, +LINE_TO, 8, 34.34f, +LINE_TO, 8, 8, +LINE_TO, 40, 8, +LINE_TO, 40, 32, +CLOSE, +MOVE_TO, 22, 24, +LINE_TO, 26, 24, +LINE_TO, 26, 28, +LINE_TO, 22, 28, +LINE_TO, 22, 24, +CLOSE, +MOVE_TO, 22, 12, +LINE_TO, 26, 12, +LINE_TO, 26, 20, +LINE_TO, 22, 20, +LINE_TO, 22, 12, +CLOSE + +CANVAS_DIMENSIONS, 24, +MOVE_TO, 20, 2, +LINE_TO, 4, 2, +CUBIC_TO, 2.9f, 2, 2.01f, 2.9f, 2.01f, 4, +LINE_TO, 2, 22, +LINE_TO, 6, 18, +LINE_TO, 20, 18, +CUBIC_TO, 21.1f, 18, 22, 17.1f, 22, 16, +LINE_TO, 22, 4, +CUBIC_TO, 22, 2.9f, 21.1f, 2, 20, 2, +CLOSE, +MOVE_TO, 20, 16, +LINE_TO, 5.17f, 16, +LINE_TO, 4.58f, 16.59f, +LINE_TO, 4, 17.17f, +LINE_TO, 4, 4, +LINE_TO, 20, 4, +LINE_TO, 20, 16, +CLOSE, +MOVE_TO, 11, 12, +LINE_TO, 13, 12, +LINE_TO, 13, 14, +LINE_TO, 11, 14, +LINE_TO, 11, 12, +CLOSE, +MOVE_TO, 11, 6, +LINE_TO, 13, 6, +LINE_TO, 13, 10, +LINE_TO, 11, 10, +LINE_TO, 11, 6, +CLOSE
diff --git a/ash/system/power/power_button_controller.cc b/ash/system/power/power_button_controller.cc index a6e9f1c..48b2347351 100644 --- a/ash/system/power/power_button_controller.cc +++ b/ash/system/power/power_button_controller.cc
@@ -562,13 +562,11 @@ void PowerButtonController::UpdatePowerButtonEventUMAHistogram( uint32_t up_state) { - if (up_state & UP_SHOWING_ANIMATION_CANCELLED) { + if (up_state & UP_SHOWING_ANIMATION_CANCELLED) RecordPressInLaptopModeHistogram(PowerButtonPressType::kTapWithoutMenu); - } - if (up_state & UP_MENU_TIMER_WAS_RUNNING) { + if (up_state & UP_MENU_TIMER_WAS_RUNNING) RecordPressInTabletModeHistogram(PowerButtonPressType::kTapWithoutMenu); - } if (menu_shown_when_power_button_down_) { if (up_state & UP_PRE_SHUTDOWN_TIMER_WAS_RUNNING) {
diff --git a/ash/system/power/power_button_controller_test_api.cc b/ash/system/power/power_button_controller_test_api.cc index 32a746d..94287a7 100644 --- a/ash/system/power/power_button_controller_test_api.cc +++ b/ash/system/power/power_button_controller_test_api.cc
@@ -78,6 +78,10 @@ GetPowerButtonMenuView()->lock_screen_item_for_test(); } +bool PowerButtonControllerTestApi::MenuHasFeedbackItem() const { + return IsMenuOpened() && GetPowerButtonMenuView()->feedback_item_for_test(); +} + PowerButtonScreenshotController* PowerButtonControllerTestApi::GetScreenshotController() { return controller_->screenshot_controller_.get();
diff --git a/ash/system/power/power_button_controller_test_api.h b/ash/system/power/power_button_controller_test_api.h index 59be2f1..77b3d24 100644 --- a/ash/system/power/power_button_controller_test_api.h +++ b/ash/system/power/power_button_controller_test_api.h
@@ -64,6 +64,9 @@ // True if |controller_|'s menu has a lock screen item. bool MenuHasLockScreenItem() const; + // True if |controller_|'s menu has a feedback item. + bool MenuHasFeedbackItem() const; + PowerButtonScreenshotController* GetScreenshotController(); void SetPowerButtonType(PowerButtonController::ButtonType button_type);
diff --git a/ash/system/power/power_button_controller_unittest.cc b/ash/system/power/power_button_controller_unittest.cc index 60277df..00e7974 100644 --- a/ash/system/power/power_button_controller_unittest.cc +++ b/ash/system/power/power_button_controller_unittest.cc
@@ -26,6 +26,7 @@ #include "base/command_line.h" #include "base/json/json_writer.h" #include "base/run_loop.h" +#include "base/test/scoped_feature_list.h" #include "base/test/simple_test_tick_clock.h" #include "chromeos/dbus/fake_power_manager_client.h" #include "chromeos/dbus/fake_session_manager_client.h" @@ -85,6 +86,8 @@ // Run the event loop so that PowerButtonDisplayController can receive the // initial backlights-forced-off state. base::RunLoop().RunUntilIdle(); + scoped_feature_list_.InitAndEnableFeature( + PowerButtonMenuView::kEnableFeedbackItem); } protected: @@ -151,6 +154,9 @@ power_button_controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); } + private: + base::test::ScopedFeatureList scoped_feature_list_; + DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerTest); }; @@ -782,31 +788,34 @@ // Tests the menu items according to the login and screen locked status. TEST_F(PowerButtonControllerTest, MenuItemsToLoginAndLockedStatus) { - // No sign out and lock screen item if user is not logged in. + // No sign out, lock screen and feedback items if user is not logged in. ClearLogin(); Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN); OpenPowerButtonMenu(); EXPECT_FALSE(power_button_test_api_->MenuHasSignOutItem()); EXPECT_FALSE(power_button_test_api_->MenuHasLockScreenItem()); + EXPECT_FALSE(power_button_test_api_->MenuHasFeedbackItem()); TapToDismissPowerButtonMenu(); - // Should have sign out and lock screen item if user is logged in and screen - // is unlocked. + // Should have sign out, lock screen and feedback items if user is logged in + // and screen is unlocked. CreateUserSessions(1); Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER); OpenPowerButtonMenu(); EXPECT_FALSE(GetLockedState()); EXPECT_TRUE(power_button_test_api_->MenuHasSignOutItem()); EXPECT_TRUE(power_button_test_api_->MenuHasLockScreenItem()); + EXPECT_TRUE(power_button_test_api_->MenuHasFeedbackItem()); TapToDismissPowerButtonMenu(); - // Should have sign out but not lock screen item if user is logged in but - // screen is locked. + // Should have sign out but not lock screen and feedback items if user is + // logged in but screen is locked. LockScreen(); EXPECT_TRUE(GetLockedState()); OpenPowerButtonMenu(); EXPECT_TRUE(power_button_test_api_->MenuHasSignOutItem()); EXPECT_FALSE(power_button_test_api_->MenuHasLockScreenItem()); + EXPECT_FALSE(power_button_test_api_->MenuHasFeedbackItem()); } // Tests long-pressing the power button when the menu is open. @@ -977,6 +986,7 @@ OpenPowerButtonMenu(); ASSERT_TRUE(power_button_test_api_->MenuHasSignOutItem()); ASSERT_TRUE(power_button_test_api_->MenuHasLockScreenItem()); + ASSERT_TRUE(power_button_test_api_->MenuHasFeedbackItem()); PressKey(ui::VKEY_TAB); EXPECT_TRUE(power_button_test_api_->GetPowerButtonMenuView() ->power_off_item_for_test() @@ -994,11 +1004,21 @@ PressKey(ui::VKEY_TAB); EXPECT_TRUE(power_button_test_api_->GetPowerButtonMenuView() + ->feedback_item_for_test() + ->HasFocus()); + + PressKey(ui::VKEY_TAB); + EXPECT_TRUE(power_button_test_api_->GetPowerButtonMenuView() ->power_off_item_for_test() ->HasFocus()); PressKey(ui::VKEY_UP); EXPECT_TRUE(power_button_test_api_->GetPowerButtonMenuView() + ->feedback_item_for_test() + ->HasFocus()); + + PressKey(ui::VKEY_UP); + EXPECT_TRUE(power_button_test_api_->GetPowerButtonMenuView() ->lock_screen_item_for_test() ->HasFocus()); @@ -1193,7 +1213,7 @@ // display has different scale factors. TEST_P(PowerButtonControllerWithPositionTest, MenuShownAtPercentageOfPosition) { const int scale_factor = 2; - std::string display = "4000x2400*" + std::to_string(scale_factor); + std::string display = "8000x2400*" + std::to_string(scale_factor); UpdateDisplay(display); int64_t primary_id = GetPrimaryDisplay().id(); display::test::ScopedSetInternalDisplayId set_internal(display_manager(),
diff --git a/ash/system/power/power_button_menu_metrics_type.h b/ash/system/power/power_button_menu_metrics_type.h index 8081ce6..52c3524 100644 --- a/ash/system/power/power_button_menu_metrics_type.h +++ b/ash/system/power/power_button_menu_metrics_type.h
@@ -16,7 +16,8 @@ kDismissByMouse, kDismissByTouch, kLockScreen, - kMaxValue = kLockScreen, + kFeedback, + kMaxValue = kFeedback, }; void RecordMenuActionHistogram(PowerButtonMenuActionType type);
diff --git a/ash/system/power/power_button_menu_view.cc b/ash/system/power/power_button_menu_view.cc index cc6524a..ef8e713 100644 --- a/ash/system/power/power_button_menu_view.cc +++ b/ash/system/power/power_button_menu_view.cc
@@ -5,6 +5,7 @@ #include "ash/system/power/power_button_menu_view.h" #include "ash/display/screen_orientation_controller.h" +#include "ash/new_window_controller.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/session/session_controller.h" #include "ash/shell.h" @@ -37,6 +38,7 @@ using PowerButtonPosition = PowerButtonController::PowerButtonPosition; +constexpr base::Feature PowerButtonMenuView::kEnableFeedbackItem; constexpr base::TimeDelta PowerButtonMenuView::kMenuAnimationDuration; PowerButtonMenuView::PowerButtonMenuView( @@ -158,41 +160,54 @@ l10n_util::GetStringUTF16( IDS_ASH_POWER_BUTTON_MENU_LOCK_SCREEN_BUTTON)); AddChildView(lock_screen_item_); + + if (base::FeatureList::IsEnabled(kEnableFeedbackItem)) { + feedback_item_ = new PowerButtonMenuItemView( + this, kSystemPowerButtonMenuFeedbackIcon, + l10n_util::GetStringUTF16( + IDS_ASH_POWER_BUTTON_MENU_FEEDBACK_BUTTON)); + AddChildView(feedback_item_); + } } } } void PowerButtonMenuView::Layout() { - const gfx::Rect rect(GetContentsBounds()); + gfx::Rect rect(GetContentsBounds()); + const gfx::Size item_size(power_off_item_->GetPreferredSize()); + rect.set_size(item_size); gfx::Rect power_off_rect(rect); - power_off_rect.set_size(power_off_item_->GetPreferredSize()); const int y_offset = kMenuItemVerticalPadding - PowerButtonMenuItemView::kItemBorderThickness; const int power_off_x_offset = kMenuItemHorizontalPadding - PowerButtonMenuItemView::kItemBorderThickness; - power_off_rect.Offset(gfx::Vector2d(power_off_x_offset, y_offset)); + power_off_rect.Offset(power_off_x_offset, y_offset); power_off_item_->SetBoundsRect(power_off_rect); if (sign_out_item_) { gfx::Rect sign_out_rect(rect); - sign_out_rect.set_size(sign_out_item_->GetPreferredSize()); const int padding_between_items_with_border = kPaddingBetweenMenuItems - 2 * PowerButtonMenuItemView::kItemBorderThickness; - const int sign_out_x_offset = power_off_x_offset + - power_off_item_->GetPreferredSize().width() + + const int sign_out_x_offset = power_off_x_offset + item_size.width() + padding_between_items_with_border; - sign_out_rect.Offset(gfx::Vector2d(sign_out_x_offset, y_offset)); + sign_out_rect.Offset(sign_out_x_offset, y_offset); sign_out_item_->SetBoundsRect(sign_out_rect); if (lock_screen_item_) { gfx::Rect lock_screen_rect(rect); - lock_screen_rect.set_size(lock_screen_item_->GetPreferredSize()); - lock_screen_rect.Offset(gfx::Vector2d( - sign_out_x_offset + sign_out_item_->GetPreferredSize().width() + - padding_between_items_with_border, - y_offset)); + const int lock_screen_x_offset = sign_out_x_offset + item_size.width() + + padding_between_items_with_border; + lock_screen_rect.Offset(lock_screen_x_offset, y_offset); lock_screen_item_->SetBoundsRect(lock_screen_rect); + + if (feedback_item_) { + gfx::Rect feedback_rect(rect); + feedback_rect.Offset(lock_screen_x_offset + item_size.width() + + padding_between_items_with_border, + y_offset); + feedback_item_->SetBoundsRect(feedback_rect); + } } } } @@ -224,6 +239,8 @@ width += one_item_x_offset; if (lock_screen_item_) width += one_item_x_offset; + if (feedback_item_) + width += one_item_x_offset; } menu_size.set_width(width); return menu_size; @@ -243,10 +260,13 @@ } else if (sender == lock_screen_item_) { RecordMenuActionHistogram(PowerButtonMenuActionType::kLockScreen); shell->session_controller()->LockScreen(); - shell->power_button_controller()->DismissMenu(); + } else if (sender == feedback_item_) { + RecordMenuActionHistogram(PowerButtonMenuActionType::kFeedback); + shell->new_window_controller()->OpenFeedbackPage(); } else { NOTREACHED() << "Invalid sender"; } + shell->power_button_controller()->DismissMenu(); } void PowerButtonMenuView::OnImplicitAnimationsCompleted() {
diff --git a/ash/system/power/power_button_menu_view.h b/ash/system/power/power_button_menu_view.h index f6ec691..8e0a645 100644 --- a/ash/system/power/power_button_menu_view.h +++ b/ash/system/power/power_button_menu_view.h
@@ -7,6 +7,7 @@ #include "ash/ash_export.h" #include "ash/system/power/power_button_controller.h" +#include "base/feature_list.h" #include "base/macros.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/views/controls/button/button.h" @@ -28,6 +29,11 @@ // Distance of the menu animation transform. static constexpr int kMenuViewTransformDistanceDp = 16; + // The feedback item is controlled by a feature solely so it can be turned on + // only for some users on the beta, dev and stable channels. + static constexpr base::Feature kEnableFeedbackItem{ + "PowerButtonMenuFeedbackItem", base::FEATURE_DISABLED_BY_DEFAULT}; + // Direction of the animation transform. X means to translate from // x-coordinate. Y means to translate from y-coordinate. enum class TransformDirection { NONE, X, Y }; @@ -51,6 +57,9 @@ PowerButtonMenuItemView* lock_screen_item_for_test() const { return lock_screen_item_; } + PowerButtonMenuItemView* feedback_item_for_test() const { + return feedback_item_; + } // Requests focus for |power_off_item_|. void FocusPowerOffButton(); @@ -80,6 +89,7 @@ PowerButtonMenuItemView* power_off_item_ = nullptr; PowerButtonMenuItemView* sign_out_item_ = nullptr; PowerButtonMenuItemView* lock_screen_item_ = nullptr; + PowerButtonMenuItemView* feedback_item_ = nullptr; // The physical display side of power button in landscape primary. PowerButtonController::PowerButtonPosition power_button_position_;
diff --git a/base/BUILD.gn b/base/BUILD.gn index 917434d..c6b55f54 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn
@@ -2005,7 +2005,6 @@ ] deps = [ ":base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/icu:icuuc", ] @@ -2017,7 +2016,6 @@ ] deps = [ ":base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2039,9 +2037,6 @@ "cfgmgr32.lib", "shell32.lib", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } loadable_module("scoped_handle_test_dll") { @@ -2062,9 +2057,6 @@ sources = [ "profiler/test_support_library.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } } }
diff --git a/base/android/jni_generator/BUILD.gn b/base/android/jni_generator/BUILD.gn index f93b416..915da97 100644 --- a/base/android/jni_generator/BUILD.gn +++ b/base/android/jni_generator/BUILD.gn
@@ -41,7 +41,6 @@ ":jni_sample_native_side", ":sample_jni_registration", "//base", - "//build/config:exe_and_shlib_deps", ] }
diff --git a/base/android/linker/BUILD.gn b/base/android/linker/BUILD.gn index 27e5cdb..ce6ae7f7 100644 --- a/base/android/linker/BUILD.gn +++ b/base/android/linker/BUILD.gn
@@ -18,7 +18,6 @@ # '<(android_ndk_root)/crazy_linker.gyp:crazy_linker' # However, we use our own fork. See bug 384700. deps = [ - "//build/config:exe_and_shlib_deps", "//third_party/android_crazy_linker", ] }
diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn index c0c1932..bc25b14 100644 --- a/base/test/BUILD.gn +++ b/base/test/BUILD.gn
@@ -351,7 +351,6 @@ deps = [ ":fontconfig_util_linux", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -375,7 +374,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", ] } } @@ -441,7 +439,4 @@ sources = [ "test_child_process.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] }
diff --git a/base/threading/thread_local_storage.h b/base/threading/thread_local_storage.h index f84ac33..0f0cc6b3 100644 --- a/base/threading/thread_local_storage.h +++ b/base/threading/thread_local_storage.h
@@ -19,7 +19,7 @@ #endif namespace heap_profiling { -class ScopedAllowLogging; +class ScopedAllowAlloc; } // namespace heap_profiling namespace base { @@ -156,7 +156,7 @@ friend class base::SamplingHeapProfiler; friend class base::internal::ThreadLocalStorageTestInternal; friend class base::trace_event::MallocDumpProvider; - friend class heap_profiling::ScopedAllowLogging; + friend class heap_profiling::ScopedAllowAlloc; static bool HasBeenDestroyed(); DISALLOW_COPY_AND_ASSIGN(ThreadLocalStorage);
diff --git a/base/trace_event/trace_event_memory_overhead.cc b/base/trace_event/trace_event_memory_overhead.cc index d5875f8..dd7b3025 100644 --- a/base/trace_event/trace_event_memory_overhead.cc +++ b/base/trace_event/trace_event_memory_overhead.cc
@@ -47,6 +47,8 @@ return "base::Value"; case TraceEventMemoryOverhead::kTraceEventMemoryOverhead: return "TraceEventMemoryOverhead"; + case TraceEventMemoryOverhead::kFrameMetrics: + return "FrameMetrics"; case TraceEventMemoryOverhead::kLast: NOTREACHED(); }
diff --git a/base/trace_event/trace_event_memory_overhead.h b/base/trace_event/trace_event_memory_overhead.h index 1587a30..69468d4 100644 --- a/base/trace_event/trace_event_memory_overhead.h +++ b/base/trace_event/trace_event_memory_overhead.h
@@ -39,6 +39,7 @@ kStdString, kBaseValue, kTraceEventMemoryOverhead, + kFrameMetrics, kLast };
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 93a97ff2..04a9639 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn
@@ -641,6 +641,7 @@ foreach(target_type, [ "executable", + "loadable_module", "shared_library", ]) { template(target_type) {
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index ce18244a..490f1b4 100644 --- a/build/config/android/internal_rules.gni +++ b/build/config/android/internal_rules.gni
@@ -2846,7 +2846,6 @@ if (defined(invoker.deps)) { _accumulated_deps = invoker.deps } - _accumulated_deps += [ "//build/config:exe_and_shlib_deps" ] _enable_build_hooks = _supports_android &&
diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn index 55a83f3d..ba5edc1 100644 --- a/build/config/sanitizers/BUILD.gn +++ b/build/config/sanitizers/BUILD.gn
@@ -13,11 +13,9 @@ import("//build/config/ios/ios_sdk.gni") } -# Contains the dependencies needed for sanitizers to link into -# executables and shared_libraries. Unconditionally depend upon -# "//build/config:exe_and_shlib_deps" to pull in this target. +# Contains the dependencies needed for sanitizers to link into executables and +# shared_libraries. group("deps") { - visibility = [ "//build/config:exe_and_shlib_deps" ] if (using_sanitizer) { public_configs = [ ":sanitizer_options_link_helper",
diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn index 4f77b14..d921713 100644 --- a/build/config/win/BUILD.gn +++ b/build/config/win/BUILD.gn
@@ -361,7 +361,10 @@ # turned on either. # CFG seems to lead to random corruption with incremental linking so turn off # CFG in component builds. https://crbug.com/812421 - if (!is_debug && !is_component_build) { + # ASan and CFG leads to slow process startup. Chromium's test runner uses + # lots of child processes, so this means things are really slow. Disable CFG + # for now. https://crbug.com/846966 + if (!is_debug && !is_component_build && !is_asan) { # Turn on CFG in msvc linker, regardless of compiler used. Turn off CFG for # longjmp (new in VS 2017) because it relies on compiler support which we do # not have enabled.
diff --git a/build/fuchsia/boot_data.py b/build/fuchsia/boot_data.py index 50275b04c..e70128c 100644 --- a/build/fuchsia/boot_data.py +++ b/build/fuchsia/boot_data.py
@@ -22,8 +22,8 @@ User fuchsia IdentitiesOnly yes IdentityFile {identity} - ServerAliveInterval 1 - ServerAliveCountMax 1 + ServerAliveInterval 2 + ServerAliveCountMax 5 ControlMaster auto ControlPersist 1m ControlPath /tmp/ssh-%r@%h:%p"""
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index e5b7356..c73326fc 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn
@@ -428,7 +428,6 @@ "test/fake_recording_source.cc", "test/fake_recording_source.h", "test/fake_rendering_stats_instrumentation.h", - "test/fake_resource_provider.h", "test/fake_scoped_ui_resource.cc", "test/fake_scoped_ui_resource.h", "test/fake_scrollbar.cc",
diff --git a/cc/raster/raster_buffer_provider_perftest.cc b/cc/raster/raster_buffer_provider_perftest.cc index 8310bad..36db4d2 100644 --- a/cc/raster/raster_buffer_provider_perftest.cc +++ b/cc/raster/raster_buffer_provider_perftest.cc
@@ -18,7 +18,6 @@ #include "cc/raster/zero_copy_raster_buffer_provider.h" #include "cc/resources/resource_pool.h" #include "cc/test/fake_layer_tree_frame_sink.h" -#include "cc/test/fake_resource_provider.h" #include "cc/tiles/tile_task_manager.h" #include "components/viz/client/client_resource_provider.h" #include "components/viz/common/gpu/context_cache_controller.h" @@ -501,14 +500,12 @@ private: void Create3dResourceProvider() { - resource_provider_ = FakeResourceProvider::CreateClientResourceProvider( - compositor_context_provider_.get()); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); } void CreateSoftwareResourceProvider() { layer_tree_frame_sink_ = FakeLayerTreeFrameSink::CreateSoftware(); - resource_provider_ = - FakeResourceProvider::CreateClientResourceProvider(nullptr); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); } std::string TestModifierString() const { @@ -571,8 +568,7 @@ public: // Overridden from testing::Test: void SetUp() override { - resource_provider_ = FakeResourceProvider::CreateClientResourceProvider( - compositor_context_provider_.get()); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); resource_pool_ = std::make_unique<ResourcePool>( resource_provider_.get(), compositor_context_provider_.get(), task_runner_, ResourcePool::kDefaultExpirationDelay, false);
diff --git a/cc/raster/raster_buffer_provider_unittest.cc b/cc/raster/raster_buffer_provider_unittest.cc index 9484b66..b7de488 100644 --- a/cc/raster/raster_buffer_provider_unittest.cc +++ b/cc/raster/raster_buffer_provider_unittest.cc
@@ -27,7 +27,6 @@ #include "cc/resources/resource_pool.h" #include "cc/test/fake_layer_tree_frame_sink.h" #include "cc/test/fake_raster_source.h" -#include "cc/test/fake_resource_provider.h" #include "cc/tiles/tile_task_manager.h" #include "components/viz/client/client_resource_provider.h" #include "components/viz/common/resources/platform_color.h" @@ -297,14 +296,12 @@ context_provider_->BindToCurrentThread(); worker_context_provider_ = viz::TestContextProvider::CreateWorker(); layer_tree_frame_sink_ = FakeLayerTreeFrameSink::Create3d(); - resource_provider_ = FakeResourceProvider::CreateClientResourceProvider( - context_provider_.get()); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); } void CreateSoftwareResourceProvider() { layer_tree_frame_sink_ = FakeLayerTreeFrameSink::CreateSoftware(); - resource_provider_ = - FakeResourceProvider::CreateClientResourceProvider(nullptr); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); } void OnTimeout() {
diff --git a/cc/resources/resource_pool_unittest.cc b/cc/resources/resource_pool_unittest.cc index 154b7a8..2350af6 100644 --- a/cc/resources/resource_pool_unittest.cc +++ b/cc/resources/resource_pool_unittest.cc
@@ -9,8 +9,9 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" -#include "cc/test/fake_resource_provider.h" +#include "components/viz/client/client_resource_provider.h" #include "components/viz/common/resources/resource_sizes.h" +#include "components/viz/common/resources/returned_resource.h" #include "components/viz/test/test_context_provider.h" #include "components/viz/test/test_shared_bitmap_manager.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,8 +23,7 @@ void SetUp() override { context_provider_ = viz::TestContextProvider::Create(); context_provider_->BindToCurrentThread(); - resource_provider_ = FakeResourceProvider::CreateClientResourceProvider( - context_provider_.get()); + resource_provider_ = std::make_unique<viz::ClientResourceProvider>(true); task_runner_ = base::ThreadTaskRunnerHandle::Get(); resource_pool_ = std::make_unique<ResourcePool>( resource_provider_.get(), context_provider_.get(), task_runner_,
diff --git a/cc/test/fake_resource_provider.h b/cc/test/fake_resource_provider.h deleted file mode 100644 index 150a7e2..0000000 --- a/cc/test/fake_resource_provider.h +++ /dev/null
@@ -1,32 +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 CC_TEST_FAKE_RESOURCE_PROVIDER_H_ -#define CC_TEST_FAKE_RESOURCE_PROVIDER_H_ - -#include "components/viz/client/client_resource_provider.h" -#include "components/viz/service/display/display_resource_provider.h" - -namespace cc { - -class FakeResourceProvider { - public: - static std::unique_ptr<viz::ClientResourceProvider> - CreateClientResourceProvider(viz::ContextProvider* context_provider) { - return std::make_unique<viz::ClientResourceProvider>(context_provider, - true); - } - - static std::unique_ptr<viz::DisplayResourceProvider> - CreateDisplayResourceProvider( - viz::ContextProvider* context_provider, - viz::SharedBitmapManager* shared_bitmap_manager) { - return std::make_unique<viz::DisplayResourceProvider>( - context_provider, shared_bitmap_manager); - } -}; - -} // namespace cc - -#endif // CC_TEST_FAKE_RESOURCE_PROVIDER_H_
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc index c705f25..20b615ea 100644 --- a/cc/test/layer_test_common.cc +++ b/cc/test/layer_test_common.cc
@@ -225,10 +225,7 @@ surface_impl->set_occlusion_in_content_space( Occlusion(gfx::Transform(), SimpleEnclosedRegion(occluded), SimpleEnclosedRegion())); - surface_impl->AppendQuads(resource_provider()->IsSoftware() - ? DRAW_MODE_SOFTWARE - : DRAW_MODE_HARDWARE, - render_pass_.get(), &data); + surface_impl->AppendQuads(DRAW_MODE_HARDWARE, render_pass_.get(), &data); } void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() {
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 03320d7..1d3ddd58 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc
@@ -206,8 +206,8 @@ child_context_provider_ = base::MakeRefCounted<TestInProcessContextProvider>( /*enable_oop_rasterization=*/false); child_context_provider_->BindToCurrentThread(); - child_resource_provider_ = std::make_unique<viz::ClientResourceProvider>( - child_context_provider_.get(), true); + child_resource_provider_ = + std::make_unique<viz::ClientResourceProvider>(true); } void PixelTest::SetUpGLRenderer(bool flipped_output_surface) { @@ -240,7 +240,7 @@ resource_provider_ = std::make_unique<viz::DisplayResourceProvider>( nullptr, shared_bitmap_manager_.get()); child_resource_provider_ = - std::make_unique<viz::ClientResourceProvider>(nullptr, true); + std::make_unique<viz::ClientResourceProvider>(true); auto renderer = std::make_unique<viz::SoftwareRenderer>( &renderer_settings_, output_surface_.get(), resource_provider_.get());
diff --git a/cc/tiles/picture_layer_tiling_set_unittest.cc b/cc/tiles/picture_layer_tiling_set_unittest.cc index fdd8e78..b18a67c 100644 --- a/cc/tiles/picture_layer_tiling_set_unittest.cc +++ b/cc/tiles/picture_layer_tiling_set_unittest.cc
@@ -10,7 +10,6 @@ #include "cc/test/fake_output_surface_client.h" #include "cc/test/fake_picture_layer_tiling_client.h" #include "cc/test/fake_raster_source.h" -#include "cc/test/fake_resource_provider.h" #include "cc/trees/layer_tree_settings.h" #include "components/viz/client/client_resource_provider.h" #include "components/viz/test/fake_output_surface.h" @@ -247,8 +246,7 @@ ASSERT_EQ(context_provider->BindToCurrentThread(), gpu::ContextResult::kSuccess); std::unique_ptr<viz::ClientResourceProvider> resource_provider = - FakeResourceProvider::CreateClientResourceProvider( - context_provider.get()); + std::make_unique<viz::ClientResourceProvider>(true); FakePictureLayerTilingClient client(resource_provider.get(), context_provider.get());
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 011763e..c5d8a32 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc
@@ -3045,8 +3045,9 @@ max_texture_size_ = 16 * 1024; } + // TODO(danakj): Move delegated_sync_points_required to LayerTreeSettings, + // then don't recreate this when the LayerTreeFrameSink changes. resource_provider_ = std::make_unique<viz::ClientResourceProvider>( - layer_tree_frame_sink_->context_provider(), layer_tree_frame_sink_->capabilities().delegated_sync_points_required); resource_pool_ = std::make_unique<ResourcePool>( resource_provider_.get(), layer_tree_frame_sink_->context_provider(),
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc index 3e7fa7e..7479426 100644 --- a/cc/trees/layer_tree_host_unittest_context.cc +++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -22,7 +22,6 @@ #include "cc/test/fake_painted_scrollbar_layer.h" #include "cc/test/fake_picture_layer.h" #include "cc/test/fake_picture_layer_impl.h" -#include "cc/test/fake_resource_provider.h" #include "cc/test/fake_scoped_ui_resource.h" #include "cc/test/fake_scrollbar.h" #include "cc/test/fake_video_frame_provider.h" @@ -32,6 +31,7 @@ #include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_impl.h" #include "cc/trees/single_thread_proxy.h" +#include "components/viz/client/client_resource_provider.h" #include "components/viz/common/resources/single_release_callback.h" #include "components/viz/test/test_context_provider.h" #include "components/viz/test/test_gles2_interface.h" @@ -885,8 +885,7 @@ CHECK_EQ(result, gpu::ContextResult::kSuccess); shared_bitmap_manager_ = std::make_unique<viz::TestSharedBitmapManager>(); child_resource_provider_ = - FakeResourceProvider::CreateClientResourceProvider( - child_context_provider_.get()); + std::make_unique<viz::ClientResourceProvider>(true); } static void EmptyReleaseCallback(const gpu::SyncToken& sync_token,
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 395d16c7..d292793b 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn
@@ -153,10 +153,7 @@ sources += [ "app/chrome_exe_resource.h" ] defines = [] public_deps = [] - deps += [ - "//build/config:exe_and_shlib_deps", - "//printing/buildflags", - ] + deps += [ "//printing/buildflags" ] data += [ "$root_out_dir/resources.pak" ] if (is_linux || is_win) { @@ -396,7 +393,6 @@ ":chrome_dll_manifest", ":chrome_dll_version", "//base/trace_event/etw_manifest:chrome_events_win", - "//build/config:exe_and_shlib_deps", "//chrome/app:chrome_dll_resources", "//chrome/app:command_ids", "//chrome/app/theme:chrome_unscaled_resources", @@ -503,7 +499,6 @@ ":child_dependencies", ":chrome_child_manifest", ":chrome_dll_version", - "//build/config:exe_and_shlib_deps", "//chrome/browser/policy:path_parser", "//chrome/common:buildflags", "//chrome/install_static:install_static_util", @@ -634,7 +629,6 @@ ":chrome_app_strings_bundle_data", ":chrome_resources", ":chrome_versioned_bundle_data", - "//build/config:exe_and_shlib_deps", "//chrome/common:version_header", ] @@ -820,7 +814,6 @@ defines = [ "HELPER_EXECUTABLE" ] deps = [ - "//build/config:exe_and_shlib_deps", "//chrome/common:version_header", "//sandbox/mac:seatbelt", ] @@ -1268,7 +1261,6 @@ ":packed_resources", ":swiftshader_library", ":widevine_cdm_library", - "//build/config:exe_and_shlib_deps", "//chrome/app/nibs:chrome_xibs", "//chrome/browser/resources/media/mei_preload:component_bundle", ]
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn index 2ec8a666..ac0672a9 100644 --- a/chrome/android/BUILD.gn +++ b/chrome/android/BUILD.gn
@@ -337,6 +337,7 @@ # Include sources from feed_java_sources.gni. java_files += feed_java_sources + srcjar_deps += feed_srcjar_deps if (enable_vr) { java_files += chrome_vr_java_sources @@ -823,10 +824,7 @@ shared_library(target_name) { forward_variables_from(invoker, "*") - deps += [ - "//build/config:exe_and_shlib_deps", - "//chrome:chrome_android_core", - ] + deps += [ "//chrome:chrome_android_core" ] if (use_order_profiling) { deps += [ "//tools/cygprofile" ] @@ -1036,7 +1034,6 @@ ] deps = [ "//android_webview:common", - "//build/config:exe_and_shlib_deps", "//chrome:chrome_android_core", ] @@ -1076,7 +1073,6 @@ ] deps = [ ":chrome_sync_shell_jni_registration($default_toolchain)", - "//build/config:exe_and_shlib_deps", "//chrome:chrome_android_core", "//chrome/browser/android/metrics:ukm_utils_for_test", "//components/sync",
diff --git a/chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java b/chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java new file mode 100644 index 0000000..736e687 --- /dev/null +++ b/chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java
@@ -0,0 +1,115 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.feed; + +import com.google.android.libraries.feed.api.requestmanager.RequestManager; +import com.google.android.libraries.feed.host.scheduler.SchedulerApi; +import com.google.search.now.wire.feed.FeedQueryProto.FeedQuery.RequestReason; + +import org.chromium.base.annotations.CalledByNative; +import org.chromium.base.annotations.JNINamespace; +import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.components.feed.NativeRequestBehavior; + +/** + * Provides access to native implementations of SchedulerApi. + */ +@JNINamespace("feed") +public class FeedSchedulerBridge implements SchedulerApi { + private long mNativeBridge; + private RequestManager mRequestManager; + + /** + * Creates a FeedSchedulerBridge for accessing native scheduling logic. + * + * @param profile Profile of the user we are rendering the Feed for. + */ + public FeedSchedulerBridge(Profile profile) { + mNativeBridge = nativeInit(profile); + } + + /* + * Cleans up native half of this bridge. + */ + public void destroy() { + assert mNativeBridge != 0; + nativeDestroy(mNativeBridge); + mNativeBridge = 0; + } + + /* + * Sets our copy of the RequestManager. Should be done as early as possible, + * as the scheduler will be unable to trigger refreshes until after it has a + * reference to a RequestManager. When this is called, it is assumed that + * the RequestManager is initialized and can be used. + * + * @param requestManager The interface that allows us make refresh requests. + */ + public void setRequestManager(RequestManager requestManager) { + mRequestManager = requestManager; + } + + @Override + public int shouldSessionRequestData(SessionManagerState sessionManagerState) { + assert mNativeBridge != 0; + + @NativeRequestBehavior + int nativeBehavior = nativeShouldSessionRequestData(mNativeBridge, + sessionManagerState.hasContent, sessionManagerState.contentCreationDateTimeMs, + sessionManagerState.hasOutstandingRequest); + // If this breaks, it is because SchedulerApi.RequestBehavior and the + // NativeRequestBehavior defined in feed_scheduler_host.h have diverged. + // If this happens during a feed DEPS roll, it likely means that the + // native side needs to be updated. Note that this will not catch new + // values and should handle value changes. Only removals/renames will + // cause compile failures. + switch (nativeBehavior) { + case NativeRequestBehavior.REQUEST_WITH_WAIT: + return SchedulerApi.RequestBehavior.REQUEST_WITH_WAIT; + case NativeRequestBehavior.REQUEST_WITH_CONTENT: + return SchedulerApi.RequestBehavior.REQUEST_WITH_CONTENT; + case NativeRequestBehavior.REQUEST_WITH_TIMEOUT: + return SchedulerApi.RequestBehavior.REQUEST_WITH_TIMEOUT; + case NativeRequestBehavior.NO_REQUEST_WITH_WAIT: + return SchedulerApi.RequestBehavior.NO_REQUEST_WITH_WAIT; + case NativeRequestBehavior.NO_REQUEST_WITH_CONTENT: + return SchedulerApi.RequestBehavior.NO_REQUEST_WITH_CONTENT; + case NativeRequestBehavior.NO_REQUEST_WITH_TIMEOUT: + return SchedulerApi.RequestBehavior.NO_REQUEST_WITH_TIMEOUT; + } + + return SchedulerApi.RequestBehavior.UNKNOWN; + } + + @Override + public void onReceiveNewContent(long contentCreationDateTimeMs) { + assert mNativeBridge != 0; + nativeOnReceiveNewContent(mNativeBridge); + } + + @Override + public void onRequestError(int networkResponseCode) { + assert mNativeBridge != 0; + nativeOnRequestError(mNativeBridge, networkResponseCode); + } + + @CalledByNative + private boolean triggerRefresh() { + if (mRequestManager != null) { + mRequestManager.triggerRefresh(RequestReason.SCHEDULED_REFRESH, ignored -> {}); + return true; + } + return false; + } + + private native long nativeInit(Profile profile); + private native void nativeDestroy(long nativeFeedSchedulerBridge); + private native @NativeRequestBehavior int nativeShouldSessionRequestData( + long nativeFeedSchedulerBridge, boolean hasContent, long contentCreationDateTimeMs, + boolean hasOutstandingRequest); + private native void nativeOnReceiveNewContent(long nativeFeedSchedulerBridge); + private native void nativeOnRequestError( + long nativeFeedSchedulerBridge, int networkResponseCode); +}
diff --git a/chrome/android/feed/feed_java_sources.gni b/chrome/android/feed/feed_java_sources.gni index 3e80941..b0a70cd 100644 --- a/chrome/android/feed/feed_java_sources.gni +++ b/chrome/android/feed/feed_java_sources.gni
@@ -13,9 +13,12 @@ "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedImageLoaderBridge.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNetworkBridge.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNewTabPage.java", + "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java", "//chrome/android/feed/core/java/src/org/chromium/chrome/browser/feed/action/FeedActionHandler.java", ] + feed_srcjar_deps = [ "//components/feed/core:feed_core_java_enums_srcjar" ] + feed_conformance_test_sources = [ "//chrome/android/javatests/src/org/chromium/chrome/browser/feed/FeedNetworkBridgeConformanceTest.java" ] feed_conformance_test_deps = [ @@ -24,6 +27,6 @@ ] } else { feed_deps = [] - feed_java_sources = [ "//chrome/android/feed/dummy/java/src/org/chromium/chrome/browser/feed/FeedNewTabPage.java" ] + feed_srcjar_deps = [] }
diff --git a/chrome/android/java/res/layout/data_usage_breakdown.xml b/chrome/android/java/res/layout/data_usage_breakdown.xml index 3a7585a..df02b63 100644 --- a/chrome/android/java/res/layout/data_usage_breakdown.xml +++ b/chrome/android/java/res/layout/data_usage_breakdown.xml
@@ -37,10 +37,14 @@ android:layout_width="match_parent"> <TextView + android:id="@+id/data_reduction_breakdown_site_title" android:text="@string/data_reduction_breakdown_site_title" android:layout_width="0dp" android:layout_weight="0" android:layout_gravity="start" + android:contentDescription="@string/data_reduction_breakdown_site_header_content_description" + android:drawablePadding="3dp" + android:drawableEnd="@drawable/data_reduction_breakdown_sort_arrow" style="@style/DataUsageBreakdownColumnLabel" /> <TextView @@ -48,6 +52,7 @@ android:text="@string/data_reduction_breakdown_used_title" android:layout_width="wrap_content" android:layout_marginStart="24dp" + android:contentDescription="@string/data_reduction_breakdown_used_header_content_description" android:drawablePadding="3dp" android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow" android:gravity="end" @@ -58,6 +63,7 @@ android:text="@string/data_reduction_breakdown_saved_title" android:layout_width="wrap_content" android:layout_marginStart="24dp" + android:contentDescription="@string/data_reduction_breakdown_saved_header_content_description" android:drawablePadding="3dp" android:drawableStart="@drawable/data_reduction_breakdown_sort_arrow" android:gravity="end"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/BitmapCache.java b/chrome/android/java/src/org/chromium/chrome/browser/BitmapCache.java new file mode 100644 index 0000000..ff11c394 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/BitmapCache.java
@@ -0,0 +1,151 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser; + +import android.graphics.Bitmap; +import android.os.Looper; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.util.LruCache; + +import org.chromium.base.DiscardableReferencePool; +import org.chromium.base.SysUtils; +import org.chromium.base.ThreadUtils; + +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * In-memory cache of Bitmap. + * + * Bitmaps are cached in memory and shared across all instances of BitmapCache. There are two + * levels of caches: one static cache for deduplication (or canonicalization) of bitmaps, and one + * per-object cache for storing recently used bitmaps. The deduplication cache uses weak references + * to allow bitmaps to be garbage-collected once they are no longer in use. As long as there is at + * least one strong reference to a bitmap, it is not going to be GC'd and will therefore stay in the + * cache. This ensures that there is never more than one (reachable) copy of a bitmap in memory. + * The {@link RecentlyUsedCache} is limited in size and dropped under memory pressure, or when the + * object is destroyed. + */ +public class BitmapCache { + private final int mCacheSize; + + /** + * Least-recently-used cache that falls back to the deduplication cache on misses. + * This propagates bitmaps that were only in the deduplication cache back into the LRU cache + * and also moves them to the front to ensure correct eviction order. + * Cache key is a pair of the filepath and the height/width of the thumbnail. Value is + * the thumbnail. + */ + private static class RecentlyUsedCache extends LruCache<String, Bitmap> { + private RecentlyUsedCache(int size) { + super(size); + } + + @Override + protected Bitmap create(String key) { + WeakReference<Bitmap> cachedBitmap = sDeduplicationCache.get(key); + return cachedBitmap == null ? null : cachedBitmap.get(); + } + + @Override + protected int sizeOf(String key, Bitmap thumbnail) { + return thumbnail.getByteCount(); + } + } + + /** + * Discardable reference to the {@link RecentlyUsedCache} that can be dropped under memory + * pressure. + */ + private DiscardableReferencePool.DiscardableReference<RecentlyUsedCache> mBitmapCache; + + /** + * The reference pool that contains the {@link #mBitmapCache}. Used to recreate a new cache + * after the old one has been dropped. + */ + private final DiscardableReferencePool mReferencePool; + + /** + * Static cache used for deduplicating bitmaps. The key is a pair of file name and thumbnail + * size (as for the {@link #mBitmapCache}. + */ + private static Map<String, WeakReference<Bitmap>> sDeduplicationCache = new HashMap<>(); + private static int sUsageCount; + + /** + * Creates an instance of a {@link BitmapCache}. + * + * This constructor must be called on UI thread. + * + * @param referencePool The discardable reference pool. See + * {@link ChromeApplication#getReferencePool}. + * @param size The capacity of the cache in bytes. + */ + public BitmapCache(DiscardableReferencePool referencePool, int size) { + ThreadUtils.assertOnUiThread(); + mReferencePool = referencePool; + mCacheSize = size; + mBitmapCache = referencePool.put(new RecentlyUsedCache(mCacheSize)); + } + + public Bitmap getBitmap(String key) { + ThreadUtils.assertOnUiThread(); + Bitmap cachedBitmap = getBitmapCache().get(key); + assert cachedBitmap == null || !cachedBitmap.isRecycled(); + maybeScheduleDeduplicationCache(); + return cachedBitmap; + } + + public void putBitmap(@NonNull String key, @Nullable Bitmap bitmap) { + ThreadUtils.assertOnUiThread(); + if (bitmap == null) return; + if (!SysUtils.isLowEndDevice()) { + getBitmapCache().put(key, bitmap); + } + maybeScheduleDeduplicationCache(); + sDeduplicationCache.put(key, new WeakReference<>(bitmap)); + } + + private RecentlyUsedCache getBitmapCache() { + RecentlyUsedCache bitmapCache = mBitmapCache.get(); + if (bitmapCache == null) { + bitmapCache = new RecentlyUsedCache(mCacheSize); + mBitmapCache = mReferencePool.put(bitmapCache); + } + return bitmapCache; + } + + private static void maybeScheduleDeduplicationCache() { + sUsageCount++; + // Amortized cost of automatic dedup work is constant. + if (sUsageCount < sDeduplicationCache.size()) return; + sUsageCount = 0; + scheduleDeduplicationCache(); + } + + private static void scheduleDeduplicationCache() { + Looper.myQueue().addIdleHandler(() -> { + compactDeduplicationCache(); + return false; + }); + } + + /** + * Compacts the deduplication cache by removing all entries that have been cleared by the + * garbage collector. + */ + private static void compactDeduplicationCache() { + // Too many angle brackets for clang-format :-( + // clang-format off + for (Iterator<Map.Entry<String, WeakReference<Bitmap>>> it = + sDeduplicationCache.entrySet().iterator(); it.hasNext();) { + // clang-format on + if (it.next().getValue().get() == null) it.remove(); + } + } +}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelper.java index 57909c8..a891882 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelper.java
@@ -299,19 +299,28 @@ if (shouldFetchCanonicalUrl(tab)) { mFetchRequestedForCurrentTab = true; + String url = tab.getUrl(); tab.getWebContents().getMainFrame().getCanonicalUrlForSharing(new Callback<String>() { @Override public void onResult(String result) { + if (tab != mCurrentTab) { + return; + } + // Reset mFetchRequestedForCurrentTab so that it remains false if // maybeStartFetchWithCanonicalURLResolved doesn't end up requesting // suggestions. If it does end up requesting suggestions, - // mFetchRequestedForCurrentTab will be set back to true in the same synchronous - // flow of execution, so there shouldn't be a race condition. + // mFetchRequestedForCurrentTab will be set back to true in the same + // synchronous flow of execution, so there shouldn't be a race condition. mFetchRequestedForCurrentTab = false; + TabFetchReadinessState tabFetchReadinessState = getTabFetchReadinessState(tab); - tabFetchReadinessState.setCanonicalUrl(result); - maybeStartFetchWithCanonicalURLResolved( - tab, getUrlToFetchFor(tab.getUrl(), result)); + if (tabFetchReadinessState != null && tabFetchReadinessState.isTrackingPage() + && tabFetchReadinessState.isContextTheSame(url)) { + tabFetchReadinessState.setCanonicalUrl(result); + maybeStartFetchWithCanonicalURLResolved( + tab, getUrlToFetchFor(tab.getUrl(), result)); + } } }); return;
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionProxyUma.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionProxyUma.java index ad211e6d..efc9e2a3 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionProxyUma.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionProxyUma.java
@@ -50,7 +50,8 @@ public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED = 24; public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED = 25; public static final int ACTION_SITE_BREAKDOWN_EXPANDED = 26; - public static final int ACTION_INDEX_BOUNDARY = 27; + public static final int ACTION_SITE_BREAKDOWN_SORTED_BY_HOSTNAME = 27; + public static final int ACTION_INDEX_BOUNDARY = 28; // Represent the possible Lo-Fi context menu user actions. This must remain in sync with // Previews.ContextMenuAction.LoFi in tools/metrics/histograms/histograms.xml. @@ -107,4 +108,4 @@ PREVIEWS_HISTOGRAM_NAME, action, ACTION_LOFI_CONTEXT_MENU_INDEX_BOUNDARY); } -} \ No newline at end of file +}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java index ef67a03..7377b16 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionSiteBreakdownView.java
@@ -39,6 +39,7 @@ private int mNumDataUseItemsToDisplay = 10; private TableLayout mTableLayout; + private TextView mHostnameTitle; private TextView mDataUsedTitle; private TextView mDataSavedTitle; private List<DataReductionDataUseItem> mDataUseItems; @@ -52,14 +53,29 @@ protected void onFinishInflate() { super.onFinishInflate(); mTableLayout = (TableLayout) findViewById(R.id.data_reduction_proxy_breakdown_table); + mHostnameTitle = (TextView) findViewById(R.id.data_reduction_breakdown_site_title); mDataUsedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_used_title); mDataSavedTitle = (TextView) findViewById(R.id.data_reduction_breakdown_saved_title); + mHostnameTitle.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + DataReductionProxyUma.dataReductionProxyUIAction( + DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_HOSTNAME); + setTextViewUnsortedAttributes(mDataSavedTitle); + setTextViewUnsortedAttributes(mDataUsedTitle); + setTextViewSortedAttributes(mHostnameTitle); + Collections.sort(mDataUseItems, new HostnameComparator()); + updateSiteBreakdown(); + } + }); + mDataUsedTitle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DataReductionProxyUma.dataReductionProxyUIAction( DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_USED); + setTextViewUnsortedAttributes(mHostnameTitle); setTextViewUnsortedAttributes(mDataSavedTitle); setTextViewSortedAttributes(mDataUsedTitle); Collections.sort(mDataUseItems, new DataUsedComparator()); @@ -72,6 +88,7 @@ public void onClick(View v) { DataReductionProxyUma.dataReductionProxyUIAction( DataReductionProxyUma.ACTION_SITE_BREAKDOWN_SORTED_BY_DATA_SAVED); + setTextViewUnsortedAttributes(mHostnameTitle); setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewSortedAttributes(mDataSavedTitle); Collections.sort(mDataUseItems, new DataSavedComparator()); @@ -85,6 +102,7 @@ super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (mTextViewsNeedAttributesSet) { mTextViewsNeedAttributesSet = false; + setTextViewUnsortedAttributes(mHostnameTitle); setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewSortedAttributes(mDataSavedTitle); } @@ -96,6 +114,7 @@ */ public void setAndDisplayDataUseItems(List<DataReductionDataUseItem> items) { mDataUseItems = items; + setTextViewUnsortedAttributes(mHostnameTitle); setTextViewUnsortedAttributes(mDataUsedTitle); setTextViewSortedAttributes(mDataSavedTitle); Collections.sort(mDataUseItems, new DataSavedComparator()); @@ -148,6 +167,23 @@ } /** + * Sorts the DataReductionDataUseItems by hostname. + */ + private static final class HostnameComparator + implements Comparator<DataReductionDataUseItem>, Serializable { + @Override + public int compare(DataReductionDataUseItem lhs, DataReductionDataUseItem rhs) { + // Force the 'Other' category to the bottom of the list. + if (OTHER_HOST_NAME.equals(lhs.getHostname())) { + return 1; + } else if (OTHER_HOST_NAME.equals(rhs.getHostname())) { + return -1; + } + return lhs.getHostname().compareTo(rhs.getHostname()); + } + } + + /** * Sorts the DataReductionDataUseItems by most to least data used. */ private static final class DataUsedComparator @@ -220,8 +256,18 @@ R.string.data_reduction_breakdown_other_host_name); } hostnameView.setText(hostName); - dataUsedView.setText(mDataUseItems.get(i).getFormattedDataUsed(getContext())); - dataSavedView.setText(mDataUseItems.get(i).getFormattedDataSaved(getContext())); + + final CharSequence dataUsed = + mDataUseItems.get(i).getFormattedDataUsed(getContext()); + dataUsedView.setText(dataUsed); + dataUsedView.setContentDescription(getResources().getString( + R.string.data_reduction_breakdown_used_content_description, dataUsed)); + + final CharSequence dataSaved = + mDataUseItems.get(i).getFormattedDataSaved(getContext()); + dataSavedView.setText(dataSaved); + dataSavedView.setContentDescription(getResources().getString( + R.string.data_reduction_breakdown_saved_content_description, dataSaved)); mTableLayout.addView(row, i + 1); } else {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java index fa81070..fd6ae2a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionStatsPreference.java
@@ -155,9 +155,14 @@ } private void setDetailText() { + final Context context = getContext(); updateDetailData(); mStartDateTextView.setText(mStartDatePhrase); + mStartDateTextView.setContentDescription(context.getString( + R.string.data_reduction_start_date_content_description, mStartDatePhrase)); mEndDateTextView.setText(mEndDatePhrase); + mEndDateTextView.setContentDescription(context.getString( + R.string.data_reduction_end_date_content_description, mEndDatePhrase)); if (mDataUsageTextView != null) mDataUsageTextView.setText(mReceivedTotalPhrase); if (mDataSavingsTextView != null) mDataSavingsTextView.setText(mSavingsTotalPhrase); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreference.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreference.java index 58a99cb5..c48f862 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreference.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreference.java
@@ -6,12 +6,16 @@ import android.content.Context; import android.preference.DialogPreference; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.style.StyleSpan; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.ListView; import org.chromium.chrome.R; +import org.chromium.chrome.browser.download.DirectoryOption; /** * The preference used to save the download directory in download settings page. @@ -35,6 +39,22 @@ mAdapter = new DownloadLocationPreferenceAdapter(context, this); } + /** + * Updates the summary that shows the download location directory. + */ + public void updateSummary() { + DirectoryOption directoryOption = + (DirectoryOption) mAdapter.getItem(mAdapter.getSelectedItemId()); + final SpannableStringBuilder summaryBuilder = new SpannableStringBuilder(); + summaryBuilder.append(directoryOption.name); + summaryBuilder.append(" "); + summaryBuilder.append(directoryOption.location.getAbsolutePath()); + summaryBuilder.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, + directoryOption.name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + + setSummary(summaryBuilder); + } + @Override protected View onCreateDialogView() { View view = LayoutInflater.from(getContext())
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreferenceAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreferenceAdapter.java index 9156ea4e..0760d20 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreferenceAdapter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadLocationPreferenceAdapter.java
@@ -101,10 +101,12 @@ editor.putString( DownloadPreferences.PREF_LOCATION_CHANGE, option.location.getAbsolutePath()); editor.apply(); - mPreference.setSummary(option.location.getAbsolutePath()); mSelectedPosition = selectedId; + // Update the preference after selected position is updated. + mPreference.updateSummary(); + option.recordDirectoryOptionType(); // Refresh the list of download directories UI.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadPreferences.java index c75d62d..0b046ca 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadPreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/download/DownloadPreferences.java
@@ -50,8 +50,7 @@ private void updateData() { if (mLocationChangePref != null) { - mLocationChangePref.setSummary( - PrefServiceBridge.getInstance().getDownloadDefaultDirectory()); + mLocationChangePref.updateSummary(); } if (mLocationPromptEnabledPref != null) {
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 06c13c1..2dd6b0c 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
@@ -67,6 +67,12 @@ onError(AuthenticatorStatus.NOT_IMPLEMENTED); } + @Override + public void isUserVerifyingPlatformAuthenticatorAvailable( + IsUserVerifyingPlatformAuthenticatorAvailableResponse callback) { + callback.call(false); + } + /** * Callbacks for receiving responses from the internal handlers. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/ThumbnailProviderImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/ThumbnailProviderImpl.java index a33c97d..c7aa05c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/widget/ThumbnailProviderImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/ThumbnailProviderImpl.java
@@ -5,36 +5,22 @@ package org.chromium.chrome.browser.widget; import android.graphics.Bitmap; -import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.util.LruCache; import android.text.TextUtils; -import android.util.Pair; import org.chromium.base.DiscardableReferencePool; -import org.chromium.base.SysUtils; import org.chromium.base.ThreadUtils; +import org.chromium.chrome.browser.BitmapCache; -import java.lang.ref.WeakReference; import java.util.ArrayDeque; import java.util.Deque; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; +import java.util.Locale; /** * Concrete implementation of {@link ThumbnailProvider}. * - * Thumbnails are cached in memory and shared across all ThumbnailProviderImpls. There are two - * levels of caches: One static cache for deduplication (or canonicalization) of bitmaps, and one - * per-object cache for storing recently used bitmaps. The deduplication cache uses weak references - * to allow bitmaps to be garbage-collected once they are no longer in use. As long as there is at - * least one strong reference to a bitmap, it is not going to be GC'd and will therefore stay in the - * cache. This ensures that there is never more than one (reachable) copy of a bitmap in memory. - * The {@link RecentlyUsedCache} is limited in size and dropped under memory pressure, or when the - * object is destroyed. - * + * Thumbnails are cached in {@link BitmapCache}. * A queue of requests is maintained in FIFO order. * * TODO(dfalcantara): Figure out how to send requests simultaneously to the utility process without @@ -44,55 +30,11 @@ /** 5 MB of thumbnails should be enough for everyone. */ private static final int MAX_CACHE_BYTES = 5 * 1024 * 1024; - /** - * Least-recently-used cache that falls back to the deduplication cache on misses. - * This propagates bitmaps that were only in the deduplication cache back into the LRU cache - * and also moves them to the front to ensure correct eviction order. - * Cache key is a pair of the filepath and the height/width of the thumbnail. Value is - * the thumbnail. - */ - private static class RecentlyUsedCache extends LruCache<Pair<String, Integer>, Bitmap> { - private RecentlyUsedCache() { - super(MAX_CACHE_BYTES); - } - - @Override - protected Bitmap create(Pair<String, Integer> key) { - WeakReference<Bitmap> cachedBitmap = sDeduplicationCache.get(key); - return cachedBitmap == null ? null : cachedBitmap.get(); - } - - @Override - protected int sizeOf(Pair<String, Integer> key, Bitmap thumbnail) { - return thumbnail.getByteCount(); - } - } - - /** - * Discardable reference to the {@link RecentlyUsedCache} that can be dropped under memory - * pressure. - */ - private DiscardableReferencePool.DiscardableReference<RecentlyUsedCache> mBitmapCache; - - /** - * The reference pool that contains the {@link #mBitmapCache}. Used to recreate a new cache - * after the old one has been dropped. - */ - private final DiscardableReferencePool mReferencePool; - - /** - * Static cache used for deduplicating bitmaps. The key is a pair of file name and thumbnail - * size (as for the {@link #mBitmapCache}. - */ - private static Map<Pair<String, Integer>, WeakReference<Bitmap>> sDeduplicationCache = - new HashMap<>(); + private BitmapCache mBitmapCache; /** Queue of files to retrieve thumbnails for. */ private final Deque<ThumbnailRequest> mRequestQueue = new ArrayDeque<>(); - /** The native side pointer that is owned and destroyed by the Java class. */ - private long mNativeThumbnailProvider; - /** Request that is currently having its thumbnail retrieved. */ private ThumbnailRequest mCurrentRequest; @@ -100,8 +42,7 @@ public ThumbnailProviderImpl(DiscardableReferencePool referencePool) { ThreadUtils.assertOnUiThread(); - mReferencePool = referencePool; - mBitmapCache = referencePool.put(new RecentlyUsedCache()); + mBitmapCache = new BitmapCache(referencePool, MAX_CACHE_BYTES); mStorage = ThumbnailDiskStorage.create(this); } @@ -156,17 +97,13 @@ ThreadUtils.postOnUiThread(this::processNextRequest); } - private RecentlyUsedCache getBitmapCache() { - RecentlyUsedCache bitmapCache = mBitmapCache.get(); - if (bitmapCache == null) { - bitmapCache = new RecentlyUsedCache(); - mBitmapCache = mReferencePool.put(bitmapCache); - } - return bitmapCache; + private String getKey(String contentId, int bitmapSizePx) { + return String.format(Locale.US, "id=%s, size=%d", contentId, bitmapSizePx); } private Bitmap getBitmapFromCache(String contentId, int bitmapSizePx) { - Bitmap cachedBitmap = getBitmapCache().get(Pair.create(contentId, bitmapSizePx)); + String key = getKey(contentId, bitmapSizePx); + Bitmap cachedBitmap = mBitmapCache.getBitmap(key); assert cachedBitmap == null || !cachedBitmap.isRecycled(); return cachedBitmap; } @@ -174,14 +111,7 @@ private void processNextRequest() { ThreadUtils.assertOnUiThread(); if (mCurrentRequest != null) return; - if (mRequestQueue.isEmpty()) { - // If the request queue is empty, schedule compaction for when the main loop is idling. - Looper.myQueue().addIdleHandler(() -> { - compactDeduplicationCache(); - return false; - }); - return; - } + if (mRequestQueue.isEmpty()) return; mCurrentRequest = mRequestQueue.poll(); @@ -217,7 +147,7 @@ /** * Called when thumbnail is ready, retrieved from memory cache or by - * {@link ThumbnailDiskStorage} or by {@link ThumbnailRequest#getThumbnail()}. + * {@link ThumbnailDiskStorage} or by {@link ThumbnailRequest#getThumbnail}. * @param contentId Content ID for the thumbnail retrieved. * @param bitmap The thumbnail retrieved. */ @@ -234,29 +164,12 @@ // We set the key pair to contain the required size (maximum dimension (pixel) of the // smaller side) instead of the minimal dimension of the thumbnail so that future // fetches of this thumbnail can recognise the key in the cache. - Pair<String, Integer> key = Pair.create(contentId, mCurrentRequest.getIconSize()); - if (!SysUtils.isLowEndDevice()) { - getBitmapCache().put(key, bitmap); - } - sDeduplicationCache.put(key, new WeakReference<>(bitmap)); + String key = getKey(contentId, mCurrentRequest.getIconSize()); + mBitmapCache.putBitmap(key, bitmap); mCurrentRequest.onThumbnailRetrieved(contentId, bitmap); } mCurrentRequest = null; processQueue(); } - - /** - * Compacts the deduplication cache by removing all entries that have been cleared by the - * garbage collector. - */ - private void compactDeduplicationCache() { - // Too many angle brackets for clang-format :-( - // clang-format off - for (Iterator<Map.Entry<Pair<String, Integer>, WeakReference<Bitmap>>> it = - sDeduplicationCache.entrySet().iterator(); it.hasNext();) { - // clang-format on - if (it.next().getValue().get() == null) it.remove(); - } - } }
diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd index 91310db..7f5f733 100644 --- a/chrome/android/java/strings/android_chrome_strings.grd +++ b/chrome/android/java/strings/android_chrome_strings.grd
@@ -1129,15 +1129,36 @@ <message name="IDS_DATA_REDUCTION_USAGE_LABEL" desc="Data Reduction statistics label that states the amount of data that was used by Chrome when Data Saver is enabled."> data used </message> + <message name="IDS_DATA_REDUCTION_START_DATE_CONTENT_DESCRIPTION" desc="This label is used in the device screen reader to describe the starting date that data savings are computed from. This will always be used in the form 'Start date: February 28'."> + Start date <ph name="date">%1$s<ex>Feb 28</ex></ph> + </message> + <message name="IDS_DATA_REDUCTION_END_DATE_CONTENT_DESCRIPTION" desc="This label is used in the device screen reader to describe the end date that data savings are computed until. This will always be used in the form 'End date: February 28'.."> + End date <ph name="date">%1$s<ex>Feb 28</ex></ph> + </message> <message name="IDS_DATA_REDUCTION_BREAKDOWN_SITE_TITLE" desc="Title for the sites column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved."> Site </message> + <message name="IDS_DATA_REDUCTION_BREAKDOWN_SITE_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted by website domain name. This is used in the device's screen reader and is not displayed visually to the user."> + Sort by site + </message> <message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_TITLE" desc="Title for the data used column on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved."> Used </message> + <message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted descending by the amount of mobile data that was used when viewing a webpage. This is used in the device's screen reader and is not displayed visually to the user."> + Sort by amount of data used + </message> <message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_TITLE" desc="Title for the data saved column on the Data Reduction statistics page. The breakdown lists for the top ten sites with the greatest amount of data usage or mobile data that was saved. Data Saver allows users to to reduce their mobile data usage by compressing network traffic."> Saved </message> + <message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_HEADER_CONTENT_DESCRIPTION" desc="This label is used to state that by clicking the associated button, the displayed table will be sorted descending by the amount of mobile data that was saved when viewing a webpage by using Chrome's Data Saver feature. This is used in the device's screen reader and is not displayed visually to the user."> + Sort by amount of data saved + </message> + <message name="IDS_DATA_REDUCTION_BREAKDOWN_USED_CONTENT_DESCRIPTION" desc="This label is used as a suffix to describe the amount of mobile data that was used to view a webpage. It is used in the form '0 bytes used'."> + <ph name="amount">%1$s<ex>0 bytes</ex></ph> used + </message> + <message name="IDS_DATA_REDUCTION_BREAKDOWN_SAVED_CONTENT_DESCRIPTION" desc="This label is used as a suffix to describe the amount of mobile data that was saved when viewing a webpage by using Chrome's Data Saver feature. It is used in the form '0 bytes used'."> + <ph name="amount">%1$s<ex>0 bytes</ex></ph> saved + </message> <message name="IDS_DATA_REDUCTION_BREAKDOWN_REMAINING_SITES_LABEL" desc="Title for the the remaining sites on the Data Reduction statistics page. The breakdown lists the top ten sites with the greatest amount of data usage or mobile data that was saved and then groups the remaining sites together."> Remaining sites (<ph name="NUMBER_OF_SITES">%1$d<ex>35</ex></ph>) </message>
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index bb6829aa..77ab0b3 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni
@@ -19,6 +19,7 @@ "java/src/org/chromium/chrome/browser/AssistStatusHandler.java", "java/src/org/chromium/chrome/browser/BackgroundSyncLauncher.java", "java/src/org/chromium/chrome/browser/BasicNativePage.java", + "java/src/org/chromium/chrome/browser/BitmapCache.java", "java/src/org/chromium/chrome/browser/BluetoothChooserDialog.java", "java/src/org/chromium/chrome/browser/BrowserRestartActivity.java", "java/src/org/chromium/chrome/browser/ChromeActionModeCallback.java",
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webauth/AuthenticatorTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webauth/AuthenticatorTest.java index 0a6f0f2..24da6652 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webauth/AuthenticatorTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webauth/AuthenticatorTest.java
@@ -104,7 +104,7 @@ /** * Verify that the Mojo bridge between Blink and Java is working for - * navigator.credentials.create. This test currently expects a + * navigator.credentials.get. This test currently expects a * "Not Implemented" response. Testing any real response would require * setting up or mocking a real APK. */ @@ -116,4 +116,19 @@ mActivityTestRule.runJavaScriptCodeInCurrentTab("doGetPublicKeyCredential()"); Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate()); } + + /** + * Verify that the Mojo bridge between Blink and Java is working for + * PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable. + * This test currently expects a "false" response. + */ + @Test + @MediumTest + @Feature({"WebAuth"}) + public void testIsUserVerifyingPlatformAuthenticatorAvailable() throws Exception { + mActivityTestRule.loadUrl(mUrl); + mActivityTestRule.runJavaScriptCodeInCurrentTab( + "doIsUserVerifyingPlatformAuthenticatorAvailable()"); + Assert.assertEquals("Success", mUpdateWaiter.waitForUpdate()); + } }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelperTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelperTest.java index fa3c86414..986abc5 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelperTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/contextual_suggestions/FetchHelperTest.java
@@ -418,6 +418,32 @@ verify(mDelegate, times(1)).requestSuggestions(DIFFERENT_URL); } + @Test + public void canonicalUrl_readinessStateIsNull() { + doReturn(true).when(mTab).isLoading(); + + FetchHelper helper = createFetchHelper(); + + doReturn(mFrameHost).when(mWebContents).getMainFrame(); + doAnswer(new Answer<Void>() { + @Override + public Void answer(InvocationOnMock invocation) { + if (invocation.getArguments()[0] instanceof Callback) { + closeTab(mTab); + @SuppressWarnings("unchecked") + Callback<String> callback = (Callback<String>) invocation.getArguments()[0]; + callback.onResult(DIFFERENT_URL); + } + return null; + } + }) + .when(mFrameHost) + .getCanonicalUrlForSharing(any()); + getTabObserver().onPageLoadFinished(mTab); + runUntilFetchPossible(); + verify(mDelegate, times(0)).requestSuggestions(DIFFERENT_URL); + } + private void addTab(Tab tab) { getTabModelObserver().didAddTab(tab, TabLaunchType.FROM_LINK); }
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 75e3062..e5d4da2 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd
@@ -1240,7 +1240,7 @@ <!-- Chroium launch blocking dialog. --> <if expr="not is_android and not chromeos"> <message name="IDS_ENTERPRISE_STARTUP_CLOUD_POLICY_ENROLLMENT_TOOLTIP" desc="The information message of Chromium launch blocking dialog for machine level user cloud policy enrollment."> - Launching Chromium + Launching Chromium... </message> <message name="IDS_ENTERPRISE_STARTUP_CLOUD_POLICY_ENROLLMENT_ERROR" desc="The error message of Chromium launch blocking dialog when machine level user cloud policy enrollment failed."> Couldn't launch Chromium. Try again.
diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index 804eed7..679e0e3 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd
@@ -1259,7 +1259,7 @@ <!-- Chrome launch blocking dialog. --> <if expr="not is_android and not chromeos"> <message name="IDS_ENTERPRISE_STARTUP_CLOUD_POLICY_ENROLLMENT_TOOLTIP" desc="The information message of Chrome launch blocking dialog for machine level user cloud policy enrollment."> - Launching Chrome + Launching Chrome... </message> <message name="IDS_ENTERPRISE_STARTUP_CLOUD_POLICY_ENROLLMENT_ERROR" desc="The error message of Chrome launch blocking dialog when machine level user cloud policy enrollment failed."> Couldn't launch Chrome. Try again.
diff --git a/chrome/app/media_router_strings.grdp b/chrome/app/media_router_strings.grdp index 64c474bc..7d9040a 100644 --- a/chrome/app/media_router_strings.grdp +++ b/chrome/app/media_router_strings.grdp
@@ -195,6 +195,12 @@ <message name="IDS_MEDIA_ROUTER_DESTINATION_MISSING" desc="Link to display when no Cast destinations are found which, on click, opens a page to the Chromecast help center explaining possible reasons why none are detected."> No Cast destinations found. Need help? </message> + <message name="IDS_MEDIA_ROUTER_SINK_AVAILABLE" desc="Text shown as the status of a Cast destination that the user can Cast to."> + Available + </message> + <message name="IDS_MEDIA_ROUTER_SINK_CONNECTING" desc="Text shown as the status of a Cast destination that we are starting a Cast session on."> + Connecting... + </message> <!-- Sink Search --> <message name="IDS_MEDIA_ROUTER_SEARCH_LABEL" desc="Label for search input in sink list.">
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 0555ebb..9cc01fd2 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -1624,6 +1624,7 @@ "//chrome/browser/metrics/variations:chrome_ui_string_overrider_factory", "//chrome/browser/net:probe_message_proto", "//chrome/browser/profiling_host", + "//chrome/browser/resource_coordinator:mojo_bindings", "//chrome/browser/safe_browsing", "//chrome/browser/ssl:proto", "//chrome/browser/ui", @@ -4239,6 +4240,8 @@ "android/feed/feed_image_loader_bridge.h", "android/feed/feed_network_bridge.cc", "android/feed/feed_network_bridge.h", + "android/feed/feed_scheduler_bridge.cc", + "android/feed/feed_scheduler_bridge.h", ] deps += [ "//components/feed/core:feed_core" ] } @@ -4495,6 +4498,7 @@ sources += [ "../android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedImageLoaderBridge.java", "../android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedNetworkBridge.java", + "../android/feed/core/java/src/org/chromium/chrome/browser/feed/FeedSchedulerBridge.java", ] }
diff --git a/chrome/browser/android/download/download_manager_service.cc b/chrome/browser/android/download/download_manager_service.cc index a8f20f8..a3889c0 100644 --- a/chrome/browser/android/download/download_manager_service.cc +++ b/chrome/browser/android/download/download_manager_service.cc
@@ -15,12 +15,14 @@ #include "base/time/time.h" #include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/download/download_controller.h" +#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/download/download_core_service.h" #include "chrome/browser/download/download_core_service_factory.h" #include "chrome/browser/profiles/profile_manager.h" #include "components/download/public/common/download_item.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/download_item_utils.h" +#include "content/public/browser/notification_service.h" #include "jni/DownloadInfo_jni.h" #include "jni/DownloadItem_jni.h" #include "jni/DownloadManagerService_jni.h" @@ -137,6 +139,8 @@ DownloadManagerService::DownloadManagerService() : is_history_query_complete_(false), pending_get_downloads_actions_(NONE) { + registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, + content::NotificationService::AllSources()); } DownloadManagerService::~DownloadManagerService() {} @@ -147,6 +151,32 @@ java_ref_.Reset(env, obj); } +void DownloadManagerService::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + switch (type) { + case chrome::NOTIFICATION_PROFILE_CREATED: { + Profile* profile = content::Source<Profile>(source).ptr(); + content::DownloadManager* manager = + content::BrowserContext::GetDownloadManager(profile); + if (!manager) + break; + + auto& notifier = profile->IsOffTheRecord() ? off_the_record_notifier_ + : original_notifier_; + + // Update notifiers to monitor any newly created DownloadManagers. + if (!notifier || notifier->GetManager() != manager) { + notifier = + std::make_unique<download::AllDownloadItemNotifier>(manager, this); + } + } break; + default: + NOTREACHED(); + } +} + void DownloadManagerService::OpenDownload( JNIEnv* env, jobject obj,
diff --git a/chrome/browser/android/download/download_manager_service.h b/chrome/browser/android/download/download_manager_service.h index 9d05d01..d8da9c16 100644 --- a/chrome/browser/android/download/download_manager_service.h +++ b/chrome/browser/android/download/download_manager_service.h
@@ -17,6 +17,8 @@ #include "chrome/browser/download/download_history.h" #include "components/download/content/public/all_download_item_notifier.h" #include "content/public/browser/download_manager.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" using base::android::JavaParamRef; @@ -28,7 +30,8 @@ // Java object. class DownloadManagerService : public download::AllDownloadItemNotifier::Observer, - public DownloadHistory::Observer { + public DownloadHistory::Observer, + public content::NotificationObserver { public: static void OnDownloadCanceled( download::DownloadItem* download, @@ -115,6 +118,11 @@ void OnDownloadRemoved(content::DownloadManager* manager, download::DownloadItem* item) override; + // content::NotificationObserver methods. + void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) override; + protected: // Called to get the content::DownloadManager instance. virtual content::DownloadManager* GetDownloadManager(bool is_off_the_record); @@ -180,6 +188,9 @@ ResumeCallback resume_callback_for_testing_; + // The Registrar used to register for notifications. + content::NotificationRegistrar registrar_; + std::unique_ptr<download::AllDownloadItemNotifier> original_notifier_; std::unique_ptr<download::AllDownloadItemNotifier> off_the_record_notifier_;
diff --git a/chrome/browser/android/feed/feed_host_service_factory.cc b/chrome/browser/android/feed/feed_host_service_factory.cc index 299d22f..7c05483 100644 --- a/chrome/browser/android/feed/feed_host_service_factory.cc +++ b/chrome/browser/android/feed/feed_host_service_factory.cc
@@ -14,6 +14,9 @@ #include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/common/channel_info.h" #include "components/feed/core/feed_host_service.h" +#include "components/feed/core/feed_image_manager.h" +#include "components/feed/core/feed_networking_host.h" +#include "components/feed/core/feed_scheduler_host.h" #include "components/image_fetcher/core/image_fetcher_impl.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/version_info/version_info.h" @@ -79,8 +82,11 @@ auto image_manager = std::make_unique<FeedImageManager>( std::move(image_fetcher), std::move(image_database)); + auto scheduler_host = std::make_unique<FeedSchedulerHost>(); + return new FeedHostService(std::move(image_manager), - std::move(networking_host)); + std::move(networking_host), + std::move(scheduler_host)); } content::BrowserContext* FeedHostServiceFactory::GetBrowserContextToUse(
diff --git a/chrome/browser/android/feed/feed_network_bridge.cc b/chrome/browser/android/feed/feed_network_bridge.cc index dc5c3ec..61f6086 100644 --- a/chrome/browser/android/feed/feed_network_bridge.cc +++ b/chrome/browser/android/feed/feed_network_bridge.cc
@@ -4,8 +4,6 @@ #include "chrome/browser/android/feed/feed_network_bridge.h" -#include <jni.h> - #include <utility> #include <vector>
diff --git a/chrome/browser/android/feed/feed_network_bridge.h b/chrome/browser/android/feed/feed_network_bridge.h index 644b851..44080b9 100644 --- a/chrome/browser/android/feed/feed_network_bridge.h +++ b/chrome/browser/android/feed/feed_network_bridge.h
@@ -5,7 +5,10 @@ #ifndef CHROME_BROWSER_ANDROID_FEED_FEED_NETWORK_BRIDGE_H_ #define CHROME_BROWSER_ANDROID_FEED_FEED_NETWORK_BRIDGE_H_ +#include <jni.h> + #include "base/android/scoped_java_ref.h" +#include "base/macros.h" namespace feed {
diff --git a/chrome/browser/android/feed/feed_scheduler_bridge.cc b/chrome/browser/android/feed/feed_scheduler_bridge.cc new file mode 100644 index 0000000..90301f7c --- /dev/null +++ b/chrome/browser/android/feed/feed_scheduler_bridge.cc
@@ -0,0 +1,77 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/android/feed/feed_scheduler_bridge.h" + +#include "base/android/jni_android.h" +#include "base/bind.h" +#include "base/time/time.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/core/feed_host_service.h" +#include "components/feed/core/feed_scheduler_host.h" +#include "jni/FeedSchedulerBridge_jni.h" + +using base::android::JavaRef; +using base::android::JavaParamRef; +using base::android::ScopedJavaGlobalRef; + +namespace feed { + +static jlong JNI_FeedSchedulerBridge_Init( + JNIEnv* env, + const JavaParamRef<jobject>& j_this, + const JavaParamRef<jobject>& j_profile) { + Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); + FeedHostService* host_service = + FeedHostServiceFactory::GetForBrowserContext(profile); + return reinterpret_cast<intptr_t>( + new FeedSchedulerBridge(j_this, host_service->GetSchedulerHost())); +} + +FeedSchedulerBridge::FeedSchedulerBridge(const JavaRef<jobject>& j_this, + FeedSchedulerHost* scheduler_host) + : j_this_(ScopedJavaGlobalRef<jobject>(j_this)), + scheduler_host_(scheduler_host), + weak_factory_(this) { + DCHECK(scheduler_host_); + scheduler_host_->RegisterTriggerRefreshCallback(base::BindRepeating( + &FeedSchedulerBridge::TriggerRefresh, weak_factory_.GetWeakPtr())); +} + +FeedSchedulerBridge::~FeedSchedulerBridge() {} + +void FeedSchedulerBridge::Destroy(JNIEnv* env, const JavaRef<jobject>& j_this) { + delete this; +} + +jint FeedSchedulerBridge::ShouldSessionRequestData( + JNIEnv* env, + const JavaRef<jobject>& j_this, + const jboolean j_has_content, + const jlong j_content_creation_date_time_ms, + const jboolean j_has_outstanding_request) { + return static_cast<int>(scheduler_host_->ShouldSessionRequestData( + j_has_content, base::Time::FromJavaTime(j_content_creation_date_time_ms), + j_has_outstanding_request)); +} + +void FeedSchedulerBridge::OnReceiveNewContent(JNIEnv* env, + const JavaRef<jobject>& j_this) { + scheduler_host_->OnReceiveNewContent(); +} + +void FeedSchedulerBridge::OnRequestError(JNIEnv* env, + const JavaRef<jobject>& j_this, + const jint j_network_response_code) { + scheduler_host_->OnRequestError(j_network_response_code); +} + +void FeedSchedulerBridge::TriggerRefresh() { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_FeedSchedulerBridge_triggerRefresh(env, j_this_); +} + +} // namespace feed
diff --git a/chrome/browser/android/feed/feed_scheduler_bridge.h b/chrome/browser/android/feed/feed_scheduler_bridge.h new file mode 100644 index 0000000..b813898 --- /dev/null +++ b/chrome/browser/android/feed/feed_scheduler_bridge.h
@@ -0,0 +1,60 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ANDROID_FEED_FEED_SCHEDULER_BRIDGE_H_ +#define CHROME_BROWSER_ANDROID_FEED_FEED_SCHEDULER_BRIDGE_H_ + +#include <jni.h> + +#include "base/android/scoped_java_ref.h" +#include "base/macros.h" +#include "base/memory/weak_ptr.h" + +namespace feed { + +class FeedSchedulerHost; + +// Native counterpart of FeedSchedulerBridge.java. Holds non-owning pointers to +// native implementation, to which operations are delegated. Also capable of +// calling back into Java half. +class FeedSchedulerBridge { + public: + FeedSchedulerBridge(const base::android::JavaRef<jobject>& j_this, + FeedSchedulerHost* scheduler_host); + ~FeedSchedulerBridge(); + + void Destroy(JNIEnv* env, const base::android::JavaRef<jobject>& j_this); + + jint ShouldSessionRequestData(JNIEnv* env, + const base::android::JavaRef<jobject>& j_this, + const jboolean j_has_content, + const jlong j_content_creation_date_time_ms, + const jboolean j_has_outstanding_request); + + void OnReceiveNewContent(JNIEnv* env, + const base::android::JavaRef<jobject>& j_this); + + void OnRequestError(JNIEnv* env, + const base::android::JavaRef<jobject>& j_this, + jint j_network_response_code); + + // Callable by native code to invoke Java code. Sends a request to the Feed + // library to make the refresh call. + void TriggerRefresh(); + + private: + // Reference to the Java half of this bridge. Always valid. + base::android::ScopedJavaGlobalRef<jobject> j_this_; + + // Object to which all Java to native calls are delegated. + FeedSchedulerHost* scheduler_host_; + + base::WeakPtrFactory<FeedSchedulerBridge> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(FeedSchedulerBridge); +}; + +} // namespace feed + +#endif // CHROME_BROWSER_ANDROID_FEED_FEED_SCHEDULER_BRIDGE_H_
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index dab990a..b22e03e 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -50,6 +50,8 @@ #include "components/guest_view/browser/guest_view_manager_delegate.h" #include "components/guest_view/browser/guest_view_manager_factory.h" #include "components/guest_view/browser/test_guest_view_manager.h" +#include "components/version_info/channel.h" +#include "components/version_info/version_info.h" #include "components/viz/common/features.h" #include "content/public/browser/ax_event_notification_details.h" #include "content/public/browser/browser_thread.h" @@ -84,6 +86,7 @@ #include "extensions/browser/guest_view/web_view/web_view_guest.h" #include "extensions/common/extension.h" #include "extensions/common/extensions_client.h" +#include "extensions/common/features/feature_channel.h" #include "extensions/test/extension_test_message_listener.h" #include "media/base/media_switches.h" #include "net/dns/mock_host_resolver.h" @@ -3319,12 +3322,29 @@ TestHelper("testZoomBeforeNavigation", "web_view/shim", NO_TEST_SERVER); } +// Test fixture to run the test on multiple channels. +class WebViewChannelTest + : public WebViewTest, + public testing::WithParamInterface<version_info::Channel> { + public: + WebViewChannelTest() : channel_(GetParam()) {} + + private: + extensions::ScopedCurrentChannel channel_; + DISALLOW_COPY_AND_ASSIGN(WebViewChannelTest); +}; + // This test verify that the set of rules registries of a webview will be // removed from RulesRegistryService after the webview is gone. // http://crbug.com/438327 -IN_PROC_BROWSER_TEST_F( - WebViewTest, +IN_PROC_BROWSER_TEST_P( + WebViewChannelTest, DISABLED_Shim_TestRulesRegistryIDAreRemovedAfterWebViewIsGone) { + ASSERT_EQ(extensions::GetCurrentChannel(), GetParam()); + SCOPED_TRACE( + base::StringPrintf("Testing Channel %s", + version_info::GetChannelString(GetParam()).c_str())); + LoadAppWithGuest("web_view/rules_registry"); content::WebContents* embedder_web_contents = GetEmbedderWebContents(); @@ -3348,12 +3368,12 @@ extensions::RulesRegistryService* registry_service = extensions::RulesRegistryService::Get(profile); extensions::TestRulesRegistry* rules_registry = - new extensions::TestRulesRegistry( - content::BrowserThread::UI, "ui", rules_registry_id); + new extensions::TestRulesRegistry(content::BrowserThread::UI, "ui", + rules_registry_id); registry_service->RegisterRulesRegistry(base::WrapRefCounted(rules_registry)); - EXPECT_TRUE(registry_service->GetRulesRegistry( - rules_registry_id, "ui").get()); + EXPECT_TRUE( + registry_service->GetRulesRegistry(rules_registry_id, "ui").get()); // Kill the embedder's render process, so the webview will go as well. base::Process process = base::Process::DeprecatedGetProcessFromHandle( @@ -3364,12 +3384,17 @@ process.Terminate(0, false); observer->WaitForEmbedderRenderProcessTerminate(); - EXPECT_FALSE(registry_service->GetRulesRegistry( - rules_registry_id, "ui").get()); + EXPECT_FALSE( + registry_service->GetRulesRegistry(rules_registry_id, "ui").get()); } -IN_PROC_BROWSER_TEST_F(WebViewTest, +IN_PROC_BROWSER_TEST_P(WebViewChannelTest, Shim_WebViewWebRequestRegistryHasNoPersistentCache) { + ASSERT_EQ(extensions::GetCurrentChannel(), GetParam()); + SCOPED_TRACE( + base::StringPrintf("Testing Channel %s", + version_info::GetChannelString(GetParam()).c_str())); + LoadAppWithGuest("web_view/rules_registry"); content::WebContents* guest_web_contents = GetGuestWebContents(); @@ -3388,9 +3413,11 @@ // Get an existing registered rule for the guest. extensions::RulesRegistry* registry = - registry_service->GetRulesRegistry( - rules_registry_id, - extensions::declarative_webrequest_constants::kOnRequest).get(); + registry_service + ->GetRulesRegistry( + rules_registry_id, + extensions::declarative_webrequest_constants::kOnRequest) + .get(); ASSERT_TRUE(registry); ASSERT_TRUE(registry->rules_cache_delegate_for_testing()); @@ -3398,6 +3425,11 @@ registry->rules_cache_delegate_for_testing()->type()); } +INSTANTIATE_TEST_CASE_P(, + WebViewChannelTest, + testing::Values(version_info::Channel::UNKNOWN, + version_info::Channel::STABLE)); + // This test verifies that webview.contentWindow works inside an iframe. IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebViewInsideFrame) { LoadAppWithGuest("web_view/inside_iframe");
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 2df7581..77f1e2df 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd
@@ -72,6 +72,7 @@ <include name="IDR_ABOUT_DISCARDS_HTML" file="resources\discards\discards.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_ABOUT_DISCARDS_JS" file="resources\discards\discards.js" type="BINDATA" /> <include name="IDR_ABOUT_DISCARDS_MOJO_JS" file="${root_gen_dir}\chrome\browser\ui\webui\discards\discards.mojom.js" use_base_dir="false" type="BINDATA" /> + <include name="IDR_ABOUT_DISCARDS_LIFECYCLE_UNIT_STATE_MOJO_JS" file="${root_gen_dir}\chrome\browser\resource_coordinator\lifecycle_unit_state.mojom.js" use_base_dir="false" type="BINDATA" /> </if> <if expr="is_win"> <include name="IDR_ABOUT_CONFLICTS_HTML" file="resources\about_conflicts.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc index b9c192f..3da067e 100644 --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.cc
@@ -206,14 +206,6 @@ predictor->DiscardAllResults(); } -void ClearHostnameResolutionCacheOnIOThread( - IOThread* io_thread, - base::RepeatingCallback<bool(const std::string&)> host_filter) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - io_thread->ClearHostCache(host_filter); -} - #if defined(OS_ANDROID) void ClearPrecacheInBackground(content::BrowserContext* browser_context) { // Precache code was removed in M61 but the sqlite database file could be @@ -436,17 +428,11 @@ // Need to clear the host cache and accumulated speculative data, as it also // reveals some history. We have no mechanism to track when these items were // created, so we'll not honor the time range. - // TODO(msramek): We can use the plugin filter here because plugins, same - // as the hostname resolution cache, key their entries by hostname. Rename - // BuildPluginFilter() to something more general to reflect this use. - if (g_browser_process->io_thread()) { - BrowserThread::PostTaskAndReply( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&ClearHostnameResolutionCacheOnIOThread, - g_browser_process->io_thread(), - filter_builder.BuildPluginFilter()), - CreatePendingTaskCompletionClosure()); - } + BrowserContext::GetDefaultStoragePartition(profile_) + ->GetNetworkContext() + ->ClearHostCache(filter_builder.BuildNetworkServiceFilter(), + CreatePendingTaskCompletionClosureForMojo()); + if (profile_->GetNetworkPredictor()) { // TODO(dmurph): Support all backends with filter (crbug.com/113621). BrowserThread::PostTaskAndReply(
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index d86bc2d..99badbc 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -4132,6 +4132,23 @@ #endif } +void ChromeContentBrowserClient::WillCreateWebSocket( + content::RenderFrameHost* frame, + network::mojom::WebSocketRequest* request) { +#if BUILDFLAG(ENABLE_EXTENSIONS) + auto* web_request_api = + extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get( + frame->GetProcess()->GetBrowserContext()); + + // NOTE: Some unit test environments do not initialize + // BrowserContextKeyedAPI factories for e.g. WebRequest. + if (!web_request_api) + return; + + web_request_api->MaybeProxyWebSocket(frame, request); +#endif +} + network::mojom::NetworkContextPtr ChromeContentBrowserClient::CreateNetworkContext( content::BrowserContext* context,
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index fa9fcb5..902246fa 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h
@@ -395,6 +395,8 @@ content::RenderFrameHost* frame, bool is_navigation, network::mojom::URLLoaderFactoryRequest* factory_request) override; + void WillCreateWebSocket(content::RenderFrameHost* frame, + network::mojom::WebSocketRequest* request) override; network::mojom::NetworkContextPtr CreateNetworkContext( content::BrowserContext* context, bool in_memory,
diff --git a/chrome/browser/chromeos/attestation/enrollment_policy_observer.cc b/chrome/browser/chromeos/attestation/enrollment_policy_observer.cc index 28ee796..6897f4d4 100644 --- a/chrome/browser/chromeos/attestation/enrollment_policy_observer.cc +++ b/chrome/browser/chromeos/attestation/enrollment_policy_observer.cc
@@ -187,10 +187,14 @@ void EnrollmentPolicyObserver::HandleEnrollmentId( const std::string& enrollment_id) { + if (enrollment_id.empty()) { + LOG(WARNING) << "EnrollmentPolicyObserver: The enrollment identifier" + " obtained is empty."; + } policy_client_->UploadEnterpriseEnrollmentId( enrollment_id, - base::Bind(&EnrollmentPolicyObserver::OnUploadComplete, - weak_factory_.GetWeakPtr(), "Enrollment Identifier")); + base::BindRepeating(&EnrollmentPolicyObserver::OnUploadComplete, + weak_factory_.GetWeakPtr(), "Enrollment Identifier")); } void EnrollmentPolicyObserver::RescheduleGetEnrollmentId() {
diff --git a/chrome/browser/chromeos/attestation/enrollment_policy_observer_unittest.cc b/chrome/browser/chromeos/attestation/enrollment_policy_observer_unittest.cc index 27db6bf..b7f6ae4 100644 --- a/chrome/browser/chromeos/attestation/enrollment_policy_observer_unittest.cc +++ b/chrome/browser/chromeos/attestation/enrollment_policy_observer_unittest.cc
@@ -11,6 +11,7 @@ #include "base/location.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" +#include "base/strings/string_number_conversions.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/chromeos/attestation/enrollment_policy_observer.h" #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" @@ -61,17 +62,18 @@ public: EnrollmentPolicyObserverTest() { policy_client_.SetDMToken("fake_dm_token"); + + std::vector<uint8_t> eid; + EXPECT_TRUE(base::HexStringToBytes(kEnrollmentId, &eid)); + enrollment_id_.assign(reinterpret_cast<const char*>(eid.data()), + eid.size()); + cryptohome_client_.set_tpm_attestation_enrollment_id( + true /* ignore_cache */, enrollment_id_); } protected: static constexpr char kEnrollmentId[] = - "6fcc0ebddec3db95cdcf82476d594f4d60db934c5b47fa6085c707b2a93e205b"; - - void SetUp() override { - DeviceSettingsTestBase::SetUp(); - cryptohome_client_.set_tpm_attestation_enrollment_id( - true /* ignore_cache */, kEnrollmentId); - } + "6fcc0ebddec3db9500cf82476d594f4d60db934c5b47fa6085c707b2a93e205b"; void SetUpEnrollmentIdNeeded(bool enrollment_id_needed) { if (enrollment_id_needed) { @@ -103,6 +105,7 @@ FakeCryptohomeClient cryptohome_client_; StrictMock<MockAttestationFlow> attestation_flow_; StrictMock<policy::MockCloudPolicyClient> policy_client_; + std::string enrollment_id_; }; constexpr char EnrollmentPolicyObserverTest::kEnrollmentId[]; @@ -132,7 +135,7 @@ TEST_F(EnrollmentPolicyObserverTest, GetCertificateBadRequestFailure) { EXPECT_CALL(attestation_flow_, GetCertificate(_, _, _, _, _)) .WillOnce(WithArgs<4>(Invoke(CertCallbackBadRequestFailure))); - EXPECT_CALL(policy_client_, UploadEnterpriseEnrollmentId(kEnrollmentId, _)) + EXPECT_CALL(policy_client_, UploadEnterpriseEnrollmentId(enrollment_id_, _)) .WillOnce(WithArgs<1>(Invoke(StatusCallbackSuccess))); SetUpDevicePolicy(true); Run();
diff --git a/chrome/browser/chromeos/oauth2_token_service_delegate.cc b/chrome/browser/chromeos/oauth2_token_service_delegate.cc index d33884b4..8e689d5 100644 --- a/chrome/browser/chromeos/oauth2_token_service_delegate.cc +++ b/chrome/browser/chromeos/oauth2_token_service_delegate.cc
@@ -230,4 +230,15 @@ } } +void ChromeOSOAuth2TokenServiceDelegate::RevokeCredentials( + const std::string& account_id) { + // Signing out of Chrome is not possible on Chrome OS. + NOTREACHED(); +} + +void ChromeOSOAuth2TokenServiceDelegate::RevokeAllCredentials() { + // Signing out of Chrome is not possible on Chrome OS. + NOTREACHED(); +} + } // namespace chromeos
diff --git a/chrome/browser/chromeos/oauth2_token_service_delegate.h b/chrome/browser/chromeos/oauth2_token_service_delegate.h index 72c73eb..94272d92 100644 --- a/chrome/browser/chromeos/oauth2_token_service_delegate.h +++ b/chrome/browser/chromeos/oauth2_token_service_delegate.h
@@ -48,12 +48,12 @@ const std::string& refresh_token) override; net::URLRequestContextGetter* GetRequestContext() const override; LoadCredentialsState GetLoadCredentialsState() const override; + void RevokeCredentials(const std::string& account_id) override; + void RevokeAllCredentials() override; // |AccountManager::Observer| overrides void OnTokenUpserted(const AccountManager::AccountKey& account_key) override; - // TODO(sinhak): Implement server token revocation. - private: // Callback handler for |AccountManager::GetAccounts|. void GetAccountsCallback(
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index d8097c1..a5cfe6dc0 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc
@@ -109,6 +109,21 @@ static_cast<int>(method)); } +// Whitelist synable preferences that may be registered after sync system init. +void WhitelistLateRegistrationPrefsForSync( + user_prefs::PrefRegistrySyncable* registry) { + // These foreign syncable preferences are registered asynchronously by Ash, + // perhaps after sync system initialization. Whitelist these prefs so that any + // values obtained via sync before the prefs are registered will be stored. + const char* const kAshForeignSyncablePrefs[] = { + ash::prefs::kEnableAutoScreenLock, ash::prefs::kEnableStylusTools, + ash::prefs::kLaunchPaletteOnEjectEvent, ash::prefs::kShelfAlignment, + ash::prefs::kShelfAutoHideBehavior, ash::prefs::kTapDraggingEnabled, + }; + for (const auto* pref : kAshForeignSyncablePrefs) + registry->WhitelistLateRegistrationPrefForSync(pref); +} + } // namespace Preferences::Preferences() @@ -159,6 +174,8 @@ // static void Preferences::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { + WhitelistLateRegistrationPrefsForSync(registry); + std::string hardware_keyboard_id; // TODO(yusukes): Remove the runtime hack. if (IsRunningAsSystemCompositor()) {
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc index c9eaa34..f8ae3fa 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc
@@ -10,12 +10,18 @@ #include "base/bind.h" #include "base/run_loop.h" #include "chrome/test/base/testing_profile.h" +#include "components/version_info/channel.h" +#include "components/version_info/version_info.h" #include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread_bundle.h" #include "extensions/browser/api/declarative/test_rules_registry.h" #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" +#include "extensions/common/api/declarative/declarative_constants.h" #include "extensions/common/extension.h" #include "extensions/common/extension_builder.h" +#include "extensions/common/features/feature.h" +#include "extensions/common/features/feature_channel.h" +#include "extensions/common/features/feature_provider.h" #include "extensions/common/value_builder.h" #include "testing/gtest/include/gtest/gtest.h" @@ -124,4 +130,49 @@ base::RunLoop().RunUntilIdle(); } +TEST_F(RulesRegistryServiceTest, DefaultRulesRegistryRegistered) { + struct { + version_info::Channel channel; + bool expect_api_enabled; + } test_cases[] = { + {version_info::Channel::UNKNOWN, true}, + {version_info::Channel::STABLE, false}, + }; + + for (const auto& test_case : test_cases) { + SCOPED_TRACE(base::StringPrintf( + "Testing Channel %s", + version_info::GetChannelString(test_case.channel).c_str())); + ScopedCurrentChannel scoped_channel(test_case.channel); + + ASSERT_EQ(test_case.expect_api_enabled, + FeatureProvider::GetAPIFeature("declarativeWebRequest") + ->IsAvailableToEnvironment() + .is_available()); + + TestingProfile profile; + RulesRegistryService registry_service(&profile); + + // The default web request rules registry should only be created if the API + // is enabled. + EXPECT_EQ( + test_case.expect_api_enabled, + registry_service + .GetRulesRegistry(RulesRegistryService::kDefaultRulesRegistryID, + declarative_webrequest_constants::kOnRequest) + .get() != nullptr); + + // Content rules registry should always be created. + EXPECT_TRUE(registry_service.GetRulesRegistry( + RulesRegistryService::kDefaultRulesRegistryID, + declarative_content_constants::kOnPageChanged)); + EXPECT_TRUE(registry_service.content_rules_registry()); + + // Rules registries for web views should always be created. + const int kWebViewRulesRegistryID = 1; + EXPECT_TRUE(registry_service.GetRulesRegistry( + kWebViewRulesRegistryID, declarative_webrequest_constants::kOnRequest)); + } +} + } // namespace extensions
diff --git a/chrome/browser/extensions/content_script_apitest.cc b/chrome/browser/extensions/content_script_apitest.cc index 6139066..28fcf0e 100644 --- a/chrome/browser/extensions/content_script_apitest.cc +++ b/chrome/browser/extensions/content_script_apitest.cc
@@ -20,8 +20,10 @@ #include "chrome/browser/search/search.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" +#include "chrome/browser/ui/search/local_ntp_test_utils.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/webui_url_constants.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/javascript_dialog_manager.h" #include "content/public/browser/render_frame_host.h" @@ -798,4 +800,63 @@ ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); } +// Test fixture which sets a custom NTP Page. +// TODO(karandeepb): Similar logic to set up a custom NTP is used elsewhere as +// well. Abstract this away into a reusable test fixture class. +class NTPInterceptionTest : public ExtensionApiTest { + public: + NTPInterceptionTest() + : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} + + // ExtensionApiTest override: + void SetUpOnMainThread() override { + ExtensionApiTest::SetUpOnMainThread(); + test_data_dir_ = test_data_dir_.AppendASCII("ntp_content_script"); + https_test_server_.ServeFilesFromDirectory(test_data_dir_); + ASSERT_TRUE(https_test_server_.Start()); + + GURL ntp_url = https_test_server_.GetURL("/fake_ntp.html"); + local_ntp_test_utils::SetUserSelectedDefaultSearchProvider( + profile(), https_test_server_.base_url().spec(), ntp_url.spec()); + } + + const net::EmbeddedTestServer* https_test_server() const { + return &https_test_server_; + } + + private: + net::EmbeddedTestServer https_test_server_; + DISALLOW_COPY_AND_ASSIGN(NTPInterceptionTest); +}; + +// Ensure extensions can't inject a content script into the New Tab page. +// Regression test for crbug.com/844428. +IN_PROC_BROWSER_TEST_F(NTPInterceptionTest, ContentScript) { + // Load an extension which tries to inject a script into every frame. + ExtensionTestMessageListener listener("ready", false /*will_reply*/); + const Extension* extension = LoadExtension(test_data_dir_); + ASSERT_TRUE(extension); + ASSERT_TRUE(listener.WaitUntilSatisfied()); + + // Create a corresponding off the record profile for the current profile. This + // is necessary to reproduce crbug.com/844428, which occurs in part due to + // incorrect handling of multiple profiles by the NTP code. + Browser* incognito_browser = CreateIncognitoBrowser(profile()); + ASSERT_TRUE(incognito_browser); + + // Ensure that the extension isn't able to inject the script into the New Tab + // Page. + ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); + ASSERT_TRUE(search::IsInstantNTP(web_contents)); + + bool script_injected_in_ntp = false; + ASSERT_TRUE(ExecuteScriptAndExtractBool( + web_contents, + "window.domAutomationController.send(document.title !== 'Fake NTP');", + &script_injected_in_ntp)); + EXPECT_FALSE(script_injected_in_ntp); +} + } // namespace extensions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index ff53e82..a4bb91d9 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc
@@ -432,14 +432,6 @@ return net_log_; } -void IOThread::ChangedToOnTheRecord() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&IOThread::ChangedToOnTheRecordOnIOThread, - base::Unretained(this))); -} - net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!system_url_request_context_getter_.get()) { @@ -645,28 +637,11 @@ globals_->http_auth_preferences.get(), host_resolver); } -void IOThread::ClearHostCache( - const base::Callback<bool(const std::string&)>& host_filter) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - globals_->system_request_context->host_resolver() - ->GetHostCache() - ->ClearForHosts(host_filter); -} - void IOThread::DisableQuic() { DCHECK_CURRENTLY_ON(BrowserThread::IO); globals_->quic_disabled = true; } -void IOThread::ChangedToOnTheRecordOnIOThread() { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - - // Clear the host cache to avoid showing entries from the OTR session - // in about:net-internals. - ClearHostCache(base::Callback<bool(const std::string&)>()); -} - void IOThread::UpdateDnsClientEnabled() { globals()->system_request_context->host_resolver()->SetDnsClientEnabled( *dns_client_enabled_ || (*dns_over_https_servers_).size() > 0); @@ -715,8 +690,6 @@ builder->SetHttpAuthHandlerFactory( CreateDefaultAuthHandlerFactory(host_resolver.get())); - builder->set_host_resolver(std::move(host_resolver)); - std::unique_ptr<net::CertVerifier> cert_verifier; if (g_cert_verifier_for_io_thread_testing) { cert_verifier = std::make_unique<WrappedCertVerifierForIOThreadTesting>(); @@ -753,12 +726,16 @@ std::make_unique<net::NetworkQualityEstimatorParams>( std::map<std::string, std::string>()), net_log_); + globals_->deprecated_host_resolver = std::move(host_resolver); globals_->system_request_context_owner = std::move(builder)->Create( std::move(network_context_params_).get(), !is_quic_allowed_on_init_, - net_log_, globals_->deprecated_network_quality_estimator.get()); + net_log_, globals_->deprecated_host_resolver.get(), + globals_->deprecated_network_quality_estimator.get()); globals_->system_request_context = globals_->system_request_context_owner.url_request_context.get(); } else { + content::GetNetworkServiceImpl()->SetHostResolver(std::move(host_resolver)); + globals_->system_network_context = content::GetNetworkServiceImpl()->CreateNetworkContextWithBuilder( std::move(network_context_request_),
diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index 95e674a7..642ae5e 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h
@@ -126,6 +126,10 @@ std::unique_ptr<net::NetworkQualityEstimator> deprecated_network_quality_estimator; + // HostResolver only for use in dummy in-process + // URLRequestContext when network service is enabled. + std::unique_ptr<net::HostResolver> deprecated_host_resolver; + std::unique_ptr<net::RTTAndThroughputEstimatesObserver> network_quality_observer; @@ -162,19 +166,9 @@ net_log::ChromeNetLog* net_log(); - // Handles changing to On The Record mode, discarding confidential data. - void ChangedToOnTheRecord(); - // Returns a getter for the URLRequestContext. Only called on the UI thread. net::URLRequestContextGetter* system_url_request_context_getter(); - // Clears the host cache. Intended to be used to prevent exposing recently - // visited sites on about:net-internals/#dns and about:dns pages. Must be - // called on the IO thread. If |host_filter| is not null, only hosts matched - // by it are deleted from the cache. - void ClearHostCache( - const base::Callback<bool(const std::string&)>& host_filter); - // Dynamically disables QUIC for all NetworkContexts using the IOThread's // NetworkService. Re-enabling Quic dynamically is not supported for // simplicity and requires a browser restart. May only be called on the IO @@ -197,8 +191,6 @@ std::unique_ptr<net::HttpAuthHandlerFactory> CreateDefaultAuthHandlerFactory( net::HostResolver* host_resolver); - void ChangedToOnTheRecordOnIOThread(); - void UpdateDnsClientEnabled(); void UpdateServerWhitelist(); void UpdateDelegateWhitelist();
diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc index f844546..d068a0d 100644 --- a/chrome/browser/media/encrypted_media_browsertest.cc +++ b/chrome/browser/media/encrypted_media_browsertest.cc
@@ -72,8 +72,8 @@ #endif const char kExternalClearKeyStorageIdTestKeySystem[] = "org.chromium.externalclearkey.storageidtest"; -const char kExternalClearKeyCdmProxyTestKeySystem[] = - "org.chromium.externalclearkey.cdmproxytest"; +const char kExternalClearKeyCdmProxyKeySystem[] = + "org.chromium.externalclearkey.cdmproxy"; #endif // Supported media types. @@ -863,8 +863,7 @@ // ClearKeyCdmProxy only supports decrypt-only. RunSimpleEncryptedMediaTest("bear-a_enc-a.webm", kWebMVorbisAudioOnly, - kExternalClearKeyCdmProxyTestKeySystem, - SrcType::MSE); + kExternalClearKeyCdmProxyKeySystem, SrcType::MSE); } #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
diff --git a/chrome/browser/nacl_host/test/BUILD.gn b/chrome/browser/nacl_host/test/BUILD.gn index 0de6e09..3f9c9f2d 100644 --- a/chrome/browser/nacl_host/test/BUILD.gn +++ b/chrome/browser/nacl_host/test/BUILD.gn
@@ -11,7 +11,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest",
diff --git a/chrome/browser/notifications/chrome_ash_message_center_client_unittest.cc b/chrome/browser/notifications/chrome_ash_message_center_client_unittest.cc index 630f785d..3fba2b84 100644 --- a/chrome/browser/notifications/chrome_ash_message_center_client_unittest.cc +++ b/chrome/browser/notifications/chrome_ash_message_center_client_unittest.cc
@@ -110,7 +110,7 @@ static_cast<extensions::TestExtensionSystem*>( extensions::ExtensionSystem::Get(profile)); base::CommandLine command_line(base::CommandLine::NO_PROGRAM); - ExtensionService* extension_service = + extensions::ExtensionService* extension_service = test_extension_system->CreateExtensionService( &command_line, base::FilePath() /* install_directory */, false /* autoupdate_enabled*/);
diff --git a/chrome/browser/notifications/platform_notification_service_unittest.cc b/chrome/browser/notifications/platform_notification_service_unittest.cc index 1283eaed..9302fbab 100644 --- a/chrome/browser/notifications/platform_notification_service_unittest.cc +++ b/chrome/browser/notifications/platform_notification_service_unittest.cc
@@ -288,7 +288,7 @@ static_cast<extensions::TestExtensionSystem*>( extensions::ExtensionSystem::Get(profile_)); - ExtensionService* extension_service = + extensions::ExtensionService* extension_service = test_extension_system->CreateExtensionService( &command_line, base::FilePath() /* install_directory */, false /* autoupdate_enabled */);
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index ece708b..d05841fc3 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -60,6 +60,7 @@ #include "extensions/buildflags/buildflags.h" #include "net/http/transport_security_state.h" #include "ppapi/buildflags/buildflags.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "services/preferences/public/cpp/in_process_service_factory.h" #include "services/preferences/public/cpp/pref_service_main.h" #include "services/preferences/public/mojom/preferences.mojom.h" @@ -200,6 +201,12 @@ io_data_->GetResourceContextNoInit()); #endif + // Clears any data the network stack contains that may be related to the + // OTR session. Must be done before DestroyBrowserContextServices, since + // the NetworkContext is managed by one such service. + GetDefaultStoragePartition(this)->GetNetworkContext()->ClearHostCache( + nullptr, network::mojom::NetworkContext::ClearHostCacheCallback()); + BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( this); @@ -209,10 +216,6 @@ base::BindOnce(&NotifyOTRProfileDestroyedOnIOThread, profile_, this)); #endif - // Clears any data the network stack contains that may be related to the - // OTR session. - g_browser_process->io_thread()->ChangedToOnTheRecord(); - // This must be called before ProfileIOData::ShutdownOnUIThread but after // other profile-related destroy notifications are dispatched. ShutdownStoragePartitions();
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index a9a5998f..755d319 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc
@@ -1084,9 +1084,6 @@ builder->set_network_delegate(std::move(network_delegate)); } - builder->set_shared_host_resolver( - io_thread_globals->system_request_context->host_resolver()); - builder->set_shared_http_auth_handler_factory( io_thread_globals->system_request_context->http_auth_handler_factory()); @@ -1177,6 +1174,7 @@ main_request_context_owner_ = std::move(builder)->Create( std::move(profile_params_->main_network_context_params).get(), io_thread_globals->quic_disabled, io_thread->net_log(), + io_thread_globals->deprecated_host_resolver.get(), io_thread_globals->deprecated_network_quality_estimator.get()); main_request_context_ = main_request_context_owner_.url_request_context.get();
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc index 9d970c9..54392da 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -642,7 +642,7 @@ void RenderViewContextMenu::AppendAllExtensionItems() { extension_items_.Clear(); - ExtensionService* service = + extensions::ExtensionService* service = extensions::ExtensionSystem::Get(browser_context_)->extension_service(); if (!service) return; // In unit-tests, we may not have an ExtensionService.
diff --git a/chrome/browser/resource_coordinator/BUILD.gn b/chrome/browser/resource_coordinator/BUILD.gn index 2edf4a2..3a6a6326 100644 --- a/chrome/browser/resource_coordinator/BUILD.gn +++ b/chrome/browser/resource_coordinator/BUILD.gn
@@ -3,6 +3,7 @@ # found in the LICENSE file. import("//chrome/common/features.gni") +import("//mojo/public/tools/bindings/mojom.gni") import("//third_party/protobuf/proto_library.gni") proto_library("tab_metrics_event_proto") { @@ -16,3 +17,9 @@ "site_characteristics.proto", ] } + +mojom("mojo_bindings") { + sources = [ + "lifecycle_unit_state.mojom", + ] +}
diff --git a/chrome/browser/resource_coordinator/OWNERS b/chrome/browser/resource_coordinator/OWNERS index 669672a..d329c2c 100644 --- a/chrome/browser/resource_coordinator/OWNERS +++ b/chrome/browser/resource_coordinator/OWNERS
@@ -4,3 +4,6 @@ # ChromeOS tab manager related implementation. per-file *chromeos*=cylee@chromium.org + +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.cc b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.cc index 09c86a70..4fa7171 100644 --- a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.cc +++ b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.cc
@@ -19,10 +19,10 @@ void DiscardMetricsLifecycleUnitObserver::OnLifecycleUnitStateChanged( LifecycleUnit* lifecycle_unit, - LifecycleState last_state) { - if (lifecycle_unit->GetState() == LifecycleState::DISCARDED) + LifecycleUnitState last_state) { + if (lifecycle_unit->GetState() == LifecycleUnitState::DISCARDED) OnDiscard(lifecycle_unit); - else if (last_state == LifecycleState::DISCARDED) + else if (last_state == LifecycleUnitState::DISCARDED) OnReload(); } @@ -31,7 +31,7 @@ // If the browser is not shutting down and the tab is loaded after // being discarded, record TabManager.Discarding.ReloadToCloseTime. if (g_browser_process && !g_browser_process->IsShuttingDown() && - lifecycle_unit->GetState() != LifecycleState::DISCARDED && + lifecycle_unit->GetState() != LifecycleUnitState::DISCARDED && !reload_time_.is_null()) { auto reload_to_close_time = NowTicks() - reload_time_; UMA_HISTOGRAM_CUSTOM_TIMES(
diff --git a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.h b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.h index 1e364c0d..426d0ff3 100644 --- a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.h +++ b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer.h
@@ -9,10 +9,12 @@ #include "base/macros.h" #include "base/time/time.h" -#include "chrome/browser/resource_coordinator/lifecycle_state.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" namespace resource_coordinator { +using ::mojom::LifecycleUnitState; + // Observes a LifecycleUnit to record metrics. class DiscardMetricsLifecycleUnitObserver : public LifecycleUnitObserver { public: @@ -21,7 +23,7 @@ // LifecycleUnitObserver: void OnLifecycleUnitStateChanged(LifecycleUnit* lifecycle_unit, - LifecycleState last_state) override; + LifecycleUnitState last_state) override; void OnLifecycleUnitDestroyed(LifecycleUnit* lifecycle_unit) override; private:
diff --git a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer_unittest.cc b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer_unittest.cc index 970dd6c..55c4638 100644 --- a/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer_unittest.cc +++ b/chrome/browser/resource_coordinator/discard_metrics_lifecycle_unit_observer_unittest.cc
@@ -58,19 +58,19 @@ histograms_.ExpectTotalCount(kDiscardCountHistogram, 0); histograms_.ExpectTotalCount(kReloadCountHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); histograms_.ExpectTotalCount(kDiscardCountHistogram, 1); histograms_.ExpectTotalCount(kReloadCountHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::ACTIVE); + lifecycle_unit_->SetState(LifecycleUnitState::ACTIVE); histograms_.ExpectTotalCount(kDiscardCountHistogram, 1); histograms_.ExpectTotalCount(kReloadCountHistogram, 1); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); histograms_.ExpectTotalCount(kDiscardCountHistogram, 2); histograms_.ExpectTotalCount(kReloadCountHistogram, 1); - lifecycle_unit_->SetState(LifecycleState::ACTIVE); + lifecycle_unit_->SetState(LifecycleUnitState::ACTIVE); histograms_.ExpectTotalCount(kDiscardCountHistogram, 2); histograms_.ExpectTotalCount(kReloadCountHistogram, 2); } @@ -78,11 +78,11 @@ TEST_F(DiscardMetricsLifecycleUnitObserverTest, DiscardToReloadTime) { histograms_.ExpectTotalCount(kDiscardToReloadTimeHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); test_clock_.Advance(kShortDelay); histograms_.ExpectTotalCount(kDiscardToReloadTimeHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::ACTIVE); + lifecycle_unit_->SetState(LifecycleUnitState::ACTIVE); histograms_.ExpectTimeBucketCount(kDiscardToReloadTimeHistogram, kShortDelay, 1); } @@ -93,11 +93,11 @@ const base::TimeTicks last_focused_time = NowTicks(); lifecycle_unit_->SetLastFocusedTime(last_focused_time); test_clock_.Advance(kShortDelay); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); test_clock_.Advance(kShortDelay); histograms_.ExpectTotalCount(kInactiveToReloadTimeHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::ACTIVE); + lifecycle_unit_->SetState(LifecycleUnitState::ACTIVE); histograms_.ExpectTimeBucketCount(kInactiveToReloadTimeHistogram, 2 * kShortDelay, 1); } @@ -113,7 +113,7 @@ ReloadToCloseTimeDiscardedButNotReloaded) { histograms_.ExpectTotalCount(kReloadToCloseTimeHistogram, 0); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); histograms_.ExpectTotalCount(kReloadToCloseTimeHistogram, 0); lifecycle_unit_.reset(); @@ -124,11 +124,11 @@ histograms_.ExpectTotalCount(kReloadToCloseTimeHistogram, 0); test_clock_.Advance(kShortDelay * 1); - lifecycle_unit_->SetState(LifecycleState::DISCARDED); + lifecycle_unit_->SetState(LifecycleUnitState::DISCARDED); histograms_.ExpectTotalCount(kReloadToCloseTimeHistogram, 0); test_clock_.Advance(kShortDelay * 2); - lifecycle_unit_->SetState(LifecycleState::ACTIVE); + lifecycle_unit_->SetState(LifecycleUnitState::ACTIVE); histograms_.ExpectTotalCount(kReloadToCloseTimeHistogram, 0); test_clock_.Advance(kShortDelay * 4);
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit.h b/chrome/browser/resource_coordinator/lifecycle_unit.h index 0c56acc..eb9f1900 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit.h +++ b/chrome/browser/resource_coordinator/lifecycle_unit.h
@@ -15,11 +15,13 @@ #include "base/time/time.h" #include "chrome/browser/resource_coordinator/decision_details.h" #include "chrome/browser/resource_coordinator/discard_reason.h" -#include "chrome/browser/resource_coordinator/lifecycle_state.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" #include "content/public/browser/visibility.h" namespace resource_coordinator { +using ::mojom::LifecycleUnitState; + class DecisionDetails; class LifecycleUnitObserver; class TabLifecycleUnitExternal; @@ -107,7 +109,7 @@ virtual SortKey GetSortKey() const = 0; // Returns the current state of this LifecycleUnit. - virtual LifecycleState GetState() const = 0; + virtual LifecycleUnitState GetState() const = 0; // Request that the LifecycleUnit be frozen, return true if the request is // successfully sent.
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit_base.cc b/chrome/browser/resource_coordinator/lifecycle_unit_base.cc index bdc5dbd6..2793d5b 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit_base.cc +++ b/chrome/browser/resource_coordinator/lifecycle_unit_base.cc
@@ -20,7 +20,7 @@ return id_; } -LifecycleState LifecycleUnitBase::GetState() const { +LifecycleUnitState LifecycleUnitBase::GetState() const { return state_; } @@ -36,10 +36,10 @@ observers_.RemoveObserver(observer); } -void LifecycleUnitBase::SetState(LifecycleState state) { +void LifecycleUnitBase::SetState(LifecycleUnitState state) { if (state == state_) return; - LifecycleState last_state = state_; + LifecycleUnitState last_state = state_; state_ = state; for (auto& observer : observers_) observer.OnLifecycleUnitStateChanged(this, last_state);
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit_base.h b/chrome/browser/resource_coordinator/lifecycle_unit_base.h index 56145ae..dd76e8f 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit_base.h +++ b/chrome/browser/resource_coordinator/lifecycle_unit_base.h
@@ -7,12 +7,13 @@ #include "base/macros.h" #include "base/observer_list.h" -#include "chrome/browser/resource_coordinator/lifecycle_state.h" #include "chrome/browser/resource_coordinator/lifecycle_unit.h" #include "content/public/browser/visibility.h" namespace resource_coordinator { +using ::mojom::LifecycleUnitState; + // Base class for a LifecycleUnit. class LifecycleUnitBase : public LifecycleUnit { public: @@ -22,13 +23,13 @@ // LifecycleUnit: int32_t GetID() const override; base::TimeTicks GetLastVisibleTime() const override; - LifecycleState GetState() const override; + LifecycleUnitState GetState() const override; void AddObserver(LifecycleUnitObserver* observer) override; void RemoveObserver(LifecycleUnitObserver* observer) override; protected: // Sets the state of this LifecycleUnit to |state| and notifies observers. - void SetState(LifecycleState state); + void SetState(LifecycleUnitState state); // Notifies observers that the visibility of the LifecycleUnit has changed. void OnLifecycleUnitVisibilityChanged(content::Visibility visibility); @@ -45,7 +46,7 @@ const int32_t id_ = ++next_id_; // Current state of this LifecycleUnit. - LifecycleState state_ = LifecycleState::ACTIVE; + LifecycleUnitState state_ = LifecycleUnitState::ACTIVE; base::TimeTicks last_visible_time_;
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit_base_unittest.cc b/chrome/browser/resource_coordinator/lifecycle_unit_base_unittest.cc index 36b0e3b..9c5b49e 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit_base_unittest.cc +++ b/chrome/browser/resource_coordinator/lifecycle_unit_base_unittest.cc
@@ -22,7 +22,7 @@ MockLifecycleUnitObserver() = default; MOCK_METHOD2(OnLifecycleUnitStateChanged, - void(LifecycleUnit*, LifecycleState)); + void(LifecycleUnit*, LifecycleUnitState)); MOCK_METHOD2(OnLifecycleUnitVisibilityChanged, void(LifecycleUnit*, content::Visibility)); MOCK_METHOD1(OnLifecycleUnitDestroyed, void(LifecycleUnit*)); @@ -59,11 +59,11 @@ // Observer is notified when the state changes. EXPECT_CALL(observer, OnLifecycleUnitStateChanged(&lifecycle_unit, lifecycle_unit.GetState())); - lifecycle_unit.SetState(LifecycleState::DISCARDED); + lifecycle_unit.SetState(LifecycleUnitState::DISCARDED); testing::Mock::VerifyAndClear(&observer); // Observer isn't notified when the state stays the same. - lifecycle_unit.SetState(LifecycleState::DISCARDED); + lifecycle_unit.SetState(LifecycleUnitState::DISCARDED); lifecycle_unit.RemoveObserver(&observer); }
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit_observer.cc b/chrome/browser/resource_coordinator/lifecycle_unit_observer.cc index 10d2bfb..65a3fb8 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit_observer.cc +++ b/chrome/browser/resource_coordinator/lifecycle_unit_observer.cc
@@ -10,7 +10,7 @@ void LifecycleUnitObserver::OnLifecycleUnitStateChanged( LifecycleUnit* lifecycle_unit, - LifecycleState last_state) {} + LifecycleUnitState last_state) {} void LifecycleUnitObserver::OnLifecycleUnitVisibilityChanged( LifecycleUnit* lifecycle_unit,
diff --git a/chrome/browser/resource_coordinator/lifecycle_unit_observer.h b/chrome/browser/resource_coordinator/lifecycle_unit_observer.h index ca80ef8e..6e4560bf8 100644 --- a/chrome/browser/resource_coordinator/lifecycle_unit_observer.h +++ b/chrome/browser/resource_coordinator/lifecycle_unit_observer.h
@@ -5,11 +5,13 @@ #ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_LIFECYCLE_UNIT_OBSERVER_H_ #define CHROME_BROWSER_RESOURCE_COORDINATOR_LIFECYCLE_UNIT_OBSERVER_H_ -#include "chrome/browser/resource_coordinator/lifecycle_state.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" #include "content/public/browser/visibility.h" namespace resource_coordinator { +using ::mojom::LifecycleUnitState; + class LifecycleUnit; // Interface to be notified when the state of a LifecycleUnit changes. @@ -19,7 +21,7 @@ // Invoked when the state of the observed LifecycleUnit changes. virtual void OnLifecycleUnitStateChanged(LifecycleUnit* lifecycle_unit, - LifecycleState last_state); + LifecycleUnitState last_state); // Invoked when the visibility of the observed LifecyleUnit changes. virtual void OnLifecycleUnitVisibilityChanged(LifecycleUnit* lifecycle_unit,
diff --git a/chrome/browser/resource_coordinator/lifecycle_state.h b/chrome/browser/resource_coordinator/lifecycle_unit_state.mojom similarity index 77% rename from chrome/browser/resource_coordinator/lifecycle_state.h rename to chrome/browser/resource_coordinator/lifecycle_unit_state.mojom index fc37ecf..d27a976 100644 --- a/chrome/browser/resource_coordinator/lifecycle_state.h +++ b/chrome/browser/resource_coordinator/lifecycle_unit_state.mojom
@@ -2,14 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_RESOURCE_COORDINATOR_LIFECYCLE_STATE_H_ -#define CHROME_BROWSER_RESOURCE_COORDINATOR_LIFECYCLE_STATE_H_ - -namespace resource_coordinator { +module mojom; // Note that these states are emitted via UKMs, so the integer values should // remain consistent. -enum class LifecycleState { +enum LifecycleUnitState { // The LifecycleUnit is alive and active with no CPU throttling. ACTIVE = 0, // The LifecycleUnit is currently being CPU throttled. @@ -26,15 +23,11 @@ // An enumeration of reasons why a lifecycle state change was applied. These are // also emitted via UKM so need to remain stable. -enum class LifecycleStateChangeReason { +enum LifecycleUnitStateChangeReason { // Policy in the browser decided to initiate the state change. BROWSER_INITIATED = 0, // Policy in the renderer decided to initiate the state change. RENDERER_INITIATED = 1, // A system wide memory pressure condition initiated the state change. SYSTEM_MEMORY_PRESSURE = 2, -}; - -} // namespace resource_coordinator - -#endif // CHROME_BROWSER_RESOURCE_COORDINATOR_LIFECYCLE_STATE_H_ +}; \ No newline at end of file
diff --git a/chrome/browser/resource_coordinator/tab_lifecycle_unit.cc b/chrome/browser/resource_coordinator/tab_lifecycle_unit.cc index 40daa00..bd24a86e 100644 --- a/chrome/browser/resource_coordinator/tab_lifecycle_unit.cc +++ b/chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/resource_coordinator/lifecycle_state.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" #include "chrome/browser/resource_coordinator/tab_activity_watcher.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_observer.h" #include "chrome/browser/resource_coordinator/tab_load_tracker.h" @@ -63,10 +63,10 @@ return; last_focused_time_ = focused ? base::TimeTicks::Max() : NowTicks(); - if (focused && (GetState() == LifecycleState::DISCARDED || - GetState() == LifecycleState::PENDING_DISCARD)) { - bool was_discarded = GetState() == LifecycleState::DISCARDED; - SetState(LifecycleState::ACTIVE); + if (focused && (GetState() == LifecycleUnitState::DISCARDED || + GetState() == LifecycleUnitState::PENDING_DISCARD)) { + bool was_discarded = GetState() == LifecycleUnitState::DISCARDED; + SetState(LifecycleUnitState::ACTIVE); // If the tab was fully discarded, the tab needs to be reloaded. if (was_discarded) { @@ -101,17 +101,17 @@ switch (state) { case mojom::LifecycleState::kFrozen: { - if (GetState() == LifecycleState::PENDING_DISCARD) { + if (GetState() == LifecycleUnitState::PENDING_DISCARD) { freeze_timeout_timer_->Stop(); FinishDiscard(discard_reason_); } else { - SetState(LifecycleState::FROZEN); + SetState(LifecycleUnitState::FROZEN); } break; } case mojom::LifecycleState::kRunning: { - SetState(LifecycleState::ACTIVE); + SetState(LifecycleUnitState::ACTIVE); break; } @@ -128,9 +128,9 @@ DCHECK_EQ(reason, DiscardReason::kProactive); // Ensure the tab is not already pending a discard. - DCHECK_NE(GetState(), LifecycleState::PENDING_DISCARD); + DCHECK_NE(GetState(), LifecycleUnitState::PENDING_DISCARD); - SetState(LifecycleState::PENDING_DISCARD); + SetState(LifecycleUnitState::PENDING_DISCARD); // External observers should now view this tab as discarded, hiding the // pending discard implementation detail. @@ -198,14 +198,14 @@ bool TabLifecycleUnitSource::TabLifecycleUnit::Freeze() { // Can't request to freeze a discarded tab. - if (GetState() == LifecycleState::DISCARDED) + if (GetState() == LifecycleUnitState::DISCARDED) return false; // If currently in PENDING_DISCARD, the tab IsDiscarded() to external // observers. To maintain this, don't set it to PENDING_FREEZE, but keep the // tab in the PENDING_DISCARD state. - if (GetState() != LifecycleState::PENDING_DISCARD) - SetState(LifecycleState::PENDING_FREEZE); + if (GetState() != LifecycleUnitState::PENDING_DISCARD) + SetState(LifecycleUnitState::PENDING_FREEZE); GetWebContents()->FreezePage(); return true; @@ -238,9 +238,6 @@ // rejection reasons. These aren't worth reporting about, as they have nothing // to do with the content itself. - if (IsFrozen()) - return false; - // Allow a page to load fully before freezing it. if (TabLoadTracker::Get()->GetLoadingState(GetWebContents()) != TabLoadTracker::LoadingState::LOADED) { @@ -371,13 +368,13 @@ return false; // Can't discard a tab if it is already discarded. - if (GetState() == LifecycleState::DISCARDED) + if (GetState() == LifecycleUnitState::DISCARDED) return false; // If a non-urgent discard is requested when the state is PENDING_DISCARD, // returns false to indicate that it is incorrect to request a non-urgent // discard again. - if (GetState() == LifecycleState::PENDING_DISCARD && + if (GetState() == LifecycleUnitState::PENDING_DISCARD && discard_reason == DiscardReason::kProactive) { return false; } @@ -391,7 +388,7 @@ // TODO(fdoray): Request a freeze for kExternal discards too once that doesn't // cause asynchronous change of tab id. https://crbug.com/632839 if (discard_reason == DiscardReason::kProactive && - GetState() != LifecycleState::FROZEN) { + GetState() != LifecycleUnitState::FROZEN) { RequestFreezeForDiscard(discard_reason); // Returning true because even though the discard did not happen yet, the @@ -474,9 +471,9 @@ // RenderFrameProxyHosts. old_contents_deleter.reset(); - LifecycleState previous_state = GetState(); - SetState(LifecycleState::DISCARDED); - if (previous_state != LifecycleState::PENDING_DISCARD) + LifecycleUnitState previous_state = GetState(); + SetState(LifecycleUnitState::DISCARDED); + if (previous_state != LifecycleUnitState::PENDING_DISCARD) OnDiscardedStateChange(); ++discard_count_; } @@ -515,18 +512,18 @@ // External code does not need to know about the intermediary PENDING_DISCARD // state. To external callers, the tab is discarded while in the // PENDING_DISCARD state. - LifecycleState current_state = GetState(); - return current_state == LifecycleState::PENDING_DISCARD || - current_state == LifecycleState::DISCARDED; + LifecycleUnitState current_state = GetState(); + return current_state == LifecycleUnitState::PENDING_DISCARD || + current_state == LifecycleUnitState::DISCARDED; } bool TabLifecycleUnitSource::TabLifecycleUnit::IsFrozen() const { // External code does not need to know about the intermediary PENDING_FREEZE - // state. To external callers, the tab is frozen while in the PENDING_FREEZE + // state. To external callers, the tab is frozen while in the PENDING_FREEZE // state. - LifecycleState current_state = GetState(); - return current_state == LifecycleState::PENDING_FREEZE || - current_state == LifecycleState::FROZEN; + LifecycleUnitState current_state = GetState(); + return current_state == LifecycleUnitState::PENDING_FREEZE || + current_state == LifecycleUnitState::FROZEN; } int TabLifecycleUnitSource::TabLifecycleUnit::GetDiscardCount() const { @@ -583,7 +580,7 @@ void TabLifecycleUnitSource::TabLifecycleUnit::DidStartLoading() { if (IsDiscarded()) { - SetState(LifecycleState::ACTIVE); + SetState(LifecycleUnitState::ACTIVE); OnDiscardedStateChange(); } }
diff --git a/chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc b/chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc index 85f2fc2..ba43c8f7 100644 --- a/chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc +++ b/chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc
@@ -73,7 +73,7 @@ MockLifecycleUnitObserver() = default; MOCK_METHOD2(OnLifecycleUnitStateChanged, - void(LifecycleUnit* lifecycle_unit, LifecycleState)); + void(LifecycleUnit* lifecycle_unit, LifecycleUnitState)); MOCK_METHOD2(OnLifecycleUnitVisibilityChanged, void(LifecycleUnit* lifecycle_unit, content::Visibility visibility)); @@ -240,10 +240,11 @@ DiscardReason reason, LifecycleUnit* lifecycle_unit) { if (reason == DiscardReason::kProactive) { - EXPECT_EQ(LifecycleState::PENDING_DISCARD, lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::PENDING_DISCARD, + lifecycle_unit->GetState()); task_runner_->FastForwardBy(kProactiveDiscardFreezeTimeout); } - EXPECT_EQ(LifecycleState::DISCARDED, lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::DISCARDED, lifecycle_unit->GetState()); } void DetachWebContentsTest(DiscardReason reason) { @@ -274,7 +275,7 @@ other_tab_strip_model.AppendWebContents(std::move(owned_contents), false); ExpectCanDiscardTrueAllReasons(first_lifecycle_unit); - EXPECT_EQ(LifecycleState::ACTIVE, first_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, first_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); first_lifecycle_unit->Discard(reason); @@ -300,7 +301,8 @@ initial_web_contents->SetLastActiveTime(kDummyLastActiveTime); // Discard the tab. - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(reason); testing::Mock::VerifyAndClear(&tab_observer_); @@ -328,7 +330,8 @@ tab_strip_model_->GetWebContentsAt(0); // Discard the tab. - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(reason); testing::Mock::VerifyAndClear(&tab_observer_); @@ -345,7 +348,8 @@ EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, false)); tab_strip_model_->ActivateTabAt(0, true); testing::Mock::VerifyAndClear(&tab_observer_); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_TRUE(tab_strip_model_->GetWebContentsAt(0) ->GetController() .GetPendingEntry()); @@ -360,7 +364,8 @@ tab_strip_model_->GetWebContentsAt(0); // Discard the tab. - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(reason); testing::Mock::VerifyAndClear(&tab_observer_); @@ -378,7 +383,8 @@ tab_strip_model_->GetWebContentsAt(0)->GetController().Reload( content::ReloadType::NORMAL, false); testing::Mock::VerifyAndClear(&tab_observer_); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_TRUE(tab_strip_model_->GetWebContentsAt(0) ->GetController() .GetPendingEntry()); @@ -396,7 +402,8 @@ ExpectCanDiscardTrueAllReasons(background_lifecycle_unit); // Discard the tab. - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(reason); @@ -415,7 +422,8 @@ tab_strip_model_->GetWebContentsAt(0)->GetController().Reload( content::ReloadType::NORMAL, false); testing::Mock::VerifyAndClear(&tab_observer_); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, + background_lifecycle_unit->GetState()); EXPECT_TRUE(tab_strip_model_->GetWebContentsAt(0) ->GetController() .GetPendingEntry()); @@ -636,12 +644,13 @@ ExpectCanDiscardTrueAllReasons(background_lifecycle_unit); // Discard the tab. Use DiscardReason::kUrgent to force the discard. - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(DiscardReason::kUrgent); testing::Mock::VerifyAndClear(&tab_observer_); - EXPECT_EQ(LifecycleState::DISCARDED, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::DISCARDED, + background_lifecycle_unit->GetState()); EXPECT_NE(initial_web_contents, tab_strip_model_->GetWebContentsAt(0)); EXPECT_FALSE( tab_strip_model_->GetWebContentsAt(0)->GetController().GetPendingEntry()); @@ -653,7 +662,7 @@ tab_strip_model_->GetWebContentsAt(0)->GetController().Reload( content::ReloadType::NORMAL, false); testing::Mock::VerifyAndClear(&tab_observer_); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, background_lifecycle_unit->GetState()); EXPECT_TRUE( tab_strip_model_->GetWebContentsAt(0)->GetController().GetPendingEntry()); @@ -667,18 +676,19 @@ CreateTwoTabs(true /* focus_tab_strip */, &background_lifecycle_unit, &foreground_lifecycle_unit); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(DiscardReason::kProactive); - EXPECT_EQ(LifecycleState::PENDING_DISCARD, + EXPECT_EQ(LifecycleUnitState::PENDING_DISCARD, background_lifecycle_unit->GetState()); reinterpret_cast<TabLifecycleUnitSource::TabLifecycleUnit*>( background_lifecycle_unit) ->UpdateLifecycleState(mojom::LifecycleState::kFrozen); - EXPECT_EQ(LifecycleState::DISCARDED, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::DISCARDED, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, false)); tab_strip_model_->GetWebContentsAt(0)->GetController().Reload( content::ReloadType::NORMAL, false); @@ -691,15 +701,16 @@ CreateTwoTabs(true /* focus_tab_strip */, &background_lifecycle_unit, &foreground_lifecycle_unit); - EXPECT_EQ(LifecycleState::ACTIVE, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::ACTIVE, background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, true)); background_lifecycle_unit->Discard(DiscardReason::kProactive); - EXPECT_EQ(LifecycleState::PENDING_DISCARD, + EXPECT_EQ(LifecycleUnitState::PENDING_DISCARD, background_lifecycle_unit->GetState()); task_runner_->FastForwardBy(kProactiveDiscardFreezeTimeout); - EXPECT_EQ(LifecycleState::DISCARDED, background_lifecycle_unit->GetState()); + EXPECT_EQ(LifecycleUnitState::DISCARDED, + background_lifecycle_unit->GetState()); EXPECT_CALL(tab_observer_, OnDiscardedStateChange(testing::_, false)); tab_strip_model_->GetWebContentsAt(0)->GetController().Reload(
diff --git a/chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc b/chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc index 858b3d8..f5a2788 100644 --- a/chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc +++ b/chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
@@ -54,7 +54,7 @@ MockLifecycleUnitObserver() = default; MOCK_METHOD2(OnLifecycleUnitStateChanged, - void(LifecycleUnit*, LifecycleState)); + void(LifecycleUnit*, LifecycleUnitState)); MOCK_METHOD1(OnLifecycleUnitDestroyed, void(LifecycleUnit*)); MOCK_METHOD2(OnLifecycleUnitVisibilityChanged, void(LifecycleUnit*, content::Visibility));
diff --git a/chrome/browser/resource_coordinator/tab_manager.cc b/chrome/browser/resource_coordinator/tab_manager.cc index 6ab4edc..14d0ce67 100644 --- a/chrome/browser/resource_coordinator/tab_manager.cc +++ b/chrome/browser/resource_coordinator/tab_manager.cc
@@ -120,9 +120,9 @@ int GetNumLoadedLifecycleUnits(LifecycleUnitSet lifecycle_unit_set) { int num_loaded_lifecycle_units = 0; for (auto* lifecycle_unit : lifecycle_unit_set) { - LifecycleState state = lifecycle_unit->GetState(); - if (state != LifecycleState::DISCARDED && - state != LifecycleState::PENDING_DISCARD) { + LifecycleUnitState state = lifecycle_unit->GetState(); + if (state != LifecycleUnitState::DISCARDED && + state != LifecycleUnitState::PENDING_DISCARD) { num_loaded_lifecycle_units++; } } @@ -1002,12 +1002,12 @@ } void TabManager::OnLifecycleUnitStateChanged(LifecycleUnit* lifecycle_unit, - LifecycleState last_state) { - LifecycleState state = lifecycle_unit->GetState(); - bool was_discarded = (last_state == LifecycleState::PENDING_DISCARD || - last_state == LifecycleState::DISCARDED); - bool is_discarded = (state == LifecycleState::PENDING_DISCARD || - state == LifecycleState::DISCARDED); + LifecycleUnitState last_state) { + LifecycleUnitState state = lifecycle_unit->GetState(); + bool was_discarded = (last_state == LifecycleUnitState::PENDING_DISCARD || + last_state == LifecycleUnitState::DISCARDED); + bool is_discarded = (state == LifecycleUnitState::PENDING_DISCARD || + state == LifecycleUnitState::DISCARDED); if (is_discarded && !was_discarded) { num_loaded_lifecycle_units_--; @@ -1038,8 +1038,8 @@ } void TabManager::OnLifecycleUnitDestroyed(LifecycleUnit* lifecycle_unit) { - if (lifecycle_unit->GetState() != LifecycleState::DISCARDED && - lifecycle_unit->GetState() != LifecycleState::PENDING_DISCARD) { + if (lifecycle_unit->GetState() != LifecycleUnitState::DISCARDED && + lifecycle_unit->GetState() != LifecycleUnitState::PENDING_DISCARD) { num_loaded_lifecycle_units_--; } lifecycle_units_.erase(lifecycle_unit); @@ -1052,7 +1052,7 @@ void TabManager::OnLifecycleUnitCreated(LifecycleUnit* lifecycle_unit) { lifecycle_units_.insert(lifecycle_unit); - if (lifecycle_unit->GetState() != LifecycleState::DISCARDED) + if (lifecycle_unit->GetState() != LifecycleUnitState::DISCARDED) num_loaded_lifecycle_units_++; // Add an observer to be notified of destruction.
diff --git a/chrome/browser/resource_coordinator/tab_manager.h b/chrome/browser/resource_coordinator/tab_manager.h index e36c49e..a2cac62 100644 --- a/chrome/browser/resource_coordinator/tab_manager.h +++ b/chrome/browser/resource_coordinator/tab_manager.h
@@ -21,10 +21,10 @@ #include "base/timer/timer.h" #include "build/build_config.h" #include "chrome/browser/resource_coordinator/discard_reason.h" -#include "chrome/browser/resource_coordinator/lifecycle_state.h" #include "chrome/browser/resource_coordinator/lifecycle_unit.h" #include "chrome/browser/resource_coordinator/lifecycle_unit_observer.h" #include "chrome/browser/resource_coordinator/lifecycle_unit_source_observer.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_observer.h" #include "chrome/browser/resource_coordinator/tab_load_tracker.h" #include "chrome/browser/resource_coordinator/tab_manager_features.h" @@ -408,7 +408,7 @@ content::Visibility visibility) override; void OnLifecycleUnitDestroyed(LifecycleUnit* lifecycle_unit) override; void OnLifecycleUnitStateChanged(LifecycleUnit* lifecycle_unit, - LifecycleState last_state) override; + LifecycleUnitState last_state) override; // LifecycleUnitSourceObserver: void OnLifecycleUnitCreated(LifecycleUnit* lifecycle_unit) override;
diff --git a/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn b/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn index 34d48c6..e90607aa 100644 --- a/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn +++ b/chrome/browser/resources/chromeos/zip_archiver/cpp/BUILD.gn
@@ -32,7 +32,6 @@ deps = [ "//base:base", - "//build/config:exe_and_shlib_deps", "//chrome/browser/resources/chromeos/zip_archiver:char_coding", "//ppapi/cpp", "//ppapi/native_client:ppapi_lib",
diff --git a/chrome/browser/resources/discards/discards.html b/chrome/browser/resources/discards/discards.html index 8742ff9..0227462 100644 --- a/chrome/browser/resources/discards/discards.html +++ b/chrome/browser/resources/discards/discards.html
@@ -37,9 +37,8 @@ <th data-sort-key="title">Tab Title</th> <th data-sort-key="tabUrl">Tab URL</th> <th data-sort-key="visibility">Visibility</th> + <th data-sort-key="state">State</th> <th data-sort-key="isMedia">Media</th> - <th data-sort-key="isFrozen">Frozen</th> - <th data-sort-key="isDiscarded">Discarded</th> <th data-sort-key="discardCount">Discard Count</th> <th data-sort-key="isAutoDiscardable">Auto Discardable</th> <th data-sort-key="lastActiveSeconds">Last Active</th> @@ -60,9 +59,8 @@ </td> <td class="tab-url-cell"></td> <td class="visibility-cell"></td> + <td class="state-cell"></td> <td class="is-media-cell boolean-cell"></td> - <td class="is-frozen-cell boolean-cell"></td> - <td class="is-discarded-cell boolean-cell"></td> <td class="discard-count-cell"></td> <td class="is-auto-discardable-cell boolean-cell"> <div class="is-auto-discardable-div"></div>
diff --git a/chrome/browser/resources/discards/discards.js b/chrome/browser/resources/discards/discards.js index b04312e..381081c9 100644 --- a/chrome/browser/resources/discards/discards.js +++ b/chrome/browser/resources/discards/discards.js
@@ -64,17 +64,17 @@ } // Compares boolean fields. - if (['isMedia', 'isFrozen', 'isDiscarded', 'isAutoDiscardable'].includes( - sortKey)) { + if (['isMedia', 'isAutoDiscardable'].includes(sortKey)) { if (val1 == val2) return 0; return val1 ? 1 : -1; } // Compares numeric fields. - // Note: Visibility is represented as a numeric value. + // Note: Visibility and state are represented as a numeric value. if ([ 'visibility', + 'state', 'discardCount', 'utilityRank', 'reactivationScore', @@ -203,6 +203,24 @@ assertNotReached('Unsupported visibility: ' + visibility); } + function lifecycleStateToString(state) { + switch (state) { + case mojom.LifecycleUnitState.ACTIVE: + return 'active'; + case mojom.LifecycleUnitState.THROTTLED: + return 'throttled'; + case mojom.LifecycleUnitState.PENDING_FREEZE: + return 'pending frozen'; + case mojom.LifecycleUnitState.FROZEN: + return 'frozen'; + case mojom.LifecycleUnitState.PENDING_DISCARD: + return 'pending discard'; + case mojom.LifecycleUnitState.DISCARDED: + return 'discarded'; + } + assertNotReached('Unsupported lifecycle state: ' + state); + } + /** * Returns the index of the row in the table that houses the given |element|. * @param {HTMLElement} element Any element in the DOM. @@ -287,10 +305,8 @@ visibilityToString(info.visibility); row.querySelector('.is-media-cell').textContent = boolToString(info.isMedia); - row.querySelector('.is-frozen-cell').textContent = - boolToString(info.isFrozen); - row.querySelector('.is-discarded-cell').textContent = - boolToString(info.isDiscarded); + row.querySelector('.state-cell').textContent = + lifecycleStateToString(info.state); row.querySelector('.discard-count-cell').textContent = info.discardCount.toString(); row.querySelector('.is-auto-discardable-div').textContent = @@ -302,19 +318,27 @@ row.querySelector('.is-auto-discardable-link').removeAttribute('disabled'); let discardLink = row.querySelector('.discard-link'); let discardUrgentLink = row.querySelector('.discard-urgent-link'); - if (info.isDiscarded) { - discardLink.setAttribute('disabled', ''); - discardUrgentLink.setAttribute('disabled', ''); - } else { - discardLink.removeAttribute('disabled'); - discardUrgentLink.removeAttribute('disabled'); - } - let freezeLink = row.querySelector('.freeze-link'); - if (info.isFrozen) - freezeLink.setAttribute('disabled', ''); - else - freezeLink.removeAttribute('disabled', ''); + switch (info.state) { + case mojom.LifecycleUnitState.ACTIVE: + discardLink.removeAttribute('disabled'); + discardUrgentLink.removeAttribute('disabled'); + freezeLink.removeAttribute('disabled'); + break; + case mojom.LifecycleUnitState.THROTTLED: + case mojom.LifecycleUnitState.PENDING_FREEZE: + case mojom.LifecycleUnitState.FROZEN: + discardLink.removeAttribute('disabled'); + discardUrgentLink.removeAttribute('disabled'); + freezeLink.setAttribute('disabled', ''); + break; + case mojom.LifecycleUnitState.PENDING_DISCARD: + case mojom.LifecycleUnitState.DISCARDED: + discardLink.setAttribute('disabled', ''); + discardUrgentLink.setAttribute('disabled', ''); + freezeLink.setAttribute('disabled', ''); + break; + } } /**
diff --git a/chrome/browser/safe_browsing/download_protection/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection/download_protection_service.cc index bb9ab65..a2945a6 100644 --- a/chrome/browser/safe_browsing/download_protection/download_protection_service.cc +++ b/chrome/browser/safe_browsing/download_protection/download_protection_service.cc
@@ -498,10 +498,12 @@ signin_manager ? signin_manager->GetAuthenticatedAccountInfo().email : std::string(); + std::string raw_digest_sha256 = item->GetHash(); extensions::SafeBrowsingPrivateEventRouterFactory::GetForProfile(profile) - ->OnDangerousDownloadOpened(item->GetURL(), - item->GetTargetFilePath().AsUTF8Unsafe(), - item->GetHash(), username); + ->OnDangerousDownloadOpened( + item->GetURL(), item->GetTargetFilePath().AsUTF8Unsafe(), + base::HexEncode(raw_digest_sha256.data(), raw_digest_sha256.size()), + username); } } // namespace safe_browsing
diff --git a/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc index c2631bf1..541c4af 100644 --- a/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc +++ b/chrome/browser/safe_browsing/download_protection/download_protection_service_unittest.cc
@@ -2528,7 +2528,8 @@ auto captured_args = event_observer.PassEventArgs().GetList()[0].Clone(); EXPECT_EQ("http://example.com/a.exe", captured_args.FindKey("url")->GetString()); - EXPECT_EQ(hash, captured_args.FindKey("downloadDigestSha256")->GetString()); + EXPECT_EQ(base::HexEncode(hash.data(), hash.size()), + captured_args.FindKey("downloadDigestSha256")->GetString()); EXPECT_EQ(target_path.MaybeAsASCII(), captured_args.FindKey("fileName")->GetString());
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 0f2f5b3..ec0c3e0 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -406,8 +406,9 @@ ShowTaskManager(); ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app"))); - ExtensionService* service = extensions::ExtensionSystem::Get( - browser()->profile())->extension_service(); + extensions::ExtensionService* service = + extensions::ExtensionSystem::Get(browser()->profile()) + ->extension_service(); const extensions::Extension* extension = service->GetExtensionById(last_loaded_extension_id(), false); @@ -448,8 +449,9 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTab) { ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("packaged_app"))); - ExtensionService* service = extensions::ExtensionSystem::Get( - browser()->profile())->extension_service(); + extensions::ExtensionService* service = + extensions::ExtensionSystem::Get(browser()->profile()) + ->extension_service(); const extensions::Extension* extension = service->GetExtensionById(last_loaded_extension_id(), false);
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index e43ea34..1a3dbe9 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1034,6 +1034,7 @@ "//printing/buildflags", "//rlz/buildflags", "//services/metrics/public/cpp:ukm_builders", + "//services/network/public/mojom", "//services/service_manager/runner/common", "//skia", "//storage/browser",
diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc index c2e2b08..8c98a70f4 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc
@@ -196,8 +196,7 @@ std::vector<ExtensionMsg_AccessibilityEventParams> events; events.emplace_back(ExtensionMsg_AccessibilityEventParams()); ExtensionMsg_AccessibilityEventParams& params = events.back(); - current_tree_serializer_->BeginSerializingChanges(¶ms.update); - if (!current_tree_serializer_->SerializeOneChange(aura_obj)) { + if (!current_tree_serializer_->SerializeChanges(aura_obj, ¶ms.update)) { LOG(ERROR) << "Unable to serialize one accessibility event."; return; } @@ -206,9 +205,7 @@ views::AXAuraObjWrapper* focus = views::AXAuraObjCache::GetInstance()->GetFocus(); if (focus) - current_tree_serializer_->SerializeOneChange(focus); - - current_tree_serializer_->FinishSerializingChanges(); + current_tree_serializer_->SerializeChanges(focus, ¶ms.update); params.tree_id = 0; params.id = aura_obj->GetUniqueId().Get();
diff --git a/chrome/browser/ui/browser_command_controller_interactive_browsertest.cc b/chrome/browser/ui/browser_command_controller_interactive_browsertest.cc index 23cd55e5..7d0c420 100644 --- a/chrome/browser/ui/browser_command_controller_interactive_browsertest.cc +++ b/chrome/browser/ui/browser_command_controller_interactive_browsertest.cc
@@ -2,437 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <memory> -#include <string> - #include "base/macros.h" -#include "base/strings/string_util.h" #include "build/build_config.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/fullscreen_keyboard_browsertest_base.h" #include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/interactive_test_utils.h" -#include "content/public/browser/notification_service.h" -#include "content/public/test/browser_test_utils.h" -#include "content/public/test/test_utils.h" -#include "ui/events/keycodes/dom/keycode_converter.h" -#include "ui/events/keycodes/keyboard_code_conversion.h" #include "ui/events/keycodes/keyboard_codes.h" -#include "url/gurl.h" -#include "url/url_constants.h" #if defined(OS_MACOSX) #include "base/mac/mac_util.h" #endif -namespace { - -// The html file to receive key events, prevent defaults and export all the -// events with "getKeyEventReport()" function. It has two magic keys: pressing -// "S" to enter fullscreen mode; pressing "X" to indicate the end of all the -// keys (see FinishTestAndVerifyResult() function). -constexpr char kFullscreenKeyboardLockHTML[] = - "/fullscreen_keyboardlock/fullscreen_keyboardlock.html"; - -// On MacOSX command key is used for most of the shortcuts, so replace it with -// control to reduce the complexity of comparison of the results. -void NormalizeMetaKeyForMacOS(std::string* output) { -#if defined(OS_MACOSX) - base::ReplaceSubstringsAfterOffset(output, 0, "MetaLeft", "ControlLeft"); -#endif -} - -} // namespace - -class BrowserCommandControllerInteractiveTest : public InProcessBrowserTest { - public: - BrowserCommandControllerInteractiveTest() = default; - ~BrowserCommandControllerInteractiveTest() override = default; - - protected: - // Starts |kFullscreenKeyboardLockHTML| in a new tab and waits for load. - void StartFullscreenLockPage(); - - // Sends a control or command + |key| shortcut to the focused window. Shift - // modifier will be added if |shift| is true. - void SendShortcut(ui::KeyboardCode key, bool shift = false); - - // Sends a control or command + shift + |key| shortcut to the focused window. - void SendShiftShortcut(ui::KeyboardCode key); - - // Sends a fullscreen shortcut to the focused window and wait for the - // operation to take effect. - void SendFullscreenShortcutAndWait(); - - // Sends a KeyS to the focused window to trigger JavaScript fullscreen and - // wait for the operation to take effect. - void SendJsFullscreenShortcutAndWait(); - - // Sends an ESC to the focused window. - void SendEscape(); - - // Sends an ESC to the focused window to exit JavaScript fullscreen and wait - // for the operation to take effect. - void SendEscapeAndWaitForExitingFullscreen(); - - // Sends a set of preventable shortcuts to the web page and expects them to be - // prevented. - void SendShortcutsAndExpectPrevented(); - - // Sends a set of preventable shortcuts to the web page and expects them to - // not be prevented. If |js_fullscreen| is true, the test will use - // SendJsFullscreenShortcutAndWait() to trigger the fullscreen mode. Otherwise - // SendFullscreenShortcutAndWait() will be used. - void SendShortcutsAndExpectNotPrevented(bool js_fullscreen); - - // Sends a magic KeyX to the focused window to stop the test case, receives - // the result and verifies if it is equal to |expected_result_|. - void FinishTestAndVerifyResult(); - - // Returns whether the active tab is in html fullscreen mode. - bool IsActiveTabFullscreen() const { - auto* contents = GetActiveWebContents(); - return contents->GetDelegate()->IsFullscreenForTabOrPending(contents); - } - - // Returns whether the GetActiveBrowser() is in browser fullscreen mode. - bool IsInBrowserFullscreen() const { - return GetActiveBrowser() - ->exclusive_access_manager() - ->fullscreen_controller() - ->IsFullscreenForBrowser(); - } - - content::WebContents* GetActiveWebContents() const { - return GetActiveBrowser()->tab_strip_model()->GetActiveWebContents(); - } - - // Gets the current active tab index. - int GetActiveTabIndex() const { - return GetActiveBrowser()->tab_strip_model()->active_index(); - } - - // Gets the count of tabs in current browser. - int GetTabCount() const { - return GetActiveBrowser()->tab_strip_model()->count(); - } - - // Gets the count of browser instances. - size_t GetBrowserCount() const { - return BrowserList::GetInstance()->size(); - } - - // Gets the last active Browser instance. - Browser* GetActiveBrowser() const { - return BrowserList::GetInstance()->GetLastActive(); - } - - // Ensures GetActiveBrowser() is focused. - void FocusOnLastActiveBrowser() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - GetActiveBrowser())); - } - - // Waits until the count of Browser instances becomes |expected|. - void WaitForBrowserCount(size_t expected) { - while (GetBrowserCount() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the count of the tabs in active Browser instance becomes - // |expected|. - void WaitForTabCount(int expected) { - while (GetTabCount() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the index of active tab in active Browser instance becomes - // |expected|. - void WaitForActiveTabIndex(int expected) { - while (GetActiveTabIndex() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the index of active tab in active Browser instance is not - // |expected|. - void WaitForInactiveTabIndex(int expected) { - while (GetActiveTabIndex() == expected) - content::RunAllPendingInMessageLoop(); - } - - private: - void SetUpOnMainThread() override; - - // The expected output from the web page. This string is generated by - // appending key presses from Send* functions above. - std::string expected_result_; - - DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerInteractiveTest); -}; - -void BrowserCommandControllerInteractiveTest::StartFullscreenLockPage() { - // Ensures the initial states. - ASSERT_EQ(1, GetTabCount()); - ASSERT_EQ(0, GetActiveTabIndex()); - ASSERT_EQ(1U, GetBrowserCount()); - // Add a second tab for counting and focus purposes. - AddTabAtIndex(1, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); - ASSERT_EQ(2, GetTabCount()); - ASSERT_EQ(1U, GetBrowserCount()); - - if (!embedded_test_server()->Started()) - ASSERT_TRUE(embedded_test_server()->Start()); - ui_test_utils::NavigateToURLWithDisposition( - GetActiveBrowser(), - embedded_test_server()->GetURL(kFullscreenKeyboardLockHTML), - WindowOpenDisposition::CURRENT_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); -} - -void BrowserCommandControllerInteractiveTest::SendShortcut( - ui::KeyboardCode key, - bool shift /* = false */) { -#if defined(OS_MACOSX) - const bool control_modifier = false; - const bool command_modifier = true; -#else - const bool control_modifier = true; - const bool command_modifier = false; -#endif - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), key, control_modifier, shift, false, - command_modifier)); - - expected_result_ += ui::KeycodeConverter::DomCodeToCodeString( - ui::UsLayoutKeyboardCodeToDomCode(key)); - expected_result_ += " ctrl:"; - expected_result_ += control_modifier ? "true" : "false"; - expected_result_ += " shift:"; - expected_result_ += shift ? "true" : "false"; - expected_result_ += " alt:false"; - expected_result_ += " meta:"; - expected_result_ += command_modifier ? "true" : "false"; - expected_result_ += '\n'; -} - -void BrowserCommandControllerInteractiveTest::SendShiftShortcut( - ui::KeyboardCode key) { - ASSERT_NO_FATAL_FAILURE(SendShortcut(key, true)); -} - -void BrowserCommandControllerInteractiveTest::SendFullscreenShortcutAndWait() { - // On MacOSX, entering and exiting fullscreen are not synchronous. So we wait - // for the observer to notice the change of fullscreen state. - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - // Enter fullscreen. -#if defined(OS_MACOSX) - // On MACOSX, Command + Control + F is used. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F, true, false, false, true)); -#elif defined(OS_CHROMEOS) - // A dedicated fullscreen key is used on Chrome OS, so send a fullscreen - // command directly instead, to avoid constructing the key press. - ASSERT_TRUE(chrome::ExecuteCommand(GetActiveBrowser(), IDC_FULLSCREEN)); -#else - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F11, false, false, false, false)); -#endif - -// Mac fullscreen is simulated in tests and is performed synchronously with the -// keyboard events. As a result, content doesn't actually know it has entered -// fullscreen. For more details, see ScopedFakeNSWindowFullscreen. -// TODO(crbug.com/837438): Remove this once ScopedFakeNSWindowFullscreen fires -// NOTIFICATION_FULLSCREEN_CHANGED. -#if !defined(OS_MACOSX) - observer.Wait(); -#endif -} - -void BrowserCommandControllerInteractiveTest:: - SendJsFullscreenShortcutAndWait() { - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_S, false, false, false, false)); - expected_result_ += "KeyS ctrl:false shift:false alt:false meta:false\n"; - observer.Wait(); - ASSERT_TRUE(IsActiveTabFullscreen()); -} - -void BrowserCommandControllerInteractiveTest::SendEscape() { - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_ESCAPE, false, false, false, false)); - expected_result_ += "Escape ctrl:false shift:false alt:false meta:false\n"; -} - -void BrowserCommandControllerInteractiveTest :: - SendEscapeAndWaitForExitingFullscreen() { - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_ESCAPE, false, false, false, false)); - observer.Wait(); - ASSERT_FALSE(IsActiveTabFullscreen()); -} - -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectPrevented() { - const int initial_active_index = GetActiveTabIndex(); - const int initial_tab_count = GetTabCount(); - const size_t initial_browser_count = GetBrowserCount(); - // The tab should not be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // The window should not be closed. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_W)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // A new tab should not be created. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // A new window should not be created. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // A new incognito window should not be created. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_N)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // Last closed tab should not be restored. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_T)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // Browser should not switch to the next tab. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_TAB)); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - // Browser should not switch to the previous tab. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_TAB)); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); -} - -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectNotPrevented(bool js_fullscreen) { - const int initial_active_index = GetActiveTabIndex(); - const int initial_tab_count = GetTabCount(); - const size_t initial_browser_count = GetBrowserCount(); - const auto enter_fullscreen = [this, js_fullscreen]() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - this->GetActiveBrowser())); - if (js_fullscreen) { - if (!this->IsActiveTabFullscreen()) { - static const std::string page = - "<html><head></head><body></body><script>" - "document.addEventListener('keydown', " - " (e) => {" - " if (e.code == 'KeyS') { " - " document.body.webkitRequestFullscreen();" - " }" - " });" - "</script></html>"; - ui_test_utils::NavigateToURLWithDisposition( - this->GetActiveBrowser(), - GURL("data:text/html," + page), - WindowOpenDisposition::CURRENT_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_NO_FATAL_FAILURE(this->SendJsFullscreenShortcutAndWait()); - } - } else { - if (!this->IsInBrowserFullscreen()) { - ASSERT_NO_FATAL_FAILURE(this->SendFullscreenShortcutAndWait()); - } - ASSERT_TRUE(this->IsInBrowserFullscreen()); - } - }; - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new tab should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - WaitForTabCount(initial_tab_count + 1); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - WaitForTabCount(initial_tab_count); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new tab should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - WaitForTabCount(initial_tab_count + 1); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The previous tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, true, false, false)); - WaitForActiveTabIndex(initial_active_index); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, false, false, false)); - WaitForInactiveTabIndex(initial_active_index); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - WaitForTabCount(initial_tab_count); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new window should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); - WaitForBrowserCount(initial_browser_count + 1); - ASSERT_EQ(initial_browser_count + 1, GetBrowserCount()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created window should be closed. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_W)); - WaitForBrowserCount(initial_browser_count); - - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); -} - -void BrowserCommandControllerInteractiveTest::FinishTestAndVerifyResult() { - // The renderer process receives key events through IPC channel, - // SendKeyPressSync() cannot guarantee the JS has processed the key event it - // sent. So we sent a KeyX to the webpage to indicate the end of the test - // case. After processing this key event, web page is safe to send the record - // back through window.domAutomationController. - EXPECT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_X, false, false, false, false)); - expected_result_ += "KeyX ctrl:false shift:false alt:false meta:false"; - std::string result; - EXPECT_TRUE(content::ExecuteScriptAndExtractString( - GetActiveWebContents()->GetRenderViewHost(), - "getKeyEventReport();", &result)); - NormalizeMetaKeyForMacOS(&result); - NormalizeMetaKeyForMacOS(&expected_result_); - base::TrimWhitespaceASCII(result, base::TRIM_ALL, &result); - ASSERT_EQ(expected_result_, result); -} - -void BrowserCommandControllerInteractiveTest::SetUpOnMainThread() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(GetActiveBrowser())); -} +using BrowserCommandControllerInteractiveTest = + FullscreenKeyboardBrowserTestBase; IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, ShortcutsShouldTakeEffectInWindowMode) {
diff --git a/chrome/browser/ui/cocoa/browser_window_touch_bar_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_touch_bar_browsertest.mm index 00084c7..b9b263eb 100644 --- a/chrome/browser/ui/cocoa/browser_window_touch_bar_browsertest.mm +++ b/chrome/browser/ui/cocoa/browser_window_touch_bar_browsertest.mm
@@ -11,7 +11,10 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/views/scoped_macviews_browser_mode.h" #include "components/prefs/pref_service.h" -#include "components/search_engines/search_engines_test_util.cc" +#include "components/search_engines/default_search_manager.h" +#include "components/search_engines/search_engines_test_util.h" +#include "components/search_engines/template_url_data.h" +#include "components/search_engines/template_url_data_util.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" #include "testing/gtest_mac.h"
diff --git a/chrome/browser/ui/enterprise_startup_dialog.h b/chrome/browser/ui/enterprise_startup_dialog.h index 8be64ea..62b53d8 100644 --- a/chrome/browser/ui/enterprise_startup_dialog.h +++ b/chrome/browser/ui/enterprise_startup_dialog.h
@@ -36,17 +36,16 @@ static std::unique_ptr<EnterpriseStartupDialog> CreateAndShowDialog( DialogResultCallback callback); - // Display |information| with a throbber. It changes the content of dialog + // Display |information| with a throbber. Changes the content of dialog // without re-opening it. virtual void DisplayLaunchingInformationWithThrobber( const base::string16& information) = 0; // Display |error_message| with an error icon. Show confirm button with - // value |accept_button| if provided. Same for the |cancel_button|. It changes - // the content of dialog without re-opening it. + // value |accept_button| if provided. Changes the content of dialog without + // re-opening it. virtual void DisplayErrorMessage( const base::string16& error_message, - const base::Optional<base::string16>& accept_button, - const base::Optional<base::string16>& cancel_button) = 0; + const base::Optional<base::string16>& accept_button) = 0; // Return true if dialog is being displayed. virtual bool IsShowing() = 0;
diff --git a/chrome/browser/ui/fullscreen_keyboard_browsertest_base.cc b/chrome/browser/ui/fullscreen_keyboard_browsertest_base.cc index 23cd55e5..58ed765 100644 --- a/chrome/browser/ui/fullscreen_keyboard_browsertest_base.cc +++ b/chrome/browser/ui/fullscreen_keyboard_browsertest_base.cc
@@ -1,7 +1,9 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/ui/fullscreen_keyboard_browsertest_base.h" + #include <memory> #include <string> @@ -48,133 +50,86 @@ } // namespace -class BrowserCommandControllerInteractiveTest : public InProcessBrowserTest { - public: - BrowserCommandControllerInteractiveTest() = default; - ~BrowserCommandControllerInteractiveTest() override = default; +FullscreenKeyboardBrowserTestBase::FullscreenKeyboardBrowserTestBase() = + default; - protected: - // Starts |kFullscreenKeyboardLockHTML| in a new tab and waits for load. - void StartFullscreenLockPage(); +FullscreenKeyboardBrowserTestBase::~FullscreenKeyboardBrowserTestBase() = + default; - // Sends a control or command + |key| shortcut to the focused window. Shift - // modifier will be added if |shift| is true. - void SendShortcut(ui::KeyboardCode key, bool shift = false); +net::EmbeddedTestServer* +FullscreenKeyboardBrowserTestBase::GetEmbeddedTestServer() { + return embedded_test_server(); +} - // Sends a control or command + shift + |key| shortcut to the focused window. - void SendShiftShortcut(ui::KeyboardCode key); +bool FullscreenKeyboardBrowserTestBase::IsActiveTabFullscreen() const { + auto* contents = GetActiveWebContents(); + return contents->GetDelegate()->IsFullscreenForTabOrPending(contents); +} - // Sends a fullscreen shortcut to the focused window and wait for the - // operation to take effect. - void SendFullscreenShortcutAndWait(); +bool FullscreenKeyboardBrowserTestBase::IsInBrowserFullscreen() const { + return GetActiveBrowser() + ->exclusive_access_manager() + ->fullscreen_controller() + ->IsFullscreenForBrowser(); +} - // Sends a KeyS to the focused window to trigger JavaScript fullscreen and - // wait for the operation to take effect. - void SendJsFullscreenShortcutAndWait(); +content::WebContents* FullscreenKeyboardBrowserTestBase::GetActiveWebContents() + const { + return GetActiveBrowser()->tab_strip_model()->GetActiveWebContents(); +} - // Sends an ESC to the focused window. - void SendEscape(); +int FullscreenKeyboardBrowserTestBase::GetActiveTabIndex() const { + return GetActiveBrowser()->tab_strip_model()->active_index(); +} - // Sends an ESC to the focused window to exit JavaScript fullscreen and wait - // for the operation to take effect. - void SendEscapeAndWaitForExitingFullscreen(); +int FullscreenKeyboardBrowserTestBase::GetTabCount() const { + return GetActiveBrowser()->tab_strip_model()->count(); +} - // Sends a set of preventable shortcuts to the web page and expects them to be - // prevented. - void SendShortcutsAndExpectPrevented(); +size_t FullscreenKeyboardBrowserTestBase::GetBrowserCount() const { + return BrowserList::GetInstance()->size(); +} - // Sends a set of preventable shortcuts to the web page and expects them to - // not be prevented. If |js_fullscreen| is true, the test will use - // SendJsFullscreenShortcutAndWait() to trigger the fullscreen mode. Otherwise - // SendFullscreenShortcutAndWait() will be used. - void SendShortcutsAndExpectNotPrevented(bool js_fullscreen); +Browser* FullscreenKeyboardBrowserTestBase::GetActiveBrowser() const { + return BrowserList::GetInstance()->GetLastActive(); +} - // Sends a magic KeyX to the focused window to stop the test case, receives - // the result and verifies if it is equal to |expected_result_|. - void FinishTestAndVerifyResult(); +Browser* FullscreenKeyboardBrowserTestBase::CreateNewBrowserInstance() { + Browser* first_instance = GetActiveBrowser(); + const size_t initial_browser_count = GetBrowserCount(); + EXPECT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); + WaitForBrowserCount(initial_browser_count + 1); + Browser* second_instance = GetActiveBrowser(); + EXPECT_NE(first_instance, second_instance); - // Returns whether the active tab is in html fullscreen mode. - bool IsActiveTabFullscreen() const { - auto* contents = GetActiveWebContents(); - return contents->GetDelegate()->IsFullscreenForTabOrPending(contents); - } + return second_instance; +} - // Returns whether the GetActiveBrowser() is in browser fullscreen mode. - bool IsInBrowserFullscreen() const { - return GetActiveBrowser() - ->exclusive_access_manager() - ->fullscreen_controller() - ->IsFullscreenForBrowser(); - } +void FullscreenKeyboardBrowserTestBase::FocusOnLastActiveBrowser() { + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(GetActiveBrowser())); +} - content::WebContents* GetActiveWebContents() const { - return GetActiveBrowser()->tab_strip_model()->GetActiveWebContents(); - } +void FullscreenKeyboardBrowserTestBase::WaitForBrowserCount(size_t expected) { + while (GetBrowserCount() != expected) + base::RunLoop().RunUntilIdle(); +} - // Gets the current active tab index. - int GetActiveTabIndex() const { - return GetActiveBrowser()->tab_strip_model()->active_index(); - } +void FullscreenKeyboardBrowserTestBase::WaitForTabCount(int expected) { + while (GetTabCount() != expected) + base::RunLoop().RunUntilIdle(); +} - // Gets the count of tabs in current browser. - int GetTabCount() const { - return GetActiveBrowser()->tab_strip_model()->count(); - } +void FullscreenKeyboardBrowserTestBase::WaitForActiveTabIndex(int expected) { + while (GetActiveTabIndex() != expected) + base::RunLoop().RunUntilIdle(); +} - // Gets the count of browser instances. - size_t GetBrowserCount() const { - return BrowserList::GetInstance()->size(); - } +void FullscreenKeyboardBrowserTestBase::WaitForInactiveTabIndex(int expected) { + while (GetActiveTabIndex() == expected) + base::RunLoop().RunUntilIdle(); +} - // Gets the last active Browser instance. - Browser* GetActiveBrowser() const { - return BrowserList::GetInstance()->GetLastActive(); - } - - // Ensures GetActiveBrowser() is focused. - void FocusOnLastActiveBrowser() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - GetActiveBrowser())); - } - - // Waits until the count of Browser instances becomes |expected|. - void WaitForBrowserCount(size_t expected) { - while (GetBrowserCount() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the count of the tabs in active Browser instance becomes - // |expected|. - void WaitForTabCount(int expected) { - while (GetTabCount() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the index of active tab in active Browser instance becomes - // |expected|. - void WaitForActiveTabIndex(int expected) { - while (GetActiveTabIndex() != expected) - content::RunAllPendingInMessageLoop(); - } - - // Waits until the index of active tab in active Browser instance is not - // |expected|. - void WaitForInactiveTabIndex(int expected) { - while (GetActiveTabIndex() == expected) - content::RunAllPendingInMessageLoop(); - } - - private: - void SetUpOnMainThread() override; - - // The expected output from the web page. This string is generated by - // appending key presses from Send* functions above. - std::string expected_result_; - - DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerInteractiveTest); -}; - -void BrowserCommandControllerInteractiveTest::StartFullscreenLockPage() { +void FullscreenKeyboardBrowserTestBase::StartFullscreenLockPage() { // Ensures the initial states. ASSERT_EQ(1, GetTabCount()); ASSERT_EQ(0, GetActiveTabIndex()); @@ -184,18 +139,17 @@ ASSERT_EQ(2, GetTabCount()); ASSERT_EQ(1U, GetBrowserCount()); - if (!embedded_test_server()->Started()) - ASSERT_TRUE(embedded_test_server()->Start()); + if (!GetEmbeddedTestServer()->Started()) + ASSERT_TRUE(GetEmbeddedTestServer()->Start()); ui_test_utils::NavigateToURLWithDisposition( GetActiveBrowser(), - embedded_test_server()->GetURL(kFullscreenKeyboardLockHTML), + GetEmbeddedTestServer()->GetURL(kFullscreenKeyboardLockHTML), WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); } -void BrowserCommandControllerInteractiveTest::SendShortcut( - ui::KeyboardCode key, - bool shift /* = false */) { +void FullscreenKeyboardBrowserTestBase::SendShortcut(ui::KeyboardCode key, + bool shift /* = false */) { #if defined(OS_MACOSX) const bool control_modifier = false; const bool command_modifier = true; @@ -203,9 +157,9 @@ const bool control_modifier = true; const bool command_modifier = false; #endif - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), key, control_modifier, shift, false, - command_modifier)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), key, + control_modifier, shift, false, + command_modifier)); expected_result_ += ui::KeycodeConverter::DomCodeToCodeString( ui::UsLayoutKeyboardCodeToDomCode(key)); @@ -219,29 +173,29 @@ expected_result_ += '\n'; } -void BrowserCommandControllerInteractiveTest::SendShiftShortcut( +void FullscreenKeyboardBrowserTestBase::SendShiftShortcut( ui::KeyboardCode key) { ASSERT_NO_FATAL_FAILURE(SendShortcut(key, true)); } -void BrowserCommandControllerInteractiveTest::SendFullscreenShortcutAndWait() { +void FullscreenKeyboardBrowserTestBase::SendFullscreenShortcutAndWait() { // On MacOSX, entering and exiting fullscreen are not synchronous. So we wait // for the observer to notice the change of fullscreen state. content::WindowedNotificationObserver observer( chrome::NOTIFICATION_FULLSCREEN_CHANGED, content::NotificationService::AllSources()); - // Enter fullscreen. +// Enter fullscreen. #if defined(OS_MACOSX) // On MACOSX, Command + Control + F is used. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F, true, false, false, true)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_F, + true, false, false, true)); #elif defined(OS_CHROMEOS) // A dedicated fullscreen key is used on Chrome OS, so send a fullscreen // command directly instead, to avoid constructing the key press. ASSERT_TRUE(chrome::ExecuteCommand(GetActiveBrowser(), IDC_FULLSCREEN)); #else - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F11, false, false, false, false)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_F11, + false, false, false, false)); #endif // Mac fullscreen is simulated in tests and is performed synchronously with the @@ -254,25 +208,24 @@ #endif } -void BrowserCommandControllerInteractiveTest:: - SendJsFullscreenShortcutAndWait() { +void FullscreenKeyboardBrowserTestBase::SendJsFullscreenShortcutAndWait() { content::WindowedNotificationObserver observer( chrome::NOTIFICATION_FULLSCREEN_CHANGED, content::NotificationService::AllSources()); - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_S, false, false, false, false)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_S, + false, false, false, false)); expected_result_ += "KeyS ctrl:false shift:false alt:false meta:false\n"; observer.Wait(); ASSERT_TRUE(IsActiveTabFullscreen()); } -void BrowserCommandControllerInteractiveTest::SendEscape() { +void FullscreenKeyboardBrowserTestBase::SendEscape() { ASSERT_TRUE(ui_test_utils::SendKeyPressSync( GetActiveBrowser(), ui::VKEY_ESCAPE, false, false, false, false)); expected_result_ += "Escape ctrl:false shift:false alt:false meta:false\n"; } -void BrowserCommandControllerInteractiveTest :: +void FullscreenKeyboardBrowserTestBase:: SendEscapeAndWaitForExitingFullscreen() { content::WindowedNotificationObserver observer( chrome::NOTIFICATION_FULLSCREEN_CHANGED, @@ -283,8 +236,7 @@ ASSERT_FALSE(IsActiveTabFullscreen()); } -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectPrevented() { +void FullscreenKeyboardBrowserTestBase::SendShortcutsAndExpectPrevented() { const int initial_active_index = GetActiveTabIndex(); const int initial_tab_count = GetTabCount(); const size_t initial_browser_count = GetBrowserCount(); @@ -314,14 +266,14 @@ ASSERT_EQ(initial_active_index, GetActiveTabIndex()); } -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectNotPrevented(bool js_fullscreen) { +void FullscreenKeyboardBrowserTestBase::SendShortcutsAndExpectNotPrevented( + bool js_fullscreen) { const int initial_active_index = GetActiveTabIndex(); const int initial_tab_count = GetTabCount(); const size_t initial_browser_count = GetBrowserCount(); const auto enter_fullscreen = [this, js_fullscreen]() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - this->GetActiveBrowser())); + ASSERT_TRUE( + ui_test_utils::BringBrowserWindowToFront(this->GetActiveBrowser())); if (js_fullscreen) { if (!this->IsActiveTabFullscreen()) { static const std::string page = @@ -334,8 +286,7 @@ " });" "</script></html>"; ui_test_utils::NavigateToURLWithDisposition( - this->GetActiveBrowser(), - GURL("data:text/html," + page), + this->GetActiveBrowser(), GURL("data:text/html," + page), WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); ASSERT_NO_FATAL_FAILURE(this->SendJsFullscreenShortcutAndWait()); @@ -372,16 +323,16 @@ ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); // The previous tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, true, false, false)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_TAB, + true, true, false, false)); WaitForActiveTabIndex(initial_active_index); ASSERT_EQ(initial_active_index, GetActiveTabIndex()); ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); // The newly created tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, false, false, false)); + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_TAB, + true, false, false, false)); WaitForInactiveTabIndex(initial_active_index); ASSERT_NE(initial_active_index, GetActiveTabIndex()); @@ -411,178 +362,79 @@ ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); } -void BrowserCommandControllerInteractiveTest::FinishTestAndVerifyResult() { +void FullscreenKeyboardBrowserTestBase::VerifyShortcutsAreNotPrevented() { + const int initial_active_index = GetActiveTabIndex(); + const int initial_tab_count = GetTabCount(); + const size_t initial_browser_count = GetBrowserCount(); + + // A new tab should be created and focused. + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + WaitForTabCount(initial_tab_count + 1); + ASSERT_NE(initial_active_index, GetActiveTabIndex()); + + // The newly created tab should be closed. + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); + WaitForTabCount(initial_tab_count); + ASSERT_EQ(initial_active_index, GetActiveTabIndex()); + + // A new tab should be created and focused. + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + WaitForTabCount(initial_tab_count + 1); + ASSERT_NE(initial_active_index, GetActiveTabIndex()); + + // The previous tab should be focused. + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_TAB, + true, true, false, false)); + WaitForActiveTabIndex(initial_active_index); + ASSERT_EQ(initial_active_index, GetActiveTabIndex()); + + // The newly created tab should be focused. + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_TAB, + true, false, false, false)); + WaitForInactiveTabIndex(initial_active_index); + ASSERT_NE(initial_active_index, GetActiveTabIndex()); + + // The newly created tab should be closed. + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); + WaitForTabCount(initial_tab_count); + ASSERT_EQ(initial_active_index, GetActiveTabIndex()); + + // A new window should be created and focused. + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); + WaitForBrowserCount(initial_browser_count + 1); + ASSERT_EQ(initial_browser_count + 1, GetBrowserCount()); + + // The newly created window should be closed. + ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_W)); + WaitForBrowserCount(initial_browser_count); + + ASSERT_EQ(initial_browser_count, GetBrowserCount()); + ASSERT_EQ(initial_active_index, GetActiveTabIndex()); +} + +void FullscreenKeyboardBrowserTestBase::FinishTestAndVerifyResult() { // The renderer process receives key events through IPC channel, // SendKeyPressSync() cannot guarantee the JS has processed the key event it // sent. So we sent a KeyX to the webpage to indicate the end of the test // case. After processing this key event, web page is safe to send the record // back through window.domAutomationController. - EXPECT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_X, false, false, false, false)); + EXPECT_TRUE(ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_X, + false, false, false, false)); expected_result_ += "KeyX ctrl:false shift:false alt:false meta:false"; std::string result; EXPECT_TRUE(content::ExecuteScriptAndExtractString( - GetActiveWebContents()->GetRenderViewHost(), - "getKeyEventReport();", &result)); + GetActiveWebContents()->GetRenderViewHost(), "getKeyEventReport();", + &result)); NormalizeMetaKeyForMacOS(&result); NormalizeMetaKeyForMacOS(&expected_result_); base::TrimWhitespaceASCII(result, base::TRIM_ALL, &result); ASSERT_EQ(expected_result_, result); } -void BrowserCommandControllerInteractiveTest::SetUpOnMainThread() { +std::string FullscreenKeyboardBrowserTestBase::GetFullscreenFramePath() { + return kFullscreenKeyboardLockHTML; +} + +void FullscreenKeyboardBrowserTestBase::SetUpOnMainThread() { ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(GetActiveBrowser())); } - -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - ShortcutsShouldTakeEffectInWindowMode) { - ASSERT_EQ(1, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(2, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(3, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(2, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(1, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_TRUE(IsInBrowserFullscreen()); - ASSERT_FALSE(IsActiveTabFullscreen()); -} - -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - UnpreservedShortcutsShouldBePreventable) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - // The browser print function should be blocked by the web page. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_P)); - // The system print function should be blocked by the web page. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_P)); - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// TODO(zijiehe): Figure out why this test crashes on Mac OSX. The suspicious -// command is "SendFullscreenShortcutAndWait()". See, http://crbug.com/738949. -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen \ - DISABLED_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen -#else -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen \ - KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen -#endif -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_TRUE(IsInBrowserFullscreen()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); - // Current page should not exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendEscape()); - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); - - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); -} - -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForEsc) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); - // Current page should exit HTML fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendEscapeAndWaitForExitingFullscreen()); - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// Triggers a DCHECK in MacViews: http://crbug.com/823478 -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 \ - DISABLED_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 -#else -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 \ - KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 -#endif -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); -#if defined(OS_MACOSX) - // On 10.9 or earlier, sending the exit fullscreen shortcut will crash the - // binary. See http://crbug.com/740250. - if (base::mac::IsAtLeastOS10_10()) { - // Current page should exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); - } -#else - // Current page should exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); -#endif - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// TODO(zijiehe): Figure out why this test crashes on Mac OSX. The suspicious -// command is "SendFullscreenShortcutAndWait()". See, http://crbug.com/738949. -#define MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen \ - DISABLED_ShortcutsShouldTakeEffectInBrowserFullscreen -#else -#define MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen \ - ShortcutsShouldTakeEffectInBrowserFullscreen -#endif -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen) { -#if defined(OS_MACOSX) - // On 10.9 or earlier, sending the exit fullscreen shortcut will crash the - // binary. See http://crbug.com/740250. - if (base::mac::IsAtMostOS10_9()) - return; -#endif - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectNotPrevented(false)); -} - -#if !defined(OS_MACOSX) -// HTML fullscreen is automatically exited after some commands are executed, -// such as Ctrl + T (new tab). But some commands won't have this effect, such as -// Ctrl + N (new window). -// On Mac OSX, AppKit implementation is used for HTML fullscreen mode. Entering -// and exiting AppKit fullscreen mode triggers an animation. A -// FullscreenChangeObserver is needed to ensure the animation is finished. But -// the FullscreenChangeObserver won't finish if the command actually won't cause -// the page to exit fullscreen mode. So we need to maintain a list of exiting / -// non-exiting commands, which is not the goal of this test. - -#if defined(OS_CHROMEOS) -// This test is flaky on ChromeOS, see http://crbug.com/754878. -#define MAYBE_ShortcutsShouldTakeEffectInJsFullscreen \ - DISABLED_ShortcutsShouldTakeEffectInJsFullscreen -#else -#define MAYBE_ShortcutsShouldTakeEffectInJsFullscreen \ - ShortcutsShouldTakeEffectInJsFullscreen -#endif -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - MAYBE_ShortcutsShouldTakeEffectInJsFullscreen) { -// This test is flaky. See http://crbug.com/759704. -// TODO(zijiehe): Find out the root cause. -#if defined(OS_LINUX) - return; -#endif - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectNotPrevented(true)); -} - -#endif
diff --git a/chrome/browser/ui/fullscreen_keyboard_browsertest_base.h b/chrome/browser/ui/fullscreen_keyboard_browsertest_base.h index 23cd55e5..01c4585 100644 --- a/chrome/browser/ui/fullscreen_keyboard_browsertest_base.h +++ b/chrome/browser/ui/fullscreen_keyboard_browsertest_base.h
@@ -1,59 +1,35 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <memory> +#ifndef CHROME_BROWSER_UI_FULLSCREEN_KEYBOARD_BROWSERTEST_BASE_H_ +#define CHROME_BROWSER_UI_FULLSCREEN_KEYBOARD_BROWSERTEST_BASE_H_ + #include <string> #include "base/macros.h" -#include "base/strings/string_util.h" -#include "build/build_config.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/interactive_test_utils.h" -#include "content/public/browser/notification_service.h" -#include "content/public/test/browser_test_utils.h" -#include "content/public/test/test_utils.h" -#include "ui/events/keycodes/dom/keycode_converter.h" -#include "ui/events/keycodes/keyboard_code_conversion.h" +#include "net/test/embedded_test_server/embedded_test_server.h" #include "ui/events/keycodes/keyboard_codes.h" -#include "url/gurl.h" -#include "url/url_constants.h" -#if defined(OS_MACOSX) -#include "base/mac/mac_util.h" -#endif - -namespace { - -// The html file to receive key events, prevent defaults and export all the -// events with "getKeyEventReport()" function. It has two magic keys: pressing -// "S" to enter fullscreen mode; pressing "X" to indicate the end of all the -// keys (see FinishTestAndVerifyResult() function). -constexpr char kFullscreenKeyboardLockHTML[] = - "/fullscreen_keyboardlock/fullscreen_keyboardlock.html"; - -// On MacOSX command key is used for most of the shortcuts, so replace it with -// control to reduce the complexity of comparison of the results. -void NormalizeMetaKeyForMacOS(std::string* output) { -#if defined(OS_MACOSX) - base::ReplaceSubstringsAfterOffset(output, 0, "MetaLeft", "ControlLeft"); -#endif +namespace content { +class WebContents; } -} // namespace +class Browser; -class BrowserCommandControllerInteractiveTest : public InProcessBrowserTest { +class FullscreenKeyboardBrowserTestBase : public InProcessBrowserTest { public: - BrowserCommandControllerInteractiveTest() = default; - ~BrowserCommandControllerInteractiveTest() override = default; + FullscreenKeyboardBrowserTestBase(); + ~FullscreenKeyboardBrowserTestBase() override; protected: + // InProcessBrowserTest override; + void SetUpOnMainThread() override; + + // Overridable to allow for custom test servers. + virtual net::EmbeddedTestServer* GetEmbeddedTestServer(); + // Starts |kFullscreenKeyboardLockHTML| in a new tab and waits for load. void StartFullscreenLockPage(); @@ -89,500 +65,64 @@ // SendFullscreenShortcutAndWait() will be used. void SendShortcutsAndExpectNotPrevented(bool js_fullscreen); + // Sends multiple shortcuts using the current window mode (i.e. fullscreen) + // and verifies they have no effect on the current browser instance. + void VerifyShortcutsAreNotPrevented(); + // Sends a magic KeyX to the focused window to stop the test case, receives // the result and verifies if it is equal to |expected_result_|. void FinishTestAndVerifyResult(); // Returns whether the active tab is in html fullscreen mode. - bool IsActiveTabFullscreen() const { - auto* contents = GetActiveWebContents(); - return contents->GetDelegate()->IsFullscreenForTabOrPending(contents); - } + bool IsActiveTabFullscreen() const; // Returns whether the GetActiveBrowser() is in browser fullscreen mode. - bool IsInBrowserFullscreen() const { - return GetActiveBrowser() - ->exclusive_access_manager() - ->fullscreen_controller() - ->IsFullscreenForBrowser(); - } + bool IsInBrowserFullscreen() const; - content::WebContents* GetActiveWebContents() const { - return GetActiveBrowser()->tab_strip_model()->GetActiveWebContents(); - } + content::WebContents* GetActiveWebContents() const; // Gets the current active tab index. - int GetActiveTabIndex() const { - return GetActiveBrowser()->tab_strip_model()->active_index(); - } + int GetActiveTabIndex() const; // Gets the count of tabs in current browser. - int GetTabCount() const { - return GetActiveBrowser()->tab_strip_model()->count(); - } + int GetTabCount() const; // Gets the count of browser instances. - size_t GetBrowserCount() const { - return BrowserList::GetInstance()->size(); - } + size_t GetBrowserCount() const; // Gets the last active Browser instance. - Browser* GetActiveBrowser() const { - return BrowserList::GetInstance()->GetLastActive(); - } + Browser* GetActiveBrowser() const; + + // Creates a new browser instance. Returns a pointer to the new instance. + Browser* CreateNewBrowserInstance(); // Ensures GetActiveBrowser() is focused. - void FocusOnLastActiveBrowser() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - GetActiveBrowser())); - } + void FocusOnLastActiveBrowser(); // Waits until the count of Browser instances becomes |expected|. - void WaitForBrowserCount(size_t expected) { - while (GetBrowserCount() != expected) - content::RunAllPendingInMessageLoop(); - } + void WaitForBrowserCount(size_t expected); // Waits until the count of the tabs in active Browser instance becomes // |expected|. - void WaitForTabCount(int expected) { - while (GetTabCount() != expected) - content::RunAllPendingInMessageLoop(); - } + void WaitForTabCount(int expected); // Waits until the index of active tab in active Browser instance becomes // |expected|. - void WaitForActiveTabIndex(int expected) { - while (GetActiveTabIndex() != expected) - content::RunAllPendingInMessageLoop(); - } + void WaitForActiveTabIndex(int expected); // Waits until the index of active tab in active Browser instance is not // |expected|. - void WaitForInactiveTabIndex(int expected) { - while (GetActiveTabIndex() == expected) - content::RunAllPendingInMessageLoop(); - } + void WaitForInactiveTabIndex(int expected); + + // Returns the path for the fullscreen webpage used for testing. + std::string GetFullscreenFramePath(); private: - void SetUpOnMainThread() override; - // The expected output from the web page. This string is generated by // appending key presses from Send* functions above. std::string expected_result_; - DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerInteractiveTest); + DISALLOW_COPY_AND_ASSIGN(FullscreenKeyboardBrowserTestBase); }; -void BrowserCommandControllerInteractiveTest::StartFullscreenLockPage() { - // Ensures the initial states. - ASSERT_EQ(1, GetTabCount()); - ASSERT_EQ(0, GetActiveTabIndex()); - ASSERT_EQ(1U, GetBrowserCount()); - // Add a second tab for counting and focus purposes. - AddTabAtIndex(1, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); - ASSERT_EQ(2, GetTabCount()); - ASSERT_EQ(1U, GetBrowserCount()); - - if (!embedded_test_server()->Started()) - ASSERT_TRUE(embedded_test_server()->Start()); - ui_test_utils::NavigateToURLWithDisposition( - GetActiveBrowser(), - embedded_test_server()->GetURL(kFullscreenKeyboardLockHTML), - WindowOpenDisposition::CURRENT_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); -} - -void BrowserCommandControllerInteractiveTest::SendShortcut( - ui::KeyboardCode key, - bool shift /* = false */) { -#if defined(OS_MACOSX) - const bool control_modifier = false; - const bool command_modifier = true; -#else - const bool control_modifier = true; - const bool command_modifier = false; -#endif - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), key, control_modifier, shift, false, - command_modifier)); - - expected_result_ += ui::KeycodeConverter::DomCodeToCodeString( - ui::UsLayoutKeyboardCodeToDomCode(key)); - expected_result_ += " ctrl:"; - expected_result_ += control_modifier ? "true" : "false"; - expected_result_ += " shift:"; - expected_result_ += shift ? "true" : "false"; - expected_result_ += " alt:false"; - expected_result_ += " meta:"; - expected_result_ += command_modifier ? "true" : "false"; - expected_result_ += '\n'; -} - -void BrowserCommandControllerInteractiveTest::SendShiftShortcut( - ui::KeyboardCode key) { - ASSERT_NO_FATAL_FAILURE(SendShortcut(key, true)); -} - -void BrowserCommandControllerInteractiveTest::SendFullscreenShortcutAndWait() { - // On MacOSX, entering and exiting fullscreen are not synchronous. So we wait - // for the observer to notice the change of fullscreen state. - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - // Enter fullscreen. -#if defined(OS_MACOSX) - // On MACOSX, Command + Control + F is used. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F, true, false, false, true)); -#elif defined(OS_CHROMEOS) - // A dedicated fullscreen key is used on Chrome OS, so send a fullscreen - // command directly instead, to avoid constructing the key press. - ASSERT_TRUE(chrome::ExecuteCommand(GetActiveBrowser(), IDC_FULLSCREEN)); -#else - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_F11, false, false, false, false)); -#endif - -// Mac fullscreen is simulated in tests and is performed synchronously with the -// keyboard events. As a result, content doesn't actually know it has entered -// fullscreen. For more details, see ScopedFakeNSWindowFullscreen. -// TODO(crbug.com/837438): Remove this once ScopedFakeNSWindowFullscreen fires -// NOTIFICATION_FULLSCREEN_CHANGED. -#if !defined(OS_MACOSX) - observer.Wait(); -#endif -} - -void BrowserCommandControllerInteractiveTest:: - SendJsFullscreenShortcutAndWait() { - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_S, false, false, false, false)); - expected_result_ += "KeyS ctrl:false shift:false alt:false meta:false\n"; - observer.Wait(); - ASSERT_TRUE(IsActiveTabFullscreen()); -} - -void BrowserCommandControllerInteractiveTest::SendEscape() { - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_ESCAPE, false, false, false, false)); - expected_result_ += "Escape ctrl:false shift:false alt:false meta:false\n"; -} - -void BrowserCommandControllerInteractiveTest :: - SendEscapeAndWaitForExitingFullscreen() { - content::WindowedNotificationObserver observer( - chrome::NOTIFICATION_FULLSCREEN_CHANGED, - content::NotificationService::AllSources()); - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_ESCAPE, false, false, false, false)); - observer.Wait(); - ASSERT_FALSE(IsActiveTabFullscreen()); -} - -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectPrevented() { - const int initial_active_index = GetActiveTabIndex(); - const int initial_tab_count = GetTabCount(); - const size_t initial_browser_count = GetBrowserCount(); - // The tab should not be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // The window should not be closed. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_W)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // A new tab should not be created. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // A new window should not be created. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // A new incognito window should not be created. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_N)); - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - // Last closed tab should not be restored. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_T)); - ASSERT_EQ(initial_tab_count, GetTabCount()); - // Browser should not switch to the next tab. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_TAB)); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - // Browser should not switch to the previous tab. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_TAB)); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); -} - -void BrowserCommandControllerInteractiveTest:: - SendShortcutsAndExpectNotPrevented(bool js_fullscreen) { - const int initial_active_index = GetActiveTabIndex(); - const int initial_tab_count = GetTabCount(); - const size_t initial_browser_count = GetBrowserCount(); - const auto enter_fullscreen = [this, js_fullscreen]() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront( - this->GetActiveBrowser())); - if (js_fullscreen) { - if (!this->IsActiveTabFullscreen()) { - static const std::string page = - "<html><head></head><body></body><script>" - "document.addEventListener('keydown', " - " (e) => {" - " if (e.code == 'KeyS') { " - " document.body.webkitRequestFullscreen();" - " }" - " });" - "</script></html>"; - ui_test_utils::NavigateToURLWithDisposition( - this->GetActiveBrowser(), - GURL("data:text/html," + page), - WindowOpenDisposition::CURRENT_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - ASSERT_NO_FATAL_FAILURE(this->SendJsFullscreenShortcutAndWait()); - } - } else { - if (!this->IsInBrowserFullscreen()) { - ASSERT_NO_FATAL_FAILURE(this->SendFullscreenShortcutAndWait()); - } - ASSERT_TRUE(this->IsInBrowserFullscreen()); - } - }; - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new tab should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - WaitForTabCount(initial_tab_count + 1); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - WaitForTabCount(initial_tab_count); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new tab should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - WaitForTabCount(initial_tab_count + 1); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The previous tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, true, false, false)); - WaitForActiveTabIndex(initial_active_index); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be focused. - ASSERT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_TAB, true, false, false, false)); - WaitForInactiveTabIndex(initial_active_index); - ASSERT_NE(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created tab should be closed. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - WaitForTabCount(initial_tab_count); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // A new window should be created and focused. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); - WaitForBrowserCount(initial_browser_count + 1); - ASSERT_EQ(initial_browser_count + 1, GetBrowserCount()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); - - // The newly created window should be closed. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_W)); - WaitForBrowserCount(initial_browser_count); - - ASSERT_EQ(initial_browser_count, GetBrowserCount()); - ASSERT_EQ(initial_active_index, GetActiveTabIndex()); - - ASSERT_NO_FATAL_FAILURE(enter_fullscreen()); -} - -void BrowserCommandControllerInteractiveTest::FinishTestAndVerifyResult() { - // The renderer process receives key events through IPC channel, - // SendKeyPressSync() cannot guarantee the JS has processed the key event it - // sent. So we sent a KeyX to the webpage to indicate the end of the test - // case. After processing this key event, web page is safe to send the record - // back through window.domAutomationController. - EXPECT_TRUE(ui_test_utils::SendKeyPressSync( - GetActiveBrowser(), ui::VKEY_X, false, false, false, false)); - expected_result_ += "KeyX ctrl:false shift:false alt:false meta:false"; - std::string result; - EXPECT_TRUE(content::ExecuteScriptAndExtractString( - GetActiveWebContents()->GetRenderViewHost(), - "getKeyEventReport();", &result)); - NormalizeMetaKeyForMacOS(&result); - NormalizeMetaKeyForMacOS(&expected_result_); - base::TrimWhitespaceASCII(result, base::TRIM_ALL, &result); - ASSERT_EQ(expected_result_, result); -} - -void BrowserCommandControllerInteractiveTest::SetUpOnMainThread() { - ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(GetActiveBrowser())); -} - -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - ShortcutsShouldTakeEffectInWindowMode) { - ASSERT_EQ(1, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(2, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); - ASSERT_EQ(3, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(2, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); - ASSERT_EQ(1, GetTabCount()); - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_TRUE(IsInBrowserFullscreen()); - ASSERT_FALSE(IsActiveTabFullscreen()); -} - -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - UnpreservedShortcutsShouldBePreventable) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - // The browser print function should be blocked by the web page. - ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_P)); - // The system print function should be blocked by the web page. - ASSERT_NO_FATAL_FAILURE(SendShiftShortcut(ui::VKEY_P)); - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// TODO(zijiehe): Figure out why this test crashes on Mac OSX. The suspicious -// command is "SendFullscreenShortcutAndWait()". See, http://crbug.com/738949. -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen \ - DISABLED_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen -#else -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen \ - KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen -#endif -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - MAYBE_KeyEventsShouldBeConsumedByWebPageInBrowserFullscreen) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_TRUE(IsInBrowserFullscreen()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); - // Current page should not exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendEscape()); - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); - - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); -} - -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForEsc) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); - // Current page should exit HTML fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendEscapeAndWaitForExitingFullscreen()); - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// Triggers a DCHECK in MacViews: http://crbug.com/823478 -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 \ - DISABLED_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 -#else -#define MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 \ - KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11 -#endif -IN_PROC_BROWSER_TEST_F( - BrowserCommandControllerInteractiveTest, - MAYBE_KeyEventsShouldBeConsumedByWebPageInJsFullscreenExceptForF11) { - ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); - - ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); -#if defined(OS_MACOSX) - // On 10.9 or earlier, sending the exit fullscreen shortcut will crash the - // binary. See http://crbug.com/740250. - if (base::mac::IsAtLeastOS10_10()) { - // Current page should exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); - } -#else - // Current page should exit browser fullscreen mode. - ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); - ASSERT_FALSE(IsActiveTabFullscreen()); - ASSERT_FALSE(IsInBrowserFullscreen()); -#endif - - ASSERT_NO_FATAL_FAILURE(FinishTestAndVerifyResult()); -} - -#if defined(OS_MACOSX) -// TODO(zijiehe): Figure out why this test crashes on Mac OSX. The suspicious -// command is "SendFullscreenShortcutAndWait()". See, http://crbug.com/738949. -#define MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen \ - DISABLED_ShortcutsShouldTakeEffectInBrowserFullscreen -#else -#define MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen \ - ShortcutsShouldTakeEffectInBrowserFullscreen -#endif -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - MAYBE_ShortcutsShouldTakeEffectInBrowserFullscreen) { -#if defined(OS_MACOSX) - // On 10.9 or earlier, sending the exit fullscreen shortcut will crash the - // binary. See http://crbug.com/740250. - if (base::mac::IsAtMostOS10_9()) - return; -#endif - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectNotPrevented(false)); -} - -#if !defined(OS_MACOSX) -// HTML fullscreen is automatically exited after some commands are executed, -// such as Ctrl + T (new tab). But some commands won't have this effect, such as -// Ctrl + N (new window). -// On Mac OSX, AppKit implementation is used for HTML fullscreen mode. Entering -// and exiting AppKit fullscreen mode triggers an animation. A -// FullscreenChangeObserver is needed to ensure the animation is finished. But -// the FullscreenChangeObserver won't finish if the command actually won't cause -// the page to exit fullscreen mode. So we need to maintain a list of exiting / -// non-exiting commands, which is not the goal of this test. - -#if defined(OS_CHROMEOS) -// This test is flaky on ChromeOS, see http://crbug.com/754878. -#define MAYBE_ShortcutsShouldTakeEffectInJsFullscreen \ - DISABLED_ShortcutsShouldTakeEffectInJsFullscreen -#else -#define MAYBE_ShortcutsShouldTakeEffectInJsFullscreen \ - ShortcutsShouldTakeEffectInJsFullscreen -#endif -IN_PROC_BROWSER_TEST_F(BrowserCommandControllerInteractiveTest, - MAYBE_ShortcutsShouldTakeEffectInJsFullscreen) { -// This test is flaky. See http://crbug.com/759704. -// TODO(zijiehe): Find out the root cause. -#if defined(OS_LINUX) - return; -#endif - ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectNotPrevented(true)); -} - -#endif +#endif // CHROME_BROWSER_UI_FULLSCREEN_KEYBOARD_BROWSERTEST_BASE_H_
diff --git a/chrome/browser/ui/keyboard_lock_interactive_browsertest.cc b/chrome/browser/ui/keyboard_lock_interactive_browsertest.cc new file mode 100644 index 0000000..333f790 --- /dev/null +++ b/chrome/browser/ui/keyboard_lock_interactive_browsertest.cc
@@ -0,0 +1,589 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/macros.h" +#include "base/test/scoped_feature_list.h" +#include "build/build_config.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/fullscreen_keyboard_browsertest_base.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/interactive_test_utils.h" +#include "chrome/test/base/ui_test_utils.h" +#include "content/public/browser/render_widget_host_view.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/content_features.h" +#include "content/public/test/browser_test_utils.h" +#include "net/dns/mock_host_resolver.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "ui/base/ui_base_features.h" + +namespace { + +// Javascript snippet used to verify the keyboard lock API exists. +// TODO(crbug.com/680809): These checks can be removed once the blink flag for +// the API is removed. +constexpr char kKeyboardLockMethodExistanceCheck[] = + "window.domAutomationController.send(" + " (navigator.keyboard != undefined) &&" + " (navigator.keyboard.lock != undefined));"; + +// Javascript snippet used to request that all keys be locked. +constexpr char kKeyboardLockMethodCallWithAllKeys[] = + "navigator.keyboard.lock().then(" + " () => { window.domAutomationController.send(true); }," + " () => { window.domAutomationController.send(false); }," + ");"; + +// Javascript snippet used to request that the 'T' key be locked. This means +// The Ctrl+T browser shortcut will be intercepted, but other shortcuts should +// continue to function. +constexpr char kKeyboardLockMethodCallWithSomeKeys[] = + "navigator.keyboard.lock(['KeyT']).then(" + " () => { window.domAutomationController.send(true); }," + " () => { window.domAutomationController.send(false); }," + ");"; + +// Javascript snippet used to request that the 'escape' key be locked. This +// means that all browser shortcuts will continue to work however the user would +// need to press and hold escape to exit tab-initiated fullscreen. +constexpr char kKeyboardLockMethodCallWithEscapeKey[] = + "navigator.keyboard.lock(['Escape']).then(" + " () => { window.domAutomationController.send(true); }," + " () => { window.domAutomationController.send(false); }," + ");"; + +// Javascript snippet used to release all locked keys. +constexpr char kKeyboardUnlockMethodCall[] = "navigator.keyboard.unlock()"; + +// Path to a simple html fragment, used for navigation tests. +constexpr char kSimplePageHTML[] = "/title1.html"; + +// The test data folder path used for download tests. +constexpr char kDownloadFolder[] = "downloads"; + +// Name of the test file used for download tests. +constexpr char kDownloadFile[] = "a_zip_file.zip"; + +} // namespace + +// Test fixture which sets up the environment and provides helper methods for +// testing keyboard lock functionality at the browser UI level. +class KeyboardLockInteractiveBrowserTest + : public FullscreenKeyboardBrowserTestBase { + public: + KeyboardLockInteractiveBrowserTest(); + ~KeyboardLockInteractiveBrowserTest() override; + + // FullscreenKeyboardBrowserTestBase implementation. + net::EmbeddedTestServer* GetEmbeddedTestServer() override; + + protected: + // InProcessBrowserTest overrides. + void SetUpCommandLine(base::CommandLine* command_line) override; + void SetUpOnMainThread() override; + + // Helper methods for common tasks. + bool KeyboardLockApiExists(); + bool IsKeyboardLockActive(); + bool IsKeyboardLockRequestRegistered(); + bool RequestKeyboardLock(bool lock_all_keys = true); + bool CancelKeyboardLock(); + bool DisablePreventDefaultOnTestPage(); + + ExclusiveAccessManager* GetExclusiveAccessManager() { + return browser()->exclusive_access_manager(); + } + + KeyboardLockController* GetKeyboardLockController() { + return GetExclusiveAccessManager()->keyboard_lock_controller(); + } + + private: + base::test::ScopedFeatureList scoped_feature_list_; + net::EmbeddedTestServer https_test_server_; + + DISALLOW_COPY_AND_ASSIGN(KeyboardLockInteractiveBrowserTest); +}; + +KeyboardLockInteractiveBrowserTest::KeyboardLockInteractiveBrowserTest() + : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS) {} + +KeyboardLockInteractiveBrowserTest::~KeyboardLockInteractiveBrowserTest() = + default; + +void KeyboardLockInteractiveBrowserTest::SetUpCommandLine( + base::CommandLine* command_line) { + // Ensure the KeyboardLockAPI is enabled and system keyboard lock is disabled. + // It is important to disable system keyboard lock as the low-level test + // utility functions install a keyboard hook to listen for key events and the + // keyboard lock hook can interfere with it. + scoped_feature_list_.InitWithFeatures({features::kKeyboardLockAPI}, + {features::kSystemKeyboardLock}); +} + +void KeyboardLockInteractiveBrowserTest::SetUpOnMainThread() { + GetEmbeddedTestServer()->AddDefaultHandlers( + base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); + ASSERT_TRUE(GetEmbeddedTestServer()->Start()); + FullscreenKeyboardBrowserTestBase::SetUpOnMainThread(); +} + +net::EmbeddedTestServer* +KeyboardLockInteractiveBrowserTest::GetEmbeddedTestServer() { + // KeyboardLock requires a secure context (HTTPS). The default test server + // uses HTTP so we use our own test server which we initialize to use HTTPS. + return &https_test_server_; +} + +bool KeyboardLockInteractiveBrowserTest::KeyboardLockApiExists() { + bool api_exists = false; + EXPECT_TRUE(ExecuteScriptAndExtractBool( + GetActiveWebContents(), kKeyboardLockMethodExistanceCheck, &api_exists)); + return api_exists; +} + +bool KeyboardLockInteractiveBrowserTest::IsKeyboardLockActive() { + return GetActiveWebContents()->GetRenderWidgetHostView()->IsKeyboardLocked(); +} + +bool KeyboardLockInteractiveBrowserTest::IsKeyboardLockRequestRegistered() { + return content::GetKeyboardLockWidget(GetActiveWebContents()) != nullptr; +} + +bool KeyboardLockInteractiveBrowserTest::RequestKeyboardLock( + bool lock_all_keys /*=true*/) { + bool result = false; + // keyboard.lock() is an async call which requires a promise handling dance. + EXPECT_TRUE(ExecuteScriptAndExtractBool( + GetActiveWebContents(), + lock_all_keys ? kKeyboardLockMethodCallWithAllKeys + : kKeyboardLockMethodCallWithSomeKeys, + &result)); + + return result; +} + +bool KeyboardLockInteractiveBrowserTest::CancelKeyboardLock() { + // keyboard.unlock() is a synchronous call. + return ExecuteScript(GetActiveWebContents(), kKeyboardUnlockMethodCall); +} + +bool KeyboardLockInteractiveBrowserTest::DisablePreventDefaultOnTestPage() { + // We cannot test browser shortcuts in JS fullscreen with the default webpage + // behavior as it will prevent default on every keypress. Since we want to + // test whether the browser does the right thing when receiving a shortcut, we + // tell the test webpage not to prevent default on key events. + // Note that some tests will want the prevent default behavior to ensure + // certain keys, such as escape, cannot be prevented by the webpage. + return ui_test_utils::SendKeyPressSync(GetActiveBrowser(), ui::VKEY_D, false, + false, false, false); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + RequestedButNotActive) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + ASSERT_TRUE(KeyboardLockApiExists()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Requesting keyboard lock does not engage until tab-initiated fullscreen. + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Common browser shortcuts (new tab/window) should take effect. + ASSERT_NO_FATAL_FAILURE(VerifyShortcutsAreNotPrevented()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + ActiveWithAllKeysLocked) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + ASSERT_TRUE(KeyboardLockApiExists()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + ASSERT_FALSE(IsInBrowserFullscreen()); + ASSERT_FALSE(IsActiveTabFullscreen()); + + // Requesting keyboard lock does not engage until tab-initiated fullscreen. + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Tab-initiated fullscreen (JS API) does engage keyboard lock. + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_FALSE(IsInBrowserFullscreen()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press does not exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_FALSE(IsInBrowserFullscreen()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Common browser shortcuts (new tab/window) should not take effect. + ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + ActiveWithSomeKeysLocked) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + + ASSERT_NO_FATAL_FAILURE(VerifyShortcutsAreNotPrevented()); + + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // New Tab shortcut is prevented. + int initial_tab_count = GetTabCount(); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + ASSERT_EQ(initial_tab_count, GetTabCount()); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + ASSERT_EQ(initial_tab_count, GetTabCount()); + + // New Window shortcut is not prevented. + size_t initial_browser_count = GetBrowserCount(); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_N)); + WaitForBrowserCount(initial_browser_count + 1); + ASSERT_EQ(initial_browser_count + 1, GetBrowserCount()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + SubsequentLockCallSupersedesPreviousCall) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + // First we lock all keys. + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/true)); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press does not exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Shortcuts are now prevented from having an effect. + ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); + + // Now, Only lock the escape key. + bool result = false; + ASSERT_TRUE(ExecuteScriptAndExtractBool( + GetActiveWebContents(), kKeyboardLockMethodCallWithEscapeKey, &result)); + ASSERT_TRUE(result); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press does not exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Common shortcuts should work now. + int initial_tab_count = GetTabCount(); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + WaitForTabCount(initial_tab_count + 1); + ASSERT_EQ(initial_tab_count + 1, GetTabCount()); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_W)); + WaitForTabCount(initial_tab_count); + ASSERT_EQ(initial_tab_count, GetTabCount()); + + // Creating a new tab will kick us out of fullscreen, verify that and then + // request fullscreen again. + ASSERT_FALSE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Lock all keys again. + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/true)); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press does not exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Shortcuts are prevented from having an effect. + ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); + + // Last, update the set of keys being requested so escape is not locked. + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press will now exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_FALSE(IsActiveTabFullscreen()); + ASSERT_FALSE(IsKeyboardLockActive()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + RequestedButNotActiveInBrowserFullscreen) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + ASSERT_TRUE(KeyboardLockApiExists()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Requesting keyboard lock does not engage until tab-initiated fullscreen. + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Browser fullscreen (F11) does not engage keyboard lock. + ASSERT_NO_FATAL_FAILURE(SendFullscreenShortcutAndWait()); + ASSERT_TRUE(IsInBrowserFullscreen()); + ASSERT_FALSE(IsActiveTabFullscreen()); + ASSERT_FALSE(IsKeyboardLockActive()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + CancelActiveKeyboardLockInFullscreen) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + // Requesting keyboard lock does not engage until tab-initiated fullscreen. + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Tab-initiated fullscreen (JS API) does engage keyboard lock. + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_FALSE(IsInBrowserFullscreen()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Common browser shortcuts (new tab/window) should not take effect. + ASSERT_NO_FATAL_FAILURE(SendShortcutsAndExpectPrevented()); + + // Cancel keyboard lock while in fullscreen. + ASSERT_TRUE(CancelKeyboardLock()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // New Tab shortcut is no longer prevented. + int initial_tab_count = GetTabCount(); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + WaitForTabCount(initial_tab_count + 1); + ASSERT_EQ(initial_tab_count + 1, GetTabCount()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + CancelActiveKeyboardLockBeforeFullscreen) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + // Requesting keyboard lock does not engage until tab-initiated fullscreen. + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Cancel keyboard lock before fullscreen. + ASSERT_TRUE(CancelKeyboardLock()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // Tab-initiated fullscreen (JS API) does not engage keyboard lock. + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_FALSE(IsInBrowserFullscreen()); + ASSERT_TRUE(IsActiveTabFullscreen()); + ASSERT_FALSE(IsKeyboardLockActive()); + + // New Tab shortcut is no longer prevented. + int initial_tab_count = GetTabCount(); + ASSERT_NO_FATAL_FAILURE(SendShortcut(ui::VKEY_T)); + WaitForTabCount(initial_tab_count + 1); + ASSERT_EQ(initial_tab_count + 1, GetTabCount()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + PressEscapeExitsFullscreenWhenEscNotLocked) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + // Do not disable prevent default behavior. This ensures a webpage cannot + // prevent the user from exiting fullscreen. + + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + // Single escape key press does exit fullscreen. + ASSERT_NO_FATAL_FAILURE(SendEscape()); + ASSERT_FALSE(IsActiveTabFullscreen()); + ASSERT_FALSE(IsKeyboardLockActive()); +} + +#if defined(OS_LINUX) +// BringBrowserWindowToFront hangs on Linux: http://crbug.com/163931 +#define MAYBE_GainAndLoseFocusInWindowMode DISABLED_GainAndLoseFocusInWindowMode +#else +#define MAYBE_GainAndLoseFocusInWindowMode GainAndLoseFocusInWindowMode +#endif +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + MAYBE_GainAndLoseFocusInWindowMode) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + Browser* first_instance = GetActiveBrowser(); + Browser* second_instance = CreateNewBrowserInstance(); + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + + // Save this off for querying later as ActiveWebContents() is based on focus + // and we want to check the state of the web contents associated with the + // first browser instance. + content::WebContents* web_contents = GetActiveWebContents(); + ASSERT_TRUE(web_contents); + + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + // We expect the keyboard lock request to remain valid while the window gains + // and loses focus, keyboard lock will remain inactive since the initial + // window is never put into fullscreen. + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(content::GetKeyboardLockWidget(web_contents)); + ASSERT_FALSE(IsKeyboardLockActive()); +} + +#if defined(OS_LINUX) +// BringBrowserWindowToFront hangs on Linux: http://crbug.com/163931 +#define MAYBE_GainAndLoseFocusInFullscreen DISABLED_GainAndLoseFocusInFullscreen +#else +#define MAYBE_GainAndLoseFocusInFullscreen GainAndLoseFocusInFullscreen +#endif +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + MAYBE_GainAndLoseFocusInFullscreen) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + // Create a second browser instance so we can switch back and forth between + // the two instances to simulate focus loss/gain. + Browser* first_instance = GetActiveBrowser(); + Browser* second_instance = CreateNewBrowserInstance(); + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + + // Save this off for querying later as ActiveWebContents() based on focus. + content::RenderWidgetHostView* first_instance_host_view = + GetActiveWebContents()->GetRenderWidgetHostView(); + ASSERT_TRUE(first_instance_host_view); + + ASSERT_TRUE(RequestKeyboardLock()); + ASSERT_TRUE(IsKeyboardLockRequestRegistered()); + ASSERT_FALSE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(first_instance_host_view->IsKeyboardLocked()); + + // Now we use the test utility libraries to switch between the first and + // second browser instances. The expectation is that keyboard lock will be + // disengaged when the second instance is brought to the foreground and is + // re-activated when the first instance is given focus. + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_FALSE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_FALSE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_FALSE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(second_instance)); + ASSERT_FALSE(first_instance_host_view->IsKeyboardLocked()); + + ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(first_instance)); + ASSERT_TRUE(first_instance_host_view->IsKeyboardLocked()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + KeyboardUnlockedWhenNavigatingToSameUrl) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURLWithDisposition( + GetActiveBrowser(), + GetEmbeddedTestServer()->GetURL(GetFullscreenFramePath()), + WindowOpenDisposition::CURRENT_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION)); + + ASSERT_FALSE(IsKeyboardLockActive()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + KeyboardUnlockedWhenNavigatingAway) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURLWithDisposition( + GetActiveBrowser(), GetEmbeddedTestServer()->GetURL(kSimplePageHTML), + WindowOpenDisposition::CURRENT_TAB, + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION)); + + ASSERT_FALSE(IsKeyboardLockActive()); + ASSERT_FALSE(IsKeyboardLockRequestRegistered()); +} + +IN_PROC_BROWSER_TEST_F(KeyboardLockInteractiveBrowserTest, + DownloadNavigationDoesNotUnlock) { + ASSERT_NO_FATAL_FAILURE(StartFullscreenLockPage()); + ASSERT_TRUE(DisablePreventDefaultOnTestPage()); + + ASSERT_TRUE(RequestKeyboardLock(/*lock_all_keys=*/false)); + ASSERT_NO_FATAL_FAILURE(SendJsFullscreenShortcutAndWait()); + ASSERT_TRUE(IsKeyboardLockActive()); + + GURL download_url = + ui_test_utils::GetTestUrl(base::FilePath().AppendASCII(kDownloadFolder), + base::FilePath().AppendASCII(kDownloadFile)); + ui_test_utils::DownloadURL(browser(), download_url); + + ASSERT_TRUE(IsKeyboardLockActive()); +}
diff --git a/chrome/browser/ui/media_router/media_router_ui_base.h b/chrome/browser/ui/media_router/media_router_ui_base.h index 848b470e..a6e17dd5 100644 --- a/chrome/browser/ui/media_router/media_router_ui_base.h +++ b/chrome/browser/ui/media_router/media_router_ui_base.h
@@ -108,7 +108,7 @@ // Returns a subset of |sinks_| that should be listed in the dialog. This // excludes the wired display that the initiator WebContents is on. - std::vector<MediaSinkWithCastModes> GetEnabledSinks() const; + virtual std::vector<MediaSinkWithCastModes> GetEnabledSinks() const; // Returns a source name that can be shown in the dialog. std::string GetTruncatedPresentationRequestSourceName() const;
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc index 1a1e87d..b259428 100644 --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
@@ -104,7 +104,6 @@ suppress_layout_(false), suppress_animation_(true), should_check_extension_bubble_(!main_bar), - is_drag_in_progress_(false), popped_out_action_(nullptr), is_popped_out_sticky_(false), is_showing_bubble_(false), @@ -254,7 +253,8 @@ // popped out action (because the action will pop back into overflow when the // menu opens). return GetEndIndexInBounds() != toolbar_actions_.size() || - is_drag_in_progress_ || (popped_out_action_ && !is_popped_out_sticky_); + is_drag_in_progress() || + (popped_out_action_ && !is_popped_out_sticky_); } gfx::Rect ToolbarActionsBar::GetFrameForIndex( @@ -387,11 +387,13 @@ model_->SetVisibleIconCount(resized_count); } -void ToolbarActionsBar::OnDragStarted() { - // All drag-and-drop commands should go to the main bar. - ToolbarActionsBar* main_bar = in_overflow_mode() ? main_bar_ : this; - DCHECK(!main_bar->is_drag_in_progress_); - main_bar->is_drag_in_progress_ = true; +void ToolbarActionsBar::OnDragStarted(size_t index_of_dragged_item) { + if (in_overflow_mode()) { + main_bar_->OnDragStarted(index_of_dragged_item); + return; + } + DCHECK(!is_drag_in_progress()); + index_of_dragged_item_ = index_of_dragged_item; } void ToolbarActionsBar::OnDragEnded() { @@ -401,8 +403,8 @@ return; } - DCHECK(is_drag_in_progress_); - is_drag_in_progress_ = false; + DCHECK(is_drag_in_progress()); + index_of_dragged_item_.reset(); for (ToolbarActionsBarObserver& observer : observers_) observer.OnToolbarActionDragDone(); } @@ -428,6 +430,11 @@ model_->SetVisibleIconCount(model_->visible_icon_count() + delta); } +const base::Optional<size_t> ToolbarActionsBar::IndexOfDraggedItem() const { + DCHECK(!in_overflow_mode()); + return index_of_dragged_item_; +} + void ToolbarActionsBar::OnAnimationEnded() { // Notify the observers now, since showing a bubble or popup could potentially // cause another animation to start.
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.h b/chrome/browser/ui/toolbar/toolbar_actions_bar.h index 6552eae..41cc6f7 100644 --- a/chrome/browser/ui/toolbar/toolbar_actions_bar.h +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.h
@@ -14,6 +14,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" +#include "base/optional.h" #include "base/scoped_observer.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" @@ -158,9 +159,9 @@ // the new width is |width|. void OnResizeComplete(int width); - // Notifies the ToolbarActionsBar that the user has started a drag-and-drop - // sequence. - void OnDragStarted(); + // Notifies the ToolbarActionsBar that the user has started dragging the + // action at index |index_of_dragged_item|. + void OnDragStarted(size_t index_of_dragged_item); // Notifies the ToolbarActionsBar that a drag-and-drop sequence ended. This // may not coincide with OnDragDrop(), since the view may be dropped somewhere @@ -176,6 +177,10 @@ int dropped_index, DragType drag_type); + // The index of the action currently being dragged, or |base::nullopt| if + // no drag is in progress. Should only be called on the main bar. + const base::Optional<size_t> IndexOfDraggedItem() const; + // Notifies the ToolbarActionsBar that the delegate finished animating. void OnAnimationEnded(); @@ -244,6 +249,10 @@ bool in_overflow_mode() const { return main_bar_ != nullptr; } bool is_showing_bubble() const { return is_showing_bubble_; } + bool is_drag_in_progress() const { + return index_of_dragged_item_ != base::nullopt; + } + ToolbarActionsBarDelegate* delegate_for_test() { return delegate_; } // During testing we can disable animations by setting this flag to true, @@ -337,9 +346,6 @@ // bubble. This is only ever true for the main bar. bool should_check_extension_bubble_; - // Whether or not the user is in the middle of a drag-and-drop operation. - bool is_drag_in_progress_; - // The action, if any, which is currently "popped out" of the overflow in // order to show a popup. ToolbarActionViewController* popped_out_action_; @@ -359,6 +365,10 @@ // True if a bubble is currently being shown. bool is_showing_bubble_; + // The index of the action currently being dragged, or |base::nullopt| if + // no drag is in progress. + base::Optional<size_t> index_of_dragged_item_; + ScopedObserver<TabStripModel, TabStripModelObserver> tab_strip_observer_; base::ObserverList<ToolbarActionsBarObserver> observers_;
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc index a38c0a1..64a80410 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
@@ -52,6 +52,7 @@ g_browser_process->profile_manager()-> GetProfileAttributesStorage().AddObserver(this); } + MaybeObserveTabstrip(); } BrowserNonClientFrameView::~BrowserNonClientFrameView() { @@ -68,10 +69,7 @@ } void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() { - if (browser_view()->tabstrip()) { - DCHECK(!tab_strip_observer_.IsObserving(browser_view()->tabstrip())); - tab_strip_observer_.Add(browser_view()->tabstrip()); - } + MaybeObserveTabstrip(); UpdateMinimumSize(); } @@ -422,6 +420,13 @@ UpdateTaskbarDecoration(); } +void BrowserNonClientFrameView::MaybeObserveTabstrip() { + if (browser_view()->tabstrip()) { + DCHECK(!tab_strip_observer_.IsObserving(browser_view()->tabstrip())); + tab_strip_observer_.Add(browser_view()->tabstrip()); + } +} + const ui::ThemeProvider* BrowserNonClientFrameView::GetThemeProviderForProfile() const { // Because the frame's accessor reads the ThemeProvider from the profile and
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h index e74eeaa..718c180 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
@@ -149,6 +149,8 @@ void OnProfileHighResAvatarLoaded( const base::FilePath& profile_path) override; + void MaybeObserveTabstrip(); + // Gets a theme provider that should be non-null even before we're added to a // view hierarchy. const ui::ThemeProvider* GetThemeProviderForProfile() const;
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc index 7f0c1ac..bbbb9da5 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc +++ b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.cc
@@ -10,6 +10,7 @@ #include "ui/base/ui_base_types.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/paint_vector_icon.h" +#include "ui/views/animation/ink_drop_impl.h" #include "ui/views/controls/throbber.h" #include "ui/views/vector_icons.h" @@ -79,6 +80,19 @@ return nullptr; } +base::string16 GetStatusTextForSink(const UIMediaSink& sink) { + if (!sink.status_text.empty()) + return sink.status_text; + switch (sink.state) { + case UIMediaSinkState::AVAILABLE: + return l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_SINK_AVAILABLE); + case UIMediaSinkState::CONNECTING: + return l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_SINK_CONNECTING); + default: + return base::string16(); + } +} + } // namespace CastDialogSinkButton::CastDialogSinkButton( @@ -87,7 +101,7 @@ : HoverButton(button_listener, CreatePrimaryIconForSink(sink), sink.friendly_name, - sink.status_text, + GetStatusTextForSink(sink), CreateSecondaryIconForSink(sink)), sink_(sink) {} @@ -114,6 +128,15 @@ SnapInkDropToActivated(); } +std::unique_ptr<views::InkDrop> CastDialogSinkButton::CreateInkDrop() { + auto ink_drop = HoverButton::CreateInkDrop(); + // Without overriding this value, the ink drop would fade in (as opposed to + // snapping), which results in flickers when updating sinks. + static_cast<views::InkDropImpl*>(ink_drop.get()) + ->SetAutoHighlightMode(views::InkDropImpl::AutoHighlightMode::NONE); + return ink_drop; +} + base::string16 CastDialogSinkButton::GetActionText() const { return l10n_util::GetStringUTF16(sink_.state == UIMediaSinkState::CONNECTED ? IDS_MEDIA_ROUTER_STOP_CASTING_BUTTON
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.h b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.h index ed72bab..b35dd56 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_sink_button.h +++ b/chrome/browser/ui/views/media_router/cast_dialog_sink_button.h
@@ -12,6 +12,10 @@ class MouseEvent; } +namespace views { +class InkDrop; +} + namespace media_router { // A button representing a sink in the Cast dialog. It is highlighted when @@ -28,6 +32,7 @@ // views::View: bool OnMousePressed(const ui::MouseEvent& event) override; void OnBlur() override; + std::unique_ptr<views::InkDrop> CreateInkDrop() override; // Returns the text that should be shown on the main action button of the Cast // dialog when this button is selected.
diff --git a/chrome/browser/ui/views/media_router/media_router_views_ui.cc b/chrome/browser/ui/views/media_router/media_router_views_ui.cc index 7abd448..2f4acf87 100644 --- a/chrome/browser/ui/views/media_router/media_router_views_ui.cc +++ b/chrome/browser/ui/views/media_router/media_router_views_ui.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ui/views/media_router/media_router_views_ui.h" #include "base/stl_util.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/media_router/media_sink_with_cast_modes.h" #include "chrome/browser/ui/media_router/ui_media_sink.h" @@ -69,6 +70,19 @@ TerminateRoute(route_id); } +std::vector<MediaSinkWithCastModes> MediaRouterViewsUI::GetEnabledSinks() + const { + std::vector<MediaSinkWithCastModes> sinks = + MediaRouterUIBase::GetEnabledSinks(); + // Remove the pseudo-sink, since it's only used in the WebUI dialog. + // TODO(takumif): Remove this once we've removed pseudo-sink from Cloud MRP. + base::EraseIf(sinks, [](const MediaSinkWithCastModes& sink) { + return base::StartsWith(sink.sink.id(), + "pseudo:", base::CompareCase::SENSITIVE); + }); + return sinks; +} + void MediaRouterViewsUI::OnRoutesUpdated( const std::vector<MediaRoute>& routes, const std::vector<MediaRoute::Id>& joinable_route_ids) {
diff --git a/chrome/browser/ui/views/media_router/media_router_views_ui.h b/chrome/browser/ui/views/media_router/media_router_views_ui.h index 09d86ba..eb9db95 100644 --- a/chrome/browser/ui/views/media_router/media_router_views_ui.h +++ b/chrome/browser/ui/views/media_router/media_router_views_ui.h
@@ -27,8 +27,12 @@ MediaCastMode cast_mode) override; void StopCasting(const std::string& route_id) override; + // MediaRouterUIBase: + std::vector<MediaSinkWithCastModes> GetEnabledSinks() const override; + private: FRIEND_TEST_ALL_PREFIXES(MediaRouterViewsUITest, NotifyObserver); + FRIEND_TEST_ALL_PREFIXES(MediaRouterViewsUITest, RemovePseudoSink); // MediaRouterUIBase: void OnRoutesUpdated(
diff --git a/chrome/browser/ui/views/media_router/media_router_views_ui_unittest.cc b/chrome/browser/ui/views/media_router/media_router_views_ui_unittest.cc index b5d5c9c8..50529bf 100644 --- a/chrome/browser/ui/views/media_router/media_router_views_ui_unittest.cc +++ b/chrome/browser/ui/views/media_router/media_router_views_ui_unittest.cc
@@ -24,6 +24,7 @@ namespace { +constexpr char kPseudoSinkId[] = "pseudo:sink"; constexpr char kRouteId[] = "route1"; constexpr char kSinkId[] = "sink1"; constexpr char kSinkName[] = "sink name"; @@ -138,4 +139,24 @@ ui_->StopCasting(kRouteId); } +TEST_F(MediaRouterViewsUITest, RemovePseudoSink) { + MockControllerObserver observer; + ui_->AddObserver(&observer); + + MediaSink sink(kSinkId, kSinkName, SinkIconType::CAST_AUDIO); + MediaSinkWithCastModes sink_with_cast_modes(sink); + sink_with_cast_modes.cast_modes = {MediaCastMode::TAB_MIRROR}; + MediaSink pseudo_sink(kPseudoSinkId, kSinkName, SinkIconType::MEETING); + MediaSinkWithCastModes pseudo_sink_with_cast_modes(pseudo_sink); + pseudo_sink_with_cast_modes.cast_modes = {MediaCastMode::TAB_MIRROR}; + + EXPECT_CALL(observer, OnModelUpdated(_)) + .WillOnce(WithArg<0>(Invoke([&sink](const CastDialogModel& model) { + EXPECT_EQ(1u, model.media_sinks.size()); + EXPECT_EQ(sink.id(), model.media_sinks[0].id); + }))); + ui_->OnResultsUpdated({sink_with_cast_modes, pseudo_sink_with_cast_modes}); + ui_->RemoveObserver(&observer); +} + } // namespace media_router
diff --git a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.cc b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.cc index d72cafce..2cc0d90 100644 --- a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.cc +++ b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.cc
@@ -31,7 +31,7 @@ namespace policy { namespace { -constexpr int kDialogContentHeight = 220; // The height of dialog content area. +constexpr int kDialogContentHeight = 190; // The height of dialog content area. constexpr int kDialogContentWidth = 670; // The width of dialog content area. constexpr int kIconSize = 24; // The size of throbber and error icon. constexpr int kLineHeight = 22; // The height of text line. @@ -69,7 +69,7 @@ void EnterpriseStartupDialogView::DisplayLaunchingInformationWithThrobber( const base::string16& information) { - ResetDialog(false, false); + ResetDialog(false); views::Label* text = CreateText(information); views::Throbber* throbber = new views::Throbber(); @@ -82,9 +82,8 @@ void EnterpriseStartupDialogView::DisplayErrorMessage( const base::string16& error_message, - const base::Optional<base::string16>& accept_button, - const base::Optional<base::string16>& cancel_button) { - ResetDialog(accept_button.has_value(), cancel_button.has_value()); + const base::Optional<base::string16>& accept_button) { + ResetDialog(accept_button.has_value()); views::Label* text = CreateText(error_message); views::ImageView* error_icon = new views::ImageView(); error_icon->SetImage(gfx::CreateVectorIcon(kBrowserToolsErrorIcon, kIconSize, @@ -92,8 +91,6 @@ if (accept_button) GetDialogClientView()->ok_button()->SetText(*accept_button); - if (cancel_button) - GetDialogClientView()->cancel_button()->SetText(*cancel_button); SetupLayout(error_icon, text); } @@ -120,11 +117,11 @@ return true; } -bool EnterpriseStartupDialogView::ShouldShowWindowTitle() const { - return false; +bool EnterpriseStartupDialogView::Close() { + return Cancel(); } -bool EnterpriseStartupDialogView::ShouldShowCloseButton() const { +bool EnterpriseStartupDialogView::ShouldShowWindowTitle() const { return false; } @@ -144,7 +141,7 @@ gfx::Rect logo_bounds = logo_image->GetImageBounds(); logo_image->SetImageSize(gfx::Size( logo_bounds.width() * kLogoHeight / logo_bounds.height(), kLogoHeight)); - logo_image->SetVerticalAlignment(views::ImageView::TRAILING); + logo_image->SetVerticalAlignment(views::ImageView::CENTER); return logo_image; #else return nullptr; @@ -152,29 +149,22 @@ } int EnterpriseStartupDialogView::GetDialogButtons() const { - return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; + return ui::DIALOG_BUTTON_OK; } gfx::Size EnterpriseStartupDialogView::CalculatePreferredSize() const { return gfx::Size(kDialogContentWidth, kDialogContentHeight); } -void EnterpriseStartupDialogView::ResetDialog(bool show_accept_button, - bool show_cancel_button) { +void EnterpriseStartupDialogView::ResetDialog(bool show_accept_button) { DCHECK(GetDialogClientView()->ok_button()); - DCHECK(GetDialogClientView()->cancel_button()); GetDialogClientView()->ok_button()->SetVisible(show_accept_button); - GetDialogClientView()->cancel_button()->SetVisible(show_cancel_button); RemoveAllChildViews(true); } void EnterpriseStartupDialogView::SetupLayout(views::View* icon, views::View* text) { - gfx::Size icon_size = icon->GetPreferredSize(); - - gfx::Insets dialog_insets = GetDialogInsets(); - // Padding between icon and text int text_padding = ChromeLayoutProvider::Get()->GetDistanceMetric( views::DISTANCE_TEXTFIELD_HORIZONTAL_TEXT_PADDING); @@ -191,13 +181,11 @@ views::GridLayout::USE_PREF, 0, 0); columnset->AddPaddingColumn(1, 0); - // Vertically centre the content. - layout->AddPaddingRow( - 0, (GetDialogClientView()->height() - icon_size.height()) / 2 - - dialog_insets.top()); + layout->AddPaddingRow(1, 0); layout->StartRow(0, 0); layout->AddView(icon); layout->AddView(text); + layout->AddPaddingRow(1, 0); GetDialogClientView()->Layout(); GetDialogClientView()->SchedulePaint(); @@ -228,12 +216,9 @@ void EnterpriseStartupDialogImpl::DisplayErrorMessage( const base::string16& error_message, - const base::Optional<base::string16>& accept_button, - const base::Optional<base::string16>& cancel_button) { - if (dialog_view_) { - dialog_view_->DisplayErrorMessage(error_message, accept_button, - cancel_button); - } + const base::Optional<base::string16>& accept_button) { + if (dialog_view_) + dialog_view_->DisplayErrorMessage(error_message, accept_button); } bool EnterpriseStartupDialogImpl::IsShowing() { return dialog_view_;
diff --git a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.h b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.h index 4c9ebf9..38c0503 100644 --- a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.h +++ b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view.h
@@ -26,8 +26,7 @@ void DisplayLaunchingInformationWithThrobber( const base::string16& information); void DisplayErrorMessage(const base::string16& error_message, - const base::Optional<base::string16>& accept_button, - const base::Optional<base::string16>& cancel_button); + const base::Optional<base::string16>& accept_button); void CloseDialog(); void AddWidgetObserver(views::WidgetObserver* observer); @@ -37,8 +36,8 @@ // override views::DialogDelegateView bool Accept() override; bool Cancel() override; + bool Close() override; bool ShouldShowWindowTitle() const override; - bool ShouldShowCloseButton() const override; ui::ModalType GetModalType() const override; views::View* CreateExtraView() override; @@ -49,7 +48,7 @@ gfx::Size CalculatePreferredSize() const override; // Remove all existing child views from the dialog, show/hide dialog buttons. - void ResetDialog(bool show_accept_button, bool show_cancel_button); + void ResetDialog(bool show_accept_button); // Append child views to the content area, setup the layout. void SetupLayout(views::View* icon, views::View* text); @@ -70,8 +69,7 @@ const base::string16& information) override; void DisplayErrorMessage( const base::string16& error_message, - const base::Optional<base::string16>& accept_button, - const base::Optional<base::string16>& cancel_button) override; + const base::Optional<base::string16>& accept_button) override; bool IsShowing() override; // views::WidgetObserver:
diff --git a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view_browsertest.cc b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view_browsertest.cc index 65fd605..a9c452f 100644 --- a/chrome/browser/ui/views/policy/enterprise_startup_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/policy/enterprise_startup_dialog_view_browsertest.cc
@@ -30,13 +30,11 @@ base::ASCIIToUTF16(kMessage)); } else if (name == "Error") { dialog->DisplayErrorMessage(base::ASCIIToUTF16(kMessage), - base::ASCIIToUTF16(kButton), base::ASCIIToUTF16(kButton)); } else if (name == "Switch") { dialog->DisplayLaunchingInformationWithThrobber( base::ASCIIToUTF16(kMessage)); dialog->DisplayErrorMessage(base::ASCIIToUTF16(kMessage), - base::ASCIIToUTF16(kButton), base::ASCIIToUTF16(kButton)); } }
diff --git a/chrome/browser/ui/views/sad_tab_view_interactive_uitest.cc b/chrome/browser/ui/views/sad_tab_view_interactive_uitest.cc index 4693e640..5e07442 100644 --- a/chrome/browser/ui/views/sad_tab_view_interactive_uitest.cc +++ b/chrome/browser/ui/views/sad_tab_view_interactive_uitest.cc
@@ -177,6 +177,9 @@ #if defined(OS_MACOSX) // Focusing or input is not completely working on Mac: http://crbug.com/824418 #define MAYBE_ReloadMultipleSadTabs DISABLED_ReloadMultipleSadTabs +#elif defined(OS_WIN) && defined(OFFICIAL_BUILD) +// Test seems to fail only in official Windows builds: http://crbug.com/848049 +#define MAYBE_ReloadMultipleSadTabs DISABLED_ReloadMultipleSadTabs #else #define MAYBE_ReloadMultipleSadTabs ReloadMultipleSadTabs #endif
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc index fad5dc7..4117747 100644 --- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc +++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc
@@ -543,7 +543,6 @@ void BrowserActionsContainer::WriteDragDataForView(View* sender, const gfx::Point& press_pt, OSExchangeData* data) { - toolbar_actions_bar_->OnDragStarted(); DCHECK(data); auto it = @@ -552,6 +551,10 @@ return ptr.get() == sender; }); DCHECK(it != toolbar_action_views_.cend()); + + size_t index = it - toolbar_action_views_.cbegin(); + toolbar_actions_bar_->OnDragStarted(index); + ToolbarActionViewController* view_controller = (*it)->view_controller(); data->provider().SetDragImage( view_controller @@ -561,8 +564,7 @@ .AsImageSkia(), press_pt.OffsetFromOrigin()); // Fill in the remaining info. - BrowserActionDragData drag_data(view_controller->GetId(), - it - toolbar_action_views_.cbegin()); + BrowserActionDragData drag_data(view_controller->GetId(), index); drag_data.Write(browser_->profile(), data); }
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc b/chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc index 4f57c08f..a9f0389 100644 --- a/chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc +++ b/chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc
@@ -194,7 +194,7 @@ drop_data, location, location, ui::DragDropTypes::DRAG_MOVE); // Drag and drop. - first->toolbar_actions_bar()->OnDragStarted(); + first->toolbar_actions_bar()->OnDragStarted(0u); first->OnDragUpdated(target_event); // Semi-random placement for a regression test for crbug.com/539744.
diff --git a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc index 4d30bda..1e7ac44 100644 --- a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc +++ b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "chrome/common/url_constants.h" #include "chrome/grit/browser_resources.h" +#include "chrome/grit/generated_resources.h" #include "chromeos/services/assistant/public/mojom/constants.mojom.h" #include "chromeos/services/assistant/public/proto/settings_ui.pb.h" #include "components/arc/arc_prefs.h" @@ -21,6 +22,7 @@ #include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui_data_source.h" #include "services/service_manager/public/cpp/connector.h" +#include "ui/base/l10n/l10n_util.h" namespace chromeos { @@ -157,11 +159,6 @@ consent_token_ = activity_control_ui.consent_token(); base::ListValue zippy_data; - if (activity_control_ui.setting_zippy().size() == 0) { - // No need to consent. Close the dialog for now. - CloseDialog(nullptr); - return; - } for (auto& setting_zippy : activity_control_ui.setting_zippy()) { base::DictionaryValue data; data.SetString("title", setting_zippy.title()); @@ -174,17 +171,24 @@ assistant_handler_->AddSettingZippy(zippy_data); base::DictionaryValue dictionary; - dictionary.SetString("valuePropIntro", - activity_control_ui.intro_text_paragraph(0)); dictionary.SetString("valuePropIdentity", activity_control_ui.identity()); - dictionary.SetString("valuePropFooter", - activity_control_ui.footer_paragraph(0)); + if (activity_control_ui.intro_text_paragraph_size() > 0) { + dictionary.SetString("valuePropIntro", + activity_control_ui.intro_text_paragraph(0)); + } + if (activity_control_ui.footer_paragraph_size() > 0) { + dictionary.SetString("valuePropFooter", + activity_control_ui.footer_paragraph(0)); + } dictionary.SetString( "valuePropNextButton", settings_ui.consent_flow_ui().consent_ui().accept_button_text()); dictionary.SetString( "valuePropSkipButton", - settings_ui.consent_flow_ui().consent_ui().reject_button_text()); + settings_ui.consent_flow_ui().consent_ui().has_reject_button_text() + ? settings_ui.consent_flow_ui().consent_ui().reject_button_text() + : l10n_util::GetStringUTF8( + IDS_VOICE_INTERACTION_VALUE_PROP_SKIP_BUTTON)); assistant_handler_->ReloadContent(dictionary); } @@ -199,6 +203,10 @@ LOG(ERROR) << "Consent udpate error."; } + Next(); +} + +void AssistantOptInUI::Next() { // More screens to be added. Close the dialog for now. PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); prefs->SetBoolean(arc::prefs::kArcVoiceInteractionValuePropAccepted, true);
diff --git a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h index 1d6b7687..7a8f9bc 100644 --- a/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h +++ b/chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_ui.h
@@ -45,6 +45,9 @@ void OnGetSettingsResponse(const std::string& settings); void OnUpdateSettingsResponse(const std::string& settings); + // Show next screen in the optin flow. + void Next(); + // Consent token used to complete the opt-in. std::string consent_token_;
diff --git a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc index cc22ec03..c099e1ac 100644 --- a/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc
@@ -37,7 +37,6 @@ #include "chrome/browser/chromeos/policy/temp_certs_cache_nss.h" #include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/settings/cros_settings.h" -#include "chrome/browser/io_thread.h" #include "chrome/browser/lifetime/browser_shutdown.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" @@ -68,6 +67,8 @@ #include "content/public/browser/render_frame_host.h" #include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_urls.h" +#include "mojo/public/cpp/bindings/callback_helpers.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_util.h" #include "ui/base/l10n/l10n_util.h" @@ -196,16 +197,6 @@ UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); } -// The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO -// thread. -void ClearDnsCache(IOThread* io_thread) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - if (browser_shutdown::IsTryingToQuit()) - return; - - io_thread->ClearHostCache(base::Callback<bool(const std::string&)>()); -} - void PushFrontIMIfNotExists(const std::string& input_method, std::vector<std::string>* input_methods) { if (input_method.empty()) @@ -882,15 +873,23 @@ } void GaiaScreenHandler::StartClearingDnsCache() { - if (dns_clear_task_running_ || !g_browser_process->io_thread()) + if (dns_clear_task_running_ || + !g_browser_process->system_network_context_manager()) { return; + } dns_cleared_ = false; - BrowserThread::PostTaskAndReply( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&ClearDnsCache, g_browser_process->io_thread()), - base::BindOnce(&GaiaScreenHandler::OnDnsCleared, - weak_factory_.GetWeakPtr())); + + g_browser_process->system_network_context_manager() + ->GetContext() + ->ClearHostCache(nullptr /* filter */, + // Need to ensure that even if the network service + // crashes, OnDnsCleared() is invoked. + mojo::WrapCallbackWithDropHandler( + base::BindOnce(&GaiaScreenHandler::OnDnsCleared, + weak_factory_.GetWeakPtr()), + base::BindOnce(&GaiaScreenHandler::OnDnsCleared, + weak_factory_.GetWeakPtr()))); dns_clear_task_running_ = true; }
diff --git a/chrome/browser/ui/webui/discards/BUILD.gn b/chrome/browser/ui/webui/discards/BUILD.gn index a33645ed..62abc88 100644 --- a/chrome/browser/ui/webui/discards/BUILD.gn +++ b/chrome/browser/ui/webui/discards/BUILD.gn
@@ -9,5 +9,9 @@ sources = [ "discards.mojom", ] + + public_deps = [ + "//chrome/browser/resource_coordinator:mojo_bindings", + ] } }
diff --git a/chrome/browser/ui/webui/discards/discards.mojom b/chrome/browser/ui/webui/discards/discards.mojom index 5fe64a8b..4ea62d0 100644 --- a/chrome/browser/ui/webui/discards/discards.mojom +++ b/chrome/browser/ui/webui/discards/discards.mojom
@@ -4,6 +4,8 @@ module mojom; +import "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom"; + // Identical to content::Visibility. enum LifecycleUnitVisibility { HIDDEN = 0, @@ -20,16 +22,11 @@ string title; // The visibility of the LifecycleUnit. LifecycleUnitVisibility visibility; + // The state of the LifecycleUnit. + LifecycleUnitState state; // If the tab is currently using media functionality (casting, WebRTC, playing // audio, etc) this is true. bool is_media; - // If the tab is currently discarded, this is true. - bool is_discarded; - // If the tab is currently frozen, this is true. - // TODO(fmeawad): is_discarded and is_frozen are mutually exclusive, instead - // of representing each individually, we should add a "lifecycle_state" field - // instead. - bool is_frozen; // The number of times this tab has been discarded in the current browser // session. int32 discard_count;
diff --git a/chrome/browser/ui/webui/discards/discards_ui.cc b/chrome/browser/ui/webui/discards/discards_ui.cc index c6140907..7aea7c6 100644 --- a/chrome/browser/ui/webui/discards/discards_ui.cc +++ b/chrome/browser/ui/webui/discards/discards_ui.cc
@@ -14,6 +14,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/resource_coordinator/discard_reason.h" #include "chrome/browser/resource_coordinator/lifecycle_unit.h" +#include "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.h" #include "chrome/browser/resource_coordinator/tab_activity_watcher.h" #include "chrome/browser/resource_coordinator/tab_lifecycle_unit_external.h" #include "chrome/browser/resource_coordinator/tab_manager.h" @@ -96,9 +97,8 @@ info->title = base::UTF16ToUTF8(lifecycle_unit->GetTitle()); info->visibility = GetLifecycleUnitVisibility(lifecycle_unit->GetVisibility()); + info->state = lifecycle_unit->GetState(); info->is_media = tab_lifecycle_unit_external->IsMediaTab(); - info->is_frozen = tab_lifecycle_unit_external->IsFrozen(); - info->is_discarded = tab_lifecycle_unit_external->IsDiscarded(); info->discard_count = tab_lifecycle_unit_external->GetDiscardCount(); info->utility_rank = rank++; const base::TimeTicks last_focused_time = @@ -177,6 +177,9 @@ // Full paths (relative to src) are important for Mojom generated files. source->AddResourcePath("chrome/browser/ui/webui/discards/discards.mojom.js", IDR_ABOUT_DISCARDS_MOJO_JS); + source->AddResourcePath( + "chrome/browser/resource_coordinator/lifecycle_unit_state.mojom.js", + IDR_ABOUT_DISCARDS_LIFECYCLE_UNIT_STATE_MOJO_JS); source->SetDefaultResource(IDR_ABOUT_DISCARDS_HTML); Profile* profile = Profile::FromWebUI(web_ui);
diff --git a/chrome/browser/vr/BUILD.gn b/chrome/browser/vr/BUILD.gn index 5ec46d0..b5c72542 100644 --- a/chrome/browser/vr/BUILD.gn +++ b/chrome/browser/vr/BUILD.gn
@@ -20,7 +20,7 @@ flags = [ "USE_VR_ASSETS_COMPONENT=$use_vr_assets_component" ] } -static_library("vr_common") { +component("vr_common") { sources = [ "animation.cc", "animation.h", @@ -233,6 +233,7 @@ "ui_test_input.cc", "ui_test_input.h", "ui_unsupported_mode.h", + "vr_export.h", "vr_features.h", "vr_gl_util.cc", "vr_gl_util.h", @@ -269,6 +270,8 @@ "//ui/display", "//ui/gl/init", ] + + defines = [ "VR_IMPLEMENTATION" ] } test("vr_common_unittests") { @@ -324,6 +327,7 @@ deps = [ ":vr_test_support", + "//components/url_formatter", "//mojo/public/cpp/bindings", "//testing/gmock", "//ui/gfx/geometry",
diff --git a/chrome/browser/vr/animation.h b/chrome/browser/vr/animation.h index c3aafb25..db4624a 100644 --- a/chrome/browser/vr/animation.h +++ b/chrome/browser/vr/animation.h
@@ -11,6 +11,7 @@ #include "base/macros.h" #include "cc/animation/keyframe_model.h" #include "chrome/browser/vr/transition.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace cc { @@ -31,7 +32,7 @@ // TODO(vollick): if cc::KeyframeModel and friends move into gfx/, then this // class should follow suit. As such, it should not absorb any vr-specific // functionality. -class Animation final { +class VR_EXPORT Animation final { public: static int GetNextKeyframeModelId(); static int GetNextGroupId();
diff --git a/chrome/browser/vr/assets_loader.h b/chrome/browser/vr/assets_loader.h index 0fc3c1bf..fc02813 100644 --- a/chrome/browser/vr/assets_loader.h +++ b/chrome/browser/vr/assets_loader.h
@@ -13,6 +13,7 @@ #include "base/memory/weak_ptr.h" #include "base/version.h" #include "chrome/browser/vr/assets_load_status.h" +#include "chrome/browser/vr/vr_export.h" namespace base { class DictionaryValue; @@ -39,7 +40,7 @@ // component will be made available on a different thread than the asset load // request. Internally, the function calls will be posted on the main thread. // The asset load may be performed on a worker thread. -class AssetsLoader { +class VR_EXPORT AssetsLoader { public: typedef base::OnceCallback<void(AssetsLoadStatus status, std::unique_ptr<Assets> assets,
diff --git a/chrome/browser/vr/content_input_delegate.h b/chrome/browser/vr/content_input_delegate.h index fbee776..3798266 100644 --- a/chrome/browser/vr/content_input_delegate.h +++ b/chrome/browser/vr/content_input_delegate.h
@@ -15,6 +15,7 @@ #include "chrome/browser/vr/model/text_input_info.h" #include "chrome/browser/vr/platform_ui_input_delegate.h" #include "chrome/browser/vr/text_edit_action.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/blink/public/platform/web_input_event.h" namespace vr { @@ -24,7 +25,7 @@ // This class is responsible for processing all events and gestures for // ContentElement. -class ContentInputDelegate : public PlatformUiInputDelegate { +class VR_EXPORT ContentInputDelegate : public PlatformUiInputDelegate { public: ContentInputDelegate(); explicit ContentInputDelegate(PlatformInputHandler* content);
diff --git a/chrome/browser/vr/elements/button.h b/chrome/browser/vr/elements/button.h index 46b98dc..1705cfd 100644 --- a/chrome/browser/vr/elements/button.h +++ b/chrome/browser/vr/elements/button.h
@@ -12,6 +12,7 @@ #include "chrome/browser/vr/elements/draw_phase.h" #include "chrome/browser/vr/elements/ui_element.h" #include "chrome/browser/vr/model/color_scheme.h" +#include "chrome/browser/vr/vr_export.h" namespace gfx { class PointF; @@ -26,7 +27,7 @@ // axis. This matches the Daydream disk-style button. Subclasses may add // arbitrary non-hit-testable elements as children of the background, if // desired. -class Button : public UiElement { +class VR_EXPORT Button : public UiElement { public: explicit Button(base::RepeatingCallback<void()> click_handler, AudioDelegate* audio_delegate);
diff --git a/chrome/browser/vr/elements/content_element.h b/chrome/browser/vr/elements/content_element.h index b1f65af..4fdf96ff 100644 --- a/chrome/browser/vr/elements/content_element.h +++ b/chrome/browser/vr/elements/content_element.h
@@ -8,6 +8,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/platform_ui_element.h" #include "chrome/browser/vr/ui_element_renderer.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { @@ -21,7 +22,7 @@ // If quad layer is set, it stops surface frames of web page but instead draws // transparent in UI. So the web page in quad layer can be later composited to // the UI. -class ContentElement : public PlatformUiElement { +class VR_EXPORT ContentElement : public PlatformUiElement { public: typedef typename base::RepeatingCallback<void(const gfx::SizeF&)> ScreenBoundsChangedCallback;
diff --git a/chrome/browser/vr/elements/disc_button.h b/chrome/browser/vr/elements/disc_button.h index 00a6bb1..cc18ef7 100644 --- a/chrome/browser/vr/elements/disc_button.h +++ b/chrome/browser/vr/elements/disc_button.h
@@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/macros.h" #include "chrome/browser/vr/elements/vector_icon_button.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/vector_icon_types.h" namespace vr { @@ -19,7 +20,7 @@ // A disc button has a circle as the background and a vector icon as the // foreground. When hovered, background and foreground both move forward on Z // axis. This matches the Daydream disc-style button. -class DiscButton : public VectorIconButton { +class VR_EXPORT DiscButton : public VectorIconButton { public: DiscButton(base::RepeatingCallback<void()> click_handler, const gfx::VectorIcon& icon,
diff --git a/chrome/browser/vr/elements/indicator_spec.h b/chrome/browser/vr/elements/indicator_spec.h index ec51b49..36586e77 100644 --- a/chrome/browser/vr/elements/indicator_spec.h +++ b/chrome/browser/vr/elements/indicator_spec.h
@@ -9,11 +9,12 @@ #include "chrome/browser/vr/elements/ui_element_name.h" #include "chrome/browser/vr/model/capturing_state_model.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/vector_icon_types.h" namespace vr { -struct IndicatorSpec { +struct VR_EXPORT IndicatorSpec { IndicatorSpec(UiElementName name, UiElementName webvr_name, const gfx::VectorIcon& icon, @@ -39,7 +40,7 @@ bool is_url; }; -std::vector<IndicatorSpec> GetIndicatorSpecs(); +VR_EXPORT std::vector<IndicatorSpec> GetIndicatorSpecs(); } // namespace vr
diff --git a/chrome/browser/vr/elements/keyboard.h b/chrome/browser/vr/elements/keyboard.h index d5a0ecab..e485e49 100644 --- a/chrome/browser/vr/elements/keyboard.h +++ b/chrome/browser/vr/elements/keyboard.h
@@ -9,12 +9,13 @@ #include "chrome/browser/vr/elements/ui_element.h" #include "chrome/browser/vr/keyboard_delegate.h" #include "chrome/browser/vr/renderers/base_renderer.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // Represents the virtual keyboard. This element is a proxy to the // platform-specific keyboard implementation. -class Keyboard : public UiElement { +class VR_EXPORT Keyboard : public UiElement { public: Keyboard(); ~Keyboard() override;
diff --git a/chrome/browser/vr/elements/linear_layout.h b/chrome/browser/vr/elements/linear_layout.h index afa7c94..9ef1b49 100644 --- a/chrome/browser/vr/elements/linear_layout.h +++ b/chrome/browser/vr/elements/linear_layout.h
@@ -6,10 +6,11 @@ #define CHROME_BROWSER_VR_ELEMENTS_LINEAR_LAYOUT_H_ #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -class LinearLayout : public UiElement { +class VR_EXPORT LinearLayout : public UiElement { public: enum Direction { kUp, kDown, kLeft, kRight };
diff --git a/chrome/browser/vr/elements/omnibox_formatting.h b/chrome/browser/vr/elements/omnibox_formatting.h index 1605fec..a6cdeab 100644 --- a/chrome/browser/vr/elements/omnibox_formatting.h +++ b/chrome/browser/vr/elements/omnibox_formatting.h
@@ -9,6 +9,7 @@ #include "chrome/browser/vr/elements/text.h" #include "chrome/browser/vr/model/color_scheme.h" +#include "chrome/browser/vr/vr_export.h" #include "components/omnibox/browser/autocomplete_match.h" namespace gfx { @@ -18,12 +19,12 @@ namespace vr { // Convert Autocomplete's suggestion formatting to generic VR text formatting. -TextFormatting ConvertClassification( - const ACMatchClassifications& classifications, - size_t text_length, - const ColorScheme& color_scheme); +VR_EXPORT TextFormatting +ConvertClassification(const ACMatchClassifications& classifications, + size_t text_length, + const ColorScheme& color_scheme); -url_formatter::FormatUrlTypes GetVrFormatUrlTypes(); +VR_EXPORT url_formatter::FormatUrlTypes GetVrFormatUrlTypes(); struct ElisionParameters { // The horizontal pixel offset to be applied to URL text, such that the right @@ -41,18 +42,19 @@ // elision parameters. This means computing an offset such that the rightmost // portion of the TLD is visible (along with a small part of the path), and // fading either edge if they overflow available space. -ElisionParameters GetElisionParameters(const GURL& gurl, - const url::Parsed& parsed, - gfx::RenderText* render_text, - int min_path_pixels); +VR_EXPORT ElisionParameters GetElisionParameters(const GURL& gurl, + const url::Parsed& parsed, + gfx::RenderText* render_text, + int min_path_pixels); // Given a formatted URL and associated Parsed data, generates a VR-specific // text formatting description that can be applied to a RenderText. This mainly // handles emphasis of hosts, etc., but could also include color. -TextFormatting CreateUrlFormatting(const base::string16& formatted_url, - const url::Parsed& parsed, - SkColor emphasized_color, - SkColor deemphasized_color); +VR_EXPORT TextFormatting +CreateUrlFormatting(const base::string16& formatted_url, + const url::Parsed& parsed, + SkColor emphasized_color, + SkColor deemphasized_color); } // namespace vr
diff --git a/chrome/browser/vr/elements/omnibox_text_field.h b/chrome/browser/vr/elements/omnibox_text_field.h index 48f2478d..9eb38aa 100644 --- a/chrome/browser/vr/elements/omnibox_text_field.h +++ b/chrome/browser/vr/elements/omnibox_text_field.h
@@ -10,10 +10,11 @@ #include "chrome/browser/vr/elements/text_input.h" #include "chrome/browser/vr/model/omnibox_suggestions.h" #include "chrome/browser/vr/model/text_input_info.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -class OmniboxTextField : public TextInput { +class VR_EXPORT OmniboxTextField : public TextInput { public: OmniboxTextField(float font_height_meters, OnInputEditedCallback input_edit_callback,
diff --git a/chrome/browser/vr/elements/oval.h b/chrome/browser/vr/elements/oval.h index 39359df..42e8b1e 100644 --- a/chrome/browser/vr/elements/oval.h +++ b/chrome/browser/vr/elements/oval.h
@@ -6,12 +6,13 @@ #define CHROME_BROWSER_VR_ELEMENTS_OVAL_H_ #include "chrome/browser/vr/elements/rect.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // An oval behaves like a rect save for the fact that it manages its own corner // radii to ensure circular right and left end caps. -class Oval : public Rect { +class VR_EXPORT Oval : public Rect { public: Oval(); ~Oval() override;
diff --git a/chrome/browser/vr/elements/paged_grid_layout.h b/chrome/browser/vr/elements/paged_grid_layout.h index 805386f..fccb108 100644 --- a/chrome/browser/vr/elements/paged_grid_layout.h +++ b/chrome/browser/vr/elements/paged_grid_layout.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { @@ -20,7 +21,7 @@ // follows the alphabetical ordering pictured above. // // NOTE: it is assumed that each child view has the same dimensions. -class PagedGridLayout : public UiElement { +class VR_EXPORT PagedGridLayout : public UiElement { public: enum PageState { kNone, kActive, kInactive, kHidden };
diff --git a/chrome/browser/vr/elements/rect.h b/chrome/browser/vr/elements/rect.h index 2e49636..1708a758a 100644 --- a/chrome/browser/vr/elements/rect.h +++ b/chrome/browser/vr/elements/rect.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_VR_ELEMENTS_RECT_H_ #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/geometry/point_f.h" @@ -17,7 +18,7 @@ // two colors. This radial gradient is not aspect correct; it will be elliptical // if the rect is stretched. This is intended to serve as a background to be put // behind other elements. -class Rect : public UiElement { +class VR_EXPORT Rect : public UiElement { public: Rect(); ~Rect() override;
diff --git a/chrome/browser/vr/elements/render_text_wrapper.h b/chrome/browser/vr/elements/render_text_wrapper.h index 64e9a2e..4bdd413 100644 --- a/chrome/browser/vr/elements/render_text_wrapper.h +++ b/chrome/browser/vr/elements/render_text_wrapper.h
@@ -6,13 +6,14 @@ #define CHROME_BROWSER_VR_ELEMENTS_RENDER_TEXT_WRAPPER_H_ #include "base/macros.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/render_text.h" namespace vr { // A minimal, mockable wrapper around gfx::RenderText, to facilitate testing of // RenderText users. -class RenderTextWrapper { +class VR_EXPORT RenderTextWrapper { public: explicit RenderTextWrapper(gfx::RenderText* render_text); virtual ~RenderTextWrapper();
diff --git a/chrome/browser/vr/elements/repositioner.h b/chrome/browser/vr/elements/repositioner.h index 129a24f3..726ce952 100644 --- a/chrome/browser/vr/elements/repositioner.h +++ b/chrome/browser/vr/elements/repositioner.h
@@ -9,6 +9,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/transform.h" namespace vr { @@ -20,7 +21,7 @@ // adjusting the up vector of the content so that it aligns with the head's up // vector. As the window is being repositioned, we rotate it so that it remains // pointing upward. -class Repositioner : public UiElement { +class VR_EXPORT Repositioner : public UiElement { public: Repositioner(); ~Repositioner() override;
diff --git a/chrome/browser/vr/elements/resizer.h b/chrome/browser/vr/elements/resizer.h index 493f90d..483d50f 100644 --- a/chrome/browser/vr/elements/resizer.h +++ b/chrome/browser/vr/elements/resizer.h
@@ -9,13 +9,14 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/transform.h" namespace vr { // When enabled, a resizer scales its descendant elements in response to // trackpad use. -class Resizer : public UiElement { +class VR_EXPORT Resizer : public UiElement { public: Resizer(); ~Resizer() override;
diff --git a/chrome/browser/vr/elements/scaled_depth_adjuster.h b/chrome/browser/vr/elements/scaled_depth_adjuster.h index 2805262..d435665 100644 --- a/chrome/browser/vr/elements/scaled_depth_adjuster.h +++ b/chrome/browser/vr/elements/scaled_depth_adjuster.h
@@ -9,6 +9,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/transform.h" namespace vr { @@ -17,7 +18,7 @@ // permits dimensions in the subtree to be expressed in DM directly. Its main // contribution is a tailored local transform that accounts for adjustments made // by other ScaledDepthAdjuster elements on its ancestor chain. -class ScaledDepthAdjuster : public UiElement { +class VR_EXPORT ScaledDepthAdjuster : public UiElement { public: explicit ScaledDepthAdjuster(float delta_z); ~ScaledDepthAdjuster() override;
diff --git a/chrome/browser/vr/elements/scrollable_element.h b/chrome/browser/vr/elements/scrollable_element.h index 2bdf60a6..0c2b5ba 100644 --- a/chrome/browser/vr/elements/scrollable_element.h +++ b/chrome/browser/vr/elements/scrollable_element.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_VR_ELEMENTS_SCROLLABLE_ELEMENT_H_ #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { @@ -14,7 +15,7 @@ // It is required that none of its descendants define any rotation. A good use // case for this element is the creation of menus, for which you can place a // LinearLayout as its only scrolling. -class ScrollableElement : public UiElement { +class VR_EXPORT ScrollableElement : public UiElement { public: enum Orientation { kVertical, kHorizontal };
diff --git a/chrome/browser/vr/elements/shadow.h b/chrome/browser/vr/elements/shadow.h index 053462ff..8b8c41ca 100644 --- a/chrome/browser/vr/elements/shadow.h +++ b/chrome/browser/vr/elements/shadow.h
@@ -8,6 +8,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" #include "chrome/browser/vr/renderers/base_quad_renderer.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace vr { @@ -16,7 +17,7 @@ // applied. The shadow is applied across its padding. // By default the direct child is used as the shadow caster. This behavior can // be changed by manually setting a shadow caster. -class Shadow : public UiElement { +class VR_EXPORT Shadow : public UiElement { public: Shadow(); ~Shadow() override;
diff --git a/chrome/browser/vr/elements/spinner.h b/chrome/browser/vr/elements/spinner.h index 1588e230..8409468 100644 --- a/chrome/browser/vr/elements/spinner.h +++ b/chrome/browser/vr/elements/spinner.h
@@ -9,13 +9,14 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/textured_element.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace vr { class SpinnerTexture; -class Spinner : public TexturedElement { +class VR_EXPORT Spinner : public TexturedElement { public: explicit Spinner(int texture_width); ~Spinner() override;
diff --git a/chrome/browser/vr/elements/text.h b/chrome/browser/vr/elements/text.h index 84bc3e08dd..b0dd4b93 100644 --- a/chrome/browser/vr/elements/text.h +++ b/chrome/browser/vr/elements/text.h
@@ -10,6 +10,7 @@ #include "chrome/browser/vr/elements/textured_element.h" #include "chrome/browser/vr/elements/ui_texture.h" #include "chrome/browser/vr/model/color_scheme.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkRect.h" #include "ui/gfx/font.h" @@ -34,7 +35,7 @@ // This class describes a formatting attribute, applicable to a Text element. // Attributes are applied in order, and may override previous attributes. // Formatting may be applied only to non-wrapping text. -class TextFormattingAttribute { +class VR_EXPORT TextFormattingAttribute { public: enum Type { COLOR, @@ -92,7 +93,7 @@ float shadow_size = 10.0f; }; -class Text : public TexturedElement { +class VR_EXPORT Text : public TexturedElement { public: explicit Text(float font_height_dmms); ~Text() override;
diff --git a/chrome/browser/vr/elements/text_input.h b/chrome/browser/vr/elements/text_input.h index 458c2d7c..068289fc 100644 --- a/chrome/browser/vr/elements/text_input.h +++ b/chrome/browser/vr/elements/text_input.h
@@ -12,6 +12,7 @@ #include "chrome/browser/vr/model/color_scheme.h" #include "chrome/browser/vr/model/text_input_info.h" #include "chrome/browser/vr/text_input_delegate.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace vr { @@ -19,7 +20,7 @@ class Rect; class Text; -class TextInput : public UiElement { +class VR_EXPORT TextInput : public UiElement { public: // Called when this element receives focus. typedef base::RepeatingCallback<void(bool)> OnFocusChangedCallback;
diff --git a/chrome/browser/vr/elements/textured_element.h b/chrome/browser/vr/elements/textured_element.h index ce4e102..086ec7e 100644 --- a/chrome/browser/vr/elements/textured_element.h +++ b/chrome/browser/vr/elements/textured_element.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkRefCnt.h" #include "ui/gfx/geometry/size.h" #include "ui/gl/gl_bindings.h" @@ -17,7 +18,7 @@ class UiTexture; -class TexturedElement : public UiElement { +class VR_EXPORT TexturedElement : public UiElement { public: TexturedElement();
diff --git a/chrome/browser/vr/elements/throbber.h b/chrome/browser/vr/elements/throbber.h index 834ff16..6d0a2628 100644 --- a/chrome/browser/vr/elements/throbber.h +++ b/chrome/browser/vr/elements/throbber.h
@@ -7,12 +7,13 @@ #include "cc/animation/transform_operation.h" #include "chrome/browser/vr/elements/rect.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // A throbber renders a fading and pulsing rect through animating element's // scale and opacity. -class Throbber : public Rect { +class VR_EXPORT Throbber : public Rect { public: Throbber(); ~Throbber() override;
diff --git a/chrome/browser/vr/elements/transient_element.h b/chrome/browser/vr/elements/transient_element.h index b4ee457..837d9640 100644 --- a/chrome/browser/vr/elements/transient_element.h +++ b/chrome/browser/vr/elements/transient_element.h
@@ -7,12 +7,13 @@ #include "base/callback.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // Base class for a transient element that automatically hides itself after some // point in time. The exacly transience behavior depends on the subclass. -class TransientElement : public UiElement { +class VR_EXPORT TransientElement : public UiElement { public: ~TransientElement() override; @@ -39,7 +40,7 @@ }; // An element that hides itself after after a set timeout. -class SimpleTransientElement : public TransientElement { +class VR_EXPORT SimpleTransientElement : public TransientElement { public: explicit SimpleTransientElement(const base::TimeDelta& timeout); ~SimpleTransientElement() override; @@ -63,7 +64,7 @@ // made visible. The element will stay visible for at least the set // minimum duration regardless of when ::Signal is called. The set callback // is triggered when the element hides itself. -class ShowUntilSignalTransientElement : public TransientElement { +class VR_EXPORT ShowUntilSignalTransientElement : public TransientElement { public: typedef typename base::RepeatingCallback<void()> OnMinDurationCallback; typedef typename base::RepeatingCallback<void(TransientElementHideReason)>
diff --git a/chrome/browser/vr/elements/ui_element.cc b/chrome/browser/vr/elements/ui_element.cc index ebd6975c..81eba90 100644 --- a/chrome/browser/vr/elements/ui_element.cc +++ b/chrome/browser/vr/elements/ui_element.cc
@@ -209,6 +209,17 @@ } } +void UiElement::OnTouchMove(const gfx::PointF& position) { + if (GetSounds().touch_move != kSoundNone && audio_delegate_) { + audio_delegate_->PlaySound(GetSounds().touch_move); + } + if (event_handlers_.touch_move) { + event_handlers_.touch_move.Run(position); + } else if (parent() && bubble_events()) { + parent()->OnTouchMove(position); + } +} + void UiElement::OnFlingCancel(std::unique_ptr<blink::WebGestureEvent> gesture, const gfx::PointF& position) {} void UiElement::OnScrollBegin(std::unique_ptr<blink::WebGestureEvent> gesture,
diff --git a/chrome/browser/vr/elements/ui_element.h b/chrome/browser/vr/elements/ui_element.h index 807876e..0ec0403 100644 --- a/chrome/browser/vr/elements/ui_element.h +++ b/chrome/browser/vr/elements/ui_element.h
@@ -26,6 +26,7 @@ #include "chrome/browser/vr/model/reticle_model.h" #include "chrome/browser/vr/model/sounds.h" #include "chrome/browser/vr/target_property.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/geometry/point3_f.h" #include "ui/gfx/geometry/quaternion.h" #include "ui/gfx/geometry/rect_f.h" @@ -57,7 +58,7 @@ BOTTOM, }; -struct EventHandlers { +struct VR_EXPORT EventHandlers { EventHandlers(); EventHandlers(const EventHandlers& other); ~EventHandlers(); @@ -66,6 +67,7 @@ base::RepeatingCallback<void(const gfx::PointF&)> hover_move; base::RepeatingCallback<void()> button_down; base::RepeatingCallback<void()> button_up; + base::RepeatingCallback<void(const gfx::PointF&)> touch_move; base::RepeatingCallback<void(bool)> focus_change; }; @@ -97,7 +99,7 @@ float distance_to_plane; }; -class UiElement : public cc::AnimationTarget { +class VR_EXPORT UiElement : public cc::AnimationTarget { public: UiElement(); ~UiElement() override; @@ -152,6 +154,7 @@ virtual void OnHoverMove(const gfx::PointF& position); virtual void OnButtonDown(const gfx::PointF& position); virtual void OnButtonUp(const gfx::PointF& position); + virtual void OnTouchMove(const gfx::PointF& position); virtual void OnFlingCancel(std::unique_ptr<blink::WebGestureEvent> gesture, const gfx::PointF& position); virtual void OnScrollBegin(std::unique_ptr<blink::WebGestureEvent> gesture, @@ -535,7 +538,7 @@ // A signal to the input routing machinery that this element accepts scrolls. bool scrollable_ = false; - // If true, events such as OnButtonDown, OnBubbleUp, etc, get bubbled up the + // If true, events such as OnButtonDown, OnHoverEnter, etc, get bubbled up the // parent chain. bool bubble_events_ = false;
diff --git a/chrome/browser/vr/elements/ui_element_name.h b/chrome/browser/vr/elements/ui_element_name.h index ce0579d..ac39b7d 100644 --- a/chrome/browser/vr/elements/ui_element_name.h +++ b/chrome/browser/vr/elements/ui_element_name.h
@@ -7,6 +7,8 @@ #include <string> +#include "chrome/browser/vr/vr_export.h" + namespace vr { // These identifiers serve as stable, semantic identifiers for UI elements. @@ -151,7 +153,7 @@ kNumUiElementNames, }; -std::string UiElementNameToString(UiElementName name); +VR_EXPORT std::string UiElementNameToString(UiElementName name); } // namespace vr
diff --git a/chrome/browser/vr/elements/ui_element_type.h b/chrome/browser/vr/elements/ui_element_type.h index 3008514..fee2b90 100644 --- a/chrome/browser/vr/elements/ui_element_type.h +++ b/chrome/browser/vr/elements/ui_element_type.h
@@ -7,6 +7,8 @@ #include <string> +#include "chrome/browser/vr/vr_export.h" + namespace vr { // These identifiers serve as stable, semantic identifiers for UI elements. @@ -52,7 +54,7 @@ kNumUiElementTypes, }; -std::string UiElementTypeToString(UiElementType type); +VR_EXPORT std::string UiElementTypeToString(UiElementType type); } // namespace vr
diff --git a/chrome/browser/vr/elements/url_text.h b/chrome/browser/vr/elements/url_text.h index 83c9377..a9af827 100644 --- a/chrome/browser/vr/elements/url_text.h +++ b/chrome/browser/vr/elements/url_text.h
@@ -12,13 +12,14 @@ #include "chrome/browser/vr/elements/omnibox_formatting.h" #include "chrome/browser/vr/elements/text.h" #include "chrome/browser/vr/ui_unsupported_mode.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/render_text.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" namespace vr { -class UrlText : public Text { +class VR_EXPORT UrlText : public Text { public: UrlText(float font_height_dmm, const base::RepeatingCallback<void()>& unhandled_codepoint_callback);
diff --git a/chrome/browser/vr/elements/vector_icon.h b/chrome/browser/vr/elements/vector_icon.h index 8e118f04f..21aaddc5 100644 --- a/chrome/browser/vr/elements/vector_icon.h +++ b/chrome/browser/vr/elements/vector_icon.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/textured_element.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace gfx { @@ -19,7 +20,7 @@ class VectorIconTexture; -class VectorIcon : public TexturedElement { +class VR_EXPORT VectorIcon : public TexturedElement { public: explicit VectorIcon(int texture_width); ~VectorIcon() override;
diff --git a/chrome/browser/vr/elements/vector_icon_button.h b/chrome/browser/vr/elements/vector_icon_button.h index 89f98612..e011af4 100644 --- a/chrome/browser/vr/elements/vector_icon_button.h +++ b/chrome/browser/vr/elements/vector_icon_button.h
@@ -10,6 +10,7 @@ #include "base/callback.h" #include "base/macros.h" #include "chrome/browser/vr/elements/button.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/vector_icon_types.h" namespace vr { @@ -19,7 +20,7 @@ // A vector button has rect as a background and a vector icon as the // foreground. When hovered, background and foreground both move forward on Z // axis. -class VectorIconButton : public Button { +class VR_EXPORT VectorIconButton : public Button { public: VectorIconButton(base::RepeatingCallback<void()> click_handler, const gfx::VectorIcon& icon,
diff --git a/chrome/browser/vr/elements/viewport_aware_root.h b/chrome/browser/vr/elements/viewport_aware_root.h index 923374f..0cb681e 100644 --- a/chrome/browser/vr/elements/viewport_aware_root.h +++ b/chrome/browser/vr/elements/viewport_aware_root.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/vr/elements/ui_element.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/transform.h" namespace vr { @@ -14,7 +15,7 @@ // This class is the root of all viewport aware elements. It calcuates the // yaw rotation which all elements need to apply to be visible in current // viewport. -class ViewportAwareRoot : public UiElement { +class VR_EXPORT ViewportAwareRoot : public UiElement { public: static const float kViewportRotationTriggerDegrees;
diff --git a/chrome/browser/vr/fps_meter.h b/chrome/browser/vr/fps_meter.h index 57900d9..1d13e711 100644 --- a/chrome/browser/vr/fps_meter.h +++ b/chrome/browser/vr/fps_meter.h
@@ -8,11 +8,12 @@ #include "base/macros.h" #include "base/time/time.h" #include "chrome/browser/vr/sample_queue.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // Computes fps based on submitted frame times. -class FPSMeter { +class VR_EXPORT FPSMeter { public: FPSMeter(); explicit FPSMeter(size_t window_size);
diff --git a/chrome/browser/vr/ganesh_surface_provider.h b/chrome/browser/vr/ganesh_surface_provider.h index 6328c908..e370be72 100644 --- a/chrome/browser/vr/ganesh_surface_provider.h +++ b/chrome/browser/vr/ganesh_surface_provider.h
@@ -6,13 +6,14 @@ #define CHROME_BROWSER_VR_GANESH_SURFACE_PROVIDER_H_ #include "chrome/browser/vr/skia_surface_provider.h" +#include "chrome/browser/vr/vr_export.h" class GrContext; namespace vr { // Creates a Skia surface for which drawing commands are executed on the GPU. -class GaneshSurfaceProvider : public SkiaSurfaceProvider { +class VR_EXPORT GaneshSurfaceProvider : public SkiaSurfaceProvider { public: GaneshSurfaceProvider(); ~GaneshSurfaceProvider() override;
diff --git a/chrome/browser/vr/metrics/metrics_helper.h b/chrome/browser/vr/metrics/metrics_helper.h index bcadb45..59bb6e8 100644 --- a/chrome/browser/vr/metrics/metrics_helper.h +++ b/chrome/browser/vr/metrics/metrics_helper.h
@@ -13,6 +13,7 @@ #include "chrome/browser/vr/assets_component_update_status.h" #include "chrome/browser/vr/assets_load_status.h" #include "chrome/browser/vr/mode.h" +#include "chrome/browser/vr/vr_export.h" namespace base { class Version; @@ -23,7 +24,7 @@ // Helper to collect VR UMA metrics. // // For thread-safety, all functions must be called in sequence. -class MetricsHelper { +class VR_EXPORT MetricsHelper { public: MetricsHelper(); ~MetricsHelper();
diff --git a/chrome/browser/vr/metrics/session_metrics_helper.h b/chrome/browser/vr/metrics/session_metrics_helper.h index 92f1a407..6fb12bbd8 100644 --- a/chrome/browser/vr/metrics/session_metrics_helper.h +++ b/chrome/browser/vr/metrics/session_metrics_helper.h
@@ -10,6 +10,7 @@ #include "base/time/time.h" #include "chrome/browser/vr/mode.h" #include "chrome/browser/vr/ui_browser_interface.h" +#include "chrome/browser/vr/vr_export.h" #include "content/public/browser/web_contents_observer.h" #include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_source_id.h" @@ -146,7 +147,7 @@ // metrics that require state monitoring, such as durations, but also tracks // data we want attached to that, such as number of videos watched and how the // session was started. -class SessionMetricsHelper : public content::WebContentsObserver { +class VR_EXPORT SessionMetricsHelper : public content::WebContentsObserver { public: // Returns the SessionMetricsHelper singleton if it has been created for the // WebContents.
diff --git a/chrome/browser/vr/model/assets.h b/chrome/browser/vr/model/assets.h index 1fa3dfea..291b131 100644 --- a/chrome/browser/vr/model/assets.h +++ b/chrome/browser/vr/model/assets.h
@@ -8,12 +8,13 @@ #include <memory> #include "base/version.h" +#include "chrome/browser/vr/vr_export.h" class SkBitmap; namespace vr { -struct Assets { +struct VR_EXPORT Assets { Assets(); ~Assets();
diff --git a/chrome/browser/vr/model/capturing_state_model.h b/chrome/browser/vr/model/capturing_state_model.h index 1ef64394..ca4cb52 100644 --- a/chrome/browser/vr/model/capturing_state_model.h +++ b/chrome/browser/vr/model/capturing_state_model.h
@@ -5,9 +5,11 @@ #ifndef CHROME_BROWSER_VR_MODEL_CAPTURING_STATE_MODEL_H_ #define CHROME_BROWSER_VR_MODEL_CAPTURING_STATE_MODEL_H_ +#include "chrome/browser/vr/vr_export.h" + namespace vr { -struct CapturingStateModel { +struct VR_EXPORT CapturingStateModel { CapturingStateModel(); CapturingStateModel(const CapturingStateModel& other); ~CapturingStateModel();
diff --git a/chrome/browser/vr/model/color_scheme.h b/chrome/browser/vr/model/color_scheme.h index e704832..01d1cc6 100644 --- a/chrome/browser/vr/model/color_scheme.h +++ b/chrome/browser/vr/model/color_scheme.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_VR_MODEL_COLOR_SCHEME_H_ #include "base/version.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace vr { @@ -32,7 +33,7 @@ SkColor foreground = SK_ColorBLACK; }; -struct ColorScheme { +struct VR_EXPORT ColorScheme { enum Mode : int { kModeNormal = 0, kModeFullscreen,
diff --git a/chrome/browser/vr/model/controller_model.h b/chrome/browser/vr/model/controller_model.h index 211ccf21..f99c3480 100644 --- a/chrome/browser/vr/model/controller_model.h +++ b/chrome/browser/vr/model/controller_model.h
@@ -7,6 +7,7 @@ #include "chrome/browser/vr/platform_controller.h" #include "chrome/browser/vr/ui_input_manager.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/geometry/point3_f.h" #include "ui/gfx/transform.h" @@ -16,7 +17,7 @@ // platform-specific VR subsystem (e.g., GVR). It is used by both the // UiInputManager (for generating gestures), and by the UI for rendering the // controller. -struct ControllerModel { +struct VR_EXPORT ControllerModel { ControllerModel(); ControllerModel(const ControllerModel& other); ~ControllerModel();
diff --git a/chrome/browser/vr/model/model.h b/chrome/browser/vr/model/model.h index 5049664..e9147270 100644 --- a/chrome/browser/vr/model/model.h +++ b/chrome/browser/vr/model/model.h
@@ -22,11 +22,12 @@ #include "chrome/browser/vr/model/ui_mode.h" #include "chrome/browser/vr/model/web_vr_model.h" #include "chrome/browser/vr/ui_element_renderer.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/transform.h" namespace vr { -struct Model { +struct VR_EXPORT Model { Model(); ~Model();
diff --git a/chrome/browser/vr/model/omnibox_suggestions.h b/chrome/browser/vr/model/omnibox_suggestions.h index 032f904..6e326da 100644 --- a/chrome/browser/vr/model/omnibox_suggestions.h +++ b/chrome/browser/vr/model/omnibox_suggestions.h
@@ -6,12 +6,13 @@ #define CHROME_BROWSER_VR_MODEL_OMNIBOX_SUGGESTIONS_H_ #include "base/strings/string16.h" +#include "chrome/browser/vr/vr_export.h" #include "components/omnibox/browser/autocomplete_match.h" #include "url/gurl.h" namespace vr { -struct Autocompletion { +struct VR_EXPORT Autocompletion { Autocompletion(); Autocompletion(const base::string16& new_input, const base::string16& new_suffix); @@ -27,7 +28,7 @@ base::string16 suffix; }; -struct OmniboxSuggestion { +struct VR_EXPORT OmniboxSuggestion { OmniboxSuggestion(); OmniboxSuggestion(const base::string16& new_contents, @@ -52,7 +53,7 @@ Autocompletion autocompletion; }; -struct OmniboxSuggestions { +struct VR_EXPORT OmniboxSuggestions { OmniboxSuggestions(); ~OmniboxSuggestions(); @@ -61,7 +62,7 @@ // This struct contains the minimal set of information required to construct an // AutocompleteInput on VR's behalf. -struct AutocompleteRequest { +struct VR_EXPORT AutocompleteRequest { base::string16 text; size_t cursor_position = 0; bool prevent_inline_autocomplete = false;
diff --git a/chrome/browser/vr/model/sounds.h b/chrome/browser/vr/model/sounds.h index fd530e21..5fffb3b 100644 --- a/chrome/browser/vr/model/sounds.h +++ b/chrome/browser/vr/model/sounds.h
@@ -12,9 +12,10 @@ struct Sounds { SoundId hover_enter = kSoundNone; SoundId hover_leave = kSoundNone; + SoundId hover_move = kSoundNone; SoundId button_down = kSoundNone; SoundId button_up = kSoundNone; - SoundId hover_move = kSoundNone; + SoundId touch_move = kSoundNone; }; } // namespace vr
diff --git a/chrome/browser/vr/model/tab_model.h b/chrome/browser/vr/model/tab_model.h index 208af47b..e8732a8 100644 --- a/chrome/browser/vr/model/tab_model.h +++ b/chrome/browser/vr/model/tab_model.h
@@ -7,10 +7,11 @@ #include "base/macros.h" #include "base/strings/string16.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -struct TabModel { +struct VR_EXPORT TabModel { TabModel(int id, const base::string16& title); TabModel(const TabModel& other); ~TabModel();
diff --git a/chrome/browser/vr/model/text_input_info.h b/chrome/browser/vr/model/text_input_info.h index f9ed23d..67343bf3 100644 --- a/chrome/browser/vr/model/text_input_info.h +++ b/chrome/browser/vr/model/text_input_info.h
@@ -11,11 +11,12 @@ #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/vr/text_edit_action.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // Represents the state of an editable text field. -struct TextInputInfo { +struct VR_EXPORT TextInputInfo { public: TextInputInfo(); explicit TextInputInfo(base::string16 t); @@ -63,7 +64,7 @@ // A superset of TextInputInfo, consisting of a current and previous text field // state. A keyboard can return this structure, allowing clients to derive // deltas in keyboard state. -struct EditedText { +struct VR_EXPORT EditedText { public: EditedText(); EditedText(const EditedText& other);
diff --git a/chrome/browser/vr/model/toolbar_state.h b/chrome/browser/vr/model/toolbar_state.h index 1965cfb..c5b877b0 100644 --- a/chrome/browser/vr/model/toolbar_state.h +++ b/chrome/browser/vr/model/toolbar_state.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_VR_MODEL_TOOLBAR_STATE_H_ #define CHROME_BROWSER_VR_MODEL_TOOLBAR_STATE_H_ +#include "chrome/browser/vr/vr_export.h" #include "components/security_state/core/security_state.h" #include "url/gurl.h" @@ -15,7 +16,7 @@ namespace vr { // Passes information obtained from ToolbarModel to the VR UI framework. -struct ToolbarState { +struct VR_EXPORT ToolbarState { public: ToolbarState(); ToolbarState(const GURL& url,
diff --git a/chrome/browser/vr/platform_ui_input_delegate.h b/chrome/browser/vr/platform_ui_input_delegate.h index 990d6383..77bbc025 100644 --- a/chrome/browser/vr/platform_ui_input_delegate.h +++ b/chrome/browser/vr/platform_ui_input_delegate.h
@@ -14,6 +14,7 @@ #include "chrome/browser/vr/macros.h" #include "chrome/browser/vr/model/text_input_info.h" #include "chrome/browser/vr/text_edit_action.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/blink/public/platform/web_input_event.h" #include "ui/gfx/geometry/size.h" @@ -32,7 +33,7 @@ // This class is responsible for processing all events and gestures for // PlatformUiElement. -class PlatformUiInputDelegate { +class VR_EXPORT PlatformUiInputDelegate { public: PlatformUiInputDelegate(); explicit PlatformUiInputDelegate(PlatformInputHandler* input_handler);
diff --git a/chrome/browser/vr/pose_util.h b/chrome/browser/vr/pose_util.h index 6a6297a..d8d7653b 100644 --- a/chrome/browser/vr/pose_util.h +++ b/chrome/browser/vr/pose_util.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_VR_POSE_UTIL_H_ #define CHROME_BROWSER_VR_POSE_UTIL_H_ +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/geometry/vector3d_f.h" namespace gfx { @@ -14,7 +15,7 @@ namespace vr { // Provides the direction the head is looking towards as a 3x1 unit vector. -gfx::Vector3dF GetForwardVector(const gfx::Transform& head_pose); +VR_EXPORT gfx::Vector3dF GetForwardVector(const gfx::Transform& head_pose); // Returns a vector heading upward from the viewer's head. gfx::Vector3dF GetUpVector(const gfx::Transform& head_pose); @@ -22,9 +23,9 @@ // Returns true if either the change is gaze direction (via GetForwardVector // above) exceeds the angular threshold, or if the change in up vector exceeds // this same threshold. -bool HeadMoveExceedsThreshold(const gfx::Transform& old_pose, - const gfx::Transform& new_pose, - float angular_threshold_degrees); +VR_EXPORT bool HeadMoveExceedsThreshold(const gfx::Transform& old_pose, + const gfx::Transform& new_pose, + float angular_threshold_degrees); } // namespace vr
diff --git a/chrome/browser/vr/renderers/base_quad_renderer.h b/chrome/browser/vr/renderers/base_quad_renderer.h index 2a79826a..2362e44 100644 --- a/chrome/browser/vr/renderers/base_quad_renderer.h +++ b/chrome/browser/vr/renderers/base_quad_renderer.h
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/vr/renderers/base_renderer.h" +#include "chrome/browser/vr/vr_export.h" namespace gfx { class Transform; @@ -19,7 +20,7 @@ BaseQuadRenderer(const char* vertex_src, const char* fragment_src); ~BaseQuadRenderer() override; - static void CreateBuffers(); + VR_EXPORT static void CreateBuffers(); static int NumQuadIndices(); protected:
diff --git a/chrome/browser/vr/renderers/web_vr_renderer.h b/chrome/browser/vr/renderers/web_vr_renderer.h index f3a7b8e..a3d5d7f6 100644 --- a/chrome/browser/vr/renderers/web_vr_renderer.h +++ b/chrome/browser/vr/renderers/web_vr_renderer.h
@@ -7,11 +7,12 @@ #include "base/macros.h" #include "chrome/browser/vr/renderers/base_quad_renderer.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { // Renders a page-generated stereo VR view. -class WebVrRenderer : public BaseQuadRenderer { +class VR_EXPORT WebVrRenderer : public BaseQuadRenderer { public: WebVrRenderer(); ~WebVrRenderer() override;
diff --git a/chrome/browser/vr/service/browser_xr_device.cc b/chrome/browser/vr/service/browser_xr_device.cc index 72ae48d..6d5fc44 100644 --- a/chrome/browser/vr/service/browser_xr_device.cc +++ b/chrome/browser/vr/service/browser_xr_device.cc
@@ -9,8 +9,8 @@ namespace vr { -BrowserXrDevice::BrowserXrDevice(device::VRDevice* device) - : device_(device), weak_ptr_factory_(this) { +BrowserXrDevice::BrowserXrDevice(device::VRDevice* device, bool is_fallback) + : device_(device), is_fallback_(is_fallback), weak_ptr_factory_(this) { device_->SetVRDeviceEventListener(this); }
diff --git a/chrome/browser/vr/service/browser_xr_device.h b/chrome/browser/vr/service/browser_xr_device.h index 5c940b27..b5d04ba 100644 --- a/chrome/browser/vr/service/browser_xr_device.h +++ b/chrome/browser/vr/service/browser_xr_device.h
@@ -17,7 +17,7 @@ // listening for device activation. class BrowserXrDevice : public device::VRDeviceEventListener { public: - explicit BrowserXrDevice(device::VRDevice* device); + explicit BrowserXrDevice(device::VRDevice* device, bool is_fallback); ~BrowserXrDevice() override; device::VRDevice* GetDevice() { return device_; } @@ -42,6 +42,9 @@ VRDisplayHost* GetPresentingDisplayHost() { return presenting_display_host_; } void UpdateListeningForActivate(VRDisplayHost* display); + // Methods called by VRDeviceManager to inspect the device. + bool IsFallbackDevice() { return is_fallback_; } + private: void OnListeningForActivate(bool is_listening); void OnRequestPresentResult( @@ -56,6 +59,7 @@ std::set<VRDisplayHost*> displays_; VRDisplayHost* listening_for_activation_display_host_ = nullptr; VRDisplayHost* presenting_display_host_ = nullptr; + bool is_fallback_; base::WeakPtrFactory<BrowserXrDevice> weak_ptr_factory_; };
diff --git a/chrome/browser/vr/service/vr_device_manager.cc b/chrome/browser/vr/service/vr_device_manager.cc index 5b94e05cb..8d2bfe19 100644 --- a/chrome/browser/vr/service/vr_device_manager.cc +++ b/chrome/browser/vr/service/vr_device_manager.cc
@@ -45,6 +45,7 @@ if (!g_vr_device_manager) { // Register VRDeviceProviders for the current platform ProviderList providers; + ProviderList fallback_providers; #if defined(OS_ANDROID) // TODO(https://crbug.com/828321): when we support multiple devices and @@ -77,13 +78,13 @@ content::ServiceManagerConnection* connection = content::ServiceManagerConnection::GetForProcess(); if (connection) { - providers.emplace_back( + fallback_providers.emplace_back( std::make_unique<device::VROrientationDeviceProvider>( connection->GetConnector())); } } - new VRDeviceManager(std::move(providers)); + new VRDeviceManager(std::move(providers), std::move(fallback_providers)); } return g_vr_device_manager; } @@ -92,8 +93,10 @@ return g_vr_device_manager != nullptr; } -VRDeviceManager::VRDeviceManager(ProviderList providers) - : providers_(std::move(providers)) { +VRDeviceManager::VRDeviceManager(ProviderList providers, + ProviderList fallback_providers) + : providers_(std::move(providers)), + fallback_providers_(std::move(fallback_providers)) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); CHECK(!g_vr_device_manager); g_vr_device_manager = this; @@ -113,8 +116,7 @@ InitializeProviders(); for (const DeviceMap::value_type& map_entry : devices_) { - if (!map_entry.second->GetDevice()->IsFallbackDevice() || - devices_.size() == 1) + if (!map_entry.second->IsFallbackDevice() || devices_.size() == 1) service->ConnectDevice(map_entry.second.get()); } @@ -134,7 +136,7 @@ } } -void VRDeviceManager::AddDevice(device::VRDevice* device) { +void VRDeviceManager::AddDevice(bool is_fallback, device::VRDevice* device) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(devices_.find(device->GetId()) == devices_.end()); // Ignore any devices with VR_DEVICE_LAST_ID, which is used to prevent @@ -146,15 +148,15 @@ // TODO(offenwanger): This has the potential to cause device change events to // fire in rapid succession. This should be discussed and resolved when we // start to actually add and remove devices. - if (devices_.size() == 1 && - devices_.begin()->second->GetDevice()->IsFallbackDevice()) { + if (devices_.size() == 1 && devices_.begin()->second->IsFallbackDevice()) { BrowserXrDevice* device = devices_.begin()->second.get(); for (VRServiceImpl* service : services_) service->RemoveDevice(device); } - devices_[device->GetId()] = std::make_unique<BrowserXrDevice>(device); - if (!device->IsFallbackDevice() || devices_.size() == 1) { + devices_[device->GetId()] = + std::make_unique<BrowserXrDevice>(device, is_fallback); + if (!is_fallback || devices_.size() == 1) { BrowserXrDevice* device_to_add = devices_[device->GetId()].get(); for (VRServiceImpl* service : services_) service->ConnectDevice(device_to_add); @@ -173,8 +175,7 @@ devices_.erase(it); - if (devices_.size() == 1 && - devices_.begin()->second->GetDevice()->IsFallbackDevice()) { + if (devices_.size() == 1 && devices_.begin()->second->IsFallbackDevice()) { BrowserXrDevice* device = devices_.begin()->second.get(); for (VRServiceImpl* service : services_) service->ConnectDevice(device); @@ -205,12 +206,23 @@ return; for (const auto& provider : providers_) { - provider->Initialize(base::BindRepeating(&VRDeviceManager::AddDevice, - base::Unretained(this)), - base::BindRepeating(&VRDeviceManager::RemoveDevice, - base::Unretained(this)), - base::BindOnce(&VRDeviceManager::OnProviderInitialized, - base::Unretained(this))); + provider->Initialize( + base::BindRepeating(&VRDeviceManager::AddDevice, base::Unretained(this), + false /* is_fallback */), + base::BindRepeating(&VRDeviceManager::RemoveDevice, + base::Unretained(this)), + base::BindOnce(&VRDeviceManager::OnProviderInitialized, + base::Unretained(this))); + } + + for (const auto& provider : fallback_providers_) { + provider->Initialize( + base::BindRepeating(&VRDeviceManager::AddDevice, base::Unretained(this), + true /* is_fallback */), + base::BindRepeating(&VRDeviceManager::RemoveDevice, + base::Unretained(this)), + base::BindOnce(&VRDeviceManager::OnProviderInitialized, + base::Unretained(this))); } providers_initialized_ = true; @@ -227,7 +239,8 @@ bool VRDeviceManager::AreAllProvidersInitialized() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - return num_initialized_providers_ == providers_.size(); + return num_initialized_providers_ == + providers_.size() + fallback_providers_.size(); } size_t VRDeviceManager::NumberOfConnectedServices() {
diff --git a/chrome/browser/vr/service/vr_device_manager.h b/chrome/browser/vr/service/vr_device_manager.h index 81a5874d..4d78011 100644 --- a/chrome/browser/vr/service/vr_device_manager.h +++ b/chrome/browser/vr/service/vr_device_manager.h
@@ -17,6 +17,7 @@ #include "base/threading/thread_checker.h" #include "base/timer/timer.h" #include "chrome/browser/vr/service/vr_service_impl.h" +#include "chrome/browser/vr/vr_export.h" #include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/vr_device.h" #include "mojo/public/cpp/bindings/binding_set.h" @@ -31,7 +32,7 @@ // Singleton used to provide the platform's VR devices to VRServiceImpl // instances. -class VRDeviceManager { +class VR_EXPORT VRDeviceManager { public: virtual ~VRDeviceManager(); @@ -52,7 +53,8 @@ using ProviderList = std::vector<std::unique_ptr<device::VRDeviceProvider>>; // Used by tests to supply providers. - explicit VRDeviceManager(ProviderList providers); + explicit VRDeviceManager(ProviderList providers, + ProviderList fallback_providers); // Used by tests to check on device state. device::VRDevice* GetDevice(unsigned int index); @@ -64,10 +66,11 @@ void OnProviderInitialized(); bool AreAllProvidersInitialized(); - void AddDevice(device::VRDevice* device); + void AddDevice(bool is_fallback, device::VRDevice* device); void RemoveDevice(device::VRDevice* device); ProviderList providers_; + ProviderList fallback_providers_; // VRDevices are owned by their providers, each correspond to a // BrowserXrDevice that is owned by VRDeviceManager.
diff --git a/chrome/browser/vr/service/vr_device_manager_unittest.cc b/chrome/browser/vr/service/vr_device_manager_unittest.cc index 3395bab..8e7b5dc 100644 --- a/chrome/browser/vr/service/vr_device_manager_unittest.cc +++ b/chrome/browser/vr/service/vr_device_manager_unittest.cc
@@ -25,8 +25,9 @@ class VRDeviceManagerForTesting : public VRDeviceManager { public: - explicit VRDeviceManagerForTesting(ProviderList providers) - : VRDeviceManager(std::move(providers)) {} + explicit VRDeviceManagerForTesting(ProviderList providers, + ProviderList fallback_providers) + : VRDeviceManager(std::move(providers), std::move(fallback_providers)) {} ~VRDeviceManagerForTesting() override = default; size_t NumberOfConnectedServices() { @@ -62,7 +63,9 @@ provider_ = new device::FakeVRDeviceProvider(); providers.emplace_back( std::unique_ptr<device::FakeVRDeviceProvider>(provider_)); - new VRDeviceManagerForTesting(std::move(providers)); + std::vector<std::unique_ptr<device::VRDeviceProvider>> fallback_providers; + new VRDeviceManagerForTesting(std::move(providers), + std::move(fallback_providers)); } void TearDown() override { EXPECT_FALSE(VRDeviceManager::HasInstance()); }
diff --git a/chrome/browser/vr/service/vr_service_impl.h b/chrome/browser/vr/service/vr_service_impl.h index 7c937f1..fa9f205 100644 --- a/chrome/browser/vr/service/vr_service_impl.h +++ b/chrome/browser/vr/service/vr_service_impl.h
@@ -9,6 +9,7 @@ #include "base/macros.h" +#include "chrome/browser/vr/vr_export.h" #include "content/public/browser/web_contents_observer.h" #include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/vr_device.h" @@ -25,8 +26,8 @@ // It instantiates a VRDisplayImpl for each newly connected VRDisplay and sends // the display's info to the render process through its connected // mojom::VRServiceClient. -class VRServiceImpl : public device::mojom::VRService, - content::WebContentsObserver { +class VR_EXPORT VRServiceImpl : public device::mojom::VRService, + content::WebContentsObserver { public: explicit VRServiceImpl(content::RenderFrameHost* render_frame_host); ~VRServiceImpl() override;
diff --git a/chrome/browser/vr/skia_surface_provider.h b/chrome/browser/vr/skia_surface_provider.h index 0e54e2e..7dbc479 100644 --- a/chrome/browser/vr/skia_surface_provider.h +++ b/chrome/browser/vr/skia_surface_provider.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_VR_SKIA_SURFACE_PROVIDER_H_ #include "third_party/skia/include/core/SkRefCnt.h" +#include "third_party/skia/include/gpu/GrContext.h" #include "ui/gl/gl_bindings.h" class SkSurface;
diff --git a/chrome/browser/vr/sliding_average.h b/chrome/browser/vr/sliding_average.h index 7589673b..175f716 100644 --- a/chrome/browser/vr/sliding_average.h +++ b/chrome/browser/vr/sliding_average.h
@@ -10,10 +10,11 @@ #include "base/macros.h" #include "base/time/time.h" #include "chrome/browser/vr/sample_queue.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -class SlidingAverage { +class VR_EXPORT SlidingAverage { public: explicit SlidingAverage(size_t window_size); ~SlidingAverage(); @@ -28,7 +29,7 @@ DISALLOW_COPY_AND_ASSIGN(SlidingAverage); }; -class SlidingTimeDeltaAverage { +class VR_EXPORT SlidingTimeDeltaAverage { public: explicit SlidingTimeDeltaAverage(size_t window_size); virtual ~SlidingTimeDeltaAverage();
diff --git a/chrome/browser/vr/sounds_manager_audio_delegate.h b/chrome/browser/vr/sounds_manager_audio_delegate.h index 48e6a826..266cd71 100644 --- a/chrome/browser/vr/sounds_manager_audio_delegate.h +++ b/chrome/browser/vr/sounds_manager_audio_delegate.h
@@ -9,10 +9,11 @@ #include "base/macros.h" #include "chrome/browser/vr/audio_delegate.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -class SoundsManagerAudioDelegate : public AudioDelegate { +class VR_EXPORT SoundsManagerAudioDelegate : public AudioDelegate { public: SoundsManagerAudioDelegate(); ~SoundsManagerAudioDelegate() override;
diff --git a/chrome/browser/vr/speech_recognizer.h b/chrome/browser/vr/speech_recognizer.h index e297e40..3985c56 100644 --- a/chrome/browser/vr/speech_recognizer.h +++ b/chrome/browser/vr/speech_recognizer.h
@@ -10,6 +10,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" +#include "chrome/browser/vr/vr_export.h" namespace content { class SpeechRecognitionManager; @@ -88,7 +89,7 @@ // SpeechRecognizer is a wrapper around the speech recognition engine that // simplifies its use from the UI thread. This class handles all setup/shutdown, // collection of results, error cases, and threading. -class SpeechRecognizer : public IOBrowserUIInterface { +class VR_EXPORT SpeechRecognizer : public IOBrowserUIInterface { public: SpeechRecognizer(VoiceResultDelegate* delegate, BrowserUiInterface* ui,
diff --git a/chrome/browser/vr/testapp/BUILD.gn b/chrome/browser/vr/testapp/BUILD.gn index 8a28aac..00b222e 100644 --- a/chrome/browser/vr/testapp/BUILD.gn +++ b/chrome/browser/vr/testapp/BUILD.gn
@@ -24,7 +24,6 @@ deps = [ ":assets_component_version_header", ":vr_testapp_pak", - "//build/config:exe_and_shlib_deps", "//chrome/browser/vr:vr_gl_test_support", "//chrome/browser/vr:vr_test_support", "//components:components_tests_pak",
diff --git a/chrome/browser/vr/text_edit_action.h b/chrome/browser/vr/text_edit_action.h index 6e64a6f..5d5ff7e 100644 --- a/chrome/browser/vr/text_edit_action.h +++ b/chrome/browser/vr/text_edit_action.h
@@ -8,6 +8,7 @@ #include <vector> #include "base/strings/string16.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { @@ -19,7 +20,7 @@ DELETE_TEXT, }; -class TextEditAction { +class VR_EXPORT TextEditAction { public: explicit TextEditAction(TextEditActionType type); TextEditAction(TextEditActionType type,
diff --git a/chrome/browser/vr/text_input_delegate.h b/chrome/browser/vr/text_input_delegate.h index bdcccf6..e9ae347 100644 --- a/chrome/browser/vr/text_input_delegate.h +++ b/chrome/browser/vr/text_input_delegate.h
@@ -7,12 +7,13 @@ #include "base/callback.h" #include "base/macros.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { struct TextInputInfo; -class TextInputDelegate { +class VR_EXPORT TextInputDelegate { public: TextInputDelegate(); virtual ~TextInputDelegate();
diff --git a/chrome/browser/vr/toolbar_helper.h b/chrome/browser/vr/toolbar_helper.h index 3a276ce61..43cc021 100644 --- a/chrome/browser/vr/toolbar_helper.h +++ b/chrome/browser/vr/toolbar_helper.h
@@ -7,6 +7,7 @@ #include "chrome/browser/vr/browser_ui_interface.h" #include "chrome/browser/vr/model/toolbar_state.h" +#include "chrome/browser/vr/vr_export.h" class ToolbarModel; class ToolbarModelDelegate; @@ -17,7 +18,7 @@ // This class houses an instance of ToolbarModel, and queries it when requested, // passing a snapshot of the toolbar state to the UI when necessary. -class ToolbarHelper { +class VR_EXPORT ToolbarHelper { public: ToolbarHelper(BrowserUiInterface* ui, ToolbarModelDelegate* delegate); virtual ~ToolbarHelper();
diff --git a/chrome/browser/vr/transition.h b/chrome/browser/vr/transition.h index eba06797..4d93f08 100644 --- a/chrome/browser/vr/transition.h +++ b/chrome/browser/vr/transition.h
@@ -8,10 +8,11 @@ #include <set> #include "base/time/time.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { -struct Transition { +struct VR_EXPORT Transition { Transition(); ~Transition();
diff --git a/chrome/browser/vr/ui.h b/chrome/browser/vr/ui.h index 84b6c4c..6be6a0d 100644 --- a/chrome/browser/vr/ui.h +++ b/chrome/browser/vr/ui.h
@@ -17,6 +17,7 @@ #include "chrome/browser/vr/platform_controller.h" #include "chrome/browser/vr/ui_element_renderer.h" #include "chrome/browser/vr/ui_test_input.h" +#include "chrome/browser/vr/vr_export.h" namespace vr { @@ -39,7 +40,7 @@ struct OmniboxSuggestions; struct ReticleModel; -struct UiInitialState { +struct VR_EXPORT UiInitialState { UiInitialState(); UiInitialState(const UiInitialState& other); bool in_cct = false; @@ -57,7 +58,7 @@ // This class manages all GLThread owned objects and GL rendering for VrShell. // It is not threadsafe and must only be used on the GL thread. -class Ui : public BrowserUiInterface, public KeyboardUiInterface { +class VR_EXPORT Ui : public BrowserUiInterface, public KeyboardUiInterface { public: Ui(UiBrowserInterface* browser, PlatformInputHandler* content_input_forwarder,
diff --git a/chrome/browser/vr/ui_input_manager.cc b/chrome/browser/vr/ui_input_manager.cc index ed53e23..f82f297 100644 --- a/chrome/browser/vr/ui_input_manager.cc +++ b/chrome/browser/vr/ui_input_manager.cc
@@ -116,18 +116,21 @@ } auto element_local_point = reticle_model->target_local_point; + UiElement* captured_element = nullptr; if (input_capture_element_id_) { - auto* captured = scene_->GetUiElementById(input_capture_element_id_); - if (captured && captured->IsVisible()) { + captured_element = scene_->GetUiElementById(input_capture_element_id_); + if (captured_element && captured_element->IsVisible()) { HitTestRequest request; request.ray_target = reticle_model->target_point; request.max_distance_to_plane = 2 * scene_->background_distance(); HitTestResult result; - captured->HitTest(request, &result); + captured_element->HitTest(request, &result); element_local_point = result.local_hit_point; if (result.type == HitTestResult::Type::kNone) { element_local_point = kInvalidTargetPoint; } + } else { + captured_element = nullptr; } } @@ -147,11 +150,15 @@ return; } - SendHoverEvents(target_element, reticle_model->target_local_point); + SendHoverEvents(target_element, reticle_model->target_local_point, + controller_model.touchpad_button_state != ButtonState::DOWN); + if (controller_model.touchpad_button_state == ButtonState::DOWN && + captured_element) { + captured_element->OnTouchMove(element_local_point); + } SendButtonDown(target_element, reticle_model->target_local_point, controller_model.touchpad_button_state); SendButtonUp(element_local_point, controller_model.touchpad_button_state); - previous_button_state_ = controller_model.touchpad_button_state; } @@ -190,18 +197,14 @@ DCHECK_EQ(gesture_list->front()->GetType(), blink::WebInputEvent::kGestureScrollEnd); } - if (element) { - DCHECK(element->scrollable()); - } + DCHECK(!element || element->scrollable()); if (gesture_list->empty() || gesture_list->front()->GetType() != blink::WebInputEvent::kGestureScrollEnd) { return; } DCHECK_LE(gesture_list->size(), 1LU); fling_target_id_ = input_capture_element_id_; - if (element) { - element->OnScrollEnd(std::move(gesture_list->front()), target_point); - } + element->OnScrollEnd(std::move(gesture_list->front()), target_point); gesture_list->erase(gesture_list->begin()); input_capture_element_id_ = 0; in_scroll_ = false; @@ -248,9 +251,11 @@ } void UiInputManager::SendHoverEvents(UiElement* target, - const gfx::PointF& target_point) { + const gfx::PointF& target_point, + bool send_move) { if (target && target->id() == hover_target_id_) { - SendMove(target, target_point); + if (send_move) + target->OnHoverMove(target_point); return; } @@ -265,23 +270,6 @@ } } -void UiInputManager::SendMove(UiElement* element, - const gfx::PointF& target_point) { - DCHECK(element); - if (!element) { - return; - } - // TODO(mthiesse, vollick): Content is currently way too sensitive to - // mouse moves for how noisy the controller is. It's almost impossible - // to click a link without unintentionally starting a drag event. For - // this reason we disable mouse moves, only delivering a down and up - // event. - if (element->name() == kContentQuad && in_click_) { - return; - } - element->OnHoverMove(target_point); -} - void UiInputManager::SendButtonDown(UiElement* target, const gfx::PointF& target_point, ButtonState button_state) { @@ -303,24 +291,19 @@ bool UiInputManager::SendButtonUp(const gfx::PointF& target_point, ButtonState button_state) { - if (!in_click_) { - return false; - } - if (previous_button_state_ == button_state || + if (!in_click_ || previous_button_state_ == button_state || button_state != ButtonState::UP) { return false; } in_click_ = false; - if (!input_capture_element_id_) { + if (!input_capture_element_id_) return false; - } UiElement* element = scene_->GetUiElementById(input_capture_element_id_); if (element) { element->OnButtonUp(target_point); // Clicking outside of the focused element causes it to lose focus. - if (element->id() != focused_element_id_ && element->focusable()) { + if (element->id() != focused_element_id_ && element->focusable()) UnfocusFocusedElement(); - } } input_capture_element_id_ = 0;
diff --git a/chrome/browser/vr/ui_input_manager.h b/chrome/browser/vr/ui_input_manager.h index 45c351d..811b23f 100644 --- a/chrome/browser/vr/ui_input_manager.h +++ b/chrome/browser/vr/ui_input_manager.h
@@ -9,6 +9,7 @@ #include <vector> #include "base/time/time.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/geometry/point3_f.h" #include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/vector3d_f.h" @@ -31,7 +32,7 @@ // Based on controller input finds the hit UI element and determines the // interaction with UI elements and the web contents. -class UiInputManager { +class VR_EXPORT UiInputManager { public: enum ButtonState { UP, // The button is released. @@ -84,7 +85,9 @@ void SendScrollUpdate(GestureList* gesture_list, const gfx::PointF& target_point); - void SendHoverEvents(UiElement* target, const gfx::PointF& target_point); + void SendHoverEvents(UiElement* target, + const gfx::PointF& target_point, + bool send_move); void SendMove(UiElement* element, const gfx::PointF& target_point); void SendButtonDown(UiElement* target, const gfx::PointF& target_point,
diff --git a/chrome/browser/vr/ui_input_manager_unittest.cc b/chrome/browser/vr/ui_input_manager_unittest.cc index 8acdda0..7d34225 100644 --- a/chrome/browser/vr/ui_input_manager_unittest.cc +++ b/chrome/browser/vr/ui_input_manager_unittest.cc
@@ -50,6 +50,7 @@ MOCK_METHOD1(OnHoverMove, void(const gfx::PointF& position)); MOCK_METHOD1(OnButtonDown, void(const gfx::PointF& position)); MOCK_METHOD1(OnButtonUp, void(const gfx::PointF& position)); + MOCK_METHOD1(OnTouchMove, void(const gfx::PointF& position)); MOCK_METHOD2(OnScrollBegin, void(std::unique_ptr<blink::WebGestureEvent>, const gfx::PointF&)); @@ -289,11 +290,14 @@ Mock::VerifyAndClearExpectations(p_element); // Press the button while on the element. - EXPECT_CALL(*p_element, OnHoverMove(_)); EXPECT_CALL(*p_element, OnButtonDown(_)); HandleInput(kForwardVector, kDown); Mock::VerifyAndClearExpectations(p_element); + EXPECT_CALL(*p_element, OnTouchMove(_)); + HandleInput(kForwardVector, kDown); + Mock::VerifyAndClearExpectations(p_element); + // Release the button while on the element. EXPECT_CALL(*p_element, OnHoverMove(_)); EXPECT_CALL(*p_element, OnButtonUp(_)); @@ -306,7 +310,8 @@ Mock::VerifyAndClearExpectations(p_element); // Press while not on the element, move over the element, move away, then - // release. The element should receive hover events. + // release. The element should receive hover enter/leave, but not hover move + // nor touch events. HandleInput(kBackwardVector, kDown); EXPECT_CALL(*p_element, OnHoverEnter(_)); HandleInput(kForwardVector, kDown); @@ -314,11 +319,13 @@ HandleInput(kBackwardVector, kUp); Mock::VerifyAndClearExpectations(p_element); - // Press on an element, move away, then release. + // Press on an element, move away, then release. The element should receive + // hover leave, but keep receiving touch move events until release. EXPECT_CALL(*p_element, OnHoverEnter(_)); EXPECT_CALL(*p_element, OnButtonDown(_)); HandleInput(kForwardVector, kDown); EXPECT_CALL(*p_element, OnHoverLeave()); + EXPECT_CALL(*p_element, OnTouchMove(_)); HandleInput(kBackwardVector, kDown); Mock::VerifyAndClearExpectations(p_element); EXPECT_CALL(*p_element, OnButtonUp(_)); @@ -327,7 +334,8 @@ } // Test pressing the button while on an element, moving to another element, and -// releasing the button. Upon release, the previous element should see its click +// releasing the button. Before release, the first element should still receive +// touch move events. Upon release, the previous element should see its click // and hover states cleared, and the new element should see a hover. TEST_F(UiInputManagerTest, ReleaseButtonOnAnotherElement) { StrictMock<MockRect>* p_front_element = CreateAndAddMockElement(-5.f); @@ -342,6 +350,7 @@ HandleInput(kForwardVector, kDown); EXPECT_CALL(*p_front_element, OnHoverLeave()); EXPECT_CALL(*p_back_element, OnHoverEnter(_)); + EXPECT_CALL(*p_front_element, OnTouchMove(_)); HandleInput(kBackwardVector, kDown); EXPECT_CALL(*p_back_element, OnHoverMove(_)); EXPECT_CALL(*p_front_element, OnButtonUp(_));
diff --git a/chrome/browser/vr/ui_renderer.h b/chrome/browser/vr/ui_renderer.h index e914eaa..8e5796c 100644 --- a/chrome/browser/vr/ui_renderer.h +++ b/chrome/browser/vr/ui_renderer.h
@@ -7,6 +7,7 @@ #include "chrome/browser/vr/model/camera_model.h" #include "chrome/browser/vr/ui_input_manager.h" +#include "chrome/browser/vr/vr_export.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/transform.h" @@ -26,7 +27,7 @@ }; // Renders a UI scene. -class UiRenderer { +class VR_EXPORT UiRenderer { public: UiRenderer(UiScene* scene, UiElementRenderer* ui_element_renderer); ~UiRenderer();
diff --git a/chrome/browser/vr/ui_scene.h b/chrome/browser/vr/ui_scene.h index e25f5dd7..57e9824 100644 --- a/chrome/browser/vr/ui_scene.h +++ b/chrome/browser/vr/ui_scene.h
@@ -14,6 +14,7 @@ #include "chrome/browser/vr/elements/ui_element_name.h" #include "chrome/browser/vr/keyboard_delegate.h" #include "chrome/browser/vr/sequence.h" +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" namespace base { @@ -28,7 +29,7 @@ class UiElement; -class UiScene { +class VR_EXPORT UiScene { public: typedef base::RepeatingCallback<void()> PerFrameCallback;
diff --git a/chrome/browser/vr/ui_scene_creator.cc b/chrome/browser/vr/ui_scene_creator.cc index a7925e4..54e34e4 100644 --- a/chrome/browser/vr/ui_scene_creator.cc +++ b/chrome/browser/vr/ui_scene_creator.cc
@@ -2429,7 +2429,7 @@ kOverflowMenuNewIncognitoTabItem, IDS_VR_MENU_NEW_INCOGNITO_TAB, base::BindRepeating( [](UiBrowserInterface* browser) { browser->OpenNewTab(true); }), - base::BindRepeating([](Model* m) { return true; }), + base::BindRepeating([](Model* m) { return !m->incognito; }), }, {kOverflowMenuCloseAllIncognitoTabsItem, IDS_VR_MENU_CLOSE_INCOGNITO_TABS, base::BindRepeating([](UiBrowserInterface* browser) {
diff --git a/chrome/browser/vr/ui_unittest.cc b/chrome/browser/vr/ui_unittest.cc index 4274611..9858b98c 100644 --- a/chrome/browser/vr/ui_unittest.cc +++ b/chrome/browser/vr/ui_unittest.cc
@@ -1371,6 +1371,12 @@ model_->incognito_tabs.emplace_back(TabModel(0, base::string16())); OnBeginFrame(); + EXPECT_EQ(IsVisible(kOverflowMenuNewIncognitoTabItem), true); + EXPECT_EQ(IsVisible(kOverflowMenuCloseAllIncognitoTabsItem), true); + + model_->incognito = true; + OnBeginFrame(); + EXPECT_EQ(IsVisible(kOverflowMenuNewIncognitoTabItem), false); EXPECT_EQ(IsVisible(kOverflowMenuCloseAllIncognitoTabsItem), true); model_->standalone_vr_device = true;
diff --git a/chrome/browser/vr/vr_export.h b/chrome/browser/vr/vr_export.h new file mode 100644 index 0000000..7c77208 --- /dev/null +++ b/chrome/browser/vr/vr_export.h
@@ -0,0 +1,29 @@ +// Copyright (c) 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VR_VR_EXPORT_H_ +#define CHROME_BROWSER_VR_VR_EXPORT_H_ + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(VR_IMPLEMENTATION) +#define VR_EXPORT __declspec(dllexport) +#else +#define VR_EXPORT __declspec(dllimport) +#endif // defined(VR_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(VR_IMPLEMENTATION) +#define VR_EXPORT __attribute__((visibility("default"))) +#else +#define VR_EXPORT +#endif // defined(VR_IMPLEMENTATION) +#endif + +#else // defined(COMPONENT_BUILD) +#define VR_EXPORT +#endif + +#endif // CHROME_BROWSER_VR_VR_EXPORT_H_
diff --git a/chrome/browser/vr/vr_gl_util.h b/chrome/browser/vr/vr_gl_util.h index 5686249..43e77d0 100644 --- a/chrome/browser/vr/vr_gl_util.h +++ b/chrome/browser/vr/vr_gl_util.h
@@ -8,6 +8,7 @@ #include <array> #include <string> +#include "chrome/browser/vr/vr_export.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/geometry/rect.h" #include "ui/gl/gl_bindings.h" @@ -28,8 +29,8 @@ std::array<float, 16> MatrixToGLArray(const gfx::Transform& matrix); -gfx::Rect CalculatePixelSpaceRect(const gfx::Size& texture_size, - const gfx::RectF& texture_rect); +VR_EXPORT gfx::Rect CalculatePixelSpaceRect(const gfx::Size& texture_size, + const gfx::RectF& texture_rect); // Compile a shader. GLuint CompileShader(GLenum shader_type, @@ -43,9 +44,9 @@ // Returns the normalized size of the element projected into screen space. // If (1, 1) the element fills the entire buffer. -gfx::SizeF CalculateScreenSize(const gfx::Transform& proj_matrix, - float distance, - const gfx::SizeF& size); +VR_EXPORT gfx::SizeF CalculateScreenSize(const gfx::Transform& proj_matrix, + float distance, + const gfx::SizeF& size); // Sets default texture parameters given a texture type. void SetTexParameters(GLenum texture_type);
diff --git a/chrome/chrome_watcher/BUILD.gn b/chrome/chrome_watcher/BUILD.gn index c47f8a8..0783cc8 100644 --- a/chrome/chrome_watcher/BUILD.gn +++ b/chrome/chrome_watcher/BUILD.gn
@@ -59,7 +59,6 @@ ":client", "//base", "//base:base_static", - "//build/config:exe_and_shlib_deps", "//chrome/common:non_code_constants", "//chrome/install_static:secondary_module", "//chrome_elf",
diff --git a/chrome/common/safe_browsing/BUILD.gn b/chrome/common/safe_browsing/BUILD.gn index a4c8092..06f65f9 100644 --- a/chrome/common/safe_browsing/BUILD.gn +++ b/chrome/common/safe_browsing/BUILD.gn
@@ -13,16 +13,74 @@ ] } -source_set("safe_browsing") { +source_set("file_type_policies") { sources = [ "file_type_policies.cc", "file_type_policies.h", ] - if (safe_browsing_mode == 1) { - sources += [ + deps = [ + ":proto", + "//base", + "//chrome/browser:resources", + "//ui/base", + ] +} + +if (safe_browsing_mode == 1) { + source_set("archive_analyzer_results") { + sources = [ "archive_analyzer_results.cc", "archive_analyzer_results.h", + ] + deps = [ + "//base", + ] + public_deps = [ + "//components/safe_browsing:csd_proto", + ] + } + + source_set("rar_analyzer") { + sources = [ + "rar_analyzer.cc", + "rar_analyzer.h", + ] + + deps = [ + ":archive_analyzer_results", + ":file_type_policies", + "//base", + "//third_party/unrar:unrar", + ] + + defines = [ + "_FILE_OFFSET_BITS=64", + "LARGEFILE_SOURCE", + "RAR_SMP", + "SILENT", + + # The following is set to disable certain macro definitions in the unrar + # source code. + "CHROMIUM_UNRAR", + + # Disables exceptions in unrar, replaces them with process termination. + "UNRAR_NO_EXCEPTIONS", + ] + + public_deps = [ + "//components/safe_browsing:csd_proto", + ] + } +} + +source_set("safe_browsing") { + deps = [ + ":file_type_policies", + ] + + if (safe_browsing_mode == 1) { + sources = [ "binary_feature_extractor.cc", "binary_feature_extractor.h", "binary_feature_extractor_mac.cc", @@ -44,17 +102,20 @@ if (is_posix) { sources += [ "binary_feature_extractor_posix.cc" ] } - } - public_deps = [ - "//base:i18n", - "//chrome/browser:resources", - "//chrome/common:mojo_bindings", - "//chrome/common/safe_browsing:proto", - "//components/safe_browsing:csd_proto", - "//crypto", - "//ipc", - "//third_party/zlib/google:zip", - "//ui/base", - ] + deps += [ + ":archive_analyzer_results", + ":rar_analyzer", + ] + + public_deps = [ + ":proto", + "//base:i18n", + "//chrome/common:mojo_bindings", + "//components/safe_browsing:csd_proto", + "//crypto", + "//ipc", + "//third_party/zlib/google:zip", + ] + } }
diff --git a/chrome/common/safe_browsing/DEPS b/chrome/common/safe_browsing/DEPS index 214d5f22..195fc35e 100644 --- a/chrome/common/safe_browsing/DEPS +++ b/chrome/common/safe_browsing/DEPS
@@ -1,4 +1,5 @@ include_rules = [ "+third_party/protobuf", + "+third_party/unrar", "+third_party/zlib", ]
diff --git a/chrome/common/safe_browsing/rar_analyzer.cc b/chrome/common/safe_browsing/rar_analyzer.cc new file mode 100644 index 0000000..5d73d41 --- /dev/null +++ b/chrome/common/safe_browsing/rar_analyzer.cc
@@ -0,0 +1,73 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/safe_browsing/rar_analyzer.h" + +#include <memory> +#include <string> +#include "build/build_config.h" +#include "chrome/common/safe_browsing/archive_analyzer_results.h" +#include "chrome/common/safe_browsing/file_type_policies.h" +#include "third_party/unrar/src/unrar_wrapper.h" + +namespace safe_browsing { +namespace rar_analyzer { + +void AnalyzeRarFile(base::File rar_file, + const base::FilePath& rar_file_path, + ArchiveAnalyzerResults* results) { + auto archive = std::make_unique<third_party_unrar::Archive>(); + archive->SetFileHandle(rar_file.GetPlatformFile()); + std::wstring wide_rar_file_path(rar_file_path.value().begin(), + rar_file_path.value().end()); + if (!archive->Open(wide_rar_file_path.c_str())) { + results->success = false; + // TODO(vakh): Log UMA here. + VLOG(1) << __FUNCTION__ + << ": Unable to open rar_file: " << rar_file.GetPlatformFile(); + return; + } + if (!archive->IsArchive(/*EnableBroken=*/true)) { + // TODO(vakh): Log UMA here. + results->success = false; + VLOG(1) << __FUNCTION__ + << ": !IsArchive: rar_file: " << rar_file.GetPlatformFile(); + return; + } + // TODO(vakh): Log UMA here. + + results->success = true; + std::set<base::FilePath> archived_archive_filenames; + for (archive->ViewComment(); + archive->ReadHeader() > 0 && + archive->GetHeaderType() != third_party_unrar::kUnrarEndarcHead; + archive->SeekToNext()) { + VLOG(2) << __FUNCTION__ << ": FileName: " << archive->FileHead.FileName; + std::wstring wide_filename(archive->FileHead.FileName); +#if defined(OS_WIN) + base::FilePath file_path(wide_filename); +#else + std::string filename(wide_filename.begin(), wide_filename.end()); + base::FilePath file_path(filename); +#endif // OS_WIN + VLOG(2) << __FUNCTION__ << ": file_path: " << file_path.value().c_str(); + + bool is_executable = + FileTypePolicies::GetInstance()->IsCheckedBinaryFile(file_path); + VLOG(2) << __FUNCTION__ << ": is_executable: " << is_executable; + results->has_executable |= is_executable; + + bool is_archive = FileTypePolicies::GetInstance()->IsArchiveFile(file_path); + VLOG(2) << __FUNCTION__ << ": is_archive: " << is_archive; + results->has_archive |= is_archive; + if (is_archive) { + archived_archive_filenames.insert(file_path.BaseName()); + } + results->archived_archive_filenames.assign( + archived_archive_filenames.begin(), archived_archive_filenames.end()); + } +} + +} // namespace rar_analyzer +} // namespace safe_browsing
diff --git a/chrome/common/safe_browsing/rar_analyzer.h b/chrome/common/safe_browsing/rar_analyzer.h new file mode 100644 index 0000000..289450e --- /dev/null +++ b/chrome/common/safe_browsing/rar_analyzer.h
@@ -0,0 +1,49 @@ +// 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. +// +// This file contains the rar file analysis implementation for download +// protection, which runs in a sandbox. The reason for running in a sandbox is +// to isolate the browser and other renderer processes from any vulnerabilities +// that the attacker-controlled download file may try to exploit. +// +// Here's the call flow for inspecting .rar files upon download: +// 1. File is downloaded. +// 2. |CheckClientDownloadRequest::AnalyzeFile()| is called to analyze the Safe +// Browsing reputation of the downloaded file. +// 3. It calls |CheckClientDownloadRequest::StartExtractRarFeatures()|, which +// creates an instance of |SandboxedRarAnalyzer|, and calls |Start()|. +// 4. |SandboxedRarAnalyzer::Start()| leads to a mojo call to +// |SafeArchiveAnalyzer::AnalyzeRarFile()| in a sandbox. +// 5. Finally, |SafeArchiveAnalyzer::AnalyzeRarFile()| calls |AnalyzeRarFile()| +// defined in this file to actually inspect the file. + +#ifndef CHROME_COMMON_SAFE_BROWSING_RAR_ANALYZER_H_ +#define CHROME_COMMON_SAFE_BROWSING_RAR_ANALYZER_H_ + +#include "base/files/file.h" +#include "base/files/file_path.h" + +namespace safe_browsing { + +struct ArchiveAnalyzerResults; + +namespace rar_analyzer { + +// |rar_file| is a platform-agnostic handle to the file. Since |AnalyzeRarFile| +// runs inside a sandbox, it isn't allowed to open file handles. So the file is +// opened in |SandboxedRarAnalyzer|, which runs in the browser process, and the +// handle is passed here. |rar_file_path| is the path to the same file. It is +// required only because the unrar library expects it to be used with a +// filename. The function populates the various fields in |results| based on the +// results of parsing the rar file. +// If the parsing fails for any reason, including crashing the sandbox process, +// the browser process considers the file safe. +void AnalyzeRarFile(base::File rar_file, + const base::FilePath& rar_file_path, + ArchiveAnalyzerResults* results); + +} // namespace rar_analyzer +} // namespace safe_browsing + +#endif // CHROME_COMMON_SAFE_BROWSING_RAR_ANALYZER_H_
diff --git a/chrome/installer/mini_installer/BUILD.gn b/chrome/installer/mini_installer/BUILD.gn index 5c940dd..7189a44 100644 --- a/chrome/installer/mini_installer/BUILD.gn +++ b/chrome/installer/mini_installer/BUILD.gn
@@ -272,15 +272,14 @@ # In general, mini_installer tries to avoid depending on the C++ standard # library for size reasons. This is achieved by setting a custom entry point # (which avoids pulling in the standard library via a link dependency) as - # well as by not depending on exe_and_shlib_deps (which depends on - # libc++ in use_custom_libcxx=true builds). + # well as by not depending on //buildtools/third_party/libc++. # # But in asan builds we need to link against the asan runtime library, which # in turn depends on the standard library and relies on it to run - # initializers. So in asan builds we depend on exe_and_shlib_deps for the - # asan runtime and use the standard entry point. + # initializers. So in asan builds we depend on libc++ for the asan runtime + # and use the standard entry point. if (is_asan) { - deps += [ "//build/config:exe_and_shlib_deps" ] + deps += [ "//buildtools/third_party/libc++" ] } else { ldflags += [ "/ENTRY:MainEntryPoint" ] }
diff --git a/chrome/installer/setup/BUILD.gn b/chrome/installer/setup/BUILD.gn index 6ea3100e..a8d0504 100644 --- a/chrome/installer/setup/BUILD.gn +++ b/chrome/installer/setup/BUILD.gn
@@ -33,7 +33,6 @@ ":buildflags", ":lib", ":setup_exe_version", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//chrome/install_static:install_static_util", "//components/crash/content/app:app",
diff --git a/chrome/installer/test/BUILD.gn b/chrome/installer/test/BUILD.gn index 1ee0552..cb7f71f 100644 --- a/chrome/installer/test/BUILD.gn +++ b/chrome/installer/test/BUILD.gn
@@ -16,7 +16,6 @@ ":alternate_version_generator_lib", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//chrome/common:constants", "//chrome/installer/util:with_rc_strings",
diff --git a/chrome/renderer/extensions/renderer_permissions_policy_delegate.cc b/chrome/renderer/extensions/renderer_permissions_policy_delegate.cc index e37362c4..22fcfa02 100644 --- a/chrome/renderer/extensions/renderer_permissions_policy_delegate.cc +++ b/chrome/renderer/extensions/renderer_permissions_policy_delegate.cc
@@ -4,8 +4,9 @@ #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h" +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" -#include "chrome/renderer/searchbox/search_bouncer.h" #include "extensions/common/constants.h" #include "extensions/common/extensions_client.h" #include "extensions/common/manifest_constants.h" @@ -33,7 +34,8 @@ return true; } - if (SearchBouncer::GetInstance()->IsNewTabPage(document_url)) { + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + ::switches::kInstantProcess)) { if (error) *error = errors::kCannotScriptNtp; return true;
diff --git a/chrome/renderer/media/chrome_key_systems.cc b/chrome/renderer/media/chrome_key_systems.cc index c0cf00b..436b110 100644 --- a/chrome/renderer/media/chrome_key_systems.cc +++ b/chrome/renderer/media/chrome_key_systems.cc
@@ -77,8 +77,8 @@ "org.chromium.externalclearkey.storageidtest"; static const char kExternalClearKeyDifferentGuidTestKeySystem[] = "org.chromium.externalclearkey.differentguid"; - static const char kExternalClearKeyCdmProxyTestKeySystem[] = - "org.chromium.externalclearkey.cdmproxytest"; + static const char kExternalClearKeyCdmProxyKeySystem[] = + "org.chromium.externalclearkey.cdmproxy"; std::vector<media::VideoCodec> supported_video_codecs; bool supports_persistent_license; @@ -134,9 +134,9 @@ concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( kExternalClearKeyDifferentGuidTestKeySystem)); - // A key system that triggers CDM Proxy test in ClearKeyCdm. - concrete_key_systems->emplace_back(new cdm::ExternalClearKeyProperties( - kExternalClearKeyCdmProxyTestKeySystem)); + // A key system that requires the use of CdmProxy. + concrete_key_systems->emplace_back( + new cdm::ExternalClearKeyProperties(kExternalClearKeyCdmProxyKeySystem)); } #if defined(WIDEVINE_CDM_AVAILABLE)
diff --git a/chrome/services/file_util/public/cpp/BUILD.gn b/chrome/services/file_util/public/cpp/BUILD.gn index 88c2008..f55e4fda9 100644 --- a/chrome/services/file_util/public/cpp/BUILD.gn +++ b/chrome/services/file_util/public/cpp/BUILD.gn
@@ -26,11 +26,6 @@ ] } - #TODO(crbug/750327): This dependency is here temporarily. - deps = [ - "//third_party/unrar:unrar", - ] - public_deps += [ "//chrome/common/safe_browsing" ] } }
diff --git a/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.cc b/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.cc index 7d5c2b90..133755bd 100644 --- a/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.cc +++ b/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.cc
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/files/file_util.h" +#include "base/process/process_handle.h" #include "base/strings/stringprintf.h" #include "base/task_scheduler/post_task.h" #include "chrome/common/safe_browsing/archive_analyzer_results.h" @@ -17,10 +18,10 @@ #include "services/service_manager/public/cpp/connector.h" SandboxedRarAnalyzer::SandboxedRarAnalyzer( - const base::FilePath& rar_file, + const base::FilePath& rar_file_path, const ResultCallback& callback, service_manager::Connector* connector) - : file_path_(rar_file), callback_(callback), connector_(connector) { + : file_path_(rar_file_path), callback_(callback), connector_(connector) { DCHECK(callback); DCHECK(!file_path_.value().empty()); } @@ -37,7 +38,7 @@ SandboxedRarAnalyzer::~SandboxedRarAnalyzer() = default; -void SandboxedRarAnalyzer::AnalyzeFile() { +void SandboxedRarAnalyzer::AnalyzeFile(base::File file) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK(!analyzer_ptr_); DCHECK(!file_path_.value().empty()); @@ -48,34 +49,41 @@ &SandboxedRarAnalyzer::AnalyzeFileDone, base::Unretained(this), safe_browsing::ArchiveAnalyzerResults())); analyzer_ptr_->AnalyzeRarFile( - file_path_, base::BindOnce(&SandboxedRarAnalyzer::AnalyzeFileDone, this)); + std::move(file), file_path_, + base::BindOnce(&SandboxedRarAnalyzer::AnalyzeFileDone, this)); } void SandboxedRarAnalyzer::AnalyzeFileDone( const safe_browsing::ArchiveAnalyzerResults& results) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - analyzer_ptr_.reset(); callback_.Run(results); } void SandboxedRarAnalyzer::PrepareFileToAnalyze() { - base::File file(file_path_, base::File::FLAG_OPEN | base::File::FLAG_READ); + if (file_path_.value().empty()) { + // TODO(vakh): Add UMA metrics here to check how often this happens. + DLOG(ERROR) << "file_path_ empty!"; + ReportFileFailure(); + return; + } + base::File file(file_path_, base::File::FLAG_OPEN | base::File::FLAG_READ); if (!file.IsValid()) { // TODO(vakh): Add UMA metrics here to check how often this happens. + DLOG(ERROR) << "Could not open file: " << file_path_.value(); ReportFileFailure(); return; } content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, - base::BindOnce(&SandboxedRarAnalyzer::AnalyzeFile, this)); + base::BindOnce(&SandboxedRarAnalyzer::AnalyzeFile, this, + std::move(file))); } void SandboxedRarAnalyzer::ReportFileFailure() { DCHECK(!analyzer_ptr_); - content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::BindOnce(callback_, safe_browsing::ArchiveAnalyzerResults()));
diff --git a/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.h b/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.h index 79a474c3..295347b2f 100644 --- a/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.h +++ b/chrome/services/file_util/public/cpp/sandboxed_rar_analyzer.h
@@ -28,7 +28,7 @@ using ResultCallback = base::RepeatingCallback<void( const safe_browsing::ArchiveAnalyzerResults&)>; - SandboxedRarAnalyzer(const base::FilePath& rar_file, + SandboxedRarAnalyzer(const base::FilePath& rar_file_path, const ResultCallback& callback, service_manager::Connector* connector); @@ -50,7 +50,7 @@ void ReportFileFailure(); // Starts the utility process and sends it a file analyze request. - void AnalyzeFile(); + void AnalyzeFile(base::File file); // The response containing the file analyze results. void AnalyzeFileDone(const safe_browsing::ArchiveAnalyzerResults& results);
diff --git a/chrome/services/file_util/public/mojom/safe_archive_analyzer.mojom b/chrome/services/file_util/public/mojom/safe_archive_analyzer.mojom index 378ee92..650f037b 100644 --- a/chrome/services/file_util/public/mojom/safe_archive_analyzer.mojom +++ b/chrome/services/file_util/public/mojom/safe_archive_analyzer.mojom
@@ -26,7 +26,8 @@ // Build flag FULL_SAFE_BROWSING: Analyze the |rar_file| for malicious // download protection. - AnalyzeRarFile(mojo_base.mojom.FilePath rar_file) + AnalyzeRarFile(mojo_base.mojom.File rar_file, + mojo_base.mojom.FilePath rar_file_path) => (SafeArchiveAnalyzerResults results); };
diff --git a/chrome/services/file_util/safe_archive_analyzer.cc b/chrome/services/file_util/safe_archive_analyzer.cc index f0bb062..37cdb11 100644 --- a/chrome/services/file_util/safe_archive_analyzer.cc +++ b/chrome/services/file_util/safe_archive_analyzer.cc
@@ -7,6 +7,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "chrome/common/safe_browsing/archive_analyzer_results.h" +#include "chrome/common/safe_browsing/rar_analyzer.h" #include "chrome/common/safe_browsing/zip_analyzer.h" #include "mojo/public/cpp/bindings/strong_binding.h" @@ -44,15 +45,14 @@ #endif } -void SafeArchiveAnalyzer::AnalyzeRarFile(const base::FilePath& rar_file_path, +void SafeArchiveAnalyzer::AnalyzeRarFile(base::File rar_file, + const base::FilePath& rar_file_path, AnalyzeRarFileCallback callback) { + DCHECK(rar_file.IsValid()); DCHECK(!rar_file_path.value().empty()); safe_browsing::ArchiveAnalyzerResults results; - base::File file(rar_file_path, base::File::FLAG_OPEN | base::File::FLAG_READ); - if (!file.IsValid()) { - results.success = false; - } - // TODO(crbug/750327): Inspect |file|. + safe_browsing::rar_analyzer::AnalyzeRarFile(std::move(rar_file), + rar_file_path, &results); std::move(callback).Run(results); }
diff --git a/chrome/services/file_util/safe_archive_analyzer.h b/chrome/services/file_util/safe_archive_analyzer.h index 8fa67a3..4c5924e9 100644 --- a/chrome/services/file_util/safe_archive_analyzer.h +++ b/chrome/services/file_util/safe_archive_analyzer.h
@@ -26,7 +26,8 @@ AnalyzeZipFileCallback callback) override; void AnalyzeDmgFile(base::File dmg_file, AnalyzeDmgFileCallback callback) override; - void AnalyzeRarFile(const base::FilePath& rar_file_path, + void AnalyzeRarFile(base::File rar_file, + const base::FilePath& rar_file_path, AnalyzeRarFileCallback callback) override; const std::unique_ptr<service_manager::ServiceContextRef> service_ref_;
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 426cef1..8b475f8 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -3700,8 +3700,11 @@ "../browser/password_manager/native_backend_kwallet_x_unittest.cc", "../browser/shell_integration_linux_unittest.cc", "../browser/ui/input_method/input_method_engine_unittest.cc", - "../browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc", ] + } + if (!is_chromeos && !is_chromecast && is_linux) { + sources += + [ "../browser/ui/libgtkui/select_file_dialog_impl_gtk_unittest.cc" ] deps += [ "//build/config/linux/gtk" ] } @@ -4657,7 +4660,10 @@ "../browser/ui/exclusive_access/fullscreen_controller_interactive_browsertest.cc", "../browser/ui/exclusive_access/fullscreen_controller_state_interactive_browsertest.cc", "../browser/ui/find_bar/find_bar_host_interactive_uitest.cc", + "../browser/ui/fullscreen_keyboard_browsertest_base.cc", + "../browser/ui/fullscreen_keyboard_browsertest_base.h", "../browser/ui/hung_renderer/hung_renderer_interactive_uitest.cc", + "../browser/ui/keyboard_lock_interactive_browsertest.cc", "../browser/ui/omnibox/omnibox_view_browsertest.cc", "../browser/ui/passwords/manage_passwords_test.cc", "../browser/ui/passwords/manage_passwords_test.h",
diff --git a/chrome/test/chromedriver/BUILD.gn b/chrome/test/chromedriver/BUILD.gn index b22e8f6e..811f4cf3 100644 --- a/chrome/test/chromedriver/BUILD.gn +++ b/chrome/test/chromedriver/BUILD.gn
@@ -320,7 +320,6 @@ deps = [ ":lib", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/chrome/test/chromedriver/test/test_expectations b/chrome/test/chromedriver/test/test_expectations index b7fbe4f..1db587a6 100644 --- a/chrome/test/chromedriver/test/test_expectations +++ b/chrome/test/chromedriver/test/test_expectations
@@ -212,9 +212,6 @@ 'BasicMouseInterfaceTest.testMoveAndClick', 'BasicMouseInterfaceTest.testShouldClickElementInIFrame', 'CombinedInputActionsTest.testCanClickOnLinks', - - # https://bugs.chromium.org/p/chromedriver/issues/detail?id=998 - 'ImplicitWaitTest.testShouldImplicitlyWaitForASingleElement', ] _OS_NEGATIVE_FILTER['android:chrome_stable'] = ( _OS_NEGATIVE_FILTER['android:chrome'] + [
diff --git a/chrome/test/data/extensions/api_test/ntp_content_script/background.js b/chrome/test/data/extensions/api_test/ntp_content_script/background.js new file mode 100644 index 0000000..558f3ed --- /dev/null +++ b/chrome/test/data/extensions/api_test/ntp_content_script/background.js
@@ -0,0 +1,5 @@ +// 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. + +chrome.test.sendMessage('ready');
diff --git a/chrome/test/data/extensions/api_test/ntp_content_script/content_script.js b/chrome/test/data/extensions/api_test/ntp_content_script/content_script.js new file mode 100644 index 0000000..b8a5a02 --- /dev/null +++ b/chrome/test/data/extensions/api_test/ntp_content_script/content_script.js
@@ -0,0 +1,7 @@ +// 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. + +document.addEventListener('DOMContentLoaded', function() { + document.title = 'injected'; +});
diff --git a/chrome/test/data/extensions/api_test/ntp_content_script/fake_ntp.html b/chrome/test/data/extensions/api_test/ntp_content_script/fake_ntp.html new file mode 100644 index 0000000..2a39a50 --- /dev/null +++ b/chrome/test/data/extensions/api_test/ntp_content_script/fake_ntp.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<html> +<head> + <title>Fake NTP</title> +</head> +<body> +</body> +</html>
diff --git a/chrome/test/data/extensions/api_test/ntp_content_script/manifest.json b/chrome/test/data/extensions/api_test/ntp_content_script/manifest.json new file mode 100644 index 0000000..efa8cc38 --- /dev/null +++ b/chrome/test/data/extensions/api_test/ntp_content_script/manifest.json
@@ -0,0 +1,23 @@ +{ + "manifest_version": 2, + "name": "NTP content script injection", + "version": "1", + "description": "Test for crbug.com/844428", + "content_scripts": [ + { + "matches": [ + "<all_urls>" + ], + "js": [ + "content_script.js" + ], + "run_at": "document_start", + "all_frames": true + } + ], + "background": { + "scripts": [ + "background.js" + ] + } +}
diff --git a/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html b/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html index 4cef2e05..8869800a 100644 --- a/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html +++ b/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html
@@ -11,6 +11,7 @@ <script> let x_pressed = false; let report_called = false; + let prevent_default = true; function processResult() { if (x_pressed && report_called) { @@ -61,7 +62,9 @@ ' alt:' + e.getModifierState('Alt') + ' meta:' + e.getModifierState('Meta') + '\n'; } - e.preventDefault(); + if (prevent_default) { + e.preventDefault(); + } } function init() { @@ -73,6 +76,9 @@ // Web page can consume fullscreen shortcut when the page is in // window mode, but it's not expected in test cases. return; + } else if (e.code == 'KeyD') { + // Disable prevent default behavior. + prevent_default = false; } consumeEvent('keydown', e); });
diff --git a/chrome/test/data/webui/discards/discards_browsertest.js b/chrome/test/data/webui/discards/discards_browsertest.js index 48465dc..aa042b7 100644 --- a/chrome/test/data/webui/discards/discards_browsertest.js +++ b/chrome/test/data/webui/discards/discards_browsertest.js
@@ -20,10 +20,9 @@ let dummy1 = { title: 'title 1', tabUrl: 'http://urlone.com', - visibility: 0, + visibility: 0, // hidden + state: 0, // active isMedia: false, - isFrozen: false, - isDiscarded: false, isAutoDiscardable: false, discardCount: 0, utilityRank: 0, @@ -32,7 +31,8 @@ let dummy2 = { title: 'title 2', tabUrl: 'http://urltwo.com', - visibility: 1, + visibility: 1, // occluded + state: 3, // frozen isMedia: true, isFrozen: true, isDiscarded: true, @@ -42,8 +42,8 @@ lastActiveSeconds: 1 }; - ['title', 'tabUrl', 'visibility', 'isMedia', 'isFrozen', 'isDiscarded', - 'isAutoDiscardable', 'discardCount', 'utilityRank', 'lastActiveSeconds'] + ['title', 'tabUrl', 'visibility', 'state', 'isMedia', 'isAutoDiscardable', + 'discardCount', 'utilityRank', 'lastActiveSeconds'] .forEach((sortKey) => { assertTrue( discards.compareTabDiscardsInfos(sortKey, dummy1, dummy2) < 0);
diff --git a/chrome/tools/convert_dict/BUILD.gn b/chrome/tools/convert_dict/BUILD.gn index 573baae..089b379 100644 --- a/chrome/tools/convert_dict/BUILD.gn +++ b/chrome/tools/convert_dict/BUILD.gn
@@ -33,7 +33,6 @@ ":lib", "//base", "//base:i18n", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/hunspell", ]
diff --git a/chrome/tools/service_discovery_sniffer/BUILD.gn b/chrome/tools/service_discovery_sniffer/BUILD.gn index 5c3ba63..9355aae 100644 --- a/chrome/tools/service_discovery_sniffer/BUILD.gn +++ b/chrome/tools/service_discovery_sniffer/BUILD.gn
@@ -14,7 +14,6 @@ deps = [ "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//chrome/browser", "//net", "//third_party/webrtc_overrides:init_webrtc",
diff --git a/chrome/utility/safe_browsing/mac/BUILD.gn b/chrome/utility/safe_browsing/mac/BUILD.gn index b8fbf25..4ac0be1 100644 --- a/chrome/utility/safe_browsing/mac/BUILD.gn +++ b/chrome/utility/safe_browsing/mac/BUILD.gn
@@ -15,7 +15,8 @@ deps = [ ":dmg_common", "//base", - "//chrome/common", + "//chrome/common/safe_browsing:archive_analyzer_results", + "//chrome/common/safe_browsing:safe_browsing", "//components/safe_browsing:csd_proto", ] }
diff --git a/chrome_elf/BUILD.gn b/chrome_elf/BUILD.gn index ebc3f38..2451bb4 100644 --- a/chrome_elf/BUILD.gn +++ b/chrome_elf/BUILD.gn
@@ -59,7 +59,6 @@ ":nt_registry", ":security", ":third_party_dlls", - "//build/config:exe_and_shlib_deps", "//chrome/install_static:install_static_util", "//chrome/install_static:primary_module", "//components/crash/content/app:crash_export_thunks", @@ -169,7 +168,6 @@ ] deps = [ ":dll_hash", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -370,9 +368,6 @@ sources = [ "third_party_dlls/main_unittest_dll_1.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } shared_library("main_unittest_dll_2") { @@ -381,9 +376,6 @@ "third_party_dlls/main_unittest_dll_2.cc", "third_party_dlls/main_unittest_dll_2.def", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } executable("third_party_dlls_test_exe") { @@ -395,7 +387,6 @@ deps = [ ":third_party_dlls", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//chrome/install_static:install_static_util", "//components/crash/content/app:crash_export_stubs", @@ -413,7 +404,6 @@ ":blacklist", ":nt_registry", "//base", - "//build/config:exe_and_shlib_deps", "//chrome/install_static:install_static_util", "//components/crash/content/app:test_support", ] @@ -425,9 +415,6 @@ "blacklist/test/blacklist_test_dll_1.cc", "blacklist/test/blacklist_test_dll_1.def", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } loadable_module("blacklist_test_dll_2") { @@ -436,9 +423,6 @@ "blacklist/test/blacklist_test_dll_2.cc", "blacklist/test/blacklist_test_dll_2.def", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } # As-is, this does not generate a .lib file because there are no exports and no @@ -451,9 +435,6 @@ sources = [ "blacklist/test/blacklist_test_dll_3.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } shared_library("hook_util_test_dll") { @@ -462,7 +443,4 @@ "hook_util/test/hook_util_test_dll.cc", "hook_util/test/hook_util_test_dll.h", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] }
diff --git a/chromecast/browser/cast_content_window.h b/chromecast/browser/cast_content_window.h index 475b1b1d..c8df02e 100644 --- a/chromecast/browser/cast_content_window.h +++ b/chromecast/browser/cast_content_window.h
@@ -29,19 +29,23 @@ DEFAULT = 0, // The activity wants to occupy the full screen for some period of time and - // then become hidden after a timeout. - TRANSIENT_ACTIVITY = 1, + // then become hidden after a timeout. When timeout, it returns to the + // previous activity. + TRANSIENT_TIMEOUTABLE = 1, // A high priority interruption occupies half of the screen if a sticky // activity is showing on the screen. Otherwise, it occupies the full screen. HIGH_PRIORITY_INTERRUPTION = 2, - // The activity wants to be persistently visible. Unlike TRANSIENT_ACTIVITY, - // there should be no timeout. + // The activity takes place of other activity and won't be timeout. STICKY_ACTIVITY = 3, + // The activity stays on top of others (transient) but won't be timeout. + // When the activity finishes, it returns to the previous one. + TRANSIENT_STICKY = 4, + // The activity should not be visible. - HIDDEN = 4, + HIDDEN = 5, }; enum class GestureType { NO_GESTURE = 0, GO_BACK = 1 };
diff --git a/chromecast/browser/ui/aura/accessibility/automation_manager_aura.cc b/chromecast/browser/ui/aura/accessibility/automation_manager_aura.cc index 190f770..1ea4341c 100644 --- a/chromecast/browser/ui/aura/accessibility/automation_manager_aura.cc +++ b/chromecast/browser/ui/aura/accessibility/automation_manager_aura.cc
@@ -141,8 +141,7 @@ std::vector<ExtensionMsg_AccessibilityEventParams> events; events.emplace_back(ExtensionMsg_AccessibilityEventParams()); ExtensionMsg_AccessibilityEventParams& params = events.back(); - current_tree_serializer_->BeginSerializingChanges(¶ms.update); - if (!current_tree_serializer_->SerializeOneChange(aura_obj)) { + if (!current_tree_serializer_->SerializeChanges(aura_obj, ¶ms.update)) { LOG(ERROR) << "Unable to serialize one accessibility event."; return; } @@ -151,9 +150,7 @@ views::AXAuraObjWrapper* focus = views::AXAuraObjCache::GetInstance()->GetFocus(); if (focus) - current_tree_serializer_->SerializeOneChange(focus); - - current_tree_serializer_->FinishSerializingChanges(); + current_tree_serializer_->SerializeChanges(focus, ¶ms.update); params.tree_id = 0; params.id = aura_obj->GetUniqueId().Get();
diff --git a/chromecast/chromecast.gni b/chromecast/chromecast.gni index 1907fb6..9dba4bf 100644 --- a/chromecast/chromecast.gni +++ b/chromecast/chromecast.gni
@@ -110,8 +110,6 @@ enable_chromecast_extensions = enable_extensions -# These templates are a temporary fix fo link libc++ into shared libraries and -# executables. These should be removed as soon as crbug.com/746091 is resolved. foreach(target_type, [ "executable", @@ -124,14 +122,6 @@ forward_variables_from(invoker, "*") configs += [ "//chromecast:cast_config" ] - - if (!defined(deps)) { - deps = [] - } - - if (target_type != "source_set") { - deps += [ "//build/config:exe_and_shlib_deps" ] - } } } }
diff --git a/chromecast/renderer/media/key_systems_cast.cc b/chromecast/renderer/media/key_systems_cast.cc index fb9c731..81cc86b7 100644 --- a/chromecast/renderer/media/key_systems_cast.cc +++ b/chromecast/renderer/media/key_systems_cast.cc
@@ -112,8 +112,9 @@ SupportedCodecs GetCastEmeSupportedCodecs() { SupportedCodecs codecs = ::media::EME_CODEC_MP4_AAC | ::media::EME_CODEC_MP4_AVC1 | - ::media::EME_CODEC_COMMON_VP9 | ::media::EME_CODEC_WEBM_VP8 | - ::media::EME_CODEC_WEBM_VP9; + ::media::EME_CODEC_MP4_FLAC | ::media::EME_CODEC_COMMON_VP9 | + ::media::EME_CODEC_WEBM_OPUS | ::media::EME_CODEC_WEBM_VORBIS | + ::media::EME_CODEC_WEBM_VP8 | ::media::EME_CODEC_WEBM_VP9; #if BUILDFLAG(ENABLE_HEVC_DEMUXING) codecs |= ::media::EME_CODEC_MP4_HEVC;
diff --git a/chromeos/system/name_value_pairs_parser.cc b/chromeos/system/name_value_pairs_parser.cc index 94454e9..b6e1877 100644 --- a/chromeos/system/name_value_pairs_parser.cc +++ b/chromeos/system/name_value_pairs_parser.cc
@@ -73,6 +73,17 @@ comment_delim); } +void NameValuePairsParser::DeletePairsWithValue(const std::string& value) { + auto it = map_->begin(); + while (it != map_->end()) { + if (it->second == value) { + it = map_->erase(it); + } else { + it++; + } + } +} + void NameValuePairsParser::AddNameValuePair(const std::string& key, const std::string& value) { const auto it = map_->find(key);
diff --git a/chromeos/system/name_value_pairs_parser.h b/chromeos/system/name_value_pairs_parser.h index 50cc5ec..a16a7aa8 100644 --- a/chromeos/system/name_value_pairs_parser.h +++ b/chromeos/system/name_value_pairs_parser.h
@@ -43,6 +43,9 @@ const std::string& delim, const std::string& comment_delim); + // Delete all pairs with |value|. + void DeletePairsWithValue(const std::string& value); + private: FRIEND_TEST_ALL_PREFIXES(NameValuePairsParser, TestParseNameValuePairs); FRIEND_TEST_ALL_PREFIXES(NameValuePairsParser,
diff --git a/chromeos/system/name_value_pairs_parser_unittest.cc b/chromeos/system/name_value_pairs_parser_unittest.cc index e7eeecfa..7bed31a 100644 --- a/chromeos/system/name_value_pairs_parser_unittest.cc +++ b/chromeos/system/name_value_pairs_parser_unittest.cc
@@ -104,5 +104,16 @@ map["vdat_timers"]); } +TEST(NameValuePairsParser, DeletePairsWithValue) { + NameValuePairsParser::NameValueMap map = { + {"foo", "good"}, {"bar", "bad"}, {"baz", "good"}, {"end", "bad"}, + }; + NameValuePairsParser parser(&map); + parser.DeletePairsWithValue("bad"); + ASSERT_EQ(2u, map.size()); + EXPECT_EQ("good", map["foo"]); + EXPECT_EQ("good", map["baz"]); +} + } // namespace system } // namespace chromeos
diff --git a/chromeos/system/statistics_provider.cc b/chromeos/system/statistics_provider.cc index 3abad2d..a2967d1 100644 --- a/chromeos/system/statistics_provider.cc +++ b/chromeos/system/statistics_provider.cc
@@ -327,8 +327,8 @@ base::TimeDelta dtime = base::Time::Now() - start_time; if (statistics_loaded_.IsSignaled()) { - LOG(WARNING) << "Statistics loaded after waiting " - << dtime.InMilliseconds() << "ms."; + VLOG(1) << "Statistics loaded after waiting " << dtime.InMilliseconds() + << "ms."; return true; } @@ -524,6 +524,9 @@ kCrosSystemCommentDelim)) { LOG(ERROR) << "Errors parsing output from: " << kCrosSystemTool; } + // Drop useless "(error)" values so they don't displace valid values + // supplied later by other tools: https://crbug.com/844258 + parser.DeletePairsWithValue(kCrosSystemValueError); } base::FilePath machine_info_path; @@ -569,11 +572,8 @@ // Ensure that the hardware class key is present with the expected // key name, and if it couldn't be retrieved, that the value is "unknown". std::string hardware_class = machine_info_[kHardwareClassCrosSystemKey]; - if (hardware_class.empty() || hardware_class == kCrosSystemValueError) { - machine_info_[kHardwareClassKey] = kHardwareClassValueUnknown; - } else { - machine_info_[kHardwareClassKey] = hardware_class; - } + machine_info_[kHardwareClassKey] = + !hardware_class.empty() ? hardware_class : kHardwareClassValueUnknown; if (base::SysInfo::IsRunningOnChromeOS()) { // By default, assume that this is *not* a VM. If crossystem is not present,
diff --git a/components/cronet/BUILD.gn b/components/cronet/BUILD.gn index 5d528ff..59522b7 100644 --- a/components/cronet/BUILD.gn +++ b/components/cronet/BUILD.gn
@@ -86,10 +86,6 @@ shared_library("cronet") { deps = [ "//base", - - # Explicitly add the exe_and_shlib_deps, otherwise the library will fail - # to link in component builds, due to missing libc++ symbols. - "//build/config:exe_and_shlib_deps", "//components/cronet:cronet_common", "//components/cronet/native:cronet_native_impl", "//net",
diff --git a/components/exo/wayland/BUILD.gn b/components/exo/wayland/BUILD.gn index 0129450b..25def53 100644 --- a/components/exo/wayland/BUILD.gn +++ b/components/exo/wayland/BUILD.gn
@@ -162,7 +162,6 @@ deps = [ ":client_support", "//base", - "//build/config:exe_and_shlib_deps", "//skia", "//third_party/wayland:wayland_client", "//third_party/wayland-protocols:input_timestamps_protocol", @@ -215,7 +214,6 @@ ":client_support", ":simple", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -227,7 +225,6 @@ deps = [ ":client_support", "//base", - "//build/config:exe_and_shlib_deps", "//skia", "//third_party/wayland:wayland_client", "//third_party/wayland-protocols:linux_dmabuf_protocol", @@ -275,7 +272,6 @@ ":blur", ":client_support", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -287,7 +283,6 @@ deps = [ ":client_support", "//base", - "//build/config:exe_and_shlib_deps", "//third_party/wayland:wayland_client", "//ui/gfx/geometry", ] @@ -343,7 +338,6 @@ deps = [ ":client_support", "//base", - "//build/config:exe_and_shlib_deps", "//skia", "//third_party/wayland:wayland_client", "//third_party/wayland-protocols:linux_dmabuf_protocol",
diff --git a/components/feed/core/BUILD.gn b/components/feed/core/BUILD.gn index 74be816..981190f 100644 --- a/components/feed/core/BUILD.gn +++ b/components/feed/core/BUILD.gn
@@ -2,6 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if (is_android) { + import("//build/config/android/rules.gni") +} + source_set("feed_core") { sources = [ "feed_host_service.cc", @@ -12,6 +16,8 @@ "feed_image_manager.h", "feed_networking_host.cc", "feed_networking_host.h", + "feed_scheduler_host.cc", + "feed_scheduler_host.h", "time_serialization.cc", "time_serialization.h", ] @@ -38,6 +44,14 @@ ] } +if (is_android) { + java_cpp_enum("feed_core_java_enums_srcjar") { + sources = [ + "feed_scheduler_host.h", + ] + } +} + source_set("core_unit_tests") { testonly = true sources = [
diff --git a/components/feed/core/feed_host_service.cc b/components/feed/core/feed_host_service.cc index 72e985c..e06bb3f 100644 --- a/components/feed/core/feed_host_service.cc +++ b/components/feed/core/feed_host_service.cc
@@ -10,9 +10,11 @@ FeedHostService::FeedHostService( std::unique_ptr<FeedImageManager> image_manager, - std::unique_ptr<FeedNetworkingHost> networking_host) + std::unique_ptr<FeedNetworkingHost> networking_host, + std::unique_ptr<FeedSchedulerHost> scheduler_host) : image_manager_(std::move(image_manager)), - networking_host_(std::move(networking_host)) {} + networking_host_(std::move(networking_host)), + scheduler_host_(std::move(scheduler_host)) {} FeedHostService::~FeedHostService() = default; @@ -24,4 +26,8 @@ return networking_host_.get(); } +FeedSchedulerHost* FeedHostService::GetSchedulerHost() { + return scheduler_host_.get(); +} + } // namespace feed
diff --git a/components/feed/core/feed_host_service.h b/components/feed/core/feed_host_service.h index 4270b31..88d12de 100644 --- a/components/feed/core/feed_host_service.h +++ b/components/feed/core/feed_host_service.h
@@ -10,6 +10,7 @@ #include "base/macros.h" #include "components/feed/core/feed_image_manager.h" #include "components/feed/core/feed_networking_host.h" +#include "components/feed/core/feed_scheduler_host.h" #include "components/keyed_service/core/keyed_service.h" namespace feed { @@ -22,15 +23,18 @@ class FeedHostService : public KeyedService { public: FeedHostService(std::unique_ptr<FeedImageManager> image_manager, - std::unique_ptr<FeedNetworkingHost> networking_host); + std::unique_ptr<FeedNetworkingHost> networking_host, + std::unique_ptr<FeedSchedulerHost> scheduler_host); ~FeedHostService() override; FeedImageManager* GetImageManager(); FeedNetworkingHost* GetNetworkingHost(); + FeedSchedulerHost* GetSchedulerHost(); private: std::unique_ptr<FeedImageManager> image_manager_; std::unique_ptr<FeedNetworkingHost> networking_host_; + std::unique_ptr<FeedSchedulerHost> scheduler_host_; DISALLOW_COPY_AND_ASSIGN(FeedHostService); };
diff --git a/components/feed/core/feed_scheduler_host.cc b/components/feed/core/feed_scheduler_host.cc new file mode 100644 index 0000000..75b0e120 --- /dev/null +++ b/components/feed/core/feed_scheduler_host.cc
@@ -0,0 +1,37 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/feed/core/feed_scheduler_host.h" + +#include <utility> + +#include "base/time/time.h" + +namespace feed { + +FeedSchedulerHost::FeedSchedulerHost() {} + +FeedSchedulerHost::~FeedSchedulerHost() {} + +NativeRequestBehavior FeedSchedulerHost::ShouldSessionRequestData( + bool has_content, + base::Time content_creation_date_time, + bool has_outstanding_request) { + return REQUEST_WITH_CONTENT; +} + +void FeedSchedulerHost::OnReceiveNewContent() {} + +void FeedSchedulerHost::OnRequestError(int network_response_code) {} + +void FeedSchedulerHost::RegisterTriggerRefreshCallback( + base::RepeatingClosure callback) { + // There should only ever be one scheduler host and bridge created. This may + // stop being true eventually. + DCHECK(trigger_refresh_.is_null()); + + trigger_refresh_ = std::move(callback); +} + +} // namespace feed
diff --git a/components/feed/core/feed_scheduler_host.h b/components/feed/core/feed_scheduler_host.h new file mode 100644 index 0000000..577c5b02 --- /dev/null +++ b/components/feed/core/feed_scheduler_host.h
@@ -0,0 +1,64 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_FEED_CORE_FEED_SCHEDULER_HOST_H_ +#define COMPONENTS_FEED_CORE_FEED_SCHEDULER_HOST_H_ + +#include "base/callback.h" +#include "base/macros.h" + +namespace base { +class Time; +} // namespace base + +namespace feed { + +// The enum values and names are kept in sync with SchedulerApi.RequestBehavior +// through Java unit tests, new values however must be manually added. If any +// new values are added, also update FeedSchedulerBridgeTest.java. +// A Java counterpart will be generated for this enum. +// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.feed +enum NativeRequestBehavior { + UNKNOWN = 0, + REQUEST_WITH_WAIT, + REQUEST_WITH_CONTENT, + REQUEST_WITH_TIMEOUT, + NO_REQUEST_WITH_WAIT, + NO_REQUEST_WITH_CONTENT, + NO_REQUEST_WITH_TIMEOUT +}; + +// Implementation of the Feed Scheduler Host API. The scheduler host decides +// what content is allowed to be shown, based on its age, and when to fetch new +// content. +class FeedSchedulerHost { + public: + FeedSchedulerHost(); + ~FeedSchedulerHost(); + + // Called when the NTP is opened to decide how to handle displaying and + // refreshing content. + NativeRequestBehavior ShouldSessionRequestData( + bool has_content, + base::Time content_creation_date_time, + bool has_outstanding_request); + + // Called when a successful refresh completes. + void OnReceiveNewContent(); + + // Called when an unsuccessful refresh completes. + void OnRequestError(int network_response_code); + + // Registers a callback to trigger a refresh. + void RegisterTriggerRefreshCallback(base::RepeatingClosure callback); + + private: + base::RepeatingClosure trigger_refresh_; + + DISALLOW_COPY_AND_ASSIGN(FeedSchedulerHost); +}; + +} // namespace feed + +#endif // COMPONENTS_FEED_CORE_FEED_SCHEDULER_HOST_H_
diff --git a/components/nacl/loader/BUILD.gn b/components/nacl/loader/BUILD.gn index c468773c..c5de97b 100644 --- a/components/nacl/loader/BUILD.gn +++ b/components/nacl/loader/BUILD.gn
@@ -124,7 +124,6 @@ deps = [ ":loader", "//base", - "//build/config:exe_and_shlib_deps", "//components/nacl/common:switches", "//components/nacl/loader/sandbox_linux", "//content/public/common",
diff --git a/components/password_manager/core/browser/form_parsing/form_parser.cc b/components/password_manager/core/browser/form_parsing/form_parser.cc index acddf93..b6b94761 100644 --- a/components/password_manager/core/browser/form_parsing/form_parser.cc +++ b/components/password_manager/core/browser/form_parsing/form_parser.cc
@@ -326,9 +326,7 @@ const FormFieldData* focusable_username = nullptr; const FormFieldData* username = nullptr; // Do reverse search to find the closest candidates preceding the password. - for (auto it = std::reverse_iterator< - std::vector<const FormFieldData*>::const_iterator>( - first_relevant_password_it); + for (auto it = std::make_reverse_iterator(first_relevant_password_it); it != fields.rend(); ++it) { if ((*it)->form_control_type == "password") continue;
diff --git a/components/policy/proto/device_management_backend.proto b/components/policy/proto/device_management_backend.proto index 4fb8d86..a042bc7a 100644 --- a/components/policy/proto/device_management_backend.proto +++ b/components/policy/proto/device_management_backend.proto
@@ -213,7 +213,7 @@ // Type of certificate. If omitted, will be guessed from the other fields. optional CertificateType certificate_type = 2; // Enrollment identifier if provided. - optional string enrollment_id = 3; + optional bytes enrollment_id = 3; } // Response from server to device for cert upload request.
diff --git a/components/services/heap_profiling/public/cpp/allocator_shim.cc b/components/services/heap_profiling/public/cpp/allocator_shim.cc index 729d2119..906a18b 100644 --- a/components/services/heap_profiling/public/cpp/allocator_shim.cc +++ b/components/services/heap_profiling/public/cpp/allocator_shim.cc
@@ -27,6 +27,11 @@ #if defined(OS_POSIX) #include <limits.h> +#include <pthread.h> +#endif + +#if defined(OS_WIN) +#include <windows.h> #endif #if defined(OS_LINUX) || defined(OS_ANDROID) @@ -44,7 +49,57 @@ namespace heap_profiling { -// A ScopedAllowLogging instance must be instantiated in the scope of all hooks. +namespace { + +// The base implementation of TLS will leak memory if accessed during late +// stages of thread destruction. We roll our own implementation of TLS to +// prevent reentrancy. Since this only requires storing a single bit of +// information, we don't need to deal with hooking thread destruction to free +// memory, and thus avoid leaks and other issues. +#if defined(OS_WIN) +using TLSKey = DWORD; +#else +using TLSKey = pthread_key_t; +#endif + +// Holds a key to a TLS value. The TLS value (0 or 1) indicates whether the +// allocator shim is already being used on the current thread. +TLSKey g_prevent_reentrancy_key = 0; + +void InitializeReentrancyKey() { +#if defined(OS_WIN) + g_prevent_reentrancy_key = TlsAlloc(); + DCHECK_NE(TLS_OUT_OF_INDEXES, g_prevent_reentrancy_key); +#else + // Returns |0| on success. + int result = pthread_key_create(&g_prevent_reentrancy_key, nullptr); + DCHECK(!result); +#endif +} + +bool CanEnterAllocatorShim() { +#if defined(OS_WIN) + return !TlsGetValue(g_prevent_reentrancy_key); +#else + return !pthread_getspecific(g_prevent_reentrancy_key); +#endif +} + +void SetEnteringAllocatorShim(bool entering) { + void* value = entering ? reinterpret_cast<void*>(1) : nullptr; +#if defined(OS_WIN) + BOOL ret = TlsSetValue(g_prevent_reentrancy_key, value); + DPCHECK(ret); +#else + int ret = pthread_setspecific(g_prevent_reentrancy_key, value); + DCHECK_EQ(ret, 0); +#endif +} + +} // namespace + +// A ScopedAllow{Free,Alloc} instance must be instantiated in the scope of all +// hooks. // AllocatorShimLogAlloc/AllocatorShimLogFree must only be called if it // evaluates to true. // @@ -62,28 +117,42 @@ // The implementation of libmalloc will sometimes call malloc [from // one zone to another] - without this guard, the allocation would get two // chances of being sampled. -class ScopedAllowLogging { +class ScopedAllowFree { public: - ScopedAllowLogging() - : allowed_(LIKELY(!base::ThreadLocalStorage::HasBeenDestroyed()) && - LIKELY(!prevent_reentrancy_.Pointer()->Get())) { + ScopedAllowFree() : allowed_(LIKELY(CanEnterAllocatorShim())) { if (allowed_) - prevent_reentrancy_.Pointer()->Set(true); + SetEnteringAllocatorShim(true); } - ~ScopedAllowLogging() { + ~ScopedAllowFree() { if (allowed_) - prevent_reentrancy_.Pointer()->Set(false); + SetEnteringAllocatorShim(false); } explicit operator bool() const { return allowed_; } private: const bool allowed_; - static base::LazyInstance<base::ThreadLocalBoolean>::Leaky - prevent_reentrancy_; }; -base::LazyInstance<base::ThreadLocalBoolean>::Leaky - ScopedAllowLogging::prevent_reentrancy_; +// Allocation logging also requires use of base TLS, so we must also check that +// that is available. This means that allocations that occur after base TLS has +// been torn down will not be logged. +class ScopedAllowAlloc { + public: + ScopedAllowAlloc() + : allowed_(LIKELY(CanEnterAllocatorShim()) && + LIKELY(!base::ThreadLocalStorage::HasBeenDestroyed())) { + if (allowed_) + SetEnteringAllocatorShim(true); + } + ~ScopedAllowAlloc() { + if (allowed_) + SetEnteringAllocatorShim(false); + } + explicit operator bool() const { return allowed_; } + + private: + const bool allowed_; +}; namespace { @@ -162,14 +231,14 @@ // Technically, this code could be called after Thread destruction and we would // need to guard this with ThreadLocalStorage::HasBeenDestroyed(), but all calls -// to this are guarded behind ScopedAllowLogging, which already makes the check. +// to this are guarded behind ScopedAllowAlloc, which already makes the check. base::ThreadLocalStorage::Slot& ShimStateTLS() { static base::NoDestructor<base::ThreadLocalStorage::Slot> shim_state_tls( &DestructShimState); return *shim_state_tls; } -// We don't need to worry about re-entrancy because ScopedAllowLogging +// We don't need to worry about re-entrancy because ScopedAllowAlloc. // already guards against that. ShimState* GetShimState() { ShimState* state = static_cast<ShimState*>(ShimStateTLS().Get()); @@ -321,7 +390,7 @@ #if BUILDFLAG(USE_ALLOCATOR_SHIM) void* HookAlloc(const AllocatorDispatch* self, size_t size, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; const AllocatorDispatch* const next = self->next; void* ptr = next->alloc_function(next, size, context); @@ -337,7 +406,7 @@ size_t n, size_t size, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; const AllocatorDispatch* const next = self->next; void* ptr = next->alloc_zero_initialized_function(next, n, size, context); @@ -352,7 +421,7 @@ size_t alignment, size_t size, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; const AllocatorDispatch* const next = self->next; void* ptr = next->alloc_aligned_function(next, alignment, size, context); @@ -367,7 +436,7 @@ void* address, size_t size, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; const AllocatorDispatch* const next = self->next; void* ptr = next->realloc_function(next, address, size, context); @@ -382,7 +451,7 @@ } void HookFree(const AllocatorDispatch* self, void* address, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowFree allow_logging; const AllocatorDispatch* const next = self->next; next->free_function(next, address, context); @@ -404,7 +473,7 @@ void** results, unsigned num_requested, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; const AllocatorDispatch* const next = self->next; unsigned count = @@ -421,7 +490,7 @@ void** to_be_freed, unsigned num_to_be_freed, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowFree allow_logging; const AllocatorDispatch* const next = self->next; next->batch_free_function(next, to_be_freed, num_to_be_freed, context); @@ -436,7 +505,7 @@ void* ptr, size_t size, void* context) { - ScopedAllowLogging allow_logging; + ScopedAllowFree allow_logging; const AllocatorDispatch* const next = self->next; next->free_definite_size_function(next, ptr, size, context); @@ -461,28 +530,28 @@ #endif // BUILDFLAG(USE_ALLOCATOR_SHIM) void HookPartitionAlloc(void* address, size_t size, const char* type) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; if (LIKELY(allow_logging)) { AllocatorShimLogAlloc(AllocatorType::kPartitionAlloc, address, size, type); } } void HookPartitionFree(void* address) { - ScopedAllowLogging allow_logging; + ScopedAllowFree allow_logging; if (LIKELY(allow_logging)) { AllocatorShimLogFree(address); } } void HookGCAlloc(uint8_t* address, size_t size, const char* type) { - ScopedAllowLogging allow_logging; + ScopedAllowAlloc allow_logging; if (LIKELY(allow_logging)) { AllocatorShimLogAlloc(AllocatorType::kOilpan, address, size, type); } } void HookGCFree(uint8_t* address) { - ScopedAllowLogging allow_logging; + ScopedAllowFree allow_logging; if (LIKELY(allow_logging)) { AllocatorShimLogFree(address); } @@ -589,7 +658,7 @@ } // namespace void InitTLSSlot() { - { ScopedAllowLogging allow_logging; } + InitializeReentrancyKey(); ignore_result(ShimStateTLS()); }
diff --git a/components/services/heap_profiling/public/cpp/allocator_shim.h b/components/services/heap_profiling/public/cpp/allocator_shim.h index 8004d323..a1fedfc 100644 --- a/components/services/heap_profiling/public/cpp/allocator_shim.h +++ b/components/services/heap_profiling/public/cpp/allocator_shim.h
@@ -38,6 +38,7 @@ size_t sz, const char* context); +// Logs a free. This must not rely on the base implementation of TLS. void AllocatorShimLogFree(void* address); // Ensures all send buffers are flushed. The given barrier ID is sent to the
diff --git a/components/subresource_filter/tools/BUILD.gn b/components/subresource_filter/tools/BUILD.gn index 557e6b2..6f37813 100644 --- a/components/subresource_filter/tools/BUILD.gn +++ b/components/subresource_filter/tools/BUILD.gn
@@ -52,7 +52,6 @@ deps = [ ":tools_lib", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -65,7 +64,6 @@ deps = [ ":tools_lib", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -76,7 +74,6 @@ deps = [ "ruleset_converter:support", "//base", - "//build/config:exe_and_shlib_deps", "//third_party/protobuf:protobuf_lite", ] }
diff --git a/components/sync/BUILD.gn b/components/sync/BUILD.gn index a799b4c..5a4e948 100644 --- a/components/sync/BUILD.gn +++ b/components/sync/BUILD.gn
@@ -1026,7 +1026,6 @@ ":test_support_testserver", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//net:test_support", "//testing/gtest",
diff --git a/components/url_formatter/top_domains/BUILD.gn b/components/url_formatter/top_domains/BUILD.gn index d8c9771..2dfa592 100644 --- a/components/url_formatter/top_domains/BUILD.gn +++ b/components/url_formatter/top_domains/BUILD.gn
@@ -27,7 +27,6 @@ deps = [ "//base", "//base:i18n", - "//build/config:exe_and_shlib_deps", "//third_party/icu", ] }
diff --git a/components/viz/client/client_resource_provider.cc b/components/viz/client/client_resource_provider.cc index cc5f914..60126f2a 100644 --- a/components/viz/client/client_resource_provider.cc +++ b/components/viz/client/client_resource_provider.cc
@@ -49,10 +49,8 @@ }; ClientResourceProvider::ClientResourceProvider( - ContextProvider* compositor_context_provider, bool delegated_sync_points_required) - : delegated_sync_points_required_(delegated_sync_points_required), - compositor_context_provider_(compositor_context_provider) { + : delegated_sync_points_required_(delegated_sync_points_required) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); } @@ -184,70 +182,6 @@ } } -bool ClientResourceProvider::IsTextureFormatSupported( - ResourceFormat format) const { - gpu::Capabilities caps; - if (compositor_context_provider_) - caps = compositor_context_provider_->ContextCapabilities(); - - switch (format) { - case ALPHA_8: - case RGBA_4444: - case RGBA_8888: - case RGB_565: - case LUMINANCE_8: - return true; - case BGRA_8888: - return caps.texture_format_bgra8888; - case ETC1: - return caps.texture_format_etc1; - case RED_8: - return caps.texture_rg; - case R16_EXT: - return caps.texture_norm16; - case LUMINANCE_F16: - case RGBA_F16: - return caps.texture_half_float_linear; - } - - NOTREACHED(); - return false; -} - -bool ClientResourceProvider::IsRenderBufferFormatSupported( - ResourceFormat format) const { - gpu::Capabilities caps; - if (compositor_context_provider_) - caps = compositor_context_provider_->ContextCapabilities(); - - switch (format) { - case RGBA_4444: - case RGBA_8888: - case RGB_565: - return true; - case BGRA_8888: - return caps.render_buffer_format_bgra8888; - case RGBA_F16: - // TODO(ccameron): This will always return false on pixel tests, which - // makes it un-test-able until we upgrade Mesa. - // https://crbug.com/687720 - return caps.texture_half_float_linear && - caps.color_buffer_half_float_rgba; - case LUMINANCE_8: - case ALPHA_8: - case RED_8: - case ETC1: - case LUMINANCE_F16: - case R16_EXT: - // We don't currently render into these formats. If we need to render into - // these eventually, we should expand this logic. - return false; - } - - NOTREACHED(); - return false; -} - ClientResourceProvider::ScopedSkSurface::ScopedSkSurface( GrContext* gr_context, GLuint texture_id,
diff --git a/components/viz/client/client_resource_provider.h b/components/viz/client/client_resource_provider.h index a66c65b..5e3d590 100644 --- a/components/viz/client/client_resource_provider.h +++ b/components/viz/client/client_resource_provider.h
@@ -43,8 +43,7 @@ // created on (in practice, the impl thread). class VIZ_CLIENT_EXPORT ClientResourceProvider { public: - ClientResourceProvider(ContextProvider* compositor_context_provider, - bool delegated_sync_points_required); + explicit ClientResourceProvider(bool delegated_sync_points_required); ~ClientResourceProvider(); static gpu::SyncToken GenerateSyncTokenHelper(gpu::gles2::GLES2Interface* gl); @@ -82,14 +81,6 @@ // Checks whether a resource is in use by a consumer. bool InUseByConsumer(ResourceId id); - bool IsTextureFormatSupported(ResourceFormat format) const; - - // Returns true if the provided |format| can be used as a render buffer. - // Note that render buffer support implies texture support. - bool IsRenderBufferFormatSupported(ResourceFormat format) const; - - bool IsSoftware() const { return !compositor_context_provider_; } - class VIZ_CLIENT_EXPORT ScopedSkSurface { public: ScopedSkSurface(GrContext* gr_context, @@ -116,7 +107,6 @@ THREAD_CHECKER(thread_checker_); const bool delegated_sync_points_required_; - ContextProvider* const compositor_context_provider_; base::flat_map<ResourceId, ImportedResource> imported_resources_; // The ResourceIds in ClientResourceProvider start from 1 to avoid
diff --git a/components/viz/client/client_resource_provider_unittest.cc b/components/viz/client/client_resource_provider_unittest.cc index dcdb409..070e8a7 100644 --- a/components/viz/client/client_resource_provider_unittest.cc +++ b/components/viz/client/client_resource_provider_unittest.cc
@@ -26,8 +26,7 @@ context_provider_(TestContextProvider::Create()), bound_(context_provider_->BindToCurrentThread()), provider_(std::make_unique<ClientResourceProvider>( - use_gpu_ ? context_provider_.get() : nullptr, - delegated_sync_points_required_)) { + /*delegated_sync_points_required=*/true)) { DCHECK_EQ(bound_, gpu::ContextResult::kSuccess); } @@ -70,7 +69,6 @@ bool use_gpu_; scoped_refptr<TestContextProvider> context_provider_; gpu::ContextResult bound_; - bool delegated_sync_points_required_ = true; std::unique_ptr<ClientResourceProvider> provider_; };
diff --git a/components/viz/service/display/display_resource_provider_unittest.cc b/components/viz/service/display/display_resource_provider_unittest.cc index 40b1fd92..a10b30a7 100644 --- a/components/viz/service/display/display_resource_provider_unittest.cc +++ b/components/viz/service/display/display_resource_provider_unittest.cc
@@ -364,8 +364,8 @@ bool use_gpu() const { return use_gpu_; } void MakeChildResourceProvider() { - child_resource_provider_ = std::make_unique<ClientResourceProvider>( - child_context_provider_.get(), child_needs_sync_token_); + child_resource_provider_ = + std::make_unique<ClientResourceProvider>(child_needs_sync_token_); } static ReturnCallback GetReturnCallback( @@ -739,9 +739,8 @@ if (!use_gpu()) return; - bool need_sync_tokens = false; auto no_token_resource_provider = std::make_unique<ClientResourceProvider>( - child_context_provider_.get(), need_sync_tokens); + /*delegated_sync_points_required=*/true); GLuint external_texture_id = child_gl_->CreateExternalTexture(); @@ -1000,7 +999,6 @@ child_context_provider->BindToCurrentThread(); auto child_resource_provider = std::make_unique<ClientResourceProvider>( - child_context_provider.get(), /*delegated_sync_points_required=*/true); unsigned texture_id = 1; @@ -1156,7 +1154,6 @@ child_context_provider->BindToCurrentThread(); auto child_resource_provider = std::make_unique<ClientResourceProvider>( - child_context_provider.get(), /*delegated_sync_points_required=*/true); gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO,
diff --git a/components/viz/service/display/gl_renderer_unittest.cc b/components/viz/service/display/gl_renderer_unittest.cc index d57fcca2..0f120e60 100644 --- a/components/viz/service/display/gl_renderer_unittest.cc +++ b/components/viz/service/display/gl_renderer_unittest.cc
@@ -20,7 +20,6 @@ #include "cc/test/fake_impl_task_runner_provider.h" #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/fake_output_surface_client.h" -#include "cc/test/fake_resource_provider.h" #include "cc/test/pixel_test.h" #include "cc/test/render_pass_test_utils.h" #include "cc/test/resource_provider_test_utils.h" @@ -497,9 +496,8 @@ output_surface_->BindToClient(&output_surface_client_); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), shared_bitmap_manager_.get()); renderer_ = std::make_unique<FakeRendererGL>( &settings_, output_surface_.get(), resource_provider_.get()); renderer_->Initialize(); @@ -530,9 +528,8 @@ output_surface_->BindToClient(&output_surface_client_); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), shared_bitmap_manager_.get()); renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), resource_provider_.get())); renderer_->Initialize(); @@ -540,9 +537,7 @@ child_context_provider_ = TestContextProvider::Create(); child_context_provider_->BindToCurrentThread(); - child_resource_provider_ = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_context_provider_.get()); + child_resource_provider_ = std::make_unique<ClientResourceProvider>(true); } void TestRenderPassProgram(TexCoordPrecision precision, @@ -774,7 +769,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -812,7 +807,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -848,7 +843,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -893,7 +888,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -931,7 +926,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -989,7 +984,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -1006,9 +1001,7 @@ auto child_context_provider = TestContextProvider::Create(std::move(child_gl_owned)); child_context_provider->BindToCurrentThread(); - auto child_resource_provider = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_context_provider.get()); + auto child_resource_provider = std::make_unique<ClientResourceProvider>(true); RenderPass* root_pass = cc::AddRenderPass(&render_passes_in_draw_order_, 1, gfx::Rect(100, 100), @@ -1084,7 +1077,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -1172,7 +1165,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -1245,7 +1238,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -1445,7 +1438,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); { @@ -1491,9 +1484,8 @@ output_surface_->BindToClient(&output_surface_client_); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), shared_bitmap_manager_.get()); settings_.partial_swap_enabled = true; renderer_ = std::make_unique<FakeRendererGL>( &settings_, output_surface_.get(), resource_provider_.get()); @@ -1580,7 +1572,7 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), shared_bitmap_manager.get()); RendererSettings settings; @@ -1946,9 +1938,8 @@ output_surface_->BindToClient(&output_surface_client_); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), shared_bitmap_manager_.get()); renderer_.reset(new FakeRendererGL(&settings_, output_surface_.get(), resource_provider_.get())); @@ -2069,15 +2060,12 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); - auto parent_resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface->context_provider(), shared_bitmap_manager.get()); + auto parent_resource_provider = std::make_unique<DisplayResourceProvider>( + output_surface->context_provider(), shared_bitmap_manager.get()); auto child_context_provider = TestContextProvider::Create(); child_context_provider->BindToCurrentThread(); - auto child_resource_provider = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_context_provider.get()); + auto child_resource_provider = std::make_unique<ClientResourceProvider>(true); auto transfer_resource = TransferableResource::MakeGLOverlay( gpu::Mailbox::Generate(), GL_LINEAR, GL_TEXTURE_2D, gpu::SyncToken(), @@ -2263,15 +2251,12 @@ std::unique_ptr<SharedBitmapManager> shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); - auto parent_resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface->context_provider(), shared_bitmap_manager.get()); + auto parent_resource_provider = std::make_unique<DisplayResourceProvider>( + output_surface->context_provider(), shared_bitmap_manager.get()); auto child_context_provider = TestContextProvider::Create(); child_context_provider->BindToCurrentThread(); - auto child_resource_provider = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_context_provider.get()); + auto child_resource_provider = std::make_unique<ClientResourceProvider>(true); gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, gpu::CommandBufferId::FromUnsafeValue(0x123), 29); @@ -2384,7 +2369,7 @@ cc::FakeOutputSurfaceClient output_surface_client; output_surface->BindToClient(&output_surface_client); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), nullptr); RendererSettings settings; FakeRendererGL renderer(&settings, output_surface.get(), @@ -2470,7 +2455,7 @@ cc::FakeOutputSurfaceClient output_surface_client; output_surface->BindToClient(&output_surface_client); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), nullptr); RendererSettings settings; FakeRendererGL renderer(&settings, output_surface.get(), @@ -2532,7 +2517,7 @@ output_surface->BindToClient(&output_surface_client); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), nullptr); RendererSettings settings; @@ -2646,15 +2631,12 @@ FakeOutputSurface::Create3d(std::move(provider))); output_surface->BindToClient(&output_surface_client); - auto parent_resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface->context_provider(), nullptr); + auto parent_resource_provider = std::make_unique<DisplayResourceProvider>( + output_surface->context_provider(), nullptr); auto child_context_provider = TestContextProvider::Create(); child_context_provider->BindToCurrentThread(); - auto child_resource_provider = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_context_provider.get()); + auto child_resource_provider = std::make_unique<ClientResourceProvider>(true); auto transfer_resource = TransferableResource::MakeGLOverlay( gpu::Mailbox::Generate(), GL_LINEAR, GL_TEXTURE_2D, gpu::SyncToken(), @@ -2768,9 +2750,8 @@ gpu::ContextResult::kSuccess); output_surface_ = FakeOutputSurface::Create3d(std::move(context_provider)); output_surface_->BindToClient(&output_surface_client_); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), nullptr); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), nullptr); renderer_ = std::make_unique<GLRenderer>(&settings_, output_surface_.get(), resource_provider_.get(), nullptr); renderer_->Initialize(); @@ -2847,7 +2828,7 @@ output_surface->BindToClient(&output_surface_client); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), nullptr); RendererSettings settings; @@ -2947,9 +2928,8 @@ // we can skip the root RenderPass, swapping empty. output_surface_->SetOverlayCandidateValidator(&validator_); - display_resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - output_surface_->context_provider(), nullptr); + display_resource_provider_ = std::make_unique<DisplayResourceProvider>( + output_surface_->context_provider(), nullptr); settings_ = std::make_unique<RendererSettings>(); // This setting is enabled to use CALayer overlays. @@ -3794,7 +3774,7 @@ output_surface->BindToClient(&output_surface_client); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( + std::make_unique<DisplayResourceProvider>( output_surface->context_provider(), nullptr); for (int i = 0; i < 2; ++i) {
diff --git a/components/viz/service/display/overlay_unittest.cc b/components/viz/service/display/overlay_unittest.cc index 1fcf743..a94e00bd 100644 --- a/components/viz/service/display/overlay_unittest.cc +++ b/components/viz/service/display/overlay_unittest.cc
@@ -10,7 +10,6 @@ #include "base/containers/flat_map.h" #include "base/test/scoped_feature_list.h" #include "cc/test/fake_output_surface_client.h" -#include "cc/test/fake_resource_provider.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/resource_provider_test_utils.h" #include "components/viz/client/client_resource_provider.h" @@ -523,15 +522,12 @@ new OverlayCandidateValidatorType); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - provider_.get(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + provider_.get(), shared_bitmap_manager_.get()); child_provider_ = TestContextProvider::Create(); child_provider_->BindToCurrentThread(); - child_resource_provider_ = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_provider_.get()); + child_resource_provider_ = std::make_unique<ClientResourceProvider>(true); overlay_processor_ = std::make_unique<OverlayProcessor>(output_surface_.get()); @@ -577,8 +573,8 @@ auto shared_bitmap_manager = std::make_unique<TestSharedBitmapManager>(); std::unique_ptr<DisplayResourceProvider> resource_provider = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - provider.get(), shared_bitmap_manager.get()); + std::make_unique<DisplayResourceProvider>(provider.get(), + shared_bitmap_manager.get()); auto overlay_processor = std::make_unique<DefaultOverlayProcessor>(&output_surface); @@ -2585,17 +2581,14 @@ output_surface_ = std::make_unique<OutputSurfaceType>(provider_); output_surface_->BindToClient(&output_surface_client_); resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider(provider_.get(), - nullptr); + std::make_unique<DisplayResourceProvider>(provider_.get(), nullptr); provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); child_provider_ = TestContextProvider::Create(); child_provider_->BindToCurrentThread(); - child_resource_provider_ = - cc::FakeResourceProvider::CreateClientResourceProvider( - child_provider_.get()); + child_resource_provider_ = std::make_unique<ClientResourceProvider>(true); } void Init(bool use_validator) {
diff --git a/components/viz/service/display/renderer_pixeltest.cc b/components/viz/service/display/renderer_pixeltest.cc index ae457b4..9c39987 100644 --- a/components/viz/service/display/renderer_pixeltest.cc +++ b/components/viz/service/display/renderer_pixeltest.cc
@@ -29,6 +29,7 @@ #include "gpu/command_buffer/client/gles2_interface.h" #include "media/base/video_frame.h" #include "media/renderers/video_resource_updater.h" +#include "media/video/half_float_maker.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkColorSpaceXform.h" #include "third_party/skia/include/core/SkMatrix.h" @@ -446,18 +447,25 @@ ResourceFormat yuv_highbit_resource_format = video_resource_updater->YuvResourceFormat(bits_per_channel); - float multiplier = 1.0; + float offset = 0.0f; + float multiplier = 1.0f; - if (yuv_highbit_resource_format == R16_EXT) + if (yuv_highbit_resource_format == R16_EXT) { multiplier = 65535.0f / ((1 << bits_per_channel) - 1); - else + } else if (yuv_highbit_resource_format == LUMINANCE_F16) { + std::unique_ptr<media::HalfFloatMaker> half_float_maker = + media::HalfFloatMaker::NewHalfFloatMaker(bits_per_channel); + offset = half_float_maker->Offset(); + multiplier = half_float_maker->Multiplier(); + } else { bits_per_channel = 8; + } yuv_quad->SetNew(shared_state, rect, visible_rect, needs_blending, ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, mapped_resource_y, mapped_resource_u, mapped_resource_v, mapped_resource_a, video_color_space, - 0.0f, multiplier, bits_per_channel); + offset, multiplier, bits_per_channel); } void CreateTestY16TextureDrawQuad_FromVideoFrame(
diff --git a/components/viz/service/display/software_renderer_unittest.cc b/components/viz/service/display/software_renderer_unittest.cc index a7916a8..ba2bdca5 100644 --- a/components/viz/service/display/software_renderer_unittest.cc +++ b/components/viz/service/display/software_renderer_unittest.cc
@@ -12,11 +12,11 @@ #include "base/run_loop.h" #include "cc/test/animation_test_common.h" #include "cc/test/fake_output_surface_client.h" -#include "cc/test/fake_resource_provider.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/pixel_test_utils.h" #include "cc/test/render_pass_test_utils.h" #include "cc/test/resource_provider_test_utils.h" +#include "components/viz/client/client_resource_provider.h" #include "components/viz/common/frame_sinks/copy_output_request.h" #include "components/viz/common/frame_sinks/copy_output_result.h" #include "components/viz/common/quads/compositor_frame_metadata.h" @@ -26,6 +26,7 @@ #include "components/viz/common/quads/solid_color_draw_quad.h" #include "components/viz/common/quads/tile_draw_quad.h" #include "components/viz/common/resources/bitmap_allocation.h" +#include "components/viz/service/display/display_resource_provider.h" #include "components/viz/service/display/software_output_device.h" #include "components/viz/test/fake_output_surface.h" #include "components/viz/test/test_shared_bitmap_manager.h" @@ -47,16 +48,14 @@ output_surface_->BindToClient(&output_surface_client_); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - nullptr, shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + nullptr, shared_bitmap_manager_.get()); renderer_ = std::make_unique<SoftwareRenderer>( &settings_, output_surface_.get(), resource_provider()); renderer_->Initialize(); renderer_->SetVisible(true); - child_resource_provider_ = - cc::FakeResourceProvider::CreateClientResourceProvider(nullptr); + child_resource_provider_ = std::make_unique<ClientResourceProvider>(true); } DisplayResourceProvider* resource_provider() const {
diff --git a/components/viz/service/display/surface_aggregator_perftest.cc b/components/viz/service/display/surface_aggregator_perftest.cc index ca2a783..3244d5d 100644 --- a/components/viz/service/display/surface_aggregator_perftest.cc +++ b/components/viz/service/display/surface_aggregator_perftest.cc
@@ -4,7 +4,6 @@ #include "cc/base/lap_timer.h" #include "cc/test/fake_output_surface_client.h" -#include "cc/test/fake_resource_provider.h" #include "components/viz/common/frame_sinks/begin_frame_args.h" #include "components/viz/common/quads/compositor_frame.h" #include "components/viz/common/quads/surface_draw_quad.h" @@ -36,9 +35,8 @@ context_provider_->BindToCurrentThread(); shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - context_provider_.get(), shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + context_provider_.get(), shared_bitmap_manager_.get()); } void RunTest(int num_surfaces,
diff --git a/components/viz/service/display/surface_aggregator_unittest.cc b/components/viz/service/display/surface_aggregator_unittest.cc index 23db64e..0fde3f47 100644 --- a/components/viz/service/display/surface_aggregator_unittest.cc +++ b/components/viz/service/display/surface_aggregator_unittest.cc
@@ -14,7 +14,6 @@ #include "base/memory/weak_ptr.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" -#include "cc/test/fake_resource_provider.h" #include "cc/test/render_pass_test_utils.h" #include "components/viz/common/frame_sinks/begin_frame_args.h" #include "components/viz/common/quads/compositor_frame.h" @@ -2955,9 +2954,8 @@ public: void SetUp() override { shared_bitmap_manager_ = std::make_unique<TestSharedBitmapManager>(); - resource_provider_ = - cc::FakeResourceProvider::CreateDisplayResourceProvider( - nullptr, shared_bitmap_manager_.get()); + resource_provider_ = std::make_unique<DisplayResourceProvider>( + nullptr, shared_bitmap_manager_.get()); aggregator_ = std::make_unique<SurfaceAggregator>( manager_.surface_manager(), resource_provider_.get(), false);
diff --git a/components/wifi/BUILD.gn b/components/wifi/BUILD.gn index 392dbac..3cd5593 100644 --- a/components/wifi/BUILD.gn +++ b/components/wifi/BUILD.gn
@@ -56,7 +56,6 @@ deps = [ ":wifi", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//components/onc", ]
diff --git a/components/zucchini/BUILD.gn b/components/zucchini/BUILD.gn index 9f7318a..232e6e7 100644 --- a/components/zucchini/BUILD.gn +++ b/components/zucchini/BUILD.gn
@@ -130,7 +130,6 @@ ":zucchini_io", ":zucchini_lib", "//base", - "//build/config:exe_and_shlib_deps", ] if (is_win) {
diff --git a/content/BUILD.gn b/content/BUILD.gn index 063220b..8ec381e 100644 --- a/content/BUILD.gn +++ b/content/BUILD.gn
@@ -81,9 +81,6 @@ component("content") { public_deps = content_shared_components + [ "//content/public/app:both_sources" ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } } else if (is_nacl_nonsfi) { source_set("content") {
diff --git a/content/browser/android/dialog_overlay_impl.cc b/content/browser/android/dialog_overlay_impl.cc index 8335d3b..70457ba 100644 --- a/content/browser/android/dialog_overlay_impl.cc +++ b/content/browser/android/dialog_overlay_impl.cc
@@ -38,14 +38,14 @@ // reprojection video surface. RenderWidgetHostViewBase* rwhvb = static_cast<RenderWidgetHostViewBase*>(rfhi->GetView()); - if (rwhvb->IsInVR()) + if (!rwhvb || rwhvb->IsInVR()) return 0; WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>( content::WebContents::FromRenderFrameHost(rfhi)); // If the overlay would not be immediately used, fail the request. - if (!rfhi->IsCurrent() || web_contents_impl->IsHidden()) + if (!rfhi->IsCurrent() || !web_contents_impl || web_contents_impl->IsHidden()) return 0; // Dialog-based overlays are not supported for persistent video.
diff --git a/content/browser/android/selection/composited_touch_handle_drawable.cc b/content/browser/android/selection/composited_touch_handle_drawable.cc index 3065171..75d1769 100644 --- a/content/browser/android/selection/composited_touch_handle_drawable.cc +++ b/content/browser/android/selection/composited_touch_handle_drawable.cc
@@ -7,11 +7,9 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/macros.h" -#include "base/trace_event/trace_event.h" #include "cc/layers/ui_resource_layer.h" #include "content/public/browser/android/compositor.h" -#include "jni/HandleViewResources_jni.h" -#include "ui/gfx/android/java_bitmap.h" +#include "ui/android/handle_view_resources.h" using base::android::JavaRef; @@ -19,73 +17,7 @@ namespace { -static SkBitmap CreateSkBitmapFromJavaBitmap( - base::android::ScopedJavaLocalRef<jobject> jbitmap) { - return jbitmap.is_null() - ? SkBitmap() - : CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(jbitmap)); -} - -class HandleResources { - public: - HandleResources() : loaded_(false) { - } - - void LoadIfNecessary(const JavaRef<jobject>& context) { - if (loaded_) - return; - - loaded_ = true; - - TRACE_EVENT0("browser", "HandleResources::Create"); - JNIEnv* env = base::android::AttachCurrentThread(); - - left_bitmap_ = CreateSkBitmapFromJavaBitmap( - Java_HandleViewResources_getLeftHandleBitmap(env, context)); - right_bitmap_ = CreateSkBitmapFromJavaBitmap( - Java_HandleViewResources_getRightHandleBitmap(env, context)); - center_bitmap_ = CreateSkBitmapFromJavaBitmap( - Java_HandleViewResources_getCenterHandleBitmap(env, context)); - - left_bitmap_.setImmutable(); - right_bitmap_.setImmutable(); - center_bitmap_.setImmutable(); - - drawable_horizontal_padding_ratio_ = - Java_HandleViewResources_getHandleHorizontalPaddingRatio(env); - } - - const SkBitmap& GetBitmap(ui::TouchHandleOrientation orientation) { - DCHECK(loaded_); - switch (orientation) { - case ui::TouchHandleOrientation::LEFT: - return left_bitmap_; - case ui::TouchHandleOrientation::RIGHT: - return right_bitmap_; - case ui::TouchHandleOrientation::CENTER: - return center_bitmap_; - case ui::TouchHandleOrientation::UNDEFINED: - NOTREACHED() << "Invalid touch handle orientation."; - }; - return center_bitmap_; - } - - float GetDrawableHorizontalPaddingRatio() const { - DCHECK(loaded_); - return drawable_horizontal_padding_ratio_; - } - - private: - SkBitmap left_bitmap_; - SkBitmap right_bitmap_; - SkBitmap center_bitmap_; - float drawable_horizontal_padding_ratio_; - bool loaded_; - - DISALLOW_COPY_AND_ASSIGN(HandleResources); -}; - -base::LazyInstance<HandleResources>::Leaky g_selection_resources; +base::LazyInstance<ui::HandleViewResources>::Leaky g_selection_resources; } // namespace
diff --git a/content/browser/android/selection/composited_touch_handle_drawable.h b/content/browser/android/selection/composited_touch_handle_drawable.h index 0e4b6a2..4682df5 100644 --- a/content/browser/android/selection/composited_touch_handle_drawable.h +++ b/content/browser/android/selection/composited_touch_handle_drawable.h
@@ -5,12 +5,15 @@ #ifndef CONTENT_BROWSER_ANDROID_SELECTION_COMPOSITED_TOUCH_HANDLE_DRAWABLE_H_ #define CONTENT_BROWSER_ANDROID_SELECTION_COMPOSITED_TOUCH_HANDLE_DRAWABLE_H_ -#include "ui/touch_selection/touch_handle.h" - -#include "base/android/jni_android.h" #include "base/android/scoped_java_ref.h" #include "base/macros.h" -#include "cc/layers/ui_resource_layer.h" +#include "base/memory/scoped_refptr.h" +#include "ui/touch_selection/touch_handle.h" + +namespace cc { +class Layer; +class UIResourceLayer; +} // namespace cc namespace content {
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc index 5fc543b..f5e33f9 100644 --- a/content/browser/background_sync/background_sync_manager_unittest.cc +++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -25,7 +25,6 @@ #include "content/browser/service_worker/embedded_worker_test_helper.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" -#include "content/browser/service_worker/service_worker_dispatcher_host.h" #include "content/browser/service_worker/service_worker_registration_object_host.h" #include "content/browser/service_worker/service_worker_storage.h" #include "content/browser/storage_partition_impl.h"
diff --git a/content/browser/bluetooth/tools/BUILD.gn b/content/browser/bluetooth/tools/BUILD.gn index 8615c6d..4971caa 100644 --- a/content/browser/bluetooth/tools/BUILD.gn +++ b/content/browser/bluetooth/tools/BUILD.gn
@@ -9,7 +9,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//device/bluetooth", ]
diff --git a/content/browser/fileapi/file_system_url_loader_factory_browsertest.cc b/content/browser/fileapi/file_system_url_loader_factory_browsertest.cc index 79fd5803..82cfc276 100644 --- a/content/browser/fileapi/file_system_url_loader_factory_browsertest.cc +++ b/content/browser/fileapi/file_system_url_loader_factory_browsertest.cc
@@ -34,6 +34,7 @@ #include "storage/browser/test/mock_special_storage_policy.h" #include "storage/browser/test/test_file_system_backend.h" #include "storage/browser/test/test_file_system_context.h" +#include "storage/browser/test/test_file_system_options.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/icu/source/i18n/unicode/datefmt.h" #include "third_party/icu/source/i18n/unicode/regex.h" @@ -154,25 +155,27 @@ class FileSystemURLLoaderFactoryTest : public ContentBrowserTest { protected: - FileSystemURLLoaderFactoryTest() : weak_factory_(this) {} + FileSystemURLLoaderFactoryTest() {} ~FileSystemURLLoaderFactoryTest() override = default; void SetUpOnMainThread() override { feature_list_.InitAndEnableFeature(network::features::kNetworkService); - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - special_storage_policy_ = new MockSpecialStoragePolicy; + + // We use a test FileSystemContext which runs on the main thread, so we + // can work with it synchronously. + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); file_system_context_ = CreateFileSystemContextForTesting(nullptr, temp_dir_.GetPath()); - - // We use the main thread so that we can get the root path synchronously. + base::RunLoop run_loop; file_system_context_->OpenFileSystem( GURL("http://remote/"), storage::kFileSystemTypeTemporary, storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, base::BindOnce(&FileSystemURLLoaderFactoryTest::OnOpenFileSystem, - weak_factory_.GetWeakPtr())); - base::RunLoop().RunUntilIdle(); + run_loop.QuitWhenIdleClosure())); + run_loop.Run(); + ContentBrowserTest::SetUpOnMainThread(); } @@ -333,6 +336,14 @@ network::mojom::URLLoaderPtr loader_; private: + static void OnOpenFileSystem(base::OnceClosure done_closure, + const GURL& root_url, + const std::string& name, + base::File::Error result) { + ASSERT_EQ(base::File::FILE_OK, result); + std::move(done_closure).Run(); + } + storage::FileSystemFileUtil* file_util() { return file_system_context_->sandbox_delegate()->sync_file_util(); } @@ -344,12 +355,6 @@ return context; } - void OnOpenFileSystem(const GURL& root_url, - const std::string& name, - base::File::Error result) { - ASSERT_EQ(base::File::FILE_OK, result); - } - RenderFrameHost* render_frame_host() const { return shell()->web_contents()->GetMainFrame(); } @@ -393,7 +398,6 @@ base::test::ScopedFeatureList feature_list_; scoped_refptr<MockSpecialStoragePolicy> special_storage_policy_; scoped_refptr<FileSystemContext> file_system_context_; - base::WeakPtrFactory<FileSystemURLLoaderFactoryTest> weak_factory_; DISALLOW_COPY_AND_ASSIGN(FileSystemURLLoaderFactoryTest); };
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index 8c3082a0..82030f5 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -4598,6 +4598,8 @@ void RenderFrameHostImpl::CreateWebSocket( network::mojom::WebSocketRequest request) { + GetContentClient()->browser()->WillCreateWebSocket(this, &request); + // This is to support usage of WebSockets in cases in which there is an // associated RenderFrame. This is important for showing the correct security // state of the page and also honoring user override of bad certificates.
diff --git a/content/browser/keyboard_lock_browsertest.cc b/content/browser/keyboard_lock_browsertest.cc index 2a4739de..51df4840 100644 --- a/content/browser/keyboard_lock_browsertest.cc +++ b/content/browser/keyboard_lock_browsertest.cc
@@ -917,26 +917,6 @@ } IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, - SubsequentLockCallSupersedesPreviousCall) { - // TODO(joedow): Added per code review feedback. - // Steps: 1. Request all keys, verify keys are locked - // 2. Request subset of keys, verify the subset of keys are locked, but - // non-requested keys are no longer locked - // 3. Request all keys again, verify keys are now locked -} - -IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, - BrowserShortcutsHandledCorrectly) { - // TODO(joedow): Added per code review feedback. - // Steps: 1. Request keyboard lock for all keys - // 2. Simulate browser shortcut (Ctrl+T) - // 3. Verify new tab is not created - // 4. Unlock keyboard - // 5. Simulate browser shortcut (Ctrl+T) - // 6. Verify new tab was created -} - -IN_PROC_BROWSER_TEST_F(KeyboardLockBrowserTest, InnerContentsFullscreenBehavior) { // TODO(joedow): Added per code review feedback. Need to define the behavior // for KeyboardLock when an attached InnerWebContents goes fullscreen.
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.h b/content/browser/renderer_host/browser_compositor_view_mac.h index bc9eba1..18c9e51 100644 --- a/content/browser/renderer_host/browser_compositor_view_mac.h +++ b/content/browser/renderer_host/browser_compositor_view_mac.h
@@ -90,6 +90,7 @@ // Update the renderer's SurfaceId to reflect |new_size_in_pixels| in // anticipation of the NSView resizing during auto-resize. void SynchronizeVisualProperties( + float new_device_scale_factor, const gfx::Size& new_size_in_pixels, const viz::LocalSurfaceId& child_allocated_local_surface_id);
diff --git a/content/browser/renderer_host/browser_compositor_view_mac.mm b/content/browser/renderer_host/browser_compositor_view_mac.mm index 6b26a87..17c4647 100644 --- a/content/browser/renderer_host/browser_compositor_view_mac.mm +++ b/content/browser/renderer_host/browser_compositor_view_mac.mm
@@ -339,10 +339,12 @@ } void BrowserCompositorMac::SynchronizeVisualProperties( + float new_device_scale_factor, const gfx::Size& new_size_in_pixels, const viz::LocalSurfaceId& child_allocated_local_surface_id) { if (dfh_local_surface_id_allocator_.UpdateFromChild( child_allocated_local_surface_id)) { + dfh_display_.set_device_scale_factor(new_device_scale_factor); dfh_size_dip_ = gfx::ConvertSizeToDIP(dfh_display_.device_scale_factor(), new_size_in_pixels); dfh_size_pixels_ = new_size_in_pixels;
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index de5009d..a8be65ae 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1839,9 +1839,8 @@ #endif auto service_worker_filter = - base::MakeRefCounted<ServiceWorkerDispatcherHost>(GetID()); - service_worker_filter->Init( - storage_partition_impl_->GetServiceWorkerContext()); + base::MakeRefCounted<ServiceWorkerDispatcherHost>( + storage_partition_impl_->GetServiceWorkerContext(), GetID()); AddFilter(service_worker_filter.get()); p2p_socket_dispatcher_host_ = new P2PSocketDispatcherHost(
diff --git a/content/browser/renderer_host/render_widget_host_ns_view_bridge.h b/content/browser/renderer_host/render_widget_host_ns_view_bridge.h index fa412cd..3761be5 100644 --- a/content/browser/renderer_host/render_widget_host_ns_view_bridge.h +++ b/content/browser/renderer_host/render_widget_host_ns_view_bridge.h
@@ -54,6 +54,10 @@ virtual void InitAsPopup(const gfx::Rect& content_rect, blink::WebPopupType popup_type) = 0; + // Disable displaying any content (including the background color). This is + // to be called on views that are to be displayed via a parent ui::Compositor. + virtual void DisableDisplay() = 0; + // Make the NSView be the first responder of its NSWindow. virtual void MakeFirstResponder() = 0;
diff --git a/content/browser/renderer_host/render_widget_host_ns_view_bridge.mm b/content/browser/renderer_host/render_widget_host_ns_view_bridge.mm index 0b80616..54b1c71b 100644 --- a/content/browser/renderer_host/render_widget_host_ns_view_bridge.mm +++ b/content/browser/renderer_host/render_widget_host_ns_view_bridge.mm
@@ -38,6 +38,7 @@ void InitAsPopup(const gfx::Rect& content_rect, blink::WebPopupType popup_type) override; + void DisableDisplay() override; void MakeFirstResponder() override; void SetBounds(const gfx::Rect& rect) override; void SetCALayerParams(const gfx::CALayerParams& ca_layer_params) override; @@ -74,6 +75,10 @@ // The NSView used for input and display. base::scoped_nsobject<RenderWidgetHostViewCocoa> cocoa_view_; + // Once set, all calls to set the background color or CALayer content will + // be ignored. + bool display_disabled_ = false; + // The window used for popup widgets, and its helper. std::unique_ptr<PopupWindowMac> popup_window_; blink::WebPopupType popup_type_ = blink::kWebPopupTypeNone; @@ -134,6 +139,14 @@ [[cocoa_view_ window] makeFirstResponder:cocoa_view_]; } +void RenderWidgetHostViewNSViewBridgeLocal::DisableDisplay() { + if (display_disabled_) + return; + SetBackgroundColor(SK_ColorTRANSPARENT); + display_ca_layer_tree_.reset(); + display_disabled_ = true; +} + void RenderWidgetHostViewNSViewBridgeLocal::SetBounds(const gfx::Rect& rect) { // |rect.size()| is view coordinates, |rect.origin| is screen coordinates, // TODO(thakis): fix, http://crbug.com/73362 @@ -177,10 +190,14 @@ void RenderWidgetHostViewNSViewBridgeLocal::SetCALayerParams( const gfx::CALayerParams& ca_layer_params) { + if (display_disabled_) + return; display_ca_layer_tree_->UpdateCALayerTree(ca_layer_params); } void RenderWidgetHostViewNSViewBridgeLocal::SetBackgroundColor(SkColor color) { + if (display_disabled_) + return; ScopedCAActionDisabler disabler; base::ScopedCFTypeRef<CGColorRef> cg_color( skia::CGColorCreateFromSkColor(color));
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index fb5b6f2..8cd2f9c 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -110,11 +110,6 @@ } void RenderWidgetHostViewMac::AcceleratedWidgetCALayerParamsUpdated() { - // This may be called when we do not have a parent ui::Layer (e.g, when tab - // capturing a background layer). Do not update the NSView in this case. - if (display_only_using_parent_ui_layer_) - return; - // Set the background color for the root layer from the frame that just // swapped. See RenderWidgetHostViewAura for more details. Note that this is // done only after the swap has completed, so that the background is not set @@ -146,11 +141,6 @@ ui::GestureProviderConfigType::CURRENT_PLATFORM), this), weak_factory_(this) { - display_only_using_parent_ui_layer_ = !features::IsViewsBrowserCocoa(); - // TODO(ccameron): This path breaks content_shell because content_shell does - // not display using ui::Views, even when !features::IsViewsBrowserCocoa. - display_only_using_parent_ui_layer_ = false; - // The NSView is on the other side of |ns_view_bridge_|. ns_view_bridge_ = RenderWidgetHostNSViewBridge::Create(this); @@ -209,8 +199,16 @@ } void RenderWidgetHostViewMac::SetParentUiLayer(ui::Layer* parent_ui_layer) { - if (!display_only_using_parent_ui_layer_) - return; + if (!display_only_using_parent_ui_layer_) { + // The first time that we display using a parent ui::Layer, permanently + // switch from drawing using Cocoa to only drawing using ui::Views. Erase + // the existing content being drawn by Cocoa (which may have been set due + // to races, e.g, in https://crbug.com/845807). Note that this transition + // must be done lazily because not all code has been updated to use + // ui::Views (e.g, content_shell). + display_only_using_parent_ui_layer_ = true; + ns_view_bridge_->DisableDisplay(); + } if (browser_compositor_) browser_compositor_->SetParentUiLayer(parent_ui_layer); } @@ -748,7 +746,7 @@ void RenderWidgetHostViewMac::OnDidUpdateVisualPropertiesComplete( const cc::RenderFrameMetadata& metadata) { browser_compositor_->SynchronizeVisualProperties( - metadata.viewport_size_in_pixels, + metadata.device_scale_factor, metadata.viewport_size_in_pixels, metadata.local_surface_id.value_or(viz::LocalSurfaceId())); } @@ -1245,11 +1243,6 @@ } void RenderWidgetHostViewMac::SetBackgroundLayerColor(SkColor color) { - // If displaying via a ui::Layer, leave the background color of the NSView - // as transparent (it is to be used for input handling only). - if (display_only_using_parent_ui_layer_) - return; - if (color == background_layer_color_) return; background_layer_color_ = color;
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index 56915e589..402e95e 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -23,7 +23,6 @@ #include "content/browser/service_worker/embedded_worker_status.h" #include "content/browser/service_worker/service_worker_context_core_observer.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" -#include "content/browser/service_worker/service_worker_dispatcher_host.h" #include "content/browser/service_worker/service_worker_info.h" #include "content/browser/service_worker/service_worker_job_coordinator.h" #include "content/browser/service_worker/service_worker_process_manager.h" @@ -299,7 +298,6 @@ ServiceWorkerContextCore* old_context, ServiceWorkerContextWrapper* wrapper) : wrapper_(wrapper), - dispatcher_hosts_(std::move(old_context->dispatcher_hosts_)), providers_(old_context->providers_.release()), provider_by_uuid_(old_context->provider_by_uuid_.release()), loader_factory_getter_(old_context->loader_factory_getter()), @@ -325,32 +323,6 @@ weak_factory_.InvalidateWeakPtrs(); } -void ServiceWorkerContextCore::AddDispatcherHost( - int process_id, - content::ServiceWorkerDispatcherHost* dispatcher_host) { - DCHECK(dispatcher_hosts_.find(process_id) == dispatcher_hosts_.end()); - dispatcher_hosts_[process_id] = dispatcher_host; -} - -ServiceWorkerDispatcherHost* ServiceWorkerContextCore::GetDispatcherHost( - int process_id) { - auto it = dispatcher_hosts_.find(process_id); - if (it == dispatcher_hosts_.end()) - return nullptr; - return it->second; -} - -void ServiceWorkerContextCore::RemoveDispatcherHost(int process_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - // TODO(falken) Try to remove this call. It should be unnecessary because - // provider hosts remove themselves when their Mojo connection to the renderer - // is destroyed. But if we don't remove the hosts immediately here, collisions - // of <process_id, provider_id> can occur if a new dispatcher host is - // created for a reused RenderProcessHost. https://crbug.com/736203 - RemoveAllProviderHostsForProcess(process_id); - dispatcher_hosts_.erase(process_id); -} - void ServiceWorkerContextCore::AddProviderHost( std::unique_ptr<ServiceWorkerProviderHost> host) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
diff --git a/content/browser/service_worker/service_worker_context_core.h b/content/browser/service_worker/service_worker_context_core.h index e505febed..fa9bd0d 100644 --- a/content/browser/service_worker/service_worker_context_core.h +++ b/content/browser/service_worker/service_worker_context_core.h
@@ -43,7 +43,6 @@ class EmbeddedWorkerRegistry; class ServiceWorkerContextCoreObserver; class ServiceWorkerContextWrapper; -class ServiceWorkerDispatcherHost; class ServiceWorkerJobCoordinator; class ServiceWorkerProviderHost; class ServiceWorkerRegistration; @@ -160,13 +159,6 @@ return job_coordinator_.get(); } - // Maintains DispatcherHosts to exchange service worker related messages - // through them. The DispatcherHosts are not owned by this class. - void AddDispatcherHost(int process_id, - ServiceWorkerDispatcherHost* dispatcher_host); - ServiceWorkerDispatcherHost* GetDispatcherHost(int process_id); - void RemoveDispatcherHost(int process_id); - // The context class owns the set of ProviderHosts. void AddProviderHost( std::unique_ptr<ServiceWorkerProviderHost> provider_host); @@ -339,8 +331,6 @@ // because the Wrapper::Shutdown call that hops threads to destroy |this| uses // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. ServiceWorkerContextWrapper* wrapper_; - std::map<int /* process_id */, ServiceWorkerDispatcherHost*> - dispatcher_hosts_; std::unique_ptr<ProcessToProviderMap> providers_; std::unique_ptr<ProviderByClientUUIDMap> provider_by_uuid_; std::unique_ptr<ServiceWorkerStorage> storage_;
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc index 9319d43..11d961f 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -48,51 +48,40 @@ ServiceWorkerMsgStart, }; +void RemoveAllProviderHostsForProcess(ServiceWorkerContextCore* context, + int render_process_id) { + // TODO(falken) Try to remove this call. It should be unnecessary because + // provider hosts remove themselves when their Mojo connection to the + // renderer is destroyed. But if we don't remove the hosts immediately here, + // collisions of <process_id, provider_id> can occur if a new dispatcher + // host is created for a reused RenderProcessHost. https://crbug.com/736203 + if (context) { + context->RemoveAllProviderHostsForProcess(render_process_id); + } +} + } // namespace -ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(int render_process_id) +ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( + scoped_refptr<ServiceWorkerContextWrapper> context_wrapper, + int render_process_id) : BrowserMessageFilter(kServiceWorkerFilteredMessageClasses, arraysize(kServiceWorkerFilteredMessageClasses)), BrowserAssociatedInterface<mojom::ServiceWorkerDispatcherHost>(this, this), - render_process_id_(render_process_id) {} + render_process_id_(render_process_id), + context_wrapper_(context_wrapper) {} ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (GetContext() && phase_ == Phase::kAddedToContext) - GetContext()->RemoveDispatcherHost(render_process_id_); -} - -void ServiceWorkerDispatcherHost::Init( - ServiceWorkerContextWrapper* context_wrapper) { - if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::BindOnce(&ServiceWorkerDispatcherHost::Init, this, - base::RetainedRef(context_wrapper))); - return; - } - - // Just speculating that maybe we were destructed before Init() was called on - // the IO thread in order to try to fix https://crbug.com/750267. - if (phase_ != Phase::kInitial) - return; - - context_wrapper_ = context_wrapper; - if (!GetContext()) - return; - GetContext()->AddDispatcherHost(render_process_id_, this); - phase_ = Phase::kAddedToContext; + RemoveAllProviderHostsForProcess(GetContext(), render_process_id_); } void ServiceWorkerDispatcherHost::OnFilterRemoved() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); // Don't wait until the destructor to teardown since a new dispatcher host // for this process might be created before then. - if (GetContext() && phase_ == Phase::kAddedToContext) { - GetContext()->RemoveDispatcherHost(render_process_id_); - } - phase_ = Phase::kRemovedFromContext; + RemoveAllProviderHostsForProcess(GetContext(), render_process_id_); context_wrapper_ = nullptr; } @@ -109,6 +98,7 @@ void ServiceWorkerDispatcherHost::OnProviderCreated( ServiceWorkerProviderHostInfo info) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); TRACE_EVENT0("ServiceWorker", "ServiceWorkerDispatcherHost::OnProviderCreated"); if (!GetContext())
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.h b/content/browser/service_worker/service_worker_dispatcher_host.h index 0ea446f..0901bb5 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.h +++ b/content/browser/service_worker/service_worker_dispatcher_host.h
@@ -33,40 +33,29 @@ FORWARD_DECLARE_TEST(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed); FORWARD_DECLARE_TEST(ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash); -FORWARD_DECLARE_TEST(BackgroundSyncManagerTest, - RegisterWithoutLiveSWRegistration); } // namespace service_worker_dispatcher_host_unittest -// ServiceWorkerDispatcherHost is the browser-side endpoint for several IPC -// messages for service workers. There is a 1:1 correspondence between -// renderer processes and ServiceWorkerDispatcherHosts. Currently -// ServiceWorkerDispatcherHost sends the legacy IPC message -// ServiceWorkerMsg_ServiceWorkerStateChanged to its corresponding -// ServiceWorkerDispatcher on the renderer and receives Mojo IPC messages from -// any ServiceWorkerNetworkProvider on the renderer. +// ServiceWorkerDispatcherHost is a browser-side endpoint for the renderer to +// notify the browser ServiceWorkerProviderHost is created. In order to +// associate the Mojo interface with the legacy IPC channel, +// ServiceWorkerDispatcherHost overrides BrowserMessageFilter and +// BrowserAssociatedInterface. // // ServiceWorkerDispatcherHost is created on the UI thread in // RenderProcessHostImpl::Init() via CreateMessageFilters(), but initialization, -// destruction, and IPC message handling occur on the IO thread. It lives as -// long as the renderer process lives. Therefore much tracking of renderer -// processes in browser-side service worker code is built on -// ServiceWorkerDispatcherHost lifetime. +// destruction, and Mojo calls occur on the IO thread. It lives as +// long as the renderer process lives. // -// This class is bound with mojom::ServiceWorkerDispatcherHost. All -// InterfacePtrs on the same render process are bound to the same -// content::ServiceWorkerDispatcherHost. This can be overridden only for -// testing. -// -// TODO(leonhsl): This class no longer needs to be a BrowserMessageFilter -// because we are already in a pure Mojo world. +// TODO(leonhsl): Remove this class once we can understand how to move +// OnProviderCreated() to an isolated message pipe. class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter, public BrowserAssociatedInterface<mojom::ServiceWorkerDispatcherHost>, public mojom::ServiceWorkerDispatcherHost { public: - explicit ServiceWorkerDispatcherHost(int render_process_id); - - void Init(ServiceWorkerContextWrapper* context_wrapper); + ServiceWorkerDispatcherHost( + scoped_refptr<ServiceWorkerContextWrapper> context_wrapper, + int render_process_id); // BrowserMessageFilter implementation void OnFilterRemoved() override; @@ -89,13 +78,6 @@ FRIEND_TEST_ALL_PREFIXES( service_worker_dispatcher_host_unittest::ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash); - FRIEND_TEST_ALL_PREFIXES( - service_worker_dispatcher_host_unittest::BackgroundSyncManagerTest, - RegisterWithoutLiveSWRegistration); - - enum class ProviderStatus { OK, NO_CONTEXT, DEAD_HOST, NO_HOST, NO_URL }; - // Debugging for https://crbug.com/750267 - enum class Phase { kInitial, kAddedToContext, kRemovedFromContext }; // mojom::ServiceWorkerDispatcherHost implementation void OnProviderCreated(ServiceWorkerProviderHostInfo info) override; @@ -104,8 +86,6 @@ const int render_process_id_; // Only accessed on the IO thread. - Phase phase_ = Phase::kInitial; - // Only accessed on the IO thread. scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_; DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDispatcherHost);
diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc index d07d623..a0f3cc70 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc
@@ -85,9 +85,11 @@ class TestingServiceWorkerDispatcherHost : public ServiceWorkerDispatcherHost { public: - TestingServiceWorkerDispatcherHost(int process_id, - EmbeddedWorkerTestHelper* helper) - : ServiceWorkerDispatcherHost(process_id), + TestingServiceWorkerDispatcherHost( + scoped_refptr<ServiceWorkerContextWrapper> context_wrapper, + int process_id, + EmbeddedWorkerTestHelper* helper) + : ServiceWorkerDispatcherHost(context_wrapper, process_id), bad_messages_received_count_(0), helper_(helper) {} @@ -128,9 +130,8 @@ helper_.reset(helper.release()); // Replace the default dispatcher host. int process_id = helper_->mock_render_process_id(); - dispatcher_host_ = - new TestingServiceWorkerDispatcherHost(process_id, helper_.get()); - dispatcher_host_->Init(context_wrapper()); + dispatcher_host_ = new TestingServiceWorkerDispatcherHost( + context_wrapper(), process_id, helper_.get()); } void SetUpRegistration(const GURL& scope, const GURL& script_url) { @@ -282,9 +283,8 @@ // is not yet destroyed. This is what the browser does when reusing a crashed // render process. auto new_dispatcher_host = - base::MakeRefCounted<TestingServiceWorkerDispatcherHost>(process_id, - helper_.get()); - new_dispatcher_host->Init(context_wrapper()); + base::MakeRefCounted<TestingServiceWorkerDispatcherHost>( + context_wrapper(), process_id, helper_.get()); // To show the new dispatcher can operate, simulate provider creation. Since // the old dispatcher cleaned up the old provider host, the new one won't
diff --git a/content/browser/webauth/authenticator_impl.cc b/content/browser/webauth/authenticator_impl.cc index 2cc796d..73d269d 100644 --- a/content/browser/webauth/authenticator_impl.cc +++ b/content/browser/webauth/authenticator_impl.cc
@@ -674,6 +674,11 @@ } } +void AuthenticatorImpl::IsUserVerifyingPlatformAuthenticatorAvailable( + IsUserVerifyingPlatformAuthenticatorAvailableCallback callback) { + std::move(callback).Run(false); +} + void AuthenticatorImpl::DidFinishNavigation( NavigationHandle* navigation_handle) { if (!navigation_handle->HasCommitted() ||
diff --git a/content/browser/webauth/authenticator_impl.h b/content/browser/webauth/authenticator_impl.h index 5fe89035..9b451cb 100644 --- a/content/browser/webauth/authenticator_impl.h +++ b/content/browser/webauth/authenticator_impl.h
@@ -103,6 +103,8 @@ void GetAssertion( webauth::mojom::PublicKeyCredentialRequestOptionsPtr options, GetAssertionCallback callback) override; + void IsUserVerifyingPlatformAuthenticatorAvailable( + IsUserVerifyingPlatformAuthenticatorAvailableCallback callback) override; // WebContentsObserver: void DidFinishNavigation(NavigationHandle* navigation_handle) override;
diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn index 882c8f6..7e875b1 100644 --- a/content/public/android/BUILD.gn +++ b/content/public/android/BUILD.gn
@@ -206,7 +206,6 @@ "java/src/org/chromium/content/browser/selection/AdditionalMenuItemProvider.java", "java/src/org/chromium/content/browser/selection/FloatingActionModeCallback.java", "java/src/org/chromium/content/browser/selection/FloatingPastePopupMenu.java", - "java/src/org/chromium/content/browser/selection/HandleViewResources.java", "java/src/org/chromium/content/browser/selection/LGEmailActionModeWorkaroundImpl.java", "java/src/org/chromium/content/browser/selection/LegacyPastePopupMenu.java", "java/src/org/chromium/content/browser/selection/PastePopupMenu.java", @@ -389,7 +388,6 @@ "java/src/org/chromium/content/browser/input/SelectPopup.java", "java/src/org/chromium/content/browser/input/SuggestionInfo.java", "java/src/org/chromium/content/browser/input/TextSuggestionHost.java", - "java/src/org/chromium/content/browser/selection/HandleViewResources.java", "java/src/org/chromium/content/browser/selection/SelectionPopupControllerImpl.java", "java/src/org/chromium/content/browser/selection/SmartSelectionClient.java", "java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java",
diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index 2825197..e7d6bcc 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc
@@ -621,6 +621,10 @@ return false; } +void ContentBrowserClient::WillCreateWebSocket( + RenderFrameHost* frame, + network::mojom::WebSocketRequest* request) {} + network::mojom::NetworkContextPtr ContentBrowserClient::CreateNetworkContext( BrowserContext* context, bool in_memory,
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index 690808d..b7efb73 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h
@@ -34,6 +34,7 @@ #include "net/base/mime_util.h" #include "net/cookies/canonical_cookie.h" #include "services/network/public/mojom/network_service.mojom.h" +#include "services/network/public/mojom/websocket.mojom.h" #include "services/service_manager/embedder/embedded_service_info.h" #include "services/service_manager/public/cpp/binder_registry.h" #include "services/service_manager/public/mojom/service.mojom.h" @@ -1038,6 +1039,15 @@ bool is_navigation, network::mojom::URLLoaderFactoryRequest* factory_request); + // Allows the embedder to intercept a WebSocket connection. |*request| + // is always valid upon entry and MUST be valid upon return. The embedder + // may swap out the value of |*request| for its own. + // + // Always called on the UI thread and only when the Network Service is + // enabled. + virtual void WillCreateWebSocket(RenderFrameHost* frame, + network::mojom::WebSocketRequest* request); + // Allows the embedder to returns a list of request interceptors that can // intercept a navigation request. //
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index 15adb76..658487ec 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc
@@ -1468,6 +1468,10 @@ return static_cast<WebContentsImpl*>(web_contents)->GetMouseLockWidget(); } +RenderWidgetHost* GetKeyboardLockWidget(WebContents* web_contents) { + return static_cast<WebContentsImpl*>(web_contents)->GetKeyboardLockWidget(); +} + bool IsInnerInterstitialPageConnected(InterstitialPage* interstitial_page) { InterstitialPageImpl* impl = static_cast<InterstitialPageImpl*>(interstitial_page);
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h index 99feb9a..ca80821 100644 --- a/content/public/test/browser_test_utils.h +++ b/content/public/test/browser_test_utils.h
@@ -484,6 +484,9 @@ // Returns the RenderWidgetHost that holds the mouse lock. RenderWidgetHost* GetMouseLockWidget(WebContents* web_contents); +// Returns the RenderWidgetHost that holds the keyboard lock. +RenderWidgetHost* GetKeyboardLockWidget(WebContents* web_contents); + // Returns true if inner |interstitial_page| is connected to an outer // WebContents. bool IsInnerInterstitialPageConnected(InterstitialPage* interstitial_page);
diff --git a/content/renderer/accessibility/render_accessibility_impl.cc b/content/renderer/accessibility/render_accessibility_impl.cc index 2f1dbac..79fd36cff 100644 --- a/content/renderer/accessibility/render_accessibility_impl.cc +++ b/content/renderer/accessibility/render_accessibility_impl.cc
@@ -454,15 +454,8 @@ if (plugin_tree_source_) event_msg.update.has_tree_data = true; - if (event_msgs.size() == 0) - serializer_.BeginSerializingChanges(&event_msg.update); - - if (!serializer_.SerializeOneChange(obj)) { + if (!serializer_.SerializeChanges(obj, &event_msg.update)) { VLOG(1) << "Failed to serialize one accessibility event."; - - if (event_msgs.size() == 0) - serializer_.FinishSerializingChanges(); - continue; } @@ -488,9 +481,6 @@ << "\n" << event_msg.update.ToString(); } - if (event_msgs.size()) - serializer_.FinishSerializingChanges(); - Send(new AccessibilityHostMsg_Events(routing_id(), event_msgs, reset_token_, ack_token_)); reset_token_ = 0;
diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn index bd604be..c6d2d179 100644 --- a/content/shell/BUILD.gn +++ b/content/shell/BUILD.gn
@@ -537,7 +537,6 @@ deps = [ ":content_shell_framework_bundle_data", ":content_shell_resources_bundle_data", - "//build/config:exe_and_shlib_deps", # TODO(rsesek): Remove this after GYP is gone, since it only needs to # be here per the comment in blink_test_platform_support_mac.mm about @@ -573,7 +572,6 @@ deps = [ ":content_shell_lib", ":pak", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] @@ -791,7 +789,6 @@ ] deps = [ ":content_shell_framework+link", - "//build/config:exe_and_shlib_deps", ] ldflags = [ # The helper is in Content Shell.app/Contents/Frameworks/Content Shell Helper.app/Contents/MacOS/
diff --git a/content/shell/android/BUILD.gn b/content/shell/android/BUILD.gn index d430a3a2..b823a3c1 100644 --- a/content/shell/android/BUILD.gn +++ b/content/shell/android/BUILD.gn
@@ -31,7 +31,6 @@ deps = [ ":content_shell_jni_headers", ":content_shell_jni_registration", - "//build/config:exe_and_shlib_deps", "//components/crash/content/browser", "//content/shell:content_shell_lib", "//content/shell:pak", @@ -303,7 +302,6 @@ deps = [ ":linker_test_jni_headers", ":linker_test_jni_registration", - "//build/config:exe_and_shlib_deps", "//content/shell:content_shell_lib", # Required to include "content/public/browser/android/compositor.h"
diff --git a/content/test/data/android/authenticator.html b/content/test/data/android/authenticator.html index f30e13c..ed454752 100644 --- a/content/test/data/android/authenticator.html +++ b/content/test/data/android/authenticator.html
@@ -73,6 +73,30 @@ } }); } + + function doIsUserVerifyingPlatformAuthenticatorAvailable() { + if (window.PublicKeyCredential === undefined) { + window.document.title = 'Fail: isUserVerifyingPlatformAuthenticatorAvailable() === undefined'; + return; + } + + if (window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable === undefined) { + window.document.title = 'Fail: isUserVerifyingPlatformAuthenticatorAvailable() === undefined'; + return; + } + + PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() + .then(r => { + if (r == false) { + window.document.title = 'Success'; + } else { + window.document.title = 'Fail'; + } + }) + .catch(e => { + window.document.title = 'Fail: ' + e.name + " " + e.message; + }); + } </script> </head> <body>
diff --git a/content/test/gpu/generate_buildbot_json.py b/content/test/gpu/generate_buildbot_json.py index b4428c5..9284f750 100755 --- a/content/test/gpu/generate_buildbot_json.py +++ b/content/test/gpu/generate_buildbot_json.py
@@ -2859,6 +2859,8 @@ 'can_use_on_swarming_builders': tester_config['swarming'], 'dimension_sets': tester_config['swarming_dimensions'] }) + if 'swarming_settings' in tester_config: + result['swarming'].update(tester_config['swarming_settings']) if is_android(tester_config): # Integrate with the unified logcat system. result['swarming'].update({ @@ -3031,6 +3033,21 @@ for name, config in waterfall.get('testers', {}).iteritems(): config['parent'] = waterfall +def cmp_gtests(a, b): + # Prefer to compare based on the "test" key. + val = cmp(a['test'], b['test']) + if val != 0: + return val + if 'name' in a and 'name' in b: + return cmp(a['name'], b['name']) # pragma: no cover + if 'name' not in a and 'name' not in b: + return 0 # pragma: no cover + # Prefer to put variants of the same test after the first one. + if 'name' in a: + return 1 + # 'name' is in b. + return -1 # pragma: no cover + def generate_all_tests(waterfall, filename): tests = {} for builder, config in waterfall.get('prologue', {}).iteritems(): @@ -3044,10 +3061,12 @@ name, config, TELEMETRY_GPU_INTEGRATION_TESTS) + \ generate_non_telemetry_isolated_tests(waterfall, name, config, NON_TELEMETRY_ISOLATED_SCRIPT_TESTS) - tests[name] = { - 'gtest_tests': sorted(gtests, key=lambda x: x['test']), - 'isolated_scripts': sorted(isolated_scripts, key=lambda x: x['name']) - } + tests[name] = {} + if len(gtests) > 0: + tests[name]['gtest_tests'] = sorted(gtests, cmp=cmp_gtests) + if len(isolated_scripts) > 0: + tests[name]['isolated_scripts'] = sorted( + isolated_scripts, key=lambda x: x['name']) tests['AAAAA1 AUTOGENERATED FILE DO NOT EDIT'] = {} tests['AAAAA2 See gpu/generate_buildbot_json.py to make changes'] = {} with open(os.path.join(SRC_DIR, 'testing', 'buildbot', filename), 'wb') as fp:
diff --git a/courgette/BUILD.gn b/courgette/BUILD.gn index 3084b06..047784d 100644 --- a/courgette/BUILD.gn +++ b/courgette/BUILD.gn
@@ -98,7 +98,6 @@ deps = [ ":courgette_lib", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -111,7 +110,6 @@ deps = [ ":courgette_lib", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/dbus/BUILD.gn b/dbus/BUILD.gn index be11703..042d8c0 100644 --- a/dbus/BUILD.gn +++ b/dbus/BUILD.gn
@@ -125,7 +125,6 @@ ":dbus", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", ] configs += [ "//build/config/linux/dbus" ]
diff --git a/device/fido/fido_cable_discovery.cc b/device/fido/fido_cable_discovery.cc index a290edc6..c4bfb6c 100644 --- a/device/fido/fido_cable_discovery.cc +++ b/device/fido/fido_cable_discovery.cc
@@ -8,6 +8,7 @@ #include <utility> #include "base/bind.h" +#include "base/bind_helpers.h" #include "base/callback_helpers.h" #include "base/strings/stringprintf.h" #include "base/threading/sequenced_task_runner_handle.h" @@ -128,9 +129,11 @@ std::vector<CableDiscoveryData> discovery_data) : discovery_data_(std::move(discovery_data)), weak_factory_(this) {} -// Destruction of FidoCableDiscovery will unregister |advertisements_| on -// best-effort basis. -FidoCableDiscovery::~FidoCableDiscovery() = default; +// This is a workaround for https://crbug.com/846522 +FidoCableDiscovery::~FidoCableDiscovery() { + for (auto advertisement : advertisements_) + advertisement.second->Unregister(base::DoNothing(), base::DoNothing()); +} void FidoCableDiscovery::DeviceAdded(BluetoothAdapter* adapter, BluetoothDevice* device) {
diff --git a/device/fido/fido_cable_discovery.h b/device/fido/fido_cable_discovery.h index c0006c0c..8050ab6 100644 --- a/device/fido/fido_cable_discovery.h +++ b/device/fido/fido_cable_discovery.h
@@ -56,6 +56,9 @@ ~FidoCableDiscovery() override; private: + FRIEND_TEST_ALL_PREFIXES(FidoCableDiscoveryTest, + TestUnregisterAdvertisementUponDestruction); + // BluetoothAdapter::Observer: void DeviceAdded(BluetoothAdapter* adapter, BluetoothDevice* device) override; void DeviceChanged(BluetoothAdapter* adapter,
diff --git a/device/fido/fido_cable_discovery_unittest.cc b/device/fido/fido_cable_discovery_unittest.cc index ee890790..712ad671 100644 --- a/device/fido/fido_cable_discovery_unittest.cc +++ b/device/fido/fido_cable_discovery_unittest.cc
@@ -11,9 +11,9 @@ #include "base/stl_util.h" #include "build/build_config.h" #include "device/bluetooth/bluetooth_adapter_factory.h" +#include "device/bluetooth/bluetooth_advertisement.h" #include "device/bluetooth/test/bluetooth_test.h" #include "device/bluetooth/test/mock_bluetooth_adapter.h" -#include "device/bluetooth/test/mock_bluetooth_advertisement.h" #include "device/fido/fido_ble_device.h" #include "device/fido/fido_ble_uuids.h" #include "device/fido/fido_parsing_utils.h" @@ -112,6 +112,16 @@ return true; } +class CableMockBluetoothAdvertisement : public BluetoothAdvertisement { + public: + MOCK_METHOD2(Unregister, + void(const SuccessCallback& success_callback, + const ErrorCallback& error_callback)); + + private: + ~CableMockBluetoothAdvertisement() override = default; +}; + // Mock BLE adapter that abstracts out authenticator logic with the following // logic: // - Responds to BluetoothAdapter::RegisterAdvertisement() by always invoking @@ -150,18 +160,23 @@ void ExpectRegisterAdvertisementWithResponse( bool simulate_success, base::span<const uint8_t> expected_client_eid, - base::StringPiece expected_uuid_formatted_client_eid) { + base::StringPiece expected_uuid_formatted_client_eid, + scoped_refptr<CableMockBluetoothAdvertisement> advertisement_ptr = + nullptr) { + if (!advertisement_ptr) + advertisement_ptr = + base::MakeRefCounted<CableMockBluetoothAdvertisement>(); + EXPECT_CALL(*this, RegisterAdvertisement( IsAdvertisementContent(expected_client_eid, expected_uuid_formatted_client_eid), _, _)) .WillOnce(::testing::WithArgs<1, 2>( - [simulate_success](const auto& success_callback, - const auto& failure_callback) { + [simulate_success, advertisement_ptr]( + const auto& success_callback, const auto& failure_callback) { simulate_success - ? success_callback.Run( - base::MakeRefCounted<MockBluetoothAdvertisement>()) + ? success_callback.Run(advertisement_ptr) : failure_callback.Run(BluetoothAdvertisement::ErrorCode:: INVALID_ADVERTISEMENT_ERROR_CODE); })); @@ -338,4 +353,26 @@ scoped_task_environment_.RunUntilIdle(); } +TEST_F(FidoCableDiscoveryTest, TestUnregisterAdvertisementUponDestruction) { + auto cable_discovery = CreateDiscovery(); + CableMockBluetoothAdvertisement* advertisement = + new CableMockBluetoothAdvertisement(); + EXPECT_CALL(*advertisement, Unregister(_, _)).Times(1); + + ::testing::InSequence testing_sequence; + auto mock_adapter = + base::MakeRefCounted<::testing::NiceMock<CableMockAdapter>>(); + mock_adapter->ExpectSuccessCallbackToSetPowered(); + mock_adapter->ExpectRegisterAdvertisementWithResponse( + true /* simulate_success */, kClientEid, kUuidFormattedClientEid, + base::WrapRefCounted(advertisement)); + + BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter); + cable_discovery->Start(); + scoped_task_environment_.RunUntilIdle(); + + EXPECT_EQ(1u, cable_discovery->advertisements_.size()); + cable_discovery.reset(); +} + } // namespace device
diff --git a/device/vr/orientation/orientation_device.cc b/device/vr/orientation/orientation_device.cc index 730814b..bdfbd333 100644 --- a/device/vr/orientation/orientation_device.cc +++ b/device/vr/orientation/orientation_device.cc
@@ -204,8 +204,4 @@ return q; } -bool VROrientationDevice::IsFallbackDevice() { - return true; -}; - } // namespace device
diff --git a/device/vr/orientation/orientation_device.h b/device/vr/orientation/orientation_device.h index dde90f7..cdd1604 100644 --- a/device/vr/orientation/orientation_device.h +++ b/device/vr/orientation/orientation_device.h
@@ -46,8 +46,6 @@ void OnMagicWindowPoseRequest( mojom::VRMagicWindowProvider::GetPoseCallback callback) override; - bool IsFallbackDevice() override; - // Indicates whether the device was able to connect to orientation events. bool IsAvailable() const { return available_; }
diff --git a/device/vr/vr_device.h b/device/vr/vr_device.h index e556478c..521fc2404 100644 --- a/device/vr/vr_device.h +++ b/device/vr/vr_device.h
@@ -72,9 +72,6 @@ mojom::VRDisplayHost::RequestPresentCallback callback) = 0; virtual void SetListeningForActivate(bool is_listening) = 0; - // The fallback device should only be provided in lieu of other devices. - virtual bool IsFallbackDevice() = 0; - // TODO(mthiesse): The browser should handle browser-side exiting of // presentation before device/ is even aware presentation is being exited. // Then the browser should call ExitPresent() on Device, which does device/
diff --git a/device/vr/vr_device_base.cc b/device/vr/vr_device_base.cc index c73cb7f0..23abf3b 100644 --- a/device/vr/vr_device_base.cc +++ b/device/vr/vr_device_base.cc
@@ -32,10 +32,6 @@ return display_info_.Clone(); } -bool VRDeviceBase::IsFallbackDevice() { - return false; -}; - void VRDeviceBase::OnExitPresent() { if (listener_) listener_->OnExitPresent();
diff --git a/device/vr/vr_device_base.h b/device/vr/vr_device_base.h index 5417516a..005678a 100644 --- a/device/vr/vr_device_base.h +++ b/device/vr/vr_device_base.h
@@ -39,7 +39,6 @@ mojom::VRRequestPresentOptionsPtr present_options, mojom::VRDisplayHost::RequestPresentCallback callback) override; void ExitPresent() override; - bool IsFallbackDevice() override; void SetListeningForActivate(bool is_listening) override; bool IsAccessAllowed(VRDisplayImpl* display);
diff --git a/extensions/browser/api/declarative/rules_registry_service.cc b/extensions/browser/api/declarative/rules_registry_service.cc index 4b3fc2c..d92d3d5 100644 --- a/extensions/browser/api/declarative/rules_registry_service.cc +++ b/extensions/browser/api/declarative/rules_registry_service.cc
@@ -20,6 +20,8 @@ #include "extensions/browser/api/web_request/web_request_api.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/extension.h" +#include "extensions/common/features/feature.h" +#include "extensions/common/features/feature_provider.h" namespace extensions { @@ -194,9 +196,17 @@ RulesRegistryKey(declarative_webrequest_constants::kOnRequest, kDefaultRulesRegistryID))); - // Persist the cache since it pertains to regular pages (i.e. not webviews). - RegisterWebRequestRulesRegistry(kDefaultRulesRegistryID, - RulesCacheDelegate::Type::kPersistent); + // Only register the default web request rules registry if the + // declarativeWebRequest API is enabled. See crbug.com/693243. + const bool is_api_enabled = + FeatureProvider::GetAPIFeature("declarativeWebRequest") + ->IsAvailableToEnvironment() + .is_available(); + if (is_api_enabled) { + // Persist the cache since it pertains to regular pages (i.e. not webviews). + RegisterWebRequestRulesRegistry(kDefaultRulesRegistryID, + RulesCacheDelegate::Type::kPersistent); + } // Create the ContentRulesRegistry. DCHECK(!content_rules_registry_);
diff --git a/extensions/browser/api/web_request/BUILD.gn b/extensions/browser/api/web_request/BUILD.gn index d41346d..b98dd3e 100644 --- a/extensions/browser/api/web_request/BUILD.gn +++ b/extensions/browser/api/web_request/BUILD.gn
@@ -28,6 +28,8 @@ "web_request_permissions.h", "web_request_proxying_url_loader_factory.cc", "web_request_proxying_url_loader_factory.h", + "web_request_proxying_websocket.cc", + "web_request_proxying_websocket.h", "web_request_resource_type.cc", "web_request_resource_type.h", "web_request_time_tracker.cc",
diff --git a/extensions/browser/api/web_request/web_request_api.cc b/extensions/browser/api/web_request/web_request_api.cc index 28917d9..9a9e433 100644 --- a/extensions/browser/api/web_request/web_request_api.cc +++ b/extensions/browser/api/web_request/web_request_api.cc
@@ -50,6 +50,7 @@ #include "extensions/browser/api/web_request/web_request_event_router_delegate.h" #include "extensions/browser/api/web_request/web_request_info.h" #include "extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h" +#include "extensions/browser/api/web_request/web_request_proxying_websocket.h" #include "extensions/browser/api/web_request/web_request_resource_type.h" #include "extensions/browser/api/web_request/web_request_time_tracker.h" #include "extensions/browser/api_activity_monitor.h" @@ -389,7 +390,8 @@ WebRequestAPI::WebRequestAPI(content::BrowserContext* context) : browser_context_(context), info_map_(ExtensionSystem::Get(browser_context_)->info_map()), - proxies_(base::MakeRefCounted<ProxySet>()) { + proxies_(base::MakeRefCounted<ProxySet>()), + request_id_generator_(base::MakeRefCounted<RequestIDGenerator>()) { EventRouter* event_router = EventRouter::Get(browser_context_); for (size_t i = 0; i < arraysize(kWebRequestEvents); ++i) { // Observe the webRequest event. @@ -495,12 +497,44 @@ // which takes a net::URLRequest*. is_navigation ? -1 : frame->GetProcess()->GetID(), is_navigation ? MSG_ROUTING_NONE : frame->GetRoutingID(), - std::move(navigation_ui_data), base::Unretained(info_map_), - std::move(proxied_request), std::move(target_factory_info), - proxies_)); + request_id_generator_, std::move(navigation_ui_data), + base::Unretained(info_map_), std::move(proxied_request), + std::move(target_factory_info), proxies_)); return true; } +void WebRequestAPI::MaybeProxyWebSocket( + content::RenderFrameHost* frame, + network::mojom::WebSocketRequest* request) { + DCHECK_CURRENTLY_ON(BrowserThread::UI); + const auto* rules_registry_service = + BrowserContextKeyedAPIFactory<RulesRegistryService>::Get( + browser_context_); + const auto* rules_monitor_service = BrowserContextKeyedAPIFactory< + declarative_net_request::RulesMonitorService>::Get(browser_context_); + if (!base::FeatureList::IsEnabled(network::features::kNetworkService) || + (listener_count_ == 0 && + !rules_registry_service->HasAnyRegisteredRules() && + !rules_monitor_service->HasAnyRegisteredRulesets())) { + return; + } + + network::mojom::WebSocketPtrInfo proxied_socket_ptr_info; + auto proxied_request = std::move(*request); + *request = mojo::MakeRequest(&proxied_socket_ptr_info); + + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::BindOnce( + &WebRequestProxyingWebSocket::StartProxying, + frame->GetProcess()->GetID(), frame->GetRoutingID(), + request_id_generator_, frame->GetLastCommittedOrigin(), + frame->GetProcess()->GetBrowserContext(), + frame->GetProcess()->GetBrowserContext()->GetResourceContext(), + base::Unretained(info_map_), std::move(proxied_socket_ptr_info), + std::move(proxied_request), proxies_)); +} + // Represents a single unique listener to an event, along with whatever filter // parameters and extra_info_spec were specified at the time the listener was // added.
diff --git a/extensions/browser/api/web_request/web_request_api.h b/extensions/browser/api/web_request/web_request_api.h index ef838578..d0134c5 100644 --- a/extensions/browser/api/web_request/web_request_api.h +++ b/extensions/browser/api/web_request/web_request_api.h
@@ -34,6 +34,7 @@ #include "net/base/network_delegate.h" #include "net/http/http_request_headers.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" +#include "services/network/public/mojom/websocket.mojom.h" class ExtensionWebRequestTimeTracker; class GURL; @@ -115,6 +116,26 @@ DISALLOW_COPY_AND_ASSIGN(ProxySet); }; + class RequestIDGenerator + : public base::RefCountedThreadSafe<RequestIDGenerator> { + public: + RequestIDGenerator() = default; + int64_t Generate() { + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + return ++id_; + } + + private: + friend class base::RefCountedThreadSafe<RequestIDGenerator>; + ~RequestIDGenerator() {} + + // Although this initialization can be done in a thread other than the IO + // thread, we expect at least one memory barrier before actually calling + // Generate in the IO thread, so we don't protect the variable with a lock. + int64_t id_ = 0; + DISALLOW_COPY_AND_ASSIGN(RequestIDGenerator); + }; + explicit WebRequestAPI(content::BrowserContext* context); ~WebRequestAPI() override; @@ -138,6 +159,15 @@ bool is_navigation, network::mojom::URLLoaderFactoryRequest* factory_request); + // If any WebRequest event listeners are currently active for this + // BrowserContext, |*request| is swapped out for a new request which proxies + // through an internal WebSocket implementation. This supports lifetime + // observation and control on behalf of the WebRequest API. + // + // Only used when the Network Service is enabled. + void MaybeProxyWebSocket(content::RenderFrameHost* frame, + network::mojom::WebSocketRequest* request); + private: friend class BrowserContextKeyedAPIFactory<WebRequestAPI>; @@ -156,6 +186,8 @@ // Active proxies. Only used when the Network Service is enabled. scoped_refptr<ProxySet> proxies_; + scoped_refptr<RequestIDGenerator> request_id_generator_; + DISALLOW_COPY_AND_ASSIGN(WebRequestAPI); };
diff --git a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc index 04d0b6f..474b329 100644 --- a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc +++ b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.cc
@@ -410,6 +410,7 @@ content::ResourceContext* resource_context, int render_process_id, int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, InfoMap* info_map, network::mojom::URLLoaderFactoryRequest loader_request, @@ -419,6 +420,7 @@ resource_context_(resource_context), render_process_id_(render_process_id), render_frame_id_(render_frame_id), + request_id_generator_(std::move(request_id_generator)), navigation_ui_data_(std::move(navigation_ui_data)), info_map_(info_map), proxies_(proxies) { @@ -438,6 +440,7 @@ content::ResourceContext* resource_context, int render_process_id, int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, InfoMap* info_map, network::mojom::URLLoaderFactoryRequest loader_request, @@ -449,8 +452,8 @@ auto proxy = std::make_unique<WebRequestProxyingURLLoaderFactory>( browser_context, resource_context, render_process_id, render_frame_id, - std::move(navigation_ui_data), info_map, std::move(loader_request), - std::move(target_factory_info), proxies.get()); + std::move(request_id_generator), std::move(navigation_ui_data), info_map, + std::move(loader_request), std::move(target_factory_info), proxies.get()); proxies->AddProxy(std::move(proxy)); } @@ -469,7 +472,7 @@ // needs to be unique per-BrowserContext so extensions can make sense of it. // Note that |network_service_request_id_| by contrast is not necessarily // unique, so we don't use it for identity here. - const uint64_t web_request_id = next_request_id_++; + const uint64_t web_request_id = request_id_generator_->Generate(); auto result = requests_.emplace( web_request_id, std::make_unique<InProgressRequest>(
diff --git a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h index 3481589..f7d263b7 100644 --- a/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h +++ b/extensions/browser/api/web_request/web_request_proxying_url_loader_factory.h
@@ -141,11 +141,13 @@ content::ResourceContext* resource_context, int render_process_id, int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, InfoMap* info_map, network::mojom::URLLoaderFactoryRequest loader_request, network::mojom::URLLoaderFactoryPtrInfo target_factory_info, WebRequestAPI::ProxySet* proxies); + ~WebRequestProxyingURLLoaderFactory() override; static void StartProxying( @@ -153,6 +155,7 @@ content::ResourceContext* resource_context, int render_process_id, int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, InfoMap* info_map, network::mojom::URLLoaderFactoryRequest loader_request, @@ -179,13 +182,13 @@ content::ResourceContext* const resource_context_; const int render_process_id_; const int render_frame_id_; + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator_; std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data_; InfoMap* const info_map_; mojo::BindingSet<network::mojom::URLLoaderFactory> proxy_bindings_; network::mojom::URLLoaderFactoryPtr target_factory_; // Owns |this|. WebRequestAPI::ProxySet* const proxies_; - uint64_t next_request_id_ = 1; std::map<int32_t, std::unique_ptr<InProgressRequest>> requests_;
diff --git a/extensions/browser/api/web_request/web_request_proxying_websocket.cc b/extensions/browser/api/web_request/web_request_proxying_websocket.cc new file mode 100644 index 0000000..50f1b03 --- /dev/null +++ b/extensions/browser/api/web_request/web_request_proxying_websocket.cc
@@ -0,0 +1,310 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "extensions/browser/api/web_request/web_request_proxying_websocket.h" + +#include "base/strings/stringprintf.h" +#include "content/public/browser/browser_thread.h" +#include "extensions/browser/extension_navigation_ui_data.h" +#include "mojo/public/cpp/bindings/strong_binding.h" +#include "net/http/http_util.h" + +namespace extensions { + +WebRequestProxyingWebSocket::WebRequestProxyingWebSocket( + int process_id, + int render_frame_id, + const url::Origin& origin, + content::BrowserContext* browser_context, + content::ResourceContext* resource_context, + InfoMap* info_map, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, + network::mojom::WebSocketPtr proxied_socket, + network::mojom::WebSocketRequest proxied_request, + WebRequestAPI::ProxySet* proxies) + : process_id_(process_id), + render_frame_id_(render_frame_id), + origin_(origin), + browser_context_(browser_context), + resource_context_(resource_context), + info_map_(info_map), + request_id_generator_(std::move(request_id_generator)), + proxied_socket_(std::move(proxied_socket)), + binding_as_websocket_(this), + binding_as_client_(this), + proxies_(proxies), + weak_factory_(this) { + binding_as_websocket_.Bind(std::move(proxied_request)); + + binding_as_websocket_.set_connection_error_handler( + base::BindRepeating(&WebRequestProxyingWebSocket::OnError, + base::Unretained(this), net::ERR_FAILED)); +} + +WebRequestProxyingWebSocket::~WebRequestProxyingWebSocket() = default; + +void WebRequestProxyingWebSocket::AddChannelRequest( + const GURL& url, + const std::vector<std::string>& requested_protocols, + const GURL& site_for_cookies, + std::vector<network::mojom::HttpHeaderPtr> additional_headers, + network::mojom::WebSocketClientPtr client) { + if (binding_as_client_.is_bound() || !client || forwarding_client_) { + // Illegal request. + proxied_socket_ = nullptr; + return; + } + + request_.url = url; + request_.site_for_cookies = site_for_cookies; + request_.request_initiator = origin_; + websocket_protocols_ = requested_protocols; + uint64_t request_id = request_id_generator_->Generate(); + int routing_id = MSG_ROUTING_NONE; + info_.emplace(request_id, process_id_, render_frame_id_, nullptr, routing_id, + resource_context_, request_); + + forwarding_client_ = std::move(client); + + auto continuation = + base::BindRepeating(&WebRequestProxyingWebSocket::OnBeforeRequestComplete, + weak_factory_.GetWeakPtr()); + + // TODO(yhirano): Consider having throttling here (probably with aligned with + // WebRequestProxyingURLLoaderFactory). + int result = ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest( + browser_context_, info_map_, &info_.value(), continuation, + &redirect_url_); + + if (result == net::ERR_BLOCKED_BY_CLIENT) { + OnError(result); + return; + } + + if (result == net::ERR_IO_PENDING) { + return; + } + + DCHECK_EQ(net::OK, result); + OnBeforeRequestComplete(net::OK); +} + +void WebRequestProxyingWebSocket::SendFrame( + bool fin, + network::mojom::WebSocketMessageType type, + const std::vector<uint8_t>& data) { + proxied_socket_->SendFrame(fin, type, data); +} + +void WebRequestProxyingWebSocket::SendFlowControl(int64_t quota) { + proxied_socket_->SendFlowControl(quota); +} + +void WebRequestProxyingWebSocket::StartClosingHandshake( + uint16_t code, + const std::string& reason) { + proxied_socket_->StartClosingHandshake(code, reason); +} + +void WebRequestProxyingWebSocket::OnFailChannel(const std::string& reason) { + DCHECK(forwarding_client_); + forwarding_client_->OnFailChannel(reason); + + forwarding_client_ = nullptr; + OnError(net::ERR_FAILED); +} + +void WebRequestProxyingWebSocket::OnStartOpeningHandshake( + network::mojom::WebSocketHandshakeRequestPtr request) { + DCHECK(forwarding_client_); + forwarding_client_->OnStartOpeningHandshake(std::move(request)); +} + +void WebRequestProxyingWebSocket::OnFinishOpeningHandshake( + network::mojom::WebSocketHandshakeResponsePtr response) { + DCHECK(forwarding_client_); + + response_.headers = + base::MakeRefCounted<net::HttpResponseHeaders>(base::StringPrintf( + "HTTP/%d.%d %d %s", response->http_version.major_value(), + response->http_version.minor_value(), response->status_code, + response->status_text.c_str())); + for (const auto& header : response->headers) { + if (!net::HttpResponseHeaders::IsCookieResponseHeader(header->name)) { + // When the renderer process has an access to raw cookie headers, such + // headers can be contained in |response|. Here we remove such headers + // manually. + response_.headers->AddHeader(header->name + ": " + header->value); + } + } + response_.socket_address = response->socket_address; + + forwarding_client_->OnFinishOpeningHandshake(std::move(response)); + + auto continuation = base::BindRepeating( + &WebRequestProxyingWebSocket::OnHeadersReceivedComplete, + weak_factory_.GetWeakPtr()); + int result = ExtensionWebRequestEventRouter::GetInstance()->OnHeadersReceived( + browser_context_, info_map_, &info_.value(), continuation, + response_.headers.get(), &override_headers_, &redirect_url_); + + if (result == net::ERR_BLOCKED_BY_CLIENT) { + OnError(result); + return; + } + + binding_as_client_.PauseIncomingMethodCallProcessing(); + if (result == net::ERR_IO_PENDING) + return; + + DCHECK_EQ(net::OK, result); + OnHeadersReceivedComplete(net::OK); +} + +void WebRequestProxyingWebSocket::OnAddChannelResponse( + const std::string& selected_protocol, + const std::string& extensions) { + DCHECK(forwarding_client_); + DCHECK(!is_done_); + is_done_ = true; + ExtensionWebRequestEventRouter::GetInstance()->OnCompleted( + browser_context_, info_map_, &info_.value(), net::ERR_WS_UPGRADE); + + forwarding_client_->OnAddChannelResponse(selected_protocol, extensions); +} + +void WebRequestProxyingWebSocket::OnDataFrame( + bool fin, + network::mojom::WebSocketMessageType type, + const std::vector<uint8_t>& data) { + DCHECK(forwarding_client_); + forwarding_client_->OnDataFrame(fin, type, data); +} + +void WebRequestProxyingWebSocket::OnFlowControl(int64_t quota) { + DCHECK(forwarding_client_); + forwarding_client_->OnFlowControl(quota); +} + +void WebRequestProxyingWebSocket::OnDropChannel(bool was_clean, + uint16_t code, + const std::string& reason) { + DCHECK(forwarding_client_); + forwarding_client_->OnDropChannel(was_clean, code, reason); + + forwarding_client_ = nullptr; + OnError(net::ERR_FAILED); +} + +void WebRequestProxyingWebSocket::OnClosingHandshake() { + DCHECK(forwarding_client_); + forwarding_client_->OnClosingHandshake(); +} + +void WebRequestProxyingWebSocket::StartProxying( + int process_id, + int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, + const url::Origin& origin, + content::BrowserContext* browser_context, + content::ResourceContext* resource_context, + InfoMap* info_map, + network::mojom::WebSocketPtrInfo proxied_socket_ptr_info, + network::mojom::WebSocketRequest proxied_request, + scoped_refptr<WebRequestAPI::ProxySet> proxies) { + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + if (proxies->is_shutdown()) + return; + + auto proxy = std::make_unique<WebRequestProxyingWebSocket>( + process_id, render_frame_id, origin, browser_context, resource_context, + info_map, std::move(request_id_generator), + network::mojom::WebSocketPtr(std::move(proxied_socket_ptr_info)), + std::move(proxied_request), proxies.get()); + + proxies->AddProxy(std::move(proxy)); +} + +void WebRequestProxyingWebSocket::OnBeforeRequestComplete(int error_code) { + DCHECK(!binding_as_client_.is_bound()); + DCHECK(request_.url.SchemeIsWSOrWSS()); + if (error_code != net::OK) { + OnError(error_code); + return; + } + + auto continuation = base::BindRepeating( + &WebRequestProxyingWebSocket::OnBeforeSendHeadersComplete, + weak_factory_.GetWeakPtr()); + + int result = + ExtensionWebRequestEventRouter::GetInstance()->OnBeforeSendHeaders( + browser_context_, info_map_, &info_.value(), continuation, + &request_.headers); + + if (result == net::ERR_BLOCKED_BY_CLIENT) { + OnError(result); + return; + } + + if (result == net::ERR_IO_PENDING) + return; + + DCHECK_EQ(net::OK, result); + OnBeforeSendHeadersComplete(net::OK); +} + +void WebRequestProxyingWebSocket::OnBeforeSendHeadersComplete(int error_code) { + DCHECK(!binding_as_client_.is_bound()); + if (error_code != net::OK) { + OnError(error_code); + return; + } + + ExtensionWebRequestEventRouter::GetInstance()->OnSendHeaders( + browser_context_, info_map_, &info_.value(), request_.headers); + + network::mojom::WebSocketClientPtr proxy; + + std::vector<network::mojom::HttpHeaderPtr> additional_headers; + for (net::HttpRequestHeaders::Iterator it(request_.headers); it.GetNext();) { + additional_headers.push_back( + network::mojom::HttpHeader::New(it.name(), it.value())); + } + + binding_as_client_.Bind(mojo::MakeRequest(&proxy)); + binding_as_client_.set_connection_error_handler( + base::BindOnce(&WebRequestProxyingWebSocket::OnError, + base::Unretained(this), net::ERR_FAILED)); + proxied_socket_->AddChannelRequest( + request_.url, websocket_protocols_, request_.site_for_cookies, + std::move(additional_headers), std::move(proxy)); +} + +void WebRequestProxyingWebSocket::OnHeadersReceivedComplete(int error_code) { + if (error_code != net::OK) { + OnError(error_code); + return; + } + binding_as_client_.ResumeIncomingMethodCallProcessing(); + info_->AddResponseInfoFromResourceResponse(response_); + ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted( + browser_context_, info_map_, &info_.value(), net::OK); +} + +void WebRequestProxyingWebSocket::OnError(int error_code) { + if (!is_done_) { + is_done_ = true; + ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred( + browser_context_, info_map_, &info_.value(), true /* started */, + error_code); + } + if (forwarding_client_) + forwarding_client_->OnFailChannel(net::ErrorToString(error_code)); + + // Deletes |this|. + proxies_->RemoveProxy(this); +} + +} // namespace extensions
diff --git a/extensions/browser/api/web_request/web_request_proxying_websocket.h b/extensions/browser/api/web_request/web_request_proxying_websocket.h new file mode 100644 index 0000000..15a87b79 --- /dev/null +++ b/extensions/browser/api/web_request/web_request_proxying_websocket.h
@@ -0,0 +1,127 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_PROXYING_WEBSOCKET_H_ +#define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_PROXYING_WEBSOCKET_H_ + +#include <string> +#include <vector> + +#include "base/callback.h" +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "base/optional.h" +#include "extensions/browser/api/web_request/web_request_api.h" +#include "extensions/browser/api/web_request/web_request_info.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/binding_set.h" +#include "services/network/public/cpp/resource_request.h" +#include "services/network/public/cpp/resource_response.h" +#include "services/network/public/mojom/websocket.mojom.h" +#include "url/gurl.h" +#include "url/origin.h" + +namespace extensions { + +// A WebRequestProxyingWebSocket proxies a WebSocket connection and dispatches +// WebRequest API events. This is used only when the network service is enabled. +class WebRequestProxyingWebSocket : public WebRequestAPI::Proxy, + public network::mojom::WebSocket, + public network::mojom::WebSocketClient { + public: + WebRequestProxyingWebSocket( + int process_id, + int render_frame_id, + const url::Origin& origin, + content::BrowserContext* browser_context, + content::ResourceContext* resource_context, + InfoMap* info_map, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, + network::mojom::WebSocketPtr proxied_socket, + network::mojom::WebSocketRequest proxied_request, + WebRequestAPI::ProxySet* proxies); + ~WebRequestProxyingWebSocket() override; + + // mojom::WebSocket methods: + void AddChannelRequest( + const GURL& url, + const std::vector<std::string>& requested_protocols, + const GURL& site_for_cookies, + std::vector<network::mojom::HttpHeaderPtr> additional_headers, + network::mojom::WebSocketClientPtr client) override; + void SendFrame(bool fin, + network::mojom::WebSocketMessageType type, + const std::vector<uint8_t>& data) override; + void SendFlowControl(int64_t quota) override; + void StartClosingHandshake(uint16_t code, const std::string& reason) override; + + // mojom::WebSocketClient methods: + void OnFailChannel(const std::string& reason) override; + void OnStartOpeningHandshake( + network::mojom::WebSocketHandshakeRequestPtr request) override; + void OnFinishOpeningHandshake( + network::mojom::WebSocketHandshakeResponsePtr response) override; + void OnAddChannelResponse(const std::string& selected_protocol, + const std::string& extensions) override; + void OnDataFrame(bool fin, + network::mojom::WebSocketMessageType type, + const std::vector<uint8_t>& data) override; + void OnFlowControl(int64_t quota) override; + void OnDropChannel(bool was_clean, + uint16_t code, + const std::string& reason) override; + void OnClosingHandshake() override; + + static void StartProxying( + int process_id, + int render_frame_id, + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator, + const url::Origin& origin, + content::BrowserContext* browser_context, + content::ResourceContext* resource_context, + InfoMap* info_map, + network::mojom::WebSocketPtrInfo proxied_socket_ptr_info, + network::mojom::WebSocketRequest proxied_request, + scoped_refptr<WebRequestAPI::ProxySet> proxies); + + private: + void OnBeforeRequestComplete(int error_code); + void OnBeforeSendHeadersComplete(int error_code); + void OnHeadersReceivedComplete(int error_code); + + void OnError(int result); + + const int process_id_; + const int render_frame_id_; + const url::Origin origin_; + content::BrowserContext* const browser_context_; + content::ResourceContext* const resource_context_; + InfoMap* const info_map_; + scoped_refptr<WebRequestAPI::RequestIDGenerator> request_id_generator_; + network::mojom::WebSocketPtr proxied_socket_; + network::mojom::WebSocketClientPtr forwarding_client_; + mojo::Binding<network::mojom::WebSocket> binding_as_websocket_; + mojo::Binding<network::mojom::WebSocketClient> binding_as_client_; + + network::ResourceRequest request_; + network::ResourceResponseHead response_; + scoped_refptr<net::HttpResponseHeaders> override_headers_; + std::vector<std::string> websocket_protocols_; + + GURL redirect_url_; + bool is_done_ = false; + + base::Optional<WebRequestInfo> info_; + + // Owns |this|. + WebRequestAPI::ProxySet* const proxies_; + + base::WeakPtrFactory<WebRequestProxyingWebSocket> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(WebRequestProxyingWebSocket); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_PROXYING_WEBSOCKET_H_
diff --git a/extensions/browser/updater/extension_downloader.cc b/extensions/browser/updater/extension_downloader.cc index d2c303f..621a7ee 100644 --- a/extensions/browser/updater/extension_downloader.cc +++ b/extensions/browser/updater/extension_downloader.cc
@@ -116,8 +116,11 @@ int response_code) { // Retry if the response code is a server error, or the request failed because // of network errors as opposed to file errors. - return ((response_code >= 500 && status.is_success()) || - status.status() == net::URLRequestStatus::FAILED); + return (response_code >= 500 && status.is_success()) || + status.status() == net::URLRequestStatus::FAILED || + // Note: URLRequestJob::OnSuspend() results in a canceled status; if + // the request is suspended, we should retry. + status.status() == net::URLRequestStatus::CANCELED; } // This parses and updates a URL query such that the value of the |authuser|
diff --git a/extensions/shell/BUILD.gn b/extensions/shell/BUILD.gn index 628af4a..81fa7f8 100644 --- a/extensions/shell/BUILD.gn +++ b/extensions/shell/BUILD.gn
@@ -267,7 +267,6 @@ ] deps = [ ":app_shell_framework_bundle_data", - "//build/config:exe_and_shlib_deps", "//content/public/app:both", "//extensions:shell_and_test_pak", ] @@ -287,7 +286,6 @@ deps = [ ":app_shell_lib", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//content/public/app:both", "//extensions:shell_and_test_pak", @@ -454,7 +452,6 @@ ] deps = [ ":app_shell_framework+link", - "//build/config:exe_and_shlib_deps", "//content/public/app:both", ] ldflags = [
diff --git a/gin/BUILD.gn b/gin/BUILD.gn index 89fe7a5..5670afc 100644 --- a/gin/BUILD.gn +++ b/gin/BUILD.gn
@@ -103,7 +103,6 @@ ":gin", "//base", "//base:i18n", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//v8", ]
diff --git a/google_apis/gcm/BUILD.gn b/google_apis/gcm/BUILD.gn index 0a6ccbb..d5f2361c6 100644 --- a/google_apis/gcm/BUILD.gn +++ b/google_apis/gcm/BUILD.gn
@@ -124,7 +124,6 @@ ":gcm", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//net", "//net:test_support",
diff --git a/gpu/BUILD.gn b/gpu/BUILD.gn index da9f4e8..e05c569 100644 --- a/gpu/BUILD.gn +++ b/gpu/BUILD.gn
@@ -77,7 +77,6 @@ deps = [ ":gpu", "//base", - "//build/config:exe_and_shlib_deps", "//gpu/command_buffer/client:gles2_c_lib", "//gpu/command_buffer/client:gles2_cmd_helper", "//gpu/command_buffer/client:gles2_implementation", @@ -171,6 +170,7 @@ "//gpu/skia_bindings:skia_bindings", "//testing/gmock", "//testing/gtest", + "//ui/gfx:test_support", "//ui/gl:gl_unittest_utils", "//ui/gl:test_support", ]
diff --git a/gpu/gles2_conform_support/BUILD.gn b/gpu/gles2_conform_support/BUILD.gn index ca9e1a3d..e3eaff8 100644 --- a/gpu/gles2_conform_support/BUILD.gn +++ b/gpu/gles2_conform_support/BUILD.gn
@@ -54,7 +54,6 @@ deps = [ "//base", "//base/third_party/dynamic_annotations", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//gpu/command_buffer/client:gles2_c_lib_nocheck", "//gpu/gles2_conform_support/egl", @@ -401,7 +400,6 @@ ] deps = [ ":generate_gles2_conform_embedded_data", - "//build/config:exe_and_shlib_deps", "//gpu/command_buffer/client:gles2_c_lib_nocheck", "//gpu/gles2_conform_support/egl", "//gpu/gles2_conform_support/native:windowless",
diff --git a/gpu/tools/compositor_model_bench/BUILD.gn b/gpu/tools/compositor_model_bench/BUILD.gn index b6e0e95..1154469 100644 --- a/gpu/tools/compositor_model_bench/BUILD.gn +++ b/gpu/tools/compositor_model_bench/BUILD.gn
@@ -26,7 +26,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//ui/gl", "//ui/gl/init", ]
diff --git a/headless/BUILD.gn b/headless/BUILD.gn index 476d50d..ed16269d 100644 --- a/headless/BUILD.gn +++ b/headless/BUILD.gn
@@ -991,7 +991,6 @@ deps = [ ":headless_shell_lib", - "//build/config:exe_and_shlib_deps", ] if (!headless_use_embedded_resources) { @@ -1021,7 +1020,6 @@ deps = [ ":headless_shell_lib", - "//build/config:exe_and_shlib_deps", "//skia", # we need this to override font render hinting in headless build ] }
diff --git a/headless/lib/browser/headless_browser_context_impl.cc b/headless/lib/browser/headless_browser_context_impl.cc index cb38ee1..770cac2 100644 --- a/headless/lib/browser/headless_browser_context_impl.cc +++ b/headless/lib/browser/headless_browser_context_impl.cc
@@ -384,14 +384,6 @@ observers_.RemoveObserver(obs); } -void HeadlessBrowserContextImpl::NotifyChildContentsCreated( - HeadlessWebContentsImpl* parent, - HeadlessWebContentsImpl* child) { - base::AutoLock lock(observers_lock_); - for (auto& observer : observers_) - observer.OnChildContentsCreated(parent, child); -} - void HeadlessBrowserContextImpl::NotifyUrlRequestFailed( net::URLRequest* request, int net_error,
diff --git a/headless/lib/browser/headless_browser_context_impl.h b/headless/lib/browser/headless_browser_context_impl.h index 8df21fa..48ecb20 100644 --- a/headless/lib/browser/headless_browser_context_impl.h +++ b/headless/lib/browser/headless_browser_context_impl.h
@@ -112,9 +112,6 @@ void SetRemoveHeaders(bool should_remove_headers); bool ShouldRemoveHeaders() const; - void NotifyChildContentsCreated(HeadlessWebContentsImpl* parent, - HeadlessWebContentsImpl* child); - // This will be called on the IO thread. void NotifyUrlRequestFailed(net::URLRequest* request, int net_error,
diff --git a/headless/lib/browser/headless_web_contents_impl.cc b/headless/lib/browser/headless_web_contents_impl.cc index 51d5010e..c04a7d4 100644 --- a/headless/lib/browser/headless_web_contents_impl.cc +++ b/headless/lib/browser/headless_web_contents_impl.cc
@@ -112,8 +112,6 @@ HeadlessWebContentsImpl* raw_child_contents = child_contents.get(); headless_web_contents_->browser_context()->RegisterWebContents( std::move(child_contents)); - headless_web_contents_->browser_context()->NotifyChildContentsCreated( - headless_web_contents_, raw_child_contents); const gfx::Rect default_rect( headless_web_contents_->browser()->options()->window_size); @@ -140,8 +138,6 @@ ->CreateWebContentsBuilder() .SetWindowSize(source->GetContainerBounds().size()) .Build()); - headless_web_contents_->browser_context()->NotifyChildContentsCreated( - headless_web_contents_, child_contents); target = child_contents->web_contents(); break; }
diff --git a/headless/lib/headless_web_contents_browsertest.cc b/headless/lib/headless_web_contents_browsertest.cc index 9b0b059..c2d3ab4b 100644 --- a/headless/lib/headless_web_contents_browsertest.cc +++ b/headless/lib/headless_web_contents_browsertest.cc
@@ -9,6 +9,7 @@ #include "base/base64.h" #include "base/command_line.h" #include "base/json/json_writer.h" +#include "base/logging.h" #include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "base/test/scoped_feature_list.h" @@ -57,25 +58,6 @@ using testing::UnorderedElementsAreArray; namespace headless { - -#define EXPECT_CHILD_CONTENTS_CREATED(obs) \ - EXPECT_CALL((obs), OnChildContentsCreated(::testing::_, ::testing::_)) \ - .WillOnce(::testing::DoAll(::testing::SaveArg<0>(&((obs).last_parent)), \ - ::testing::SaveArg<1>(&((obs).last_child)))) - -class MockHeadlessBrowserContextObserver - : public HeadlessBrowserContext::Observer { - public: - MOCK_METHOD2(OnChildContentsCreated, - void(HeadlessWebContents*, HeadlessWebContents*)); - - MockHeadlessBrowserContextObserver() = default; - ~MockHeadlessBrowserContextObserver() override = default; - - HeadlessWebContents* last_parent; - HeadlessWebContents* last_child; -}; - class HeadlessWebContentsTest : public HeadlessBrowserTest {}; IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) { @@ -100,10 +82,6 @@ HeadlessBrowserContext* browser_context = browser()->CreateBrowserContextBuilder().Build(); - MockHeadlessBrowserContextObserver observer; - browser_context->AddObserver(&observer); - EXPECT_CHILD_CONTENTS_CREATED(observer); - HeadlessWebContents* web_contents = browser_context->CreateWebContentsBuilder() .SetInitialURL(embedded_test_server()->GetURL("/window_open.html")) @@ -112,8 +90,16 @@ EXPECT_EQ(2u, browser_context->GetAllWebContents().size()); - auto* parent = HeadlessWebContentsImpl::From(observer.last_parent); - auto* child = HeadlessWebContentsImpl::From(observer.last_child); + HeadlessWebContentsImpl* child = nullptr; + HeadlessWebContentsImpl* parent = nullptr; + for (HeadlessWebContents* c : browser_context->GetAllWebContents()) { + HeadlessWebContentsImpl* impl = HeadlessWebContentsImpl::From(c); + if (impl->window_id() == 1) + parent = impl; + else if (impl->window_id() == 2) + child = impl; + } + EXPECT_NE(nullptr, parent); EXPECT_NE(nullptr, child); EXPECT_NE(parent, child); @@ -131,8 +117,6 @@ EXPECT_EQ(expected_bounds.size(), child->web_contents()->GetContainerBounds().size()); #endif // !defined(OS_MACOSX) - - browser_context->RemoveObserver(&observer); } IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, @@ -440,10 +424,6 @@ HeadlessBrowserContext* browser_context = browser()->CreateBrowserContextBuilder().Build(); - MockHeadlessBrowserContextObserver observer; - browser_context->AddObserver(&observer); - EXPECT_CHILD_CONTENTS_CREATED(observer); - HeadlessWebContents* web_contents = browser_context->CreateWebContentsBuilder() .SetInitialURL(embedded_test_server()->GetURL("/link.html")) @@ -460,7 +440,6 @@ // Check that we have a new tab. EXPECT_EQ(2u, browser_context->GetAllWebContents().size()); - browser_context->RemoveObserver(&observer); } namespace {
diff --git a/headless/public/headless_browser_context.h b/headless/public/headless_browser_context.h index 3665efb..8b95773 100644 --- a/headless/public/headless_browser_context.h +++ b/headless/public/headless_browser_context.h
@@ -88,9 +88,6 @@ class HEADLESS_EXPORT HeadlessBrowserContext::Observer { public: - // This will be delivered on the UI thread. - virtual void OnChildContentsCreated(HeadlessWebContents* parent, - HeadlessWebContents* child) {} // Indicates that a network request failed or was canceled. This will be // delivered on the IO thread.
diff --git a/infra/config/branch/cq.cfg b/infra/config/branch/cq.cfg index 76c609ba..3dd85907 100644 --- a/infra/config/branch/cq.cfg +++ b/infra/config/branch/cq.cfg
@@ -62,7 +62,7 @@ builders { name: "linux-chromeos-rel" } builders { name: "linux-jumbo-rel" - experiment_percentage: 50 + experiment_percentage: 100 } builders { name: "linux-ozone-rel" } builders { name: "linux_chromium_compile_dbg_ng" }
diff --git a/infra/config/global/cr-buildbucket.cfg b/infra/config/global/cr-buildbucket.cfg index 0d26b06..06a2633 100644 --- a/infra/config/global/cr-buildbucket.cfg +++ b/infra/config/global/cr-buildbucket.cfg
@@ -1818,7 +1818,6 @@ builders { name: "Linux x64" dimensions: "os:Ubuntu-14.04" - dimensions: "cores:32" mixins: "chromium-ci" } builders { @@ -1970,7 +1969,7 @@ } builders { name: "Mac" - dimensions: "os:Mac-10.12.6" + dimensions: "os:Mac-10.13" mixins: "chromium-ci" } builders { @@ -2362,7 +2361,13 @@ properties_j: "runhooks:true" } } - builders { mixins: "linux-try" name: "closure_compilation" } + builders { + mixins: "linux-try" + name: "closure_compilation" + recipe { + name: "closure_compilation" + } + } builders { mixins: "linux-try" name: "fuchsia_arm64" } builders { mixins: "linux-try" name: "fuchsia_arm64_cast_audio" } builders { mixins: "linux-try" name: "fuchsia_x64" } @@ -2417,10 +2422,22 @@ builders { mixins: "linux-try" name: "linux_chromium_compile_dbg_32_ng" } builders { mixins: "linux-try" name: "linux_chromium_compile_dbg_ng" } builders { mixins: "linux-try" name: "linux_chromium_compile_rel_ng" } - builders { mixins: "linux-try" name: "linux_chromium_component_updater" } + builders { + mixins: "linux-try" + name: "linux_chromium_component_updater" + recipe { + name: "findit/chromium/update_components" + } + } builders { mixins: "linux-try" name: "linux_chromium_dbg_32_ng" } builders { mixins: "linux-try" name: "linux_chromium_dbg_ng" } - builders { mixins: "linux-try" name: "linux_chromium_gn_upload" } + builders { + mixins: "linux-try" + name: "linux_chromium_gn_upload" + recipe { + name: "chromium_gn_upload" + } + } builders { mixins: "linux-try" name: "linux_chromium_headless_rel" } builders { mixins: "linux-try" name: "linux_chromium_msan_rel_ng" } builders { mixins: "linux-try" name: "linux_chromium_msan_variable" } @@ -2452,12 +2469,29 @@ builders { mixins: "linux-try" name: "linux_layout_tests_slimming_paint_v2" } builders { mixins: "linux-try" name: "linux_mojo" } builders { mixins: "linux-try" name: "linux_mojo_chromeos" } - builders { mixins: "linux-try" name: "linux_nacl_sdk" } - builders { mixins: "linux-try" name: "linux_nacl_sdk_build" } + builders { + mixins: "linux-try" + name: "linux_nacl_sdk" + recipe { + name: "nacl/sdk" + } + } + builders { + mixins: "linux-try" + name: "linux_nacl_sdk_build" + recipe { + name: "nacl/sdk_build" + } + } builders { mixins: "linux-optional-gpu-try" name: "linux_optional_gpu_tests_rel" } builders { mixins: "linux-try" name: "linux_site_isolation" } - builders { mixins: "linux-try" name: "linux_upload_clang" } - + builders { + mixins: "linux-try" + name: "linux_upload_clang" + recipe { + name: "chromium_upload_clang" + } + } builders { mixins: "ios-try" name: "ios-device" } builders { mixins: "ios-try" name: "ios-device-xcode-clang" } # TODO(crbug.com/836626): delete dimensions: "cores:" when bug is fixed.
diff --git a/infra/config/global/luci-milo.cfg b/infra/config/global/luci-milo.cfg index e4fe314b..dc0ae818 100644 --- a/infra/config/global/luci-milo.cfg +++ b/infra/config/global/luci-milo.cfg
@@ -1448,123 +1448,6 @@ ref: "refs/heads/master" manifest_name: "REVISION" builders { - name: "buildbot/chromium.lkgr/Win ASan Release" - name: "buildbucket/luci.chromium.ci/Win ASan Release" - category: "win asan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/Win ASan Release Media" - name: "buildbucket/luci.chromium.ci/Win ASan Release Media" - category: "win asan" - short_name: "med" - } - builders { - name: "buildbot/chromium.lkgr/Mac ASAN Debug" - name: "buildbucket/luci.chromium.ci/Mac ASAN Debug" - category: "mac asan" - short_name: "dbg" - } - builders { - name: "buildbot/chromium.lkgr/Mac ASAN Release" - name: "buildbucket/luci.chromium.ci/Mac ASAN Release" - category: "mac asan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/Mac ASAN Release Media" - name: "buildbucket/luci.chromium.ci/Mac ASAN Release Media" - category: "mac asan" - short_name: "med" - } - builders { - name: "buildbot/chromium.lkgr/ChromiumOS ASAN Release" - name: "buildbucket/luci.chromium.ci/ChromiumOS ASAN Release" - short_name: "cro" - } - builders { - name: "buildbot/chromium.lkgr/ASAN Debug" - name: "buildbucket/luci.chromium.ci/ASAN Debug" - category: "linux asan" - short_name: "dbg" - } - builders { - name: "buildbot/chromium.lkgr/ASAN Release" - name: "buildbucket/luci.chromium.ci/ASAN Release" - category: "linux asan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/ASAN Release Media" - name: "buildbucket/luci.chromium.ci/ASAN Release Media" - category: "linux asan" - short_name: "med" - } - builders { - name: "buildbot/chromium.lkgr/ASan Debug (32-bit x86 with V8-ARM)" - name: "buildbucket/luci.chromium.ci/ASan Debug (32-bit x86 with V8-ARM)" - category: "linux asan|x64 v8-ARM" - short_name: "dbg" - } - builders { - name: "buildbot/chromium.lkgr/ASan Release (32-bit x86 with V8-ARM)" - name: "buildbucket/luci.chromium.ci/ASan Release (32-bit x86 with V8-ARM)" - category: "linux asan|x64 v8-ARM" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/ASan Release Media (32-bit x86 with V8-ARM)" - name: "buildbucket/luci.chromium.ci/ASan Release Media (32-bit x86 with V8-ARM)" - category: "linux asan|x64 v8-ARM" - short_name: "med" - } - builders { - name: "buildbot/chromium.lkgr/MSAN Release (chained origins)" - name: "buildbucket/luci.chromium.ci/MSAN Release (chained origins)" - category: "linux msan" - short_name: "org" - } - builders { - name: "buildbot/chromium.lkgr/MSAN Release (no origins)" - name: "buildbucket/luci.chromium.ci/MSAN Release (no origins)" - category: "linux msan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/TSAN Debug" - name: "buildbucket/luci.chromium.ci/TSAN Debug" - category: "linux tsan" - short_name: "dbg" - } - builders { - name: "buildbot/chromium.lkgr/TSAN Release" - name: "buildbucket/luci.chromium.ci/TSAN Release" - category: "linux tsan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/UBSan Release" - name: "buildbucket/luci.chromium.ci/UBSan Release" - category: "linux UBSan" - short_name: "rel" - } - builders { - name: "buildbot/chromium.lkgr/UBSan vptr Release" - name: "buildbucket/luci.chromium.ci/UBSan vptr Release" - category: "linux UBSan" - short_name: "vpt" - } -} - -consoles { - header_id: "chromium" - include_experimental_builds: true - id: "luci.chromium.lkgr" - name: "luci.chromium.lkgr" - repo_url: "https://chromium.googlesource.com/chromium/src" - ref: "refs/heads/master" - manifest_name: "REVISION" - builders { name: "buildbucket/luci.chromium.ci/Win ASan Release" category: "win asan" short_name: "rel"
diff --git a/ios/chrome/browser/metrics/external_url_tab_usage_recorder_egtest.mm b/ios/chrome/browser/metrics/external_url_tab_usage_recorder_egtest.mm index e6090d8..0785854 100644 --- a/ios/chrome/browser/metrics/external_url_tab_usage_recorder_egtest.mm +++ b/ios/chrome/browser/metrics/external_url_tab_usage_recorder_egtest.mm
@@ -29,9 +29,15 @@ @implementation ExternalURLTabUsageRecorderTestCase +// TODO(crbug.com/847948): This test is faling on devices. +#if TARGET_IPHONE_SIMULATOR +#define MAYBE_testEvictedTabReloadFailure testEvictedTabReloadFailure +#else +#define MAYBE_testEvictedTabReloadFailure DISABLED_testEvictedTabReloadFailure +#endif // Verify correct recording of metrics when the reloading of an evicted tab // fails. -- (void)testEvictedTabReloadFailure { +- (void)MAYBE_testEvictedTabReloadFailure { web::test::SetUpFileBasedHttpServer(); chrome_test_util::HistogramTester histogramTester; FailureBlock failureBlock = ^(NSString* error) {
diff --git a/ios/chrome/browser/translate/translate_egtest.mm b/ios/chrome/browser/translate/translate_egtest.mm index 45852ea8..d385a99c 100644 --- a/ios/chrome/browser/translate/translate_egtest.mm +++ b/ios/chrome/browser/translate/translate_egtest.mm
@@ -471,8 +471,16 @@ [self assertLanguageDetails:expectedLanguageDetails]; } +// TODO(crbug.com/847948): This test is faling on devices. +#if TARGET_IPHONE_SIMULATOR +#define MAYBE_testLanguageDetectionHttpContentLanguage \ + testLanguageDetectionHttpContentLanguage +#else +#define MAYBE_testLanguageDetectionHttpContentLanguage \ + DISABLED_testLanguageDetectionHttpContentLanguage +#endif // Tests that language in http content is detected. -- (void)testLanguageDetectionHttpContentLanguage { +- (void)MAYBE_testLanguageDetectionHttpContentLanguage { // Start the HTTP server. std::unique_ptr<web::DataResponseProvider> provider(new TestResponseProvider); web::test::SetUpHttpServer(std::move(provider));
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm index d225290d..98df455 100644 --- a/ios/chrome/browser/ui/browser_view_controller.mm +++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -791,6 +791,8 @@ - (BOOL)isTabScrolledToTop:(Tab*)tab; // Returns the footer view if one exists (e.g. the voice search bar). - (UIView*)footerView; +// Returns web contents frame without including primary toolbar. +- (CGRect)visibleFrameForTab:(Tab*)tab; // Returns the header height needed for |tab|. - (CGFloat)headerHeightForTab:(Tab*)tab; // Sets the frame for the headers. @@ -2578,6 +2580,12 @@ } } +- (CGRect)visibleFrameForTab:(Tab*)tab { + UIEdgeInsets headerInset = UIEdgeInsetsMake( + [self nativeContentHeaderHeightForWebState:tab.webState], 0, 0, 0); + return UIEdgeInsetsInsetRect(tab.view.bounds, headerInset); +} + - (CGFloat)headerHeightForTab:(Tab*)tab { id nativeController = [self nativeControllerForTab:tab]; if ([nativeController conformsToProtocol:@protocol(ToolbarOwner)] && @@ -2935,13 +2943,10 @@ selectText:(BOOL)selectText shouldFocus:(BOOL)shouldFocus { DCHECK(_findBarController); - Tab* tab = [_model currentTab]; - DCHECK(tab); - CRWWebController* webController = tab.webController; - CGRect referenceFrame = CGRectZero; if ([self canShowTabStrip]) { - referenceFrame = webController.visibleFrame; + DCHECK(_model.currentTab); + referenceFrame = [self visibleFrameForTab:_model.currentTab]; referenceFrame.origin.y -= kIPadFindBarOverlap; } else { referenceFrame = self.contentArea.frame; @@ -3487,10 +3492,10 @@ return CGRectGetMaxY(self.view.frame); } else if (IsIPadIdiom()) { // The infobars on iPad are display at the top of a tab. - return CGRectGetMinY([[_model currentTab].webController visibleFrame]); + return CGRectGetMinY([self visibleFrameForTab:_model.currentTab]); } else { // The infobars on iPhone are displayed at the bottom of a tab. - CGRect visibleFrame = [[_model currentTab].webController visibleFrame]; + CGRect visibleFrame = [self visibleFrameForTab:_model.currentTab]; return CGRectGetMaxY(visibleFrame) - CGRectGetHeight(_infoBarContainer->view().frame); } @@ -3498,7 +3503,7 @@ // Returns a vertical download manager offset relative to the tab content. - (CGFloat)downloadManagerOverlayYOffsetForTab:(Tab*)tab { - return CGRectGetMaxY([tab.webController visibleFrame]) - + return CGRectGetMaxY([self visibleFrameForTab:tab]) - CGRectGetHeight(_downloadManagerCoordinator.viewController.view.frame); } @@ -3521,7 +3526,7 @@ return CGRectGetMaxY(self.view.frame); } else { // The voice search bar on iPhone is displayed at the bottom of a tab. - CGRect visibleFrame = [[_model currentTab].webController visibleFrame]; + CGRect visibleFrame = [self visibleFrameForTab:_model.currentTab]; return CGRectGetMaxY(visibleFrame) - kVoiceSearchBarHeight; } }
diff --git a/ios/showcase/BUILD.gn b/ios/showcase/BUILD.gn index 0830741..8958ef1 100644 --- a/ios/showcase/BUILD.gn +++ b/ios/showcase/BUILD.gn
@@ -13,10 +13,6 @@ output_name = "Showcase" deps = [ ":features", - - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", "//ios/showcase/core:main", ] bundle_deps = [ "//ios/showcase/core/resources" ] @@ -58,10 +54,6 @@ "//ios/showcase/core:eg_tests", "//ios/showcase/payments:eg_tests", "//ios/showcase/text_badge_view:eg_tests", - - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", ] bundle_deps = [ "//ios/showcase/core/resources" ] assert_no_deps = ios_assert_no_deps
diff --git a/ios/web/shell/BUILD.gn b/ios/web/shell/BUILD.gn index 856f739..bbcfb32 100644 --- a/ios/web/shell/BUILD.gn +++ b/ios/web/shell/BUILD.gn
@@ -14,10 +14,6 @@ deps = [ ":shell", - - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", ] configs += [ "//build/config/compiler:enable_arc" ]
diff --git a/ios/web/shell/test/BUILD.gn b/ios/web/shell/test/BUILD.gn index 324d20d..255ad44 100644 --- a/ios/web/shell/test/BUILD.gn +++ b/ios/web/shell/test/BUILD.gn
@@ -43,10 +43,6 @@ "//services/test/echo/public/mojom", "//services/test/user_id/public/mojom", "//url", - - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", ] bundle_deps = [ ":bundle" ]
diff --git a/ios/web/web_state/ui/crw_web_controller.h b/ios/web/web_state/ui/crw_web_controller.h index 23934b09..b42bc1c 100644 --- a/ios/web/web_state/ui/crw_web_controller.h +++ b/ios/web/web_state/ui/crw_web_controller.h
@@ -204,10 +204,6 @@ // Removes |toolbar| from the web view. - (void)removeToolbarViewFromWebView:(UIView*)toolbarView; -// Returns the always-visible frame, not including the part that could be -// covered by the toolbar. -- (CGRect)visibleFrame; - - (CRWJSInjectionReceiver*)jsInjectionReceiver; // Returns the native controller (if any) current mananging the content.
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index 78c7655..00eb177 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -747,8 +747,6 @@ - (BOOL)isMainFrameNavigationAction:(WKNavigationAction*)action; // Returns whether external URL navigation action should be opened. - (BOOL)shouldOpenExternalURLForNavigationAction:(WKNavigationAction*)action; -// Returns the header height. -- (CGFloat)headerHeight; // Updates SSL status for the current navigation item based on the information // provided by web view. - (void)updateSSLStatusForCurrentNavigationItem; @@ -2218,7 +2216,7 @@ - (CGFloat)nativeContentHeaderHeightForContainerView: (CRWWebControllerContainerView*)containerView { - return [self headerHeight]; + return [_nativeProvider nativeContentHeaderHeightForWebState:self.webState]; } #pragma mark - @@ -3614,14 +3612,6 @@ #pragma mark - #pragma mark Fullscreen -- (CGRect)visibleFrame { - CGRect frame = [_containerView bounds]; - CGFloat headerHeight = [self headerHeight]; - frame.origin.y = headerHeight; - frame.size.height -= headerHeight; - return frame; -} - - (void)optOutScrollsToTopForSubviews { NSMutableArray* stack = [NSMutableArray arrayWithArray:[self.webScrollView subviews]]; @@ -3688,10 +3678,6 @@ [_delegate webController:self shouldOpenExternalURL:requestURL]; } -- (CGFloat)headerHeight { - return [_nativeProvider nativeContentHeaderHeightForWebState:self.webState]; -} - - (void)updateSSLStatusForCurrentNavigationItem { if (_isBeingDestroyed) { return;
diff --git a/ios/web_view/shell/test/BUILD.gn b/ios/web_view/shell/test/BUILD.gn index 1966b173..465ad07 100644 --- a/ios/web_view/shell/test/BUILD.gn +++ b/ios/web_view/shell/test/BUILD.gn
@@ -25,10 +25,6 @@ "//ios/web_view/shell:shell", "//ios/web_view/test:test_support", "//net:test_support", - - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", ] configs += [ "//build/config/compiler:enable_arc" ]
diff --git a/mash/runner/BUILD.gn b/mash/runner/BUILD.gn index 4a823fe..92b79ef 100644 --- a/mash/runner/BUILD.gn +++ b/mash/runner/BUILD.gn
@@ -13,7 +13,6 @@ "//base", "//base:i18n", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//mojo/edk", "//services/service_manager", "//services/service_manager/runner:init",
diff --git a/media/cast/BUILD.gn b/media/cast/BUILD.gn index 07122a4..e283cb5c 100644 --- a/media/cast/BUILD.gn +++ b/media/cast/BUILD.gn
@@ -411,7 +411,6 @@ ":receiver", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//media:test_support", "//net", @@ -442,7 +441,6 @@ ":sender", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//media", ] @@ -469,7 +467,6 @@ ":test_support", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//media:test_support", ] @@ -483,7 +480,6 @@ deps = [ ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//media", ] @@ -497,7 +493,6 @@ deps = [ ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//media", ] @@ -511,7 +506,6 @@ deps = [ ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//net", ]
diff --git a/media/cdm/library_cdm/clear_key_cdm/BUILD.gn b/media/cdm/library_cdm/clear_key_cdm/BUILD.gn index c6fe179..932e2bd 100644 --- a/media/cdm/library_cdm/clear_key_cdm/BUILD.gn +++ b/media/cdm/library_cdm/clear_key_cdm/BUILD.gn
@@ -14,8 +14,8 @@ "cdm_file_adapter.h", "cdm_file_io_test.cc", "cdm_file_io_test.h", - "cdm_proxy_test.cc", - "cdm_proxy_test.h", + "cdm_proxy_handler.cc", + "cdm_proxy_handler.h", "cdm_video_decoder.cc", "cdm_video_decoder.h", "clear_key_cdm.cc", @@ -32,7 +32,6 @@ deps = [ ":cdm_proxy_common", "//base", - "//build/config:exe_and_shlib_deps", "//media", # For media::AudioTimestampHelper "//media:shared_memory_support", # For media::AudioBus. "//media/cdm:cdm_api", # For content_decryption_module.h
diff --git a/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc b/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc similarity index 60% rename from media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc rename to media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc index 37675b2d..ebcb163a 100644 --- a/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.cc +++ b/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h" +#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h" #include <stdint.h> #include <algorithm> @@ -14,48 +14,48 @@ namespace media { -CdmProxyTest::CdmProxyTest(CdmHostProxy* cdm_host_proxy) +CdmProxyHandler::CdmProxyHandler(CdmHostProxy* cdm_host_proxy) : cdm_host_proxy_(cdm_host_proxy) {} -CdmProxyTest::~CdmProxyTest() {} +CdmProxyHandler::~CdmProxyHandler() {} -void CdmProxyTest::Run(CompletionCB completion_cb) { +void CdmProxyHandler::Initialize(InitCB init_cb) { DVLOG(1) << __func__; - completion_cb_ = std::move(completion_cb); + init_cb_ = std::move(init_cb); cdm_proxy_ = cdm_host_proxy_->RequestCdmProxy(this); if (!cdm_proxy_) { - OnTestComplete(false); + FinishInitialization(false); return; } cdm_proxy_->Initialize(); } -void CdmProxyTest::SetKey(const std::vector<uint8_t>& response) { +void CdmProxyHandler::SetKey(const std::vector<uint8_t>& response) { cdm_proxy_->SetKey(crypto_session_id_, nullptr, 0, response.data(), response.size()); } -void CdmProxyTest::OnTestComplete(bool success) { +void CdmProxyHandler::FinishInitialization(bool success) { DVLOG(1) << __func__ << ": success = " << success; - std::move(completion_cb_).Run(success); + std::move(init_cb_).Run(success); } -void CdmProxyTest::OnInitialized(Status status, - Protocol protocol, - uint32_t crypto_session_id) { +void CdmProxyHandler::OnInitialized(Status status, + Protocol protocol, + uint32_t crypto_session_id) { DVLOG(1) << __func__ << ": status = " << status; if (status != Status::kOk || crypto_session_id != kClearKeyCdmProxyCryptoSessionId) { - OnTestComplete(false); + FinishInitialization(false); return; } // Only one CdmProxy can be created during the lifetime of the CDM instance. if (cdm_host_proxy_->RequestCdmProxy(this)) { - OnTestComplete(false); + FinishInitialization(false); return; } @@ -64,15 +64,15 @@ kClearKeyCdmProxyInputData.size(), 0); } -void CdmProxyTest::OnProcessed(Status status, - const uint8_t* output_data, - uint32_t output_data_size) { +void CdmProxyHandler::OnProcessed(Status status, + const uint8_t* output_data, + uint32_t output_data_size) { DVLOG(1) << __func__ << ": status = " << status; if (status != Status::kOk || !std::equal(output_data, output_data + output_data_size, kClearKeyCdmProxyOutputData.begin())) { - OnTestComplete(false); + FinishInitialization(false); return; } @@ -80,21 +80,21 @@ kClearKeyCdmProxyInputData.size()); } -void CdmProxyTest::OnMediaCryptoSessionCreated(Status status, - uint32_t crypto_session_id, - uint64_t output_data) { +void CdmProxyHandler::OnMediaCryptoSessionCreated(Status status, + uint32_t crypto_session_id, + uint64_t output_data) { DVLOG(1) << __func__ << ": status = " << status; if (status != Status::kOk || crypto_session_id != kClearKeyCdmProxyMediaCryptoSessionId) { - OnTestComplete(false); + FinishInitialization(false); return; } - OnTestComplete(true); + FinishInitialization(true); } -void CdmProxyTest::NotifyHardwareReset() { +void CdmProxyHandler::NotifyHardwareReset() { DVLOG(1) << __func__; NOTREACHED(); }
diff --git a/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h b/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h new file mode 100644 index 0000000..dd5badb9 --- /dev/null +++ b/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h
@@ -0,0 +1,56 @@ +// 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 MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_ +#define MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_ + +#include "base/callback.h" +#include "base/macros.h" +#include "media/cdm/api/content_decryption_module.h" + +namespace media { + +class CdmHostProxy; + +class CdmProxyHandler : public cdm::CdmProxyClient { + public: + using InitCB = base::OnceCallback<void(bool success)>; + + explicit CdmProxyHandler(CdmHostProxy* cdm_host_proxy); + ~CdmProxyHandler() override; + + // Initializes the CdmProxyHandler and returns the result through |init_cb|. + // This will request and initialize the CdmProxy, create media crypto session + // and do some trivial procesing for better test coverage. + void Initialize(InitCB init_cb); + + // Push a response that contains a license to the CdmProxy. + void SetKey(const std::vector<uint8_t>& response); + + private: + void FinishInitialization(bool success); + + // cdm::CdmProxyClient implementation. + void OnInitialized(Status status, + Protocol protocol, + uint32_t crypto_session_id) final; + void OnProcessed(Status status, + const uint8_t* output_data, + uint32_t output_data_size) final; + void OnMediaCryptoSessionCreated(Status status, + uint32_t crypto_session_id, + uint64_t output_data) final; + void NotifyHardwareReset() final; + + CdmHostProxy* const cdm_host_proxy_ = nullptr; + InitCB init_cb_; + cdm::CdmProxy* cdm_proxy_ = nullptr; + uint32_t crypto_session_id_ = 0u; + + DISALLOW_COPY_AND_ASSIGN(CdmProxyHandler); +}; + +} // namespace media + +#endif // MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_HANDLER_H_
diff --git a/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h b/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h deleted file mode 100644 index c7b8f73c..0000000 --- a/media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h +++ /dev/null
@@ -1,53 +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 MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_ -#define MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_ - -#include "base/callback.h" -#include "base/macros.h" -#include "media/cdm/api/content_decryption_module.h" - -namespace media { - -class CdmHostProxy; - -class CdmProxyTest : public cdm::CdmProxyClient { - public: - using CompletionCB = base::OnceCallback<void(bool success)>; - - explicit CdmProxyTest(CdmHostProxy* cdm_host_proxy); - ~CdmProxyTest() override; - - // Runs the test and returns the test result through |completion_cb|. - void Run(CompletionCB completion_cb); - - void SetKey(const std::vector<uint8_t>& response); - - private: - void OnTestComplete(bool success); - - // cdm::CdmProxyClient implementation. - void OnInitialized(Status status, - Protocol protocol, - uint32_t crypto_session_id) final; - void OnProcessed(Status status, - const uint8_t* output_data, - uint32_t output_data_size) final; - void OnMediaCryptoSessionCreated(Status status, - uint32_t crypto_session_id, - uint64_t output_data) final; - void NotifyHardwareReset() final; - - CdmHostProxy* const cdm_host_proxy_ = nullptr; - CompletionCB completion_cb_; - cdm::CdmProxy* cdm_proxy_ = nullptr; - uint32_t crypto_session_id_ = 0u; - - DISALLOW_COPY_AND_ASSIGN(CdmProxyTest); -}; - -} // namespace media - -#endif // MEDIA_CDM_LIBRARY_CDM_CLEAR_KEY_CDM_CDM_PROXY_TEST_H_
diff --git a/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc b/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc index da69505..f1b7cdb 100644 --- a/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc +++ b/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.cc
@@ -27,7 +27,7 @@ #include "media/cdm/library_cdm/cdm_host_proxy.h" #include "media/cdm/library_cdm/cdm_host_proxy_impl.h" #include "media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.h" -#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_test.h" +#include "media/cdm/library_cdm/clear_key_cdm/cdm_proxy_handler.h" #include "media/cdm/library_cdm/clear_key_cdm/cdm_video_decoder.h" #include "media/media_buildflags.h" @@ -65,8 +65,8 @@ "org.chromium.externalclearkey.storageidtest"; const char kExternalClearKeyDifferentGuidTestKeySystem[] = "org.chromium.externalclearkey.differentguid"; -const char kExternalClearKeyCdmProxyTestKeySystem[] = - "org.chromium.externalclearkey.cdmproxytest"; +const char kExternalClearKeyCdmProxyKeySystem[] = + "org.chromium.externalclearkey.cdmproxy"; const int64_t kSecondsPerMinute = 60; const int64_t kMsPerSecond = 1000; @@ -264,7 +264,7 @@ key_system_string != kExternalClearKeyVerifyCdmHostTestKeySystem && key_system_string != kExternalClearKeyStorageIdTestKeySystem && key_system_string != kExternalClearKeyDifferentGuidTestKeySystem && - key_system_string != kExternalClearKeyCdmProxyTestKeySystem) { + key_system_string != kExternalClearKeyCdmProxyKeySystem) { DVLOG(1) << "Unsupported key system:" << key_system_string; return nullptr; } @@ -416,9 +416,9 @@ allow_persistent_state_ = allow_persistent_state; // CdmProxy must be created during initialization time. OnInitialized() will - // be called in OnCdmProxyTestComplete(). - if (key_system_ == kExternalClearKeyCdmProxyTestKeySystem) { - StartCdmProxyTest(); + // be called in OnCdmProxyHandlerInitialized(). + if (key_system_ == kExternalClearKeyCdmProxyKeySystem) { + InitializeCdmProxyHandler(); return; } @@ -514,6 +514,15 @@ std::string web_session_str(session_id, session_id_length); std::vector<uint8_t> response_vector(response, response + response_size); + // Push the license to CdmProxy. + // TODO(xhwang): There's a potential race condition here where key status + // update is dispatched in the render process first, which triggers the + // resume-decryption-after-no-key logic, and by the time we try to decrypt + // again in the ClearKeyCdmProxy (GPU process), SetKey() hasn't been + // dispatched yet. To solve this, handle no-key in ClearKeyCdmProxy. + if (cdm_proxy_handler_) + cdm_proxy_handler_->SetKey(response_vector); + std::unique_ptr<media::SimpleCdmPromise> promise( new media::CdmCallbackPromise<>( base::Bind(&ClearKeyCdm::OnUpdateSuccess, base::Unretained(this), @@ -521,10 +530,6 @@ base::Bind(&ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); cdm_->UpdateSession(web_session_str, response_vector, std::move(promise)); - - // Also push the license to CdmProxy - if (cdm_proxy_test_) - cdm_proxy_test_->SetKey(response_vector); } void ClearKeyCdm::OnUpdateSuccess(uint32_t promise_id, @@ -651,7 +656,7 @@ DCHECK(encrypted_buffer.data); // When CdmProxy is used, the CDM cannot do any decryption or decoding. - if (key_system_ == kExternalClearKeyCdmProxyTestKeySystem) + if (key_system_ == kExternalClearKeyCdmProxyKeySystem) return cdm::kDecryptError; scoped_refptr<DecoderBuffer> buffer; @@ -689,7 +694,7 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder( const cdm::AudioDecoderConfig_2& audio_decoder_config) { if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem || - key_system_ == kExternalClearKeyCdmProxyTestKeySystem) { + key_system_ == kExternalClearKeyCdmProxyKeySystem) { return cdm::kInitializationError; } @@ -723,7 +728,7 @@ cdm::Status ClearKeyCdm::InitializeVideoDecoder( const cdm::VideoDecoderConfig_2& video_decoder_config) { if (key_system_ == kExternalClearKeyDecryptOnlyKeySystem || - key_system_ == kExternalClearKeyCdmProxyTestKeySystem) { + key_system_ == kExternalClearKeyCdmProxyKeySystem) { return cdm::kInitializationError; } @@ -1080,18 +1085,18 @@ cdm_host_proxy_->RequestStorageId(0); } -void ClearKeyCdm::StartCdmProxyTest() { +void ClearKeyCdm::InitializeCdmProxyHandler() { DVLOG(1) << __func__; - DCHECK(!cdm_proxy_test_); + DCHECK(!cdm_proxy_handler_); - cdm_proxy_test_.reset(new CdmProxyTest(cdm_host_proxy_.get())); - cdm_proxy_test_->Run(base::BindOnce(&ClearKeyCdm::OnCdmProxyTestComplete, - base::Unretained(this))); + cdm_proxy_handler_ = std::make_unique<CdmProxyHandler>(cdm_host_proxy_.get()); + cdm_proxy_handler_->Initialize(base::BindOnce( + &ClearKeyCdm::OnCdmProxyHandlerInitialized, base::Unretained(this))); } -void ClearKeyCdm::OnCdmProxyTestComplete(bool success) { +void ClearKeyCdm::OnCdmProxyHandlerInitialized(bool success) { DVLOG(1) << __func__; - DCHECK(cdm_proxy_test_); + DCHECK(cdm_proxy_handler_); cdm_host_proxy_->OnInitialized(success); }
diff --git a/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h b/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h index 59b3660..386f2b95 100644 --- a/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h +++ b/media/cdm/library_cdm/clear_key_cdm/clear_key_cdm.h
@@ -23,7 +23,7 @@ namespace media { class CdmHostProxy; -class CdmProxyTest; +class CdmProxyHandler; class CdmVideoDecoder; class DecoderBuffer; class FFmpegCdmAudioDecoder; @@ -159,8 +159,8 @@ void ReportVerifyCdmHostTestResult(); void StartStorageIdTest(); - void StartCdmProxyTest(); - void OnCdmProxyTestComplete(bool success); + void InitializeCdmProxyHandler(); + void OnCdmProxyHandlerInitialized(bool success); int host_interface_version_ = 0; @@ -188,7 +188,7 @@ std::unique_ptr<CdmVideoDecoder> video_decoder_; std::unique_ptr<FileIOTestRunner> file_io_test_runner_; - std::unique_ptr<CdmProxyTest> cdm_proxy_test_; + std::unique_ptr<CdmProxyHandler> cdm_proxy_handler_; bool is_running_output_protection_test_ = false; bool is_running_platform_verification_test_ = false;
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc index e09411ed..3310d5a 100644 --- a/media/filters/decrypting_audio_decoder.cc +++ b/media/filters/decrypting_audio_decoder.cc
@@ -141,10 +141,9 @@ void DecryptingAudioDecoder::Reset(const base::Closure& closure) { DVLOG(2) << "Reset() - state: " << state_; DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(state_ == kIdle || - state_ == kPendingDecode || - state_ == kWaitingForKey || - state_ == kDecodeFinished) << state_; + DCHECK(state_ == kIdle || state_ == kPendingDecode || + state_ == kWaitingForKey || state_ == kDecodeFinished) + << state_; DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. DCHECK(reset_cb_.is_null()); @@ -194,9 +193,8 @@ void DecryptingAudioDecoder::InitializeDecoder() { state_ = kPendingDecoderInit; decryptor_->InitializeAudioDecoder( - config_, - BindToCurrentLoop(base::Bind( - &DecryptingAudioDecoder::FinishInitialization, weak_this_))); + config_, BindToCurrentLoop(base::Bind( + &DecryptingAudioDecoder::FinishInitialization, weak_this_))); } void DecryptingAudioDecoder::FinishInitialization(bool success) { @@ -204,12 +202,12 @@ DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(state_ == kPendingDecoderInit) << state_; DCHECK(!init_cb_.is_null()); - DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. + DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. if (!success) { - MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() - << ": failed to init decoder on decryptor"; + MEDIA_LOG(DEBUG, media_log_) + << GetDisplayName() << ": failed to init decoder on decryptor"; base::ResetAndReturn(&init_cb_).Run(false); decryptor_ = NULL; state_ = kError; @@ -221,9 +219,8 @@ new AudioTimestampHelper(config_.samples_per_second())); decryptor_->RegisterNewKeyCB( - Decryptor::kAudio, - BindToCurrentLoop( - base::Bind(&DecryptingAudioDecoder::OnKeyAdded, weak_this_))); + Decryptor::kAudio, BindToCurrentLoop(base::Bind( + &DecryptingAudioDecoder::OnKeyAdded, weak_this_))); state_ = kIdle; base::ResetAndReturn(&init_cb_).Run(true); @@ -240,8 +237,8 @@ decryptor_->DecryptAndDecodeAudio( pending_buffer_to_decode_, - BindToCurrentLoop(base::Bind( - &DecryptingAudioDecoder::DeliverFrame, weak_this_, buffer_size))); + BindToCurrentLoop(base::Bind(&DecryptingAudioDecoder::DeliverFrame, + weak_this_, buffer_size))); } void DecryptingAudioDecoder::DeliverFrame( @@ -271,7 +268,7 @@ if (status == Decryptor::kError) { DVLOG(2) << "DeliverFrame() - kError"; MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": decode error"; - state_ = kDecodeFinished; // TODO add kError state + state_ = kDecodeFinished; // TODO add kError state base::ResetAndReturn(&decode_cb_).Run(DecodeStatus::DECODE_ERROR); return; } @@ -281,8 +278,8 @@ scoped_pending_buffer_to_decode->decrypt_config()->key_id(); std::string missing_key_id = base::HexEncode(key_id.data(), key_id.size()); DVLOG(1) << "DeliverFrame() - no key for key ID " << missing_key_id; - MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() << ": no key for key ID " - << missing_key_id; + MEDIA_LOG(DEBUG, media_log_) + << GetDisplayName() << ": no key for key ID " << missing_key_id; // Set |pending_buffer_to_decode_| back as we need to try decoding the // pending buffer again when new key is added to the decryptor. @@ -290,8 +287,8 @@ if (need_to_try_again_if_nokey_is_returned) { // The |state_| is still kPendingDecode. - MEDIA_LOG(INFO, media_log_) << GetDisplayName() - << ": key was added, resuming decode"; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": key was added, resuming decode"; DecodePendingBuffer(); return; } @@ -334,8 +331,8 @@ } if (state_ == kWaitingForKey) { - MEDIA_LOG(INFO, media_log_) << GetDisplayName() - << ": key added, resuming decode"; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": key added, resuming decode"; state_ = kPendingDecode; DecodePendingBuffer(); } @@ -352,8 +349,7 @@ void DecryptingAudioDecoder::ProcessDecodedFrames( const Decryptor::AudioFrames& frames) { for (Decryptor::AudioFrames::const_iterator iter = frames.begin(); - iter != frames.end(); - ++iter) { + iter != frames.end(); ++iter) { scoped_refptr<AudioBuffer> frame = *iter; DCHECK(!frame->end_of_stream()) << "EOS frame returned.";
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc index f68e048a..8a5b4621 100644 --- a/media/filters/decrypting_audio_decoder_unittest.cc +++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -111,16 +111,14 @@ InitializeAndExpectResult(config_, true); } - void Reinitialize() { - ReinitializeConfigChange(config_); - } + void Reinitialize() { ReinitializeConfigChange(config_); } void ReinitializeConfigChange(const AudioDecoderConfig& new_config) { EXPECT_CALL(*decryptor_, DeinitializeDecoder(Decryptor::kAudio)); EXPECT_CALL(*decryptor_, InitializeAudioDecoder(_, _)) .WillOnce(RunCallback<1>(true)); EXPECT_CALL(*decryptor_, RegisterNewKeyCB(Decryptor::kAudio, _)) - .WillOnce(SaveArg<1>(&key_added_cb_)); + .WillOnce(SaveArg<1>(&key_added_cb_)); decoder_->Initialize( new_config, cdm_context_.get(), NewExpectedBoolCB(true), base::Bind(&DecryptingAudioDecoderTest::FrameReady, @@ -133,9 +131,8 @@ void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, DecodeStatus status) { EXPECT_CALL(*this, DecodeDone(status)); - decoder_->Decode(buffer, - base::Bind(&DecryptingAudioDecoderTest::DecodeDone, - base::Unretained(this))); + decoder_->Decode(buffer, base::Bind(&DecryptingAudioDecoderTest::DecodeDone, + base::Unretained(this))); base::RunLoop().RunUntilIdle(); } @@ -161,8 +158,9 @@ // Sets up expectations and actions to put DecryptingAudioDecoder in an // active normal decoding state. void EnterNormalDecodingState() { - EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)).WillRepeatedly( - Invoke(this, &DecryptingAudioDecoderTest::DecryptAndDecodeAudio)); + EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) + .WillRepeatedly( + Invoke(this, &DecryptingAudioDecoderTest::DecryptAndDecodeAudio)); EXPECT_CALL(*this, FrameReady(decoded_frame_)); for (int i = 0; i < kDecodingDelay + 1; ++i) DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); @@ -173,8 +171,7 @@ // EnterNormalDecodingState() to work. void EnterEndOfStreamState() { // The codec in the |decryptor_| will be flushed. - EXPECT_CALL(*this, FrameReady(decoded_frame_)) - .Times(kDecodingDelay); + EXPECT_CALL(*this, FrameReady(decoded_frame_)).Times(kDecodingDelay); DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK); EXPECT_EQ(0, num_frames_in_decryptor_); } @@ -196,8 +193,8 @@ void EnterWaitingForKeyState() { EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(encrypted_buffer_, _)) - .WillRepeatedly(RunCallback<1>(Decryptor::kNoKey, - Decryptor::AudioFrames())); + .WillRepeatedly( + RunCallback<1>(Decryptor::kNoKey, Decryptor::AudioFrames())); EXPECT_CALL(*this, OnWaitingForDecryptionKey()); decoder_->Decode(encrypted_buffer_, base::Bind(&DecryptingAudioDecoderTest::DecodeDone, @@ -208,8 +205,8 @@ void AbortPendingAudioDecodeCB() { if (!pending_audio_decode_cb_.is_null()) { - base::ResetAndReturn(&pending_audio_decode_cb_).Run( - Decryptor::kSuccess, Decryptor::AudioFrames()); + base::ResetAndReturn(&pending_audio_decode_cb_) + .Run(Decryptor::kSuccess, Decryptor::AudioFrames()); } } @@ -315,8 +312,8 @@ Initialize(); EXPECT_CALL(*decryptor_, DecryptAndDecodeAudio(_, _)) - .WillRepeatedly(RunCallback<1>(Decryptor::kError, - Decryptor::AudioFrames())); + .WillRepeatedly( + RunCallback<1>(Decryptor::kError, Decryptor::AudioFrames())); DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR); } @@ -423,8 +420,8 @@ // The audio decode callback is returned after the correct decryption key is // added. key_added_cb_.Run(); - base::ResetAndReturn(&pending_audio_decode_cb_).Run( - Decryptor::kNoKey, Decryptor::AudioFrames()); + base::ResetAndReturn(&pending_audio_decode_cb_) + .Run(Decryptor::kNoKey, Decryptor::AudioFrames()); base::RunLoop().RunUntilIdle(); }
diff --git a/media/filters/decrypting_demuxer_stream.cc b/media/filters/decrypting_demuxer_stream.cc index 06009f7a..853c9ce 100644 --- a/media/filters/decrypting_demuxer_stream.cc +++ b/media/filters/decrypting_demuxer_stream.cc
@@ -235,8 +235,7 @@ DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, kPendingDecrypt) << state_; decryptor_->Decrypt( - GetDecryptorStreamType(), - pending_buffer_to_decrypt_, + GetDecryptorStreamType(), pending_buffer_to_decrypt_, BindToCurrentLoop( base::Bind(&DecryptingDemuxerStream::DeliverBuffer, weak_this_))); } @@ -276,13 +275,13 @@ std::string key_id = pending_buffer_to_decrypt_->decrypt_config()->key_id(); std::string missing_key_id = base::HexEncode(key_id.data(), key_id.size()); DVLOG(1) << "DeliverBuffer() - no key for key ID " << missing_key_id; - MEDIA_LOG(INFO, media_log_) << GetDisplayName() << ": no key for key ID " - << missing_key_id; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": no key for key ID " << missing_key_id; if (need_to_try_again_if_nokey) { // The |state_| is still kPendingDecrypt. - MEDIA_LOG(INFO, media_log_) << GetDisplayName() - << ": key was added, resuming decrypt"; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": key was added, resuming decrypt"; DecryptPendingBuffer(); return; }
diff --git a/media/filters/decrypting_demuxer_stream_unittest.cc b/media/filters/decrypting_demuxer_stream_unittest.cc index 2650a45a..d156adc8 100644 --- a/media/filters/decrypting_demuxer_stream_unittest.cc +++ b/media/filters/decrypting_demuxer_stream_unittest.cc
@@ -41,8 +41,10 @@ static scoped_refptr<DecoderBuffer> CreateFakeEncryptedStreamBuffer( bool is_clear) { scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(kFakeBufferSize)); - std::string iv = is_clear ? std::string() : - std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)); + std::string iv = is_clear + ? std::string() + : std::string(reinterpret_cast<const char*>(kFakeIv), + arraysize(kFakeIv)); if (!is_clear) { buffer->set_decrypt_config(DecryptConfig::CreateCencConfig( std::string(reinterpret_cast<const char*>(kFakeKeyId), @@ -227,8 +229,8 @@ EXPECT_CALL(*input_audio_stream_, Read(_)) .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); EXPECT_CALL(*decryptor_, Decrypt(_, encrypted_buffer_, _)) - .WillRepeatedly(RunCallback<2>(Decryptor::kNoKey, - scoped_refptr<DecoderBuffer>())); + .WillRepeatedly( + RunCallback<2>(Decryptor::kNoKey, scoped_refptr<DecoderBuffer>())); EXPECT_MEDIA_LOG(HasSubstr("DecryptingDemuxerStream: no key for key ID")); EXPECT_CALL(*this, OnWaitingForDecryptionKey()); demuxer_stream_->Read(base::Bind(&DecryptingDemuxerStreamTest::BufferReady, @@ -343,8 +345,8 @@ EXPECT_CALL(*input_audio_stream_, Read(_)) .WillRepeatedly(ReturnBuffer(encrypted_buffer_)); EXPECT_CALL(*decryptor_, Decrypt(_, encrypted_buffer_, _)) - .WillRepeatedly(RunCallback<2>(Decryptor::kError, - scoped_refptr<DecoderBuffer>())); + .WillRepeatedly( + RunCallback<2>(Decryptor::kError, scoped_refptr<DecoderBuffer>())); EXPECT_MEDIA_LOG(HasSubstr("DecryptingDemuxerStream: decrypt error")); ReadAndExpectBufferReadyWith(DemuxerStream::kError, nullptr); }
diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc index 1f4968d..03d1dad 100644 --- a/media/filters/decrypting_video_decoder.cc +++ b/media/filters/decrypting_video_decoder.cc
@@ -47,9 +47,9 @@ DVLOG(2) << __func__ << ": " << config.AsHumanReadableString(); DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(state_ == kUninitialized || - state_ == kIdle || - state_ == kDecodeFinished) << state_; + DCHECK(state_ == kUninitialized || state_ == kIdle || + state_ == kDecodeFinished) + << state_; DCHECK(decode_cb_.is_null()); DCHECK(reset_cb_.is_null()); DCHECK(config.IsValidConfig()); @@ -102,9 +102,8 @@ const DecodeCB& decode_cb) { DVLOG(3) << "Decode()"; DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(state_ == kIdle || - state_ == kDecodeFinished || - state_ == kError) << state_; + DCHECK(state_ == kIdle || state_ == kDecodeFinished || state_ == kError) + << state_; DCHECK(!decode_cb.is_null()); CHECK(decode_cb_.is_null()) << "Overlapping decodes are not supported."; @@ -129,11 +128,10 @@ void DecryptingVideoDecoder::Reset(const base::Closure& closure) { DVLOG(2) << "Reset() - state: " << state_; DCHECK(task_runner_->BelongsToCurrentThread()); - DCHECK(state_ == kIdle || - state_ == kPendingDecode || - state_ == kWaitingForKey || - state_ == kDecodeFinished || - state_ == kError) << state_; + DCHECK(state_ == kIdle || state_ == kPendingDecode || + state_ == kWaitingForKey || state_ == kDecodeFinished || + state_ == kError) + << state_; DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. DCHECK(reset_cb_.is_null()); @@ -184,12 +182,12 @@ DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, kPendingDecoderInit) << state_; DCHECK(!init_cb_.is_null()); - DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. + DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. if (!success) { - MEDIA_LOG(DEBUG, media_log_) << GetDisplayName() - << ": failed to init decoder on decryptor"; + MEDIA_LOG(DEBUG, media_log_) + << GetDisplayName() << ": failed to init decoder on decryptor"; base::ResetAndReturn(&init_cb_).Run(false); decryptor_ = NULL; state_ = kError; @@ -197,16 +195,14 @@ } decryptor_->RegisterNewKeyCB( - Decryptor::kVideo, - BindToCurrentLoop( - base::Bind(&DecryptingVideoDecoder::OnKeyAdded, weak_this_))); + Decryptor::kVideo, BindToCurrentLoop(base::Bind( + &DecryptingVideoDecoder::OnKeyAdded, weak_this_))); // Success! state_ = kIdle; base::ResetAndReturn(&init_cb_).Run(true); } - void DecryptingVideoDecoder::DecodePendingBuffer() { DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK_EQ(state_, kPendingDecode) << state_; @@ -219,8 +215,9 @@ } decryptor_->DecryptAndDecodeVideo( - pending_buffer_to_decode_, BindToCurrentLoop(base::Bind( - &DecryptingVideoDecoder::DeliverFrame, weak_this_, buffer_size))); + pending_buffer_to_decode_, + BindToCurrentLoop(base::Bind(&DecryptingVideoDecoder::DeliverFrame, + weak_this_, buffer_size))); } void DecryptingVideoDecoder::DeliverFrame( @@ -233,9 +230,9 @@ DCHECK(!decode_cb_.is_null()); DCHECK(pending_buffer_to_decode_.get()); - TRACE_EVENT_ASYNC_END2( - "media", "DecryptingVideoDecoder::DecodePendingBuffer", trace_id_, - "buffer_size", buffer_size, "status", status); + TRACE_EVENT_ASYNC_END2("media", "DecryptingVideoDecoder::DecodePendingBuffer", + trace_id_, "buffer_size", buffer_size, "status", + status); bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; key_added_while_decode_pending_ = false; @@ -264,8 +261,8 @@ scoped_pending_buffer_to_decode->decrypt_config()->key_id(); std::string missing_key_id = base::HexEncode(key_id.data(), key_id.size()); DVLOG(1) << "DeliverFrame() - no key for key ID " << missing_key_id; - MEDIA_LOG(INFO, media_log_) << GetDisplayName() << ": no key for key ID " - << missing_key_id; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": no key for key ID " << missing_key_id; // Set |pending_buffer_to_decode_| back as we need to try decoding the // pending buffer again when new key is added to the decryptor. @@ -273,8 +270,8 @@ if (need_to_try_again_if_nokey_is_returned) { // The |state_| is still kPendingDecode. - MEDIA_LOG(INFO, media_log_) << GetDisplayName() - << ": key was added, resuming decode"; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": key was added, resuming decode"; DecodePendingBuffer(); return; } @@ -331,8 +328,8 @@ } if (state_ == kWaitingForKey) { - MEDIA_LOG(INFO, media_log_) << GetDisplayName() - << ": key added, resuming decode"; + MEDIA_LOG(INFO, media_log_) + << GetDisplayName() << ": key added, resuming decode"; state_ = kPendingDecode; DecodePendingBuffer(); }
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc index 095dc3a..90d131f 100644 --- a/media/filters/decrypting_video_decoder_unittest.cc +++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -108,9 +108,8 @@ void DecodeAndExpect(scoped_refptr<DecoderBuffer> buffer, DecodeStatus status) { EXPECT_CALL(*this, DecodeDone(status)); - decoder_->Decode(buffer, - base::Bind(&DecryptingVideoDecoderTest::DecodeDone, - base::Unretained(this))); + decoder_->Decode(buffer, base::Bind(&DecryptingVideoDecoderTest::DecodeDone, + base::Unretained(this))); base::RunLoop().RunUntilIdle(); } @@ -136,8 +135,9 @@ // Sets up expectations and actions to put DecryptingVideoDecoder in an // active normal decoding state. void EnterNormalDecodingState() { - EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)).WillRepeatedly( - Invoke(this, &DecryptingVideoDecoderTest::DecryptAndDecodeVideo)); + EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) + .WillRepeatedly( + Invoke(this, &DecryptingVideoDecoderTest::DecryptAndDecodeVideo)); EXPECT_CALL(*this, FrameReady(decoded_video_frame_)); for (int i = 0; i < kDecodingDelay + 1; ++i) DecodeAndExpect(encrypted_buffer_, DecodeStatus::OK); @@ -148,8 +148,7 @@ // EnterNormalDecodingState() to work. void EnterEndOfStreamState() { // The codec in the |decryptor_| will be flushed. - EXPECT_CALL(*this, FrameReady(decoded_video_frame_)) - .Times(kDecodingDelay); + EXPECT_CALL(*this, FrameReady(decoded_video_frame_)).Times(kDecodingDelay); DecodeAndExpect(DecoderBuffer::CreateEOSBuffer(), DecodeStatus::OK); EXPECT_EQ(0, num_frames_in_decryptor_); } @@ -181,8 +180,8 @@ void AbortPendingVideoDecodeCB() { if (!pending_video_decode_cb_.is_null()) { - base::ResetAndReturn(&pending_video_decode_cb_).Run( - Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL)); + base::ResetAndReturn(&pending_video_decode_cb_) + .Run(Decryptor::kSuccess, scoped_refptr<VideoFrame>(NULL)); } } @@ -299,8 +298,8 @@ Initialize(); EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) - .WillRepeatedly(RunCallback<1>(Decryptor::kError, - scoped_refptr<VideoFrame>(NULL))); + .WillRepeatedly( + RunCallback<1>(Decryptor::kError, scoped_refptr<VideoFrame>(NULL))); DecodeAndExpect(encrypted_buffer_, DecodeStatus::DECODE_ERROR); @@ -322,8 +321,8 @@ EnterWaitingForKeyState(); EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) - .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, - decoded_video_frame_)); + .WillRepeatedly( + RunCallback<1>(Decryptor::kSuccess, decoded_video_frame_)); EXPECT_CALL(*this, FrameReady(decoded_video_frame_)); EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK)); key_added_cb_.Run(); @@ -337,15 +336,15 @@ EnterPendingDecodeState(); EXPECT_CALL(*decryptor_, DecryptAndDecodeVideo(_, _)) - .WillRepeatedly(RunCallback<1>(Decryptor::kSuccess, - decoded_video_frame_)); + .WillRepeatedly( + RunCallback<1>(Decryptor::kSuccess, decoded_video_frame_)); EXPECT_CALL(*this, FrameReady(decoded_video_frame_)); EXPECT_CALL(*this, DecodeDone(DecodeStatus::OK)); // The video decode callback is returned after the correct decryption key is // added. key_added_cb_.Run(); - base::ResetAndReturn(&pending_video_decode_cb_).Run(Decryptor::kNoKey, - null_video_frame_); + base::ResetAndReturn(&pending_video_decode_cb_) + .Run(Decryptor::kNoKey, null_video_frame_); base::RunLoop().RunUntilIdle(); }
diff --git a/media/renderers/video_resource_updater_unittest.cc b/media/renderers/video_resource_updater_unittest.cc index ea450d0..c82d7018 100644 --- a/media/renderers/video_resource_updater_unittest.cc +++ b/media/renderers/video_resource_updater_unittest.cc
@@ -102,7 +102,7 @@ void SetUp() override { testing::Test::SetUp(); resource_provider_ = std::make_unique<viz::ClientResourceProvider>( - context_provider_.get(), /*delegated_sync_points_required=*/true); + /*delegated_sync_points_required=*/true); } std::unique_ptr<VideoResourceUpdater> CreateUpdaterForHardware(
diff --git a/media/test/data/eme_player_js/globals.js b/media/test/data/eme_player_js/globals.js index 510d96b..329fb01 100644 --- a/media/test/data/eme_player_js/globals.js +++ b/media/test/data/eme_player_js/globals.js
@@ -36,6 +36,7 @@ var UNIT_TEST_RESULT_HEADER = 'UNIT_TEST_RESULT'; // Available EME key systems to use. +// TODO(xhwang): Unify naming in this list. var WIDEVINE_KEYSYSTEM = 'com.widevine.alpha'; var CLEARKEY = 'org.w3.clearkey'; var EXTERNAL_CLEARKEY = 'org.chromium.externalclearkey'; @@ -50,7 +51,7 @@ var VERIFY_HOST_FILES_TEST_KEYSYSTEM = 'org.chromium.externalclearkey.verifycdmhosttest'; var STORAGE_ID_TEST_KEYSYSTEM = 'org.chromium.externalclearkey.storageidtest'; -var CDM_PROXY_TEST_KEYSYSTEM = 'org.chromium.externalclearkey.cdmproxytest'; +var EXTERNAL_CLEARKEY_CDM_PROXY = 'org.chromium.externalclearkey.cdmproxy'; // Key system name:value map to show on the document page. var KEY_SYSTEMS = {
diff --git a/media/test/data/eme_player_js/player_utils.js b/media/test/data/eme_player_js/player_utils.js index c28b815..670fb3d0 100644 --- a/media/test/data/eme_player_js/player_utils.js +++ b/media/test/data/eme_player_js/player_utils.js
@@ -286,9 +286,9 @@ switch (keySystem) { case WIDEVINE_KEYSYSTEM: return WidevinePlayer; - case CDM_PROXY_TEST_KEYSYSTEM: case CLEARKEY: case EXTERNAL_CLEARKEY: + case EXTERNAL_CLEARKEY_CDM_PROXY: case MESSAGE_TYPE_TEST_KEYSYSTEM: case CRASH_TEST_KEYSYSTEM: return ClearKeyPlayer;
diff --git a/mojo/android/BUILD.gn b/mojo/android/BUILD.gn index 223f859a..ce2b92e4 100644 --- a/mojo/android/BUILD.gn +++ b/mojo/android/BUILD.gn
@@ -129,7 +129,6 @@ ":system_java_jni_headers", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//mojo/edk", "//mojo/public/cpp/bindings/tests:mojo_public_bindings_test_utils", "//mojo/public/cpp/test_support:test_utils",
diff --git a/mojo/edk/BUILD.gn b/mojo/edk/BUILD.gn index f768e2c58..1858a25d 100644 --- a/mojo/edk/BUILD.gn +++ b/mojo/edk/BUILD.gn
@@ -228,7 +228,6 @@ ] deps = [ ":impl_for_mojo_core", - "//build/config:exe_and_shlib_deps", "//mojo/public/c/system:headers", ] configs += [ ":export_only_thunks_api" ]
diff --git a/mojo/public/tools/fuzzers/BUILD.gn b/mojo/public/tools/fuzzers/BUILD.gn index 00d09f1..7b0bfd8 100644 --- a/mojo/public/tools/fuzzers/BUILD.gn +++ b/mojo/public/tools/fuzzers/BUILD.gn
@@ -41,7 +41,6 @@ deps = [ ":fuzz_mojom", "//base", - "//build/config:exe_and_shlib_deps", "//mojo/edk", ] }
diff --git a/net/BUILD.gn b/net/BUILD.gn index 9697b2b..9581979d 100644 --- a/net/BUILD.gn +++ b/net/BUILD.gn
@@ -2338,7 +2338,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2826,7 +2825,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] @@ -2845,7 +2843,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2859,7 +2856,6 @@ deps = [ ":net", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2874,7 +2870,6 @@ deps = [ ":net", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2888,7 +2883,6 @@ deps = [ ":net", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2903,7 +2897,6 @@ ":net", ":net_with_v8", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2918,7 +2911,6 @@ ":test_support", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//testing/gtest", ] @@ -2934,7 +2926,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -2947,7 +2938,6 @@ deps = [ "//base", "//base:i18n", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//net/tools/tld_cleanup", ] @@ -2964,7 +2954,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", ] } @@ -2979,7 +2968,6 @@ ":net", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//url", ] } @@ -3042,7 +3030,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//third_party/boringssl", ] } @@ -3057,7 +3044,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//third_party/boringssl", ] } @@ -3101,7 +3087,6 @@ deps = [ ":net", "//base", - "//build/config:exe_and_shlib_deps", ] } } @@ -3339,7 +3324,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//url", ] @@ -3352,7 +3336,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/boringssl", "//third_party/protobuf:protobuf_lite", @@ -3366,7 +3349,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/boringssl", "//third_party/protobuf:protobuf_lite", @@ -3380,7 +3362,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/boringssl", "//third_party/protobuf:protobuf_lite", @@ -3393,7 +3374,6 @@ deps = [ ":net", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -3405,7 +3385,6 @@ ":net", ":simple_quic_tools", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -5731,7 +5710,6 @@ "//base", "//base:i18n", "//base/test:test_support_perf", - "//build/config:exe_and_shlib_deps", "//testing/gtest", "//testing/perf", "//url",
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc index 7a29f958..4370a23 100644 --- a/net/dns/host_resolver_impl.cc +++ b/net/dns/host_resolver_impl.cc
@@ -2003,6 +2003,7 @@ last_ipv6_probe_result_(true), additional_resolver_flags_(0), fallback_to_proctask_(true), + url_request_context_(nullptr), tick_clock_(base::DefaultTickClock::GetInstance()), weak_ptr_factory_(this), probe_weak_ptr_factory_(this) {
diff --git a/net/dns/host_resolver_impl.h b/net/dns/host_resolver_impl.h index ffd89ba..fcda4d5c 100644 --- a/net/dns/host_resolver_impl.h +++ b/net/dns/host_resolver_impl.h
@@ -19,7 +19,7 @@ #include "net/dns/host_cache.h" #include "net/dns/host_resolver.h" #include "net/dns/host_resolver_proc.h" -#include "net/url_request/url_request_context_getter.h" +#include "net/url_request/url_request_context.h" #include "url/gurl.h" namespace base {
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc index 59a8dd9..b9da022 100644 --- a/net/http/http_response_headers.cc +++ b/net/http/http_response_headers.cc
@@ -1287,4 +1287,12 @@ HasHeaderValue("Transfer-Encoding", "chunked"); } +bool HttpResponseHeaders::IsCookieResponseHeader(StringPiece name) { + for (const char* cookie_header : kCookieResponseHeaders) { + if (base::EqualsCaseInsensitiveASCII(cookie_header, name)) + return true; + } + return false; +} + } // namespace net
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h index 839dd75d8..b21435c 100644 --- a/net/http/http_response_headers.h +++ b/net/http/http_response_headers.h
@@ -286,6 +286,10 @@ // Returns the raw header string. const std::string& raw_headers() const { return raw_headers_; } + // Returns true if |name| is a cookie related header name. This is consistent + // with |PERSIST_SANS_COOKIES|. + static bool IsCookieResponseHeader(base::StringPiece name); + private: friend class base::RefCountedThreadSafe<HttpResponseHeaders>;
diff --git a/net/tools/transport_security_state_generator/BUILD.gn b/net/tools/transport_security_state_generator/BUILD.gn index 73c07c4..06bfd8b 100644 --- a/net/tools/transport_security_state_generator/BUILD.gn +++ b/net/tools/transport_security_state_generator/BUILD.gn
@@ -62,7 +62,6 @@ deps = [ ":transport_security_state_generator_sources", "//base", - "//build/config:exe_and_shlib_deps", "//crypto", "//third_party/boringssl", ]
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc index 936eb08..fb86f5d 100644 --- a/net/websockets/websocket_basic_handshake_stream.cc +++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -403,10 +403,9 @@ void WebSocketBasicHandshakeStream::OnFinishOpeningHandshake() { DCHECK(http_response_info_); - WebSocketDispatchOnFinishOpeningHandshake(connect_delegate_, - url_, - http_response_info_->headers, - http_response_info_->response_time); + WebSocketDispatchOnFinishOpeningHandshake( + connect_delegate_, url_, http_response_info_->headers, + http_response_info_->socket_address, http_response_info_->response_time); } int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc index d704cb3..9e78ec0 100644 --- a/net/websockets/websocket_channel_test.cc +++ b/net/websockets/websocket_channel_test.cc
@@ -1576,7 +1576,8 @@ auto response_headers = base::MakeRefCounted<HttpResponseHeaders>("HTTP/1.1 200 OK"); auto response_info = std::make_unique<WebSocketHandshakeResponseInfo>( - GURL("ws://www.example.com/"), response_headers, base::Time()); + GURL("ws://www.example.com/"), response_headers, HostPortPair(), + base::Time()); connect_data_.argument_saver.connect_delegate->OnFinishOpeningHandshake( std::move(response_info)); base::RunLoop().RunUntilIdle(); @@ -1600,7 +1601,7 @@ auto response_headers = base::MakeRefCounted<HttpResponseHeaders>("HTTP/1.1 200 OK"); auto response_info = std::make_unique<WebSocketHandshakeResponseInfo>( - url, response_headers, base::Time()); + url, response_headers, HostPortPair(), base::Time()); connect_delegate->OnStartOpeningHandshake(std::move(request_info)); connect_delegate->OnFinishOpeningHandshake(std::move(response_info));
diff --git a/net/websockets/websocket_handshake_response_info.cc b/net/websockets/websocket_handshake_response_info.cc index 008e32d..d59ab1e4 100644 --- a/net/websockets/websocket_handshake_response_info.cc +++ b/net/websockets/websocket_handshake_response_info.cc
@@ -15,8 +15,12 @@ WebSocketHandshakeResponseInfo::WebSocketHandshakeResponseInfo( const GURL& url, scoped_refptr<HttpResponseHeaders> headers, + const HostPortPair& socket_address, base::Time response_time) - : url(url), headers(std::move(headers)), response_time(response_time) {} + : url(url), + headers(std::move(headers)), + socket_address(socket_address), + response_time(response_time) {} WebSocketHandshakeResponseInfo::~WebSocketHandshakeResponseInfo() = default;
diff --git a/net/websockets/websocket_handshake_response_info.h b/net/websockets/websocket_handshake_response_info.h index 6bf7098..90232da0 100644 --- a/net/websockets/websocket_handshake_response_info.h +++ b/net/websockets/websocket_handshake_response_info.h
@@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/time/time.h" +#include "net/base/host_port_pair.h" #include "net/base/net_export.h" #include "url/gurl.h" @@ -18,12 +19,15 @@ struct NET_EXPORT WebSocketHandshakeResponseInfo { WebSocketHandshakeResponseInfo(const GURL& url, scoped_refptr<HttpResponseHeaders> headers, + const HostPortPair& socket_address, base::Time response_time); ~WebSocketHandshakeResponseInfo(); // The request URL GURL url; // HTTP response headers scoped_refptr<HttpResponseHeaders> headers; + // Remote address of the socket. + HostPortPair socket_address; // The time that this response arrived base::Time response_time;
diff --git a/net/websockets/websocket_http2_handshake_stream.cc b/net/websockets/websocket_http2_handshake_stream.cc index 5889037..6b13a40 100644 --- a/net/websockets/websocket_http2_handshake_stream.cc +++ b/net/websockets/websocket_http2_handshake_stream.cc
@@ -378,7 +378,7 @@ DCHECK(http_response_info_); WebSocketDispatchOnFinishOpeningHandshake( connect_delegate_, request_info_->url, http_response_info_->headers, - http_response_info_->response_time); + http_response_info_->socket_address, http_response_info_->response_time); } void WebSocketHttp2HandshakeStream::OnFailure(const std::string& message) {
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc index 4415ac0..47ea8d4 100644 --- a/net/websockets/websocket_stream.cc +++ b/net/websockets/websocket_stream.cc
@@ -250,10 +250,10 @@ } void OnFinishOpeningHandshake() { - WebSocketDispatchOnFinishOpeningHandshake(connect_delegate(), - url_request_->url(), - url_request_->response_headers(), - url_request_->response_time()); + WebSocketDispatchOnFinishOpeningHandshake( + connect_delegate(), url_request_->url(), + url_request_->response_headers(), url_request_->GetSocketAddress(), + url_request_->response_time()); } WebSocketStream::ConnectDelegate* connect_delegate() const { @@ -469,12 +469,13 @@ WebSocketStream::ConnectDelegate* connect_delegate, const GURL& url, const scoped_refptr<HttpResponseHeaders>& headers, + const HostPortPair& socket_address, base::Time response_time) { DCHECK(connect_delegate); if (headers.get()) { connect_delegate->OnFinishOpeningHandshake( - std::make_unique<WebSocketHandshakeResponseInfo>(url, headers, - response_time)); + std::make_unique<WebSocketHandshakeResponseInfo>( + url, headers, socket_address, response_time)); } }
diff --git a/net/websockets/websocket_stream.h b/net/websockets/websocket_stream.h index fd9e1c0..e7c78c2 100644 --- a/net/websockets/websocket_stream.h +++ b/net/websockets/websocket_stream.h
@@ -31,6 +31,7 @@ namespace net { +class HostPortPair; class HttpRequestHeaders; class NetLogWithSource; class URLRequest; @@ -243,6 +244,7 @@ WebSocketStream::ConnectDelegate* connect_delegate, const GURL& gurl, const scoped_refptr<HttpResponseHeaders>& headers, + const HostPortPair& socket_address, base::Time response_time); } // namespace net
diff --git a/ppapi/BUILD.gn b/ppapi/BUILD.gn index bbaaa45..0982955 100644 --- a/ppapi/BUILD.gn +++ b/ppapi/BUILD.gn
@@ -231,7 +231,6 @@ deps = [ ":copy_test_files", ":copy_test_files2", - "//build/config:exe_and_shlib_deps", "//ppapi/cpp", "//ppapi/shared_impl", ] @@ -255,7 +254,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//ppapi/cpp", "//ppapi/shared_impl", ] @@ -282,7 +280,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//ppapi/cpp", "//ppapi/shared_impl", ] @@ -309,7 +306,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//ppapi/cpp", "//ppapi/shared_impl", ] @@ -409,7 +405,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/ppapi/examples/ppapi_example.gni b/ppapi/examples/ppapi_example.gni index cb24dcf..3cedcc0 100644 --- a/ppapi/examples/ppapi_example.gni +++ b/ppapi/examples/ppapi_example.gni
@@ -18,7 +18,7 @@ } sources = invoker.sources - deps = invoker.deps + [ "//build/config:exe_and_shlib_deps" ] + deps = invoker.deps } } else { mac_plugin_bundle(target_name) {
diff --git a/remoting/client/jni/BUILD.gn b/remoting/client/jni/BUILD.gn index 8f6a569..6d097626 100644 --- a/remoting/client/jni/BUILD.gn +++ b/remoting/client/jni/BUILD.gn
@@ -18,7 +18,6 @@ shared_library("remoting_client_jni") { deps = [ - "//build/config:exe_and_shlib_deps", "//remoting/android:jni_headers", "//remoting/android:remoting_jni_registration", "//remoting/base",
diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn index b0fca33b..db3de12 100644 --- a/remoting/host/BUILD.gn +++ b/remoting/host/BUILD.gn
@@ -573,7 +573,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//third_party/libjingle_xmpp", "//third_party/webrtc_overrides:init_webrtc", ] @@ -774,7 +773,6 @@ deps = [ ":remoting_me2me_host_static", - "//build/config:exe_and_shlib_deps", "//remoting/base:breakpad", "//remoting/host/installer:credits", "//remoting/resources",
diff --git a/remoting/host/it2me/BUILD.gn b/remoting/host/it2me/BUILD.gn index 7e2df5c..b69e217f 100644 --- a/remoting/host/it2me/BUILD.gn +++ b/remoting/host/it2me/BUILD.gn
@@ -202,7 +202,6 @@ deps = [ ":common", - "//build/config:exe_and_shlib_deps", "//remoting/host", "//remoting/host/native_messaging", "//remoting/proto",
diff --git a/remoting/host/linux/BUILD.gn b/remoting/host/linux/BUILD.gn index 89a9c708..6fca9dc 100644 --- a/remoting/host/linux/BUILD.gn +++ b/remoting/host/linux/BUILD.gn
@@ -17,7 +17,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", ] libs = [ "pam" ] @@ -59,7 +58,6 @@ ] deps = [ ":remoting_user_session", - "//build/config:exe_and_shlib_deps", ] if (is_component_build) { sources += [ "$root_build_dir/libbase.so" ] @@ -67,6 +65,7 @@ } if (!libcpp_is_static && use_custom_libcxx) { sources += [ "$root_build_dir/libc++.so" ] + deps += [ "//buildtools/third_party/libc++" ] } } @@ -133,7 +132,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//net", "//remoting/base:breakpad", "//remoting/host",
diff --git a/remoting/host/mac/BUILD.gn b/remoting/host/mac/BUILD.gn index 81c434e..f9d46f4 100644 --- a/remoting/host/mac/BUILD.gn +++ b/remoting/host/mac/BUILD.gn
@@ -74,7 +74,6 @@ # } deps = [ - "//build/config:exe_and_shlib_deps", "//remoting/base:breakpad", "//remoting/host:main", "//remoting/host:remoting_me2me_host_static",
diff --git a/remoting/test/BUILD.gn b/remoting/test/BUILD.gn index fa9826c..fa1b4c3 100644 --- a/remoting/test/BUILD.gn +++ b/remoting/test/BUILD.gn
@@ -104,7 +104,6 @@ deps = [ ":test_support", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//testing/gtest", ] @@ -143,7 +142,6 @@ deps = [ ":ar_test_driver_common", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//testing/gtest", ] @@ -195,7 +193,6 @@ deps = [ ":it2me_standalone_host", - "//build/config:exe_and_shlib_deps", ] if (is_desktop_linux) { @@ -222,7 +219,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", ] } }
diff --git a/remoting/tools/javascript_key_tester/pnacl/BUILD.gn b/remoting/tools/javascript_key_tester/pnacl/BUILD.gn index 13cc012..90d9565b 100644 --- a/remoting/tools/javascript_key_tester/pnacl/BUILD.gn +++ b/remoting/tools/javascript_key_tester/pnacl/BUILD.gn
@@ -11,7 +11,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//ppapi/cpp", "//ppapi/native_client:ppapi_lib", ]
diff --git a/rlz/BUILD.gn b/rlz/BUILD.gn index fee26a7..59d4816 100644 --- a/rlz/BUILD.gn +++ b/rlz/BUILD.gn
@@ -167,7 +167,6 @@ ] deps = [ ":rlz_lib", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -182,7 +181,6 @@ deps = [ ":rlz_lib", ":rlz_utils", - "//build/config:exe_and_shlib_deps", "//third_party/zlib", ] }
diff --git a/sandbox/linux/BUILD.gn b/sandbox/linux/BUILD.gn index b409fd6..6f43c6cb 100644 --- a/sandbox/linux/BUILD.gn +++ b/sandbox/linux/BUILD.gn
@@ -201,7 +201,6 @@ test("sandbox_linux_unittests") { deps = [ ":sandbox_linux_unittests_sources", - "//build/config:exe_and_shlib_deps", ] if (is_android) { use_raw_android_executable = true
diff --git a/sandbox/win/BUILD.gn b/sandbox/win/BUILD.gn index 4fabf924..6dec9880 100644 --- a/sandbox/win/BUILD.gn +++ b/sandbox/win/BUILD.gn
@@ -234,7 +234,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -360,8 +359,4 @@ ] defines = [ "POCDLL_EXPORTS" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] }
diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 3f2b1bd..f5f4338 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc
@@ -35,6 +35,7 @@ #include "net/cert/ct_log_verifier.h" #include "net/cert/multi_log_ct_verifier.h" #include "net/cookies/cookie_monster.h" +#include "net/dns/host_cache.h" #include "net/dns/host_resolver.h" #include "net/dns/mapped_host_resolver.h" #include "net/extras/sqlite/sqlite_channel_id_store.h" @@ -122,17 +123,32 @@ } }; -// Predicate function to determine if the given |channel_id_server_id| matches -// the |filter_type| and |filter_domains| from a |mojom::ClearDataFilter|. -bool MatchesClearChannelIdFilter(mojom::ClearDataFilter_Type filter_type, - std::set<std::string> filter_domains, - const std::string& channel_id_server_id) { - bool found_domain = - filter_domains.find(channel_id_server_id) != filter_domains.end(); +// Predicate function to determine if the given |domain| matches the +// |filter_type| and |filter_domains| from a |mojom::ClearDataFilter|. +bool MatchesDomainFilter(mojom::ClearDataFilter_Type filter_type, + std::set<std::string> filter_domains, + const std::string& domain) { + bool found_domain = filter_domains.find(domain) != filter_domains.end(); return (filter_type == mojom::ClearDataFilter_Type::DELETE_MATCHES) == found_domain; } +// Returns a callback that checks if a domain matches the |filter|. |filter| +// must contain no origins. A null filter matches everything. +base::RepeatingCallback<bool(const std::string& host_name)> MakeDomainFilter( + mojom::ClearDataFilter* filter) { + if (!filter) + return base::BindRepeating([](const std::string&) { return true; }); + + DCHECK(filter->origins.empty()) + << "Origin filtering not allowed in a domain-only filter"; + + std::set<std::string> filter_domains; + filter_domains.insert(filter->domains.begin(), filter->domains.end()); + return base::BindRepeating(&MatchesDomainFilter, filter->type, + std::move(filter_domains)); +} + // Generic functions but currently only used for reporting. #if BUILDFLAG(ENABLE_REPORTING) // Predicate function to determine if the given |url| matches the |filter_type|, @@ -232,7 +248,8 @@ binding_(this, std::move(request)) { url_request_context_owner_ = ApplyContextParamsToBuilder( builder.get(), params_.get(), network_service->quic_disabled(), - network_service->net_log(), network_service->network_quality_estimator(), + network_service->net_log(), network_service->host_resolver(), + network_service->network_quality_estimator(), network_service_->sth_reporter(), &ct_tree_tracker_, &require_ct_delegate_, &certificate_report_sender_, &user_agent_settings_); @@ -400,30 +417,23 @@ return; } - base::RepeatingCallback<bool(const std::string& channel_id_server_id)> - filter_predicate; - if (filter) { - DCHECK(filter->origins.empty()) - << "Origin filtering not allowed in a ClearChannelIds request as " - "channel IDs are only keyed by domain."; - - std::set<std::string> filter_domains; - filter_domains.insert(filter->domains.begin(), filter->domains.end()); - filter_predicate = base::BindRepeating( - &MatchesClearChannelIdFilter, filter->type, std::move(filter_domains)); - } else { - filter_predicate = - base::BindRepeating([](const std::string&) { return true; }); - } - channel_id_store->DeleteForDomainsCreatedBetween( - std::move(filter_predicate), start_time, end_time, + MakeDomainFilter(filter.get()), start_time, end_time, base::BindOnce( &OnClearedChannelIds, base::RetainedRef(url_request_context_->ssl_config_service()), std::move(callback))); } +void NetworkContext::ClearHostCache(mojom::ClearDataFilterPtr filter, + ClearHostCacheCallback callback) { + net::HostCache* host_cache = + url_request_context_->host_resolver()->GetHostCache(); + DCHECK(host_cache); + host_cache->ClearForHosts(MakeDomainFilter(filter.get())); + std::move(callback).Run(); +} + void NetworkContext::ClearHttpAuthCache(base::Time start_time, ClearHttpAuthCacheCallback callback) { net::HttpNetworkSession* http_session = @@ -632,6 +642,7 @@ mojom::NetworkContextParams* network_context_params, bool quic_disabled, net::NetLog* net_log, + net::HostResolver* host_resolver, net::NetworkQualityEstimator* network_quality_estimator, certificate_transparency::STHReporter* sth_reporter, std::unique_ptr<certificate_transparency::TreeStateTracker>* @@ -643,6 +654,9 @@ if (net_log) builder->set_net_log(net_log); + if (host_resolver) + builder->set_shared_host_resolver(host_resolver); + if (network_quality_estimator) builder->set_network_quality_estimator(network_quality_estimator); @@ -947,8 +961,6 @@ net::HttpAuthHandlerRegistryFactory::Create( http_auth_preferences_.get(), network_service_->host_resolver()); - builder.set_shared_host_resolver(network_service_->host_resolver()); - builder.SetHttpAuthHandlerFactory(std::move(http_auth_handler_factory)); if (g_cert_verifier_for_testing) { @@ -969,6 +981,7 @@ &builder, network_context_params, network_service_ ? network_service_->quic_disabled() : false, network_service_ ? network_service_->net_log() : nullptr, + network_service_ ? network_service_->host_resolver() : nullptr, network_service_ ? network_service_->network_quality_estimator() : nullptr, network_service_ ? network_service_->sth_reporter() : nullptr,
diff --git a/services/network/network_context.h b/services/network/network_context.h index f0d5187..9344f0fa 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h
@@ -33,6 +33,7 @@ namespace net { class CertVerifier; +class HostResolver; class HttpAuthPreferences; class NetworkQualityEstimator; class ReportSender; @@ -135,6 +136,8 @@ base::Time end_time, mojom::ClearDataFilterPtr filter, ClearChannelIdsCallback callback) override; + void ClearHostCache(mojom::ClearDataFilterPtr filter, + ClearHostCacheCallback callback) override; void ClearHttpAuthCache(base::Time start_time, ClearHttpAuthCacheCallback callback) override; void ClearReportingCacheReports( @@ -202,6 +205,7 @@ mojom::NetworkContextParams* network_context_params, bool quic_disabled, net::NetLog* net_log, + net::HostResolver* host_resolver, net::NetworkQualityEstimator* network_quality_estimator, certificate_transparency::STHReporter* sth_reporter, std::unique_ptr<certificate_transparency::TreeStateTracker>*
diff --git a/services/network/network_context_unittest.cc b/services/network/network_context_unittest.cc index 6ee80e7f..f953c2e 100644 --- a/services/network/network_context_unittest.cc +++ b/services/network/network_context_unittest.cc
@@ -18,6 +18,7 @@ #include "base/location.h" #include "base/metrics/field_trial.h" #include "base/run_loop.h" +#include "base/stl_util.h" #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" @@ -1103,6 +1104,113 @@ run_loop.Run(); } +TEST_F(NetworkContextTest, ClearHostCache) { + // List of domains added to the host cache before running each test case. + const char* kDomains[] = { + "domain0", "domain1", "domain2", "domain3", + }; + + // Each bit correponds to one of the 4 domains above. + enum Domains { + NO_DOMAINS = 0x0, + DOMAIN0 = 0x1, + DOMAIN1 = 0x2, + DOMAIN2 = 0x4, + DOMAIN3 = 0x8, + }; + + const struct { + // True if the ClearDataFilter should be a nullptr. + bool null_filter; + network::mojom::ClearDataFilter::Type type; + // Bit field of Domains that appear in the filter. The origin vector is + // never populated. + int filter_domains; + // Only domains that are expected to remain in the host cache. + int expected_cached_domains; + } kTestCases[] = { + // A null filter should delete everything. The filter type and filter + // domain lists are ignored. + { + true /* null_filter */, + network::mojom::ClearDataFilter::Type::KEEP_MATCHES, + NO_DOMAINS /* filter_domains */, + NO_DOMAINS /* expected_cached_domains */ + }, + // An empty DELETE_MATCHES filter should delete nothing. + { + false /* null_filter */, + network::mojom::ClearDataFilter::Type::DELETE_MATCHES, + NO_DOMAINS /* filter_domains */, + DOMAIN0 | DOMAIN1 | DOMAIN2 | DOMAIN3 /* expected_cached_domains */ + }, + // An empty KEEP_MATCHES filter should delete everything. + { + false /* null_filter */, + network::mojom::ClearDataFilter::Type::KEEP_MATCHES, + NO_DOMAINS /* filter_domains */, + NO_DOMAINS /* expected_cached_domains */ + }, + // Test a non-empty DELETE_MATCHES filter. + { + false /* null_filter */, + network::mojom::ClearDataFilter::Type::DELETE_MATCHES, + DOMAIN0 | DOMAIN2 /* filter_domains */, + DOMAIN1 | DOMAIN3 /* expected_cached_domains */ + }, + // Test a non-empty KEEP_MATCHES filter. + { + false /* null_filter */, + network::mojom::ClearDataFilter::Type::KEEP_MATCHES, + DOMAIN0 | DOMAIN2 /* filter_domains */, + DOMAIN0 | DOMAIN2 /* expected_cached_domains */ + }, + }; + + for (const auto& test_case : kTestCases) { + std::unique_ptr<NetworkContext> network_context = + CreateContextWithParams(CreateContextParams()); + net::HostCache* host_cache = + network_context->url_request_context()->host_resolver()->GetHostCache(); + ASSERT_TRUE(host_cache); + + // Add the 4 test domains to the host cache. + for (const auto* domain : kDomains) { + host_cache->Set( + net::HostCache::Key(domain, net::ADDRESS_FAMILY_UNSPECIFIED, 0), + net::HostCache::Entry(net::OK, net::AddressList(), + net::HostCache::Entry::SOURCE_UNKNOWN), + base::TimeTicks::Now(), base::TimeDelta::FromDays(1)); + } + // Sanity check. + EXPECT_EQ(base::size(kDomains), host_cache->entries().size()); + + // Set up and run the filter, according to |test_case|. + network::mojom::ClearDataFilterPtr clear_data_filter; + if (!test_case.null_filter) { + clear_data_filter = network::mojom::ClearDataFilter::New(); + clear_data_filter->type = test_case.type; + for (size_t i = 0; i < base::size(kDomains); ++i) { + if (test_case.filter_domains & (1 << i)) + clear_data_filter->domains.push_back(kDomains[i]); + } + } + base::RunLoop run_loop; + network_context->ClearHostCache(std::move(clear_data_filter), + run_loop.QuitClosure()); + run_loop.Run(); + + // Check that only the expected domains remain in the cache. + for (size_t i = 0; i < base::size(kDomains); ++i) { + bool expect_domain_cached = + ((test_case.expected_cached_domains & (1 << i)) != 0); + EXPECT_EQ(expect_domain_cached, + host_cache->HasEntry(kDomains[i], nullptr /* source_out */, + nullptr /* stale_out */)); + } + } +} + TEST_F(NetworkContextTest, ClearHttpAuthCache) { GURL origin("http://google.com"); std::unique_ptr<NetworkContext> network_context =
diff --git a/services/network/network_service.cc b/services/network/network_service.cc index e9d423a..e2f7a0b 100644 --- a/services/network/network_service.cc +++ b/services/network/network_service.cc
@@ -191,6 +191,12 @@ return network_context; } +void NetworkService::SetHostResolver( + std::unique_ptr<net::HostResolver> host_resolver) { + DCHECK(network_contexts_.empty()); + host_resolver_ = std::move(host_resolver); +} + std::unique_ptr<NetworkService> NetworkService::CreateForTesting() { return base::WrapUnique( new NetworkService(std::make_unique<service_manager::BinderRegistry>()));
diff --git a/services/network/network_service.h b/services/network/network_service.h index 3d5b3bd..2f066fc 100644 --- a/services/network/network_service.h +++ b/services/network/network_service.h
@@ -73,6 +73,12 @@ std::unique_ptr<URLRequestContextBuilderMojo> builder, net::URLRequestContext** url_request_context); + // Sets the HostResolver used by the NetworkService. Must be called before any + // NetworkContexts have been created. Used in the legacy path only. + // TODO(mmenke): Remove once the NetworkService can create a correct + // HostResolver for ChromeOS. + void SetHostResolver(std::unique_ptr<net::HostResolver> host_resolver); + // Allows late binding if the mojo request wasn't specified in the // constructor. void Bind(mojom::NetworkServiceRequest request);
diff --git a/services/network/public/cpp/network_ipc_param_traits.h b/services/network/public/cpp/network_ipc_param_traits.h index 61d2619f..b3e566cb5 100644 --- a/services/network/public/cpp/network_ipc_param_traits.h +++ b/services/network/public/cpp/network_ipc_param_traits.h
@@ -20,6 +20,7 @@ #include "net/cert/signed_certificate_timestamp_and_status.h" #include "net/cert/x509_certificate.h" #include "net/http/http_request_headers.h" +#include "net/http/http_version.h" #include "net/nqe/effective_connection_type.h" #include "net/ssl/ssl_cert_request_info.h" #include "net/ssl/ssl_info.h"
diff --git a/services/network/public/cpp/network_param.typemap b/services/network/public/cpp/network_param.typemap index 0e1745e..6650c9a 100644 --- a/services/network/public/cpp/network_param.typemap +++ b/services/network/public/cpp/network_param.typemap
@@ -9,10 +9,19 @@ "//net/cert/cert_verify_result.h", "//net/cert/x509_certificate.h", "//net/http/http_request_headers.h", + "//net/http/http_version.h", "//net/ssl/ssl_cert_request_info.h", "//net/ssl/ssl_info.h", ] -traits_headers = [ "//services/network/public/cpp/network_ipc_param_traits.h" ] +traits_headers = [ + "//services/network/public/cpp/network_ipc_param_traits.h", + "//services/network/public/cpp/network_param_mojom_traits.h", +] + +sources = [ + "//services/network/public/cpp/network_param_mojom_traits.cc", +] + public_deps = [ "//net", ] @@ -21,6 +30,7 @@ "network.mojom.AuthCredentials=net::AuthCredentials", "network.mojom.CertVerifyResult=net::CertVerifyResult", "network.mojom.HostPortPair=net::HostPortPair", + "network.mojom.HttpVersion=net::HttpVersion", "network.mojom.SSLCertRequestInfo=scoped_refptr<net::SSLCertRequestInfo>[nullable_is_same_type]", "network.mojom.SSLInfo=net::SSLInfo", "network.mojom.X509Certificate=scoped_refptr<net::X509Certificate>[nullable_is_same_type]",
diff --git a/services/network/public/cpp/network_param_mojom_traits.cc b/services/network/public/cpp/network_param_mojom_traits.cc new file mode 100644 index 0000000..3ac8d89 --- /dev/null +++ b/services/network/public/cpp/network_param_mojom_traits.cc
@@ -0,0 +1,16 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "services/network/public/cpp/network_param_mojom_traits.h" + +namespace mojo { + +bool StructTraits<network::mojom::HttpVersionDataView, net::HttpVersion>::Read( + network::mojom::HttpVersionDataView data, + net::HttpVersion* out) { + *out = net::HttpVersion(data.major_value(), data.minor_value()); + return true; +} + +} // namespace mojo
diff --git a/services/network/public/cpp/network_param_mojom_traits.h b/services/network/public/cpp/network_param_mojom_traits.h new file mode 100644 index 0000000..81e3d82 --- /dev/null +++ b/services/network/public/cpp/network_param_mojom_traits.h
@@ -0,0 +1,30 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SERVICES_NETWORK_PUBLIC_CPP_NETWORK_PARAM_MOJOM_TRAITS_H_ +#define SERVICES_NETWORK_PUBLIC_CPP_NETWORK_PARAM_MOJOM_TRAITS_H_ + +#include "mojo/public/cpp/bindings/struct_traits.h" +#include "net/http/http_version.h" +#include "services/network/public/mojom/network_param.mojom.h" + +namespace mojo { + +template <> +class StructTraits<network::mojom::HttpVersionDataView, net::HttpVersion> { + public: + static int16_t major_value(net::HttpVersion version) { + return version.major_value(); + } + static int16_t minor_value(net::HttpVersion version) { + return version.minor_value(); + } + + static bool Read(network::mojom::HttpVersionDataView data, + net::HttpVersion* out); +}; + +} // namespace mojo + +#endif // SERVICES_NETWORK_PUBLIC_CPP_NETWORK_PARAM_MOJOM_TRAITS_H_
diff --git a/services/network/public/mojom/BUILD.gn b/services/network/public/mojom/BUILD.gn index 72dabae..b3da95f 100644 --- a/services/network/public/mojom/BUILD.gn +++ b/services/network/public/mojom/BUILD.gn
@@ -51,6 +51,7 @@ # cause problems. See https://crbug.com/822732. mojom("websocket_mojom") { sources = [ + "network_param.mojom", "websocket.mojom", ] @@ -81,7 +82,6 @@ "http_request_headers.mojom", "network_change_manager.mojom", "network_context.mojom", - "network_param.mojom", "network_service.mojom", "network_service_test.mojom", "network_types.mojom",
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom index e4fc852d..3b47004 100644 --- a/services/network/public/mojom/network_context.mojom +++ b/services/network/public/mojom/network_context.mojom
@@ -312,6 +312,14 @@ mojo_base.mojom.Time end_time, ClearDataFilter? filter) => (); + // Clears the host cache. This will affect all NetworkContexts that share the + // same HostResolved as the NetworkContext this is called on. + // + // If a non-null |filter| is specified, will clear only entries for domains + // matching the filter. Filtering by origins is not supported. If |filter| is + // non-null, |filter.origins| must be empty. + ClearHostCache(ClearDataFilter? filter) => (); + // Clears all entries from the HTTP Auth cache that were added since // |start_time|. Supports unbounded delete using null Time value. ClearHttpAuthCache(mojo_base.mojom.Time start_time) => (); @@ -419,7 +427,7 @@ // configuration summary written out at the end of the log. CreateNetLogExporter(NetLogExporter& exporter); - // Enables/Disables blocking of third-party cookies. + // Enables/Disables blocking of third-party cookies. BlockThirdPartyCookies(bool block); [Sync]
diff --git a/services/network/public/mojom/network_param.mojom b/services/network/public/mojom/network_param.mojom index e68c575..1feb2ea 100644 --- a/services/network/public/mojom/network_param.mojom +++ b/services/network/public/mojom/network_param.mojom
@@ -13,6 +13,11 @@ [Native] struct CertVerifyResult; +struct HttpVersion { + uint16 major_value; + uint16 minor_value; +}; + [Native] struct HostPortPair;
diff --git a/services/network/public/mojom/websocket.mojom b/services/network/public/mojom/websocket.mojom index d8d0bfa..4b16d65c 100644 --- a/services/network/public/mojom/websocket.mojom +++ b/services/network/public/mojom/websocket.mojom
@@ -5,6 +5,7 @@ module network.mojom; import "url/mojom/url.mojom"; +import "services/network/public/mojom/network_param.mojom"; enum WebSocketMessageType { CONTINUATION, @@ -29,8 +30,10 @@ struct WebSocketHandshakeResponse { url.mojom.Url url; + HttpVersion http_version; int32 status_code; string status_text; + HostPortPair socket_address; array<HttpHeader> headers; string headers_text; }; @@ -45,8 +48,8 @@ // Notify the renderer that the browser has finished an opening handshake. // This message precedes AddChannelResponse. - // This message is for showing the response in the inspector and - // can be omitted if the inspector is not active. + // |response| may contains cookie-related headers when the client has + // an access to raw cookie information. OnFinishOpeningHandshake(WebSocketHandshakeResponse response); // Response to an AddChannelRequest. |selected_protocol| is the sub-protocol
diff --git a/services/network/test/test_network_context.h b/services/network/test/test_network_context.h index 0c88dd04..9eb169a2 100644 --- a/services/network/test/test_network_context.h +++ b/services/network/test/test_network_context.h
@@ -52,6 +52,8 @@ base::Time end_time, mojom::ClearDataFilterPtr filter, ClearChannelIdsCallback callback) override {} + void ClearHostCache(mojom::ClearDataFilterPtr filter, + ClearHostCacheCallback callback) override {} void ClearHttpAuthCache(base::Time start_time, ClearHttpAuthCacheCallback callback) override {} void ClearReportingCacheReports(
diff --git a/services/network/url_request_context_builder_mojo.cc b/services/network/url_request_context_builder_mojo.cc index 9ddd60e..fe8cd64 100644 --- a/services/network/url_request_context_builder_mojo.cc +++ b/services/network/url_request_context_builder_mojo.cc
@@ -37,13 +37,14 @@ mojom::NetworkContextParams* params, bool quic_disabled, net::NetLog* net_log, + net::HostResolver* host_resolver, net::NetworkQualityEstimator* network_quality_estimator) { return NetworkContext::ApplyContextParamsToBuilder( - this, params, quic_disabled, net_log, network_quality_estimator, - nullptr, /* sth_distributor */ - nullptr, /* out_ct_tree_tracker */ - nullptr, /* out_require_ct_delegate */ - nullptr, /* out_certificate_report_sender */ + this, params, quic_disabled, net_log, host_resolver, + network_quality_estimator, nullptr, /* sth_distributor */ + nullptr, /* out_ct_tree_tracker */ + nullptr, /* out_require_ct_delegate */ + nullptr, /* out_certificate_report_sender */ nullptr /* out_static_user_agent_settings */); }
diff --git a/services/network/url_request_context_builder_mojo.h b/services/network/url_request_context_builder_mojo.h index d7262117..ff75f34a 100644 --- a/services/network/url_request_context_builder_mojo.h +++ b/services/network/url_request_context_builder_mojo.h
@@ -59,6 +59,7 @@ mojom::NetworkContextParams* params, bool quic_disabled, net::NetLog* net_log, + net::HostResolver* host_resolver, net::NetworkQualityEstimator* network_quality_estimator); private:
diff --git a/services/network/websocket.cc b/services/network/websocket.cc index 0e19abb..68fd1522 100644 --- a/services/network/websocket.cc +++ b/services/network/websocket.cc
@@ -225,26 +225,26 @@ void WebSocket::WebSocketEventHandler::OnFinishOpeningHandshake( std::unique_ptr<net::WebSocketHandshakeResponseInfo> response) { - bool should_send = impl_->delegate_->CanReadRawCookies(); - DVLOG(3) << "WebSocketEventHandler::OnFinishOpeningHandshake " - << reinterpret_cast<void*>(this) << " should_send=" << should_send; - - if (!should_send) - return; + << reinterpret_cast<void*>(this) + << " CanReadRawCookies=" << impl_->delegate_->CanReadRawCookies(); mojom::WebSocketHandshakeResponsePtr response_to_pass( mojom::WebSocketHandshakeResponse::New()); response_to_pass->url.Swap(&response->url); response_to_pass->status_code = response->headers->response_code(); response_to_pass->status_text = response->headers->GetStatusText(); + response_to_pass->http_version = response->headers->GetHttpVersion(); + response_to_pass->socket_address = response->socket_address; size_t iter = 0; std::string name, value; while (response->headers->EnumerateHeaderLines(&iter, &name, &value)) { - mojom::HttpHeaderPtr header(mojom::HttpHeader::New()); - header->name = name; - header->value = value; - response_to_pass->headers.push_back(std::move(header)); + if (impl_->delegate_->CanReadRawCookies() || + !net::HttpResponseHeaders::IsCookieResponseHeader(name)) { + // We drop cookie-related headers such as "set-cookie" when the + // renderer doesn't have access. + response_to_pass->headers.push_back(mojom::HttpHeader::New(name, value)); + } } response_to_pass->headers_text = net::HttpUtil::ConvertHeadersBackToHTTPResponse(
diff --git a/services/service_manager/public/cpp/service.gni b/services/service_manager/public/cpp/service.gni index 73ecc4a..58882d77 100644 --- a/services/service_manager/public/cpp/service.gni +++ b/services/service_manager/public/cpp/service.gni
@@ -84,7 +84,6 @@ data_deps = service_data_deps deps = [ - "//build/config:exe_and_shlib_deps", "//services/service_manager/public/cpp/standalone_service:main", ]
diff --git a/services/service_manager/tests/connect/BUILD.gn b/services/service_manager/tests/connect/BUILD.gn index 0c24718..34d8023 100644 --- a/services/service_manager/tests/connect/BUILD.gn +++ b/services/service_manager/tests/connect/BUILD.gn
@@ -150,7 +150,6 @@ deps = [ ":interfaces", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//services/service_manager/public/cpp", "//services/service_manager/public/cpp/standalone_service:main",
diff --git a/services/service_manager/tests/lifecycle/BUILD.gn b/services/service_manager/tests/lifecycle/BUILD.gn index 310a115d..c28db0a 100644 --- a/services/service_manager/tests/lifecycle/BUILD.gn +++ b/services/service_manager/tests/lifecycle/BUILD.gn
@@ -132,7 +132,6 @@ deps = [ ":app_client", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//services/service_manager/public/cpp", "//services/service_manager/public/cpp/standalone_service:main",
diff --git a/services/service_manager/tests/service_manager/BUILD.gn b/services/service_manager/tests/service_manager/BUILD.gn index cb9cffc..887ee2e7 100644 --- a/services/service_manager/tests/service_manager/BUILD.gn +++ b/services/service_manager/tests/service_manager/BUILD.gn
@@ -57,7 +57,6 @@ deps = [ ":interfaces", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//services/service_manager/public/cpp", "//services/service_manager/public/cpp/standalone_service:main",
diff --git a/services/ui/ws2/client_window.cc b/services/ui/ws2/client_window.cc index 9239e22..c6bb5330 100644 --- a/services/ui/ws2/client_window.cc +++ b/services/ui/ws2/client_window.cc
@@ -144,10 +144,7 @@ return; } - if (HandleInterceptedKeyEvent(event)) - return; - - if (ShouldIgnoreEvent(*event)) + if (HandleInterceptedEvent(event) || ShouldIgnoreEvent(*event)) return; auto* owning = client_window_->owning_window_service_client(); @@ -184,10 +181,14 @@ // window() is the the target. return true; } + return ShouldIgnoreEventType(event.type()); + } + + bool ShouldIgnoreEventType(EventType type) const { // WindowTreeClient takes care of sending ET_MOUSE_CAPTURE_CHANGED at the // right point. The enter events are effectively synthetic, and indirectly // generated in the client as the result of a move event. - switch (event.type()) { + switch (type) { case ET_MOUSE_CAPTURE_CHANGED: case ET_MOUSE_ENTERED: case ET_POINTER_CAPTURE_CHANGED: @@ -199,16 +200,16 @@ return false; } - private: - // If |event| is a KeyEvent that needs to be handled because a client - // intercepts events, then true is returned and the event is handled. - // Otherwise returns false. - bool HandleInterceptedKeyEvent(Event* event) { - if (!event->IsKeyEvent()) + // If |window| identifies an embedding and the owning client intercepts + // events, this forwards to the owner and returns true. Otherwise returns + // false. + bool HandleInterceptedEvent(Event* event) { + if (ShouldIgnoreEventType(event->type())) return false; - // KeyEvents do not go through through ClientWindowTargeter. As a result - // ClientWindowEventHandler has to check for a client intercepting events. + // KeyEvents, and events when there is capture, do not go through through + // ClientWindowTargeter. As a result ClientWindowEventHandler has to check + // for a client intercepting events. if (client_window_->DoesOwnerInterceptEvents()) { client_window_->owning_window_service_client()->SendEventToClient( window(), *event); @@ -218,6 +219,7 @@ return false; } + private: ClientWindow* const client_window_; DISALLOW_COPY_AND_ASSIGN(ClientWindowEventHandler); @@ -304,6 +306,9 @@ return; } + if (HandleInterceptedEvent(event)) + return; + if (!event->IsLocatedEvent()) { ClientWindowEventHandler::OnEvent(event); return;
diff --git a/services/ui/ws2/window_service_client_unittest.cc b/services/ui/ws2/window_service_client_unittest.cc index da1ace3d..5decebc6 100644 --- a/services/ui/ws2/window_service_client_unittest.cc +++ b/services/ui/ws2/window_service_client_unittest.cc
@@ -697,6 +697,51 @@ LocatedEventToEventTypeAndLocation(drag_event.event.get())); } +TEST(WindowServiceClientTest, InterceptEventsOnEmbeddedWindowWithCapture) { + EventRecordingWindowDelegate window_delegate; + WindowServiceTestSetup setup; + aura::Window* window = setup.client_test_helper()->NewWindow(); + ASSERT_TRUE(window); + setup.delegate()->set_delegate_for_next_top_level(&window_delegate); + aura::Window* top_level = setup.client_test_helper()->NewTopLevelWindow(); + ASSERT_TRUE(top_level); + top_level->AddChild(window); + top_level->Show(); + window->Show(); + + // Create an embedding, and a new window in the embedding. + std::unique_ptr<EmbeddingHelper> embedding_helper = + setup.CreateEmbedding(window, mojom::kEmbedFlagEmbedderInterceptsEvents); + ASSERT_TRUE(embedding_helper); + aura::Window* window_in_child = + embedding_helper->client_test_helper->NewWindow(); + ASSERT_TRUE(window_in_child); + window_in_child->Show(); + window->AddChild(window_in_child); + EXPECT_TRUE( + embedding_helper->client_test_helper->SetCapture(window_in_child)); + + // Do an initial move (which generates some additional events) and clear + // everything out. + test::EventGenerator event_generator(setup.root()); + event_generator.MoveMouseTo(5, 5); + setup.window_tree_client()->ClearInputEvents(); + window_delegate.ClearEvents(); + embedding_helper->window_tree_client.ClearInputEvents(); + + // Move the mouse. Even though the window in the embedding has capture, the + // event should go to the parent client (setup.window_tree_client()), because + // the embedding was created such that the embedder (parent) intercepts the + // events. + event_generator.MoveMouseTo(6, 6); + EXPECT_TRUE(window_delegate.events().empty()); + EXPECT_EQ("POINTER_MOVED", + EventToEventType( + setup.window_tree_client()->PopInputEvent().event.get())); + EXPECT_TRUE(setup.window_tree_client()->input_events().empty()); + EXPECT_TRUE(embedding_helper->window_tree_client.input_events().empty()); +} + TEST(WindowServiceClientTest, PointerDownResetOnCaptureChange) { WindowServiceTestSetup setup; aura::Window* window = setup.client_test_helper()->NewWindow();
diff --git a/skia/BUILD.gn b/skia/BUILD.gn index 294b9ac..4aefafd 100644 --- a/skia/BUILD.gn +++ b/skia/BUILD.gn
@@ -805,7 +805,6 @@ deps = [ ":skia", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -820,7 +819,6 @@ ":skia", "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/storage/browser/BUILD.gn b/storage/browser/BUILD.gn index 80bd20e..30efc22 100644 --- a/storage/browser/BUILD.gn +++ b/storage/browser/BUILD.gn
@@ -232,7 +232,6 @@ deps = [ ":browser", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//storage/common", ]
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html index e7757275..9bc95a4 100644 --- a/styleguide/c++/c++11.html +++ b/styleguide/c++/c++11.html
@@ -704,6 +704,14 @@ <td></td> </tr> +<tr> +<td>Reverse Iterator Adaptor</td> +<td><code>std::make_reverse_iterator()</code></td> +<td>For a given iterator, deduces the type of a corresponding reverse iterator and constructs it.</td> +<td><a href="http://en.cppreference.com/w/cpp/iterator/make_reverse_iterator">std::make_reverse_iterator</a></td> +<td>Useful to reduce boilerplate when constructing reverse iterators. The alternative is using <code>std::reverse_iterator<T>(i)</code> where <code>T</code> is the, usually long, type of the iterator <code>i</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/qOE1XA0b6Dk">Discussion thread</a></td> +</tr> + </tbody> </table>
diff --git a/testing/BUILD.gn b/testing/BUILD.gn index 70b4201..8e5c39f8 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn
@@ -17,9 +17,6 @@ sources = [ "empty_main.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } # Targets needed for isolate script to execute.
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 1104ff81..a864618e 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -128,8 +128,7 @@ }, "test": "angle_deqp_gles2_tests" } - ], - "isolated_scripts": [] + ] }, "Android FYI 64 Vk Release (Nexus 5X)": { "gtest_tests": [ @@ -258,8 +257,7 @@ }, "test": "angle_deqp_gles2_tests" } - ], - "isolated_scripts": [] + ] }, "Android FYI Release (NVIDIA Shield TV)": { "gtest_tests": [ @@ -2788,8 +2786,7 @@ }, "test": "angle_deqp_gles3_tests" } - ], - "isolated_scripts": [] + ] }, "GPU FYI Linux Builder": {}, "GPU FYI Linux Builder (dbg)": {}, @@ -3393,8 +3390,7 @@ }, "test": "angle_unittests" } - ], - "isolated_scripts": [] + ] }, "Linux FYI Release (AMD R7 240)": { "gtest_tests": [ @@ -3412,7 +3408,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_unittests" }, @@ -3428,7 +3425,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_white_box_tests" }, @@ -3449,7 +3447,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "browser_tests" }, @@ -3466,7 +3465,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gl_tests" }, @@ -3482,7 +3482,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gles2_conform_test" }, @@ -3495,7 +3496,8 @@ "os": "Ubuntu", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "swiftshader_unittests" } @@ -4819,8 +4821,7 @@ }, "test": "angle_deqp_gles2_tests" } - ], - "isolated_scripts": [] + ] }, "Linux FYI dEQP Release (NVIDIA)": { "gtest_tests": [ @@ -4919,8 +4920,7 @@ }, "test": "angle_deqp_gles3_tests" } - ], - "isolated_scripts": [] + ] }, "Mac FYI Debug (Intel)": { "gtest_tests": [ @@ -6143,7 +6143,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_end2end_tests" }, @@ -6161,7 +6162,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_unittests" }, @@ -6182,7 +6184,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "browser_tests" }, @@ -6200,7 +6203,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gl_tests" }, @@ -6217,7 +6221,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gl_unittests" }, @@ -6234,7 +6239,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gles2_conform_test" }, @@ -6248,7 +6254,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gpu_unittests" }, @@ -6266,7 +6273,8 @@ "os": "Mac-10.13.4", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "services_unittests" } @@ -9218,8 +9226,7 @@ }, "test": "angle_deqp_gles3_tests" } - ], - "isolated_scripts": [] + ] }, "Mac FYI dEQP Release Intel": { "gtest_tests": [ @@ -9277,8 +9284,7 @@ }, "test": "angle_deqp_gles3_tests" } - ], - "isolated_scripts": [] + ] }, "Mac Pro FYI Release (AMD)": { "gtest_tests": [ @@ -9295,7 +9301,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_end2end_tests" }, @@ -9312,7 +9319,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "angle_unittests" }, @@ -9332,7 +9340,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "browser_tests" }, @@ -9349,7 +9358,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gl_tests" }, @@ -9365,7 +9375,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gl_unittests" }, @@ -9381,7 +9392,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gles2_conform_test" }, @@ -9394,7 +9406,8 @@ "os": "Mac-10.12", "pool": "Chrome-GPU" } - ] + ], + "expiration": 10800 }, "test": "gpu_unittests" } @@ -9686,10 +9699,7 @@ } ] }, - "Optional Android Release (Nexus 5X)": { - "gtest_tests": [], - "isolated_scripts": [] - }, + "Optional Android Release (Nexus 5X)": {}, "Optional Linux Release (Intel HD 630)": { "gtest_tests": [ { @@ -10431,6 +10441,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "8086:5912-23.20.16.4877", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -10467,22 +10493,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "8086:5912-23.20.16.4877", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -10741,6 +10751,31 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:1cb3-23.21.13.8816", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test", + "trigger_script": { + "args": [ + "--multiple-trigger-configs", + "[{\"gpu\": \"10de:1cb3-23.21.13.8816\", \"os\": \"Windows-10\", \"pool\": \"Chrome-GPU\"}]", + "--multiple-dimension-script-verbose", + "True" + ], + "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" + } + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -10795,31 +10830,6 @@ } }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-23.21.13.8816", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test", - "trigger_script": { - "args": [ - "--multiple-trigger-configs", - "[{\"gpu\": \"10de:1cb3-23.21.13.8816\", \"os\": \"Windows-10\", \"pool\": \"Chrome-GPU\"}]", - "--multiple-dimension-script-verbose", - "True" - ], - "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" - } - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -11290,6 +11300,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:1cb3-23.21.13.8816", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -11326,22 +11352,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-23.21.13.8816", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -11932,6 +11942,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "8086:5912-24.20.100.6025", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -11968,22 +11994,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "8086:5912-24.20.100.6025", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -12394,7 +12404,6 @@ ] }, "Win10 FYI Exp Release (NVIDIA)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [ @@ -12583,6 +12592,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "8086:5912-23.20.16.4877", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -12619,22 +12644,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "8086:5912-23.20.16.4877", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -13334,6 +13343,31 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:1cb3-23.21.13.8816", + "os": "Windows-10", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test", + "trigger_script": { + "args": [ + "--multiple-trigger-configs", + "[{\"gpu\": \"10de:1cb3-23.21.13.8816\", \"os\": \"Windows-10\", \"pool\": \"Chrome-GPU\"}]", + "--multiple-dimension-script-verbose", + "True" + ], + "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" + } + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -13388,31 +13422,6 @@ } }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-23.21.13.8816", - "os": "Windows-10", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test", - "trigger_script": { - "args": [ - "--multiple-trigger-configs", - "[{\"gpu\": \"10de:1cb3-23.21.13.8816\", \"os\": \"Windows-10\", \"pool\": \"Chrome-GPU\"}]", - "--multiple-dimension-script-verbose", - "True" - ], - "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" - } - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -14248,8 +14257,7 @@ }, "test": "angle_deqp_gles2_tests" } - ], - "isolated_scripts": [] + ] }, "Win10 FYI dEQP Release (NVIDIA)": { "gtest_tests": [ @@ -14386,8 +14394,7 @@ }, "test": "angle_deqp_gles3_tests" } - ], - "isolated_scripts": [] + ] }, "Win7 ANGLE Tryserver (AMD)": { "gtest_tests": [ @@ -14620,6 +14627,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "1002:6613", + "os": "Windows-2008ServerR2-SP1", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -14656,22 +14679,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "1002:6613", - "os": "Windows-2008ServerR2-SP1", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -15239,6 +15246,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "1002:6613", + "os": "Windows-2008ServerR2-SP1", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -15275,22 +15298,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "1002:6613", - "os": "Windows-2008ServerR2-SP1", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -15955,6 +15962,31 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:1cb3-23.21.13.8792", + "os": "Windows-2008ServerR2-SP1", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test", + "trigger_script": { + "args": [ + "--multiple-trigger-configs", + "[{\"gpu\": \"10de:1cb3-23.21.13.8792\", \"os\": \"Windows-2008ServerR2-SP1\", \"pool\": \"Chrome-GPU\"}]", + "--multiple-dimension-script-verbose", + "True" + ], + "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" + } + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -16009,31 +16041,6 @@ } }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-23.21.13.8792", - "os": "Windows-2008ServerR2-SP1", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test", - "trigger_script": { - "args": [ - "--multiple-trigger-configs", - "[{\"gpu\": \"10de:1cb3-23.21.13.8792\", \"os\": \"Windows-2008ServerR2-SP1\", \"pool\": \"Chrome-GPU\"}]", - "--multiple-dimension-script-verbose", - "True" - ], - "script": "//testing/trigger_scripts/trigger_multiple_dimensions.py" - } - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -16737,8 +16744,7 @@ }, "test": "angle_deqp_gles2_tests" } - ], - "isolated_scripts": [] + ] }, "Win7 FYI x64 Release (NVIDIA)": { "gtest_tests": [ @@ -16881,6 +16887,22 @@ }, { "args": [ + "--use-gpu-in-tests" + ], + "swarming": { + "can_use_on_swarming_builders": true, + "dimension_sets": [ + { + "gpu": "10de:1cb3-23.21.13.8792", + "os": "Windows-2008ServerR2-SP1", + "pool": "Chrome-GPU" + } + ] + }, + "test": "gles2_conform_test" + }, + { + "args": [ "--use-gpu-in-tests", "--use-angle=d3d9" ], @@ -16917,22 +16939,6 @@ "test": "gles2_conform_test" }, { - "args": [ - "--use-gpu-in-tests" - ], - "swarming": { - "can_use_on_swarming_builders": true, - "dimension_sets": [ - { - "gpu": "10de:1cb3-23.21.13.8792", - "os": "Windows-2008ServerR2-SP1", - "pool": "Chrome-GPU" - } - ] - }, - "test": "gles2_conform_test" - }, - { "swarming": { "can_use_on_swarming_builders": true, "dimension_sets": [ @@ -17407,8 +17413,5 @@ } ] }, - "Win7 FYI x64 dEQP Release (NVIDIA)": { - "gtest_tests": [], - "isolated_scripts": [] - } + "Win7 FYI x64 dEQP Release (NVIDIA)": {} }
diff --git a/testing/buildbot/chromium.gpu.json b/testing/buildbot/chromium.gpu.json index cd56b76..73af154 100644 --- a/testing/buildbot/chromium.gpu.json +++ b/testing/buildbot/chromium.gpu.json
@@ -2,7 +2,6 @@ "AAAAA1 AUTOGENERATED FILE DO NOT EDIT": {}, "AAAAA2 See gpu/generate_buildbot_json.py to make changes": {}, "Android Release (Nexus 5X)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [
diff --git a/testing/buildbot/client.v8.fyi.json b/testing/buildbot/client.v8.fyi.json index 5849a42..8e48b781 100644 --- a/testing/buildbot/client.v8.fyi.json +++ b/testing/buildbot/client.v8.fyi.json
@@ -2,7 +2,6 @@ "AAAAA1 AUTOGENERATED FILE DO NOT EDIT": {}, "AAAAA2 See gpu/generate_buildbot_json.py to make changes": {}, "Android V8 FYI Release (Nexus 5X)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [ @@ -230,7 +229,6 @@ ] }, "Linux V8 FYI Release (NVIDIA)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [ @@ -482,7 +480,6 @@ ] }, "Linux V8 FYI Release - concurrent marking (NVIDIA)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [ @@ -734,7 +731,6 @@ ] }, "Mac V8 FYI Release (Intel)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [ @@ -1033,7 +1029,6 @@ ] }, "Win V8 FYI Release (NVIDIA)": { - "gtest_tests": [], "isolated_scripts": [ { "args": [
diff --git a/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter b/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter index 6023199..f5bc4a47 100644 --- a/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter +++ b/testing/buildbot/filters/mojo.fyi.network_browser_tests.filter
@@ -10,7 +10,6 @@ -DomainReliabilityBrowserTest.Upload -EnabledSignInIsolationBrowserTest.SyntheticTrial -ExtensionUnloadBrowserTest.UnloadWithContentScripts --NetInternalsTest.netInternalsSessionBandwidthSucceed -NewlibPackagedAppTest.SuccessfulLoad -PolicyTest.DefaultCookiesSetting -PreviewsOptimizationGuideBrowserTest.NoScriptPreviewsEnabledByWhitelist @@ -22,6 +21,12 @@ -WebstoreInstallerBrowserTest.SimultaneousInstall -WebViewTest.WebViewInBackgroundPage +# about:net-internals should be largely removed before shipping the network +# service. +# https://crbug.com/678391 +-NetInternalsTest.netInternalsSessionBandwidthSucceed +-NetInternalsTest.netInternalsDnsViewIncognitoClears + # Move ChromeExpectCTReporter to services/network # https://crbug.com/844032 -ExpectCTBrowserTest.TestDynamicExpectCTHeaderProcessing @@ -137,12 +142,9 @@ -BackgroundXhrTest.HttpAuth -BackgroundXhrTest.TlsClientAuth -# https://crbug.com/721400 -# WebSocket with the network service --DeclarativeNetRequestResourceTypeBrowserTest.Test2/1 --DeclarativeNetRequestResourceTypeBrowserTest.Test2/0 +# https://crbug.com/841827 +# WebRequest API + WebSocket + OnAuthRequired -ExtensionWebRequestApiTest.WebSocketRequestAuthRequired --ExtensionWebRequestApiTest.WebSocketRequest # http://crbug.com/705114 # Remove streams concept from code and replace with data pipe passing.
diff --git a/testing/test.gni b/testing/test.gni index 01c15c8..5764c3d 100644 --- a/testing/test.gni +++ b/testing/test.gni
@@ -134,10 +134,7 @@ if (!defined(invoker.use_default_launcher) || invoker.use_default_launcher) { - deps += [ - "//build/config:exe_and_shlib_deps", - "//testing/android/native_test:native_test_native_code", - ] + deps += [ "//testing/android/native_test:native_test_native_code" ] } } unittest_apk(_apk_target) { @@ -283,7 +280,6 @@ testonly = true forward_variables_from(invoker, "*") output_name = _exec_target - deps += [ "//build/config:exe_and_shlib_deps" ] } package(_pkg_target) { @@ -334,14 +330,6 @@ } extra_substitutions += [ "GTEST_BUNDLE_ID_SUFFIX=$_bundle_id_suffix" ] - if (!defined(deps)) { - deps = [] - } - deps += [ - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", - ] if (!defined(bundle_deps)) { bundle_deps = [] } @@ -376,23 +364,17 @@ output_name = target_name write_runtime_deps = _runtime_deps_file data += [ _runtime_deps_file ] - deps += [ - ":$_gen_runner_target", - "//build/config:exe_and_shlib_deps", - ] + deps += [ ":$_gen_runner_target" ] } } else { executable(target_name) { - deps = [] - forward_variables_from(invoker, "*") + if (!defined(deps)) { + deps = [] + } testonly = true deps += [ - # All shared libraries must have the sanitizer deps to properly link in - # asan mode (this target will be empty in other cases). - "//build/config:exe_and_shlib_deps", - # Give tests the default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ]
diff --git a/third_party/WebKit/LayoutTests/LeakExpectations b/third_party/WebKit/LayoutTests/LeakExpectations index d87b3e1..8312998e 100644 --- a/third_party/WebKit/LayoutTests/LeakExpectations +++ b/third_party/WebKit/LayoutTests/LeakExpectations
@@ -76,6 +76,7 @@ crbug.com/836278 [ Linux ] virtual/threaded/external/wpt/offscreen-canvas/convert-to-blob/offscreencanvas.convert.to.blob.html [ Pass Leak ] crbug.com/847868 [ Linux ] fast/events/drag-remove-iframe-crash.html [ Pass Leak ] +crbug.com/847868 [ Linux ] virtual/mouseevent_fractional/fast/events/drag-remove-iframe-crash.html [ Pass Leak ] ########################################################################### # WARNING: Memory leaks must be fixed asap. Sheriff is expected to revert #
diff --git a/third_party/WebKit/LayoutTests/MSANExpectations b/third_party/WebKit/LayoutTests/MSANExpectations index bd284ea..2826881 100644 --- a/third_party/WebKit/LayoutTests/MSANExpectations +++ b/third_party/WebKit/LayoutTests/MSANExpectations
@@ -86,6 +86,7 @@ crbug.com/760543 [ Linux ] http/tests/devtools/tracing/timeline-paint/timeline-paint-with-layout-invalidations-on-deleted-node.js [ Pass Timeout ] crbug.com/760543 [ Linux ] http/tests/devtools/tracing/timeline-time/timeline-usertiming.js [ Pass Timeout ] crbug.com/760543 [ Linux ] http/tests/devtools/tracing/timeline-paint/timeline-paint.js [ Pass Timeout ] +crbug.com/760543 [ Linux ] http/tests/devtools/oopif/oopif-performance-cpu-profiles.js [ Pass Timeout ] # Timing out consistenly on WebKit Linux Trusty MSAN crbug.com/798957 [ Linux ] http/tests/devtools/audits2/audits2-limited-run.js [ Skip ]
diff --git a/third_party/WebKit/LayoutTests/NeverFixTests b/third_party/WebKit/LayoutTests/NeverFixTests index 527ef2ff..b1f254b 100644 --- a/third_party/WebKit/LayoutTests/NeverFixTests +++ b/third_party/WebKit/LayoutTests/NeverFixTests
@@ -115,6 +115,9 @@ # Only run fake-Android tests on Linux [ Mac Win ] virtual/android [ WontFix ] +# Android doesn't support plugins +virtual/android/fullscreen/rendering/backdrop-object.html [ WontFix ] + # We only run it through the virtual gpu test suite. fast/canvas/canvas-lost-gpu-context.html [ WontFix ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index acb4fa71..d4e8b8a 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -2431,6 +2431,23 @@ crbug.com/249112 external/wpt/css/css-flexbox/flex-minimum-width-flex-items-005.xht [ Failure ] crbug.com/249112 external/wpt/css/css-flexbox/flex-minimum-width-flex-items-007.xht [ Failure ] +crbug.com/595206 http/tests/devtools/sources/debugger-ui/watch-expressions-preserve-expansion.js [ Skip ] +crbug.com/595206 http/tests/inspector-protocol/terminate-execution-with-fetch-callbacks.js [ Skip ] +crbug.com/595206 inspector-protocol/console/console-let-const-with-api.js [ Skip ] +crbug.com/595206 inspector-protocol/debugger/debugger-scope-skip-variables-with-empty-name.js [ Skip ] +crbug.com/595206 inspector-protocol/debugger/setScriptSource.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-await-promise.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-callFunctionOn-async.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-clear-of-command-line-api.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-console-line-and-column.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-console-log-doesnt-run-microtasks.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-evaluate-async.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-evaluate-in-default-context.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-get-properties-on-proxy.js [ Skip ] +crbug.com/595206 inspector-protocol/runtime/runtime-property-on-console-proto.js [ Skip ] +crbug.com/595206 inspector-protocol/sessions/runtime-evaluate.js [ Skip ] +crbug.com/595206 inspector-protocol/target/target-send-message.js [ Skip ] + # Not implemented yet crbug.com/336604 external/wpt/css/css-flexbox/flexbox_visibility-collapse-line-wrapping.html [ Failure ] crbug.com/336604 external/wpt/css/css-flexbox/flexbox_visibility-collapse.html [ Failure ] @@ -2620,8 +2637,6 @@ crbug.com/525296 fast/css/font-load-while-styleresolver-missing.html [ Crash Failure Pass ] -crbug.com/240576 external/wpt/fullscreen/api/element-ready-check-containing-iframe-manual.html [ Timeout Failure Pass ] - crbug.com/538717 [ Win Mac Linux ] http/tests/permissions/chromium/test-request-multiple-window.html [ Failure Pass Timeout ] crbug.com/538717 [ Win Mac Linux ] http/tests/permissions/chromium/test-request-multiple-worker.html [ Failure Pass Timeout ] crbug.com/538717 [ Win Mac Linux ] http/tests/permissions/chromium/test-request-multiple-sharedworker.html [ Failure Pass Timeout ] @@ -3325,7 +3340,6 @@ crbug.com/626703 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/writing-modes-3/logical-physical-mapping-001.html [ Failure ] crbug.com/626703 external/wpt/encoding/eof-utf-8-three.html [ Failure ] crbug.com/626703 external/wpt/encoding/eof-utf-8-two.html [ Failure ] -crbug.com/626703 external/wpt/fullscreen/api/document-exit-fullscreen-nested-in-iframe-manual.html [ Timeout Pass ] crbug.com/626703 external/wpt/fullscreen/api/element-request-fullscreen-two-iframes-manual.html [ Timeout ] crbug.com/626703 external/wpt/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-global-scope.html [ Timeout ] crbug.com/626703 external/wpt/html/browsers/the-window-object/window-open-noopener.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json b/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json index 24814508..ffa1fb0 100644 --- a/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json +++ b/third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json
@@ -3895,6 +3895,12 @@ {} ] ], + "fullscreen/api/promises-resolve-manual.html": [ + [ + "/fullscreen/api/promises-resolve-manual.html", + {} + ] + ], "fullscreen/model/move-to-fullscreen-iframe-manual.html": [ [ "/fullscreen/model/move-to-fullscreen-iframe-manual.html", @@ -141202,11 +141208,6 @@ {} ] ], - "fullscreen/interfaces-expected.txt": [ - [ - {} - ] - ], "fullscreen/model/move-to-fullscreen-iframe-manual-expected.txt": [ [ {} @@ -200114,6 +200115,12 @@ {} ] ], + "fullscreen/api/promises-reject.html": [ + [ + "/fullscreen/api/promises-reject.html", + {} + ] + ], "fullscreen/interfaces.html": [ [ "/fullscreen/interfaces.html", @@ -279682,7 +279689,7 @@ "support" ], "css/build-css-testsuites.sh": [ - "0f1d955402449b61d134265ea5962d6ed93836f4", + "f08c6940dff13aad1b6c5fc81c08abcaa8aafc67", "support" ], "css/css-align/OWNERS": [ @@ -340182,7 +340189,7 @@ "manual" ], "fullscreen/api/document-onfullscreenerror.html": [ - "ed8836f302fffdaa407bf9bf7799effa17fb6823", + "1dd69713aaa8030892e68cfb0fec2fccb8863723", "testharness" ], "fullscreen/api/element-ready-check-allowed-cross-origin-manual.sub.html": [ @@ -340266,7 +340273,7 @@ "manual" ], "fullscreen/api/element-request-fullscreen-not-allowed.html": [ - "8991e8df530fa7c24a9e084f2ab17fa9c70fb120", + "5eac634c56810200d4c6a8b1c3c6f547ba1e7dc9", "testharness" ], "fullscreen/api/element-request-fullscreen-null-ns-manual.html": [ @@ -340290,7 +340297,7 @@ "support" ], "fullscreen/api/element-request-fullscreen-timing-manual.html": [ - "4ecd76a2ef773172d45f656f52a7358be2a4568d", + "48df66c401edcba47d1336313833a24d5e3d211d", "manual" ], "fullscreen/api/element-request-fullscreen-top-manual.html": [ @@ -340321,6 +340328,14 @@ "9d9bec938f185b2461da4d00a5683ad5d07ee577", "testharness" ], + "fullscreen/api/promises-reject.html": [ + "2bc121b4bc0a397f2f25c5fca1aa32fa8727b776", + "testharness" + ], + "fullscreen/api/promises-resolve-manual.html": [ + "ec9276eb2b2ab279a84aa06a644b4333e46e970d", + "manual" + ], "fullscreen/api/resources/attempt-fullscreen.html": [ "33e277b3f06677f14eed442ecce76b408e7e006e", "support" @@ -340329,10 +340344,6 @@ "ba59db02939bc5ba00825befe4777c66cee64b4c", "support" ], - "fullscreen/interfaces-expected.txt": [ - "5cda9256ff1246215269ba147752ee42e08a1f67", - "support" - ], "fullscreen/interfaces.html": [ "f6f0dbc8a505896a0e7ec7aca2746bbd5c1eb7d9", "testharness" @@ -340390,7 +340401,7 @@ "manual" ], "fullscreen/trusted-click.js": [ - "e401e8e8bcd97446991398d6021a9bd712c923c5", + "069f4d40fbcb4e933d4f651d3220820836615660", "support" ], "gamepad/OWNERS": [ @@ -361502,11 +361513,11 @@ "testharness" ], "media-capabilities/idlharness-expected.txt": [ - "b1684e483ab7ad5ea074e655966c26e6e70fa6b5", + "019888949f6f15017a82db75a343bfeac247f700", "support" ], "media-capabilities/idlharness.html": [ - "6cbda5261b98a04d1ad5c3c9816a443e67d7d523", + "47b8077cfff98cf07d5794ab32974ed4bc8d8a01", "testharness" ], "media-source/OWNERS": [ @@ -362206,7 +362217,7 @@ "testharness" ], "mediacapture-streams/MediaDevices-getUserMedia.https.html": [ - "dbd2cbacb24f088167e1c34207bea12c19f5d0e1", + "2e54bc378625fb8fa2c6c36722ee2d09a3e88729", "testharness" ], "mediacapture-streams/MediaStream-MediaElement-preload-none-manual.https.html": [ @@ -396090,7 +396101,7 @@ "support" ], "workers/opaque-origin.html": [ - "ea9b3b24c0e95ff424bb9d381b36b06df5891d30", + "7e9c9a1eab7ae17002aff672f863ed172609cf5e", "testharness" ], "workers/postMessage_DataCloneErr.htm": [
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/build-css-testsuites.sh b/third_party/WebKit/LayoutTests/external/wpt/css/build-css-testsuites.sh index b72c486..cf40f56 100755 --- a/third_party/WebKit/LayoutTests/external/wpt/css/build-css-testsuites.sh +++ b/third_party/WebKit/LayoutTests/external/wpt/css/build-css-testsuites.sh
@@ -41,12 +41,6 @@ # Install dependencies $VENV/bin/pip install -r requirements.txt - # Error if submodules are not there - if [ ! -d tools/apiclient -o ! -d tools/w3ctestlib ]; then - echo 'Please run `git submodule update --init --recursive`' - exit 1 - fi - # Run the build script $VENV/bin/python tools/build.py "$@" }
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-014.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-014.html new file mode 100644 index 0000000..d1eb4ec8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-014.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-cell</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-paint-014-ref.html"> +<meta name=assert content="Paint containment does apply to table-cell elements."> +<style> +div { + display: table-cell; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can NOT see the word FAIL below.</p> +<div><span>FAIL</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-015.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-015.html new file mode 100644 index 0000000..0e50bea --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-015.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-row-group</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-size-001-ref.html"> +<meta name=assert content="Paint containment doesn't apply to table-row-group elements."> +<style> +div { + display: table-row-group; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can see the word PASS below.</p> +<div><span>PASS</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-016.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-016.html new file mode 100644 index 0000000..309b5a08 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-016.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-header-group</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-size-001-ref.html"> +<meta name=assert content="Paint containment doesn't apply to table-header-group elements."> +<style> +div { + display: table-header-group; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can see the word PASS below.</p> +<div><span>PASS</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-017.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-017.html new file mode 100644 index 0000000..578f382 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-017.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-footer-group</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-size-001-ref.html"> +<meta name=assert content="Paint containment doesn't apply to table-footer-group elements."> +<style> +div { + display: table-footer-group; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can see the word PASS below.</p> +<div><span>PASS</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-018.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-018.html new file mode 100644 index 0000000..bf19131 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-018.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-row</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-size-001-ref.html"> +<meta name=assert content="Paint containment doesn't apply to table-row elements."> +<style> +div { + display: table-row; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can see the word PASS below.</p> +<div><span>PASS</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-019.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-019.html new file mode 100644 index 0000000..131463c4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/contain-paint-019.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Paint containment on table-caption</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-contain-1/#containment-paint"> +<link rel="match" href="reference/contain-paint-014-ref.html"> +<meta name=assert content="Paint containment does apply to table-caption elements."> +<style> +div { + display: table-caption; + contain: paint; +} +span { + position: absolute; +} +</style> + +<p>This test passes if you can NOT see the word FAIL below.</p> +<div><span>FAIL</span></div>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/reference/contain-paint-014-ref.html b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/reference/contain-paint-014-ref.html new file mode 100644 index 0000000..6617f777 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-contain/reference/contain-paint-014-ref.html
@@ -0,0 +1,5 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Containment Test: Reference file</title> +<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com"> +<p>This test passes if you can NOT see the word FAIL below.</p>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-twice-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-twice-manual.html index b5865ecb..1582488 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-twice-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/api/document-exit-fullscreen-twice-manual.html
@@ -18,7 +18,7 @@ const secondPromise = document.exitFullscreen(); assert_equals(document.fullscreenElement, div, "fullscreenElement after second exitFullscreen()"); - document.onfullscreenchange = t.step_func(() => { + document.onfullscreenchange = t.step_func(event => { assert_equals(document.fullscreenElement, null); // Ensure that there's only one fullscreenchange event. document.onfullscreenchange = t.unreached_func("second fullscreenchange event");
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-fullscreen-iframe-manual-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-fullscreen-iframe-manual-expected.txt deleted file mode 100644 index 7b307b2..0000000 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-fullscreen-iframe-manual-expected.txt +++ /dev/null
@@ -1,4 +0,0 @@ -This is a testharness.js-based test. -FAIL Moving fullscreen document's body into a fullscreen iframe assert_equals: iframe's final fullscreen element expected Element node <body></body> but got null -Harness: the test ran to completion. -
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-iframe-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-iframe-manual.html index 1d388ea..12bda5ca 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-iframe-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-iframe-manual.html
@@ -7,6 +7,7 @@ <iframe></iframe> <script> async_test(t => { + t.add_cleanup(() => document.exitFullscreen()); const div = document.querySelector("div"); const iframe = document.querySelector("iframe"); document.onfullscreenchange = t.step_func(event => { @@ -16,6 +17,9 @@ assert_equals(div.ownerDocument, document); iframe.contentDocument.body.appendChild(div); assert_not_equals(div.ownerDocument, document); + // Moving /div/ removes it from the top layer and thus the fullscreen + // element synchronously becomes null. + assert_equals(document.fullscreenElement, null); div.onfullscreenchange = t.unreached_func("fullscreenchange fired on element"); iframe.contentDocument.onfullscreenchange = t.unreached_func("fullscreenchange fired on other document");
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-inactive-document-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-inactive-document-manual.html index 5a1dd2b..8d8ad2be 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-inactive-document-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/move-to-inactive-document-manual.html
@@ -6,6 +6,7 @@ <div></div> <script> async_test(t => { + t.add_cleanup(() => document.exitFullscreen()); const div = document.querySelector("div"); document.onfullscreenchange = t.step_func(event => { const inactiveDocument = document.implementation.createDocument(null, "");
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-child-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-child-manual.html index 4c33733..ac40bb6 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-child-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-child-manual.html
@@ -10,12 +10,15 @@ <script> async_test(function(t) { + t.add_cleanup(() => document.exitFullscreen()); var parent = document.getElementById("parent"); trusted_request(t, parent); document.onfullscreenchange = t.step_func(function() { assert_equals(document.fullscreenElement, parent); parent.textContent = ""; // removes all children + // The fullscreen element should not be affected. + assert_equals(document.fullscreenElement, parent); document.onfullscreenchange = t.unreached_func("fullscreenchange event"); // A fullscreenchange event would be fired after an async section // and an animation frame task, so wait until after that.
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-first-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-first-manual.html index 16ef298f..262e325 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-first-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-first-manual.html
@@ -10,6 +10,7 @@ <script> async_test(function(t) { + t.add_cleanup(() => document.exitFullscreen()); var first = document.getElementById("first"); trusted_request(t, first); document.onfullscreenchange = t.step_func(function(event) @@ -23,6 +24,9 @@ assert_equals(document.fullscreenElement, last); assert_equals(event.target, last); first.remove(); + // Both /first/ and /last/ were removed from the top layer and + // thus the fullscreen element synchronously becomes null. + assert_equals(document.fullscreenElement, null); document.onfullscreenchange = t.step_func_done(function(event) { assert_equals(document.fullscreenElement, null);
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-last-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-last-manual.html index a7c54b6..8952b93d 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-last-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-last-manual.html
@@ -10,6 +10,7 @@ <script> async_test(function(t) { + t.add_cleanup(() => document.exitFullscreen()); var first = document.getElementById("first"); trusted_request(t, first); document.onfullscreenchange = t.step_func(function(event) @@ -23,9 +24,14 @@ assert_equals(document.fullscreenElement, last); assert_equals(event.target, last); last.remove(); + // Because /last/ was removed from the top layer, we exit + // fullscreen element synchronously. + assert_equals(document.fullscreenElement, first); document.onfullscreenchange = t.step_func_done(function(event) { - assert_equals(document.fullscreenElement, first); + // fullscreen change element should be queued against the + // document target. + assert_equals(document.fullscreenElement, null); assert_equals(event.target, document); }); });
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-parent-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-parent-manual.html index 01796f3..f505d950 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-parent-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-parent-manual.html
@@ -10,6 +10,7 @@ <script> async_test(function(t) { + t.add_cleanup(() => document.exitFullscreen()); var child = document.getElementById("child"); trusted_request(t, child); document.onfullscreenchange = t.step_func(function(event) @@ -17,6 +18,9 @@ assert_equals(document.fullscreenElement, child); assert_equals(event.target, child); child.parentNode.remove(); + // Because /child/ was removed from the top layer, the fullscreen + // element becomes null synchronously. + assert_equals(document.fullscreenElement, null); document.onfullscreenchange = t.step_func_done(function(event) { assert_equals(document.fullscreenElement, null);
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-single-manual.html b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-single-manual.html index ed0a6b7f..537d88b 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-single-manual.html +++ b/third_party/WebKit/LayoutTests/external/wpt/fullscreen/model/remove-single-manual.html
@@ -8,12 +8,16 @@ <script> async_test(function(t) { + t.add_cleanup(() => document.exitFullscreen()); var single = document.getElementById("single"); document.onfullscreenchange = t.step_func(function(event) { assert_equals(document.fullscreenElement, single); assert_equals(event.target, single); single.remove(); + // Because /single/ was removed from the top layer, the fullscreen + // element becomes null synchronously. + assert_equals(document.fullscreenElement, null); document.onfullscreenchange = t.step_func_done(function(event) { assert_equals(document.fullscreenElement, null);
diff --git a/third_party/WebKit/LayoutTests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-remove.html b/third_party/WebKit/LayoutTests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-remove.html new file mode 100644 index 0000000..c2350c3 --- /dev/null +++ b/third_party/WebKit/LayoutTests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-showModal-remove.html
@@ -0,0 +1,24 @@ +<!doctype html> +<title>dialog element: removing from document after showModal()</title> +<link rel=help href="https://html.spec.whatwg.org/multipage/interactive-elements.html#dom-dialog-showmodal"> +<link rel=help href="https://fullscreen.spec.whatwg.org/#removing-steps"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<dialog></dialog> +<script> +async_test(t => { + const dialog = document.querySelector('dialog') + dialog.showModal() + assert_true(dialog.open) + // The dialog element is now in top layer. Removing it should synchronously + // remove it from top layer, but should leave it in a strange limbo state. + dialog.addEventListener('close', t.unreached_func('close event')) + dialog.remove() + assert_true(dialog.open) + // if an event was queued, it would fire before this timeout + step_timeout(t.step_func_done(() => { + assert_true(dialog.open) + // pass if no close event was fired + })) +}) +</script>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness-expected.txt b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness-expected.txt index 64957fc..c5c0eb8 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness-expected.txt +++ b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -PASS Test IDL implementation of Media Session +PASS Test IDL implementation of Media Capabilities PASS Navigator interface: attribute mediaCapabilities PASS Unscopable handled correctly for mediaCapabilities property on Navigator PASS Navigator interface: navigator must inherit property "mediaCapabilities" with the proper type
diff --git a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness.html b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness.html index 9f2fc655..67a6294f 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness.html +++ b/third_party/WebKit/LayoutTests/external/wpt/media-capabilities/idlharness.html
@@ -30,7 +30,7 @@ promise_test(() => { return Promise.all(["/interfaces/media-capabilities.idl"].map(fetchText)) .then(doTest); -}, "Test IDL implementation of Media Session"); +}, "Test IDL implementation of Media Capabilities"); </script> <div id="log"></div> </body>
diff --git a/third_party/WebKit/LayoutTests/external/wpt/workers/opaque-origin.html b/third_party/WebKit/LayoutTests/external/wpt/workers/opaque-origin.html index 0474b97..83574b4 100644 --- a/third_party/WebKit/LayoutTests/external/wpt/workers/opaque-origin.html +++ b/third_party/WebKit/LayoutTests/external/wpt/workers/opaque-origin.html
@@ -11,6 +11,7 @@ channel.port2.postMessage(e.data); }; fetch_tests_from_worker(channel.port1); +channel.port1.start(); </script> <iframe sandbox="allow-scripts" src="support/sandboxed-tests.html?pipe=sub"></iframe> </body>
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/color-space/canvas-colorManaged-convertToBlob-roundtrip.html b/third_party/WebKit/LayoutTests/fast/canvas/color-space/canvas-colorManaged-convertToBlob-roundtrip.html new file mode 100644 index 0000000..4ad118de --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/canvas/color-space/canvas-colorManaged-convertToBlob-roundtrip.html
@@ -0,0 +1,175 @@ +<!DOCTYPE HTML> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<script> + +// No matter what is the color space and pixel format of the color managed +// canvas, toBlob() and toDataURL() always create the blob in sRGB color +// space, and respect the legacy behavior by not including any color space +// information in the blob/data url. +// https://github.com/WICG/canvas-color-space/blob/master/CanvasColorSpaceProposal.md#common-properties-of-all-color-spaces + +var opaqueReferencePxiels, transparentReferencePixels; + +function testPixels(actualPixels, refPixels, testScenario) +{ + // Plain testing requires a tolerance as high as 50 for 8-8-8-8, which does + // not leave that much to test. Instead, we narrow down the source of + // expected error. + // - Alpha values should always match. + // - Color components should be acceptably close, except for the red + // channel of the green pixel. Green has the largest change in what's + // representable between sRGB and P3/2020. + // Red channel of the green pixel is component numnber 5. + // - Webp round-trip results in significant error in the color values. + // crbug.com/847527 + + if (testScenario.canvasColorParam.pixelFormat == '8-8-8-8') { + let tolerance_color = 10; + let tolerance_r_green = 26; + let tolerance_webp = 50; + for (let i = 0; i < actualPixels.length; i++) { + // Alpha channel + if (i % 4 == 3) + assert_equals(actualPixels[i], refPixels[i]); + else if (testScenario.encodeOptions.type == 'image/webp') + assert_approx_equals(actualPixels[i], refPixels[i], tolerance_webp); + // Red channel of the green pixel + else if (i == 4) + assert_approx_equals(actualPixels[i], refPixels[i], tolerance_r_green); + else + assert_approx_equals(actualPixels[i], refPixels[i], tolerance_color); + } + } else { + let tolerance_color = 0.02; + let tolerance_webp = 0.2; + for (let i = 0; i < actualPixels.length; i++) { + // Alpha channel + if (i % 4 == 3) + assert_equals(actualPixels[i], refPixels[i]); + else if (testScenario.encodeOptions.type == 'image/webp') + assert_approx_equals(actualPixels[i], refPixels[i], tolerance_webp); + else + assert_approx_equals(actualPixels[i], refPixels[i], tolerance_color); + } + } +} + +function createCanvas(testScenario) +{ + var canvas = document.createElement("canvas"); + canvas.width = 2; + canvas.height = 2; + return canvas; +} + +function generateFillStyle(red, green, blue, alpha) { + return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")"; +} + +function drawPatternOnCanvsa(ctx, alpha, compositeOverBlack) { + if (compositeOverBlack) { + ctx.fillStyle = generateFillStyle(0, 0, 0, 1); + ctx.fillRect(0, 0, 2, 2); + } + ctx.fillStyle = generateFillStyle(155, 27, 27, alpha); + ctx.fillRect(0, 0, 1, 1); + ctx.fillStyle = generateFillStyle(27, 155, 27, alpha); + ctx.fillRect(1, 0, 1, 1); + ctx.fillStyle = generateFillStyle(27, 27, 155, alpha); + ctx.fillRect(0, 1, 1, 1); + ctx.fillStyle = generateFillStyle(27, 27, 27, alpha); + ctx.fillRect(1, 1, 1, 1); +} + +function testScenarioToString(testScenario) { + var str = "mimeType: " + testScenario.encodeOptions.type + + ", blobColorSpace: " + testScenario.encodeOptions.colorSpace + + ", blobPixelFormat: " + testScenario.encodeOptions.pixelFormat + + ", source color space: " + testScenario.canvasColorParam.colorSpace + + ", pixel format: " + testScenario.canvasColorParam.pixelFormat + + ", alpha: " + testScenario.alpha; + return str; +} + +function runConvertToBlobTest(testScenario) { + var srcCanvas = createCanvas(testScenario); + var ctx = srcCanvas.getContext('2d', testScenario.canvasColorParam); + var compositeOverBlack = (testScenario.encodeOptions.type == "image/jpeg"); + drawPatternOnCanvsa(ctx, testScenario.alpha, compositeOverBlack); + var refPixels = ctx.getImageData(0, 0, 2, 2).dataUnion; + + var t = async_test("Test canvas convertToBlob(): " + + testScenarioToString(testScenario)); + + var image = new Image(); + image.onload = t.step_func_done(function() { + var dstCanvas = createCanvas(testScenario); + var dstCtx = dstCanvas.getContext('2d', testScenario.canvasColorParam); + dstCtx.drawImage(image, 0, 0); + var actualPixels = dstCtx.getImageData(0, 0, 2, 2).dataUnion; + testPixels(actualPixels, refPixels, testScenario); + }); + + srcCanvas.convertToBlob(testScenario.encodeOptions).then( + t.step_func(function(blob) { + var urlCreator = window.URL || window.webkitURL; + image.src = urlCreator.createObjectURL(blob); + }), + t.step_func_done(function(e) { + assert_false("convertToBlob failed."); + }) + ); +} + +function runAllTests() { + + var mimeTypes = ['image/png', 'image/jpeg', 'image/webp']; + var blobColorSpaces = ['srgb', 'rec2020', 'display-p3']; + // uint16 pixel format is not supported yet. crbug.com/840372. + var blobPixelFormats = ['8-8-8-8']; + + var encodeOptionsSet = []; + for (var i = 0; i < mimeTypes.length; i++) + for (var j = 0; j < blobColorSpaces.length; j++) + for (var k = 0; k < blobPixelFormats.length; k++) { + var encodeOptions = {}; + // Extend convertToBlob layout tests with quality < 1. + // crbug.com/847513 + encodeOptions.quality = 1; + encodeOptions.type = mimeTypes[i]; + encodeOptions.colorSpace = blobColorSpaces[j]; + encodeOptions.pixelFormat = blobPixelFormats[k]; + encodeOptionsSet.push(encodeOptions); + } + + var canvasColorParams = [ + {colorSpace: 'srgb', pixelFormat: '8-8-8-8'}, + {colorSpace: 'srgb', pixelFormat: 'float16'}, + {colorSpace: 'rec2020', pixelFormat: 'float16'}, + {colorSpace: 'p3', pixelFormat: 'float16'}]; + var alphaValues = [0.5, 1]; + + // The *correct* way to test convertToBlob() is to directly examine the + // image file for the expected color space and pixels. Since this is not + // easy to do in javascript, we use a round-trip test here and leave the + // more thorough testing to unit tests. + + var testScenarioSet = []; + for (var i = 0; i < encodeOptionsSet.length; i++) + for (var j = 0; j < canvasColorParams.length; j++) + for (var k = 0; k < alphaValues.length; k++) { + var testScenario = {}; + testScenario.encodeOptions = encodeOptionsSet[i]; + testScenario.canvasColorParam = canvasColorParams[j]; + testScenario.alpha = alphaValues[k]; + testScenarioSet.push(testScenario); + } + + for (var i = 0; i < testScenarioSet.length; i++) + runConvertToBlobTest(testScenarioSet[i]); +} + +runAllTests(); + +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen-expected.txt b/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen-expected.txt index 74d38aa..c203db5 100644 --- a/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen-expected.txt
@@ -4,7 +4,7 @@ PASS getComputedStyle(full).backgroundColor is red -PASS internals.updateStyleAndReturnAffectedElementCount() is 1 +PASS internals.updateStyleAndReturnAffectedElementCount() is 2 PASS getComputedStyle(full).backgroundColor is green PASS getComputedStyle(ancestor).backgroundColor is red PASS internals.updateStyleAndReturnAffectedElementCount() is 1
diff --git a/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen.html b/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen.html index c8bb4c89..77f0e2d 100644 --- a/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen.html +++ b/third_party/WebKit/LayoutTests/fast/css/invalidation/fullscreen.html
@@ -34,7 +34,7 @@ testRoot.offsetTop; // force recalc testRoot.className = "t1"; if (window.internals) - shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); + shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); shouldBe("getComputedStyle(full).backgroundColor", "green"); shouldBe("getComputedStyle(ancestor).backgroundColor", "red");
diff --git a/third_party/WebKit/LayoutTests/fast/events/drag-remove-iframe-crash.html b/third_party/WebKit/LayoutTests/fast/events/drag-remove-iframe-crash.html index 895d6c0..244f7b84 100644 --- a/third_party/WebKit/LayoutTests/fast/events/drag-remove-iframe-crash.html +++ b/third_party/WebKit/LayoutTests/fast/events/drag-remove-iframe-crash.html
@@ -8,7 +8,7 @@ function run_test() { var fr = document.createElement('iframe'); document.body.appendChild(fr); - fr.contentDocument.body.innerHTML = '<div draggable="true" id="target" style="margin: 0px; width: 100px; height: 100px;background-color:red"></div>'; + fr.contentDocument.body.innerHTML = '<div draggable="true" id="target" style="margin: 0px; width: 100px; height: 100px; background-color:red"></div>'; fr.contentDocument.getElementById("target").ondragstart = function(event) { document.body.removeChild(fr);
diff --git a/third_party/WebKit/LayoutTests/fullscreen/enter-exit-full-screen-hover.html b/third_party/WebKit/LayoutTests/fullscreen/enter-exit-full-screen-hover.html index 940b8be..4724936 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/enter-exit-full-screen-hover.html +++ b/third_party/WebKit/LayoutTests/fullscreen/enter-exit-full-screen-hover.html
@@ -1,4 +1,11 @@ <!DOCTYPE html> +<style> +/* Offset body by 50px so that buttons clearly change position when they enter/exit fullscreen. */ +body { + position: relative; + left: 50px; +} +</style> <script src="../resources/js-test.js"></script> <script src="full-screen-test.js"></script> <script src="../fast/events/touch/resources/touch-hover-active-tests.js"></script> @@ -46,9 +53,9 @@ }); }); - // Hover and click the "Enter fullscreen" button. - eventSender.mouseMoveTo(enterButtonCenter.x, enterButtonCenter.y); + // We move by 50px in the x-direction to account for the relative position. + eventSender.mouseMoveTo(enterButtonCenter.x + 50, enterButtonCenter.y); eventSender.mouseDown(); eventSender.mouseUp(); shouldBeOnlyHovered("getHoverActiveState(enterButton)");
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-contentEditable-crash-expected.txt b/third_party/WebKit/LayoutTests/fullscreen/full-screen-contentEditable-crash-expected.txt index a2f48eb..2799b65 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-contentEditable-crash-expected.txt +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-contentEditable-crash-expected.txt
@@ -1,2 +1,3 @@ +CONSOLE WARNING: line 22: The behavior that Selection.addRange() merges existing Range and the specified Range was removed. See https://www.chromestatus.com/features/6680566019653632 for more details. Pass if there is no crash. Click anywhere to test manually.
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style-expected.txt b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style-expected.txt index 1ef1531..cb34621 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style-expected.txt +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style-expected.txt
@@ -1,6 +1,6 @@ -TEST(getComputedStyle(ancestor).position == 'relative') OK +TEST(getComputedStyle(document.documentElement).overflow == 'visible') OK EVENT(webkitfullscreenchange) -TEST(getComputedStyle(ancestor).position == 'static') OK +TEST(getComputedStyle(document.documentElement).overflow == 'hidden') OK END OF TEST
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style.html index 8bfd0eda..21aebffc 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-ua-style.html
@@ -5,12 +5,12 @@ document.offsetWidth; frame.contentDocument.offsetWidth; var videoEnteredFullScreen = function() { - test("getComputedStyle(ancestor).position == 'static'"); + test("getComputedStyle(document.documentElement).overflow == 'hidden'"); endTest(); }; waitForEvent(frame.contentDocument, "webkitfullscreenchange", videoEnteredFullScreen); - test("getComputedStyle(ancestor).position == 'relative'"); + test("getComputedStyle(document.documentElement).overflow == 'visible'"); var x = frame.getBoundingClientRect().left + 10; var y = frame.getBoundingClientRect().top + 10;
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-zIndex.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-zIndex.html index 44b5afde..7f7e8e4 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-zIndex.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-iframe-zIndex.html
@@ -43,6 +43,6 @@ After entering full screen mode, the whole screen should be white. Click <button onclick="goFullScreen()">go full screen</button> to run the test.</div> <div id="block2"></div> - <iframe allowfullscreen src="resources/empty.html" id="block1"></iframe> + <iframe allowfullscreen src="resources/white.html" id="block1"></iframe> </body> </html>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer-expected.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer-expected.html new file mode 100644 index 0000000..e981713 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer-expected.html
@@ -0,0 +1,9 @@ +<!DOCTYPE html> +<style> +body { + background-color: green; + margin: 0; +} +</style> + +<div>Test that fullscreen elements are in the top layer. The test passes if you see a green backdrop behind this box when fullscreen.</div>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer.html new file mode 100644 index 0000000..1691bdb --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-is-in-top-layer.html
@@ -0,0 +1,43 @@ +<!doctype html> +<style> +div { + top: 100px; + bottom: 100px; + left: 100px; + right: 100px; + height: auto; + width: auto; +} +::backdrop { + background: green; +} +</style> + +<div id='element'>Test that fullscreen elements are in the top layer. The test passes if you see a green backdrop behind this box when fullscreen.</div> + +<button id='button'>Go fullscreen</button> + +<script> +var element = document.getElementById('element'); +document.getElementById('button').addEventListener('click', function() { + element.webkitRequestFullscreen(); +}); + +if (window.testRunner) { + testRunner.waitUntilDone(); + document.addEventListener('webkitfullscreenchange', function() { + testRunner.notifyDone(); + }); + + var button = document.getElementById('button'); + chrome.gpuBenchmarking.pointerActionSequence([ + { + source: 'mouse', + actions: [ + { name: 'pointerDown', x: button.offsetLeft + button.offsetWidth / 2, y: button.offsetTop + button.offsetHeight / 2 }, + { name: 'pointerUp' } + ] + } + ], () => {}); +} +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-render-inline-expected.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-render-inline-expected.html index 6bbb44a..90371ed 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-render-inline-expected.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-render-inline-expected.html
@@ -1,3 +1,2 @@ <!DOCTYPE html> -<!-- FIXME: the <br> is needed until http://crbug.com/246077 is fixed --> -<div>a<br><span>b<div>c</div>d</span>e</div> +<div>a<span>b<div>c</div>d</span>e</div>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context-expected.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context-expected.html index 98a5e31..042f660 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context-expected.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context-expected.html
@@ -1,12 +1,2 @@ <!DOCTYPE html> -<video></video> -<script> - var runPixelTests = true; -</script> -<script src="full-screen-test.js"></script> -<script> - document.onwebkitfullscreenchange = endTest; - runWithKeyDown(function() { - document.querySelector("video").webkitRequestFullScreen(); - }); -</script> +<body style="background: black"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context.html index b29ce7e..80f5c53 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-stacking-context.html
@@ -12,7 +12,7 @@ } function goFullScreen() { - document.getElementById('video').webkitRequestFullScreen(); + document.getElementById('target').webkitRequestFullScreen(); } </script> <script src="full-screen-test.js"></script> @@ -25,8 +25,6 @@ left: 50px; z-index: 1; background-color: red; - } - #one, #two { opacity: 0.5; transform: rotate(180); -webkit-mask: -webkit-linear-gradient(left, alpha 0%, white 100%); @@ -40,7 +38,7 @@ position: relative; z-index: 0; } - #video { + #target { width: 200px; height: 200px; background-color: black; @@ -53,7 +51,7 @@ Click <button onclick="goFullScreen()">go full screen</button> to run the test.</div> <div id="one"></div> <div id="zero"> - <video id="video"></video> + <div id="target"></div> </div> </body> </html>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/full-screen-zIndex-expected.html b/third_party/WebKit/LayoutTests/fullscreen/full-screen-zIndex-expected.html index 37c105b4..f9fc201 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/full-screen-zIndex-expected.html +++ b/third_party/WebKit/LayoutTests/fullscreen/full-screen-zIndex-expected.html
@@ -6,15 +6,14 @@ background-color: black; } div { - width: 200px; - height: 100px; + width: 100%; + height: 100%; border: 4px solid darkgreen; background-color: green; position: absolute; - left: 50%; - top: 50%; - margin-left: -104px; - margin-top: -54px; + box-sizing: border-box; + top: 0; + left: 0; } </style> </head>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/parent-flow-inline-with-block-child-expected.html b/third_party/WebKit/LayoutTests/fullscreen/parent-flow-inline-with-block-child-expected.html index 15618456..4545d28 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/parent-flow-inline-with-block-child-expected.html +++ b/third_party/WebKit/LayoutTests/fullscreen/parent-flow-inline-with-block-child-expected.html
@@ -1,3 +1,3 @@ <!DOCTYPE html> -<div>1</div> -<div>2</div> +<span>1</span> +<span>2</span>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-expected.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-expected.html new file mode 100644 index 0000000..3126fe1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-expected.html
@@ -0,0 +1,2 @@ +<!DOCTYPE html> +<body style="background: green"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe-expected.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe-expected.html new file mode 100644 index 0000000..3126fe1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe-expected.html
@@ -0,0 +1,2 @@ +<!DOCTYPE html> +<body style="background: green"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe.html new file mode 100644 index 0000000..94d0ad8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-iframe.html
@@ -0,0 +1,18 @@ +<!DOCTYPE html> +<title>::backdrop for a fullscreen iframe element</title> +<script src="../trusted-click.js"></script> +<style> +iframe::backdrop { + background: green; +} +</style> +<iframe></iframe> +<script> +testRunner.waitUntilDone(); +// TODO: "var t" is silly everywhere in this dir +var t = { step_func: func => func() }; +trusted_request(t, document.querySelector("iframe")); +document.addEventListener("fullscreenchange", function() { + testRunner.notifyDone(); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object-expected.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object-expected.html new file mode 100644 index 0000000..5608482 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object-expected.html
@@ -0,0 +1,13 @@ +<!DOCTYPE html> +<style> +body { + background: green; + margin: 0; +} +object { + position: fixed; + width: 100%; + height: 100%; +} +</style> +<object type="application/x-shockwave-flash" data="../../plugins/resources/simple_blank.swf"></object>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object.html new file mode 100644 index 0000000..f9a3046a --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-object.html
@@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>::backdrop for a fullscreen object element</title> +<script src="../trusted-click.js"></script> +<style> +object::backdrop { + background: green; +} +</style> +<object type="application/x-shockwave-flash" data="../../plugins/resources/simple_blank.swf"></object> +<script> +testRunner.waitUntilDone(); +var t = { step_func: func => func() }; +trusted_request(t, document.querySelector("object")); +document.addEventListener("fullscreenchange", function() { + testRunner.notifyDone(); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video-expected.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video-expected.html new file mode 100644 index 0000000..3126fe1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video-expected.html
@@ -0,0 +1,2 @@ +<!DOCTYPE html> +<body style="background: green"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video.html new file mode 100644 index 0000000..f44982c --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop-video.html
@@ -0,0 +1,23 @@ +<!DOCTYPE html> +<title>::backdrop for a fullscreen video element</title> +<script src="../trusted-click.js"></script> +<style> +video::backdrop { + background: green; +} +/* A video element in fullscreen will always get controls. + ::-webkit-media-controls shouldn't be exposed to the web, but it is, so abuse + it to hide the controls and simplify the test expectations. */ +video::-webkit-media-controls { + display: none; +} +</style> +<video></video> +<script> +testRunner.waitUntilDone(); +var t = { step_func: func => func() }; +trusted_request(t, document.querySelector("video")); +document.addEventListener("fullscreenchange", function() { + testRunner.notifyDone(); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop.html new file mode 100644 index 0000000..544593f --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/backdrop.html
@@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>::backdrop for a fullscreen div element</title> +<script src="../trusted-click.js"></script> +<style> +div::backdrop { + background: green; +} +</style> +<div></div> +<script> +testRunner.waitUntilDone(); +var t = { step_func: func => func() }; +trusted_request(t, document.querySelector("div")); +document.addEventListener("fullscreenchange", function() { + testRunner.notifyDone(); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow-root.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow-root.html new file mode 100644 index 0000000..64294f3 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow-root.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>overflow of root element when root element itself is fullscreen</title> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../trusted-click.js"></script> +<style>:root { overflow: scroll; }</style> +<div id="log"></div> +<script> +async_test(function(t) +{ + var root = document.documentElement; + trusted_request(t, root, document.body); + + document.addEventListener("fullscreenchange", t.step_func_done(function() + { + // The scrollbar should remain. + assert_equals(getComputedStyle(root).overflow, "scroll"); + if (window.internals && window.internals.runtimeFlags.overlayScrollbarsEnabled) + assert_equals(root.clientWidth, window.innerWidth); + else + assert_less_than(root.clientWidth, window.innerWidth); + })); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow.html b/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow.html new file mode 100644 index 0000000..91a9a6c6 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/rendering/overflow.html
@@ -0,0 +1,21 @@ +<!DOCTYPE html> +<title>overflow of root element when descendant is fullscreen</title> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<script src="../trusted-click.js"></script> +<style>:root { overflow: scroll; }</style> +<div id="log"></div> +<script> +async_test(function(t) +{ + var root = document.documentElement; + trusted_request(t, document.querySelector("div")); + + document.addEventListener("fullscreenchange", t.step_func_done(function() + { + // The scrollbar should be removed. + assert_equals(getComputedStyle(root).overflow, "hidden"); + assert_equals(root.clientWidth, window.innerWidth); + })); +}); +</script>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/resources/empty.html b/third_party/WebKit/LayoutTests/fullscreen/resources/empty.html index c8b7661..0e76edd6 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/resources/empty.html +++ b/third_party/WebKit/LayoutTests/fullscreen/resources/empty.html
@@ -1 +1 @@ -<body></body> +<!DOCTYPE html>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/resources/green.html b/third_party/WebKit/LayoutTests/fullscreen/resources/green.html index 9b2defacc..3126fe1 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/resources/green.html +++ b/third_party/WebKit/LayoutTests/fullscreen/resources/green.html
@@ -1,8 +1,2 @@ -<html> - <style> - body { - background-color: green; - } - </style> - <body></body> -</html> +<!DOCTYPE html> +<body style="background: green"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/resources/white.html b/third_party/WebKit/LayoutTests/fullscreen/resources/white.html new file mode 100644 index 0000000..fc01fd0 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fullscreen/resources/white.html
@@ -0,0 +1,2 @@ +<!DOCTYPE html> +<body style="background: white"></body>
diff --git a/third_party/WebKit/LayoutTests/fullscreen/video-transform-expected.html b/third_party/WebKit/LayoutTests/fullscreen/video-transform-expected.html index 01c7633..92dcfe0 100644 --- a/third_party/WebKit/LayoutTests/fullscreen/video-transform-expected.html +++ b/third_party/WebKit/LayoutTests/fullscreen/video-transform-expected.html
@@ -1,4 +1,5 @@ <!DOCTYPE html> +<p>Test that fullscreen video should not be affected by webkit-transform.</p> <video id="video" allowfullscreen></video> <script> if (window.internals)
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-detached.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-detached.html index 3b95f87..69f17b1 100644 --- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-detached.html +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/credentialscontainer-detached.html
@@ -11,6 +11,7 @@ eventWatcher.wait_for("message") .then(_ => { navigatorCredentials = openedWindow.navigator.credentials; + publicKeyCredential = openedWindow.PublicKeyCredential; window.setTimeout(_ => openedWindow.location.reload()); return eventWatcher.wait_for("message"); }) @@ -25,6 +26,8 @@ "navigator.credentials.store() should not crash nor return a Promise."); assert_equals(navigatorCredentials.preventSilentAccess(), undefined, "navigator.credentials.preventSilentAccess() should not crash nor return a Promise."); + assert_equals(publicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(), undefined, + "window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() should not crash nor return a Promise."); })); });
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/publickeycredential-basics.html b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/publickeycredential-basics.html index 089fe87..8cb567c6 100644 --- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/publickeycredential-basics.html +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/publickeycredential-basics.html
@@ -4,9 +4,8 @@ <script src="../resources/testharnessreport.js"></script> <script> -promise_test(t => { - return promise_rejects(t, "NotSupportedError", - PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()); -}, "isUserVerifyingPlatformAuthenticatorAvailable() is not implemented."); +promise_test(async _ => { + assert_equals(await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable(), false); +}, "isUserVerifyingPlatformAuthenticatorAvailable() is false by default."); </script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/resources/mock-navigator-credentials.js b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/resources/mock-navigator-credentials.js index 16d6583..08d8208 100644 --- a/third_party/WebKit/LayoutTests/http/tests/credentialmanager/resources/mock-navigator-credentials.js +++ b/third_party/WebKit/LayoutTests/http/tests/credentialmanager/resources/mock-navigator-credentials.js
@@ -125,6 +125,10 @@ return {status, credential: response}; } + async isUserVerifyingPlatformAuthenticatorAvailable() { + return false; + } + // Resets state of mock Authenticator. reset() { this.status_ = webauth.mojom.AuthenticatorStatus.UNKNOWN_ERROR;
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes-expected.txt new file mode 100644 index 0000000..29d2118 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes-expected.txt
@@ -0,0 +1,181 @@ +Tests that console produces instant previews for arrays and objects. + +console-format-classes.js:30 Error: custom error with link www.chromium.org + at console-format-classes.js:20 + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + object-value-error source-code + devtools-link + devtools-link +console-format-classes.js:30 (6) [1, empty × 2, 2, (...), empty] + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-array source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-description + object-properties-preview + object-value-number + object-value-undefined + object-value-number + object-value-accessor + object-value-undefined + object-state-note info-note + children +console-format-classes.js:30 {a: 1} + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-object source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-properties-preview + name + object-value-number + object-state-note info-note + children +console-format-classes.js:30 {str: "", nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0} + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-object source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-properties-preview + name + object-value-string + name + object-value-number + name + object-value-number + name + object-value-number + name + object-value-number + object-state-note info-note + children +console-format-classes.js:30 {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false} + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-object source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-properties-preview + name + object-value-null + name + object-value-undefined + name + object-value-regexp + name + object-value-boolean + object-state-note info-note + children +console-format-classes.js:30 Proxy {a: 1} + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-proxy source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-description + object-properties-preview + name + object-value-number + object-state-note info-note + children +console-format-classes.js:30 HTMLAllCollection(4) [html, head, base, body] + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-array source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-description + object-properties-preview + object-value-node + webkit-html-tag-name + object-value-node + webkit-html-tag-name + object-value-node + webkit-html-tag-name + object-value-node + webkit-html-tag-name + object-state-note info-note + children +console-format-classes.js:34 (7) [Error: custom error with link www.chromium.org + at test://evaluations/0/console-format-classes.js…, Array(6), {…}, {…}, {…}, Proxy, HTMLAllCollection(4)] + console-message + source-code + console-message-anchor + devtools-link + hidden console-message-badge + hide-badge-title + console-message-text + console-view-object-properties-section object-value-array source-code + tree-outline-disclosure tree-outline-disclosure-hide-overflow + tree-outline source-code object-properties-section + parent object-properties-section-root-element + selection fill + console-object console-object-preview + object-description + object-properties-preview + object-value-error + object-value-array + object-value-object + object-value-object + object-value-object + object-value-proxy + object-value-array + object-state-note info-note + children +
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes.js new file mode 100644 index 0000000..bcd332f --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-format-classes.js
@@ -0,0 +1,42 @@ +// 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. + +(async function() { + TestRunner.addResult(`Tests that console produces instant previews for arrays and objects.\n`); + await TestRunner.loadModule('console_test_runner'); + await TestRunner.showPanel('console'); + await TestRunner.evaluateInPagePromise(` + const objWithGetter = {a: 1, __proto__: 2}; + Object.defineProperty(objWithGetter, "foo", {enumerable: true, get: function() { return {a:1,b:2}; }}); + Object.defineProperty(objWithGetter, "bar", {enumerable: false, set: function(x) { this.baz = x; }}); + + const arrayWithGetter = [1]; + arrayWithGetter[3] = 2; + Object.defineProperty(arrayWithGetter, 4, {enumerable: true, get: function() { return 1; }}); + Object.defineProperty(arrayWithGetter, 5, {enumerable: false, set: function(x) { this.baz = x; }}); + + const tests = [ + new Error('custom error with link www.chromium.org'), + arrayWithGetter, + objWithGetter, + {str: "", nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0}, + {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false}, + new Proxy({a: 1}, {}), + document.all, + ]; + + for (const test of tests) + console.log(test); + + // Arrays can preview at most 100 items. + for (let i = 0; i < tests.length; i += 100) + console.log(tests.slice(i, i + 100)); + `); + + ConsoleTestRunner.waitForRemoteObjectsConsoleMessages(onRemoteObjectsLoaded); + function onRemoteObjectsLoaded() { + ConsoleTestRunner.dumpConsoleMessages(false, true /* dumpClassNames */); + TestRunner.completeTest(); + } +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors-expected.txt index faaafb9..ed5da8d 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors-expected.txt
@@ -2,66 +2,66 @@ foob.js:5 Error: Some test at namedFunction (foob.js:5) - at foob.js:8 console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link + at foob.js:8 console-log-linkify-…ack-in-errors.js:15 Error: line break at forStack (console-log-linkify-…ack-in-errors.js:15) - at console-log-linkify-…ack-in-errors.js:18 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:18 console-log-linkify-…ack-in-errors.js:34 Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. at domError (console-log-linkify-…ack-in-errors.js:32) - at console-log-linkify-…ack-in-errors.js:38 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:38 console-log-linkify-…ack-in-errors.js:45 Error: some error at logError (console-log-linkify-…ack-in-errors.js:43) - at console-log-linkify-…ack-in-errors.js:49 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > object-value-error source-code > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis -console-log-linkify-…ack-in-errors.js:51 Error message without stacks http://www.chromium.org/ console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at console-log-linkify-…ack-in-errors.js:49 +console-log-linkify-…ack-in-errors.js:51 Error message without stacks http://www.chromium.org/ console-log-linkify-…ack-in-errors.js:53 Error valid stack #2 at www.chromium.org/boo.js:40 - at foo(www.chromium.org/foo.js:10) console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link + at foo(www.chromium.org/foo.js:10) console-log-linkify-…ack-in-errors.js:54 Error valid stack #3 - at www.chromium.org/foo.js:40 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at www.chromium.org/foo.js:40 console-log-linkify-…ack-in-errors.js:55 Error: MyError at throwError (www.chromium.org/foo.js:40) at eval (eval at <anonymous> (www.chromium.org/foo.js:42), <anonymous>:1:1) - at www.chromium.org/foo.js:239 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link > devtools-link + at www.chromium.org/foo.js:239 console-log-linkify-…ack-in-errors.js:24 ReferenceError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:57 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:57 console-log-linkify-…ack-in-errors.js:24 EvalError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:58 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:58 console-log-linkify-…ack-in-errors.js:24 SyntaxError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:59 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:59 console-log-linkify-…ack-in-errors.js:24 RangeError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:60 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:60 console-log-linkify-…ack-in-errors.js:24 TypeError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:61 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:61 console-log-linkify-…ack-in-errors.js:24 URIError: valid stack at stack2 (console-log-linkify-…ack-in-errors.js:24) at stack1 (console-log-linkify-…ack-in-errors.js:26) - at console-log-linkify-…ack-in-errors.js:62 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis > devtools-link > devtools-link-ellipsis + at console-log-linkify-…ack-in-errors.js:62 console-log-linkify-…ack-in-errors.js:64 Error broken stack at function_name(foob.js foob.js:30) - at foob.js:40 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link + at foob.js:40 console-log-linkify-…ack-in-errors.js:65 Error broken stack #2 - at function_name(foob.js:20 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at function_name(foob.js:20 console-log-linkify-…ack-in-errors.js:66 Error broken stack #3 - at function_name(foob:20.js:30 bla console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at function_name(foob:20.js:30 bla console-log-linkify-…ack-in-errors.js:67 Error broken stack #4 - at function_name)foob.js:20:30( console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at function_name)foob.js:20:30( console-log-linkify-…ack-in-errors.js:68 Error broken stack #5 - at function_name foob.js:20:30) console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at function_name foob.js:20:30) console-log-linkify-…ack-in-errors.js:69 Error broken stack #6 - at foob.js foob.js:40 console-message > source-code > console-message-anchor > devtools-link > devtools-link-ellipsis > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link + at foob.js foob.js:40 stack-with-sourceMap.coffee:3 Error at Failure.letsFailWithStack (stack-with-sourceMap.coffee:3) at window.failure (stack-with-sourceMap.coffee:7) - at <anonymous>:1:1 console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > devtools-link > devtools-link + at <anonymous>:1:1
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors.js index 9194ea5..573db2e 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors.js +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-linkify-stack-in-errors.js
@@ -78,7 +78,7 @@ } function dumpMessages() { - ConsoleTestRunner.dumpConsoleMessages(false, true); + ConsoleTestRunner.dumpConsoleMessages(); TestRunner.completeTest(); } })();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter-expected.txt index 0b55a3e..9b384cc 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter-expected.txt
@@ -3,7 +3,7 @@ console-log-object-with-getter.js:30 {} console-log-object-with-getter.js:31 (2) [(...), empty] console-log-object-with-getter.js:32 {} -console-log-object-with-getter.js:30 {}foo: Objectget foo: ƒ ()set bar: ƒ (x)__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > object-state-note info-note > children expanded > parent > name > object-value-object value > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-log-object-with-getter.js:31 (2) [(...), empty]0: 1length: 2get 0: ƒ ()set 1: ƒ (x)__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-accessor > object-value-undefined > object-state-note info-note > children expanded > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-log-object-with-getter.js:32 {}error: [Exception: Error: myError]function: [Exception: ƒ ()]number: [Exception: 123]string: [Exception: "myString"]get error: ƒ error()get function: ƒ ()get number: ƒ number()get string: ƒ string()__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > object-state-note info-note > children expanded > name > error value > object-value-error > children > name > error value > object-value-function > object-value-function-prefix > children > name > error value > object-value-number > children > name > error value > object-value-string > object-value-string-quote > object-value-string-quote > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-function value > object-value-function-prefix > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children +console-log-object-with-getter.js:30 {}foo: Objectget foo: ƒ ()set bar: ƒ (x)__proto__: Object +console-log-object-with-getter.js:31 (2) [(...), empty]0: 1length: 2get 0: ƒ ()set 1: ƒ (x)__proto__: Array(0) +console-log-object-with-getter.js:32 {}error: [Exception: Error: myError]function: [Exception: ƒ ()]number: [Exception: 123]string: [Exception: "myString"]get error: ƒ error()get function: ƒ ()get number: ƒ number()get string: ƒ string()__proto__: Object
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter.js index 649f7e77..094ea88 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter.js +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-log-object-with-getter.js
@@ -45,7 +45,7 @@ ConsoleTestRunner.expandGettersInConsoleMessages(step5); } function step5() { - ConsoleTestRunner.dumpConsoleMessages(false, true); + ConsoleTestRunner.dumpConsoleMessages(); TestRunner.completeTest(); } })();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview-expected.txt index ff1c174..0eaf3e4 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview-expected.txt
@@ -1,66 +1,66 @@ Tests that console produces instant previews for arrays and objects. -console-object-preview.js:10 Mutating object in a loop console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:14 {a: 0, b: 0, c: 0} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:14 {a: 0, b: 0, c: 1} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:14 {a: 0, b: 0, c: 2} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:17 Mutating array in a loop console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:21 (3) [0, 0, 0] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children -console-object-preview.js:21 (3) [0, 0, 1] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children -console-object-preview.js:21 (3) [0, 0, 2] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children -console-object-preview.js:24 Object with many properties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:29 {property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:31 Array with many properties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:36 (2) [0, 1, property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:38 Array with gaps and overflow console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:43 (5733) [32: 0, 89: 1, 146: 2, 203: 3, 260: 4, 317: 5, 374: 6, 431: 7, 488: 8, 545: 9, 602: 10, 659: 11, 716: 12, 773: 13, 830: 14, 887: 15, 944: 16, 1001: 17, 1058: 18, 1115: 19, 1172: 20, 1229: 21, 1286: 22, 1343: 23, 1400: 24, 1457: 25, 1514: 26, 1571: 27, 1628: 28, 1685: 29, 1742: 30, 1799: 31, 1856: 32, 1913: 33, 1970: 34, 2027: 35, 2084: 36, 2141: 37, 2198: 38, 2255: 39, 2312: 40, 2369: 41, 2426: 42, 2483: 43, 2540: 44, 2597: 45, 2654: 46, 2711: 47, 2768: 48, 2825: 49, 2882: 50, 2939: 51, 2996: 52, 3053: 53, 3110: 54, 3167: 55, 3224: 56, 3281: 57, 3338: 58, 3395: 59, 3452: 60, 3509: 61, 3566: 62, 3623: 63, 3680: 64, 3737: 65, 3794: 66, 3851: 67, 3908: 68, 3965: 69, 4022: 70, 4079: 71, 4136: 72, 4193: 73, 4250: 74, 4307: 75, 4364: 76, 4421: 77, 4478: 78, 4535: 79, 4592: 80, 4649: 81, 4706: 82, 4763: 83, 4820: 84, 4877: 85, 4934: 86, 4991: 87, 5048: 88, 5105: 89, 5162: 90, 5219: 91, 5276: 92, 5333: 93, 5390: 94, 5447: 95, 5504: 96, 5561: 97, 5618: 98, 5675: 99, …] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:45 Array with gaps without overflow console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:50 (5619) [empty × 32, 0, empty × 56, 1, empty × 56, 2, empty × 56, 3, empty × 56, 4, empty × 56, 5, empty × 56, 6, empty × 56, 7, empty × 56, 8, empty × 56, 9, empty × 56, 10, empty × 56, 11, empty × 56, 12, empty × 56, 13, empty × 56, 14, empty × 56, 15, empty × 56, 16, empty × 56, 17, empty × 56, 18, empty × 56, 19, empty × 56, 20, empty × 56, 21, empty × 56, 22, empty × 56, 23, empty × 56, 24, empty × 56, 25, empty × 56, 26, empty × 56, 27, empty × 56, 28, empty × 56, 29, empty × 56, 30, empty × 56, 31, empty × 56, 32, empty × 56, 33, empty × 56, 34, empty × 56, 35, empty × 56, 36, empty × 56, 37, empty × 56, 38, empty × 56, 39, empty × 56, 40, empty × 56, 41, empty × 56, 42, empty × 56, 43, empty × 56, 44, empty × 56, 45, empty × 56, 46, empty × 56, 47, empty × 56, 48, empty × 56, 49, empty × 56, 50, empty × 56, 51, empty × 56, 52, empty × 56, 53, empty × 56, 54, empty × 56, 55, empty × 56, 56, empty × 56, 57, empty × 56, 58, empty × 56, 59, empty × 56, 60, empty × 56, 61, empty console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-state-note info-note > children -console-object-preview.js:52 Object with proto console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:55 {d: 1} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > object-state-note info-note > children -console-object-preview.js:57 Sparse array console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:60 (150) [empty × 50, 50, empty × 99] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-undefined > object-value-number > object-value-undefined > object-state-note info-note > children -console-object-preview.js:62 Dense array with indexes and propeties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:68 (150) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, …] console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-state-note info-note > children -console-object-preview.js:70 Object with properties containing whitespaces console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:77 {" a b ": " a b ", c d: "c d", "": "", " ": " ", "a↵↵b↵c": "a↵↵b↵c"} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-string > name > object-value-string > name > object-value-string > name > object-value-string > name > object-value-string > object-state-note info-note > children -console-object-preview.js:79 Object with a document.all property console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:80 {all: HTMLAllCollection(4)} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-array > object-state-note info-note > children -console-object-preview.js:82 Object with special numbers console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:84 {nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:86 Object with exactly 5 properties: expected to be lossless console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:87 {a: 1, b: 2, c: 3, d: 4, e: 5} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-object-preview.js:89 {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-null > name > object-value-undefined > name > object-value-regexp > name > object-value-boolean > object-state-note info-note > children +console-object-preview.js:10 Mutating object in a loop +console-object-preview.js:14 {a: 0, b: 0, c: 0} +console-object-preview.js:14 {a: 0, b: 0, c: 1} +console-object-preview.js:14 {a: 0, b: 0, c: 2} +console-object-preview.js:17 Mutating array in a loop +console-object-preview.js:21 (3) [0, 0, 0] +console-object-preview.js:21 (3) [0, 0, 1] +console-object-preview.js:21 (3) [0, 0, 2] +console-object-preview.js:24 Object with many properties +console-object-preview.js:29 {property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …} +console-object-preview.js:31 Array with many properties +console-object-preview.js:36 (2) [0, 1, property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …] +console-object-preview.js:38 Array with gaps and overflow +console-object-preview.js:43 (5733) [32: 0, 89: 1, 146: 2, 203: 3, 260: 4, 317: 5, 374: 6, 431: 7, 488: 8, 545: 9, 602: 10, 659: 11, 716: 12, 773: 13, 830: 14, 887: 15, 944: 16, 1001: 17, 1058: 18, 1115: 19, 1172: 20, 1229: 21, 1286: 22, 1343: 23, 1400: 24, 1457: 25, 1514: 26, 1571: 27, 1628: 28, 1685: 29, 1742: 30, 1799: 31, 1856: 32, 1913: 33, 1970: 34, 2027: 35, 2084: 36, 2141: 37, 2198: 38, 2255: 39, 2312: 40, 2369: 41, 2426: 42, 2483: 43, 2540: 44, 2597: 45, 2654: 46, 2711: 47, 2768: 48, 2825: 49, 2882: 50, 2939: 51, 2996: 52, 3053: 53, 3110: 54, 3167: 55, 3224: 56, 3281: 57, 3338: 58, 3395: 59, 3452: 60, 3509: 61, 3566: 62, 3623: 63, 3680: 64, 3737: 65, 3794: 66, 3851: 67, 3908: 68, 3965: 69, 4022: 70, 4079: 71, 4136: 72, 4193: 73, 4250: 74, 4307: 75, 4364: 76, 4421: 77, 4478: 78, 4535: 79, 4592: 80, 4649: 81, 4706: 82, 4763: 83, 4820: 84, 4877: 85, 4934: 86, 4991: 87, 5048: 88, 5105: 89, 5162: 90, 5219: 91, 5276: 92, 5333: 93, 5390: 94, 5447: 95, 5504: 96, 5561: 97, 5618: 98, 5675: 99, …] +console-object-preview.js:45 Array with gaps without overflow +console-object-preview.js:50 (5619) [empty × 32, 0, empty × 56, 1, empty × 56, 2, empty × 56, 3, empty × 56, 4, empty × 56, 5, empty × 56, 6, empty × 56, 7, empty × 56, 8, empty × 56, 9, empty × 56, 10, empty × 56, 11, empty × 56, 12, empty × 56, 13, empty × 56, 14, empty × 56, 15, empty × 56, 16, empty × 56, 17, empty × 56, 18, empty × 56, 19, empty × 56, 20, empty × 56, 21, empty × 56, 22, empty × 56, 23, empty × 56, 24, empty × 56, 25, empty × 56, 26, empty × 56, 27, empty × 56, 28, empty × 56, 29, empty × 56, 30, empty × 56, 31, empty × 56, 32, empty × 56, 33, empty × 56, 34, empty × 56, 35, empty × 56, 36, empty × 56, 37, empty × 56, 38, empty × 56, 39, empty × 56, 40, empty × 56, 41, empty × 56, 42, empty × 56, 43, empty × 56, 44, empty × 56, 45, empty × 56, 46, empty × 56, 47, empty × 56, 48, empty × 56, 49, empty × 56, 50, empty × 56, 51, empty × 56, 52, empty × 56, 53, empty × 56, 54, empty × 56, 55, empty × 56, 56, empty × 56, 57, empty × 56, 58, empty × 56, 59, empty × 56, 60, empty × 56, 61, empty +console-object-preview.js:52 Object with proto +console-object-preview.js:55 {d: 1} +console-object-preview.js:57 Sparse array +console-object-preview.js:60 (150) [empty × 50, 50, empty × 99] +console-object-preview.js:62 Dense array with indexes and propeties +console-object-preview.js:68 (150) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, …] +console-object-preview.js:70 Object with properties containing whitespaces +console-object-preview.js:77 {" a b ": " a b ", c d: "c d", "": "", " ": " ", "a↵↵b↵c": "a↵↵b↵c"} +console-object-preview.js:79 Object with a document.all property +console-object-preview.js:80 {all: HTMLAllCollection(4)} +console-object-preview.js:82 Object with special numbers +console-object-preview.js:84 {nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0} +console-object-preview.js:86 Object with exactly 5 properties: expected to be lossless +console-object-preview.js:87 {a: 1, b: 2, c: 3, d: 4, e: 5} +console-object-preview.js:89 {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false} Expanded all messages -console-object-preview.js:10 Mutating object in a loop console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:14 {a: 0, b: 0, c: 0}a: 0b: 0c: 2__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:14 {a: 0, b: 0, c: 1}a: 0b: 0c: 2__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:14 {a: 0, b: 0, c: 2}a: 0b: 0c: 2__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:17 Mutating array in a loop console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:21 (3) [0, 0, 0]0: 01: 02: 2length: 3__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:21 (3) [0, 0, 1]0: 01: 02: 2length: 3__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:21 (3) [0, 0, 2]0: 01: 02: 2length: 3__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:24 Object with many properties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:29 {property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …}property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:31 Array with many properties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:36 (2) [0, 1, property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …]0: 01: 1property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9length: 2__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:38 Array with gaps and overflow console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:43 (5733) [32: 0, 89: 1, 146: 2, 203: 3, 260: 4, 317: 5, 374: 6, 431: 7, 488: 8, 545: 9, 602: 10, 659: 11, 716: 12, 773: 13, 830: 14, 887: 15, 944: 16, 1001: 17, 1058: 18, 1115: 19, 1172: 20, 1229: 21, 1286: 22, 1343: 23, 1400: 24, 1457: 25, 1514: 26, 1571: 27, 1628: 28, 1685: 29, 1742: 30, 1799: 31, 1856: 32, 1913: 33, 1970: 34, 2027: 35, 2084: 36, 2141: 37, 2198: 38, 2255: 39, 2312: 40, 2369: 41, 2426: 42, 2483: 43, 2540: 44, 2597: 45, 2654: 46, 2711: 47, 2768: 48, 2825: 49, 2882: 50, 2939: 51, 2996: 52, 3053: 53, 3110: 54, 3167: 55, 3224: 56, 3281: 57, 3338: 58, 3395: 59, 3452: 60, 3509: 61, 3566: 62, 3623: 63, 3680: 64, 3737: 65, 3794: 66, 3851: 67, 3908: 68, 3965: 69, 4022: 70, 4079: 71, 4136: 72, 4193: 73, 4250: 74, 4307: 75, 4364: 76, 4421: 77, 4478: 78, 4535: 79, 4592: 80, 4649: 81, 4706: 82, 4763: 83, 4820: 84, 4877: 85, 4934: 86, 4991: 87, 5048: 88, 5105: 89, 5162: 90, 5219: 91, 5276: 92, 5333: 93, 5390: 94, 5447: 95, 5504: 96, 5561: 97, 5618: 98, 5675: 99, …][32 … 5675]573 console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > parent object-properties-section-name > selection fill > tree-element-title > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:45 Array with gaps without overflow console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:50 (5619) [empty × 32, 0, empty × 56, 1, empty × 56, 2, empty × 56, 3, empty × 56, 4, empty × 56, 5, empty × 56, 6, empty × 56, 7, empty × 56, 8, empty × 56, 9, empty × 56, 10, empty × 56, 11, empty × 56, 12, empty × 56, 13, empty × 56, 14, empty × 56, 15, empty × 56, 16, empty × 56, 17, empty × 56, 18, empty × 56, 19, empty × 56, 20, empty × 56, 21, empty × 56, 22, empty × 56, 23, empty × 56, 24, empty × 56, 25, empty × 56, 26, empty × 56, 27, empty × 56, 28, empty × 56, 29, empty × 56, 30, empty × 56, 31, empty × 56, 32, empty × 56, 33, empty × 56, 34, empty × 56, 35, empty × 56, 36, empty × 56, 37, empty × 56, 38, empty × 56, 39, empty × 56, 40, empty × 56, 41, empty × 56, 42, empty × 56, 43, empty × 56, 44, empty × 56, 45, empty × 56, 46, empty × 56, 47, empty × 56, 48, empty × 56, 49, empty × 56, 50, empty × 56, 51, empty × 56, 52, empty × 56, 53, empty × 56, 54, empty × 56, 55, empty × 56, 56, empty × 56, 57, empty × 56, 58, empty × 56, 59, empty × 56, 60, empty × 56, 61, empty console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-value-undefined > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:52 Object with proto console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:55 {d: 1}d: 1__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:57 Sparse array console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:60 (150) [empty × 50, 50, empty × 99]50: 50length: 150__proto__: Array(0) console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-undefined > object-value-number > object-value-undefined > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:62 Dense array with indexes and propeties console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:68 (150) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, …][0 … 99][100 … 149]property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9property_10: 10property_11: 11property_12: 12property_13: 13property_14: 14property_15: 15property_16: 16property_17: 17property_18: 18property_19: 19property_20: 20property_21: 21property_22: 22property_23: 23property_24: 24property_25: 25property_26: 26property_27: 27property_28: 28property_29: 29property_30: 30property_31: 31property_32: 32property_33: 33property_34: 34property_35: 35property_36: 36property_37: 37property_38: 38property_39: console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-array source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-value-number > object-state-note info-note > children expanded > parent object-properties-section-name > selection fill > tree-element-title > children > parent object-properties-section-name > selection fill > tree-element-title > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name object-properties-section-dimmed > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-array value > children -console-object-preview.js:70 Object with properties containing whitespaces console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:77 {" a b ": " a b ", c d: "c d", "": "", " ": " ", "a↵↵b↵c": "a↵↵b↵c"}"": """ ": " "" a b ": " a b ""a↵↵b↵c": "a↵↵b↵c"c d: "c d"__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-string > name > object-value-string > name > object-value-string > name > object-value-string > name > object-value-string > object-state-note info-note > children expanded > selection fill > name > object-value-string value > object-value-string-quote > object-value-string-quote > children > selection fill > name > object-value-string value > object-value-string-quote > object-value-string-quote > children > selection fill > name > object-value-string value > object-value-string-quote > object-value-string-quote > children > selection fill > name > object-value-string value > object-value-string-quote > object-value-string-quote > children > selection fill > name > object-value-string value > object-value-string-quote > object-value-string-quote > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:79 Object with a document.all property console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:80 {all: HTMLAllCollection(4)}all: HTMLAllCollection(4) [html, head, base, body]__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-array > object-state-note info-note > children expanded > parent > selection fill > name > object-value-array value > object-description > object-properties-preview > object-value-node > webkit-html-tag-name > object-value-node > webkit-html-tag-name > object-value-node > webkit-html-tag-name > object-value-node > webkit-html-tag-name > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:82 Object with special numbers console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:84 {nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0}nan: NaNnegInf: -InfinitynegZero: -0posInf: Infinity__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:86 Object with exactly 5 properties: expected to be lossless console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text -console-object-preview.js:87 {a: 1, b: 2, c: 3, d: 4, e: 5}a: 1b: 2c: 3d: 4e: 5__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > selection fill > name > object-value-number value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children -console-object-preview.js:89 {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false}bool: falsenull: nullregexp: /^[regexp]$/gundef: undefined__proto__: Object console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-object source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-properties-preview > name > object-value-null > name > object-value-undefined > name > object-value-regexp > name > object-value-boolean > object-state-note info-note > children expanded > selection fill > name > object-value-boolean value > children > selection fill > name > object-value-null value > children > parent > selection fill > name > object-value-regexp value > object-value-regexp > children > selection fill > name > object-value-undefined value > children > parent > selection fill > name object-properties-section-dimmed > object-value-object value > children +console-object-preview.js:10 Mutating object in a loop +console-object-preview.js:14 {a: 0, b: 0, c: 0}a: 0b: 0c: 2__proto__: Object +console-object-preview.js:14 {a: 0, b: 0, c: 1}a: 0b: 0c: 2__proto__: Object +console-object-preview.js:14 {a: 0, b: 0, c: 2}a: 0b: 0c: 2__proto__: Object +console-object-preview.js:17 Mutating array in a loop +console-object-preview.js:21 (3) [0, 0, 0]0: 01: 02: 2length: 3__proto__: Array(0) +console-object-preview.js:21 (3) [0, 0, 1]0: 01: 02: 2length: 3__proto__: Array(0) +console-object-preview.js:21 (3) [0, 0, 2]0: 01: 02: 2length: 3__proto__: Array(0) +console-object-preview.js:24 Object with many properties +console-object-preview.js:29 {property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …}property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9__proto__: Object +console-object-preview.js:31 Array with many properties +console-object-preview.js:36 (2) [0, 1, property_0: 0, property_1: 1, property_2: 2, property_3: 3, property_4: 4, …]0: 01: 1property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9length: 2__proto__: Array(0) +console-object-preview.js:38 Array with gaps and overflow +console-object-preview.js:43 (5733) [32: 0, 89: 1, 146: 2, 203: 3, 260: 4, 317: 5, 374: 6, 431: 7, 488: 8, 545: 9, 602: 10, 659: 11, 716: 12, 773: 13, 830: 14, 887: 15, 944: 16, 1001: 17, 1058: 18, 1115: 19, 1172: 20, 1229: 21, 1286: 22, 1343: 23, 1400: 24, 1457: 25, 1514: 26, 1571: 27, 1628: 28, 1685: 29, 1742: 30, 1799: 31, 1856: 32, 1913: 33, 1970: 34, 2027: 35, 2084: 36, 2141: 37, 2198: 38, 2255: 39, 2312: 40, 2369: 41, 2426: 42, 2483: 43, 2540: 44, 2597: 45, 2654: 46, 2711: 47, 2768: 48, 2825: 49, 2882: 50, 2939: 51, 2996: 52, 3053: 53, 3110: 54, 3167: 55, 3224: 56, 3281: 57, 3338: 58, 3395: 59, 3452: 60, 3509: 61, 3566: 62, 3623: 63, 3680: 64, 3737: 65, 3794: 66, 3851: 67, 3908: 68, 3965: 69, 4022: 70, 4079: 71, 4136: 72, 4193: 73, 4250: 74, 4307: 75, 4364: 76, 4421: 77, 4478: 78, 4535: 79, 4592: 80, 4649: 81, 4706: 82, 4763: 83, 4820: 84, 4877: 85, 4934: 86, 4991: 87, 5048: 88, 5105: 89, 5162: 90, 5219: 91, 5276: 92, 5333: 93, 5390: 94, 5447: 95, 5504: 96, 5561: 97, 5618: 98, 5675: 99, …][32 … 5675]573 +console-object-preview.js:45 Array with gaps without overflow +console-object-preview.js:50 (5619) [empty × 32, 0, empty × 56, 1, empty × 56, 2, empty × 56, 3, empty × 56, 4, empty × 56, 5, empty × 56, 6, empty × 56, 7, empty × 56, 8, empty × 56, 9, empty × 56, 10, empty × 56, 11, empty × 56, 12, empty × 56, 13, empty × 56, 14, empty × 56, 15, empty × 56, 16, empty × 56, 17, empty × 56, 18, empty × 56, 19, empty × 56, 20, empty × 56, 21, empty × 56, 22, empty × 56, 23, empty × 56, 24, empty × 56, 25, empty × 56, 26, empty × 56, 27, empty × 56, 28, empty × 56, 29, empty × 56, 30, empty × 56, 31, empty × 56, 32, empty × 56, 33, empty × 56, 34, empty × 56, 35, empty × 56, 36, empty × 56, 37, empty × 56, 38, empty × 56, 39, empty × 56, 40, empty × 56, 41, empty × 56, 42, empty × 56, 43, empty × 56, 44, empty × 56, 45, empty × 56, 46, empty × 56, 47, empty × 56, 48, empty × 56, 49, empty × 56, 50, empty × 56, 51, empty × 56, 52, empty × 56, 53, empty × 56, 54, empty × 56, 55, empty × 56, 56, empty × 56, 57, empty × 56, 58, empty × 56, 59, empty × 56, 60, empty × 56, 61, empty +console-object-preview.js:52 Object with proto +console-object-preview.js:55 {d: 1}d: 1__proto__: Object +console-object-preview.js:57 Sparse array +console-object-preview.js:60 (150) [empty × 50, 50, empty × 99]50: 50length: 150__proto__: Array(0) +console-object-preview.js:62 Dense array with indexes and propeties +console-object-preview.js:68 (150) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, …][0 … 99][100 … 149]property_0: 0property_1: 1property_2: 2property_3: 3property_4: 4property_5: 5property_6: 6property_7: 7property_8: 8property_9: 9property_10: 10property_11: 11property_12: 12property_13: 13property_14: 14property_15: 15property_16: 16property_17: 17property_18: 18property_19: 19property_20: 20property_21: 21property_22: 22property_23: 23property_24: 24property_25: 25property_26: 26property_27: 27property_28: 28property_29: 29property_30: 30property_31: 31property_32: 32property_33: 33property_34: 34property_35: 35property_36: 36property_37: 37property_38: 38property_39: +console-object-preview.js:70 Object with properties containing whitespaces +console-object-preview.js:77 {" a b ": " a b ", c d: "c d", "": "", " ": " ", "a↵↵b↵c": "a↵↵b↵c"}"": """ ": " "" a b ": " a b ""a↵↵b↵c": "a↵↵b↵c"c d: "c d"__proto__: Object +console-object-preview.js:79 Object with a document.all property +console-object-preview.js:80 {all: HTMLAllCollection(4)}all: HTMLAllCollection(4) [html, head, base, body]__proto__: Object +console-object-preview.js:82 Object with special numbers +console-object-preview.js:84 {nan: NaN, posInf: Infinity, negInf: -Infinity, negZero: -0}nan: NaNnegInf: -InfinitynegZero: -0posInf: Infinity__proto__: Object +console-object-preview.js:86 Object with exactly 5 properties: expected to be lossless +console-object-preview.js:87 {a: 1, b: 2, c: 3, d: 4, e: 5}a: 1b: 2c: 3d: 4e: 5__proto__: Object +console-object-preview.js:89 {null: null, undef: undefined, regexp: /^[regexp]$/g, bool: false}bool: falsenull: nullregexp: /^[regexp]$/gundef: undefined__proto__: Object
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview.js index e0001f4..621b74226 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview.js +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-object-preview.js
@@ -89,16 +89,12 @@ console.log({null:null, undef:undefined, regexp: \/^[regexp]$\/g, bool: false}); `); -// TestRunner.evaluateInPage('logToConsole()', step2); - -// function step2() { - ConsoleTestRunner.dumpConsoleMessages(false, true); - TestRunner.addResult('Expanded all messages'); - ConsoleTestRunner.expandConsoleMessages(step3); -// } + ConsoleTestRunner.dumpConsoleMessages(); + TestRunner.addResult('Expanded all messages'); + ConsoleTestRunner.expandConsoleMessages(step3); function step3() { - ConsoleTestRunner.dumpConsoleMessages(false, true); + ConsoleTestRunner.dumpConsoleMessages(); TestRunner.completeTest(); } })();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy-expected.txt index 117653f..290c7adb 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy-expected.txt
@@ -1,10 +1,10 @@ Tests that console logging dumps proxy properly. -console-proxy.js:25 Proxy {boo: 42, foo: 43} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-proxy source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > object-state-note info-note > children -console-proxy.js:27 Proxy {boo: 42, foo: 43} console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-proxy source-code > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > object-state-note info-note > children +console-proxy.js:25 Proxy {boo: 42, foo: 43} +console-proxy.js:27 Proxy {boo: 42, foo: 43} window.accessedGet = false info-note display: inline-block -console-proxy.js:25 Proxy {boo: 42, foo: 43}[[Handler]]: Object[[Target]]: Object[[IsRevoked]]: false console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-proxy source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > parent > selection fill > name > object-value-object value > children > parent > selection fill > name > object-value-object value > children > selection fill > name > object-value-boolean value > children -console-proxy.js:27 Proxy {boo: 42, foo: 43}[[Handler]]: Object[[Target]]: Proxy[[IsRevoked]]: false console-message > source-code > console-message-anchor > devtools-link > hidden console-message-badge > hide-badge-title > console-message-text > console-view-object-properties-section object-value-proxy source-code expanded > tree-outline-disclosure tree-outline-disclosure-hide-overflow > tree-outline source-code object-properties-section > parent object-properties-section-root-element expanded > selection fill > console-object console-object-preview > object-description > object-properties-preview > name > object-value-number > name > object-value-number > object-state-note info-note > children expanded > parent > selection fill > name > object-value-object value > children > parent > selection fill > name > object-value-proxy value > children > selection fill > name > object-value-boolean value > children +console-proxy.js:25 Proxy {boo: 42, foo: 43}[[Handler]]: Object[[Target]]: Object[[IsRevoked]]: false +console-proxy.js:27 Proxy {boo: 42, foo: 43}[[Handler]]: Object[[Target]]: Proxy[[IsRevoked]]: false window.accessedGet = false
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy.js b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy.js index 2f42714..376501c 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy.js +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/console/console-proxy.js
@@ -36,7 +36,7 @@ consoleView._viewport.invalidate(); var element = consoleView._visibleViewMessages[0].contentElement(); - ConsoleTestRunner.dumpConsoleMessages(false, true); + ConsoleTestRunner.dumpConsoleMessages(); TestRunner.evaluateInPage('window.accessedGet', dumpAccessedGetAndExpand); } @@ -49,7 +49,7 @@ var element = Console.ConsoleView.instance()._visibleViewMessages[0].contentElement(); dumpNoteVisible(element, 'info-note'); - ConsoleTestRunner.dumpConsoleMessages(false, true); + ConsoleTestRunner.dumpConsoleMessages(); TestRunner.evaluateInPage('window.accessedGet', dumpAccessedGetAndCompleteTest); }
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles-expected.txt new file mode 100644 index 0000000..e77cb7b --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles-expected.txt
@@ -0,0 +1,11 @@ +Test CPU profiles are recorded for OOPIFs. + +name: CrRendererMain +url: http://127.0.0.1:8000/devtools/oopif/resources/page.html +has CpuProfile: true + +name: CrRendererMain +url: http://devtools.oopif.test:8000/devtools/oopif/resources/inner-iframe.html?second +has CpuProfile: true + +
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles.js b/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles.js new file mode 100644 index 0000000..c01f82d --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/oopif/oopif-performance-cpu-profiles.js
@@ -0,0 +1,24 @@ +// 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. + +(async function() { + TestRunner.addResult(`Test CPU profiles are recorded for OOPIFs.\n`); + + await TestRunner.loadModule('performance_test_runner'); + await TestRunner.showPanel('timeline'); + + await PerformanceTestRunner.startTimeline(); + await TestRunner.navigatePromise('resources/page.html'); + await PerformanceTestRunner.stopTimeline(); + + for (const track of PerformanceTestRunner.timelineModel().tracks().sort((a, b) => a.url > b.url)) { + if (track.type !== TimelineModel.TimelineModel.TrackType.MainThread) + continue; + TestRunner.addResult(`name: ${track.name}`); + TestRunner.addResult(`url: ${track.url}`); + TestRunner.addResult(`has CpuProfile: ${track.thread.events().some(e => e.name === 'CpuProfile')}\n`); + } + + TestRunner.completeTest(); +})();
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-fix-missing-samples-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-fix-missing-samples-expected.txt index 370f5357..eb2b201d 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-fix-missing-samples-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-fix-missing-samples-expected.txt
@@ -8,34 +8,34 @@ baz id:5 total:3.2 self:3.2 depth:0 raw samples: 3 4 3 4 3 6 2 2 3 6 3 3 6 5 3 6 samples: 3 4 4 4 4 6 2 2 3 6 3 3 6 5 3 6 -timestamps: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 +timestamps: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 forEachFrame iterator structure: -+ 0 (program) 1 -- 0 (program) 1 1 1 -+ 0 bar 2 - + 1 foo 6 - + 2 (garbage collector) 7 - - 2 (garbage collector) 7 2 2 - - 1 foo 6 3 1 -- 0 bar 2 7 4 -+ 0 (program) 9 -- 0 (program) 9 1 1 -+ 0 bar 10 - + 1 foo 10 - - 1 foo 10 1 1 -- 0 bar 10 1 0 -+ 0 (program) 11 -- 0 (program) 11 2 2 -+ 0 bar 13 - + 1 foo 13 - - 1 foo 13 1 1 -- 0 bar 13 1 0 -+ 0 baz 14 -- 0 baz 14 1 1 -+ 0 (program) 15 -- 0 (program) 15 1 1 -+ 0 bar 16 - + 1 foo 16 - - 1 foo 16 1 1 -- 0 bar 16 1 0 ++ 0 (program) 2 +- 0 (program) 2 1 1 ++ 0 bar 3 + + 1 foo 7 + + 2 (garbage collector) 8 + - 2 (garbage collector) 8 2 2 + - 1 foo 7 3 1 +- 0 bar 3 7 4 ++ 0 (program) 10 +- 0 (program) 10 1 1 ++ 0 bar 11 + + 1 foo 11 + - 1 foo 11 1 1 +- 0 bar 11 1 0 ++ 0 (program) 12 +- 0 (program) 12 2 2 ++ 0 bar 14 + + 1 foo 14 + - 1 foo 14 1 1 +- 0 bar 14 1 0 ++ 0 baz 15 +- 0 baz 15 1 1 ++ 0 (program) 16 +- 0 (program) 16 1 1 ++ 0 bar 17 + + 1 foo 17 + - 1 foo 17 0 0 +- 0 bar 17 0 0
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-parsing-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-parsing-expected.txt index e42b2b1..11e36f6 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-parsing-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/profiler/cpu-profiler-parsing-expected.txt
@@ -5,14 +5,14 @@ foo id:3 total:2 self:1 depth:0 bar id:4 total:1 self:1 depth:1 samples: 4, 4, 3, 4, 2 -timestamps: 1, 1.5, 1.75, 2.75, 3, 4 +timestamps: 1.5, 1.75, 2.75, 3, 4, 4 forEachFrame iterator structure: -+ 0 foo 1 - + 1 bar 1 - - 1 bar 1 0.75 0.75 - + 1 bar 2.75 - + 2 (garbage collector) 3 - - 2 (garbage collector) 3 1 1 - - 1 bar 2.75 1.25 0.25 -- 0 foo 1 3 1 ++ 0 foo 1.5 + + 1 bar 1.5 + - 1 bar 1.5 1.25 1.25 + + 1 bar 3 + + 2 (garbage collector) 4 + - 2 (garbage collector) 4 0 0 + - 1 bar 3 1 1 +- 0 foo 1.5 2.5 0.25
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-ui/watch-expressions-preserve-expansion-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-ui/watch-expressions-preserve-expansion-expected.txt index 8fe7ba7..a8906de2 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-ui/watch-expressions-preserve-expansion-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/sources/debugger-ui/watch-expressions-preserve-expansion-expected.txt
@@ -128,7 +128,7 @@ name: prototype: Object __proto__: function () { [native code] } - [[FunctionLocation]]: Object + [[FunctionLocation]]: undefined [[Scopes]]: Scopes[2] 0: Closure a: 10 @@ -255,7 +255,7 @@ name: prototype: Object __proto__: function () { [native code] } - [[FunctionLocation]]: Object + [[FunctionLocation]]: undefined [[Scopes]]: Scopes[2] 0: Closure a: 10
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/timeline-js/timeline-js-streamed-cpu-profile-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/timeline-js/timeline-js-streamed-cpu-profile-expected.txt index c991e20..d15b204 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/timeline-js/timeline-js-streamed-cpu-profile-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/timeline-js/timeline-js-streamed-cpu-profile-expected.txt
@@ -1,5 +1,5 @@ Tests streaming CPU profile within trace log. -JSFrame: 110.000 / 7.000 foo -JSFrame: 114.000 / 2.000 bar +JSFrame: 111.000 / 6.500 foo +JSFrame: 114.500 / 2.500 bar
diff --git a/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/trace-event-self-time-expected.txt b/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/trace-event-self-time-expected.txt index 9e699462..f405b90 100644 --- a/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/trace-event-self-time-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/devtools/tracing/trace-event-self-time-expected.txt
@@ -8,19 +8,19 @@ Layout: 220 50.00/50.00 Program: 400 40.00/100.00 EventDispatch: 410 40.00/60.00 -FunctionCall: 420 0.00/10.00 -JSFrame: 420 5.00/10.00 -JSSample: 420 0.00/0.00 +FunctionCall: 420 1.00/10.00 +JSFrame: 421 4.00/9.00 JSSample: 421 0.00/0.00 -JSFrame: 422 3.00/3.00 JSSample: 422 0.00/0.00 +JSFrame: 423 3.00/3.00 JSSample: 423 0.00/0.00 JSSample: 424 0.00/0.00 -JSFrame: 425 2.00/2.00 JSSample: 425 0.00/0.00 +JSFrame: 426 2.00/2.00 JSSample: 426 0.00/0.00 JSSample: 427 0.00/0.00 JSSample: 428 0.00/0.00 +JSSample: 429 0.00/0.00 FunctionCall: 440 10.00/10.00 Animation: 445 0.00/800.00 timestamp: 450 0.00/895.00
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/terminate-execution-with-fetch-callbacks-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/terminate-execution-with-fetch-callbacks-expected.txt index 7e01385..0d16644 100644 --- a/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/terminate-execution-with-fetch-callbacks-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/terminate-execution-with-fetch-callbacks-expected.txt
@@ -1,6 +1,5 @@ Tests terminate execution. { - description : 1 type : number value : 1 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/console/console-let-const-with-api-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/console/console-let-const-with-api-expected.txt index db5ebb5..c9084b8 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/console/console-let-const-with-api-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/console/console-let-const-with-api-expected.txt
@@ -3,7 +3,7 @@ second 'let a = 1;' result: wasThrown = true exception message: Uncaught SyntaxError: Identifier 'a' has already been declared at <anonymous>:1:1 -{"result":{"type":"number","value":42,"description":"42"}} +{"result":{"type":"number","value":42}} function $(selector, [startNode]) { [Command Line API] } function $$(selector, [startNode]) { [Command Line API] } function $x(xpath, [startNode]) { [Command Line API] }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-scope-skip-variables-with-empty-name-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-scope-skip-variables-with-empty-name-expected.txt index 38b54a7..98c447c 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-scope-skip-variables-with-empty-name-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/debugger-scope-skip-variables-with-empty-name-expected.txt
@@ -7,7 +7,6 @@ isOwn : true name : a value : { - description : 2 type : number value : 2 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource-expected.txt index 8381592c..16281b0 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource-expected.txt
@@ -1,7 +1,7 @@ Tests setScriptSource functionality. -Function evaluate: {"type":"number","value":6,"description":"6"} +Function evaluate: {"type":"number","value":6} PASS, result value: 6 -Function evaluate: {"type":"number","value":8,"description":"8"} +Function evaluate: {"type":"number","value":8} PASS, result value: 8 Has error reported: PASS Reported error is a compile error: PASS
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise-expected.txt index e31ec1b6..c02e251 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-await-promise-expected.txt
@@ -3,7 +3,6 @@ Running test: testResolvedPromise { result : { - description : 239 type : number value : 239 } @@ -37,7 +36,6 @@ exceptionDetails : { columnNumber : 0 exception : { - description : 239 objectId : <number> type : number value : 239 @@ -47,7 +45,6 @@ text : Uncaught (in promise) } result : { - description : 239 type : number value : 239 } @@ -56,7 +53,6 @@ Running test: testPendingPromise { result : { - description : 239 type : number value : 239 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt index 19b6e61..d45b87d 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-callFunctionOn-async-expected.txt
@@ -61,7 +61,6 @@ Running test: testFunctionReturnNotPromise { result : { - description : 239 type : number value : 239 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api-expected.txt index db9f0d6..25529c6 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-clear-of-command-line-api-expected.txt
@@ -2,14 +2,12 @@ { result : { - description : 15 type : number value : 15 } } { result : { - description : 0 type : number value : 0 } @@ -17,21 +15,18 @@ setPropertyForMethod() { result : { - description : 14 type : number value : 14 } } { result : { - description : 0 type : number value : 0 } } { result : { - description : 42 type : number value : 42 } @@ -39,21 +34,18 @@ defineValuePropertyForMethod() { result : { - description : 14 type : number value : 14 } } { result : { - description : 0 type : number value : 0 } } { result : { - description : 42 type : number value : 42 } @@ -61,21 +53,18 @@ definePropertiesForMethod() { result : { - description : 14 type : number value : 14 } } { result : { - description : 0 type : number value : 0 } } { result : { - description : 42 type : number value : 42 } @@ -83,21 +72,18 @@ defineAccessorPropertyForMethod() { result : { - description : 14 type : number value : 14 } } { result : { - description : 0 type : number value : 0 } } { result : { - description : 42 type : number value : 42 } @@ -105,21 +91,18 @@ redefineGetOwnPropertyDescriptors() { result : { - description : 14 type : number value : 14 } } { result : { - description : 0 type : number value : 0 } } { result : { - description : 42 type : number value : 42 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-line-and-column-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-line-and-column-expected.txt index e298f8c1c..92bd363a7 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-line-and-column-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-line-and-column-expected.txt
@@ -4,7 +4,6 @@ params : { args : [ [0] : { - description : 239 type : number value : 239 } @@ -30,7 +29,6 @@ params : { args : [ [0] : { - description : 239 type : number value : 239 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-log-doesnt-run-microtasks-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-log-doesnt-run-microtasks-expected.txt index 5a234ec7..343c1e0f 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-log-doesnt-run-microtasks-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-console-log-doesnt-run-microtasks-expected.txt
@@ -1,16 +1,13 @@ Check that console.log doesn't run microtasks. { - description : 42 type : number value : 42 } { - description : 43 type : number value : 43 } { - description : 239 type : number value : 239 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async-expected.txt index 8153c1e..674f3e7 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-async-expected.txt
@@ -3,7 +3,6 @@ Running test: testResolvedPromise { result : { - description : 239 type : number value : 239 } @@ -14,7 +13,6 @@ exceptionDetails : { columnNumber : 0 exception : { - description : 239 objectId : <number> type : number value : 239 @@ -25,7 +23,6 @@ text : Uncaught (in promise) } result : { - description : 239 type : number value : 239 } @@ -63,7 +60,6 @@ exceptionDetails : { columnNumber : 0 exception : { - description : 239 objectId : <number> type : number value : 239 @@ -74,7 +70,6 @@ text : Uncaught } result : { - description : 239 type : number value : 239 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-in-default-context-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-in-default-context-expected.txt index f34c8bb..adbdc0e 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-in-default-context-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-evaluate-in-default-context-expected.txt
@@ -3,7 +3,6 @@ id : <number> result : { result : { - description : 42 type : number value : 42 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-get-properties-on-proxy-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-get-properties-on-proxy-expected.txt index 151ea38..05fdc13 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-get-properties-on-proxy-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-get-properties-on-proxy-expected.txt
@@ -1,7 +1,6 @@ Check that while Runtime.getProperties call on proxy object no user defined trap will be executed. { result : { - description : 0 type : number value : 0 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-property-on-console-proto-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-property-on-console-proto-expected.txt index ca6bbf9..b69fcbc7 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-property-on-console-proto-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/runtime/runtime-property-on-console-proto-expected.txt
@@ -3,7 +3,6 @@ id : <number> result : { result : { - description : 0 type : number value : 0 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/sessions/runtime-evaluate-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/sessions/runtime-evaluate-expected.txt index eb588a3..8fa1b52e 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/sessions/runtime-evaluate-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/sessions/runtime-evaluate-expected.txt
@@ -4,7 +4,6 @@ id : <number> result : { result : { - description : 42 type : number value : 42 } @@ -15,7 +14,6 @@ id : <number> result : { result : { - description : 42 type : number value : 42 } @@ -26,7 +24,6 @@ id : <number> result : { result : { - description : 42 type : number value : 42 }
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/target/target-send-message-expected.txt b/third_party/WebKit/LayoutTests/inspector-protocol/target/target-send-message-expected.txt index f43ed949..4e7f1f1 100644 --- a/third_party/WebKit/LayoutTests/inspector-protocol/target/target-send-message-expected.txt +++ b/third_party/WebKit/LayoutTests/inspector-protocol/target/target-send-message-expected.txt
@@ -8,5 +8,5 @@ JSON without id property.. {"error":{"code":-32600,"message":"Message must have integer 'id' property"}} Valid JSON.. -{"id":1,"result":{"result":{"type":"number","value":42,"description":"42"}}} +{"id":1,"result":{"result":{"type":"number","value":42}}}
diff --git a/third_party/WebKit/LayoutTests/media/controls/overflow-menu-always-visible.html b/third_party/WebKit/LayoutTests/media/controls/overflow-menu-always-visible.html index ffcc86f..2dad67e 100644 --- a/third_party/WebKit/LayoutTests/media/controls/overflow-menu-always-visible.html +++ b/third_party/WebKit/LayoutTests/media/controls/overflow-menu-always-visible.html
@@ -17,7 +17,6 @@ testRunner.waitUntilDone(); var video = document.querySelector('video'); - enableTestMode(video); video.src = '../content/test.ogv'; video.addTextTrack('captions', 'foo'); video.addTextTrack('captions', 'bar');
diff --git a/third_party/WebKit/LayoutTests/platform/win/virtual/color_space/fast/canvas/color-space/toDataURL-color-managed-round-trip-expected.png b/third_party/WebKit/LayoutTests/platform/win/virtual/color_space/fast/canvas/color-space/toDataURL-color-managed-round-trip-expected.png deleted file mode 100644 index 0a4896a..0000000 --- a/third_party/WebKit/LayoutTests/platform/win/virtual/color_space/fast/canvas/color-space/toDataURL-color-managed-round-trip-expected.png +++ /dev/null Binary files differ
diff --git a/third_party/WebKit/LayoutTests/virtual/android/fullscreen/rendering/backdrop-video-expected.html b/third_party/WebKit/LayoutTests/virtual/android/fullscreen/rendering/backdrop-video-expected.html new file mode 100644 index 0000000..99cbd08 --- /dev/null +++ b/third_party/WebKit/LayoutTests/virtual/android/fullscreen/rendering/backdrop-video-expected.html
@@ -0,0 +1,4 @@ +<!DOCTYPE html> +<!-- TODO(foolip): Setting the background on ::backdrop doesn't work on Android, + see crbug.com/627850 --> +<body style="background: black"></body>
diff --git a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt index 434b8ef..a8f0e19 100644 --- a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt
@@ -460,6 +460,7 @@ property willValidate html element canvas property captureStream + property convertToBlob property getContext property height property toBlob
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index ee11670..2bdcee7 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -2451,6 +2451,7 @@ getter width method captureStream method constructor + method convertToBlob method getContext method toBlob method toDataURL
diff --git a/third_party/android_crazy_linker/BUILD.gn b/third_party/android_crazy_linker/BUILD.gn index c020bd68..988f794 100644 --- a/third_party/android_crazy_linker/BUILD.gn +++ b/third_party/android_crazy_linker/BUILD.gn
@@ -165,7 +165,6 @@ configs += [ "//build/config/compiler:no_chromium_code" ] deps = [ ":android_crazy_linker_for_unittests", - "//build/config:exe_and_shlib_deps", "//testing/gtest", "//testing/gtest:gtest_main", ]
diff --git a/third_party/android_platform/BUILD.gn b/third_party/android_platform/BUILD.gn index 72fea380..fd2fd1e 100644 --- a/third_party/android_platform/BUILD.gn +++ b/third_party/android_platform/BUILD.gn
@@ -30,7 +30,6 @@ executable("android_relocation_packer") { deps = [ ":android_lib_relocation_packer", - "//build/config:exe_and_shlib_deps", "//third_party/elfutils:libelf", ] sources = [
diff --git a/third_party/android_protobuf/BUILD.gn b/third_party/android_protobuf/BUILD.gn index 1f29810a..1891d905 100644 --- a/third_party/android_protobuf/BUILD.gn +++ b/third_party/android_protobuf/BUILD.gn
@@ -28,7 +28,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//third_party/zlib", ]
diff --git a/third_party/blink/public/platform/modules/webauth/authenticator.mojom b/third_party/blink/public/platform/modules/webauth/authenticator.mojom index 71d8ed8..db190c4 100644 --- a/third_party/blink/public/platform/modules/webauth/authenticator.mojom +++ b/third_party/blink/public/platform/modules/webauth/authenticator.mojom
@@ -119,7 +119,7 @@ // Cloud-assisted BLE extension data for getAssertion. struct CableAuthentication { // The caBLE version requested. - int32 version; + uint8 version; // A 16-byte ephemeral identifier that the browser will advertise. array<uint8, 16> client_eid; @@ -136,7 +136,7 @@ // Cloud-assisted BLE extension data for makeCredential. struct CableRegistration { // The caBLE versions supported by the relying party. - array<int32> versions; + array<uint8> versions; // The 65-byte ECDSA ephemeral public key belonging to the relying party // for use in establishing an encrypted caBLE channel with an authenticator. @@ -279,4 +279,9 @@ // |GetAssertionResponse| will be set if and only if status == SUCCESS. GetAssertion(PublicKeyCredentialRequestOptions options) => (AuthenticatorStatus status, GetAssertionAuthenticatorResponse? credential); + + // Returns true if the user platform provides an authenticator. Relying + // Parties use this method to determine whether they can create a new + // credential using a user-verifying platform authenticator. + IsUserVerifyingPlatformAuthenticatorAvailable() => (bool available); };
diff --git a/third_party/blink/public/platform/web_feature.mojom b/third_party/blink/public/platform/web_feature.mojom index 7e565a9..7264332d 100644 --- a/third_party/blink/public/platform/web_feature.mojom +++ b/third_party/blink/public/platform/web_feature.mojom
@@ -1932,6 +1932,7 @@ kShapeOutsidePaddingBoxDifferentFromMarginBox = 2462, kCSSContainLayoutPositionedDescendants = 2463, kHTMLFrameSetElementAnonymousNamedGetter = 2464, + kCanvasConvertToBlob = 2465, // 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/renderer/core/core_idl_files.gni b/third_party/blink/renderer/core/core_idl_files.gni index a94060a..0aa6ddf 100644 --- a/third_party/blink/renderer/core/core_idl_files.gni +++ b/third_party/blink/renderer/core/core_idl_files.gni
@@ -623,6 +623,7 @@ "html/focus_options.idl", "html/assigned_nodes_options.idl", "html/canvas/image_data_color_settings.idl", + "html/canvas/image_encode_options.idl", "html/track/track_event_init.idl", "imagebitmap/image_bitmap_options.idl", "input/input_device_capabilities_init.idl", @@ -645,7 +646,6 @@ "mojo/mojo_write_data_options.idl", "mojo/mojo_write_data_result.idl", "mojo/test/mojo_interface_request_event_init.idl", - "offscreencanvas/image_encode_options.idl", "page/scrolling/scroll_state_init.idl", "timing/performance_mark_options.idl", "timing/performance_measure_options.idl",
diff --git a/third_party/blink/renderer/core/css/fullscreen.css b/third_party/blink/renderer/core/css/fullscreen.css index fa0079a..8023bdb 100644 --- a/third_party/blink/renderer/core/css/fullscreen.css +++ b/third_party/blink/renderer/core/css/fullscreen.css
@@ -1,64 +1,48 @@ -:-webkit-full-screen { - background-color: white; - z-index: 2147483647 !important; -} - -:root:-webkit-full-screen-ancestor { - overflow: hidden !important; -} - -:-webkit-full-screen-ancestor:not(iframe) { - z-index: auto !important; - position: static !important; - opacity: 1 !important; - transform: none !important; - -webkit-mask: none !important; - clip: none !important; - -webkit-filter: none !important; - transition: none !important; - -webkit-box-reflect: none !important; - -webkit-perspective: none !important; - -webkit-transform-style: flat !important; - will-change: auto !important; -} - -video:-webkit-full-screen, audio:-webkit-full-screen { - background-color: transparent !important; - position: relative !important; +:not(:root):-webkit-full-screen { + position: fixed !important; + top: 0 !important; + right: 0 !important; + bottom: 0 !important; left: 0 !important; - top: 0 ! important; margin: 0 !important; + box-sizing: border-box !important; min-width: 0 !important; max-width: none !important; min-height: 0 !important; max-height: none !important; width: 100% !important; height: 100% !important; - flex: 1 !important; - display: block !important; transform: none !important; -} -img:-webkit-full-screen { - width: auto; - height: 100%; - max-width: 100%; + /* intentionally not !important */ + object-fit: contain; } iframe:-webkit-full-screen { - margin: 0 !important; + border: none !important; padding: 0 !important; - border: 0 !important; - position: fixed !important; - min-width: 0 !important; - max-width: none !important; - min-height: 0 !important; - max-height: none !important; - width: 100% !important; - height: 100% !important; - left: 0 !important; - top: 0 !important; - transform: none !important; +} + +/* TODO(foolip): In the spec, there's a ::backdrop block with the properties + shared with dialog::backdrop (see html.css). */ +:not(:root):-webkit-full-screen::backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: black; +} + +/* Anything below are extensions over what the Fullscreen API (29 May 2018) mandates. */ + +/* This prevents video from overflowing the viewport in + virtual/android/fullscreen/video-scrolled-iframe.html (crbug.com/441890) and + removes scrollbars caused by html { overflow: scroll } (crbug.com/543946). + TODO(foolip): This is done differently in Gecko, find a fix not involving the + ancestor selector in https://github.com/whatwg/fullscreen/issues/19. */ +:root:-webkit-full-screen-ancestor { + overflow: hidden !important; } :-webkit-full-screen:-internal-video-persistent-ancestor :not(:-internal-video-persistent-ancestor) {
diff --git a/third_party/blink/renderer/core/css/html.css b/third_party/blink/renderer/core/css/html.css index 0a41985..a28d5f6 100644 --- a/third_party/blink/renderer/core/css/html.css +++ b/third_party/blink/renderer/core/css/html.css
@@ -1124,6 +1124,8 @@ color: black } +/* TODO(foolip): In the Fullscreen spec, there's a ::backdrop block with the + properties shared with :fullscreen::backdrop (see fullscreen.css). */ dialog::backdrop { position: fixed; top: 0;
diff --git a/third_party/blink/renderer/core/css/resolver/style_resolver.cc b/third_party/blink/renderer/core/css/resolver/style_resolver.cc index d170555..c575295 100644 --- a/third_party/blink/renderer/core/css/resolver/style_resolver.cc +++ b/third_party/blink/renderer/core/css/resolver/style_resolver.cc
@@ -845,8 +845,13 @@ !FirstLetterPseudoElement::FirstLetterTextLayoutObject(parent))) return nullptr; - if (!CanHaveGeneratedChildren(*parent_layout_object)) + // The backdrop pseudo element generates a new stacking context and its + // layout object does not become a child of |parentLayoutObject|. The + // exemption is needed so that replaced content also gets a backdrop. + if (pseudo_id != kPseudoIdBackdrop && + !CanHaveGeneratedChildren(*parent_layout_object)) { return nullptr; + } if (ComputedStyle* cached_style = parent_style->GetCachedPseudoStyle(pseudo_id)) {
diff --git a/third_party/blink/renderer/core/css/selector_checker.cc b/third_party/blink/renderer/core/css/selector_checker.cc index c0ebc3c..94d0cb65 100644 --- a/third_party/blink/renderer/core/css/selector_checker.cc +++ b/third_party/blink/renderer/core/css/selector_checker.cc
@@ -1046,14 +1046,6 @@ case CSSSelector::kPseudoFullscreen: // fall through case CSSSelector::kPseudoFullScreen: - // While a Document is in the fullscreen state, and the document's current - // fullscreen element is an element in the document, the 'full-screen' - // pseudoclass applies to that element. Also, an <iframe>, <object> or - // <embed> element whose child browsing context's Document is in the - // fullscreen state has the 'full-screen' pseudoclass applied. - if (IsHTMLFrameElementBase(element) && - element.ContainsFullScreenElement()) - return true; return Fullscreen::IsFullscreenElement(element); case CSSSelector::kPseudoFullScreenAncestor: return element.ContainsFullScreenElement();
diff --git a/third_party/blink/renderer/core/css/style_change_reason.cc b/third_party/blink/renderer/core/css/style_change_reason.cc index feeef7c..d17109a 100644 --- a/third_party/blink/renderer/core/css/style_change_reason.cc +++ b/third_party/blink/renderer/core/css/style_change_reason.cc
@@ -21,7 +21,7 @@ const char kFontSizeChange[] = "FontSizeChange"; const char kFonts[] = "Fonts"; const char kFrame[] = "Frame"; -const char kFullScreen[] = "FullScreen"; +const char kFullscreen[] = "Fullscreen"; const char kInheritedStyleChangeFromParentFrame[] = "InheritedStyleChangeFromParentFrame"; const char kInline[] = "Inline";
diff --git a/third_party/blink/renderer/core/css/style_change_reason.h b/third_party/blink/renderer/core/css/style_change_reason.h index 21ba756..3288796 100644 --- a/third_party/blink/renderer/core/css/style_change_reason.h +++ b/third_party/blink/renderer/core/css/style_change_reason.h
@@ -25,7 +25,7 @@ extern const char kFrame[]; extern const char kFontSizeChange[]; extern const char kFonts[]; -extern const char kFullScreen[]; +extern const char kFullscreen[]; extern const char kInheritedStyleChangeFromParentFrame[]; extern const char kInline[]; extern const char kInlineCSSStyleMutated[];
diff --git a/third_party/blink/renderer/core/dom/document.h b/third_party/blink/renderer/core/dom/document.h index b8060034..7a7a988 100644 --- a/third_party/blink/renderer/core/dom/document.h +++ b/third_party/blink/renderer/core/dom/document.h
@@ -1744,6 +1744,8 @@ // For early return in Fullscreen::fromIfExists() bool has_fullscreen_supplement_; + // The last element in |m_topLayerElements| is topmost in the top layer + // stack and is thus the one that will be visually on top. HeapVector<Member<Element>> top_layer_elements_; int load_event_delay_count_;
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index 2152592..9c177c8 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -1893,9 +1893,6 @@ } } - if (Fullscreen* fullscreen = Fullscreen::FromIfExists(GetDocument())) - fullscreen->ElementRemoved(*this); - if (GetDocument().GetPage()) GetDocument().GetPage()->GetPointerLockController().ElementRemoved(this); @@ -1931,7 +1928,10 @@ GetDocument().GetRootScrollerController().ElementRemoved(*this); - GetDocument().RemoveFromTopLayer(this); + if (IsInTopLayer()) { + Fullscreen::ElementRemoved(*this); + GetDocument().RemoveFromTopLayer(this); + } ClearElementFlag(ElementFlags::kIsInCanvasSubtree); @@ -2088,7 +2088,8 @@ ? CustomStyleForLayoutObject() : OriginalStyleForLayoutObject(); if (!style) { - DCHECK(IsBeforePseudoElement() || IsAfterPseudoElement()); + DCHECK(IsBeforePseudoElement() || IsAfterPseudoElement() || + GetPseudoId() == kPseudoIdBackdrop); return nullptr; }
diff --git a/third_party/blink/renderer/core/dom/layout_tree_builder.cc b/third_party/blink/renderer/core/dom/layout_tree_builder.cc index d3bcaddf..a06f199 100644 --- a/third_party/blink/renderer/core/dom/layout_tree_builder.cc +++ b/third_party/blink/renderer/core/dom/layout_tree_builder.cc
@@ -36,9 +36,7 @@ #include "third_party/blink/renderer/core/dom/text.h" #include "third_party/blink/renderer/core/dom/v0_insertion_point.h" #include "third_party/blink/renderer/core/dom/whitespace_attacher.h" -#include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/layout/layout_inline.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_text.h" @@ -167,15 +165,6 @@ new_layout_object->SetStyle( &style); // SetStyle() can depend on LayoutObject() already being set. - Document& document = node_->GetDocument(); - if (Fullscreen::IsFullscreenElement(*node_) && - node_.Get() != document.documentElement()) { - new_layout_object = LayoutFullScreen::WrapLayoutObject( - new_layout_object, parent_layout_object, &document); - if (!new_layout_object) - return; - } - // Note: Adding new_layout_object instead of LayoutObject(). LayoutObject() // may be a child of new_layout_object. parent_layout_object->AddChild(new_layout_object, next_layout_object);
diff --git a/third_party/blink/renderer/core/dom/node.cc b/third_party/blink/renderer/core/dom/node.cc index 215c0e55..72c1cf2 100644 --- a/third_party/blink/renderer/core/dom/node.cc +++ b/third_party/blink/renderer/core/dom/node.cc
@@ -942,11 +942,6 @@ DCHECK(!ChildNeedsDistributionRecalc()); if (this != GetDocument()) { - // TODO(foolip): When fullscreen uses top layer, this can be simplified to - // just look at the topmost element in top layer. https://crbug.com/240576. - // Note: It's currently appropriate that a modal dialog element takes - // precedence over a fullscreen element, because it will be rendered on top, - // but with fullscreen merged into top layer that will no longer be true. const Element* modal_element = GetDocument().ActiveModalDialog(); if (!modal_element) modal_element = Fullscreen::FullscreenElementFrom(GetDocument());
diff --git a/third_party/blink/renderer/core/dom/pseudo_element.cc b/third_party/blink/renderer/core/dom/pseudo_element.cc index 3f08801d..751a03f 100644 --- a/third_party/blink/renderer/core/dom/pseudo_element.cc +++ b/third_party/blink/renderer/core/dom/pseudo_element.cc
@@ -29,6 +29,7 @@ #include "third_party/blink/renderer/core/dom/element_rare_data.h" #include "third_party/blink/renderer/core/dom/first_letter_pseudo_element.h" #include "third_party/blink/renderer/core/frame/use_counter.h" +#include "third_party/blink/renderer/core/layout/generated_children.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/layout_quote.h" #include "third_party/blink/renderer/core/probe/core_probes.h" @@ -145,6 +146,13 @@ if (!layout_object) return; + // This is to ensure that bypassing the canHaveGeneratedChildren check in + // StyleResolver::createPseudoElementIfNeeded does not result in the + // backdrop pseudo element's layout object becoming the child of a layout + // object that doesn't allow children. + DCHECK(layout_object->Parent()); + DCHECK(CanHaveGeneratedChildren(*layout_object->Parent())); + ComputedStyle& style = layout_object->MutableStyleRef(); if (style.StyleType() != kPseudoIdBefore && style.StyleType() != kPseudoIdAfter)
diff --git a/third_party/blink/renderer/core/exported/web_frame_test.cc b/third_party/blink/renderer/core/exported/web_frame_test.cc index 3c8eeb06..c29fa7c 100644 --- a/third_party/blink/renderer/core/exported/web_frame_test.cc +++ b/third_party/blink/renderer/core/exported/web_frame_test.cc
@@ -124,7 +124,6 @@ #include "third_party/blink/renderer/core/input/event_handler.h" #include "third_party/blink/renderer/core/inspector/dev_tools_emulator.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_threadable_loader.h" @@ -8510,8 +8509,8 @@ EXPECT_EQ(div_fullscreen, Fullscreen::FullscreenElementFrom(*document)); // Verify that the element is sized to the viewport. - LayoutFullScreen* fullscreen_layout_object = - Fullscreen::From(*document).FullScreenLayoutObject(); + LayoutBox* fullscreen_layout_object = + ToLayoutBox(div_fullscreen->GetLayoutObject()); EXPECT_EQ(viewport_width, fullscreen_layout_object->LogicalWidth().ToInt()); EXPECT_EQ(viewport_height, fullscreen_layout_object->LogicalHeight().ToInt()); @@ -8665,8 +8664,8 @@ web_view_impl->UpdateAllLifecyclePhases(); // Verify that the element is sized to the viewport. - LayoutFullScreen* fullscreen_layout_object = - Fullscreen::From(*document).FullScreenLayoutObject(); + LayoutBox* fullscreen_layout_object = + ToLayoutBox(div_fullscreen->GetLayoutObject()); EXPECT_EQ(viewport_width, fullscreen_layout_object->LogicalWidth().ToInt()); EXPECT_EQ(viewport_height, fullscreen_layout_object->LogicalHeight().ToInt());
diff --git a/third_party/blink/renderer/core/frame/fullscreen_controller.cc b/third_party/blink/renderer/core/frame/fullscreen_controller.cc index df7cf55..32b6959d 100644 --- a/third_party/blink/renderer/core/frame/fullscreen_controller.cc +++ b/third_party/blink/renderer/core/frame/fullscreen_controller.cc
@@ -43,7 +43,6 @@ #include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/fullscreen/fullscreen_options.h" #include "third_party/blink/renderer/core/html/media/html_video_element.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/page/page.h" namespace blink { @@ -87,10 +86,8 @@ frame = frame->Tree().TraverseNext()) { if (!frame->IsLocalFrame()) continue; - if (Document* document = ToLocalFrame(frame)->GetDocument()) { - if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) - fullscreen->DidEnterFullscreen(); - } + if (Document* document = ToLocalFrame(frame)->GetDocument()) + Fullscreen::DidEnterFullscreen(*document); } // TODO(foolip): If the top level browsing context (main frame) ends up with @@ -123,10 +120,8 @@ } DCHECK(frame->IsLocalFrame() && ToLocalFrame(frame)->IsLocalRoot()); - if (Document* document = ToLocalFrame(frame)->GetDocument()) { - if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) - fullscreen->DidExitFullscreen(); - } + if (Document* document = ToLocalFrame(frame)->GetDocument()) + Fullscreen::DidExitFullscreen(*document); // Skip over all descendant frames. while (next_frame && next_frame->Tree().IsDescendantOf(frame)) @@ -247,20 +242,6 @@ return; UpdatePageScaleConstraints(false); - - // Traverse all local frames and notify the LayoutFullScreen object, if any. - for (Frame* frame = web_view_base_->GetPage()->MainFrame(); frame; - frame = frame->Tree().TraverseNext()) { - if (!frame->IsLocalFrame()) - continue; - if (Document* document = ToLocalFrame(frame)->GetDocument()) { - if (Fullscreen* fullscreen = Fullscreen::FromIfExists(*document)) { - if (LayoutFullScreen* layout_object = - fullscreen->FullScreenLayoutObject()) - layout_object->UpdateStyle(); - } - } - } } void FullscreenController::DidUpdateLayout() {
diff --git a/third_party/blink/renderer/core/fullscreen/fullscreen.cc b/third_party/blink/renderer/core/fullscreen/fullscreen.cc index 26368f4..95b7a505 100644 --- a/third_party/blink/renderer/core/fullscreen/fullscreen.cc +++ b/third_party/blink/renderer/core/fullscreen/fullscreen.cc
@@ -32,10 +32,12 @@ #include "base/macros.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" +#include "third_party/blink/renderer/core/css/style_change_reason.h" #include "third_party/blink/renderer/core/css/style_engine.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/element_traversal.h" #include "third_party/blink/renderer/core/dom/events/event.h" +#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/frame/hosts_using_features.h" #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h" @@ -46,8 +48,6 @@ #include "third_party/blink/renderer/core/html_element_type_helpers.h" #include "third_party/blink/renderer/core/input/event_handler.h" #include "third_party/blink/renderer/core/inspector/console_message.h" -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/svg/svg_svg_element.h" #include "third_party/blink/renderer/platform/bindings/microtask.h" @@ -58,6 +58,139 @@ namespace { +void FullscreenElementChanged(Document& document, + Element* old_element, + Element* new_element, + Fullscreen::RequestType new_request_type) { + DCHECK_NE(old_element, new_element); + + document.GetStyleEngine().EnsureUAStyleForFullscreen(); + + if (old_element) { + DCHECK_NE(old_element, Fullscreen::FullscreenElementFrom(document)); + + old_element->PseudoStateChanged(CSSSelector::kPseudoFullScreen); + + old_element->SetContainsFullScreenElement(false); + old_element->SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries( + false); + } + + if (new_element) { + DCHECK_EQ(new_element, Fullscreen::FullscreenElementFrom(document)); + + new_element->PseudoStateChanged(CSSSelector::kPseudoFullScreen); + + // OOPIF: For RequestType::PrefixedForCrossProcessDescendant, |new_element| + // is the iframe element for the out-of-process frame that contains the + // fullscreen element. Hence, it must match :-webkit-full-screen-ancestor. + if (new_request_type == + Fullscreen::RequestType::kPrefixedForCrossProcessDescendant) { + DCHECK(IsHTMLIFrameElement(new_element)); + new_element->SetContainsFullScreenElement(true); + } + new_element->SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries( + true); + } + + if (document.GetFrame()) { + // SetIsInert recurses through subframes to propagate the inert bit as + // needed. + document.GetFrame()->SetIsInert(document.LocalOwner() && + document.LocalOwner()->IsInert()); + } + + // Any element not contained by the fullscreen element is inert (see + // |Node::IsInert()|), so changing the fullscreen element will typically + // change the inertness of most elements. Clear the entire cache. + document.ClearAXObjectCache(); + + if (LocalFrame* frame = document.GetFrame()) { + // TODO(foolip): Synchronize hover state changes with animation frames. + // https://crbug.com/668758 + frame->GetEventHandler().ScheduleHoverStateUpdate(); + frame->GetChromeClient().FullscreenElementChanged(old_element, new_element); + } +} + +using ElementRequestTypeMap = + HeapHashMap<WeakMember<Element>, Fullscreen::RequestType>; + +ElementRequestTypeMap& FullscreenFlagMap() { + DEFINE_STATIC_LOCAL(ElementRequestTypeMap, map, (new ElementRequestTypeMap)); + return map; +} + +bool HasFullscreenFlag(Element& element) { + return FullscreenFlagMap().Contains(&element); +} + +void SetFullscreenFlag(Element& element, Fullscreen::RequestType request_type) { + FullscreenFlagMap().insert(&element, request_type); +} + +void UnsetFullscreenFlag(Element& element) { + FullscreenFlagMap().erase(&element); +} + +Fullscreen::RequestType GetRequestType(Element& element) { + return FullscreenFlagMap().find(&element)->value; +} + +// https://fullscreen.spec.whatwg.org/#fullscreen-an-element +void GoFullscreen(Element& element, Fullscreen::RequestType request_type) { + Document& document = element.GetDocument(); + Element* old_element = Fullscreen::FullscreenElementFrom(document); + + // To fullscreen an |element| within a |document|, set the |element|'s + // fullscreen flag and add it to |document|'s top layer. + DCHECK(!HasFullscreenFlag(element)); + DCHECK(!element.IsInTopLayer()); + SetFullscreenFlag(element, request_type); + document.AddToTopLayer(&element); + + DCHECK_EQ(&element, Fullscreen::FullscreenElementFrom(document)); + FullscreenElementChanged(document, old_element, &element, request_type); +} + +// https://fullscreen.spec.whatwg.org/#unfullscreen-an-element +void Unfullscreen(Element& element) { + Document& document = element.GetDocument(); + Element* old_element = Fullscreen::FullscreenElementFrom(document); + + // To unfullscreen an |element| within a |document|, unset the element's + // fullscreen flag and iframe fullscreen flag (if any), and remove it from + // |document|'s top layer. + DCHECK(element.IsInTopLayer()); + DCHECK(HasFullscreenFlag(element)); + UnsetFullscreenFlag(element); + document.RemoveFromTopLayer(&element); + + Element* new_element = Fullscreen::FullscreenElementFrom(document); + if (old_element != new_element) { + Fullscreen::RequestType new_request_type = + new_element ? GetRequestType(*new_element) + : Fullscreen::RequestType::kUnprefixed; + FullscreenElementChanged(document, old_element, new_element, + new_request_type); + } +} + +// https://fullscreen.spec.whatwg.org/#unfullscreen-a-document +void Unfullscreen(Document& document) { + // To unfullscreen a |document|, unfullscreen all elements, within + // |document|'s top layer, whose fullscreen flag is set. + + HeapVector<Member<Element>> fullscreen_elements; + for (Element* element : document.TopLayerElements()) { + if (HasFullscreenFlag(*element)) + fullscreen_elements.push_back(element); + } + + for (Element* element : fullscreen_elements) + Unfullscreen(*element); +} + // https://html.spec.whatwg.org/multipage/embedded-content.html#allowed-to-use bool AllowedToUseFullscreen(const Frame* frame) { // To determine whether a Document object |document| is allowed to use the @@ -250,9 +383,18 @@ return document; } +size_t CountFullscreenInTopLayer(const Document& document) { + size_t count = 0; + for (Element* element : document.TopLayerElements()) { + if (HasFullscreenFlag(*element)) + ++count; + } + return count; +} + // https://fullscreen.spec.whatwg.org/#simple-fullscreen-document -bool IsSimpleFullscreenDocument(Document& document) { - return Fullscreen::FullscreenElementStackSizeFrom(document) == 1; +bool IsSimpleFullscreenDocument(const Document& document) { + return CountFullscreenInTopLayer(document) == 1; } // https://fullscreen.spec.whatwg.org/#collect-documents-to-unfullscreen @@ -340,6 +482,11 @@ WrapPersistent(&document))); } +void DidEnterFullscreenTask(Document* document) { + DCHECK(document); + Fullscreen::DidEnterFullscreen(*document); +} + } // anonymous namespace const char Fullscreen::kSupplementName[] = "Fullscreen"; @@ -350,26 +497,30 @@ fullscreen = new Fullscreen(document); ProvideTo(document, fullscreen); } - return *fullscreen; } -Fullscreen* Fullscreen::FromIfExistsSlow(Document& document) { +Fullscreen* Fullscreen::FromIfExists(Document& document) { + if (!document.HasFullscreenSupplement()) + return nullptr; return Supplement<Document>::From<Fullscreen>(document); } Element* Fullscreen::FullscreenElementFrom(Document& document) { - if (Fullscreen* found = FromIfExists(document)) - return found->FullscreenElement(); + // The fullscreen element is the topmost element in the document's top layer + // whose fullscreen flag is set, if any, and null otherwise. + + const auto& elements = document.TopLayerElements(); + for (auto it = elements.rbegin(); it != elements.rend(); ++it) { + Element* element = (*it).Get(); + if (HasFullscreenFlag(*element)) + return element; + } + return nullptr; } -size_t Fullscreen::FullscreenElementStackSizeFrom(Document& document) { - if (Fullscreen* found = FromIfExists(document)) - return found->fullscreen_element_stack_.size(); - return 0; -} - +// https://fullscreen.spec.whatwg.org/#fullscreen-element Element* Fullscreen::FullscreenElementForBindingFrom(TreeScope& scope) { Element* element = FullscreenElementFrom(scope.GetDocument()); if (!element || !RuntimeEnabledFeatures::FullscreenUnprefixedEnabled()) @@ -392,20 +543,11 @@ } bool Fullscreen::IsInFullscreenElementStack(const Element& element) { - const Fullscreen* found = FromIfExists(element.GetDocument()); - if (!found) - return false; - for (size_t i = 0; i < found->fullscreen_element_stack_.size(); ++i) { - if (found->fullscreen_element_stack_[i].first.Get() == &element) - return true; - } - return false; + return HasFullscreenFlag(const_cast<Element&>(element)); } Fullscreen::Fullscreen(Document& document) - : Supplement<Document>(document), - ContextLifecycleObserver(&document), - full_screen_layout_object_(nullptr) { + : Supplement<Document>(document), ContextLifecycleObserver(&document) { document.SetHasFullscreenSupplement(); } @@ -416,12 +558,8 @@ } void Fullscreen::ContextDestroyed(ExecutionContext*) { - if (full_screen_layout_object_) - full_screen_layout_object_->Destroy(); - pending_requests_.clear(); pending_exits_.clear(); - fullscreen_element_stack_.clear(); } // https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen @@ -517,26 +655,22 @@ return promise; } -void Fullscreen::DidEnterFullscreen() { - if (!GetDocument()) - return; - +void Fullscreen::DidEnterFullscreen(Document& document) { // We may be called synchronously from within // |FullscreenController::EnterFullscreen()| if we were already fullscreen, // but must still not synchronously change the fullscreen element. Instead // enqueue a microtask to continue. if (RequestFullscreenScope::RunningRequestFullscreen()) { Microtask::EnqueueMicrotask( - WTF::Bind(&Fullscreen::DidEnterFullscreen, WrapPersistent(this))); + WTF::Bind(DidEnterFullscreenTask, WrapPersistent(&document))); return; } PendingRequests requests; - requests.swap(pending_requests_); + requests.swap(From(document).pending_requests_); for (const Member<PendingRequest>& request : requests) { - ContinueRequestFullscreen(*GetDocument(), *request->element(), - request->type(), request->resolver(), - false /* error */); + ContinueRequestFullscreen(document, *request->element(), request->type(), + request->resolver(), false /* error */); } } @@ -611,9 +745,7 @@ // https://crbug.com/644695 // 13.4. Fullscreen |element| within |doc|. - // TODO(foolip): Merge fullscreen element stack into top layer. - // https://crbug.com/627790 - From(doc).PushFullscreenElementStack(*element, request_type); + GoFullscreen(*element, request_type); // 13.5. Append (fullscreenchange, |element|) to |doc|'s list of pending // fullscreen events. @@ -628,7 +760,7 @@ } // https://fullscreen.spec.whatwg.org/#fully-exit-fullscreen -void Fullscreen::FullyExitFullscreen(Document& document) { +void Fullscreen::FullyExitFullscreen(Document& document, bool ua_originated) { // TODO(foolip): The spec used to have a first step saying "Let |doc| be the // top-level browsing context's document" which was removed in // https://github.com/whatwg/fullscreen/commit/3243119d027a8ff5b80998eb1f17f8eba148a346. @@ -636,22 +768,29 @@ Document& doc = TopmostLocalAncestor(document); // 1. If |document|'s fullscreen element is null, terminate these steps. - if (!FullscreenElementFrom(doc)) + Element* fullscreen_element = FullscreenElementFrom(doc); + if (!fullscreen_element) return; // 2. Unfullscreen elements whose fullscreen flag is set, within // |document|'s top layer, except for |document|'s fullscreen element. - size_t stack_size = From(doc).fullscreen_element_stack_.size(); - From(doc).fullscreen_element_stack_.EraseAt(0, stack_size - 1); - DCHECK_EQ(From(doc).fullscreen_element_stack_.size(), 1u); + HeapVector<Member<Element>> unfullscreen_elements; + for (Element* element : doc.TopLayerElements()) { + if (HasFullscreenFlag(*element) && element != fullscreen_element) + unfullscreen_elements.push_back(element); + } + for (Element* element : unfullscreen_elements) + Unfullscreen(*element); + DCHECK(IsSimpleFullscreenDocument(doc)); // 3. Exit fullscreen |document|. - ExitFullscreen(doc); + ExitFullscreen(doc, nullptr, ua_originated); } // https://fullscreen.spec.whatwg.org/#exit-fullscreen ScriptPromise Fullscreen::ExitFullscreen(Document& doc, - ScriptState* script_state) { + ScriptState* script_state, + bool ua_originated) { // 1. Let |promise| be a new promise. // ScriptPromiseResolver is allocated after step 2. ScriptPromiseResolver* resolver = nullptr; @@ -696,15 +835,33 @@ resize = true; } + // 7. If |doc|'s fullscreen element is not connected. + Element* element = FullscreenElementFrom(doc); + if (!element->isConnected()) { + RequestType request_type = GetRequestType(*element); + + // 7.1. Append (fullscreenchange, |doc|'s fullscreen element) to + // |doc|'s list of pending fullscreen events. + EnqueueEvent(EventTypeNames::fullscreenchange, *element, doc, request_type); + + // 7.2. Unfullscreen |element|. + Unfullscreen(*element); + } + // 7. Return |promise|, and run the remaining steps in parallel. ScriptPromise promise = resolver ? resolver->Promise() : ScriptPromise(); // 8. If |resize| is true, resize |doc|'s viewport to its "normal" dimensions. if (resize) { - From(doc).pending_exits_.push_back(resolver); - LocalFrame& frame = *doc.GetFrame(); - frame.GetChromeClient().ExitFullscreen(frame); + if (ua_originated) { + ContinueExitFullscreen(&doc, resolver, true /* resize */); + } else { + From(top_level_doc).pending_exits_.push_back(resolver); + LocalFrame& frame = *doc.GetFrame(); + frame.GetChromeClient().ExitFullscreen(frame); + } } else { + DCHECK(!ua_originated); // Note: We are past the "in parallel" point, and |ContinueExitFullscreen()| // will change script-observable state (document.fullscreenElement) // synchronously, so we have to continue asynchronously. @@ -715,16 +872,17 @@ return promise; } -void Fullscreen::DidExitFullscreen() { - Document* document = GetDocument(); +void Fullscreen::DidExitFullscreen(Document& document) { + // If this is a response to an ExitFullscreen call then + // continue exiting. Otherwise call FullyExitFullscreen. + Fullscreen& fullscreen = From(document); PendingExits exits; - exits.swap(pending_exits_); - // Allow a UA originated fullscreen exit to complete. + exits.swap(fullscreen.pending_exits_); if (exits.IsEmpty()) { - ContinueExitFullscreen(document, nullptr, true /* resize */); + FullyExitFullscreen(document, true /* ua_originated */); } else { for (const Member<PendingExit>& exit : exits) - ContinueExitFullscreen(document, exit, true /* resize */); + ContinueExitFullscreen(&document, exit, true /* resize */); } } @@ -774,39 +932,36 @@ // 12. For each |exitDoc| in |exitDocs|: for (Document* exit_doc : exit_docs) { - Fullscreen& fullscreen = From(*exit_doc); - ElementStack& stack = fullscreen.fullscreen_element_stack_; - DCHECK(!stack.IsEmpty()); + Element* exit_element = FullscreenElementFrom(*exit_doc); + DCHECK(exit_element); + RequestType request_type = GetRequestType(*exit_element); // 12.1. Append (fullscreenchange, |exitDoc|'s fullscreen element) to // |exitDoc|'s list of pending fullscreen events. - EnqueueEvent(EventTypeNames::fullscreenchange, *stack.back().first, - *exit_doc, stack.back().second); + EnqueueEvent(EventTypeNames::fullscreenchange, *exit_element, *exit_doc, + request_type); // 12.2. If |resize| is true, unfullscreen |exitDoc|. // 12.3. Otherwise, unfullscreen |exitDoc|'s fullscreen element. - if (resize) { - while (!stack.IsEmpty()) - fullscreen.PopFullscreenElementStack(); - } else { - fullscreen.PopFullscreenElementStack(); - } + if (resize) + Unfullscreen(*exit_doc); + else + Unfullscreen(*exit_element); } // 13. For each |descendantDoc| in |descendantDocs|: for (Document* descendant_doc : descendant_docs) { - Fullscreen& fullscreen = From(*descendant_doc); - ElementStack& stack = fullscreen.fullscreen_element_stack_; - DCHECK(!stack.IsEmpty()); + Element* descendant_element = FullscreenElementFrom(*descendant_doc); + DCHECK(descendant_element); + RequestType request_type = GetRequestType(*descendant_element); // 13.1. Append (fullscreenchange, |descendantDoc|'s fullscreen element) to // |descendantDoc|'s list of pending fullscreen events. - EnqueueEvent(EventTypeNames::fullscreenchange, *stack.back().first, - *descendant_doc, stack.back().second); + EnqueueEvent(EventTypeNames::fullscreenchange, *descendant_element, + *descendant_doc, request_type); // 13.2. Unfullscreen |descendantDoc|. - while (!stack.IsEmpty()) - fullscreen.PopFullscreenElementStack(); + Unfullscreen(*descendant_doc); } // 14. Resolve |promise| with undefined. @@ -825,164 +980,42 @@ FullscreenIsSupported(document); } -void Fullscreen::SetFullScreenLayoutObject(LayoutFullScreen* layout_object) { - if (layout_object == full_screen_layout_object_) - return; - - if (layout_object && saved_placeholder_computed_style_) { - layout_object->CreatePlaceholder( - std::move(saved_placeholder_computed_style_), - saved_placeholder_frame_rect_); - } else if (layout_object && full_screen_layout_object_ && - full_screen_layout_object_->Placeholder()) { - LayoutBlockFlow* placeholder = full_screen_layout_object_->Placeholder(); - layout_object->CreatePlaceholder( - ComputedStyle::Clone(placeholder->StyleRef()), - placeholder->FrameRect()); - } - - if (full_screen_layout_object_) - full_screen_layout_object_->UnwrapLayoutObject(); - DCHECK(!full_screen_layout_object_); - - full_screen_layout_object_ = layout_object; -} - -void Fullscreen::FullScreenLayoutObjectDestroyed() { - full_screen_layout_object_ = nullptr; +void Fullscreen::DidUpdateSize(Element& element) { + // StyleAdjuster will set the size so we need to do a style recalc. + // Normally changing size means layout so just doing a style recalc is a + // bit surprising. + element.SetNeedsStyleRecalc( + kLocalStyleChange, + StyleChangeReasonForTracing::Create(StyleChangeReason::kFullscreen)); } void Fullscreen::ElementRemoved(Element& node) { - DCHECK_EQ(GetDocument(), &node.GetDocument()); + DCHECK(node.IsInTopLayer()); + if (!HasFullscreenFlag(node)) + return; + + // 1. Let |document| be removedNode's node document. + Document& document = node.GetDocument(); // |Fullscreen::ElementRemoved()| is called for each removed element, so only // the body of the spec "removing steps" loop appears here: - // 2.1. If |node| is its node document's fullscreen element, exit fullscreen + // 3.1. If |node| is its node document's fullscreen element, exit fullscreen // that document. - if (FullscreenElement() == &node) { - ExitFullscreen(node.GetDocument()); - return; + if (IsFullscreenElement(node)) { + ExitFullscreen(document, nullptr, false); + } else { + // 3.2. Otherwise, unfullscreen |node| within its node document. + Unfullscreen(node); } - // 2.2. Otherwise, unfullscreen |node| within its node document. - for (size_t i = 0; i < fullscreen_element_stack_.size(); ++i) { - if (fullscreen_element_stack_[i].first.Get() == &node) { - fullscreen_element_stack_.EraseAt(i); - return; - } - } - - // Note: |node| was not in the fullscreen element stack. -} - -void Fullscreen::PopFullscreenElementStack() { - DCHECK(!fullscreen_element_stack_.IsEmpty()); - - Element* old_element = FullscreenElement(); - fullscreen_element_stack_.pop_back(); - - // Note: |requestType| is only used if |FullscreenElement()| is non-null. - RequestType request_type = fullscreen_element_stack_.IsEmpty() - ? RequestType::kUnprefixed - : fullscreen_element_stack_.back().second; - FullscreenElementChanged(old_element, FullscreenElement(), request_type); -} - -void Fullscreen::PushFullscreenElementStack(Element& element, - RequestType request_type) { - Element* old_element = FullscreenElement(); - fullscreen_element_stack_.push_back(std::make_pair(&element, request_type)); - - FullscreenElementChanged(old_element, &element, request_type); -} - -void Fullscreen::FullscreenElementChanged(Element* old_element, - Element* new_element, - RequestType new_request_type) { - DCHECK_NE(old_element, new_element); - - if (!GetDocument()) - return; - - GetDocument()->GetStyleEngine().EnsureUAStyleForFullscreen(); - - if (full_screen_layout_object_) - full_screen_layout_object_->UnwrapLayoutObject(); - DCHECK(!full_screen_layout_object_); - - if (old_element) { - DCHECK_NE(old_element, FullscreenElement()); - - old_element->PseudoStateChanged(CSSSelector::kPseudoFullScreen); - old_element->PseudoStateChanged(CSSSelector::kPseudoFullscreen); - - old_element->SetContainsFullScreenElement(false); - old_element->SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries( - false); - } - - if (new_element) { - DCHECK_EQ(new_element, FullscreenElement()); - - new_element->PseudoStateChanged(CSSSelector::kPseudoFullScreen); - new_element->PseudoStateChanged(CSSSelector::kPseudoFullscreen); - - // OOPIF: For RequestType::PrefixedForCrossProcessDescendant, |toElement| is - // the iframe element for the out-of-process frame that contains the - // fullscreen element. Hence, it must match :-webkit-full-screen-ancestor. - if (new_request_type == RequestType::kPrefixedForCrossProcessDescendant) { - DCHECK(IsHTMLIFrameElement(new_element)); - new_element->SetContainsFullScreenElement(true); - } - new_element->SetContainsFullScreenElementOnAncestorsCrossingFrameBoundaries( - true); - - // Create a placeholder block for the fullscreen element, to keep the page - // from reflowing when the element is removed from the normal flow. Only do - // this for a LayoutBox, as only a box will have a frameRect. The - // placeholder will be created in setFullScreenLayoutObject() during layout. - LayoutObject* layout_object = new_element->GetLayoutObject(); - bool should_create_placeholder = layout_object && layout_object->IsBox(); - if (should_create_placeholder) { - saved_placeholder_frame_rect_ = ToLayoutBox(layout_object)->FrameRect(); - saved_placeholder_computed_style_ = - ComputedStyle::Clone(layout_object->StyleRef()); - } - - if (new_element != GetDocument()->documentElement()) { - LayoutFullScreen::WrapLayoutObject( - layout_object, layout_object ? layout_object->Parent() : nullptr, - GetDocument()); - } - } - - if (LocalFrame* frame = GetDocument()->GetFrame()) { - // TODO(foolip): Synchronize hover state changes with animation frames. - // https://crbug.com/668758 - frame->GetEventHandler().ScheduleHoverStateUpdate(); - frame->GetChromeClient().FullscreenElementChanged(old_element, new_element); - - // Descendant frames may have been inert because their owner iframes were - // outside of fullscreen element. SetIsInert recurses through subframes to - // propagate the inert bit as needed. - frame->SetIsInert(GetDocument()->LocalOwner() && - GetDocument()->LocalOwner()->IsInert()); - } - - // TODO(foolip): This should not call |UpdateStyleAndLayoutTree()|. - GetDocument()->UpdateStyleAndLayoutTree(); - - // Any element not contained by the fullscreen element is inert (see - // |Node::IsInert()|), so changing the fullscreen element will typically - // change the inertness of most elements. Clear the entire cache. - GetDocument()->ClearAXObjectCache(); + // 3.3 If document's top layer contains node, remove node from document's top + // layer. This is done in Element::RemovedFrom. } void Fullscreen::Trace(blink::Visitor* visitor) { visitor->Trace(pending_requests_); visitor->Trace(pending_exits_); - visitor->Trace(fullscreen_element_stack_); Supplement<Document>::Trace(visitor); ContextLifecycleObserver::Trace(visitor); }
diff --git a/third_party/blink/renderer/core/fullscreen/fullscreen.h b/third_party/blink/renderer/core/fullscreen/fullscreen.h index 309f14b..ac2a76f 100644 --- a/third_party/blink/renderer/core/fullscreen/fullscreen.h +++ b/third_party/blink/renderer/core/fullscreen/fullscreen.h
@@ -42,9 +42,7 @@ namespace blink { -class ComputedStyle; class FullscreenOptions; -class LayoutFullScreen; class ScriptPromiseResolver; // The Fullscreen class implements most of the Fullscreen API Standard, @@ -62,10 +60,8 @@ virtual ~Fullscreen(); static Fullscreen& From(Document&); - static Fullscreen* FromIfExists(Document&); static Element* FullscreenElementFrom(Document&); static Element* FullscreenElementForBindingFrom(TreeScope&); - static size_t FullscreenElementStackSizeFrom(Document&); static bool IsFullscreenElement(const Element&); static bool IsInFullscreenElementStack(const Element&); @@ -86,28 +82,21 @@ RequestType, ScriptState* state = nullptr); - static void FullyExitFullscreen(Document&); - static ScriptPromise ExitFullscreen(Document&, ScriptState* state = nullptr); + static void FullyExitFullscreen(Document&, bool ua_originated = false); + static ScriptPromise ExitFullscreen(Document&, + ScriptState* state = nullptr, + bool ua_originated = false); static bool FullscreenEnabled(Document&); - Element* FullscreenElement() const { - return !fullscreen_element_stack_.IsEmpty() - ? fullscreen_element_stack_.back().first.Get() - : nullptr; - } // Called by FullscreenController to notify that we've entered or exited // fullscreen. All frames are notified, so there may be no pending request. - void DidEnterFullscreen(); - void DidExitFullscreen(); + static void DidEnterFullscreen(Document&); + static void DidExitFullscreen(Document&); - void SetFullScreenLayoutObject(LayoutFullScreen*); - LayoutFullScreen* FullScreenLayoutObject() const { - return full_screen_layout_object_; - } - void FullScreenLayoutObjectDestroyed(); + static void DidUpdateSize(Element&); - void ElementRemoved(Element&); + static void ElementRemoved(Element&); // ContextLifecycleObserver: void ContextDestroyed(ExecutionContext*) override; @@ -115,7 +104,7 @@ void Trace(blink::Visitor*) override; private: - static Fullscreen* FromIfExistsSlow(Document&); + static Fullscreen* FromIfExists(Document&); explicit Fullscreen(Document&); @@ -131,21 +120,10 @@ ScriptPromiseResolver* resolver, bool resize); - void ClearFullscreenElementStack(); - void PopFullscreenElementStack(); - void PushFullscreenElementStack(Element&, RequestType); void FullscreenElementChanged(Element* old_element, Element* new_element, RequestType new_request_type); - using ElementStackEntry = std::pair<Member<Element>, RequestType>; - using ElementStack = HeapVector<ElementStackEntry>; - ElementStack fullscreen_element_stack_; - - LayoutFullScreen* full_screen_layout_object_; - LayoutRect saved_placeholder_frame_rect_; - scoped_refptr<ComputedStyle> saved_placeholder_computed_style_; - // Stores the pending request, promise and the type for executing // the asynchronous portion of the request. class PendingRequest : public GarbageCollectedFinalized<PendingRequest> { @@ -175,16 +153,8 @@ PendingExits pending_exits_; }; -inline Fullscreen* Fullscreen::FromIfExists(Document& document) { - if (!document.HasFullscreenSupplement()) - return nullptr; - return FromIfExistsSlow(document); -} - inline bool Fullscreen::IsFullscreenElement(const Element& element) { - if (Fullscreen* found = FromIfExists(element.GetDocument())) - return found->FullscreenElement() == &element; - return false; + return FullscreenElementFrom(element.GetDocument()) == &element; } } // namespace blink
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.cc b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.cc index b6323284..34004cc 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.cc +++ b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.cc
@@ -13,14 +13,17 @@ #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/core/fileapi/blob.h" +#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/graphics/image_data_buffer.h" #include "third_party/blink/renderer/platform/histogram.h" +#include "third_party/blink/renderer/platform/image-encoders/image_encoder_utils.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h" #include "third_party/blink/renderer/platform/threading/background_task_runner.h" #include "third_party/blink/renderer/platform/web_task_runner.h" #include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/time.h" +#include "third_party/skia/include/core/SkColorSpaceXform.h" #include "third_party/skia/include/core/SkSurface.h" namespace blink { @@ -154,27 +157,30 @@ scoped_refptr<StaticBitmapImage> image, const String& mime_type, V8BlobCallback* callback, + ToBlobFunctionType function_type, double start_time, ExecutionContext* context) { - return new CanvasAsyncBlobCreator(image, - ConvertMimeTypeStringToEnum(mime_type), - callback, start_time, context, nullptr); + ImageEncodeOptions options; + options.setType(mime_type); + return new CanvasAsyncBlobCreator(image, options, function_type, callback, + start_time, context, nullptr); } CanvasAsyncBlobCreator* CanvasAsyncBlobCreator::Create( scoped_refptr<StaticBitmapImage> image, - const String& mime_type, + const ImageEncodeOptions& options, + ToBlobFunctionType function_type, double start_time, ExecutionContext* context, ScriptPromiseResolver* resolver) { - return new CanvasAsyncBlobCreator(image, - ConvertMimeTypeStringToEnum(mime_type), - nullptr, start_time, context, resolver); + return new CanvasAsyncBlobCreator(image, options, function_type, nullptr, + start_time, context, resolver); } CanvasAsyncBlobCreator::CanvasAsyncBlobCreator( scoped_refptr<StaticBitmapImage> image, - ImageEncoder::MimeType mime_type, + const ImageEncodeOptions& options, + ToBlobFunctionType function_type, V8BlobCallback* callback, double start_time, ExecutionContext* context, @@ -182,12 +188,19 @@ : fail_encoder_initialization_for_test_(false), image_(image), context_(context), - mime_type_(mime_type), + encode_options_(options), + function_type_(function_type), start_time_(start_time), static_bitmap_image_loaded_(false), callback_(ToV8PersistentCallbackFunction(callback)), script_promise_resolver_(resolver) { DCHECK(image); + + String mime_type_string = ImageEncoderUtils::ToEncodingMimeType( + encode_options_.type(), + ImageEncoderUtils::kEncodeReasonConvertToBlobPromise); + mime_type_ = ConvertMimeTypeStringToEnum(mime_type_string); + // We use pixmap to access the image pixels. Make the image unaccelerated if // necessary. image_ = image_->MakeUnaccelerated(); @@ -208,15 +221,76 @@ } } - // toBlob always encodes in sRGB and does not include the color space - // information. - if (skia_image->colorSpace()) { - image_ = image_->ConvertToColorSpace(SkColorSpace::MakeSRGB(), - SkTransferFunctionBehavior::kIgnore); - skia_image = image_->PaintImageForCurrentFrame().GetSkImage(); + // For kHTMLCanvasToBlobCallback and kOffscreenCanvasConvertToBlobPromise + // to-blob function types, we color convert to sRGB and do not tag the image + // with any color space info. + // For kHTMLCanvasConvertToBlobPromise to-blob function type, we color + // covnert to the requested color space and pixel format. + if (function_type_ != kHTMLCanvasConvertToBlobPromise) { + if (skia_image->colorSpace()) { + image_ = image_->ConvertToColorSpace(SkColorSpace::MakeSRGB(), + SkTransferFunctionBehavior::kIgnore); + skia_image = image_->PaintImageForCurrentFrame().GetSkImage(); + } + + if (skia_image->peekPixels(&src_data_)) { + src_data_.setColorSpace(nullptr); + static_bitmap_image_loaded_ = true; + } + DCHECK(!src_data_.colorSpace()); + } else { + sk_sp<SkColorSpace> blob_color_space = + BlobColorSpaceToSkColorSpace(encode_options_.colorSpace()); + + if (!SkColorSpace::Equals(skia_image->colorSpace(), + blob_color_space.get())) { + if (!skia_image->colorSpace()) { + skia_image->peekPixels(&src_data_); + src_data_.setColorSpace(SkColorSpace::MakeSRGB()); + skia_image = SkImage::MakeFromRaster(src_data_, nullptr, nullptr); + } + DCHECK(skia_image->colorSpace()); + skia_image = skia_image->makeColorSpace( + blob_color_space, SkTransferFunctionBehavior::kRespect); + image_ = StaticBitmapImage::Create(skia_image); + } + + if (skia_image->peekPixels(&src_data_)) + static_bitmap_image_loaded_ = true; + + // If the source image is 8 bit per channel but the blob is requested in + // 16 bpc PNG, we need to ensure the color type of the pixmap is + // kRGBA_F16_SkColorType to kick in 16 bit encoding in SkPngEncoder. Since + // SkPixmap only holds a pointer to data, we need a helper data member here. + if (mime_type_ == ImageEncoder::kMimeTypePng && + encode_options_.pixelFormat() == kRGBA16ImagePixelFormatName && + src_data_.colorType() == kN32_SkColorType) { + size_t data_length = src_data_.width() * src_data_.height() * + SkColorTypeBytesPerPixel(kRGBA_F16_SkColorType); + png_16bit_data_helper_ = SkData::MakeUninitialized(data_length); + SkColorSpaceXform::ColorFormat src_format = + SkColorSpaceXform::ColorFormat::kRGBA_8888_ColorFormat; + if (kN32_SkColorType == kBGRA_8888_SkColorType) + src_format = SkColorSpaceXform::ColorFormat::kBGRA_8888_ColorFormat; + if (SkColorSpaceXform::Apply( + src_data_.colorSpace(), + SkColorSpaceXform::ColorFormat::kRGBA_F16_ColorFormat, + png_16bit_data_helper_->writable_data(), src_data_.colorSpace(), + src_format, src_data_.addr(), + src_data_.width() * src_data_.height(), + SkColorSpaceXform::AlphaOp::kPreserve_AlphaOp)) { + SkImageInfo info = SkImageInfo::Make( + src_data_.width(), src_data_.height(), kRGBA_F16_SkColorType, + src_data_.alphaType(), src_data_.info().refColorSpace()); + src_data_.reset(info, png_16bit_data_helper_->data(), + info.minRowBytes()); + } + skia_image = SkImage::MakeFromRaster(src_data_, nullptr, nullptr); + image_ = StaticBitmapImage::Create(skia_image); + } } - if (skia_image->peekPixels(&src_data_)) { + if (static_bitmap_image_loaded_) { // Ensure that the size of the to-be-encoded-image does not pass the maximum // size supported by the encoders. int max_dimension = ImageEncoder::MaxDimension(mime_type_); @@ -226,11 +300,7 @@ std::min(info.height(), max_dimension)); src_data_.reset(info, src_data_.addr(), src_data_.rowBytes()); } - - src_data_.setColorSpace(nullptr); - static_bitmap_image_loaded_ = true; } - DCHECK(!src_data_.colorSpace()); idle_task_status_ = kIdleTaskNotSupported; num_rows_completed_ = 0; @@ -238,11 +308,6 @@ parent_frame_task_runner_ = context->GetTaskRunner(TaskType::kCanvasBlobSerialization); } - if (script_promise_resolver_) { - function_type_ = kOffscreenCanvasToBlobPromise; - } else { - function_type_ = kHTMLCanvasToBlobCallback; - } } CanvasAsyncBlobCreator::~CanvasAsyncBlobCreator() = default; @@ -256,11 +321,23 @@ image_ = nullptr; } +ImageEncodeOptions CanvasAsyncBlobCreator::GetImageEncodeOptionsForMimeType( + ImageEncoder::MimeType mime_type) { + ImageEncodeOptions encode_options; + encode_options.setType(ConvertMimeTypeEnumToString(mime_type)); + return encode_options; +} + bool CanvasAsyncBlobCreator::EncodeImage(const double& quality) { std::unique_ptr<ImageDataBuffer> buffer = ImageDataBuffer::Create(src_data_); if (!buffer) return false; - return buffer->EncodeImage("image/webp", quality, &encoded_image_); + SkTransferFunctionBehavior transfer_fn_behavior = + SkTransferFunctionBehavior::kIgnore; + if (function_type_ == kHTMLCanvasConvertToBlobPromise) + transfer_fn_behavior = SkTransferFunctionBehavior::kRespect; + return buffer->EncodeImage("image/webp", quality, &encoded_image_, + transfer_fn_behavior); } void CanvasAsyncBlobCreator::ScheduleAsyncBlobCreation(const double& quality) { @@ -273,7 +350,8 @@ } if (mime_type_ == ImageEncoder::kMimeTypeWebp) { if (!IsMainThread()) { - DCHECK(function_type_ == kOffscreenCanvasToBlobPromise); + DCHECK(function_type_ == kHTMLCanvasConvertToBlobPromise || + function_type_ == kOffscreenCanvasConvertToBlobPromise); // When OffscreenCanvas.convertToBlob() occurs on worker thread, // we do not need to use background task runner to reduce load on main. // So we just directly encode images on the worker thread. @@ -561,4 +639,25 @@ visitor->Trace(script_promise_resolver_); } +sk_sp<SkColorSpace> CanvasAsyncBlobCreator::BlobColorSpaceToSkColorSpace( + String blob_color_space) { + SkColorSpace::Gamut gamut = SkColorSpace::kSRGB_Gamut; + if (blob_color_space == kDisplayP3ImageColorSpaceName) + gamut = SkColorSpace::kDCIP3_D65_Gamut; + else if (blob_color_space == kRec2020ImageColorSpaceName) + gamut = SkColorSpace::kRec2020_Gamut; + return SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, gamut); +} + +bool CanvasAsyncBlobCreator::EncodeImageForConvertToBlobTest() { + if (!static_bitmap_image_loaded_) + return false; + std::unique_ptr<ImageDataBuffer> buffer = ImageDataBuffer::Create(src_data_); + if (!buffer) + return false; + return buffer->EncodeImage(encode_options_.type(), encode_options_.quality(), + &encoded_image_, + SkTransferFunctionBehavior::kRespect); +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h index 23e1f8b2..42c1b0c 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h +++ b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h
@@ -12,6 +12,7 @@ #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/v8_blob_callback.h" #include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/core/html/canvas/image_encode_options.h" #include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" #include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h" @@ -24,22 +25,16 @@ class ExecutionContext; +constexpr const char* kSRGBImageColorSpaceName = "srgb"; +constexpr const char* kRec2020ImageColorSpaceName = "rec2020"; +constexpr const char* kDisplayP3ImageColorSpaceName = "display-p3"; + +constexpr const char* kRGBA8ImagePixelFormatName = "8-8-8-8"; +constexpr const char* kRGBA16ImagePixelFormatName = "uint16"; + class CORE_EXPORT CanvasAsyncBlobCreator : public GarbageCollectedFinalized<CanvasAsyncBlobCreator> { public: - static CanvasAsyncBlobCreator* Create(scoped_refptr<StaticBitmapImage>, - const String& mime_type, - V8BlobCallback*, - double start_time, - ExecutionContext*); - static CanvasAsyncBlobCreator* Create(scoped_refptr<StaticBitmapImage>, - const String& mime_type, - double start_time, - ExecutionContext*, - ScriptPromiseResolver*); - - void ScheduleAsyncBlobCreation(const double& quality); - virtual ~CanvasAsyncBlobCreator(); // This enum is used to back an UMA histogram, and should therefore be treated // as append-only. @@ -53,26 +48,53 @@ // types kIdleTaskCount, // Should not be seen in production }; - enum ToBlobFunctionType { kHTMLCanvasToBlobCallback, - kOffscreenCanvasToBlobPromise, + kHTMLCanvasConvertToBlobPromise, + kOffscreenCanvasConvertToBlobPromise, kNumberOfToBlobFunctionTypes }; + static CanvasAsyncBlobCreator* Create(scoped_refptr<StaticBitmapImage>, + const String& mime_type, + V8BlobCallback*, + ToBlobFunctionType function_type, + double start_time, + ExecutionContext*); + static CanvasAsyncBlobCreator* Create(scoped_refptr<StaticBitmapImage>, + const ImageEncodeOptions& options, + ToBlobFunctionType function_type, + double start_time, + ExecutionContext*, + ScriptPromiseResolver*); + + void ScheduleAsyncBlobCreation(const double& quality); + virtual ~CanvasAsyncBlobCreator(); + // Methods are virtual for mocking in unit tests virtual void SignalTaskSwitchInStartTimeoutEventForTesting() {} virtual void SignalTaskSwitchInCompleteTimeoutEventForTesting() {} virtual void Trace(blink::Visitor*); + static sk_sp<SkColorSpace> BlobColorSpaceToSkColorSpace( + String blob_color_space); + + bool EncodeImageForConvertToBlobTest(); + Vector<unsigned char> GetEncodedImageForConvertToBlobTest() { + return encoded_image_; + } + protected: CanvasAsyncBlobCreator(scoped_refptr<StaticBitmapImage>, - ImageEncoder::MimeType, + const ImageEncodeOptions&, + ToBlobFunctionType, V8BlobCallback*, double, ExecutionContext*, ScriptPromiseResolver*); + static ImageEncodeOptions GetImageEncodeOptionsForMimeType( + ImageEncoder::MimeType); // Methods are virtual for unit testing virtual void ScheduleInitiateEncoding(double quality); virtual void IdleEncodeRows(double deadline_seconds); @@ -101,15 +123,16 @@ Member<ExecutionContext> context_; SkPixmap src_data_; - const ImageEncoder::MimeType mime_type_; + ImageEncoder::MimeType mime_type_; + const ImageEncodeOptions encode_options_; + ToBlobFunctionType function_type_; + sk_sp<SkData> png_16bit_data_helper_; // Chrome metrics use double start_time_; double schedule_idle_task_start_time_; bool static_bitmap_image_loaded_; - ToBlobFunctionType function_type_; - // Used when CanvasAsyncBlobCreator runs on main thread only scoped_refptr<base::SingleThreadTaskRunner> parent_frame_task_runner_;
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator_test.cc b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator_test.cc index 31f9829..bb5b266 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator_test.cc +++ b/third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator_test.cc
@@ -9,6 +9,8 @@ #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/core/html/canvas/image_data.h" #include "third_party/blink/renderer/core/testing/page_test_base.h" +#include "third_party/blink/renderer/platform/graphics/color_correction_test_utils.h" +#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/skia/include/core/SkSurface.h" @@ -23,12 +25,14 @@ ImageEncoder::MimeType mime_type, Document* document, bool fail_encoder_initialization = false) - : CanvasAsyncBlobCreator(image, - mime_type, - nullptr, - 0, - document, - nullptr) { + : CanvasAsyncBlobCreator( + image, + CanvasAsyncBlobCreator::GetImageEncodeOptionsForMimeType(mime_type), + kHTMLCanvasToBlobCallback, + nullptr, + 0, + document, + nullptr) { if (fail_encoder_initialization) fail_encoder_initialization_for_test_ = true; } @@ -213,4 +217,103 @@ AsyncBlobCreator()->GetIdleTaskStatus()); } +static sk_sp<SkImage> DrawAndReturnImage( + const std::pair<sk_sp<SkColorSpace>, SkColorType>& color_space_param) { + SkPaint transparentRed, transparentGreen, transparentBlue, transparentBlack; + transparentRed.setARGB(128, 155, 27, 27); + transparentGreen.setARGB(128, 27, 155, 27); + transparentBlue.setARGB(128, 27, 27, 155); + transparentBlack.setARGB(128, 27, 27, 27); + + SkImageInfo info = SkImageInfo::Make(2, 2, color_space_param.second, + SkAlphaType::kPremul_SkAlphaType, + color_space_param.first); + sk_sp<SkSurface> surface = SkSurface::MakeRaster(info); + surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), transparentRed); + surface->getCanvas()->drawRect(SkRect::MakeXYWH(1, 0, 1, 1), + transparentGreen); + surface->getCanvas()->drawRect(SkRect::MakeXYWH(0, 1, 1, 1), transparentBlue); + surface->getCanvas()->drawRect(SkRect::MakeXYWH(1, 1, 1, 1), + transparentBlack); + return surface->makeImageSnapshot(); +} + +TEST_F(CanvasAsyncBlobCreatorTest, ColorManagedConvertToBlob) { + std::list<std::pair<sk_sp<SkColorSpace>, SkColorType>> color_space_params; + color_space_params.push_back(std::pair<sk_sp<SkColorSpace>, SkColorType>( + SkColorSpace::MakeSRGB(), kN32_SkColorType)); + color_space_params.push_back(std::pair<sk_sp<SkColorSpace>, SkColorType>( + SkColorSpace::MakeSRGBLinear(), kRGBA_F16_SkColorType)); + color_space_params.push_back(std::pair<sk_sp<SkColorSpace>, SkColorType>( + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, + SkColorSpace::kDCIP3_D65_Gamut), + kRGBA_F16_SkColorType)); + color_space_params.push_back(std::pair<sk_sp<SkColorSpace>, SkColorType>( + SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, + SkColorSpace::kRec2020_Gamut), + kRGBA_F16_SkColorType)); + + std::list<String> blob_mime_types = {"image/png", "image/webp", "image/jpeg"}; + std::list<String> blob_color_spaces = {kSRGBImageColorSpaceName, + kDisplayP3ImageColorSpaceName, + kRec2020ImageColorSpaceName}; + // SkPngEncoder still does not support 16bit PNG encoding. Add + // kRGBA16ImagePixelFormatName to blob_pixel_formats when this is fixed. + // crbug.com/840372 + // bugs.chromium.org/p/skia/issues/detail?id=7926 + // https://fiddle.skia.org/c/b795f0141f4e1a5773bf9494b5bc87b5 + std::list<String> blob_pixel_formats = {kRGBA8ImagePixelFormatName}; + + // The maximum difference locally observed is 3. + const unsigned uint8_color_tolerance = 5; + const float f16_color_tolerance = 0.01; + // The maximum difference locally observed has the order of e^-6. + const float xyz_d50_color_space_component_tolerance = 0.001; + + for (auto color_space_param : color_space_params) { + for (auto blob_mime_type : blob_mime_types) { + for (auto blob_color_space : blob_color_spaces) { + for (auto blob_pixel_format : blob_pixel_formats) { + // Create the StaticBitmapImage in canvas_color_space + sk_sp<SkImage> source_image = DrawAndReturnImage(color_space_param); + scoped_refptr<UnacceleratedStaticBitmapImage> source_bitmap_image = + UnacceleratedStaticBitmapImage::Create(source_image); + + // Prepare encoding options + ImageEncodeOptions options; + options.setQuality(1); + options.setType(blob_mime_type); + options.setColorSpace(blob_color_space); + options.setPixelFormat(blob_pixel_format); + + // Encode the image using CanvasAsyncBlobCreator + CanvasAsyncBlobCreator* async_blob_creator = + CanvasAsyncBlobCreator::Create( + source_bitmap_image, options, + CanvasAsyncBlobCreator::ToBlobFunctionType:: + kHTMLCanvasConvertToBlobPromise, + 0, &GetDocument(), nullptr); + ASSERT_TRUE(async_blob_creator->EncodeImageForConvertToBlobTest()); + + sk_sp<SkData> sk_data = SkData::MakeWithCopy( + async_blob_creator->GetEncodedImageForConvertToBlobTest().data(), + async_blob_creator->GetEncodedImageForConvertToBlobTest().size()); + sk_sp<SkImage> decoded_img = SkImage::MakeFromEncoded(sk_data); + + sk_sp<SkImage> ref_image = source_image->makeColorSpace( + CanvasAsyncBlobCreator::BlobColorSpaceToSkColorSpace( + blob_color_space), + SkTransferFunctionBehavior::kRespect); + + // Jpeg does not support transparent images. + bool compare_alpha = (blob_mime_type != "image/jpeg"); + ASSERT_TRUE(ColorCorrectionTestUtils::MatchSkImages( + ref_image, decoded_img, uint8_color_tolerance, + f16_color_tolerance, xyz_d50_color_space_component_tolerance, + compare_alpha)); + } + } + } + } +} }
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.cc b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.cc index 91f52d6..e10a7577 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.cc +++ b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h" #include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h" #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h" #include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h" @@ -83,4 +84,61 @@ return CanvasColorParams(); } +ScriptPromise CanvasRenderingContextHost::convertToBlob( + ScriptState* script_state, + const ImageEncodeOptions& options, + ExceptionState& exception_state) const { + WTF::String object_name = "Canvas"; + if (this->IsOffscreenCanvas()) + object_name = "OffscreenCanvas"; + std::stringstream error_msg; + + if (this->IsOffscreenCanvas() && this->IsNeutered()) { + exception_state.ThrowDOMException(kInvalidStateError, + "OffscreenCanvas object is detached."); + return exception_state.Reject(script_state); + } + + if (!this->OriginClean()) { + error_msg << "Tainted " << object_name << " may not be exported."; + exception_state.ThrowSecurityError(error_msg.str().c_str()); + return exception_state.Reject(script_state); + } + + if (!this->IsPaintable() || Size().IsEmpty()) { + error_msg << "The size of " << object_name << " iz zero."; + exception_state.ThrowDOMException(kIndexSizeError, error_msg.str().c_str()); + return exception_state.Reject(script_state); + } + + if (!RenderingContext()) { + error_msg << object_name << " has no rendering context."; + exception_state.ThrowDOMException(kInvalidStateError, + error_msg.str().c_str()); + return exception_state.Reject(script_state); + } + + double start_time = WTF::CurrentTimeTicksInSeconds(); + scoped_refptr<StaticBitmapImage> image_bitmap = + RenderingContext()->GetImage(kPreferNoAcceleration); + if (image_bitmap) { + ScriptPromiseResolver* resolver = + ScriptPromiseResolver::Create(script_state); + CanvasAsyncBlobCreator::ToBlobFunctionType function_type = + CanvasAsyncBlobCreator::kHTMLCanvasConvertToBlobPromise; + if (this->IsOffscreenCanvas()) { + function_type = + CanvasAsyncBlobCreator::kOffscreenCanvasConvertToBlobPromise; + } + CanvasAsyncBlobCreator* async_creator = CanvasAsyncBlobCreator::Create( + image_bitmap, options, function_type, start_time, + ExecutionContext::From(script_state), resolver); + async_creator->ScheduleAsyncBlobCreation(options.quality()); + return resolver->Promise(); + } + exception_state.ThrowDOMException(kNotReadableError, + "Readback of the source image has failed."); + return exception_state.Reject(script_state); +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h index b9e29cd..4f0878f 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h +++ b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h
@@ -10,6 +10,7 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/events/event_dispatcher.h" #include "third_party/blink/renderer/core/dom/events/event_target.h" +#include "third_party/blink/renderer/core/html/canvas/image_encode_options.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/geometry/float_rect.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" @@ -63,6 +64,7 @@ // TODO(fserb): remove this. virtual bool IsOffscreenCanvas() const { return false; } + virtual bool IsNeutered() const { return false; } virtual void Commit(scoped_refptr<StaticBitmapImage> bitmap_image, const SkIRect& damage_rect) { @@ -81,6 +83,10 @@ CanvasColorParams ColorParams() const; CanvasResourceProvider* GetOrCreateCanvasResourceProvider(); + ScriptPromise convertToBlob(ScriptState*, + const ImageEncodeOptions&, + ExceptionState&) const; + protected: ~CanvasRenderingContextHost() override {}
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc index 0a5bbca..43f824d 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.cc
@@ -390,9 +390,7 @@ // FinalizeFrame indicates the end of a script task that may have rendered // into the canvas, now is a good time to unlock cache entries. - auto* resource_provider = canvas2d_bridge_ - ? canvas2d_bridge_->GetResourceProvider() - : ResourceProvider(); + auto* resource_provider = ResourceProvider(); if (resource_provider) resource_provider->ReleaseLockedImages(); @@ -459,7 +457,6 @@ if (bridge && canvas2d_bridge_) { ReplaceExisting2dLayerBridge(std::move(bridge)); - UpdateMemoryUsage(); } // We must force a paint invalidation on the canvas even if it's @@ -887,7 +884,9 @@ ToStaticBitmapImage(kBackBuffer, kPreferNoAcceleration); if (image_bitmap) { async_creator = CanvasAsyncBlobCreator::Create( - image_bitmap, encoding_mime_type, callback, start_time, &GetDocument()); + image_bitmap, encoding_mime_type, callback, + CanvasAsyncBlobCreator::kHTMLCanvasToBlobCallback, start_time, + &GetDocument()); } if (async_creator) { @@ -1031,7 +1030,7 @@ return nullptr; } -void HTMLCanvasElement::CreateCanvas2DLayerBridgeInternal( +void HTMLCanvasElement::SetCanvas2DLayerBridgeInternal( std::unique_ptr<Canvas2DLayerBridge> external_canvas2d_bridge) { DCHECK(Is2d() && !canvas2d_bridge_); @@ -1096,7 +1095,7 @@ Canvas2DLayerBridge* HTMLCanvasElement::GetOrCreateCanvas2DLayerBridge() { DCHECK(Is2d()); if (!canvas2d_bridge_ && !did_fail_to_create_resource_provider_) { - CreateCanvas2DLayerBridgeInternal(nullptr); + SetCanvas2DLayerBridgeInternal(nullptr); if (did_fail_to_create_resource_provider_ && !Size().IsEmpty()) { context_->LoseContext(CanvasRenderingContext::kSyntheticLostContext); } @@ -1104,13 +1103,13 @@ return canvas2d_bridge_.get(); } -void HTMLCanvasElement::CreateCanvas2DLayerBridgeForTesting( +void HTMLCanvasElement::SetCanvas2DLayerBridgeForTesting( std::unique_ptr<Canvas2DLayerBridge> bridge, const IntSize& size) { DiscardResourceProvider(); SetIntegralAttribute(widthAttr, size.Width()); SetIntegralAttribute(heightAttr, size.Height()); - CreateCanvas2DLayerBridgeInternal(std::move(bridge)); + SetCanvas2DLayerBridgeInternal(std::move(bridge)); } scoped_refptr<Image> HTMLCanvasElement::CopiedImage( @@ -1210,7 +1209,6 @@ CreateAccelerated2dBuffer(&msaa_sample_count); if (surface) { ReplaceExisting2dLayerBridge(std::move(surface)); - UpdateMemoryUsage(); SetNeedsCompositingUpdate(); } } @@ -1507,23 +1505,25 @@ } void HTMLCanvasElement::ReplaceExisting2dLayerBridge( - std::unique_ptr<Canvas2DLayerBridge> new_buffer) { + std::unique_ptr<Canvas2DLayerBridge> new_layer_bridge) { + scoped_refptr<StaticBitmapImage> image; if (canvas2d_bridge_) { - scoped_refptr<StaticBitmapImage> image = - canvas2d_bridge_->NewImageSnapshot(kPreferNoAcceleration); - - // image can be null if alloaction failed in which case we should just + image = canvas2d_bridge_->NewImageSnapshot(kPreferNoAcceleration); + // image can be null if allocation failed in which case we should just // abort the surface switch to reatain the old surface which is still // functional. if (!image) return; - new_buffer->DrawFullImage(image->PaintImageForCurrentFrame()); } + new_layer_bridge->SetCanvasResourceHost(this); + ReplaceResourceProvider(nullptr); + canvas2d_bridge_ = std::move(new_layer_bridge); + if (image) + canvas2d_bridge_->DrawFullImage(image->PaintImageForCurrentFrame()); - RestoreCanvasMatrixClipStack(new_buffer->Canvas()); - new_buffer->DidRestoreCanvasMatrixClipStack(new_buffer->Canvas()); - canvas2d_bridge_ = std::move(new_buffer); - canvas2d_bridge_->SetCanvasResourceHost(this); + RestoreCanvasMatrixClipStack(canvas2d_bridge_->Canvas()); + canvas2d_bridge_->DidRestoreCanvasMatrixClipStack(canvas2d_bridge_->Canvas()); + UpdateMemoryUsage(); } bool HTMLCanvasElement::HasImageBitmapContext() const {
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h index e815509..68bf017e 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.h +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.h
@@ -39,6 +39,7 @@ #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/html/canvas/canvas_image_source.h" #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h" +#include "third_party/blink/renderer/core/html/canvas/image_encode_options.h" #include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap_source.h" #include "third_party/blink/renderer/core/page/page_visibility_observer.h" @@ -220,8 +221,8 @@ unsigned resource_id) override; void Trace(blink::Visitor*) override; - void CreateCanvas2DLayerBridgeForTesting(std::unique_ptr<Canvas2DLayerBridge>, - const IntSize&); + void SetCanvas2DLayerBridgeForTesting(std::unique_ptr<Canvas2DLayerBridge>, + const IntSize&); static void RegisterRenderingContextFactory( std::unique_ptr<CanvasRenderingContextFactory>); @@ -310,7 +311,7 @@ std::unique_ptr<Canvas2DLayerBridge> CreateAccelerated2dBuffer( int* msaa_sample_count); std::unique_ptr<Canvas2DLayerBridge> CreateUnaccelerated2dBuffer(); - void CreateCanvas2DLayerBridgeInternal(std::unique_ptr<Canvas2DLayerBridge>); + void SetCanvas2DLayerBridgeInternal(std::unique_ptr<Canvas2DLayerBridge>); void SetSurfaceSize(const IntSize&);
diff --git a/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl b/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl index c440bac..0fee23b 100644 --- a/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl +++ b/third_party/blink/renderer/core/html/canvas/html_canvas_element.idl
@@ -40,6 +40,8 @@ [MeasureAs=CanvasToDataURL, RaisesException] DOMString toDataURL(optional DOMString type = null, optional any arguments); [MeasureAs=CanvasToBlob, RaisesException] void toBlob(BlobCallback _callback, optional DOMString type = null, optional any arguments); + + [RuntimeEnabled=CanvasColorManagement, MeasureAs=CanvasConvertToBlob, RaisesException, CallWith=ScriptState] Promise<Blob> convertToBlob(optional ImageEncodeOptions options); }; // https://html.spec.whatwg.org/multipage/canvas.html#blobcallback
diff --git a/third_party/blink/renderer/core/html/canvas/image_encode_options.idl b/third_party/blink/renderer/core/html/canvas/image_encode_options.idl new file mode 100644 index 0000000..b2aac7a --- /dev/null +++ b/third_party/blink/renderer/core/html/canvas/image_encode_options.idl
@@ -0,0 +1,21 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +enum ImageColorSpace { + "srgb", // default + "rec2020", + "display-p3", +}; + +enum ImagePixelFormat { + "8-8-8-8", // default + "uint16", +}; + +dictionary ImageEncodeOptions { + DOMString type = "image/png"; + unrestricted double quality = 1.0; + ImageColorSpace colorSpace = "srgb"; + ImagePixelFormat pixelFormat = "8-8-8-8"; +};
diff --git a/third_party/blink/renderer/core/html/media/html_media_element_event_listeners_test.cc b/third_party/blink/renderer/core/html/media/html_media_element_event_listeners_test.cc index da72e7ea..3dd7706 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element_event_listeners_test.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element_event_listeners_test.cc
@@ -207,7 +207,7 @@ std::unique_ptr<UserGestureIndicator> gesture_indicator = Frame::NotifyUserActivation(GetDocument().GetFrame()); Fullscreen::RequestFullscreen(*Video()); - Fullscreen::From(GetDocument()).DidEnterFullscreen(); + Fullscreen::DidEnterFullscreen(GetDocument()); test::RunPendingTasks();
diff --git a/third_party/blink/renderer/core/html/media/html_video_element_persistent_test.cc b/third_party/blink/renderer/core/html/media/html_video_element_persistent_test.cc index 23a223b..7efa11b 100644 --- a/third_party/blink/renderer/core/html/media/html_video_element_persistent_test.cc +++ b/third_party/blink/renderer/core/html/media/html_video_element_persistent_test.cc
@@ -12,7 +12,6 @@ #include "third_party/blink/renderer/core/fullscreen/fullscreen.h" #include "third_party/blink/renderer/core/fullscreen/fullscreen_options.h" #include "third_party/blink/renderer/core/html/html_div_element.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/loader/empty_clients.h" #include "third_party/blink/renderer/core/testing/page_test_base.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" @@ -61,11 +60,11 @@ FullscreenMockChromeClient& GetMockChromeClient() { return *chrome_client_; } void SimulateDidEnterFullscreen() { - Fullscreen::FromIfExists(GetDocument())->DidEnterFullscreen(); + Fullscreen::DidEnterFullscreen(GetDocument()); } void SimulateDidExitFullscreen() { - Fullscreen::FromIfExists(GetDocument())->DidExitFullscreen(); + Fullscreen::DidExitFullscreen(GetDocument()); } void SimulateBecamePersistentVideo(bool value) {
diff --git a/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc b/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc index 5010b17..cb6a998 100644 --- a/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc
@@ -56,7 +56,8 @@ String mime_type = "image/"; mime_type.append(encoding); - return image_to_encode->EncodeImage(mime_type, quality, output); + return image_to_encode->EncodeImage(mime_type, quality, output, + SkTransferFunctionBehavior::kIgnore); } } // namespace
diff --git a/third_party/blink/renderer/core/layout/BUILD.gn b/third_party/blink/renderer/core/layout/BUILD.gn index 97fa6ef..cd5296f7 100644 --- a/third_party/blink/renderer/core/layout/BUILD.gn +++ b/third_party/blink/renderer/core/layout/BUILD.gn
@@ -132,8 +132,6 @@ "layout_frame.h", "layout_frame_set.cc", "layout_frame_set.h", - "layout_full_screen.cc", - "layout_full_screen.h", "layout_geometry_map.cc", "layout_geometry_map.h", "layout_geometry_map_step.h",
diff --git a/third_party/blink/renderer/core/layout/layout_block.cc b/third_party/blink/renderer/core/layout/layout_block.cc index c4450e7..1deea79f 100644 --- a/third_party/blink/renderer/core/layout/layout_block.cc +++ b/third_party/blink/renderer/core/layout/layout_block.cc
@@ -314,11 +314,7 @@ // If the requested insertion point is not one of our children, then this is // because there is an anonymous container within this object that contains // the beforeDescendant. - if (before_descendant_container->IsAnonymousBlock() - // Full screen layoutObjects and full screen placeholders act as anonymous - // blocks, not tables: - || before_descendant_container->IsLayoutFullScreen() || - before_descendant_container->IsLayoutFullScreenPlaceholder()) { + if (before_descendant_container->IsAnonymousBlock()) { // Insert the child into the anonymous block box instead of here. if (new_child->IsInline() || (new_child->IsFloatingOrOutOfFlowPositioned() && !IsFlexibleBox() &&
diff --git a/third_party/blink/renderer/core/layout/layout_box.h b/third_party/blink/renderer/core/layout/layout_box.h index aa8a970..6be5618a 100644 --- a/third_party/blink/renderer/core/layout/layout_box.h +++ b/third_party/blink/renderer/core/layout/layout_box.h
@@ -561,8 +561,8 @@ // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines // (LayoutFlow) to return the remaining width on a given line (and the height // of a single line). - LayoutUnit OffsetWidth() const override { return frame_rect_.Width(); } - LayoutUnit OffsetHeight() const override { return frame_rect_.Height(); } + LayoutUnit OffsetWidth() const final { return frame_rect_.Width(); } + LayoutUnit OffsetHeight() const final { return frame_rect_.Height(); } int PixelSnappedOffsetWidth(const Element*) const final; int PixelSnappedOffsetHeight(const Element*) const final; @@ -1150,8 +1150,8 @@ LinePositionMode = kPositionOnContainingLine) const override; LayoutPoint OffsetPoint(const Element* parent) const; - LayoutUnit OffsetLeft(const Element*) const override; - LayoutUnit OffsetTop(const Element*) const override; + LayoutUnit OffsetLeft(const Element*) const final; + LayoutUnit OffsetTop(const Element*) const final; LayoutPoint FlipForWritingModeForChild(const LayoutBox* child, const LayoutPoint&) const;
diff --git a/third_party/blink/renderer/core/layout/layout_full_screen.cc b/third_party/blink/renderer/core/layout/layout_full_screen.cc deleted file mode 100644 index a90fabb..0000000 --- a/third_party/blink/renderer/core/layout/layout_full_screen.cc +++ /dev/null
@@ -1,238 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ - -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" - -#include "third_party/blink/public/platform/web_screen_info.h" -#include "third_party/blink/renderer/core/frame/visual_viewport.h" -#include "third_party/blink/renderer/core/fullscreen/fullscreen.h" -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" -#include "third_party/blink/renderer/core/page/page.h" - -namespace blink { - -namespace { - -class LayoutFullScreenPlaceholder final : public LayoutBlockFlow { - public: - LayoutFullScreenPlaceholder(LayoutFullScreen* owner) - : LayoutBlockFlow(nullptr), owner_(owner) { - SetDocumentForAnonymous(&owner->GetDocument()); - } - - // Must call SetStyleWithWritingModeOfParent() instead. - void SetStyle(scoped_refptr<ComputedStyle>) = delete; - - bool CreatesNewFormattingContext() const override { return true; } - - private: - bool IsOfType(LayoutObjectType type) const override { - return type == kLayoutObjectLayoutFullScreenPlaceholder || - LayoutBlockFlow::IsOfType(type); - } - bool AnonymousHasStylePropagationOverride() override { return true; } - - void WillBeDestroyed() override; - - LayoutFullScreen* owner_; -}; - -void LayoutFullScreenPlaceholder::WillBeDestroyed() { - owner_->ResetPlaceholder(); - LayoutBlockFlow::WillBeDestroyed(); -} - -} // namespace - -LayoutFullScreen::LayoutFullScreen() - : LayoutFlexibleBox(nullptr), placeholder_(nullptr) { - SetIsAtomicInlineLevel(false); -} - -LayoutFullScreen* LayoutFullScreen::CreateAnonymous(Document* document) { - LayoutFullScreen* layout_object = new LayoutFullScreen(); - layout_object->SetDocumentForAnonymous(document); - return layout_object; -} - -void LayoutFullScreen::WillBeDestroyed() { - if (placeholder_) { - // Remove children before self. - if (LayoutObjectChildList* children = Children()) - children->DestroyLeftoverChildren(); - Remove(); - if (!placeholder_->BeingDestroyed()) - placeholder_->Destroy(); - DCHECK(!placeholder_); - } - - // LayoutObjects are unretained, so notify the document (which holds a pointer - // to a LayoutFullScreen) if its LayoutFullScreen is destroyed. - Fullscreen& fullscreen = Fullscreen::From(GetDocument()); - if (fullscreen.FullScreenLayoutObject() == this) - fullscreen.FullScreenLayoutObjectDestroyed(); - - LayoutFlexibleBox::WillBeDestroyed(); -} - -scoped_refptr<ComputedStyle> LayoutFullScreen::CreateAnonymousStyle() { - scoped_refptr<ComputedStyle> fullscreen_style = ComputedStyle::Create(); - - // Create a stacking context: - fullscreen_style->SetZIndex(INT_MAX); - fullscreen_style->SetIsStackingContext(true); - - fullscreen_style->SetFontDescription(FontDescription()); - fullscreen_style->GetFont().Update(nullptr); - - fullscreen_style->SetDisplay(EDisplay::kFlex); - fullscreen_style->SetJustifyContentPosition(ContentPosition::kCenter); - // TODO (lajava): Since the FullScrenn layout object is anonymous, its Default - // Alignment (align-items) value can't be used to resolve its children Self - // Alignment 'auto' values. - fullscreen_style->SetAlignItemsPosition(ItemPosition::kCenter); - fullscreen_style->SetFlexDirection(EFlexDirection::kColumn); - - fullscreen_style->SetPosition(EPosition::kFixed); - fullscreen_style->SetLeft(Length(0, blink::kFixed)); - fullscreen_style->SetTop(Length(0, blink::kFixed)); - IntSize viewport_size = GetDocument().GetPage()->GetVisualViewport().Size(); - fullscreen_style->SetWidth(Length(viewport_size.Width(), blink::kFixed)); - fullscreen_style->SetHeight(Length(viewport_size.Height(), blink::kFixed)); - - fullscreen_style->SetBackgroundColor(StyleColor(Color::kBlack)); - return fullscreen_style; -} - -void LayoutFullScreen::UpdateStyle() { - scoped_refptr<ComputedStyle> style = CreateAnonymousStyle(); - SetStyleWithWritingModeOf(style, Parent()); -} - -LayoutObject* LayoutFullScreen::WrapLayoutObject(LayoutObject* object, - LayoutObject* parent, - Document* document) { - // TODO: We should not modify the structure of the layout tree during layout. - // crbug.com/370459 - DeprecatedDisableModifyLayoutTreeStructureAsserts disabler; - - // A fullscreen <html> element should not be wrapped (see crbug.com/676432). - DCHECK(!object || object->GetNode() != document->documentElement()); - - LayoutFullScreen* fullscreen_layout_object = - LayoutFullScreen::CreateAnonymous(document); - scoped_refptr<ComputedStyle> fullscreen_style = - fullscreen_layout_object->CreateAnonymousStyle(); - - if (parent && - !parent->IsChildAllowed(fullscreen_layout_object, *fullscreen_style)) { - fullscreen_layout_object->Destroy(); - return nullptr; - } - parent = object ? object->Parent() : nullptr; - fullscreen_layout_object->SetStyleWithWritingModeOf(fullscreen_style, parent); - - // |object->Parent()| can be null if the object is not yet attached - // to |parent|. - if (parent) { - LayoutBlock* containing_block = object->ContainingBlock(); - DCHECK(containing_block); - // Since we are moving the |object| to a new parent - // |fullscreen_layout_object|, the line box tree underneath our - // |containing_block| is not longer valid. - if (containing_block->IsLayoutBlockFlow()) - ToLayoutBlockFlow(containing_block)->DeleteLineBoxTree(); - - parent->AddChild(fullscreen_layout_object, object); - object->Remove(); - - // Always just do a full layout to ensure that line boxes get deleted - // properly. - // Because objects moved from |parent| to |fullscreen_layout_object|, we - // want to make new line boxes instead of leaving the old ones around. - parent->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( - LayoutInvalidationReason::kFullscreen); - containing_block->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( - LayoutInvalidationReason::kFullscreen); - } - if (object) { - fullscreen_layout_object->AddChild(object); - fullscreen_layout_object - ->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( - LayoutInvalidationReason::kFullscreen); - } - - DCHECK(document); - Fullscreen::From(*document).SetFullScreenLayoutObject( - fullscreen_layout_object); - return fullscreen_layout_object; -} - -void LayoutFullScreen::UnwrapLayoutObject() { - // FIXME: We should not modify the structure of the layout tree during - // layout. crbug.com/370459 - DeprecatedDisableModifyLayoutTreeStructureAsserts disabler; - - if (Parent()) { - for (LayoutObject* child = FirstChild(); child; child = FirstChild()) { - // We have to clear the override size, because as a flexbox, we - // may have set one on the child, and we don't want to leave that - // lying around on the child. - if (child->IsBox()) - ToLayoutBox(child)->ClearOverrideSize(); - child->Remove(); - Parent()->AddChild(child, this); - Parent()->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( - LayoutInvalidationReason::kFullscreen); - } - } - if (Placeholder()) - Placeholder()->Remove(); - Remove(); - Destroy(); -} - -void LayoutFullScreen::CreatePlaceholder(scoped_refptr<ComputedStyle> style, - const LayoutRect& frame_rect) { - if (style->Width().IsAuto()) - style->SetWidth(Length(frame_rect.Width(), kFixed)); - if (style->Height().IsAuto()) - style->SetHeight(Length(frame_rect.Height(), kFixed)); - - if (placeholder_) { - placeholder_->SetStyleWithWritingModeOfParent(std::move(style)); - return; - } - - placeholder_ = new LayoutFullScreenPlaceholder(this); - placeholder_->SetStyleWithWritingModeOf(std::move(style), Parent()); - if (Parent()) { - Parent()->AddChild(placeholder_, this); - Parent()->SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( - LayoutInvalidationReason::kFullscreen); - } -} - -} // namespace blink
diff --git a/third_party/blink/renderer/core/layout/layout_full_screen.h b/third_party/blink/renderer/core/layout/layout_full_screen.h deleted file mode 100644 index 63534f4..0000000 --- a/third_party/blink/renderer/core/layout/layout_full_screen.h +++ /dev/null
@@ -1,80 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ - -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FULL_SCREEN_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_FULL_SCREEN_H_ - -#include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/layout/layout_flexible_box.h" - -namespace blink { - -class LayoutBlockFlow; - -class CORE_EXPORT LayoutFullScreen final : public LayoutFlexibleBox { - public: - static LayoutFullScreen* CreateAnonymous(Document*); - - bool IsOfType(LayoutObjectType type) const override { - return type == kLayoutObjectLayoutFullScreen || - LayoutFlexibleBox::IsOfType(type); - } - const char* GetName() const override { return "LayoutFullScreen"; } - - void ResetPlaceholder() { placeholder_ = nullptr; } - LayoutBlockFlow* Placeholder() { return placeholder_; } - void CreatePlaceholder(scoped_refptr<ComputedStyle>, - const LayoutRect& frame_rect); - - static LayoutObject* WrapLayoutObject(LayoutObject*, - LayoutObject*, - Document*); - void UnwrapLayoutObject(); - - void UpdateStyle(); - bool AnonymousHasStylePropagationOverride() override { return true; } - - // Must call setStyleWithWritingModeOfParent() instead. - void SetStyle(scoped_refptr<ComputedStyle>) = delete; - - private: - LayoutFullScreen(); - void WillBeDestroyed() override; - scoped_refptr<ComputedStyle> CreateAnonymousStyle(); - - protected: - LayoutBlockFlow* placeholder_; - ItemPosition SelfAlignmentNormalBehavior( - const LayoutBox* child = nullptr) const override { - DCHECK(!child); - return ItemPosition::kCenter; - } -}; - -DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutFullScreen, IsLayoutFullScreen()); - -} // namespace blink - -#endif
diff --git a/third_party/blink/renderer/core/layout/layout_inline.cc b/third_party/blink/renderer/core/layout/layout_inline.cc index 7dd90d7..7154da5a 100644 --- a/third_party/blink/renderer/core/layout/layout_inline.cc +++ b/third_party/blink/renderer/core/layout/layout_inline.cc
@@ -29,7 +29,6 @@ #include "third_party/blink/renderer/core/layout/api/line_layout_box_model.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/layout/layout_geometry_map.h" #include "third_party/blink/renderer/core/layout/layout_theme.h" #include "third_party/blink/renderer/core/layout/layout_view.h" @@ -442,18 +441,6 @@ DCHECK(IsDescendantOf(from_block)); DCHECK(!IsAnonymous()); - // If we're splitting the inline containing the fullscreened element, - // |beforeChild| may be the layoutObject for the fullscreened element. - // However, that layoutObject is wrapped in a LayoutFullScreen, so |this| is - // not its parent. Since the splitting logic expects |this| to be the parent, - // set |beforeChild| to be the LayoutFullScreen. - if (Fullscreen* fullscreen = Fullscreen::FromIfExists(GetDocument())) { - const Element* fullscreen_element = fullscreen->FullscreenElement(); - if (fullscreen_element && before_child && - before_child->GetNode() == fullscreen_element) - before_child = fullscreen->FullScreenLayoutObject(); - } - // FIXME: Because splitting is O(n^2) as tags nest pathologically, we cap the // depth at which we're willing to clone. // There will eventually be a better approach to this problem that will let us
diff --git a/third_party/blink/renderer/core/layout/layout_menu_list.cc b/third_party/blink/renderer/core/layout/layout_menu_list.cc index 2218605..0f83f310 100644 --- a/third_party/blink/renderer/core/layout/layout_menu_list.cc +++ b/third_party/blink/renderer/core/layout/layout_menu_list.cc
@@ -57,7 +57,7 @@ // insertion point to prevent children from rendering. bool LayoutMenuList::IsChildAllowed(LayoutObject* object, const ComputedStyle&) const { - return object->IsAnonymous() && !object->IsLayoutFullScreen(); + return object->IsAnonymous(); } scoped_refptr<ComputedStyle> LayoutMenuList::CreateInnerStyle() {
diff --git a/third_party/blink/renderer/core/layout/layout_object.h b/third_party/blink/renderer/core/layout/layout_object.h index 5a8db517..744f7df4 100644 --- a/third_party/blink/renderer/core/layout/layout_object.h +++ b/third_party/blink/renderer/core/layout/layout_object.h
@@ -425,7 +425,8 @@ inline bool ShouldApplyPaintContainment() const { return StyleRef().ContainsPaint() && - (!IsInline() || IsAtomicInlineLevel()) && !IsRubyText(); + (!IsInline() || IsAtomicInlineLevel()) && !IsRubyText() && + (!IsTablePart() || IsLayoutBlockFlow()); } private: @@ -549,12 +550,6 @@ bool IsQuote() const { return IsOfType(kLayoutObjectQuote); } bool IsLayoutButton() const { return IsOfType(kLayoutObjectLayoutButton); } bool IsLayoutCustom() const { return IsOfType(kLayoutObjectLayoutCustom); } - bool IsLayoutFullScreen() const { - return IsOfType(kLayoutObjectLayoutFullScreen); - } - bool IsLayoutFullScreenPlaceholder() const { - return IsOfType(kLayoutObjectLayoutFullScreenPlaceholder); - } bool IsLayoutGrid() const { return IsOfType(kLayoutObjectLayoutGrid); } bool IsLayoutIFrame() const { return IsOfType(kLayoutObjectLayoutIFrame); } bool IsLayoutImage() const { return IsOfType(kLayoutObjectLayoutImage); } @@ -774,8 +769,7 @@ Style()->Display() == EDisplay::kWebkitBox) && Style()->StyleType() == kPseudoIdNone && IsLayoutBlock() && !IsListMarker() && !IsLayoutFlowThread() && - !IsLayoutMultiColumnSet() && !IsLayoutFullScreen() && - !IsLayoutFullScreenPlaceholder(); + !IsLayoutMultiColumnSet(); } bool IsElementContinuation() const { return GetNode() && GetNode()->GetLayoutObject() != this; @@ -2006,8 +2000,6 @@ kLayoutObjectLayoutButton, kLayoutObjectLayoutCustom, kLayoutObjectLayoutFlowThread, - kLayoutObjectLayoutFullScreen, - kLayoutObjectLayoutFullScreenPlaceholder, kLayoutObjectLayoutGrid, kLayoutObjectLayoutIFrame, kLayoutObjectLayoutImage,
diff --git a/third_party/blink/renderer/core/layout/layout_video.cc b/third_party/blink/renderer/core/layout/layout_video.cc index b66e8331..cb2a454 100644 --- a/third_party/blink/renderer/core/layout/layout_video.cc +++ b/third_party/blink/renderer/core/layout/layout_video.cc
@@ -27,9 +27,6 @@ #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/html/media/html_video_element.h" -#include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/layout/layout_block_flow.h" -#include "third_party/blink/renderer/core/layout/layout_full_screen.h" #include "third_party/blink/renderer/core/paint/video_painter.h" namespace blink { @@ -187,44 +184,6 @@ return !!MediaElement()->CcLayer(); } -static const LayoutBlock* LayoutObjectPlaceholder( - const LayoutObject* layout_object) { - LayoutObject* parent = layout_object->Parent(); - if (!parent) - return nullptr; - - LayoutFullScreen* full_screen = - parent->IsLayoutFullScreen() ? ToLayoutFullScreen(parent) : nullptr; - if (!full_screen) - return nullptr; - - return full_screen->Placeholder(); -} - -LayoutUnit LayoutVideo::OffsetLeft(const Element* parent) const { - if (const LayoutBlock* block = LayoutObjectPlaceholder(this)) - return block->OffsetLeft(parent); - return LayoutMedia::OffsetLeft(parent); -} - -LayoutUnit LayoutVideo::OffsetTop(const Element* parent) const { - if (const LayoutBlock* block = LayoutObjectPlaceholder(this)) - return block->OffsetTop(parent); - return LayoutMedia::OffsetTop(parent); -} - -LayoutUnit LayoutVideo::OffsetWidth() const { - if (const LayoutBlock* block = LayoutObjectPlaceholder(this)) - return block->OffsetWidth(); - return LayoutMedia::OffsetWidth(); -} - -LayoutUnit LayoutVideo::OffsetHeight() const { - if (const LayoutBlock* block = LayoutObjectPlaceholder(this)) - return block->OffsetHeight(); - return LayoutMedia::OffsetHeight(); -} - CompositingReasons LayoutVideo::AdditionalCompositingReasons() const { HTMLMediaElement* element = ToHTMLMediaElement(GetNode()); if (element->IsFullscreen() && element->UsesOverlayFullscreenVideo())
diff --git a/third_party/blink/renderer/core/layout/layout_video.h b/third_party/blink/renderer/core/layout/layout_video.h index c89807d..91b3847 100644 --- a/third_party/blink/renderer/core/layout/layout_video.h +++ b/third_party/blink/renderer/core/layout/layout_video.h
@@ -73,11 +73,6 @@ LayoutUnit estimated_used_width = LayoutUnit()) const override; LayoutUnit MinimumReplacedHeight() const override; - LayoutUnit OffsetLeft(const Element*) const override; - LayoutUnit OffsetTop(const Element*) const override; - LayoutUnit OffsetWidth() const override; - LayoutUnit OffsetHeight() const override; - CompositingReasons AdditionalCompositingReasons() const override; void UpdatePlayer();
diff --git a/third_party/blink/renderer/core/offscreencanvas/image_encode_options.idl b/third_party/blink/renderer/core/offscreencanvas/image_encode_options.idl deleted file mode 100644 index 338adc7..0000000 --- a/third_party/blink/renderer/core/offscreencanvas/image_encode_options.idl +++ /dev/null
@@ -1,10 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// https://html.spec.whatwg.org/multipage/scripting.html#the-offscreencanvas-interface - -dictionary ImageEncodeOptions { - DOMString type = "image/png"; - unrestricted double quality = 1.0; // Defaults to 1.0 if value is outside 0:1 range -};
diff --git a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc index 5f5f797..2d8d603 100644 --- a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc +++ b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc
@@ -325,53 +325,6 @@ current_frame_damage_rect_ = SkIRect::MakeEmpty(); } -ScriptPromise OffscreenCanvas::convertToBlob(ScriptState* script_state, - const ImageEncodeOptions& options, - ExceptionState& exception_state) { - if (this->IsNeutered()) { - exception_state.ThrowDOMException(kInvalidStateError, - "OffscreenCanvas object is detached."); - return exception_state.Reject(script_state); - } - - if (!this->OriginClean()) { - exception_state.ThrowSecurityError( - "Tainted OffscreenCanvas may not be exported."); - return exception_state.Reject(script_state); - } - - if (!this->IsPaintable() || size_.IsEmpty()) { - exception_state.ThrowDOMException( - kIndexSizeError, "The size of the OffscreenCanvas is zero."); - return exception_state.Reject(script_state); - } - - if (!this->context_) { - exception_state.ThrowDOMException( - kInvalidStateError, "OffscreenCanvas object has no rendering contexts"); - return exception_state.Reject(script_state); - } - - double start_time = WTF::CurrentTimeTicksInSeconds(); - scoped_refptr<StaticBitmapImage> snapshot = - context_->GetImage(kPreferNoAcceleration); - if (snapshot) { - ScriptPromiseResolver* resolver = - ScriptPromiseResolver::Create(script_state); - String encoding_mime_type = ImageEncoderUtils::ToEncodingMimeType( - options.type(), ImageEncoderUtils::kEncodeReasonConvertToBlobPromise); - CanvasAsyncBlobCreator* async_creator = CanvasAsyncBlobCreator::Create( - snapshot, encoding_mime_type, start_time, - ExecutionContext::From(script_state), resolver); - async_creator->ScheduleAsyncBlobCreation(options.quality()); - return resolver->Promise(); - } else { - exception_state.ThrowDOMException( - kNotReadableError, "Readback of the source image has failed."); - return exception_state.Reject(script_state); - } -} - void OffscreenCanvas::RegisterContextToDispatch( CanvasRenderingContext* context) { if (!HasPlaceholderCanvas())
diff --git a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h index e1ce9e3..f3fa347 100644 --- a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h +++ b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h
@@ -12,8 +12,8 @@ #include "third_party/blink/renderer/core/html/canvas/canvas_image_source.h" #include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h" #include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h" +#include "third_party/blink/renderer/core/html/canvas/image_encode_options.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap_source.h" -#include "third_party/blink/renderer/core/offscreencanvas/image_encode_options.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/geometry/int_size.h" @@ -57,9 +57,6 @@ // API Methods ImageBitmap* transferToImageBitmap(ScriptState*, ExceptionState&); - ScriptPromise convertToBlob(ScriptState*, - const ImageEncodeOptions&, - ExceptionState&); const IntSize& Size() const override { return size_; } void SetSize(const IntSize&); @@ -71,7 +68,7 @@ bool HasPlaceholderCanvas() { return placeholder_canvas_id_ != kInvalidDOMNodeId; } - bool IsNeutered() const { return is_neutered_; } + bool IsNeutered() const override { return is_neutered_; } void SetNeutered(); CanvasRenderingContext* GetCanvasRenderingContext( ExecutionContext*,
diff --git a/third_party/blink/renderer/core/paint/html_canvas_painter_test.cc b/third_party/blink/renderer/core/paint/html_canvas_painter_test.cc index 717d8769..fbbf3da0 100644 --- a/third_party/blink/renderer/core/paint/html_canvas_painter_test.cc +++ b/third_party/blink/renderer/core/paint/html_canvas_painter_test.cc
@@ -91,7 +91,7 @@ element->GetCanvasRenderingContext("2d", attributes); IntSize size(300, 200); std::unique_ptr<Canvas2DLayerBridge> bridge = MakeCanvas2DLayerBridge(size); - element->CreateCanvas2DLayerBridgeForTesting(std::move(bridge), size); + element->SetCanvas2DLayerBridgeForTesting(std::move(bridge), size); ASSERT_EQ(context, element->RenderingContext()); ASSERT_TRUE(context->IsComposited()); ASSERT_TRUE(element->IsAccelerated());
diff --git a/third_party/blink/renderer/devtools/front_end/console_test_runner/ConsoleTestRunner.js b/third_party/blink/renderer/devtools/front_end/console_test_runner/ConsoleTestRunner.js index 9575313d..560d696 100644 --- a/third_party/blink/renderer/devtools/front_end/console_test_runner/ConsoleTestRunner.js +++ b/third_party/blink/renderer/devtools/front_end/console_test_runner/ConsoleTestRunner.js
@@ -49,23 +49,32 @@ let classNames; if (dumpClassNames) { - classNames = []; + classNames = ['']; for (let node = element.firstChild; node; node = node.traverseNextNode(element)) { if (node.nodeType === Node.ELEMENT_NODE && node.className) { - classNames.push(node.className.replace('platform-linux', 'platform-*') - .replace('platform-mac', 'platform-*') - .replace('platform-windows', 'platform-*')); + let depth = 0; + let depthTest = node; + while (depthTest !== element) { + if (depthTest.nodeType === Node.ELEMENT_NODE && depthTest.className) + depth++; + depthTest = depthTest.parentNodeOrShadowHost(); + } + classNames.push( + ' '.repeat(depth) + + node.className.replace('platform-linux', 'platform-*') + .replace('platform-mac', 'platform-*') + .replace('platform-windows', 'platform-*')); } } } if (ConsoleTestRunner.dumpConsoleTableMessage(uiMessage, false, result)) { if (dumpClassNames) - result.push(classNames.join(' > ')); + result.push(classNames.join('\n')); } else { let messageText = formatter(element, message); messageText = messageText.replace(/VM\d+/g, 'VM'); - result.push(messageText + (dumpClassNames ? ' ' + classNames.join(' > ') : '')); + result.push(messageText + (dumpClassNames ? ' ' + classNames.join('\n') : '')); } if (printOriginatingCommand && uiMessage.consoleMessage().originatingMessage())
diff --git a/third_party/blink/renderer/devtools/front_end/platform/utilities.js b/third_party/blink/renderer/devtools/front_end/platform/utilities.js index 89f18ce..522c6b0 100644 --- a/third_party/blink/renderer/devtools/front_end/platform/utilities.js +++ b/third_party/blink/renderer/devtools/front_end/platform/utilities.js
@@ -1204,13 +1204,10 @@ /** * @param {K} key - * @return {!Set.<!V>} + * @return {!Set<!V>} */ get: function(key) { - let result = this._map.get(key); - if (!result) - result = new Set(); - return result; + return this._map.get(key) || new Set(); }, /**
diff --git a/third_party/blink/renderer/devtools/front_end/sdk/CPUProfileDataModel.js b/third_party/blink/renderer/devtools/front_end/sdk/CPUProfileDataModel.js index c1a7dd6..443444c 100644 --- a/third_party/blink/renderer/devtools/front_end/sdk/CPUProfileDataModel.js +++ b/third_party/blink/renderer/devtools/front_end/sdk/CPUProfileDataModel.js
@@ -94,8 +94,8 @@ let lastTimeUsec = profile.startTime; const timestamps = new Array(profile.timeDeltas.length + 1); for (let i = 0; i < profile.timeDeltas.length; ++i) { - timestamps[i] = lastTimeUsec; lastTimeUsec += profile.timeDeltas[i]; + timestamps[i] = lastTimeUsec; } timestamps[profile.timeDeltas.length] = lastTimeUsec; return timestamps;
diff --git a/third_party/blink/renderer/devtools/front_end/sdk/TracingModel.js b/third_party/blink/renderer/devtools/front_end/sdk/TracingModel.js index ccfc237..f6410fd 100644 --- a/third_party/blink/renderer/devtools/front_end/sdk/TracingModel.js +++ b/third_party/blink/renderer/devtools/front_end/sdk/TracingModel.js
@@ -293,6 +293,14 @@ } /** + * @param {number} pid + * @return {?SDK.TracingModel.Process} + */ + processById(pid) { + return this._processById.get(pid) || null; + } + + /** * @param {string} processName * @param {string} threadName * @return {?SDK.TracingModel.Thread}
diff --git a/third_party/blink/renderer/devtools/front_end/timeline/TimelineController.js b/third_party/blink/renderer/devtools/front_end/timeline/TimelineController.js index 7a01424..1cf667e 100644 --- a/third_party/blink/renderer/devtools/front_end/timeline/TimelineController.js +++ b/third_party/blink/renderer/devtools/front_end/timeline/TimelineController.js
@@ -26,6 +26,10 @@ SDK.targetManager.observeModels(SDK.CPUProfilerModel, this); } + dispose() { + SDK.targetManager.unobserveModels(SDK.CPUProfilerModel, this); + } + /** * @return {!SDK.Target} */ @@ -224,20 +228,74 @@ this._tracingModel.addEvents([cpuProfileEvent]); } + /** + * @return {?Map<string, number>} + */ + _buildTargetToProcessIdMap() { + const metadataEventTypes = TimelineModel.TimelineModel.DevToolsMetadataEvent; + const metadataEvents = this._tracingModel.devToolsMetadataEvents(); + const browserMetaEvent = metadataEvents.find(e => e.name === metadataEventTypes.TracingStartedInBrowser); + if (!browserMetaEvent) + return null; + + /** @type {!Multimap<string, string>} */ + const pseudoPidToFrames = new Multimap(); + /** @type {!Map<string, number>} */ + const targetIdToPid = new Map(); + const frames = browserMetaEvent.args.data['frames']; + for (const frameInfo of frames) + targetIdToPid.set(frameInfo.frame, frameInfo.processId); + for (const event of metadataEvents) { + const data = event.args.data; + switch (event.name) { + case metadataEventTypes.FrameCommittedInBrowser: + if (data.processId) + targetIdToPid.set(data.frame, data.processId); + else + pseudoPidToFrames.set(data.processPseudoId, data.frame); + break; + case metadataEventTypes.ProcessReadyInBrowser: + for (const frame of pseudoPidToFrames.get(data.processPseudoId) || []) + targetIdToPid.set(frame, data.processId); + break; + } + } + const mainFrame = frames.find(frame => !frame.parent); + const mainRendererProcessId = mainFrame.processId; + const mainProcess = this._tracingModel.processById(mainRendererProcessId); + if (mainProcess) + targetIdToPid.set(SDK.targetManager.mainTarget().id(), mainProcess.id()); + return targetIdToPid; + } + _injectCpuProfileEvents() { if (!this._cpuProfiles) return; const metadataEventTypes = TimelineModel.TimelineModel.DevToolsMetadataEvent; const metadataEvents = this._tracingModel.devToolsMetadataEvents(); - const mainMetaEvent = - metadataEvents.filter(event => event.name === metadataEventTypes.TracingStartedInPage).peekLast(); - if (!mainMetaEvent) - return; - const pid = mainMetaEvent.thread.process().id(); - const mainCpuProfile = this._cpuProfiles.get(this._tracingManager.target().id()); - this._injectCpuProfileEvent(pid, mainMetaEvent.thread.id(), mainCpuProfile); + const targetIdToPid = this._buildTargetToProcessIdMap(); + if (targetIdToPid) { + for (const [id, profile] of this._cpuProfiles) { + const pid = targetIdToPid.get(id); + if (!pid) + continue; + const process = this._tracingModel.processById(pid); + const thread = process && process.threadByName(TimelineModel.TimelineModel.RendererMainThreadName); + if (thread) + this._injectCpuProfileEvent(pid, thread.id(), profile); + } + } else { + // Legacy backends support. + const mainMetaEvent = + metadataEvents.filter(event => event.name === metadataEventTypes.TracingStartedInPage).peekLast(); + if (mainMetaEvent) { + const pid = mainMetaEvent.thread.process().id(); + const mainCpuProfile = this._cpuProfiles.get(this._tracingManager.target().id()); + this._injectCpuProfileEvent(pid, mainMetaEvent.thread.id(), mainCpuProfile); + } + } const workerMetaEvents = metadataEvents.filter(event => event.name === metadataEventTypes.TracingSessionIdForWorker);
diff --git a/third_party/blink/renderer/devtools/front_end/timeline/TimelinePanel.js b/third_party/blink/renderer/devtools/front_end/timeline/TimelinePanel.js index 621e7272..29bd3d3 100644 --- a/third_party/blink/renderer/devtools/front_end/timeline/TimelinePanel.js +++ b/third_party/blink/renderer/devtools/front_end/timeline/TimelinePanel.js
@@ -498,6 +498,7 @@ this._setState(Timeline.TimelinePanel.State.StopPending); this._performanceModel = await this._controller.stopRecording(); this._setUIControlsEnabled(true); + this._controller.dispose(); this._controller = null; }
diff --git a/third_party/blink/renderer/devtools/front_end/ui/Tooltip.js b/third_party/blink/renderer/devtools/front_end/ui/Tooltip.js index ecada08..a8034a0 100644 --- a/third_party/blink/renderer/devtools/front_end/ui/Tooltip.js +++ b/third_party/blink/renderer/devtools/front_end/ui/Tooltip.js
@@ -63,7 +63,7 @@ for (const element of path) { // The offsetParent is null when the element or an ancestor has 'display: none'. - if (element === this._anchorElement || element.offsetParent === null) { + if (element === this._anchorElement || (element.nodeName !== 'CONTENT' && element.offsetParent === null)) { return; } else if (element[UI.Tooltip._symbol]) { this._show(element, mouseEvent);
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc index 416cf6f..3db93e06 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
@@ -30,6 +30,7 @@ #include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h" #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h" +#include "third_party/blink/renderer/platform/graphics/test/fake_canvas_resource_host.h" #include "third_party/blink/renderer/platform/graphics/test/fake_gles2_interface.h" #include "third_party/blink/renderer/platform/graphics/test/fake_web_graphics_context_3d_provider.h" #include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h" @@ -300,8 +301,8 @@ std::make_unique<MockImageBufferSurfaceForOverwriteTesting>( \ size, CanvasColorParams()); \ MockImageBufferSurfaceForOverwriteTesting* surface_ptr = mock_surface.get(); \ - CanvasElement().CreateCanvas2DLayerBridgeForTesting(std::move(mock_surface), \ - size); \ + CanvasElement().SetCanvas2DLayerBridgeForTesting(std::move(mock_surface), \ + size); \ EXPECT_CALL(*surface_ptr, WillOverwriteCanvas()).Times(EXPECTED_OVERDRAWS); \ Context2d()->save(); @@ -554,7 +555,7 @@ kPreferAcceleration); FakeCanvas2DLayerBridge* fake_accelerate_surface_ptr = fake_accelerate_surface.get(); - CanvasElement().CreateCanvas2DLayerBridgeForTesting( + CanvasElement().SetCanvas2DLayerBridgeForTesting( std::move(fake_accelerate_surface), size); // 800 = 10 * 10 * 4 * 2 where 10*10 is canvas size, 4 is num of bytes per // pixel per buffer, and 2 is an estimate of num of gpu buffers required @@ -584,7 +585,7 @@ IntSize size2(10, 5); auto fake_accelerate_surface2 = std::make_unique<FakeCanvas2DLayerBridge>( size2, CanvasColorParams(), kPreferAcceleration); - anotherCanvas->CreateCanvas2DLayerBridgeForTesting( + anotherCanvas->SetCanvas2DLayerBridgeForTesting( std::move(fake_accelerate_surface2), size2); EXPECT_EQ(800, GetCurrentGPUMemoryUsage()); EXPECT_EQ(1200, GetGlobalGPUMemoryUsage()); @@ -636,7 +637,7 @@ IntSize size(300, 300); std::unique_ptr<Canvas2DLayerBridge> bridge = MakeBridge(size, Canvas2DLayerBridge::kForceAccelerationForTesting); - CanvasElement().CreateCanvas2DLayerBridgeForTesting(std::move(bridge), size); + CanvasElement().SetCanvas2DLayerBridgeForTesting(std::move(bridge), size); EXPECT_TRUE(CanvasElement().GetCanvas2DLayerBridge()->IsAccelerated()); EXPECT_EQ(1u, GetGlobalAcceleratedContextCount()); @@ -697,8 +698,7 @@ IntSize size(dst_size, dst_size); std::unique_ptr<Canvas2DLayerBridge> bridge = MakeBridge(size, Canvas2DLayerBridge::kEnableAcceleration); - CanvasElement().CreateCanvas2DLayerBridgeForTesting(std::move(bridge), - size); + CanvasElement().SetCanvas2DLayerBridgeForTesting(std::move(bridge), size); EXPECT_TRUE(CanvasElement().GetCanvas2DLayerBridge()->IsAccelerated()); EXPECT_EQ(1u, GetGlobalAcceleratedContextCount()); @@ -740,11 +740,11 @@ IntSize size(10, 10); auto fake_accelerate_surface = std::make_unique<FakeCanvas2DLayerBridge>( size, CanvasColorParams(), kPreferAcceleration); - CanvasElement().CreateCanvas2DLayerBridgeForTesting( + CanvasElement().SetCanvas2DLayerBridgeForTesting( std::move(fake_accelerate_surface), size); EXPECT_TRUE(CanvasElement().GetCanvas2DLayerBridge()); - EXPECT_FALSE(CanvasElement().GetCanvas2DLayerBridge()->GetResourceProvider()); + EXPECT_FALSE(CanvasElement().ResourceProvider()); } TEST_F(CanvasRenderingContext2DTest, DisableAcceleration_UpdateGPUMemoryUsage) { @@ -753,7 +753,7 @@ IntSize size(10, 10); auto fake_accelerate_surface = std::make_unique<FakeCanvas2DLayerBridge>( size, CanvasColorParams(), kPreferAcceleration); - CanvasElement().CreateCanvas2DLayerBridgeForTesting( + CanvasElement().SetCanvas2DLayerBridgeForTesting( std::move(fake_accelerate_surface), size); CanvasRenderingContext2D* context = Context2d(); @@ -786,11 +786,14 @@ IntSize size(10, 10); auto fake_accelerate_surface = std::make_unique<FakeCanvas2DLayerBridge>( size, CanvasColorParams(), kPreferAcceleration); - CanvasElement().CreateCanvas2DLayerBridgeForTesting( + CanvasElement().SetCanvas2DLayerBridgeForTesting( std::move(fake_accelerate_surface), size); + FakeCanvasResourceHost host; auto fake_deaccelerate_surface = std::make_unique<FakeCanvas2DLayerBridge>( size, CanvasColorParams(), kPreferNoAcceleration); + fake_deaccelerate_surface->SetCanvasResourceHost(&host); + PaintCanvas* paint_canvas_ptr = fake_deaccelerate_surface->Canvas(); FakeCanvas2DLayerBridge* surface_ptr = fake_deaccelerate_surface.get(); @@ -1139,7 +1142,7 @@ MakeBridge(size, Canvas2DLayerBridge::kEnableAcceleration); // Force hibernatation to occur in an immediate task. bridge->DontUseIdleSchedulingForTesting(); - CanvasElement().CreateCanvas2DLayerBridgeForTesting(std::move(bridge), size); + CanvasElement().SetCanvas2DLayerBridgeForTesting(std::move(bridge), size); EXPECT_TRUE(CanvasElement().GetCanvas2DLayerBridge()->IsAccelerated()); // Take a snapshot to trigger lazy resource provider creation @@ -1177,7 +1180,7 @@ MakeBridge(size, Canvas2DLayerBridge::kEnableAcceleration); // Force hibernatation to occur in an immediate task. bridge->DontUseIdleSchedulingForTesting(); - CanvasElement().CreateCanvas2DLayerBridgeForTesting(std::move(bridge), size); + CanvasElement().SetCanvas2DLayerBridgeForTesting(std::move(bridge), size); EXPECT_TRUE(CanvasElement().GetCanvas2DLayerBridge()->IsAccelerated());
diff --git a/third_party/blink/renderer/modules/credentialmanager/BUILD.gn b/third_party/blink/renderer/modules/credentialmanager/BUILD.gn index 18f143a1..92c0798 100644 --- a/third_party/blink/renderer/modules/credentialmanager/BUILD.gn +++ b/third_party/blink/renderer/modules/credentialmanager/BUILD.gn
@@ -28,5 +28,7 @@ "password_credential.h", "public_key_credential.cc", "public_key_credential.h", + "scoped_promise_resolver.cc", + "scoped_promise_resolver.h", ] }
diff --git a/third_party/blink/renderer/modules/credentialmanager/cable_authentication_data.idl b/third_party/blink/renderer/modules/credentialmanager/cable_authentication_data.idl index a0e515b..c219173 100644 --- a/third_party/blink/renderer/modules/credentialmanager/cable_authentication_data.idl +++ b/third_party/blink/renderer/modules/credentialmanager/cable_authentication_data.idl
@@ -3,7 +3,7 @@ // found in the LICENSE file. dictionary CableAuthenticationData { - required long version; + required octet version; required BufferSource clientEid; required BufferSource authenticatorEid; required BufferSource sessionPreKey;
diff --git a/third_party/blink/renderer/modules/credentialmanager/cable_registration_data.idl b/third_party/blink/renderer/modules/credentialmanager/cable_registration_data.idl index 8dfd668d..0aee556e 100644 --- a/third_party/blink/renderer/modules/credentialmanager/cable_registration_data.idl +++ b/third_party/blink/renderer/modules/credentialmanager/cable_registration_data.idl
@@ -3,6 +3,6 @@ // found in the LICENSE file. dictionary CableRegistrationData { - required sequence<long> versions; + required sequence<octet> versions; required BufferSource rpPublicKey; -}; \ No newline at end of file +};
diff --git a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc index b4fff62..d137963 100644 --- a/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc +++ b/third_party/blink/renderer/modules/credentialmanager/credentials_container.cc
@@ -33,6 +33,7 @@ #include "third_party/blink/renderer/modules/credentialmanager/public_key_credential.h" #include "third_party/blink/renderer/modules/credentialmanager/public_key_credential_creation_options.h" #include "third_party/blink/renderer/modules/credentialmanager/public_key_credential_request_options.h" +#include "third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h" #include "third_party/blink/renderer/platform/weborigin/origin_access_entry.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h" #include "third_party/blink/renderer/platform/wtf/functional.h" @@ -55,41 +56,6 @@ enum class RequiredOriginType { kSecure, kSecureAndSameWithAncestors }; -// Off-heap wrapper that holds a strong reference to a ScriptPromiseResolver. -class ScopedPromiseResolver { - WTF_MAKE_NONCOPYABLE(ScopedPromiseResolver); - - public: - explicit ScopedPromiseResolver(ScriptPromiseResolver* resolver) - : resolver_(resolver) {} - - ~ScopedPromiseResolver() { - if (resolver_) - OnConnectionError(); - } - - // Releases the owned |resolver_|. This is to be called by the Mojo response - // callback responsible for resolving the corresponding ScriptPromise - // - // If this method is not called before |this| goes of scope, it is assumed - // that a Mojo connection error has occurred, and the response callback was - // never invoked. The Promise will be rejected with an appropriate exception. - ScriptPromiseResolver* Release() { return resolver_.Release(); } - - private: - void OnConnectionError() { - // The only anticapted reason for a connection error is that the embedder - // does not implement mojom::CredentialManager, or mojom::AuthenticatorImpl, - // so go out on a limb and try to provide an actionable error message. - resolver_->Reject(DOMException::Create( - kNotSupportedError, - "The user agent either does not implement a password store or does " - "not support public key credentials.")); - } - - Persistent<ScriptPromiseResolver> resolver_; -}; - bool IsSameOriginWithAncestors(const Frame* frame) { DCHECK(frame); const Frame* current = frame; @@ -405,7 +371,7 @@ DOMArrayBuffer* user_handle = credential->user_handle ? VectorToDOMArrayBuffer(std::move(*credential->user_handle)) - : DOMArrayBuffer::Create(nullptr, 0); + : nullptr; AuthenticatorAssertionResponse* authenticator_response = AuthenticatorAssertionResponse::Create(client_data_buffer, authenticator_buffer,
diff --git a/third_party/blink/renderer/modules/credentialmanager/public_key_credential.cc b/third_party/blink/renderer/modules/credentialmanager/public_key_credential.cc index e4a5d1c..465530406 100644 --- a/third_party/blink/renderer/modules/credentialmanager/public_key_credential.cc +++ b/third_party/blink/renderer/modules/credentialmanager/public_key_credential.cc
@@ -8,6 +8,8 @@ #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/dom/exception_code.h" +#include "third_party/blink/renderer/modules/credentialmanager/credential_manager_proxy.h" +#include "third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" namespace blink { @@ -15,6 +17,12 @@ namespace { // https://www.w3.org/TR/webauthn/#dom-publickeycredential-type-slot: constexpr char kPublicKeyCredentialType[] = "public-key"; + +void OnIsUserVerifyingComplete( + std::unique_ptr<ScopedPromiseResolver> scoped_resolver, + bool available) { + scoped_resolver->Release()->Resolve(available); +} } // namespace PublicKeyCredential* PublicKeyCredential::Create( @@ -38,9 +46,23 @@ ScriptPromise PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable( ScriptState* script_state) { - return ScriptPromise::RejectWithDOMException( - script_state, - DOMException::Create(kNotSupportedError, "Operation not implemented.")); + ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); + ScriptPromise promise = resolver->Promise(); + + // Ignore calls if the current realm execution context is no longer valid, + // e.g., because the responsible document was detached. + DCHECK(resolver->GetExecutionContext()); + if (resolver->GetExecutionContext()->IsContextDestroyed()) { + resolver->Reject(); + return promise; + } + + auto* authenticator = + CredentialManagerProxy::From(script_state)->Authenticator(); + authenticator->IsUserVerifyingPlatformAuthenticatorAvailable(WTF::Bind( + &OnIsUserVerifyingComplete, + WTF::Passed(std::make_unique<ScopedPromiseResolver>(resolver)))); + return promise; } void PublicKeyCredential::getClientExtensionResults(
diff --git a/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.cc b/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.cc new file mode 100644 index 0000000..1284d25 --- /dev/null +++ b/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.cc
@@ -0,0 +1,31 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h" + +#include "third_party/blink/renderer/core/dom/dom_exception.h" + +namespace blink { + +ScopedPromiseResolver::ScopedPromiseResolver(ScriptPromiseResolver* resolver) + : resolver_(resolver) {} + +ScopedPromiseResolver::~ScopedPromiseResolver() { + if (resolver_) + OnConnectionError(); +} + +ScriptPromiseResolver* ScopedPromiseResolver::Release() { + return resolver_.Release(); +} + +void ScopedPromiseResolver::OnConnectionError() { + // The only anticipated reason for a connection error is that the embedder + // does not implement mojom::AuthenticatorImpl. + resolver_->Reject(DOMException::Create( + kNotSupportedError, + "The user agent does not support public key credentials.")); +} + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h b/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h new file mode 100644 index 0000000..ae5efcf --- /dev/null +++ b/third_party/blink/renderer/modules/credentialmanager/scoped_promise_resolver.h
@@ -0,0 +1,38 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGER_SCOPED_PROMISE_RESOLVER_H_ +#define THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGER_SCOPED_PROMISE_RESOLVER_H_ + +#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" +#include "third_party/blink/renderer/platform/wtf/functional.h" + +namespace blink { + +// Off-heap wrapper that holds a strong reference to a ScriptPromiseResolver. +class ScopedPromiseResolver { + WTF_MAKE_NONCOPYABLE(ScopedPromiseResolver); + + public: + explicit ScopedPromiseResolver(ScriptPromiseResolver* resolver); + + ~ScopedPromiseResolver(); + + // Releases the owned |resolver_|. This is to be called by the Mojo response + // callback responsible for resolving the corresponding ScriptPromise + // + // If this method is not called before |this| goes of scope, it is assumed + // that a Mojo connection error has occurred, and the response callback was + // never invoked. The Promise will be rejected with an appropriate exception. + ScriptPromiseResolver* Release(); + + private: + void OnConnectionError(); + + Persistent<ScriptPromiseResolver> resolver_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_CREDENTIALMANAGER_SCOPED_PROMISE_RESOLVER_H_
diff --git a/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc b/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc index e55344af..d5dfcab 100644 --- a/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc +++ b/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.cc
@@ -72,8 +72,6 @@ DCHECK(index < device::Gamepads::kItemsLengthCap); DCHECK_EQ(connected, gamepad.connected); - latest_change_.pad = gamepad; - latest_change_.index = index; NotifyControllers(); }
diff --git a/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.h b/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.h index 686096c..3c0121a 100644 --- a/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.h +++ b/third_party/blink/renderer/modules/gamepad/gamepad_dispatcher.h
@@ -34,16 +34,6 @@ device::mojom::blink::GamepadHapticsManager:: ResetVibrationActuatorCallback); - struct ConnectionChange { - DISALLOW_NEW(); - device::Gamepad pad; - unsigned index; - }; - - const ConnectionChange& LatestConnectionChange() const { - return latest_change_; - } - void Trace(blink::Visitor*) override; private: @@ -63,8 +53,6 @@ const device::Gamepad&, bool connected); - ConnectionChange latest_change_; - device::mojom::blink::GamepadHapticsManagerPtr gamepad_haptics_manager_; };
diff --git a/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.cc b/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.cc index 8348f62..37e3b1b 100644 --- a/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.cc +++ b/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.cc
@@ -11,6 +11,7 @@ #include "third_party/blink/renderer/core/html/html_div_element.h" #include "third_party/blink/renderer/core/html/html_style_element.h" #include "third_party/blink/renderer/core/html/media/html_media_element.h" +#include "third_party/blink/renderer/core/html/media/html_video_element.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/modules/media_controls/elements/media_control_elements_helper.h" #include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h" @@ -19,7 +20,9 @@ namespace { static const char kAnimationIterationCountName[] = "animation-iteration-count"; +static const char kClassAttributeName[] = "class"; static const char kInfinite[] = "infinite"; +static const char kNoFrameAvailableSpinnerClass[] = "dark"; } // namespace @@ -45,6 +48,11 @@ // | | +- #spinner-mask-1-background // \ +- #spinner-mask-2 // +- #spinner-mask-2-background +// +- #cutoff-1 +// +- #cutoff-2 +// +- #cutoff-3 +// +- #cutoff-4 +// +- #fake-timeline void MediaControlLoadingPanelElement::PopulateShadowDOM() { ShadowRoot* shadow_root = GetShadowRoot(); DCHECK(!shadow_root->HasChildren()); @@ -66,12 +74,13 @@ // The spinner is responsible for rotating the elements below. The square // edges will be cut off by the frame above. - HTMLDivElement* spinner = + spinner_ = MediaControlElementsHelper::CreateDivWithId("spinner", spinner_frame); + SetSpinnerClassIfNecessary(); // The layer performs a secondary "fill-unfill-rotate" animation. HTMLDivElement* layer = - MediaControlElementsHelper::CreateDivWithId("layer", spinner); + MediaControlElementsHelper::CreateDivWithId("layer", spinner_); // The spinner is split into two halves, one on the left (1) and the other // on the right (2). The mask elements stop the background from overlapping @@ -90,6 +99,18 @@ "spinner-mask-2-background", mask2); event_listener_ = new MediaControlAnimationEventListener(this); + + // The four cutoffs are responsible for filling the background of the loading + // panel with white, whilst leaving a small box in the middle that is + // transparent. This is where the spinner will be. + MediaControlElementsHelper::CreateDivWithId("cutoff-1", shadow_root); + MediaControlElementsHelper::CreateDivWithId("cutoff-2", shadow_root); + MediaControlElementsHelper::CreateDivWithId("cutoff-3", shadow_root); + MediaControlElementsHelper::CreateDivWithId("cutoff-4", shadow_root); + + // The fake timeline creates a fake bar at the bottom to look like the + // timeline. + MediaControlElementsHelper::CreateDivWithId("fake-timeline", shadow_root); } void MediaControlLoadingPanelElement::RemovedFrom( @@ -112,6 +133,7 @@ } shadow_root->RemoveChildren(); + spinner_.Clear(); mask1_background_.Clear(); mask2_background_.Clear(); } @@ -199,6 +221,24 @@ void MediaControlLoadingPanelElement::OnAnimationIteration() { animation_count_ += 1; + SetSpinnerClassIfNecessary(); +} + +void MediaControlLoadingPanelElement::SetSpinnerClassIfNecessary() { + if (!spinner_) + return; + + HTMLVideoElement& video_element = + static_cast<HTMLVideoElement&>(MediaElement()); + if (!video_element.ShouldDisplayPosterImage() && + !video_element.HasAvailableVideoFrame()) { + if (!spinner_->hasAttribute(kClassAttributeName)) { + spinner_->setAttribute(kClassAttributeName, + kNoFrameAvailableSpinnerClass); + } + } else { + spinner_->removeAttribute(kClassAttributeName); + } } Element& MediaControlLoadingPanelElement::WatchedAnimationElement() const { @@ -210,6 +250,7 @@ MediaControlAnimationEventListener::Observer::Trace(visitor); MediaControlDivElement::Trace(visitor); visitor->Trace(event_listener_); + visitor->Trace(spinner_); visitor->Trace(mask1_background_); visitor->Trace(mask2_background_); }
diff --git a/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.h b/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.h index 15b30a4..9f9ef1d 100644 --- a/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.h +++ b/third_party/blink/renderer/modules/media_controls/elements/media_control_loading_panel_element.h
@@ -63,6 +63,10 @@ // background elements. void SetAnimationIterationCount(const String&); + // Sets the background color of the spinner to black if there is no poster + // image or video frame available. + void SetSpinnerClassIfNecessary(); + // The loading panel is only used once and has a lot of DOM elements so these // two functions will populate the shadow DOM or clean it if the panel is // hidden. @@ -81,6 +85,7 @@ bool controls_hidden_ = false; Member<MediaControlAnimationEventListener> event_listener_; + Member<HTMLDivElement> spinner_; Member<HTMLDivElement> mask1_background_; Member<HTMLDivElement> mask2_background_; };
diff --git a/third_party/blink/renderer/modules/media_controls/media_controls_orientation_lock_delegate_test.cc b/third_party/blink/renderer/modules/media_controls/media_controls_orientation_lock_delegate_test.cc index edc8fb5..b591afc 100644 --- a/third_party/blink/renderer/modules/media_controls/media_controls_orientation_lock_delegate_test.cc +++ b/third_party/blink/renderer/modules/media_controls/media_controls_orientation_lock_delegate_test.cc
@@ -88,13 +88,13 @@ void DidEnterFullscreen(Document* document) { DCHECK(document); - Fullscreen::From(*document).DidEnterFullscreen(); + Fullscreen::DidEnterFullscreen(*document); document->ServiceScriptedAnimations(WTF::CurrentTimeTicks()); } void DidExitFullscreen(Document* document) { DCHECK(document); - Fullscreen::From(*document).DidExitFullscreen(); + Fullscreen::DidExitFullscreen(*document); document->ServiceScriptedAnimations(WTF::CurrentTimeTicks()); }
diff --git a/third_party/blink/renderer/modules/media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc b/third_party/blink/renderer/modules/media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc index 4923cac..af29328 100644 --- a/third_party/blink/renderer/modules/media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc +++ b/third_party/blink/renderer/modules/media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc
@@ -62,10 +62,10 @@ std::move(screen_orientation)); } void EnterFullscreen(LocalFrame& frame, const FullscreenOptions&) override { - Fullscreen::From(*frame.GetDocument()).DidEnterFullscreen(); + Fullscreen::DidEnterFullscreen(*frame.GetDocument()); } void ExitFullscreen(LocalFrame& frame) override { - Fullscreen::From(*frame.GetDocument()).DidExitFullscreen(); + Fullscreen::DidExitFullscreen(*frame.GetDocument()); } MOCK_CONST_METHOD0(GetScreenInfo, WebScreenInfo());
diff --git a/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_1.svg b/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_1.svg index 03a1b04..bbbde1e 100644 --- a/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_1.svg +++ b/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_1.svg
@@ -2,7 +2,10 @@ <!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 196 196" style="enable-background:new 0 0 196 196;" xml:space="preserve"> -<path class="st0" d="M98,49v4c-24.9,0-45,20.1-45,45 +<style type="text/css"> + .st0{fill:#FFFFFF;} +</style> +<path class="st0" d="M0,0l0,49l0,98l0,49h49h98h49v-49V49V0l-49,0L49,0L0,0z M98,49v4c-24.9,0-45,20.1-45,45 c0,18,10.6,33.6,25.9,40.8l-1.7,3.6c0.1,0,0.2,0.1,0.3,0.1c-0.1,0-0.2-0.1-0.3-0.1l0,0C60.5,134.5,49,117.6,49,98 C49,70.9,70.9,49,98,49z"/> </svg>
diff --git a/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_2.svg b/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_2.svg index a8763b0..380e62d4f 100644 --- a/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_2.svg +++ b/third_party/blink/renderer/modules/media_controls/resources/default_100_percent/modern/loading_mask_2.svg
@@ -2,6 +2,9 @@ <!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 196 196" style="enable-background:new 0 0 196 196;" xml:space="preserve"> -<path class="st0" d="M147,98c0,19.6-11.5,36.5-28.2,44.4l0,0c-0.1,0-0.2,0.1-0.3,0.1 +<style type="text/css"> + .st0{fill:#FFFFFF;enable-background:new ;} +</style> +<path class="st0" d="M147,0H49H0v49v98v49h49h98h49v-49V49V0H147z M147,98c0,19.6-11.5,36.5-28.2,44.4l0,0c-0.1,0-0.2,0.1-0.3,0.1 c0.1,0,0.2-0.1,0.3-0.1l-1.7-3.6C132.4,131.6,143,116,143,98c0-24.9-20.1-45-45-45v-4C125.1,49,147,70.9,147,98z"/> </svg>
diff --git a/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls.css b/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls.css index 16549ba..2cd56fb 100644 --- a/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls.css +++ b/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls.css
@@ -685,8 +685,7 @@ right: 0; bottom: 0; overflow: hidden; - z-index: 1; - pointer-events: none; + opacity: .5; } audio::-internal-media-controls-loading-panel, @@ -694,6 +693,16 @@ display: none; } +.state-loading-metadata div[pseudo="-webkit-media-controls-panel" i] { + background-image: none; +} + +.state-loading-metadata div[pseudo="-internal-media-controls-button-panel" i], +.state-loading-metadata input[pseudo="-webkit-media-controls-timeline" i], +.state-loading-metadata input[pseudo="-webkit-media-controls-overlay-play-button" i]::-internal-media-controls-overlay-play-button-internal { + opacity: 0; +} + /** * Text Tracks */
diff --git a/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls_loading.css b/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls_loading.css index b5cdfed..e9f59a6 100644 --- a/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls_loading.css +++ b/third_party/blink/renderer/modules/media_controls/resources/modernMediaControls_loading.css
@@ -19,6 +19,10 @@ width: 100%; } +#spinner.dark { + background-color: black; +} + #spinner:after { position: absolute; content: ' '; @@ -26,6 +30,9 @@ left: -25%; width: 150%; height: 150%; + background-image: -webkit-image-set( + url(default_100_percent/modern/loading_mask_overlay.svg) 1x); + background-position: center; } #spinner:before { @@ -35,6 +42,7 @@ left: 2px; right: 2px; bottom: 2px; + background: white; border-radius: 100%; } @@ -120,3 +128,57 @@ 50% { transform: rotate(-30deg) } to { transform: rotate(-155deg) } } + +#cutoff-1, +#cutoff-2, +#cutoff-3, +#cutoff-4 { + position: absolute; + background: white; +} + +#cutoff-1, +#cutoff-2 { + left: 0; + right: 0; +} + +#cutoff-1 { + top: 0; + bottom: 50%; + margin-bottom: 37px; +} + +#cutoff-2 { + top: 50%; + bottom: 16px; + margin-top: 19px; +} + +#cutoff-3, +#cutoff-4 { + top: 0; + bottom: 16px; +} + +#cutoff-3 { + left: 0; + right: 50%; + margin-right: 28px; +} + +#cutoff-4 { + left: 50%; + right: 0; + margin-left: 28px; +} + +#fake-timeline { + bottom: 0; + position: absolute; + left: 0; + right: 0; + border: solid white; + border-width: 0 16px 12px; + height: 4px; +}
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn index 90fcfc6..917d166 100644 --- a/third_party/blink/renderer/platform/BUILD.gn +++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -140,8 +140,6 @@ ] configs += [ "//third_party/blink/renderer:config" ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", "//third_party/icu", @@ -1973,7 +1971,6 @@ deps = [ ":platform", - "//build/config:exe_and_shlib_deps", "//mojo/edk", "//third_party/blink/renderer/platform/wtf", ]
diff --git a/third_party/blink/renderer/platform/geometry/layout_rect_outsets.cc b/third_party/blink/renderer/platform/geometry/layout_rect_outsets.cc index 2a4a35e..8c14be5d 100644 --- a/third_party/blink/renderer/platform/geometry/layout_rect_outsets.cc +++ b/third_party/blink/renderer/platform/geometry/layout_rect_outsets.cc
@@ -32,6 +32,7 @@ #include <algorithm> #include "third_party/blink/renderer/platform/wtf/assertions.h" +#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { @@ -49,4 +50,16 @@ left_ = std::max(left_, other.left_); } +std::ostream& operator<<(std::ostream& ostream, + const LayoutRectOutsets& outsets) { + return ostream << outsets.ToString(); +} + +String LayoutRectOutsets::ToString() const { + return String::Format( + "top %s; right %s; bottom %s; left %s", Top().ToString().Ascii().data(), + Right().ToString().Ascii().data(), Bottom().ToString().Ascii().data(), + Left().ToString().Ascii().data()); +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/geometry/layout_rect_outsets.h b/third_party/blink/renderer/platform/geometry/layout_rect_outsets.h index e25a64b8..6086d2c 100644 --- a/third_party/blink/renderer/platform/geometry/layout_rect_outsets.h +++ b/third_party/blink/renderer/platform/geometry/layout_rect_outsets.h
@@ -97,6 +97,8 @@ Bottom() == other.Bottom() && Left() == other.Left(); } + String ToString() const; + private: LayoutUnit top_; LayoutUnit right_; @@ -145,6 +147,9 @@ LayoutUnit::FromFloatCeil(rect.Left())); } +PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, + const LayoutRectOutsets&); + } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GEOMETRY_LAYOUT_RECT_OUTSETS_H_
diff --git a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.cc b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.cc index f03d90e..2c8431474 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.cc +++ b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.cc
@@ -85,13 +85,12 @@ // Clear the background transparent or opaque. Similar code at // CanvasResourceProvider::Clear(). if (IsValid()) { - DCHECK(!resource_provider_); DCHECK(recorder_); recorder_->getRecordingCanvas()->clear( color_params_.GetOpacityMode() == kOpaque ? SK_ColorBLACK : SK_ColorTRANSPARENT); + DidDraw(FloatRect(FloatPoint(0, 0), FloatSize(size_))); } - DidDraw(FloatRect(FloatPoint(0, 0), FloatSize(size_))); } Canvas2DLayerBridge::~Canvas2DLayerBridge() { @@ -137,7 +136,9 @@ } void Canvas2DLayerBridge::ResetResourceProvider() { - resource_provider_.reset(); + if (resource_host_) { + resource_host_->ReplaceResourceProvider(nullptr); + } } bool Canvas2DLayerBridge::ShouldAccelerate(AccelerationHint hint) const { @@ -170,8 +171,8 @@ return false; if (software_rendering_while_hidden_) return false; - if (resource_provider_) - return resource_provider_->IsAccelerated(); + if (resource_host_ && resource_host_->ResourceProvider()) + return resource_host_->ResourceProvider()->IsAccelerated(); // Whether or not to accelerate is not yet resolved. Determine whether // immediate presentation of the canvas would result in the canvas being @@ -203,7 +204,7 @@ hibernation_scheduled_ = false; - if (!resource_provider_) { + if (!resource_host_ || !resource_host_->ResourceProvider()) { logger_->ReportHibernationEvent(kHibernationAbortedBecauseNoSurface); return; } @@ -242,7 +243,8 @@ DCHECK(!have_recorded_draw_commands_); SkPaint copy_paint; copy_paint.setBlendMode(SkBlendMode::kSrc); - scoped_refptr<StaticBitmapImage> snapshot = resource_provider_->Snapshot(); + scoped_refptr<StaticBitmapImage> snapshot = + resource_host_->ResourceProvider()->Snapshot(); temp_hibernation_surface->getCanvas()->drawImage( snapshot->PaintImageForCurrentFrame().GetSkImage(), 0, 0, ©_paint); hibernation_image_ = temp_hibernation_surface->makeImageSnapshot(); @@ -266,15 +268,22 @@ } } +CanvasResourceProvider* Canvas2DLayerBridge::ResourceProvider() const { + return resource_host_ ? resource_host_->ResourceProvider() : nullptr; +} + CanvasResourceProvider* Canvas2DLayerBridge::GetOrCreateResourceProvider( AccelerationHint hint) { + DCHECK(resource_host_); + CanvasResourceProvider* resource_provider = ResourceProvider(); + if (context_lost_) { - DCHECK(!resource_provider_); + DCHECK(!resource_provider); return nullptr; } - if (resource_provider_) - return resource_provider_.get(); + if (resource_provider) + return resource_provider; if (layer_ && !IsHibernating() && hint == kPreferAcceleration && acceleration_mode_ != kDisableAcceleration) { @@ -293,21 +302,22 @@ ? CanvasResourceProvider::kAcceleratedCompositedResourceUsage : CanvasResourceProvider::kSoftwareCompositedResourceUsage; - resource_provider_ = CanvasResourceProvider::Create( + resource_host_->ReplaceResourceProvider(CanvasResourceProvider::Create( size_, usage, SharedGpuContext::ContextProviderWrapper(), - msaa_sample_count_, color_params_); + msaa_sample_count_, color_params_)); + resource_provider = resource_host_->ResourceProvider(); - if (resource_provider_) { + if (resource_provider) { // Always save an initial frame, to support resetting the top level matrix // and clip. - resource_provider_->Canvas()->save(); - resource_provider_->SetFilterQuality(filter_quality_); - resource_provider_->SetResourceRecyclingEnabled(!IsHidden()); + resource_provider->Canvas()->save(); + resource_provider->SetFilterQuality(filter_quality_); + resource_provider->SetResourceRecyclingEnabled(!IsHidden()); } else { ReportResourceProviderCreationFailure(); } - if (resource_provider_ && resource_provider_->IsAccelerated() && !layer_) { + if (resource_provider && resource_provider->IsAccelerated() && !layer_) { layer_ = cc::TextureLayer::CreateForMailbox(this); layer_->SetIsDrawable(true); layer_->SetContentsOpaque(ColorParams().GetOpacityMode() == kOpaque); @@ -316,8 +326,8 @@ GraphicsLayer::RegisterContentsLayer(layer_.get()); } - if (resource_provider_ && IsHibernating()) { - if (resource_provider_->IsAccelerated()) { + if (resource_provider && IsHibernating()) { + if (resource_provider->IsAccelerated()) { logger_->ReportHibernationEvent(kHibernationEndedNormally); } else { if (IsHidden()) { @@ -333,16 +343,14 @@ PaintImageBuilder builder = PaintImageBuilder::WithDefault(); builder.set_image(hibernation_image_, PaintImage::GetNextContentId()); builder.set_id(PaintImage::GetNextId()); - resource_provider_->Canvas()->drawImage(builder.TakePaintImage(), 0, 0, - ©_paint); + resource_provider->Canvas()->drawImage(builder.TakePaintImage(), 0, 0, + ©_paint); hibernation_image_.reset(); if (resource_host_) { - resource_host_->UpdateMemoryUsage(); - if (!is_deferral_enabled_) { resource_host_->RestoreCanvasMatrixClipStack( - resource_provider_->Canvas()); + resource_provider->Canvas()); } // shouldBeDirectComposited() may have changed. @@ -350,13 +358,15 @@ } } - return resource_provider_.get(); + return resource_provider; } PaintCanvas* Canvas2DLayerBridge::Canvas() { + DCHECK(resource_host_); if (!is_deferral_enabled_) { - GetOrCreateResourceProvider(); - return resource_provider_ ? resource_provider_->Canvas() : nullptr; + if (GetOrCreateResourceProvider()) + return resource_host_->ResourceProvider()->Canvas(); + return nullptr; } return recorder_->getRecordingCanvas(); } @@ -371,7 +381,7 @@ // required multiple times per frame, the repeated flushing of deferred // commands would cause significant overhead, so it is better to just stop // trying to defer altogether. - if (!is_deferral_enabled_) + if (!is_deferral_enabled_ || !resource_host_) return; DEFINE_STATIC_LOCAL(EnumerationHistogram, gpu_disabled_histogram, @@ -388,15 +398,14 @@ is_deferral_enabled_ = false; recorder_.reset(); // install the current matrix/clip stack onto the immediate canvas - GetOrCreateResourceProvider(); - if (resource_host_ && resource_provider_) - resource_host_->RestoreCanvasMatrixClipStack(resource_provider_->Canvas()); + if (GetOrCreateResourceProvider()) + resource_host_->RestoreCanvasMatrixClipStack(ResourceProvider()->Canvas()); } void Canvas2DLayerBridge::SetFilterQuality(SkFilterQuality filter_quality) { filter_quality_ = filter_quality; - if (resource_provider_) - resource_provider_->SetFilterQuality(filter_quality); + if (ResourceProvider()) + ResourceProvider()->SetFilterQuality(filter_quality); if (layer_) layer_->SetNearestNeighbor(filter_quality == kNone_SkFilterQuality); } @@ -406,10 +415,10 @@ return; is_hidden_ = hidden; - if (resource_provider_) - resource_provider_->SetResourceRecyclingEnabled(!IsHidden()); + if (ResourceProvider()) + ResourceProvider()->SetResourceRecyclingEnabled(!IsHidden()); - if (CANVAS2D_HIBERNATION_ENABLED && resource_provider_ && IsHidden() && + if (CANVAS2D_HIBERNATION_ENABLED && ResourceProvider() && IsHidden() && !hibernation_scheduled_) { if (layer_) layer_->ClearTexture(); @@ -431,25 +440,24 @@ copy_paint.setBlendMode(SkBlendMode::kSrc); std::unique_ptr<CanvasResourceProvider> old_resource_provider = - std::move(resource_provider_); - ResetResourceProvider(); + resource_host_->ReplaceResourceProvider(nullptr); software_rendering_while_hidden_ = false; GetOrCreateResourceProvider(kPreferAccelerationAfterVisibilityChange); - if (resource_provider_) { + if (ResourceProvider()) { if (old_resource_provider) { cc::PaintImage snapshot = old_resource_provider->Snapshot()->PaintImageForCurrentFrame(); - resource_provider_->Canvas()->drawImage(snapshot, 0, 0, ©_paint); + ResourceProvider()->Canvas()->drawImage(snapshot, 0, 0, ©_paint); } if (resource_host_ && !is_deferral_enabled_) { resource_host_->RestoreCanvasMatrixClipStack( - resource_provider_->Canvas()); + ResourceProvider()->Canvas()); } } else { // New resource provider could not be created. Stay with old one. - resource_provider_ = std::move(old_resource_provider); + resource_host_->ReplaceResourceProvider(std::move(old_resource_provider)); } } if (!IsHidden() && IsHibernating()) { @@ -527,8 +535,8 @@ return true; if (context_lost_) return false; - if (resource_provider_ && resource_provider_->IsAccelerated() && - resource_provider_->IsGpuContextLost()) { + if (ResourceProvider() && ResourceProvider()->IsAccelerated() && + ResourceProvider()->IsGpuContextLost()) { context_lost_ = true; ResetResourceProvider(); if (resource_host_) @@ -537,16 +545,14 @@ CanvasMetrics::kAccelerated2DCanvasGPUContextLost); return false; } - if (!GetOrCreateResourceProvider()) - return false; - return resource_provider_.get(); + return !!GetOrCreateResourceProvider(); } bool Canvas2DLayerBridge::Restore() { DCHECK(context_lost_); if (!IsAccelerated()) return false; - DCHECK(!resource_provider_); + DCHECK(!ResourceProvider()); gpu::gles2::GLES2Interface* shared_gl = nullptr; layer_->ClearTexture(); @@ -570,7 +576,7 @@ // which can only happen at specific times during the document lifecycle. // Therefore, we can only accept the restored surface if it is accelerated. if (resource_provider && resource_provider->IsAccelerated()) { - resource_provider_ = std::move(resource_provider); + resource_host_->ReplaceResourceProvider(std::move(resource_provider)); // FIXME: draw sad canvas picture into new buffer crbug.com/243842 } context_lost_ = false; @@ -579,7 +585,7 @@ if (resource_host_) resource_host_->UpdateMemoryUsage(); - return resource_provider_.get(); + return ResourceProvider(); } bool Canvas2DLayerBridge::PrepareTransferableResource( @@ -609,7 +615,7 @@ return false; FlushRecording(); - scoped_refptr<CanvasResource> frame = resource_provider_->ProduceFrame(); + scoped_refptr<CanvasResource> frame = ResourceProvider()->ProduceFrame(); if (frame && frame->IsValid()) { // Note frame is kept alive via a reference kept in out_release_callback. bool success =
diff --git a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.h b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.h index 14f098e..6ab0eba 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.h +++ b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge.h
@@ -58,7 +58,6 @@ namespace blink { class Canvas2DLayerBridgeTest; -class CanvasResourceProvider; class SharedContextRateLimiter; class StaticBitmapImage; @@ -163,16 +162,14 @@ }; void SetLoggerForTesting(std::unique_ptr<Logger>); - CanvasResourceProvider* GetResourceProvider() const { - return resource_provider_.get(); - } CanvasResourceProvider* GetOrCreateResourceProvider( AccelerationHint = kPreferAcceleration); - void ResetResourceProvider(); + CanvasResourceProvider* ResourceProvider() const; private: bool IsHidden() { return is_hidden_; } bool CheckResourceProviderValid(); + void ResetResourceProvider(); void StartRecording(); void SkipQueuedDrawCommands(); @@ -181,7 +178,6 @@ bool ShouldAccelerate(AccelerationHint) const; - std::unique_ptr<CanvasResourceProvider> resource_provider_; std::unique_ptr<PaintRecorder> recorder_; sk_sp<SkImage> hibernation_image_; scoped_refptr<cc::TextureLayer> layer_;
diff --git a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge_test.cc b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge_test.cc index 745135b..92f0dd6ff 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge_test.cc +++ b/third_party/blink/renderer/platform/graphics/canvas_2d_layer_bridge_test.cc
@@ -1303,7 +1303,7 @@ bridge->Canvas()->drawImage(images[0].paint_image(), 0u, 0u, nullptr); // Lose the context and ensure that the image provider is not used. - bridge->GetResourceProvider()->OnContextDestroyed(); + bridge->ResourceProvider()->OnContextDestroyed(); // We should unref all images on the cache when the context is destroyed. EXPECT_EQ(image_decode_cache_.num_locked_images(), 0); image_decode_cache_.set_disallow_cache_use(true);
diff --git a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc index ad8322a..aa5378b 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_color_params.cc +++ b/third_party/blink/renderer/platform/graphics/canvas_color_params.cc
@@ -43,32 +43,36 @@ pixel_format_(pixel_format), opacity_mode_(opacity_mode) {} -CanvasColorParams::CanvasColorParams(const SkImageInfo& info) { +CanvasColorParams::CanvasColorParams(const sk_sp<SkColorSpace> color_space, + SkColorType color_type) { color_space_ = kSRGBCanvasColorSpace; pixel_format_ = kRGBA8CanvasPixelFormat; // When there is no color space information, the SkImage is in legacy mode and // the color type is kN32_SkColorType (which translates to kRGBA8 canvas pixel // format). - if (!info.colorSpace()) + if (!color_space) return; // kSRGBCanvasColorSpace covers sRGB and linear-rgb. We need to check for // Rec2020 and P3. if (SkColorSpace::Equals( - info.colorSpace(), + color_space.get(), SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, SkColorSpace::kRec2020_Gamut) .get())) color_space_ = kRec2020CanvasColorSpace; else if (SkColorSpace::Equals( - info.colorSpace(), + color_space.get(), SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, SkColorSpace::kDCIP3_D65_Gamut) .get())) color_space_ = kP3CanvasColorSpace; - if (info.colorType() == kRGBA_F16_SkColorType) + if (color_type == kRGBA_F16_SkColorType) pixel_format_ = kF16CanvasPixelFormat; } +CanvasColorParams::CanvasColorParams(const SkImageInfo& info) + : CanvasColorParams(info.refColorSpace(), info.colorType()) {} + void CanvasColorParams::SetCanvasColorSpace(CanvasColorSpace color_space) { color_space_ = color_space; }
diff --git a/third_party/blink/renderer/platform/graphics/canvas_color_params.h b/third_party/blink/renderer/platform/graphics/canvas_color_params.h index f3d91d4..419b903 100644 --- a/third_party/blink/renderer/platform/graphics/canvas_color_params.h +++ b/third_party/blink/renderer/platform/graphics/canvas_color_params.h
@@ -41,6 +41,8 @@ // The default constructor will create an output-blended 8-bit surface. CanvasColorParams(); CanvasColorParams(CanvasColorSpace, CanvasPixelFormat, OpacityMode); + explicit CanvasColorParams(const sk_sp<SkColorSpace> color_space, + SkColorType color_type); explicit CanvasColorParams(const SkImageInfo&); CanvasColorSpace ColorSpace() const { return color_space_; } CanvasPixelFormat PixelFormat() const { return pixel_format_; }
diff --git a/third_party/blink/renderer/platform/graphics/color_correction_test_utils.cc b/third_party/blink/renderer/platform/graphics/color_correction_test_utils.cc index bd0d4c5..f6c12cf 100644 --- a/third_party/blink/renderer/platform/graphics/color_correction_test_utils.cc +++ b/third_party/blink/renderer/platform/graphics/color_correction_test_utils.cc
@@ -191,4 +191,103 @@ return conversion_result; } +bool ColorCorrectionTestUtils::MatchColorSpace( + SkColorSpace* src_color_space, + SkColorSpace* dst_color_space, + float xyz_d50_component_tolerance) { + if ((!src_color_space && dst_color_space) || + (src_color_space && !dst_color_space)) + return false; + if (src_color_space) { + const SkMatrix44* src_matrix = src_color_space->toXYZD50(); + const SkMatrix44* dst_matrix = dst_color_space->toXYZD50(); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + if (fabs(src_matrix->get(i, j) - dst_matrix->get(i, j)) > + xyz_d50_component_tolerance) { + return false; + } + } + } + } + return true; +} + +bool ColorCorrectionTestUtils::MatchSkImages(sk_sp<SkImage> src_image, + sk_sp<SkImage> dst_image, + unsigned uint8_tolerance, + float f16_tolerance, + float xyz_d50_component_tolerance, + bool compare_alpha) { + if ((!src_image && dst_image) || (src_image && !dst_image)) + return false; + if (!src_image) + return true; + if ((src_image->width() != dst_image->width()) || + (src_image->height() != dst_image->height())) { + return false; + } + + if (compare_alpha && src_image->alphaType() != dst_image->alphaType()) + return false; + if (src_image->makeRasterImage()->colorType() != + dst_image->makeRasterImage()->colorType()) { + return false; + } + if (!MatchColorSpace(src_image->colorSpace(), dst_image->colorSpace(), + xyz_d50_component_tolerance)) { + return false; + } + + bool test_passed = true; + int num_pixels = src_image->width() * src_image->height(); + int num_components = compare_alpha ? 4 : 3; + + SkImageInfo src_info = SkImageInfo::Make( + src_image->width(), src_image->height(), kN32_SkColorType, + src_image->alphaType(), src_image->refColorSpace()); + + SkImageInfo dst_info = SkImageInfo::Make( + dst_image->width(), dst_image->height(), kN32_SkColorType, + src_image->alphaType(), dst_image->refColorSpace()); + + if (src_image->colorType() != kRGBA_F16_SkColorType) { + std::unique_ptr<uint8_t[]> src_pixels(new uint8_t[num_pixels * 4]()); + std::unique_ptr<uint8_t[]> dst_pixels(new uint8_t[num_pixels * 4]()); + + src_image->readPixels(src_info, src_pixels.get(), src_info.minRowBytes(), 0, + 0); + dst_image->readPixels(dst_info, dst_pixels.get(), dst_info.minRowBytes(), 0, + 0); + + for (int i = 0; test_passed && i < num_pixels; i++) { + for (int j = 0; j < num_components; j++) { + test_passed &= IsNearlyTheSame(src_pixels[i * 4 + j], + dst_pixels[i * 4 + j], uint8_tolerance); + } + } + return test_passed; + } + + std::unique_ptr<uint16_t[]> src_pixels(new uint16_t[num_pixels * 4]()); + std::unique_ptr<uint16_t[]> dst_pixels(new uint16_t[num_pixels * 4]()); + + src_info = src_info.makeColorType(kRGBA_F16_SkColorType); + dst_info = dst_info.makeColorType(kRGBA_F16_SkColorType); + + src_image->readPixels(src_info, src_pixels.get(), src_info.minRowBytes(), 0, + 0); + dst_image->readPixels(dst_info, dst_pixels.get(), dst_info.minRowBytes(), 0, + 0); + + for (int i = 0; test_passed && i < num_pixels; i++) { + for (int j = 0; j < num_components; j++) { + test_passed &= + IsNearlyTheSame(Float16ToFloat(src_pixels[i * 4 + j]), + Float16ToFloat(dst_pixels[i * 4 + j]), f16_tolerance); + } + } + return test_passed; +} + } // namespace blink
diff --git a/third_party/blink/renderer/platform/graphics/color_correction_test_utils.h b/third_party/blink/renderer/platform/graphics/color_correction_test_utils.h index 294b159..aa8aae8 100644 --- a/third_party/blink/renderer/platform/graphics/color_correction_test_utils.h +++ b/third_party/blink/renderer/platform/graphics/color_correction_test_utils.h
@@ -10,6 +10,7 @@ #include "third_party/blink/renderer/platform/graphics/graphics_types.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/skia/include/core/SkColorSpaceXform.h" +#include "third_party/skia/include/core/SkImage.h" namespace blink { @@ -43,6 +44,17 @@ std::unique_ptr<uint8_t[]>& converted_pixels, SkColorSpaceXform::ColorFormat color_format_for_f16_canvas); + static bool MatchColorSpace(SkColorSpace* src_color_space, + SkColorSpace* dst_color_space, + float xyz_d50_component_tolerance); + + static bool MatchSkImages(sk_sp<SkImage> src_image, + sk_sp<SkImage> dst_image, + unsigned uint8_tolerance, + float f16_tolerance, + float xyz_d50_component_tolerance, + bool compare_alpha); + private: static bool IsNearlyTheSame(float expected, float actual, float tolerance); };
diff --git a/third_party/blink/renderer/platform/graphics/image_data_buffer.cc b/third_party/blink/renderer/platform/graphics/image_data_buffer.cc index 40687fd..4e2bc97 100644 --- a/third_party/blink/renderer/platform/graphics/image_data_buffer.cc +++ b/third_party/blink/renderer/platform/graphics/image_data_buffer.cc
@@ -117,30 +117,28 @@ return static_cast<const unsigned char*>(pixmap_.addr()); } -bool ImageDataBuffer::EncodeImage(const String& mime_type, - const double& quality, - Vector<unsigned char>* encoded_image) const { - return EncodeImageInternal(mime_type, quality, encoded_image, pixmap_); +bool ImageDataBuffer::EncodeImage( + const String& mime_type, + const double& quality, + Vector<unsigned char>* encoded_image, + SkTransferFunctionBehavior transfer_fn_behavior) const { + return EncodeImageInternal(mime_type, quality, encoded_image, pixmap_, + transfer_fn_behavior); } -bool ImageDataBuffer::EncodeImageInternal(const String& mime_type, - const double& quality, - Vector<unsigned char>* encoded_image, - const SkPixmap& pixmap) const { +bool ImageDataBuffer::EncodeImageInternal( + const String& mime_type, + const double& quality, + Vector<unsigned char>* encoded_image, + const SkPixmap& pixmap, + SkTransferFunctionBehavior transfer_fn_behavior) const { DCHECK(is_valid_); if (mime_type == "image/jpeg") { SkJpegEncoder::Options options; options.fQuality = ImageEncoder::ComputeJpegQuality(quality); options.fAlphaOption = SkJpegEncoder::AlphaOption::kBlendOnBlack; - // When the gamma is linear (which is always the case with currently - // supported color spaces in F16 format), it does not matter whether we use - // kRespect or kIgnore, but the JPEG encoder does not support kIgnore with - // F16 for some reason, so we switch to kRespect in that case, with no - // consequence on the encoded output. - options.fBlendBehavior = pixmap.colorType() == kRGBA_F16_SkColorType - ? SkTransferFunctionBehavior::kRespect - : SkTransferFunctionBehavior::kIgnore; + options.fBlendBehavior = transfer_fn_behavior; if (options.fQuality == 100) { options.fDownsample = SkJpegEncoder::Downsample::k444; } @@ -148,8 +146,8 @@ } if (mime_type == "image/webp") { - SkWebpEncoder::Options options = ImageEncoder::ComputeWebpOptions( - quality, SkTransferFunctionBehavior::kIgnore); + SkWebpEncoder::Options options = + ImageEncoder::ComputeWebpOptions(quality, transfer_fn_behavior); return ImageEncoder::Encode(encoded_image, pixmap, options); } @@ -157,7 +155,7 @@ SkPngEncoder::Options options; options.fFilterFlags = SkPngEncoder::FilterFlag::kSub; options.fZLibLevel = 3; - options.fUnpremulBehavior = SkTransferFunctionBehavior::kIgnore; + options.fUnpremulBehavior = transfer_fn_behavior; return ImageEncoder::Encode(encoded_image, pixmap, options); } @@ -181,7 +179,8 @@ } Vector<unsigned char> result; - if (!EncodeImageInternal(mime_type, quality, &result, pixmap)) + if (!EncodeImageInternal(mime_type, quality, &result, pixmap, + SkTransferFunctionBehavior::kIgnore)) return "data:,"; return "data:" + mime_type + ";base64," + Base64Encode(result);
diff --git a/third_party/blink/renderer/platform/graphics/image_data_buffer.h b/third_party/blink/renderer/platform/graphics/image_data_buffer.h index 3002ac98..48ffa41 100644 --- a/third_party/blink/renderer/platform/graphics/image_data_buffer.h +++ b/third_party/blink/renderer/platform/graphics/image_data_buffer.h
@@ -50,7 +50,8 @@ String ToDataURL(const String& mime_type, const double& quality) const; bool EncodeImage(const String& mime_type, const double& quality, - Vector<unsigned char>* encoded_image) const; + Vector<unsigned char>* encoded_image, + SkTransferFunctionBehavior transfer_fn_behavior) const; const unsigned char* Pixels() const; const IntSize& size() const { return size_; } @@ -66,10 +67,12 @@ bool IsValid() { return is_valid_; } // Only used by Create() - bool EncodeImageInternal(const String& mime_type, - const double& quality, - Vector<unsigned char>* encoded_image, - const SkPixmap& pixmap) const; + bool EncodeImageInternal( + const String& mime_type, + const double& quality, + Vector<unsigned char>* encoded_image, + const SkPixmap& pixmap, + SkTransferFunctionBehavior transfer_fn_behavior) const; sk_sp<SkImage> retained_image_; SkPixmap pixmap_;
diff --git a/third_party/blink/renderer/platform/graphics/video_frame_resource_provider.cc b/third_party/blink/renderer/platform/graphics/video_frame_resource_provider.cc index 061b842..21002901 100644 --- a/third_party/blink/renderer/platform/graphics/video_frame_resource_provider.cc +++ b/third_party/blink/renderer/platform/graphics/video_frame_resource_provider.cc
@@ -29,7 +29,7 @@ viz::SharedBitmapReporter* shared_bitmap_reporter) { context_provider_ = media_context_provider; resource_provider_ = std::make_unique<viz::ClientResourceProvider>( - media_context_provider, true); + /*delegated_sync_points_required=*/true); int max_texture_size; if (context_provider_) {
diff --git a/third_party/blink/renderer/platform/heap/heap_stats_collector.h b/third_party/blink/renderer/platform/heap/heap_stats_collector.h index c94e8d9e..cfc392f3 100644 --- a/third_party/blink/renderer/platform/heap/heap_stats_collector.h +++ b/third_party/blink/renderer/platform/heap/heap_stats_collector.h
@@ -36,6 +36,7 @@ kInvokePreFinalizers, kLazySweepInIdle, kLazySweepOnAllocation, + kAtomicPhase, kAtomicPhaseMarking, kVisitDOMWrappers, kNumScopeIds, @@ -43,6 +44,8 @@ static const char* ToString(Id id) { switch (id) { + case Id::kAtomicPhase: + return "BlinkGC.AtomicPhase"; case Id::kAtomicPhaseMarking: return "BlinkGC.AtomicPhaseMarking"; case Id::kCompleteSweep:
diff --git a/third_party/blink/renderer/platform/heap/thread_state.cc b/third_party/blink/renderer/platform/heap/thread_state.cc index 60293d7c..7cec65b3 100644 --- a/third_party/blink/renderer/platform/heap/thread_state.cc +++ b/third_party/blink/renderer/platform/heap/thread_state.cc
@@ -883,6 +883,15 @@ } } +void ThreadState::FinishSnapshot() { + // Force setting NoGCScheduled to circumvent checkThread() + // in setGCState(). + gc_state_ = kNoGCScheduled; + SetGCPhase(GCPhase::kSweeping); + SetGCPhase(GCPhase::kNone); + Heap().stats_collector()->Stop(); +} + void ThreadState::PreSweep(BlinkGC::MarkingType marking_type, BlinkGC::SweepingType sweeping_type) { DCHECK(InAtomicMarkingPause()); @@ -899,13 +908,6 @@ Heap().MakeConsistentForMutator(); Heap().TakeSnapshot(ThreadHeap::SnapshotType::kFreelistSnapshot); - - // Force setting NoGCScheduled to circumvent checkThread() - // in setGCState(). - gc_state_ = kNoGCScheduled; - SetGCPhase(GCPhase::kSweeping); - SetGCPhase(GCPhase::kNone); - Heap().stats_collector()->Stop(); return; } @@ -1373,6 +1375,7 @@ PreSweep(current_gc_data_.marking_type, BlinkGC::kLazySweeping); DCHECK(IsSweepingInProgress()); DCHECK_EQ(GcState(), kNoGCScheduled); + ScheduleIdleLazySweep(); } } @@ -1412,28 +1415,7 @@ CompleteSweep(); SetGCState(kNoGCScheduled); Heap().stats_collector()->Start(reason); - AtomicPauseScope atomic_pause_scope(this); - { - ThreadHeapStatsCollector::EnabledScope stats_scope( - Heap().stats_collector(), - ThreadHeapStatsCollector::kAtomicPhaseMarking, "lazySweeping", - sweeping_type == BlinkGC::kLazySweeping ? "yes" : "no", "gcReason", - GcReasonString(reason)); - MarkPhasePrologue(stack_state, marking_type, reason); - MarkPhaseVisitRoots(); - CHECK(MarkPhaseAdvanceMarking(std::numeric_limits<double>::infinity())); - MarkPhaseEpilogue(marking_type); - } - PreSweep(marking_type, sweeping_type); - } - - if (sweeping_type == BlinkGC::kEagerSweeping) { - // Eager sweeping should happen only in testing. - CompleteSweep(); - } else { - DCHECK(sweeping_type == BlinkGC::kLazySweeping); - // The default behavior is lazy sweeping. - ScheduleIdleLazySweep(); + RunAtomicPause(stack_state, marking_type, sweeping_type, reason); } double total_collect_garbage_time = @@ -1451,33 +1433,77 @@ << " reason: " << GcReasonString(reason); } +void ThreadState::RunAtomicPause(BlinkGC::StackState stack_state, + BlinkGC::MarkingType marking_type, + BlinkGC::SweepingType sweeping_type, + BlinkGC::GCReason reason) { + { + ThreadHeapStatsCollector::EnabledScope stats1( + Heap().stats_collector(), ThreadHeapStatsCollector::kAtomicPhase); + AtomicPauseScope atomic_pause_scope(this); + { + ThreadHeapStatsCollector::EnabledScope stats2( + Heap().stats_collector(), + ThreadHeapStatsCollector::kAtomicPhaseMarking, "lazySweeping", + sweeping_type == BlinkGC::kLazySweeping ? "yes" : "no", "gcReason", + GcReasonString(reason)); + MarkPhasePrologue(stack_state, marking_type, reason); + MarkPhaseVisitRoots(); + CHECK(MarkPhaseAdvanceMarking(std::numeric_limits<double>::infinity())); + MarkPhaseEpilogue(marking_type); + } + PreSweep(marking_type, sweeping_type); + } + if (marking_type == BlinkGC::kTakeSnapshot) { + FinishSnapshot(); + CHECK(!IsSweepingInProgress()); + CHECK_EQ(GcState(), kNoGCScheduled); + return; + } + DCHECK(IsSweepingInProgress()); + if (sweeping_type == BlinkGC::kEagerSweeping) { + // Eager sweeping should happen only in testing. + CompleteSweep(); + } else { + DCHECK(sweeping_type == BlinkGC::kLazySweeping); + // The default behavior is lazy sweeping. + ScheduleIdleLazySweep(); + } +} + +namespace { + +MarkingVisitor::MarkingMode GetMarkingMode(bool should_compact, + bool create_snapshot) { + CHECK(!should_compact || !create_snapshot); + return (create_snapshot) + ? MarkingVisitor::kSnapshotMarking + : (should_compact) ? MarkingVisitor::kGlobalMarkingWithCompaction + : MarkingVisitor::kGlobalMarking; +} + +} // namespace + void ThreadState::MarkPhasePrologue(BlinkGC::StackState stack_state, BlinkGC::MarkingType marking_type, BlinkGC::GCReason reason) { SetGCPhase(GCPhase::kMarking); Heap().CommitCallbackStacks(); + const bool take_snapshot = marking_type == BlinkGC::kTakeSnapshot; + const bool should_compact = + !take_snapshot && Heap().Compaction()->ShouldCompact( + &Heap(), stack_state, marking_type, reason); + + current_gc_data_.visitor = MarkingVisitor::Create( + this, GetMarkingMode(should_compact, take_snapshot)); current_gc_data_.stack_state = stack_state; current_gc_data_.marking_type = marking_type; current_gc_data_.reason = reason; current_gc_data_.marking_time_in_milliseconds = 0; - if (marking_type == BlinkGC::kTakeSnapshot) { - current_gc_data_.visitor = - MarkingVisitor::Create(this, MarkingVisitor::kSnapshotMarking); - } else { - DCHECK(marking_type == BlinkGC::kAtomicMarking || - marking_type == BlinkGC::kIncrementalMarking); - if (Heap().Compaction()->ShouldCompact(&Heap(), stack_state, marking_type, - reason)) { - Heap().Compaction()->Initialize(this); - current_gc_data_.visitor = MarkingVisitor::Create( - this, MarkingVisitor::kGlobalMarkingWithCompaction); - } else { - current_gc_data_.visitor = - MarkingVisitor::Create(this, MarkingVisitor::kGlobalMarking); - } - } + if (should_compact) + Heap().Compaction()->Initialize(this); if (marking_type == BlinkGC::kTakeSnapshot) BlinkGCMemoryDumpProvider::Instance()->ClearProcessDumpForCurrentGC();
diff --git a/third_party/blink/renderer/platform/heap/thread_state.h b/third_party/blink/renderer/platform/heap/thread_state.h index 27f2fa5..cbe918c4 100644 --- a/third_party/blink/renderer/platform/heap/thread_state.h +++ b/third_party/blink/renderer/platform/heap/thread_state.h
@@ -300,26 +300,9 @@ void EnableIncrementalMarkingBarrier(); void DisableIncrementalMarkingBarrier(); - // A GC runs in the following sequence. - // - // 1) preGC() is called. - // 2) ThreadHeap::collectGarbage() is called. This marks live objects. - // 3) postGC() is called. This does thread-local weak processing. - // 4) preSweep() is called. This does pre-finalization, eager sweeping and - // heap compaction. - // 4) Lazy sweeping sweeps heaps incrementally. completeSweep() may be called - // to complete the sweeping. - // 5) postSweep() is called. - void MarkPhasePrologue(BlinkGC::StackState, - BlinkGC::MarkingType, - BlinkGC::GCReason); - void MarkPhaseVisitRoots(); - bool MarkPhaseAdvanceMarking(double deadline_seconds); - void MarkPhaseEpilogue(BlinkGC::MarkingType); - void VerifyMarking(BlinkGC::MarkingType); - void CompleteSweep(); void PreSweep(BlinkGC::MarkingType, BlinkGC::SweepingType); + void FinishSnapshot(); void PostSweep(); // Support for disallowing allocation. Mainly used for sanity @@ -592,6 +575,7 @@ friend class incremental_marking_test::IncrementalMarkingTestDriver; template <typename T> friend class PrefinalizerRegistration; + friend class TestGCMarkingScope; // Number of ThreadState's that are currently in incremental marking. The // counter is incremented by one when some ThreadState enters incremental @@ -604,6 +588,19 @@ ThreadState(); ~ThreadState(); + void MarkPhasePrologue(BlinkGC::StackState, + BlinkGC::MarkingType, + BlinkGC::GCReason); + void MarkPhaseVisitRoots(); + bool MarkPhaseAdvanceMarking(double deadline_seconds); + void MarkPhaseEpilogue(BlinkGC::MarkingType); + void VerifyMarking(BlinkGC::MarkingType); + + void RunAtomicPause(BlinkGC::StackState, + BlinkGC::MarkingType, + BlinkGC::SweepingType, + BlinkGC::GCReason); + void ClearSafePointScopeMarker() { safe_point_stack_copy_.clear(); safe_point_scope_marker_ = nullptr;
diff --git a/third_party/blink/renderer/platform/web_task_runner.cc b/third_party/blink/renderer/platform/web_task_runner.cc index 3ae21f3..818c887 100644 --- a/third_party/blink/renderer/platform/web_task_runner.cc +++ b/third_party/blink/renderer/platform/web_task_runner.cc
@@ -7,26 +7,6 @@ #include "base/bind_helpers.h" #include "base/single_thread_task_runner.h" -namespace base { - -using RunnerMethodType = - void (blink::TaskHandle::Runner::*)(const blink::TaskHandle&); - -template <> -struct CallbackCancellationTraits< - RunnerMethodType, - std::tuple<base::WeakPtr<blink::TaskHandle::Runner>, blink::TaskHandle>> { - static constexpr bool is_cancellable = true; - - static bool IsCancelled(RunnerMethodType, - const base::WeakPtr<blink::TaskHandle::Runner>&, - const blink::TaskHandle& handle) { - return !handle.IsActive(); - } -}; - -} // namespace base - namespace blink { namespace { @@ -82,6 +62,30 @@ DISALLOW_COPY_AND_ASSIGN(Runner); }; +} // namespace blink + +namespace base { + +using RunnerMethodType = + void (blink::TaskHandle::Runner::*)(const blink::TaskHandle&); + +template <> +struct CallbackCancellationTraits< + RunnerMethodType, + std::tuple<base::WeakPtr<blink::TaskHandle::Runner>, blink::TaskHandle>> { + static constexpr bool is_cancellable = true; + + static bool IsCancelled(RunnerMethodType, + const base::WeakPtr<blink::TaskHandle::Runner>&, + const blink::TaskHandle& handle) { + return !handle.IsActive(); + } +}; + +} // namespace base + +namespace blink { + bool TaskHandle::IsActive() const { return runner_ && runner_->IsActive(); }
diff --git a/third_party/blink/tools/blinkpy/w3c/test_importer.py b/third_party/blink/tools/blinkpy/w3c/test_importer.py index 239f3bd8..04805ee 100644 --- a/third_party/blink/tools/blinkpy/w3c/test_importer.py +++ b/third_party/blink/tools/blinkpy/w3c/test_importer.py
@@ -245,16 +245,21 @@ self.git_cl.run(['set-close']) return False - if self.git_cl.all_success(cq_try_results): - _log.info('CQ appears to have passed; trying to commit.') - self.git_cl.run(['upload', '-f', '--send-mail']) # Turn off WIP mode. - self.git_cl.run(['set-commit']) - self.git_cl.wait_for_closed_status() + if not self.git_cl.all_success(cq_try_results): + _log.error('CQ appears to have failed; aborting.') + self.git_cl.run(['set-close']) + return False + + _log.info('CQ appears to have passed; trying to commit.') + self.git_cl.run(['upload', '-f', '--send-mail']) # Turn off WIP mode. + self.git_cl.run(['set-commit']) + + if self.git_cl.wait_for_closed_status(): _log.info('Update completed.') return True + _log.error('Cannot submit CL; aborting.') self.git_cl.run(['set-close']) - _log.error('CQ appears to have failed; aborting.') return False def blink_try_bots(self):
diff --git a/third_party/blink/tools/blinkpy/w3c/test_importer_unittest.py b/third_party/blink/tools/blinkpy/w3c/test_importer_unittest.py index 5f9f4a07..b825383 100644 --- a/third_party/blink/tools/blinkpy/w3c/test_importer_unittest.py +++ b/third_party/blink/tools/blinkpy/w3c/test_importer_unittest.py
@@ -109,7 +109,7 @@ ['git', 'cl', 'set-commit'], ]) - def test_run_commit_queue_for_cl_fails(self): + def test_run_commit_queue_for_cl_fail_cq(self): host = MockHost() host.filesystem.write_text_file( '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') @@ -132,6 +132,32 @@ ['git', 'cl', 'set-close'], ]) + def test_run_commit_queue_for_cl_fail_to_land(self): + host = MockHost() + host.filesystem.write_text_file( + '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') + importer = TestImporter(host) + # Only the latest job for each builder is counted. + importer.git_cl = MockGitCL(host, status='lgtm', try_job_results={ + Build('cq-builder-a', 120): TryJobStatus('COMPLETED', 'FAILURE'), + Build('cq-builder-a', 123): TryJobStatus('COMPLETED', 'SUCCESS'), + }) + importer.git_cl.wait_for_closed_status = lambda: False + success = importer.run_commit_queue_for_cl() + self.assertFalse(success) + self.assertLog([ + 'INFO: Triggering CQ try jobs.\n', + 'INFO: All jobs finished.\n', + 'INFO: CQ appears to have passed; trying to commit.\n', + 'ERROR: Cannot submit CL; aborting.\n', + ]) + self.assertEqual(importer.git_cl.calls, [ + ['git', 'cl', 'try'], + ['git', 'cl', 'upload', '-f', '--send-mail'], + ['git', 'cl', 'set-commit'], + ['git', 'cl', 'set-close'], + ]) + def test_run_commit_queue_for_cl_closed_cl(self): host = MockHost() host.filesystem.write_text_file(
diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn index 99d40a61..902736d 100644 --- a/third_party/breakpad/BUILD.gn +++ b/third_party/breakpad/BUILD.gn
@@ -162,7 +162,7 @@ "//base", ] - defines = [ "BPLOG_MINIMUM_SEVERITY=SEVERITY_ERROR" ] + defines = [ "BPLOG_MINIMUM_SEVERITY=SEVERITY_CRITICAL" ] include_dirs = [ "breakpad/src" ] libfuzzer_options = [ @@ -191,7 +191,6 @@ deps = [ ":stackwalk_common", - "//build/config:exe_and_shlib_deps", ] defines = [ "BPLOG_MINIMUM_SEVERITY=SEVERITY_ERROR" ] @@ -211,7 +210,6 @@ deps = [ ":stackwalk_common", - "//build/config:exe_and_shlib_deps", ] defines = [ "BPLOG_MINIMUM_SEVERITY=SEVERITY_ERROR" ] @@ -254,10 +252,6 @@ # There are some warnings in this code. configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] } } else { # Aliases for convenience. @@ -331,10 +325,6 @@ configs -= [ "//build/config/compiler:default_optimization" ] cflags += [ "-O0" ] } - - deps = [ - "//build/config:exe_and_shlib_deps", - ] } executable("symupload") { @@ -349,10 +339,6 @@ configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] } } else { binary_symlink("dump_syms") { @@ -423,7 +409,6 @@ deps = [ ":utilities", - "//build/config:exe_and_shlib_deps", ] } @@ -484,10 +469,6 @@ configs += [ ":tools_config" ] libs = [ "dl" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] } # dump_syms is a host tool, so only compile it for the host system. @@ -549,10 +530,6 @@ defines = [ "HAVE_A_OUT_H" ] include_dirs = [ "breakpad/src" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] } } else { # Aliases for convenience. @@ -715,7 +692,6 @@ deps = [ ":client", ":processor_support", - "//build/config:exe_and_shlib_deps", "//testing/gmock", "//testing/gtest", "//testing/gtest:gtest_main", @@ -767,7 +743,6 @@ ] deps = [ ":processor_support", - "//build/config:exe_and_shlib_deps", ] configs += [ ":client_config" ] @@ -793,7 +768,6 @@ deps = [ ":client", - "//build/config:exe_and_shlib_deps", ] if (is_android) { @@ -813,7 +787,6 @@ deps = [ ":client", - "//build/config:exe_and_shlib_deps", ] } @@ -825,7 +798,6 @@ deps = [ ":client", - "//build/config:exe_and_shlib_deps", ] include_dirs = [ "breakpad/src" ] @@ -855,10 +827,6 @@ "breakpad/src/tools/windows/dump_syms/dump_syms.cc", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] - lib_dirs = [] if (target_cpu == "x64") { lib_dirs += [ "$visual_studio_path/DIA SDK/lib/amd64" ]
diff --git a/third_party/brotli/BUILD.gn b/third_party/brotli/BUILD.gn index 500fb98..433387d 100644 --- a/third_party/brotli/BUILD.gn +++ b/third_party/brotli/BUILD.gn
@@ -164,7 +164,6 @@ ":common", ":dec", ":headers", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ]
diff --git a/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni b/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni index f767027..180928d 100644 --- a/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni +++ b/third_party/crashpad/crashpad/build/crashpad_buildconfig.gni
@@ -63,7 +63,12 @@ template("crashpad_executable") { executable(target_name) { - forward_variables_from(invoker, "*", [ "configs", "remove_configs" ]) + forward_variables_from(invoker, + "*", + [ + "configs", + "remove_configs", + ]) if (defined(invoker.remove_configs)) { configs -= invoker.remove_configs } @@ -72,13 +77,7 @@ configs += invoker.configs } - if (!defined(deps)) { - deps = [] - } - - if (crashpad_is_in_chromium) { - deps += [ "//build/config:exe_and_shlib_deps" ] - } else if (crashpad_is_in_fuchsia) { + if (crashpad_is_in_fuchsia) { configs += [ "//build/config/fuchsia:fdio_config" ] } } @@ -86,7 +85,12 @@ template("crashpad_loadable_module") { loadable_module(target_name) { - forward_variables_from(invoker, "*", [ "configs", "remove_configs" ]) + forward_variables_from(invoker, + "*", + [ + "configs", + "remove_configs", + ]) if (defined(invoker.remove_configs)) { configs -= invoker.remove_configs } @@ -95,13 +99,7 @@ configs += invoker.configs } - if (!defined(deps)) { - deps = [] - } - - if (crashpad_is_in_chromium) { - deps += [ "//build/config:exe_and_shlib_deps" ] - } else if (crashpad_is_in_fuchsia) { + if (crashpad_is_in_fuchsia) { configs += [ "//build/config/fuchsia:fdio_config" ] } }
diff --git a/third_party/flatbuffers/BUILD.gn b/third_party/flatbuffers/BUILD.gn index c687147..fe61f77 100644 --- a/third_party/flatbuffers/BUILD.gn +++ b/third_party/flatbuffers/BUILD.gn
@@ -75,7 +75,6 @@ deps = [ ":compiler_files", ":flatbuffers", - "//build/config:exe_and_shlib_deps", ] }
diff --git a/third_party/freetype/README.chromium b/third_party/freetype/README.chromium index 5e0a64bb..d742a2d 100644 --- a/third_party/freetype/README.chromium +++ b/third_party/freetype/README.chromium
@@ -1,7 +1,7 @@ Name: FreeType URL: http://www.freetype.org/ -Version: VER-2-9-1-7 -Revision: 9e345c911714ed62250be13d03d72e25d91fbc77 +Version: VER-2-9-1-34 +Revision: d45d4b97e6a03cfe21a2952138cf6e970fc358e5 License: Custom license "inspired by the BSD, Artistic, and IJG (Independent JPEG Group) licenses" License File: src/docs/FTL.TXT
diff --git a/third_party/freetype/include/freetype-custom-config/ftoption.h b/third_party/freetype/include/freetype-custom-config/ftoption.h index e2417fa..da0a6ba3 100644 --- a/third_party/freetype/include/freetype-custom-config/ftoption.h +++ b/third_party/freetype/include/freetype-custom-config/ftoption.h
@@ -537,6 +537,15 @@ /*************************************************************************/ /* */ + /* Define TT_CONFIG_OPTION_COLOR_LAYERS if you want to support coloured */ + /* outlines (from the COLR/CPAL tables) in all formats using the SFNT */ + /* module (namely TrueType & OpenType). */ + /* */ +#define TT_CONFIG_OPTION_COLOR_LAYERS + + + /*************************************************************************/ + /* */ /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ /* load and enumerate the glyph Postscript names in a TrueType or */ /* OpenType file. */
diff --git a/third_party/freetype/roll-freetype.sh b/third_party/freetype/roll-freetype.sh index 7d5cbd3..67a818e2 100755 --- a/third_party/freetype/roll-freetype.sh +++ b/third_party/freetype/roll-freetype.sh
@@ -43,8 +43,8 @@ STEP="update README.chromium" && FTVERSION=$(git -C third_party/freetype/src/ describe --long) && FTCOMMIT=$(git -C third_party/freetype/src/ rev-parse HEAD) && - sed -i "s/^Version: .*\$/Version: ${FTVERSION%-*}/" third_party/freetype/README.chromium && - sed -i "s/^Revision: .*\$/Revision: ${FTCOMMIT}/" third_party/freetype/README.chromium && + sed -i'' -e "s/^Version: .*\$/Version: ${FTVERSION%-*}/" third_party/freetype/README.chromium && + sed -i'' -e "s/^Revision: .*\$/Revision: ${FTCOMMIT}/" third_party/freetype/README.chromium && git add third_party/freetype/README.chromium }
diff --git a/third_party/ijar/BUILD.gn b/third_party/ijar/BUILD.gn index 98b1b58..89b863a9 100644 --- a/third_party/ijar/BUILD.gn +++ b/third_party/ijar/BUILD.gn
@@ -26,8 +26,5 @@ configs += [ "//build/config:release" ] } ldflags = [ "-lz" ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] } }
diff --git a/third_party/leveldatabase/BUILD.gn b/third_party/leveldatabase/BUILD.gn index 908b998..27289be 100644 --- a/third_party/leveldatabase/BUILD.gn +++ b/third_party/leveldatabase/BUILD.gn
@@ -350,7 +350,6 @@ configs += [ "//build/config/compiler:no_chromium_code" ] deps = [ ":leveldb", - "//build/config:exe_and_shlib_deps", ] }
diff --git a/third_party/libdrm/BUILD.gn b/third_party/libdrm/BUILD.gn index 188385f..4a199b3 100644 --- a/third_party/libdrm/BUILD.gn +++ b/third_party/libdrm/BUILD.gn
@@ -84,7 +84,6 @@ deps = [ ":libdrm", - "//build/config:exe_and_shlib_deps", ] } }
diff --git a/third_party/libwebp/BUILD.gn b/third_party/libwebp/BUILD.gn index dc741e0..df99210 100644 --- a/third_party/libwebp/BUILD.gn +++ b/third_party/libwebp/BUILD.gn
@@ -512,7 +512,6 @@ ":libwebp", ":libwebp_webp", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] configs += [ ":libwebp_config_internal" ] @@ -538,7 +537,6 @@ ":libwebp", ":libwebp_webp", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] configs += [ ":libwebp_config_internal" ]
diff --git a/third_party/mesa/BUILD.gn b/third_party/mesa/BUILD.gn index 875e67c..841848b 100644 --- a/third_party/mesa/BUILD.gn +++ b/third_party/mesa/BUILD.gn
@@ -761,7 +761,6 @@ ":mesa", ":mesa_headers", ":mesa_libglslcommon", - "//build/config:exe_and_shlib_deps", ] if (is_win) {
diff --git a/third_party/opus/BUILD.gn b/third_party/opus/BUILD.gn index 516ba08..9c78dce 100644 --- a/third_party/opus/BUILD.gn +++ b/third_party/opus/BUILD.gn
@@ -432,7 +432,6 @@ deps = [ ":opus", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] } @@ -450,7 +449,6 @@ deps = [ ":opus", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/third_party/protobuf/BUILD.gn b/third_party/protobuf/BUILD.gn index 3f8c1e6..b13b20eb 100644 --- a/third_party/protobuf/BUILD.gn +++ b/third_party/protobuf/BUILD.gn
@@ -188,10 +188,6 @@ "//build/config/compiler:no_size_t_to_int_warning", ] - deps = [ - "//build/config:exe_and_shlib_deps", - ] - if (is_android) { libs = [ "log" ] # Used by src/google/protobuf/stubs/common.cc } @@ -199,7 +195,9 @@ cflags = protobuf_lite_cflags if (is_component_build && is_desktop_linux) { - deps += [ ":mirclient" ] + deps = [ + ":mirclient", + ] } # Required for component builds. See http://crbug.com/172800. @@ -358,7 +356,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//third_party/zlib", ] @@ -635,9 +632,6 @@ } executable("js_embed") { - deps = [ - "//build/config:exe_and_shlib_deps", - ] sources = [ "src/google/protobuf/compiler/js/embed.cc", ]
diff --git a/third_party/qcms/BUILD.gn b/third_party/qcms/BUILD.gn index 67a0bfac..9cb511ce 100644 --- a/third_party/qcms/BUILD.gn +++ b/third_party/qcms/BUILD.gn
@@ -89,7 +89,6 @@ ] deps = [ - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/qcms", ]
diff --git a/third_party/sqlite/BUILD.gn b/third_party/sqlite/BUILD.gn index 46abef1..28889b6d 100644 --- a/third_party/sqlite/BUILD.gn +++ b/third_party/sqlite/BUILD.gn
@@ -301,7 +301,6 @@ deps = [ ":sqlite", - "//build/config:exe_and_shlib_deps", "//third_party/icu", ]
diff --git a/third_party/unrar/BUILD.gn b/third_party/unrar/BUILD.gn index 12a3a1c..c3594cf 100644 --- a/third_party/unrar/BUILD.gn +++ b/third_party/unrar/BUILD.gn
@@ -27,7 +27,6 @@ "src/global.cpp", "src/hash.cpp", "src/headers.cpp", - "src/isnt.cpp", "src/list.cpp", "src/match.cpp", "src/options.cpp", @@ -56,6 +55,9 @@ "src/unpack.cpp", "src/volume.cpp", ] + if (is_win) { + sources += [ "src/isnt.cpp" ] + } configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] @@ -64,6 +66,7 @@ "_FILE_OFFSET_BITS=64", "LARGEFILE_SOURCE", "RAR_SMP", + "SILENT", # The following is set to disable certain macro definitions in the unrar # source code.
diff --git a/third_party/unrar/README.chromium b/third_party/unrar/README.chromium index 2579342..e7ab705 100644 --- a/third_party/unrar/README.chromium +++ b/third_party/unrar/README.chromium
@@ -24,4 +24,6 @@ - Explicit use of parentheses to fix linter errors. - Replace exceptions with terminating the current process. Guarded with the macro UNRAR_NO_EXCEPTIONS. - +- Pass a file handle to the rar file, instead of trying to open the rar file + inside the unrar library code. This is done because the unrar library code + operates inside a sandbox, so it doesn't have the permissions to open files.
diff --git a/third_party/unrar/src/file.cpp b/third_party/unrar/src/file.cpp index 4ca83ad..5188dbf 100644 --- a/third_party/unrar/src/file.cpp +++ b/third_party/unrar/src/file.cpp
@@ -51,6 +51,11 @@ bool UpdateMode=(Mode & FMF_UPDATE)!=0; bool WriteMode=(Mode & FMF_WRITE)!=0; #ifdef _WIN_ALL +#if defined(CHROMIUM_UNRAR) + // Do not open a file handle since the sandbox doesn't allow it. Use the + // handle provided by the caller. + hNewFile = hOpenFile; +#else uint Access=WriteMode ? GENERIC_WRITE:GENERIC_READ; if (UpdateMode) Access|=GENERIC_WRITE; @@ -89,6 +94,14 @@ if (hNewFile==FILE_BAD_HANDLE && LastError==ERROR_FILE_NOT_FOUND) ErrorType=FILE_NOTFOUND; +#endif // defined(CHROMIUM_UNRAR) + +#else + +#if defined(CHROMIUM_UNRAR) + // Do not open a file handle since the sandbox doesn't allow it. Use the + // handle provided by the caller. + int handle = hOpenFile; #else int flags=UpdateMode ? O_RDWR:(WriteMode ? O_WRONLY:O_RDONLY); #ifdef O_BINARY @@ -99,8 +112,9 @@ #endif char NameA[NM]; WideToChar(Name,NameA,ASIZE(NameA)); - int handle=open(NameA,flags); +#endif // defined(CHROMIUM_UNRAR) + #ifdef LOCK_EX #ifdef _OSF_SOURCE @@ -230,6 +244,8 @@ { if (!SkipClose) { +#if !defined(CHROMIUM_UNRAR) +// unrar should not close the file handle since it wasn't opened by unrar. #ifdef _WIN_ALL // We use the standard system handle for stdout in Windows // and it must not be closed here. @@ -242,6 +258,7 @@ Success=fclose(hFile)!=EOF; #endif #endif +#endif // defined(CHROMIUM_UNRAR) } hFile=FILE_BAD_HANDLE; } @@ -735,3 +752,9 @@ return CopySize; } #endif + +#if defined(CHROMIUM_UNRAR) +void File::SetFileHandle(FileHandle hF) { + hOpenFile = hF; +} +#endif // defined(CHROMIUM_UNRAR)
diff --git a/third_party/unrar/src/file.hpp b/third_party/unrar/src/file.hpp index 20734e2..dd5cfec 100644 --- a/third_party/unrar/src/file.hpp +++ b/third_party/unrar/src/file.hpp
@@ -68,6 +68,10 @@ wchar FileName[NM]; FILE_ERRORTYPE ErrorType; + +#if defined(CHROMIUM_UNRAR) + FileHandle hOpenFile; +#endif // defined(CHROMIUM_UNRAR) public: File(); virtual ~File(); @@ -111,6 +115,14 @@ #ifdef _WIN_ALL void RemoveSequentialFlag() {NoSequentialRead=true;} #endif + +#if defined(CHROMIUM_UNRAR) + // Since unrar runs in a sandbox, it doesn't have the permission to open + // files on the filesystem. Instead, the caller opens the file and passes + // the file handle to unrar. This handle is then used to read the file. + void SetFileHandle(FileHandle file); +#endif // defined(CHROMIUM_UNRAR) + #ifdef _UNIX int GetFD() {
diff --git a/third_party/unrar/src/isnt.cpp b/third_party/unrar/src/isnt.cpp index cb1eefc..d30adf5 100644 --- a/third_party/unrar/src/isnt.cpp +++ b/third_party/unrar/src/isnt.cpp
@@ -1,12 +1,14 @@ -#include "isnt.hpp" +#include "rar.hpp" #ifdef _WIN_ALL #include "versionhelpers.h" DWORD WinNT() { - if (!IsWinXpOrGreater()) return WNT_NONE; - if (!IsWinVistaOrGreater()) return WNT_WXP; + if (!IsWindowsXPOrGreater()) + return WNT_NONE; + if (!IsWindowsVistaOrGreater()) + return WNT_WXP; if (!IsWindows7OrGreater()) return WNT_VISTA; if (!IsWindows8OrGreater()) return WNT_W7; if (!IsWindows8Point1OrGreater()) return WNT_W8;
diff --git a/third_party/unrar/src/isnt.hpp b/third_party/unrar/src/isnt.hpp index 691a26a7..a021744 100644 --- a/third_party/unrar/src/isnt.hpp +++ b/third_party/unrar/src/isnt.hpp
@@ -1,7 +1,7 @@ #ifndef _RAR_ISNT_ #define _RAR_ISNT_ -#ifdef _WIN_ALL +#include "windows.h" enum WINNT_VERSION { WNT_NONE=0,WNT_NT351=0x0333,WNT_NT4=0x0400,WNT_W2000=0x0500, @@ -12,5 +12,3 @@ DWORD WinNT(); #endif - -#endif
diff --git a/third_party/unrar/src/model.cpp b/third_party/unrar/src/model.cpp index b0b3a4a1..6c5c4438 100644 --- a/third_party/unrar/src/model.cpp +++ b/third_party/unrar/src/model.cpp
@@ -45,7 +45,7 @@ if (MinContext == NULL) { #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(0); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS) @@ -58,7 +58,7 @@ if (FoundState == NULL) { #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(0); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS)
diff --git a/third_party/unrar/src/unpack.cpp b/third_party/unrar/src/unpack.cpp index f619afd..ca3c52e 100644 --- a/third_party/unrar/src/unpack.cpp +++ b/third_party/unrar/src/unpack.cpp
@@ -1,7 +1,7 @@ // NOTE(vakh): The process.h file needs to be included first because "rar.hpp" // defines certain macros that cause symbol redefinition errors #if defined(UNRAR_NO_EXCEPTIONS) -#include "base/process/process.h" +#include "base/process/memory.h" #endif // defined(UNRAR_NO_EXCEPTIONS) #include "rar.hpp" @@ -97,7 +97,7 @@ if (Grow && Fragmented) { #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(0); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS) @@ -112,7 +112,7 @@ // We do not support growth for new fragmented window. // Also exclude RAR4 and small dictionaries. #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(WinSize); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS)
diff --git a/third_party/unrar/src/unpack50frag.cpp b/third_party/unrar/src/unpack50frag.cpp index ffe1c6b5..16d5b1c3 100644 --- a/third_party/unrar/src/unpack50frag.cpp +++ b/third_party/unrar/src/unpack50frag.cpp
@@ -49,7 +49,7 @@ if (NewMem == NULL) { #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(Size); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS) @@ -67,7 +67,7 @@ if (TotalSize < WinSize) // Not found enough free blocks. { #if defined(UNRAR_NO_EXCEPTIONS) - base::Process::Current().Terminate(RARX_MEMORY, false); + base::TerminateBecauseOutOfMemory(WinSize); #else throw std::bad_alloc(); #endif // defined(UNRAR_NO_EXCEPTIONS)
diff --git a/third_party/unrar/src/unrar_wrapper.h b/third_party/unrar/src/unrar_wrapper.h new file mode 100644 index 0000000..b19759da --- /dev/null +++ b/third_party/unrar/src/unrar_wrapper.h
@@ -0,0 +1,15 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_UNRAR_SRC_UNRAR_WRAPPER_H_ +#define THIRD_PARTY_UNRAR_SRC_UNRAR_WRAPPER_H_ + +#include "rar.hpp" + +namespace third_party_unrar { +using ::Archive; +static const int kUnrarEndarcHead = ::HEAD_ENDARC; +} // namespace third_party_unrar + +#endif // THIRD_PARTY_UNRAR_SRC_UNRAR_WRAPPER_H_
diff --git a/third_party/yasm/BUILD.gn b/third_party/yasm/BUILD.gn index ab2f9414..b261e4d8 100644 --- a/third_party/yasm/BUILD.gn +++ b/third_party/yasm/BUILD.gn
@@ -87,8 +87,6 @@ "//build/config/compiler:no_chromium_code", ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ] @@ -104,8 +102,6 @@ "//build/config/compiler:no_chromium_code", ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ] @@ -129,7 +125,6 @@ deps = [ ":yasm_utils", - "//build/config:exe_and_shlib_deps", # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", @@ -165,8 +160,6 @@ "//build/config/compiler:no_chromium_code", ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ] @@ -182,8 +175,6 @@ "//build/config/compiler:no_chromium_code", ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ] @@ -226,8 +217,6 @@ ":re2c_warnings", ] deps = [ - "//build/config:exe_and_shlib_deps", - # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest", ] @@ -379,7 +368,6 @@ ":generate_module", ":generate_version", ":yasm_utils", - "//build/config:exe_and_shlib_deps", # Default manifest on Windows (a no-op elsewhere). "//build/win:default_exe_manifest",
diff --git a/third_party/zlib/BUILD.gn b/third_party/zlib/BUILD.gn index cf339d4..902e287 100644 --- a/third_party/zlib/BUILD.gn +++ b/third_party/zlib/BUILD.gn
@@ -365,6 +365,5 @@ deps = [ ":zlib", - "//build/config:exe_and_shlib_deps", ] }
diff --git a/tools/android/forwarder2/BUILD.gn b/tools/android/forwarder2/BUILD.gn index b674344..c77915a 100644 --- a/tools/android/forwarder2/BUILD.gn +++ b/tools/android/forwarder2/BUILD.gn
@@ -43,7 +43,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//tools/android/common", ] data_deps = [ @@ -86,7 +85,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//tools/android/common", ] }
diff --git a/tools/android/md5sum/BUILD.gn b/tools/android/md5sum/BUILD.gn index ef8e6db..7b5fb97 100644 --- a/tools/android/md5sum/BUILD.gn +++ b/tools/android/md5sum/BUILD.gn
@@ -21,7 +21,6 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", ] # md5sum uses //base, and is built when chrome_apk is. As a consequence,
diff --git a/tools/android/memdump/BUILD.gn b/tools/android/memdump/BUILD.gn index f047218..dafc7ec 100644 --- a/tools/android/memdump/BUILD.gn +++ b/tools/android/memdump/BUILD.gn
@@ -8,6 +8,5 @@ ] deps = [ "//base", - "//build/config:exe_and_shlib_deps", ] }
diff --git a/tools/battor_agent/BUILD.gn b/tools/battor_agent/BUILD.gn index 5339b67f..f1f9f17 100644 --- a/tools/battor_agent/BUILD.gn +++ b/tools/battor_agent/BUILD.gn
@@ -14,7 +14,6 @@ deps = [ ":battor_agent_lib", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/tools/binary_size/libsupersize/integration_test.py b/tools/binary_size/libsupersize/integration_test.py index 8fd8e64f..73cbcde 100755 --- a/tools/binary_size/libsupersize/integration_test.py +++ b/tools/binary_size/libsupersize/integration_test.py
@@ -333,56 +333,80 @@ size_info1 = self._CloneSizeInfo() size_info2 = self._CloneSizeInfo() - # Removing 1 alias should not change the size. + # Find a list of exact 4 symbols with the same aliases in |size_info2|: + # text@2a0010: BarAlias() + # text@2a0010: FooAlias() + # text@2a0010: blink::ContiguousContainerBase::shrinkToFit() @ path1 + # text@2a0010: blink::ContiguousContainerBase::shrinkToFit() @ path2 + # The blink::...::shrinkToFit() group has another member: + # text@2a0000: blink::ContiguousContainerBase::shrinkToFit() @ path3 a1, _, _, _ = ( size_info2.raw_symbols.Filter(lambda s: s.num_aliases == 4)[0].aliases) + # Remove FooAlias(). size_info2.raw_symbols -= [a1] a1.aliases.remove(a1) - d = diff.Diff(size_info1, size_info2) - self.assertEquals(d.raw_symbols.pss, 0) - self.assertEquals((0, 0, 1), _DiffCounts(d.raw_symbols)) - self.assertEquals((0, 0, 1), _DiffCounts(d.symbols.GroupedByFullName())) - # Adding one alias should not change size. + # From |size_info1| -> |size_info2|: 1 symbol is deleted. + d = diff.Diff(size_info1, size_info2) + # Total size should not change. + self.assertEquals(d.raw_symbols.pss, 0) + # 1 symbol is erased, and PSS distributed among 3 remaining aliases, and + # considered as change. + self.assertEquals((3, 0, 1), _DiffCounts(d.raw_symbols)) + # Grouping combines 2 x blink::ContiguousContainerBase::shrinkToFit(), so + # now ther are 2 changed aliases. + self.assertEquals((2, 0, 1), _DiffCounts(d.symbols.GroupedByFullName())) + + # From |size_info2| -> |size_info1|: 1 symbol is added. d = diff.Diff(size_info2, size_info1) self.assertEquals(d.raw_symbols.pss, 0) - self.assertEquals((0, 1, 0), _DiffCounts(d.raw_symbols)) - self.assertEquals((0, 1, 0), _DiffCounts(d.symbols.GroupedByFullName())) + self.assertEquals((3, 1, 0), _DiffCounts(d.raw_symbols)) + self.assertEquals((2, 1, 0), _DiffCounts(d.symbols.GroupedByFullName())) def test_Diff_Aliases2(self): size_info1 = self._CloneSizeInfo() size_info2 = self._CloneSizeInfo() - # Removing 2 aliases should not change the size. + # Same list of 4 symbols as before. a1, _, a2, _ = ( size_info2.raw_symbols.Filter(lambda s: s.num_aliases == 4)[0].aliases) + # Remove BarAlias() and blink::...::shrinkToFit(). size_info2.raw_symbols -= [a1, a2] a1.aliases.remove(a1) a1.aliases.remove(a2) + + # From |size_info1| -> |size_info2|: 2 symbols are deleted. d = diff.Diff(size_info1, size_info2) self.assertEquals(d.raw_symbols.pss, 0) - self.assertEquals((0, 0, 2), _DiffCounts(d.raw_symbols)) - self.assertEquals((1, 0, 1), _DiffCounts(d.symbols.GroupedByFullName())) + self.assertEquals((2, 0, 2), _DiffCounts(d.raw_symbols)) + self.assertEquals((2, 0, 1), _DiffCounts(d.symbols.GroupedByFullName())) - # Adding 2 aliases should not change size. + # From |size_info2| -> |size_info1|: 2 symbols are added. d = diff.Diff(size_info2, size_info1) self.assertEquals(d.raw_symbols.pss, 0) - self.assertEquals((0, 2, 0), _DiffCounts(d.raw_symbols)) - self.assertEquals((1, 1, 0), _DiffCounts(d.symbols.GroupedByFullName())) + self.assertEquals((2, 2, 0), _DiffCounts(d.raw_symbols)) + self.assertEquals((2, 1, 0), _DiffCounts(d.symbols.GroupedByFullName())) def test_Diff_Aliases4(self): size_info1 = self._CloneSizeInfo() size_info2 = self._CloneSizeInfo() - # Removing all 4 aliases should change the size. + # Same list of 4 symbols as before. a1, a2, a3, a4 = ( size_info2.raw_symbols.Filter(lambda s: s.num_aliases == 4)[0].aliases) + + # Remove all 4 aliases. size_info2.raw_symbols -= [a1, a2, a3, a4] + + # From |size_info1| -> |size_info2|: 4 symbols are deleted. d = diff.Diff(size_info1, size_info2) + self.assertEquals(d.raw_symbols.pss, -a1.size) self.assertEquals((0, 0, 4), _DiffCounts(d.raw_symbols)) + # When grouped, BarAlias() and FooAlias() are deleted, but the + # blink::...::shrinkToFit() has 1 remaining symbol, so is changed. self.assertEquals((1, 0, 2), _DiffCounts(d.symbols.GroupedByFullName())) - # Adding all 4 aliases should change size. + # From |size_info2| -> |size_info1|: 4 symbols are added. d = diff.Diff(size_info2, size_info1) self.assertEquals(d.raw_symbols.pss, a1.size) self.assertEquals((0, 4, 0), _DiffCounts(d.raw_symbols))
diff --git a/tools/binary_size/libsupersize/models.py b/tools/binary_size/libsupersize/models.py index 3488bc41..2293da83 100644 --- a/tools/binary_size/libsupersize/models.py +++ b/tools/binary_size/libsupersize/models.py
@@ -411,9 +411,16 @@ return DIFF_STATUS_ADDED if self.after_symbol is None: return DIFF_STATUS_REMOVED - if self.size == 0: - return DIFF_STATUS_UNCHANGED - return DIFF_STATUS_CHANGED + # Use delta size and delta PSS as indicators of change. Delta size = 0 with + # delta PSS != 0 can be caused by: + # (1) Alias addition / removal without actual binary change. + # (2) Alias merging / splitting along with binary changes, where matched + # symbols all happen the same size (hence delta size = 0). + # The purpose of checking PSS is to account for (2). However, this means (1) + # would produce much more diffs than before! + if self.size != 0 or self.pss != 0: + return DIFF_STATUS_CHANGED + return DIFF_STATUS_UNCHANGED @property def address(self):
diff --git a/tools/gn/BUILD.gn b/tools/gn/BUILD.gn index 1e171fa..ffffd5a5 100644 --- a/tools/gn/BUILD.gn +++ b/tools/gn/BUILD.gn
@@ -270,7 +270,6 @@ ":gn_lib", ":last_commit_position", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/tools/imagediff/BUILD.gn b/tools/imagediff/BUILD.gn index 66f539a0..cdc204ef 100644 --- a/tools/imagediff/BUILD.gn +++ b/tools/imagediff/BUILD.gn
@@ -17,7 +17,6 @@ deps = [ "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//third_party/libpng", "//third_party/zlib",
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 5bad7f5..5f1ef5e 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -403,8 +403,8 @@ 'Linux Compile Perf FYI': 'official_goma_perf', 'Android Builder Perf FYI': 'official_goma_minimal_symbols_android', 'Android arm64 Builder Perf FYI': 'official_goma_minimal_symbols_android_arm64', - 'Android CFI Builder Perf FYI': 'official_goma_minimal_symbols_android_cfi', - 'Android CFI arm64 Builder Perf FYI': 'official_goma_minimal_symbols_android_cfi_arm64', + 'Android CFI Builder Perf FYI': 'official_goma_minimal_symbols_android_thin_lto', + 'Android CFI arm64 Builder Perf FYI': 'official_goma_minimal_symbols_android_thin_lto_arm64', 'Battor Agent Linux': 'release_bot', 'Battor Agent Mac': 'release_bot', 'Battor Agent Win': 'release_bot', @@ -1435,12 +1435,12 @@ 'official', 'goma', 'minimal_symbols', 'android', 'arm64', ], - 'official_goma_minimal_symbols_android_cfi': [ - 'official', 'goma', 'minimal_symbols', 'android', 'cfi', + 'official_goma_minimal_symbols_android_thin_lto': [ + 'official', 'goma', 'minimal_symbols', 'android', 'thin_lto', ], - 'official_goma_minimal_symbols_android_cfi_arm64': [ - 'official', 'goma', 'minimal_symbols', 'android', 'cfi', 'arm64', + 'official_goma_minimal_symbols_android_thin_lto_arm64': [ + 'official', 'goma', 'minimal_symbols', 'android', 'thin_lto', 'arm64', ], 'official_goma_x86': [
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 4bda71a2..ffadad8 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -9057,6 +9057,7 @@ <int value="24" label="Site breakdown sorted by data saved"/> <int value="25" label="Site breakdown sorted by data used"/> <int value="26" label="Site breakdown expanded to see more sites"/> + <int value="27" label="Site breakdown sorted by hostname"/> </enum> <enum name="DataReductionProxyWarmupURLFetchAttemptEvent"> @@ -18853,6 +18854,7 @@ <int value="2462" label="ShapeOutsidePaddingBoxDifferentFromMarginBox"/> <int value="2463" label="CSSContainLayoutPositionedDescendants"/> <int value="2464" label="HTMLFrameSetElementAnonymousNamedGetter"/> + <int value="2465" label="CanvasConvertToBlob"/> </enum> <enum name="FeedbackSource"> @@ -36964,6 +36966,7 @@ <int value="3" label="Mouse click to dismiss"/> <int value="4" label="Touch to dismiss"/> <int value="5" label="Lock screen"/> + <int value="6" label="Feedback"/> </enum> <enum name="PowerButtonPressType">
diff --git a/tools/metrics/ukm/ukm.xml b/tools/metrics/ukm/ukm.xml index 98b2919ad..10508cf 100644 --- a/tools/metrics/ukm/ukm.xml +++ b/tools/metrics/ukm/ukm.xml
@@ -3354,19 +3354,21 @@ <metric name="LifecycleStateChangeReason"> <summary> The reason the lifecycle state change was attempted. This corresponds to - the LifecycleStateChangeReason enumeration in lifecycle_state.h. + the LifecycleStateChangeReason enumeration in lifecycle_unit_state.mojom. </summary> </metric> <metric name="NewLifecycleState"> <summary> The lifecycle state the tab will be in after the state change. Corresponds - to a value from the LifecycleState enum defined in lifecycle_state.h. + to a value from the LifecycleUnitState enum defined in + lifecycle_unit_state.mojom. </summary> </metric> <metric name="OldLifecycleState"> <summary> The lifecycle state the tab was in prior to the state change. Corresponds - to a value from the LifecycleState enum defined in lifecycle_state.h. + to a value from the LifecycleUnitState enum defined in + lifecycle_unit_state.mojom. </summary> </metric> <metric name="Outcome">
diff --git a/tools/perf/clear_system_cache/BUILD.gn b/tools/perf/clear_system_cache/BUILD.gn index f3d1c38..dd4db91 100644 --- a/tools/perf/clear_system_cache/BUILD.gn +++ b/tools/perf/clear_system_cache/BUILD.gn
@@ -12,7 +12,6 @@ deps = [ "//base", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", ] }
diff --git a/tools/perf/expectations.config b/tools/perf/expectations.config index 014af581..c8db425 100644 --- a/tools/perf/expectations.config +++ b/tools/perf/expectations.config
@@ -140,6 +140,12 @@ crbug.com/249722 [ All ] rendering.mobile/espn_mobile_sync_scroll [ Skip ] crbug.com/249736 [ All ] rendering.mobile/forecast.io_mobile [ Skip ] crbug.com/249736 [ All ] rendering.mobile/forecast.io_mobile_sync_scroll [ Skip ] +crbug.com/785485 [ Android_Webview ] rendering.mobile/kevs_3d [ Skip ] +crbug.com/755657 [ Android_One ] rendering.mobile/canvas_to_blob [ Skip ] +crbug.com/785286 [ Android_Webview ] rendering.mobile/smash_cat [ Skip ] +crbug.com/785286 [ Android_Webview ] rendering.mobile/effect_games [ Skip ] +crbug.com/364248 [ Nexus_5 ] rendering.mobile/geo_apis [ Skip ] +crbug.com/825234 [ Android_Webview ] rendering.mobile/bouncing_balls_shadow [ Skip ] # Benchmark: smoothness.gpu_rasterization.polymer [ All ] smoothness.gpu_rasterization.polymer/* [ Skip ] # Test needs to be modernized.
diff --git a/tools/perf/page_sets/data/rendering_desktop.json b/tools/perf/page_sets/data/rendering_desktop.json index 6942eff..1d58ccd 100644 --- a/tools/perf/page_sets/data/rendering_desktop.json +++ b/tools/perf/page_sets/data/rendering_desktop.json
@@ -107,6 +107,69 @@ }, "ie_chalkboard": { "DEFAULT": "tough_path_rendering_cases_002.wprgo" + }, + "geo_apis": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "hakim": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_tweet_map": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_video_city": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_worker_fountains": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_asteroid_belt": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_fireflies": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_fish_ie_tank": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_snow": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_speed_reading": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "jarro_doverson": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "mix_10k": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "runway": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "spielzeugz": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "man_in_blue": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "chip_tune": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "crafty_mind": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "effect_games": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "kevs_3d": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "megi_dish": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "smash_cat": { + "DEFAULT": "tough_canvas_cases_001.wprgo" } }, "description": "Describes the Web Page Replay archives for a story set. Don't edit by hand! Use record_wpr for updating.",
diff --git a/tools/perf/page_sets/data/rendering_mobile.json b/tools/perf/page_sets/data/rendering_mobile.json index d4f13592..7534fc1 100644 --- a/tools/perf/page_sets/data/rendering_mobile.json +++ b/tools/perf/page_sets/data/rendering_mobile.json
@@ -455,6 +455,69 @@ }, "ie_chalkboard": { "DEFAULT": "tough_path_rendering_cases_002.wprgo" + }, + "geo_apis": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "hakim": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_tweet_map": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_video_city": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_worker_fountains": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_asteroid_belt": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_fireflies": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_fish_ie_tank": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_snow": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "microsoft_speed_reading": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "jarro_doverson": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "mix_10k": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "runway": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "spielzeugz": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "man_in_blue": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "chip_tune": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "crafty_mind": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "effect_games": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "kevs_3d": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "megi_dish": { + "DEFAULT": "tough_canvas_cases_001.wprgo" + }, + "smash_cat": { + "DEFAULT": "tough_canvas_cases_001.wprgo" } }, "description": "Describes the Web Page Replay archives for a story set. Don't edit by hand! Use record_wpr for updating.",
diff --git a/tools/perf/page_sets/rendering/tough_canvas_cases.py b/tools/perf/page_sets/rendering/tough_canvas_cases.py new file mode 100644 index 0000000..aae1aeb --- /dev/null +++ b/tools/perf/page_sets/rendering/tough_canvas_cases.py
@@ -0,0 +1,281 @@ +# 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. +from telemetry import story +from telemetry.page import shared_page_state + +from page_sets.rendering import rendering_story + + +class ToughCanvasPage(rendering_story.RenderingStory): + ABSTRACT_STORY = True + + def __init__(self, + page_set, + shared_page_state_class=shared_page_state.SharedPageState, + name_suffix='', + extra_browser_args=None): + super(ToughCanvasPage, self).__init__( + page_set=page_set, + shared_page_state_class=shared_page_state_class, + name_suffix=name_suffix, + extra_browser_args=extra_browser_args) + + def RunNavigateSteps(self, action_runner): + super(ToughCanvasPage, self).RunNavigateSteps(action_runner) + action_runner.WaitForJavaScriptCondition( + "document.readyState == 'complete'") + + def RunPageInteractions(self, action_runner): + with action_runner.CreateInteraction('CanvasAnimation'): + action_runner.Wait(5) + + +class MicrosoftFirefliesPage(ToughCanvasPage): + BASE_NAME = 'microsoft_fireflies' + # pylint: disable=line-too-long + URL = 'http://ie.microsoft.com/testdrive/Performance/Fireflies/Default.html' + + +class GeoAPIsPage(ToughCanvasPage): + BASE_NAME = 'geo_apis' + URL = 'http://geoapis.appspot.com/agdnZW9hcGlzchMLEgtFeGFtcGxlQ29kZRjh1wIM' + + +class RunwayPage(ToughCanvasPage): + BASE_NAME = 'runway' + URL = 'http://runway.countlessprojects.com/prototype/performance_test.html' + + +class MicrosoftFishIETankPage(ToughCanvasPage): + BASE_NAME = 'microsoft_fish_ie_tank' + # pylint: disable=line-too-long + URL = 'http://ie.microsoft.com/testdrive/Performance/FishIETank/Default.html' + + +class MicrosoftSpeedReadingPage(ToughCanvasPage): + BASE_NAME = 'microsoft_speed_reading' + # pylint: disable=line-too-long + URL = 'http://ie.microsoft.com/testdrive/Performance/SpeedReading/Default.html' + + +class Kevs3DPage(ToughCanvasPage): + BASE_NAME = 'kevs_3d' + URL = 'http://www.kevs3d.co.uk/dev/canvask3d/k3d_test.html' + + +class MegiDishPage(ToughCanvasPage): + BASE_NAME = 'megi_dish' + URL = 'http://www.megidish.net/awjs/' + + +class ManInBluePage(ToughCanvasPage): + BASE_NAME = 'man_in_blue' + URL = 'http://themaninblue.com/experiment/AnimationBenchmark/canvas/' + + +class Mix10KPage(ToughCanvasPage): + BASE_NAME = 'mix_10k' + URL = 'http://mix10k.visitmix.com/Entry/Details/169' + + +class CraftyMindPage(ToughCanvasPage): + BASE_NAME = 'crafty_mind' + URL = 'http://www.craftymind.com/factory/guimark2/HTML5ChartingTest.html' + + +class ChipTunePage(ToughCanvasPage): + BASE_NAME = 'chip_tune' + URL = 'http://www.chiptune.com/starfield/starfield.html' + + +class JarroDoversonPage(ToughCanvasPage): + BASE_NAME = 'jarro_doverson' + URL = 'http://jarrodoverson.com/static/demos/particleSystem/' + + +class EffectGamesPage(ToughCanvasPage): + BASE_NAME = 'effect_games' + URL = 'http://www.effectgames.com/demos/canvascycle/' + + +class SpielzeugzPage(ToughCanvasPage): + BASE_NAME = 'spielzeugz' + URL = 'http://spielzeugz.de/html5/liquid-particles.html' + + +class HakimPage(ToughCanvasPage): + BASE_NAME = 'hakim' + URL = 'http://hakim.se/experiments/html5/magnetic/02/' + + +class MicrosoftSnowPage(ToughCanvasPage): + BASE_NAME = 'microsoft_snow' + URL = 'http://ie.microsoft.com/testdrive/Performance/LetItSnow/' + + +class MicrosoftWorkerFountainsPage(ToughCanvasPage): + BASE_NAME = 'microsoft_worker_fountains' + # pylint: disable=line-too-long + URL = 'http://ie.microsoft.com/testdrive/Graphics/WorkerFountains/Default.html' + + +class MicrosoftTweetMapPage(ToughCanvasPage): + BASE_NAME = 'microsoft_tweet_map' + URL = 'http://ie.microsoft.com/testdrive/Graphics/TweetMap/Default.html' + + +class MicrosoftVideoCityPage(ToughCanvasPage): + BASE_NAME = 'microsoft_video_city' + URL = 'http://ie.microsoft.com/testdrive/Graphics/VideoCity/Default.html' + + +class MicrosoftAsteroidBeltPage(ToughCanvasPage): + BASE_NAME = 'microsoft_asteroid_belt' + # pylint: disable=line-too-long + URL = 'http://ie.microsoft.com/testdrive/Performance/AsteroidBelt/Default.html' + + +class SmashCatPage(ToughCanvasPage): + BASE_NAME = 'smash_cat' + URL = 'http://www.smashcat.org/av/canvas_test/' + + +class BouncingBallsShadowPage(ToughCanvasPage): + BASE_NAME = 'bouncing_balls_shadow' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/canvas2d_balls_common/bouncing_balls.html?ball=image_with_shadow&back=image' + + +class BouncingBalls15Page(ToughCanvasPage): + BASE_NAME = 'bouncing_balls_15' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/canvas2d_balls_common/bouncing_balls.html?ball=text&back=white&ball_count=15' + + +class CanvasFontCyclerPage(ToughCanvasPage): + BASE_NAME = 'canvas_font_cycler' + URL = 'file://../tough_canvas_cases/canvas-font-cycler.html' + + +class CanvasAnimationNoClearPage(ToughCanvasPage): + BASE_NAME = 'canvas_animation_no_clear' + URL = 'file://../tough_canvas_cases/canvas-animation-no-clear.html' + + +class CanvasToBlobPage(ToughCanvasPage): + BASE_NAME = 'canvas_to_blob' + URL = 'file://../tough_canvas_cases/canvas_toBlob.html' + + +class ManyImagesPage(ToughCanvasPage): + BASE_NAME = 'many_images' + URL = 'file://../../../../chrome/test/data/perf/canvas_bench/many_images.html' + + +class CanvasArcPage(ToughCanvasPage): + BASE_NAME = 'canvas_arcs' + URL = 'file://../tough_canvas_cases/rendering_throughput/canvas_arcs.html' + + +class CanvasLinesPage(ToughCanvasPage): + BASE_NAME = 'canvas_lines' + URL = 'file://../tough_canvas_cases/rendering_throughput/canvas_lines.html' + + +class PutGetImageDataPage(ToughCanvasPage): + BASE_NAME = 'put_get_image_data' + URL = 'file://../tough_canvas_cases/rendering_throughput/put_get_image_data.html' + + +class FillShapesPage(ToughCanvasPage): + BASE_NAME = 'fill_shapes' + URL = 'file://../tough_canvas_cases/rendering_throughput/fill_shapes.html' + + +class StrokeShapesPage(ToughCanvasPage): + BASE_NAME = 'stroke_shapes' + URL = 'file://../tough_canvas_cases/rendering_throughput/stroke_shapes.html' + + +class BouncingClippedRectanglesPage(ToughCanvasPage): + BASE_NAME = 'bouncing_clipped_rectangles' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/rendering_throughput/bouncing_clipped_rectangles.html' + + +class BouncingGradientCirclesPage(ToughCanvasPage): + BASE_NAME = 'bouncing_gradient_circles' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/rendering_throughput/bouncing_gradient_circles.html' + + +class BouncingSVGImagesPage(ToughCanvasPage): + BASE_NAME = 'bouncing_svg_images' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/rendering_throughput/bouncing_svg_images.html' + + +class BouncingPNGImagesPage(ToughCanvasPage): + BASE_NAME = 'bouncing_png_images' + # pylint: disable=line-too-long + URL = 'file://../tough_canvas_cases/rendering_throughput/bouncing_png_images.html' + + +# TODO(crbug.com/760553):remove this class after smoothness.tough_canvas_cases +# benchmark is completely replaced by rendering benchmarks +class ToughCanvasCasesPageSet(story.StorySet): + + """ + Description: Self-driven Canvas2D animation examples + """ + + def __init__(self): + super(ToughCanvasCasesPageSet, self).__init__( + archive_data_file='../data/tough_canvas_cases.json', + cloud_storage_bucket=story.PARTNER_BUCKET) + + # Crashes on Galaxy Nexus. crbug.com/314131 + # TODO(rnephew): Rerecord this story. + # self.AddStory(MicrosofFirefliesPage(self)) + + page_classes = [ + GeoAPIsPage, + RunwayPage, + MicrosoftFishIETankPage, + MicrosoftSpeedReadingPage, + Kevs3DPage, + MegiDishPage, + ManInBluePage, + Mix10KPage, + CraftyMindPage, + ChipTunePage, + JarroDoversonPage, + EffectGamesPage, + SpielzeugzPage, + HakimPage, + MicrosoftSnowPage, + MicrosoftWorkerFountainsPage, + MicrosoftTweetMapPage, + MicrosoftVideoCityPage, + MicrosoftAsteroidBeltPage, + SmashCatPage, + BouncingBallsShadowPage, + BouncingBalls15Page, + CanvasFontCyclerPage, + CanvasAnimationNoClearPage, + CanvasToBlobPage, + ManyImagesPage, + CanvasArcPage, + CanvasLinesPage, + PutGetImageDataPage, + FillShapesPage, + StrokeShapesPage, + BouncingClippedRectanglesPage, + BouncingGradientCirclesPage, + BouncingSVGImagesPage, + BouncingPNGImagesPage + ] + + for page_class in page_classes: + self.AddStory(page_class(self))
diff --git a/tools/perf/page_sets/tough_canvas_cases.py b/tools/perf/page_sets/tough_canvas_cases.py deleted file mode 100644 index dc389bf..0000000 --- a/tools/perf/page_sets/tough_canvas_cases.py +++ /dev/null
@@ -1,134 +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. -from telemetry.page import page as page_module -from telemetry import story - - -class ToughCanvasCasesPage(page_module.Page): - - def __init__(self, name, url, page_set): - super(ToughCanvasCasesPage, self).__init__(url=url, page_set=page_set, - name=name) - - def RunNavigateSteps(self, action_runner): - super(ToughCanvasCasesPage, self).RunNavigateSteps(action_runner) - action_runner.WaitForJavaScriptCondition( - "document.readyState == 'complete'") - - def RunPageInteractions(self, action_runner): - with action_runner.CreateInteraction('CanvasAnimation'): - action_runner.Wait(5) - - -class MicrosofFirefliesPage(ToughCanvasCasesPage): - - def __init__(self, page_set): - super(MicrosofFirefliesPage, self).__init__( - name='microsoft_fireflies', - # pylint: disable=line-too-long - url='http://ie.microsoft.com/testdrive/Performance/Fireflies/Default.html', - page_set=page_set) - - -class ToughCanvasCasesPageSet(story.StorySet): - - """ - Description: Self-driven Canvas2D animation examples - """ - - def __init__(self): - super(ToughCanvasCasesPageSet, self).__init__( - archive_data_file='data/tough_canvas_cases.json', - cloud_storage_bucket=story.PARTNER_BUCKET) - - # Crashes on Galaxy Nexus. crbug.com/314131 - # TODO(rnephew): Rerecord this story. - # self.AddStory(MicrosofFirefliesPage(self)) - - urls_list = [ - ('geo_apis', - 'http://geoapis.appspot.com/agdnZW9hcGlzchMLEgtFeGFtcGxlQ29kZRjh1wIM'), - ('runway', - 'http://runway.countlessprojects.com/prototype/performance_test.html'), - ('microsoft_fish_ie_tank', - # pylint: disable=line-too-long - 'http://ie.microsoft.com/testdrive/Performance/FishIETank/Default.html'), - ('microsoft_speed_reading', - # pylint: disable=line-too-long - 'http://ie.microsoft.com/testdrive/Performance/SpeedReading/Default.html'), - ('kevs_3d', - 'http://www.kevs3d.co.uk/dev/canvask3d/k3d_test.html'), - ('megi_dish', - 'http://www.megidish.net/awjs/'), - ('man_in_blue', - 'http://themaninblue.com/experiment/AnimationBenchmark/canvas/'), - ('mix_10k', - 'http://mix10k.visitmix.com/Entry/Details/169'), - ('crafty_mind', - 'http://www.craftymind.com/factory/guimark2/HTML5ChartingTest.html'), - ('chip_tune', - 'http://www.chiptune.com/starfield/starfield.html'), - ('jarro_doverson', - 'http://jarrodoverson.com/static/demos/particleSystem/'), - ('effect_games', - 'http://www.effectgames.com/demos/canvascycle/'), - ('spielzeugz', - 'http://spielzeugz.de/html5/liquid-particles.html'), - ('hakim', - 'http://hakim.se/experiments/html5/magnetic/02/'), - ('microsoft_snow', - 'http://ie.microsoft.com/testdrive/Performance/LetItSnow/'), - ('microsoft_worker_fountains', - # pylint: disable=line-too-long - 'http://ie.microsoft.com/testdrive/Graphics/WorkerFountains/Default.html'), - ('microsoft_tweet_map', - 'http://ie.microsoft.com/testdrive/Graphics/TweetMap/Default.html'), - ('microsoft_video_city', - 'http://ie.microsoft.com/testdrive/Graphics/VideoCity/Default.html'), - ('microsoft_asteroid_belt', - # pylint: disable=line-too-long - 'http://ie.microsoft.com/testdrive/Performance/AsteroidBelt/Default.html'), - ('smash_cat', - 'http://www.smashcat.org/av/canvas_test/'), - ('bouncing_balls_shadow', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/canvas2d_balls_common/bouncing_balls.html?ball=image_with_shadow&back=image'), - ('bouncing_balls_15', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/canvas2d_balls_common/bouncing_balls.html?ball=text&back=white&ball_count=15'), - ('canvas_font_cycler', - 'file://tough_canvas_cases/canvas-font-cycler.html'), - ('canvas_animation_no_clear', - 'file://tough_canvas_cases/canvas-animation-no-clear.html'), - ('canvas_to_blob', - 'file://tough_canvas_cases/canvas_toBlob.html'), - ('many_images', - # pylint: disable=line-too-long - 'file://../../../chrome/test/data/perf/canvas_bench/many_images.html'), - ('canvas_arcs', - 'file://tough_canvas_cases/rendering_throughput/canvas_arcs.html'), - ('canvas_lines', - 'file://tough_canvas_cases/rendering_throughput/canvas_lines.html'), - ('put_get_image_data', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/rendering_throughput/put_get_image_data.html'), - ('fill_shapes', - 'file://tough_canvas_cases/rendering_throughput/fill_shapes.html'), - ('stroke_shapes', - 'file://tough_canvas_cases/rendering_throughput/stroke_shapes.html'), - ('bouncing_clipped_rectangles', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/rendering_throughput/bouncing_clipped_rectangles.html'), - ('bouncing_gradient_circles', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/rendering_throughput/bouncing_gradient_circles.html'), - ('bouncing_svg_images', - # pylint: disable=line-too-long - 'file://tough_canvas_cases/rendering_throughput/bouncing_svg_images.html'), - ('bouncing_png_images', - 'file://tough_canvas_cases/rendering_throughput/bouncing_png_images.html') - ] - - for name, url in urls_list: - self.AddStory(ToughCanvasCasesPage(name=name,url=url,page_set=self))
diff --git a/tools/xdisplaycheck/BUILD.gn b/tools/xdisplaycheck/BUILD.gn index 064305aa..717c31a 100644 --- a/tools/xdisplaycheck/BUILD.gn +++ b/tools/xdisplaycheck/BUILD.gn
@@ -8,8 +8,4 @@ ] configs += [ "//build/config/linux:x11" ] - - deps = [ - "//build/config:exe_and_shlib_deps", - ] }
diff --git a/ui/accessibility/ax_tree_serializer.h b/ui/accessibility/ax_tree_serializer.h index c7000b6..b97ad76 100644 --- a/ui/accessibility/ax_tree_serializer.h +++ b/ui/accessibility/ax_tree_serializer.h
@@ -76,23 +76,10 @@ max_node_count_ = max_node_count; } - // Serialize a sequence of one or more changes. This is more efficient - // than calling SerializeChanges more than once with the same output - // AXTreeUpdate; it will automatically avoid serializing the same - // node more than once when there are overlapping changes. - // It's an error to call DeleteClientSubtree in the middle of a sequence. - void BeginSerializingChanges( - AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update); - bool SerializeOneChange(AXSourceNode node); - void FinishSerializingChanges(); - // Serialize all changes to |node| and append them to |out_update|. // Returns true on success. On failure, returns false and calls Reset(); // this only happens when the source tree has a problem like duplicate - // ids or changing during serialization. Note that it's more efficient - // to use BeginSerializingChanges, SerializeOneChange, and - // FinishSerializingChanges if you're going to include more than one - // change in the same output AXTreeUpdate. + // ids or changing during serialization. bool SerializeChanges(AXSourceNode node, AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update); @@ -165,7 +152,9 @@ void DeleteClientSubtree(ClientTreeNode* client_node); // Helper function, called recursively with each new node to serialize. - bool SerializeChangedNodes(AXSourceNode node); + bool SerializeChangedNodes( + AXSourceNode node, + AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update); // Visit all of the descendants of |node| once. void WalkAllDescendants(AXSourceNode node); @@ -182,14 +171,6 @@ // A map from IDs to nodes in the client tree. base::hash_map<int32_t, ClientTreeNode*> client_id_map_; - // The current update, valid in-between calls to BeginSerializingChanges - // and FinishSerializingChanges. - AXTreeUpdateBase<AXNodeData, AXTreeData>* current_update_ = nullptr; - - // The set of IDs already serialized, valid in-between calls to - // BeginSerializingChanges and FinishSerializingChanges. - std::set<int32_t> already_serialized_ids_; - // The maximum number of nodes to serialize in a given call to // SerializeChanges, or 0 if there's no maximum. size_t max_node_count_ = 0; @@ -339,25 +320,16 @@ } template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> -void AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>:: - BeginSerializingChanges( - AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update) { - CHECK(!current_update_); - current_update_ = out_update; -} - -template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> -bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::SerializeOneChange( - AXSourceNode node) { - CHECK(current_update_); - +bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::SerializeChanges( + AXSourceNode node, + AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update) { // Send the tree data if it's changed since the last update, or if - // current_update_->has_tree_data is already set to true. + // out_update->has_tree_data is already set to true. AXTreeData new_tree_data; if (tree_->GetTreeData(&new_tree_data) && - (current_update_->has_tree_data || new_tree_data != client_tree_data_)) { - current_update_->has_tree_data = true; - current_update_->tree_data = new_tree_data; + (out_update->has_tree_data || new_tree_data != client_tree_data_)) { + out_update->has_tree_data = true; + out_update->tree_data = new_tree_data; client_tree_data_ = new_tree_data; } @@ -385,13 +357,13 @@ if (!tree_->IsValid(lca)) { // If there's no LCA, just tell the client to destroy the whole // tree and then we'll serialize everything from the new root. - current_update_->node_id_to_clear = client_root_->id; + out_update->node_id_to_clear = client_root_->id; Reset(); } else if (need_delete) { // Otherwise, if we need to reserialize a subtree, first we need // to delete those nodes in our client tree so that // SerializeChangedNodes() will be sure to send them again. - current_update_->node_id_to_clear = tree_->GetId(lca); + out_update->node_id_to_clear = tree_->GetId(lca); ClientTreeNode* client_lca = ClientTreeNodeById(tree_->GetId(lca)); CHECK(client_lca); DeleteClientSubtree(client_lca); @@ -409,34 +381,13 @@ // DumpAccessibilityTreeTest.AccessibilityAriaOwns. WalkAllDescendants(lca); - return SerializeChangedNodes(lca); -} - -template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> -void AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>:: - FinishSerializingChanges() { - CHECK(current_update_); - current_update_ = nullptr; - already_serialized_ids_.clear(); -} - -template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> -bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::SerializeChanges( - AXSourceNode node, - AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update) { - CHECK(!current_update_); - BeginSerializingChanges(out_update); - bool success = SerializeOneChange(node); - FinishSerializingChanges(); - return success; + return SerializeChangedNodes(lca, out_update); } template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> void AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::DeleteClientSubtree(AXSourceNode node) { - CHECK(!current_update_); - ClientTreeNode* client_node = ClientTreeNodeById(tree_->GetId(node)); if (client_node) DeleteClientSubtree(client_node); @@ -455,7 +406,9 @@ template <typename AXSourceNode, typename AXNodeData, typename AXTreeData> bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>:: - SerializeChangedNodes(AXSourceNode node) { + SerializeChangedNodes( + AXSourceNode node, + AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update) { // This method has three responsibilities: // 1. Serialize |node| into an AXNodeData, and append it to // the AXTreeUpdate to be sent to the client. @@ -469,10 +422,6 @@ // about. If we don't find it, then this must be the new root of the // accessibility tree. int id = tree_->GetId(node); - if (already_serialized_ids_.find(id) != already_serialized_ids_.end()) - return true; - already_serialized_ids_.insert(id); - ClientTreeNode* client_node = ClientTreeNodeById(id); if (!client_node) { Reset(); @@ -491,7 +440,7 @@ // consistent results. base::hash_set<int32_t> new_child_ids; std::vector<AXSourceNode> children; - if (max_node_count_ == 0 || current_update_->nodes.size() < max_node_count_) { + if (max_node_count_ == 0 || out_update->nodes.size() < max_node_count_) { tree_->GetChildren(node, &children); } else if (max_node_count_ > 0) { static bool logged_once = false; @@ -538,18 +487,17 @@ // Serialize this node. This fills in all of the fields in // AXNodeData except child_ids, which we handle below. - size_t serialized_node_index = current_update_->nodes.size(); - current_update_->nodes.push_back(AXNodeData()); + size_t serialized_node_index = out_update->nodes.size(); + out_update->nodes.push_back(AXNodeData()); { // Take the address of an element in a vector only within a limited // scope because otherwise the pointer can become invalid if the // vector is resized. - AXNodeData* serialized_node = - ¤t_update_->nodes[serialized_node_index]; + AXNodeData* serialized_node = &out_update->nodes[serialized_node_index]; tree_->SerializeNode(node, serialized_node); if (serialized_node->id == client_root_->id) - current_update_->root_id = serialized_node->id; + out_update->root_id = serialized_node->id; } // Iterate over the children, serialize them, and update the ClientTreeNode @@ -579,14 +527,14 @@ new_child->parent = client_node; client_node->children.push_back(new_child); client_id_map_[child_id] = new_child; - if (!SerializeChangedNodes(child)) + if (!SerializeChangedNodes(child, out_update)) return false; } } // Finally, update the child ids of this node to reflect the actual child // ids that were valid during serialization. - current_update_->nodes[serialized_node_index].child_ids.swap( + out_update->nodes[serialized_node_index].child_ids.swap( actual_serialized_node_child_ids); return true;
diff --git a/ui/accessibility/ax_tree_serializer_unittest.cc b/ui/accessibility/ax_tree_serializer_unittest.cc index 09c68e8..2596278 100644 --- a/ui/accessibility/ax_tree_serializer_unittest.cc +++ b/ui/accessibility/ax_tree_serializer_unittest.cc
@@ -11,7 +11,6 @@ #include "base/macros.h" #include "base/strings/string_number_conversions.h" -#include "testing/gtest/include/gtest/gtest-death-test.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_serializable_tree.h" @@ -344,96 +343,4 @@ ASSERT_EQ(static_cast<size_t>(5), update.nodes.size()); } -TEST_F(AXTreeSerializerTest, SerializeOneChangeDeathTest) { - treedata0_.root_id = 1; - treedata0_.nodes.resize(1); - treedata0_.nodes[0].id = 1; - - treedata1_.root_id = 1; - treedata1_.nodes.resize(1); - treedata1_.nodes[0].id = 1; - - CreateTreeSerializer(); - - // It's not legal to call SerializeOneChange without calling - // BeginSerializingChanges first. - ASSERT_DEATH_IF_SUPPORTED( - { serializer_->SerializeOneChange(tree1_->GetFromId(1)); }, ".*"); -} - -TEST_F(AXTreeSerializerTest, DeleteClientSubtreeDeathTest) { - treedata0_.root_id = 1; - treedata0_.nodes.resize(1); - treedata0_.nodes[0].id = 1; - - treedata1_.root_id = 1; - treedata1_.nodes.resize(1); - treedata1_.nodes[0].id = 1; - - CreateTreeSerializer(); - - // It's not legal to call DeleteClientSubtree in the middle of a - // serialization sequence. - AXTreeUpdate update; - serializer_->BeginSerializingChanges(&update); - ASSERT_DEATH_IF_SUPPORTED( - { serializer_->DeleteClientSubtree(tree1_->GetFromId(1)); }, ".*"); -} - -TEST_F(AXTreeSerializerTest, BeginSerializingChangesTwiceDeathTest) { - treedata0_.root_id = 1; - treedata0_.nodes.resize(1); - treedata0_.nodes[0].id = 1; - - treedata1_.root_id = 1; - treedata1_.nodes.resize(1); - treedata1_.nodes[0].id = 1; - - CreateTreeSerializer(); - - AXTreeUpdate update; - serializer_->BeginSerializingChanges(&update); - ASSERT_DEATH_IF_SUPPORTED({ serializer_->BeginSerializingChanges(&update); }, - ".*"); -} - -TEST_F(AXTreeSerializerTest, SerializationSequence) { - // (1 (2 3)) - treedata0_.root_id = 1; - treedata0_.nodes.resize(3); - treedata0_.nodes[0].id = 1; - treedata0_.nodes[0].child_ids.push_back(2); - treedata0_.nodes[0].child_ids.push_back(3); - treedata0_.nodes[1].id = 2; - treedata0_.nodes[2].id = 3; - - // (1 (4 2 3)) - treedata1_.root_id = 1; - treedata1_.nodes.resize(4); - treedata1_.nodes[0].id = 1; - treedata1_.nodes[0].child_ids.push_back(4); - treedata1_.nodes[0].child_ids.push_back(2); - treedata1_.nodes[0].child_ids.push_back(3); - treedata1_.nodes[1].id = 2; - treedata1_.nodes[2].id = 3; - treedata1_.nodes[3].id = 4; - - CreateTreeSerializer(); - AXTreeUpdate update; - serializer_->BeginSerializingChanges(&update); - EXPECT_EQ(0U, update.nodes.size()); - ASSERT_TRUE(serializer_->SerializeOneChange(tree1_->GetFromId(1))); - EXPECT_EQ(2U, update.nodes.size()); - - // If we serialize the same node again, nothing should happen. - ASSERT_TRUE(serializer_->SerializeOneChange(tree1_->GetFromId(1))); - EXPECT_EQ(2U, update.nodes.size()); - - // If we serialize a different node, we should get it serialized. - ASSERT_TRUE(serializer_->SerializeOneChange(tree1_->GetFromId(2))); - EXPECT_EQ(3U, update.nodes.size()); - - serializer_->FinishSerializingChanges(); -} - } // namespace ui
diff --git a/ui/android/BUILD.gn b/ui/android/BUILD.gn index 2f80c4e..c57c74f 100644 --- a/ui/android/BUILD.gn +++ b/ui/android/BUILD.gn
@@ -23,6 +23,8 @@ "edge_effect_l.h", "event_forwarder.cc", "event_forwarder.h", + "handle_view_resources.cc", + "handle_view_resources.h", "overscroll_glow.cc", "overscroll_glow.h", "overscroll_refresh.cc", @@ -69,6 +71,7 @@ "//ui/events/devices", "//ui/gfx", "//ui/gfx/geometry", + "//ui/touch_selection", "//url", ] } @@ -93,6 +96,7 @@ "java/src/org/chromium/ui/base/ViewAndroidDelegate.java", "java/src/org/chromium/ui/base/WindowAndroid.java", "java/src/org/chromium/ui/display/DisplayAndroidManager.java", + "java/src/org/chromium/ui/resources/HandleViewResources.java", "java/src/org/chromium/ui/resources/ResourceFactory.java", "java/src/org/chromium/ui/resources/ResourceManager.java", ] @@ -229,6 +233,7 @@ "java/src/org/chromium/ui/gl/SurfaceTextureListener.java", "java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java", "java/src/org/chromium/ui/interpolators/BakedBezierInterpolator.java", + "java/src/org/chromium/ui/resources/HandleViewResources.java", "java/src/org/chromium/ui/resources/LayoutResource.java", "java/src/org/chromium/ui/resources/Resource.java", "java/src/org/chromium/ui/resources/ResourceFactory.java",
diff --git a/ui/android/DEPS b/ui/android/DEPS index 55fec7913..7a34e43 100644 --- a/ui/android/DEPS +++ b/ui/android/DEPS
@@ -20,6 +20,7 @@ "+ui/display", "+ui/events", "+ui/gfx", + "+ui/touch_selection/touch_handle.h", ] specific_include_rules = {
diff --git a/ui/android/handle_view_resources.cc b/ui/android/handle_view_resources.cc new file mode 100644 index 0000000..3214121 --- /dev/null +++ b/ui/android/handle_view_resources.cc
@@ -0,0 +1,70 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/android/handle_view_resources.h" + +#include "base/trace_event/trace_event.h" +#include "jni/HandleViewResources_jni.h" + +namespace { + +static SkBitmap CreateSkBitmapFromJavaBitmap( + base::android::ScopedJavaLocalRef<jobject> jbitmap) { + return jbitmap.is_null() + ? SkBitmap() + : CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(jbitmap)); +} + +} // namespace + +namespace ui { + +HandleViewResources::HandleViewResources() {} + +void HandleViewResources::LoadIfNecessary(const JavaRef<jobject>& context) { + if (loaded_) + return; + + loaded_ = true; + + TRACE_EVENT0("ui", "HandleViewResources::Create"); + JNIEnv* env = base::android::AttachCurrentThread(); + + left_bitmap_ = CreateSkBitmapFromJavaBitmap( + Java_HandleViewResources_getLeftHandleBitmap(env, context)); + right_bitmap_ = CreateSkBitmapFromJavaBitmap( + Java_HandleViewResources_getRightHandleBitmap(env, context)); + center_bitmap_ = CreateSkBitmapFromJavaBitmap( + Java_HandleViewResources_getCenterHandleBitmap(env, context)); + + left_bitmap_.setImmutable(); + right_bitmap_.setImmutable(); + center_bitmap_.setImmutable(); + + drawable_horizontal_padding_ratio_ = + Java_HandleViewResources_getHandleHorizontalPaddingRatio(env); +} + +const SkBitmap& HandleViewResources::GetBitmap( + ui::TouchHandleOrientation orientation) { + DCHECK(loaded_); + switch (orientation) { + case ui::TouchHandleOrientation::LEFT: + return left_bitmap_; + case ui::TouchHandleOrientation::RIGHT: + return right_bitmap_; + case ui::TouchHandleOrientation::CENTER: + return center_bitmap_; + case ui::TouchHandleOrientation::UNDEFINED: + NOTREACHED() << "Invalid touch handle orientation."; + }; + return center_bitmap_; +} + +float HandleViewResources::GetDrawableHorizontalPaddingRatio() const { + DCHECK(loaded_); + return drawable_horizontal_padding_ratio_; +} + +} // namespace ui
diff --git a/ui/android/handle_view_resources.h b/ui/android/handle_view_resources.h new file mode 100644 index 0000000..2848434 --- /dev/null +++ b/ui/android/handle_view_resources.h
@@ -0,0 +1,39 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_ANDROID_HANDLE_VIEW_RESOURCES_H_ +#define UI_ANDROID_HANDLE_VIEW_RESOURCES_H_ + +#include "base/android/jni_android.h" +#include "base/android/scoped_java_ref.h" +#include "base/macros.h" +#include "ui/android/ui_android_export.h" +#include "ui/gfx/android/java_bitmap.h" +#include "ui/touch_selection/touch_handle.h" + +using base::android::JavaRef; + +namespace ui { + +// Bridge to Java bitmap resources for selection handle. +class UI_ANDROID_EXPORT HandleViewResources { + public: + HandleViewResources(); + void LoadIfNecessary(const JavaRef<jobject>& context); + const SkBitmap& GetBitmap(ui::TouchHandleOrientation orientation); + float GetDrawableHorizontalPaddingRatio() const; + + private: + SkBitmap left_bitmap_; + SkBitmap right_bitmap_; + SkBitmap center_bitmap_; + float drawable_horizontal_padding_ratio_; + bool loaded_ = false; + + DISALLOW_COPY_AND_ASSIGN(HandleViewResources); +}; + +} // namespace ui + +#endif // UI_ANDROID_HANDLE_VIEW_RESOURCES_H_
diff --git a/content/public/android/java/src/org/chromium/content/browser/selection/HandleViewResources.java b/ui/android/java/src/org/chromium/ui/resources/HandleViewResources.java similarity index 95% rename from content/public/android/java/src/org/chromium/content/browser/selection/HandleViewResources.java rename to ui/android/java/src/org/chromium/ui/resources/HandleViewResources.java index a1e2b93..dff7f368 100644 --- a/content/public/android/java/src/org/chromium/content/browser/selection/HandleViewResources.java +++ b/ui/android/java/src/org/chromium/ui/resources/HandleViewResources.java
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.content.browser.selection; +package org.chromium.ui.resources; import android.content.Context; import android.content.res.Resources; @@ -20,7 +20,7 @@ /** * Helper class for retrieving resources related to selection handles. */ -@JNINamespace("content") +@JNINamespace("ui") public class HandleViewResources { // Android handle drawables have a transparent horizontal padding, // which is one-fourth of the image. This variable is to take the @@ -28,15 +28,15 @@ private static final float HANDLE_HORIZONTAL_PADDING_RATIO = 0.25f; private static final int[] LEFT_HANDLE_ATTRS = { - android.R.attr.textSelectHandleLeft, + android.R.attr.textSelectHandleLeft, }; private static final int[] CENTER_HANDLE_ATTRS = { - android.R.attr.textSelectHandle, + android.R.attr.textSelectHandle, }; private static final int[] RIGHT_HANDLE_ATTRS = { - android.R.attr.textSelectHandleRight, + android.R.attr.textSelectHandleRight, }; public static Drawable getLeftHandleDrawable(Context context) {
diff --git a/ui/app_list/BUILD.gn b/ui/app_list/BUILD.gn index 5e64535..a971d104 100644 --- a/ui/app_list/BUILD.gn +++ b/ui/app_list/BUILD.gn
@@ -168,7 +168,6 @@ ":app_list", ":test_support", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//content", "//content/public/browser",
diff --git a/ui/app_list/views/search_result_tile_item_view.cc b/ui/app_list/views/search_result_tile_item_view.cc index 9dccf48..9074b17f 100644 --- a/ui/app_list/views/search_result_tile_item_view.cc +++ b/ui/app_list/views/search_result_tile_item_view.cc
@@ -396,7 +396,10 @@ } void SearchResultTileItemView::SetIcon(const gfx::ImageSkia& icon) { - icon_->SetImage(icon); + gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage( + icon, skia::ImageOperations::RESIZE_BEST, + gfx::Size(kTileIconSize, kTileIconSize))); + icon_->SetImage(resized); } void SearchResultTileItemView::SetBadgeIcon(const gfx::ImageSkia& badge_icon) {
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn index 426d1f82..10fd7ce 100644 --- a/ui/aura/BUILD.gn +++ b/ui/aura/BUILD.gn
@@ -343,7 +343,6 @@ ":test_support", "//base", "//base:i18n", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//components/viz/host", "//skia",
diff --git a/ui/display/manager/display_util.cc b/ui/display/manager/display_util.cc index 84e13048..a8a5247 100644 --- a/ui/display/manager/display_util.cc +++ b/ui/display/manager/display_util.cc
@@ -6,6 +6,7 @@ #include <stddef.h> #include <algorithm> +#include <cmath> #include "base/logging.h" #include "base/strings/string_number_conversions.h" @@ -16,44 +17,38 @@ namespace display { namespace { -// The maximum logical resolution width allowed when zooming out for a display. -constexpr int kDefaultMaxZoomWidth = 4096; - -// The minimum logical resolution width allowed when zooming in for a display. -constexpr int kDefaultMinZoomWidth = 640; - // The total number of display zoom factors to enumerate. constexpr int kNumOfZoomFactors = 9; +// A pair representing the list of zoom values for a given minimum display +// resolution width. +using ZoomListBucket = std::pair<int, std::array<float, kNumOfZoomFactors>>; + +// For displays with a device scale factor of unity, we use a static list of +// initialized zoom values. For a given resolution width of a display, we can +// find its associated list of zoom values by simply finding the last bucket +// with a width less than the given resolution width. +// Ex. A resolution width of 1024, we will use the bucket with the width of 960. +constexpr std::array<ZoomListBucket, 8> kZoomListBuckets{{ + {0, {0.60f, 0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f}}, + {720, {0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f, 1.10f}}, + {800, {0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f, 1.10f, 1.15f}}, + {960, {0.90f, 0.95f, 1.f, 1.05f, 1.10f, 1.15f, 1.20f, 1.25f, 1.30f}}, + {1280, {1.f, 1.10f, 1.15f, 1.20f, 1.25f, 1.30f, 1.50f, 1.70f, 1.80f}}, + {1920, {1.f, 1.10f, 1.15f, 1.20f, 1.30f, 1.40f, 1.50f, 1.75f, 2.00f}}, + {3840, {1.f, 1.10f, 1.20f, 1.40f, 1.60f, 1.80f, 2.00f, 2.20f, 2.40f}}, + {5120, {1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f, 3.00f}}, +}}; + bool WithinEpsilon(float a, float b) { return std::abs(a - b) < std::numeric_limits<float>::epsilon(); } -// Clamps the delta between consecutive zoom factors to a user friendly and UI -// friendly value. -float ClampToUserFriendlyDelta(float delta) { - // NOTE: If these thresholds are updated, please also update aura-shell.xml. - // The list of deltas between two consecutive zoom level. Any display must - // have one of these values as the difference between two consecutive zoom - // level. - // The array of pair represents which user friendly delta value must the given - // raw |delta| be clamped to. - // std::pair::first - represents the threshold. - // std::pair::second - represents the user friendly clamped delta - constexpr std::array<std::pair<float, float>, 7> kZoomFactorDeltas = { - {{0.05f, 0.05f}, - {0.1f, 0.1f}, - {0.15f, 0.15f}, - {0.2f, 0.2f}, - {0.25f, 0.25f}, - {0.7f, 0.3f}, - {1.f, 0.5f}}}; - std::size_t delta_index = 0; - while (delta_index < kZoomFactorDeltas.size() && - delta >= kZoomFactorDeltas[delta_index].first) { - delta_index++; - } - return kZoomFactorDeltas[delta_index - 1].second; +// Returns the user friendly delta to be used for the given |dsf|. +float FindDeltaForDsf(float dsf) { + DCHECK_GT(dsf, 1.f); + const float raw_delta = (1.f - 1.f / dsf) / (kNumOfZoomFactors - 1.f); + return raw_delta > 0.05f ? 0.1f : 0.05f; } } // namespace @@ -117,59 +112,60 @@ } std::vector<float> GetDisplayZoomFactors(const ManagedDisplayMode& mode) { + // Internal displays have an internal device scale factor greater than 1 + // associated with them. This means that if we use the usual logic, we would + // end up with a list of zoom levels that the user may not find very useful. + // Take for example the pixelbook with device scale factor of 2. Based on the + // usual approach, we would get a zoom range of 100% to 180% with a step of + // 10% between each consecutive levels. This means: + // 1. Users will not be able to go to the native resolution which is + // achieved at 50% zoom level. + // 2. Due to the device scale factor, the display already has a low DPI and + // users dont want to zoom in, they mostly want to zoom out and add more + // pixels to the screen. But we only provide a zoom list of 90% to 130%. + // This clearly shows we need a different logic to handle internal displays + // which have lower DPI due to the device scale factor associated with them. + // + // OTOH if we look at an external display with a device scale factor of 1 but + // the same resolution as the pixel book, the DPI would usually be very high + // and users mostly want to zoom in to reduce the number of pixels on the + // screen. So having a range of 90% to 130% makes sense. + // TODO(malaykeshav): Investigate if we can use DPI instead of resolution or + // device scale factor to decide the list of zoom levels. + if (mode.device_scale_factor() > 1.f) + return GetDisplayZoomFactorForDsf(mode.device_scale_factor()); + + // There may be cases where the device scale factor is less than 1. This can + // happen during testing or local linux builds. const int effective_width = std::round( static_cast<float>(mode.size().width()) / mode.device_scale_factor()); - // We want to support displays greater than 4K. This is added to ensure the - // zoom does not break in such cases. - const int max_width = std::max(effective_width, kDefaultMaxZoomWidth); - const int min_width = std::min(effective_width, kDefaultMinZoomWidth); + std::size_t index = kZoomListBuckets.size() - 1; + while (index > 0 && effective_width < kZoomListBuckets[index].first) + index--; + DCHECK_GE(effective_width, kZoomListBuckets[index].first); - // The logical resolution will vary from half of the mode resolution to double - // the mode resolution. - int max_effective_width = - std::min(static_cast<int>(std::round(effective_width * 2.f)), max_width); - int min_effective_width = - std::max(static_cast<int>(std::round(effective_width / 2.f)), min_width); + const auto& zoom_array = kZoomListBuckets[index].second; + return std::vector<float>(zoom_array.begin(), zoom_array.end()); +} - // If either the maximum width or minimum width was reached in the above step - // and clamping was performed, then update the total range of logical - // resolutions and ensure that everything lies within the maximum and minimum - // resolution range. - const int interval = std::round(static_cast<float>(effective_width) * 1.5f); - if (max_effective_width == max_width) - min_effective_width = std::max(max_effective_width - interval, min_width); - if (min_effective_width == min_width) - max_effective_width = std::min(min_effective_width + interval, max_width); +std::vector<float> GetDisplayZoomFactorForDsf(float dsf) { + DCHECK(!WithinEpsilon(dsf, 1.f)); + DCHECK_GT(dsf, 1.f); - float max_zoom = static_cast<float>(effective_width) / - static_cast<float>(min_effective_width); - float min_zoom = static_cast<float>(effective_width) / - static_cast<float>(max_effective_width); + const float delta = FindDeltaForDsf(dsf); + const float inverse_dsf = 1.f / dsf; + int zoom_out_count = std::ceil((1.f - inverse_dsf) / delta); + zoom_out_count = std::min(zoom_out_count, kNumOfZoomFactors - 1); - float delta = - (max_zoom - min_zoom) / static_cast<float>(kNumOfZoomFactors - 1); + const float min_zoom = 1.f - delta * zoom_out_count; - // Number of zoom values above 100% zoom. - const int zoom_in_count = std::round((max_zoom - 1.f) / delta); - - // Number of zoom values below 100% zoom. - const int zoom_out_count = kNumOfZoomFactors - zoom_in_count - 1; - - delta = ClampToUserFriendlyDelta(delta); - - // Populate the zoom values list. - min_zoom = 1.f - delta * zoom_out_count; std::vector<float> zoom_values; for (int i = 0; i < kNumOfZoomFactors; i++) zoom_values.push_back(min_zoom + i * delta); - // Make sure the inverse of the internal device scale factor is included in - // the list. This ensures that the users have a way to go to the native - // resolution and 1.0 effective device scale factor. - InsertDsfIntoList(&zoom_values, 1.f / mode.device_scale_factor()); - - DCHECK_EQ(zoom_values.size(), static_cast<std::size_t>(kNumOfZoomFactors)); + // Ensure the inverse dsf is in the list. + zoom_values[0] = inverse_dsf; return zoom_values; } @@ -194,7 +190,7 @@ // We dont need to add |dsf| to the list if it is already in the list. auto it = std::lower_bound(zoom_values->begin(), zoom_values->end(), dsf); - if (WithinEpsilon(*it, dsf)) + if (it != zoom_values->end() && WithinEpsilon(*it, dsf)) return; if (it == zoom_values->begin()) {
diff --git a/ui/display/manager/display_util.h b/ui/display/manager/display_util.h index af9c2da..6c0da7c 100644 --- a/ui/display/manager/display_util.h +++ b/ui/display/manager/display_util.h
@@ -40,6 +40,11 @@ std::vector<float> DISPLAY_MANAGER_EXPORT GetDisplayZoomFactors(const ManagedDisplayMode& mode); +// Returns a list of display zooms based on the provided |dsf| of the display. +// This is useful for displays that have a non unity device scale factors +// applied to them. +std::vector<float> DISPLAY_MANAGER_EXPORT GetDisplayZoomFactorForDsf(float dsf); + // This function adds |dsf| to the vector of |zoom_values| by replacing // the element it is closest to in the list. It also ensures that it never // replaces the default zoom value of 1.0 from the list and that the size of the
diff --git a/ui/display/manager/display_utils_unittest.cc b/ui/display/manager/display_utils_unittest.cc index ec97fdc..b016a6d7 100644 --- a/ui/display/manager/display_utils_unittest.cc +++ b/ui/display/manager/display_utils_unittest.cc
@@ -16,127 +16,43 @@ namespace { constexpr std::size_t kNumOfZoomFactors = 9; -constexpr int kDefaultMaxZoomWidth = 4096; -constexpr int kDefaultMinZoomWidth = 640; - -// Returns true if |a| and |b| are equal within the error limits. -bool WithinEpsilon(float a, float b) { - return std::abs(a - b) < std::numeric_limits<float>::epsilon(); -} +using ZoomListBucket = std::pair<int, std::array<float, kNumOfZoomFactors>>; } // namespace using DisplayUtilTest = testing::Test; TEST_F(DisplayUtilTest, DisplayZooms) { - // A vector of pairs where each pair is the resolution width correspoinding - // to its list of available display zoom values. - const std::vector<std::pair<int, std::vector<float>>> expected_zoom_values{ - {480, {0.60f, 0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f}}, - {640, {0.60f, 0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f}}, - {720, {0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f}}, - {800, {0.40f, 0.50f, 0.60f, 0.70f, 0.80f, 0.90f, 1.f, 1.10f, 1.20f}}, - {960, {0.60f, 0.70f, 0.80f, 0.90f, 1.f, 1.10f, 1.20f, 1.30f, 1.40f}}, - {1024, {0.60f, 0.70f, 0.80f, 0.90f, 1.f, 1.10f, 1.20f, 1.30f, 1.40f}}, - {1280, {0.55f, 0.70f, 0.85f, 1.f, 1.15f, 1.30f, 1.45f, 1.60f, 1.75f}}, - {1366, {0.55f, 0.70f, 0.85f, 1.f, 1.15f, 1.30f, 1.45f, 1.60f, 1.75f}}, - {1440, {0.55f, 0.70f, 0.85f, 1.f, 1.15f, 1.30f, 1.45f, 1.60f, 1.75f}}, - {1600, {0.55f, 0.70f, 0.85f, 1.f, 1.15f, 1.30f, 1.45f, 1.60f, 1.75f}}, - {1920, {0.55f, 0.70f, 0.85f, 1.f, 1.15f, 1.30f, 1.45f, 1.60f, 1.75f}}, - {2160, {0.60f, 0.80f, 1.f, 1.20f, 1.40f, 1.60f, 1.80f, 2.00f, 2.20f}}, - {2400, {0.75f, 1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f}}, - {2560, {0.75f, 1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f}}, - {2880, {0.75f, 1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f}}, - {3200, {1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f, 3.00f}}, - {3840, {1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f, 3.00f}}, - {4096, {1.f, 1.25f, 1.50f, 1.75f, 2.00f, 2.25f, 2.50f, 2.75f, 3.00f}}, - {5120, {1.f, 1.30f, 1.60f, 1.90f, 2.20f, 2.50f, 2.80f, 3.10f, 3.40f}}, - {7680, {1.f, 1.50f, 2.00f, 2.50f, 3.00f, 3.50f, 4.00f, 4.50f, 5.00f}}, - {8192, {1.f, 1.50f, 2.00f, 2.50f, 3.00f, 3.50f, 4.00f, 4.50f, 5.00f}}, - }; - - for (const auto& pair : expected_zoom_values) { - const int size = pair.first; - ManagedDisplayMode mode(gfx::Size(size, size), 60, false, true, 1.f, 1.f); + // The expected zoom list for the width given by |first| of the pair should be + // equal to the |second| of the pair. + constexpr std::array<ZoomListBucket, 4> kTestData{{ + {240, {0.60f, 0.65f, 0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f}}, + {720, {0.70f, 0.75f, 0.80f, 0.85f, 0.90f, 0.95f, 1.f, 1.05f, 1.10f}}, + {1024, {0.90f, 0.95f, 1.f, 1.05f, 1.10f, 1.15f, 1.20f, 1.25f, 1.30f}}, + {2400, {1.f, 1.10f, 1.15f, 1.20f, 1.30f, 1.40f, 1.50f, 1.75f, 2.00f}}, + }}; + for (const auto& data : kTestData) { + ManagedDisplayMode mode(gfx::Size(data.first, data.first), 60, false, true, + 1.f, 1.f); const std::vector<float> zoom_values = GetDisplayZoomFactors(mode); - EXPECT_FLOAT_EQ(zoom_values.size(), kNumOfZoomFactors); - for (std::size_t j = 0; j < kNumOfZoomFactors; j++) { - EXPECT_FLOAT_EQ(zoom_values[j], pair.second[j]); - - // Display pref stores the zoom value as double. This check ensures that - // the values dont lose precision. - // Before changing this line please ensure that you have updated - // chromeos/display/display_prefs.cc - double double_value = static_cast<double>(zoom_values[j]); - float float_value = static_cast<float>(double_value); - EXPECT_FLOAT_EQ(zoom_values[j], float_value); - } - - const int effective_minimum_width_possible = size / zoom_values.back(); - const int effective_maximum_width_possible = size * zoom_values.front(); - - const int allowed_minimum_width = std::min(kDefaultMinZoomWidth, size); - const int allowed_maximum_width = std::max(kDefaultMaxZoomWidth, size); - - EXPECT_GE(effective_minimum_width_possible, allowed_minimum_width); - EXPECT_LE(effective_maximum_width_possible, allowed_maximum_width); + for (std::size_t j = 0; j < kNumOfZoomFactors; j++) + EXPECT_FLOAT_EQ(zoom_values[j], data.second[j]); } } TEST_F(DisplayUtilTest, DisplayZoomsWithInternalDsf) { - const std::vector<int> sizes = {1280, 1366, 1440, 1600, 1920, - 2160, 2400, 2560, 2880, 3200, - 3840, 4096, 5120, 7680, 8192}; + const std::vector<std::pair<float, std::vector<float>>> expected_zoom_values{ + {1.25f, {1.f / 1.25f, 0.85f, 0.9f, 0.95f, 1.f, 1.05f, 1.1f, 1.15f, 1.2f}}, + {1.5f, {1.f / 1.5f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1.f, 1.05f}}, + {1.6f, {1.f / 1.6f, 0.65f, 0.7f, 0.75f, 0.8f, 0.85f, 0.9f, 0.95f, 1.f}}, + {1.8f, {1.f / 1.8f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.2f, 1.3f}}, + {2.f, {1.f / 2.f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.2f, 1.3f}}, + {2.25f, {1.f / 2.25f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.f, 1.1f, 1.2f}}}; - const std::vector<float> dsfs = {1.25f, 1.5f, 1.6f, 1.8f, 2.f, 2.25f}; - - for (float dsf : dsfs) { - for (int size : sizes) { - ManagedDisplayMode mode(gfx::Size(size, size), 60, false, true, 1.f, dsf); - const std::vector<float> zoom_values = GetDisplayZoomFactors(mode); - - const int effective_size = std::round(static_cast<float>(size) / dsf); - ManagedDisplayMode expected_mode( - gfx::Size(effective_size, effective_size), 60, false, true, 1.f, 1.f); - const std::vector<float> expected_zoom_values = - GetDisplayZoomFactors(expected_mode); - EXPECT_EQ(zoom_values.size(), kNumOfZoomFactors); - - // There should be exactly 1 entry for the inverse dsf in the list. - const float inverse_dsf = 1.f / dsf; - const std::size_t count_of_inverse_dsf = - std::count_if(zoom_values.begin(), zoom_values.end(), - [inverse_dsf](float zoom_value) -> bool { - return WithinEpsilon(zoom_value, inverse_dsf); - }); - EXPECT_EQ(count_of_inverse_dsf, 1UL); - - // Check all values in |zoom_values| are present in |expected_zoom_values| - // except for |inverse_dsf|. - auto it = expected_zoom_values.begin(); - for (const auto& zoom_value : zoom_values) { - // |inverse_dsf| is not expected to be in the expected list since it was - // added later on. - if (WithinEpsilon(zoom_value, inverse_dsf)) - continue; - - // Check if |zoom_value| is present in |expected_zoom_values|. - it = std::find_if(it, expected_zoom_values.end(), - [&zoom_value](float expected_zoom) -> bool { - return WithinEpsilon(zoom_value, expected_zoom); - }); - EXPECT_TRUE(it != expected_zoom_values.end()) - << zoom_value << " not found"; - } - - const int effective_minimum_width_possible = size / zoom_values.back(); - const int effective_maximum_width_possible = size * zoom_values.front(); - - const int allowed_minimum_width = std::min(kDefaultMinZoomWidth, size); - const int allowed_maximum_width = std::max(kDefaultMaxZoomWidth, size); - - EXPECT_GE(effective_minimum_width_possible, allowed_minimum_width); - EXPECT_LE(effective_maximum_width_possible, allowed_maximum_width); - } + for (const auto& pair : expected_zoom_values) { + const std::vector<float> zoom_values = + GetDisplayZoomFactorForDsf(pair.first); + for (std::size_t j = 0; j < kNumOfZoomFactors; j++) + EXPECT_FLOAT_EQ(zoom_values[j], pair.second[j]); } }
diff --git a/ui/ozone/demo/BUILD.gn b/ui/ozone/demo/BUILD.gn index 9d8f85c..9e26636 100644 --- a/ui/ozone/demo/BUILD.gn +++ b/ui/ozone/demo/BUILD.gn
@@ -51,7 +51,6 @@ deps = [ ":ozone_demo_lib", - "//build/config:exe_and_shlib_deps", "//components/tracing:startup_tracing", "//gpu/vulkan:buildflags", "//ui/events/ozone:events_ozone_layout", @@ -82,7 +81,6 @@ deps = [ ":ozone_demo_lib", - "//build/config:exe_and_shlib_deps", "//components/tracing:startup_tracing", "//skia", "//ui/events/ozone:events_ozone_layout",
diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index 22a219b..e6cf1d8 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc
@@ -845,6 +845,9 @@ if (font_list) return *font_list; } + + if (GetMenuController() && GetMenuController()->use_touchable_layout()) + return style::GetFont(style::CONTEXT_TOUCH_MENU, style::STYLE_PRIMARY); return MenuConfig::instance().font_list; }
diff --git a/ui/views/examples/BUILD.gn b/ui/views/examples/BUILD.gn index 661329c..750ae529 100644 --- a/ui/views/examples/BUILD.gn +++ b/ui/views/examples/BUILD.gn
@@ -111,7 +111,6 @@ "//base", "//base:i18n", "//base/test:test_support", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//components/viz/host", "//ui/base", @@ -172,7 +171,6 @@ ":copy_content_resources", ":views_examples_with_content_lib", "//base", - "//build/config:exe_and_shlib_deps", "//build/win:default_exe_manifest", "//content", "//content:sandbox_helper_win",
diff --git a/ui/views/style/typography_provider.cc b/ui/views/style/typography_provider.cc index e208380..2f0f2718 100644 --- a/ui/views/style/typography_provider.cc +++ b/ui/views/style/typography_provider.cc
@@ -115,7 +115,7 @@ *size_delta = ui::kTitleFontSizeDelta; break; case style::CONTEXT_TOUCH_MENU: - *size_delta = -1; + *size_delta = 2; break; default: *size_delta = ui::kLabelFontSizeDelta;
diff --git a/webrunner/BUILD.gn b/webrunner/BUILD.gn index 2895a4be..4fdf039 100644 --- a/webrunner/BUILD.gn +++ b/webrunner/BUILD.gn
@@ -11,7 +11,6 @@ deps = [ ":webrunner_pak", "//base", - "//build/config:exe_and_shlib_deps", "//components/version_info", "//content/public/app:both", "//content/public/browser",